Commit 0c0037ca authored by Robert Bradshaw's avatar Robert Bradshaw

type cleanup

parent 0a77df1d
...@@ -1031,14 +1031,6 @@ def p_from_import_statement(s, first_statement = 0): ...@@ -1031,14 +1031,6 @@ def p_from_import_statement(s, first_statement = 0):
s.context.future_directives.add(directive) s.context.future_directives.add(directive)
return Nodes.PassStatNode(pos) return Nodes.PassStatNode(pos)
elif kind == 'cimport': elif kind == 'cimport':
for (name_pos, name, as_name, kind) in imported_names:
local_name = as_name or name
if local_name == "*" and False:
module = s.context.find_module(dotted_name)
for type in module.type_entries:
s.add_type_name(type.name)
else:
s.add_type_name(local_name)
return Nodes.FromCImportStatNode(pos, return Nodes.FromCImportStatNode(pos,
module_name = dotted_name, module_name = dotted_name,
imported_names = imported_names) imported_names = imported_names)
...@@ -1856,8 +1848,6 @@ def p_c_simple_declarator(s, ctx, empty, is_type, cmethod_flag, ...@@ -1856,8 +1848,6 @@ def p_c_simple_declarator(s, ctx, empty, is_type, cmethod_flag,
rhs = None rhs = None
if s.sy == 'IDENT': if s.sy == 'IDENT':
name = EncodedString(s.systring) name = EncodedString(s.systring)
if is_type:
s.add_type_name(name)
if empty: if empty:
error(s.position(), "Declarator should be empty") error(s.position(), "Declarator should be empty")
s.next() s.next()
...@@ -2042,7 +2032,6 @@ def p_c_enum_definition(s, pos, ctx): ...@@ -2042,7 +2032,6 @@ def p_c_enum_definition(s, pos, ctx):
if s.sy == 'IDENT': if s.sy == 'IDENT':
name = s.systring name = s.systring
s.next() s.next()
s.add_type_name(name)
cname = p_opt_cname(s) cname = p_opt_cname(s)
else: else:
name = None name = None
...@@ -2092,7 +2081,6 @@ def p_c_struct_or_union_definition(s, pos, ctx): ...@@ -2092,7 +2081,6 @@ def p_c_struct_or_union_definition(s, pos, ctx):
s.next() s.next()
name = p_ident(s) name = p_ident(s)
cname = p_opt_cname(s) cname = p_opt_cname(s)
s.add_type_name(name)
attributes = None attributes = None
if s.sy == ':': if s.sy == ':':
s.next() s.next()
...@@ -2286,7 +2274,6 @@ def p_c_class_definition(s, pos, ctx): ...@@ -2286,7 +2274,6 @@ def p_c_class_definition(s, pos, ctx):
as_name = p_ident(s) as_name = p_ident(s)
else: else:
as_name = class_name as_name = class_name
s.add_type_name(as_name)
objstruct_name = None objstruct_name = None
typeobj_name = None typeobj_name = None
base_class_module = None base_class_module = None
...@@ -2387,8 +2374,6 @@ def p_doc_string(s): ...@@ -2387,8 +2374,6 @@ def p_doc_string(s):
return None return None
def p_code(s, level=None): def p_code(s, level=None):
s.add_type_name("object")
s.add_type_name("Py_buffer")
body = p_statement_list(s, Ctx(level = level), first_statement = 1) body = p_statement_list(s, Ctx(level = level), first_statement = 1)
if s.sy != 'EOF': if s.sy != 'EOF':
s.error("Syntax error in statement [%s,%s]" % ( s.error("Syntax error in statement [%s,%s]" % (
...@@ -2413,8 +2398,6 @@ def p_compiler_directive_comments(s): ...@@ -2413,8 +2398,6 @@ def p_compiler_directive_comments(s):
return result return result
def p_module(s, pxd, full_module_name): def p_module(s, pxd, full_module_name):
s.add_type_name("object")
s.add_type_name("Py_buffer")
pos = s.position() pos = s.position()
doc = p_doc_string(s) doc = p_doc_string(s)
if pxd: if pxd:
......
...@@ -282,7 +282,6 @@ class StringSourceDescriptor(SourceDescriptor): ...@@ -282,7 +282,6 @@ class StringSourceDescriptor(SourceDescriptor):
class PyrexScanner(Scanner): class PyrexScanner(Scanner):
# context Context Compilation context # context Context Compilation context
# type_names set Identifiers to be treated as type names
# included_files [string] Files included with 'include' statement # included_files [string] Files included with 'include' statement
# compile_time_env dict Environment for conditional compilation # compile_time_env dict Environment for conditional compilation
# compile_time_eval boolean In a true conditional compilation context # compile_time_eval boolean In a true conditional compilation context
...@@ -294,14 +293,12 @@ class PyrexScanner(Scanner): ...@@ -294,14 +293,12 @@ class PyrexScanner(Scanner):
Scanner.__init__(self, get_lexicon(), file, filename) Scanner.__init__(self, get_lexicon(), file, filename)
if parent_scanner: if parent_scanner:
self.context = parent_scanner.context self.context = parent_scanner.context
self.type_names = parent_scanner.type_names
self.included_files = parent_scanner.included_files self.included_files = parent_scanner.included_files
self.compile_time_env = parent_scanner.compile_time_env self.compile_time_env = parent_scanner.compile_time_env
self.compile_time_eval = parent_scanner.compile_time_eval self.compile_time_eval = parent_scanner.compile_time_eval
self.compile_time_expr = parent_scanner.compile_time_expr self.compile_time_expr = parent_scanner.compile_time_expr
else: else:
self.context = context self.context = context
self.type_names = scope.type_names
self.included_files = scope.included_files self.included_files = scope.included_files
self.compile_time_env = initial_compile_time_env() self.compile_time_env = initial_compile_time_env()
self.compile_time_eval = 1 self.compile_time_eval = 1
...@@ -431,12 +428,6 @@ class PyrexScanner(Scanner): ...@@ -431,12 +428,6 @@ class PyrexScanner(Scanner):
# This method should be added to Plex # This method should be added to Plex
self.queue.insert(0, (token, value)) self.queue.insert(0, (token, value))
def add_type_name(self, name):
self.type_names[name] = 1
def looking_at_type_name(self):
return self.sy == 'IDENT' and self.systring in self.type_names
def error(self, message, pos = None, fatal = True): def error(self, message, pos = None, fatal = True):
if pos is None: if pos is None:
pos = self.position() pos = self.position()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment