Commit cf89a114 authored by Vitja Makarov's avatar Vitja Makarov

TypeInference: use CF collected assignments

parent 8c5aa3ef
...@@ -112,7 +112,6 @@ class Entry(object): ...@@ -112,7 +112,6 @@ class Entry(object):
# buffer_aux BufferAux or None Extra information needed for buffer variables # buffer_aux BufferAux or None Extra information needed for buffer variables
# inline_func_in_pxd boolean Hacky special case for inline function in pxd file. # inline_func_in_pxd boolean Hacky special case for inline function in pxd file.
# Ideally this should not be necesarry. # Ideally this should not be necesarry.
# assignments [ExprNode] List of expressions that get assigned to this entry.
# might_overflow boolean In an arithmetic expression that could cause # might_overflow boolean In an arithmetic expression that could cause
# overflow (used for type inference). # overflow (used for type inference).
# utility_code_definition For some Cython builtins, the utility code # utility_code_definition For some Cython builtins, the utility code
...@@ -193,7 +192,6 @@ class Entry(object): ...@@ -193,7 +192,6 @@ class Entry(object):
self.pos = pos self.pos = pos
self.init = init self.init = init
self.overloaded_alternatives = [] self.overloaded_alternatives = []
self.assignments = []
self.cf_assignments = [] self.cf_assignments = []
self.cf_references = [] self.cf_references = []
......
...@@ -31,7 +31,6 @@ class MarkAssignments(EnvTransform): ...@@ -31,7 +31,6 @@ class MarkAssignments(EnvTransform):
if lhs.entry is None: if lhs.entry is None:
# TODO: This shouldn't happen... # TODO: This shouldn't happen...
return return
lhs.entry.assignments.append(rhs)
if self.parallel_block_stack: if self.parallel_block_stack:
parallel_node = self.parallel_block_stack[-1] parallel_node = self.parallel_block_stack[-1]
...@@ -359,8 +358,8 @@ class SimpleAssignmentTypeInferer(object): ...@@ -359,8 +358,8 @@ class SimpleAssignmentTypeInferer(object):
entry.type = py_object_type entry.type = py_object_type
continue continue
all = set() all = set()
for expr in entry.assignments: for assmt in entry.cf_assignments:
all.update(expr.type_dependencies(scope)) all.update(assmt.rhs.type_dependencies(scope))
if all: if all:
dependancies_by_entry[entry] = all dependancies_by_entry[entry] = all
for dep in all: for dep in all:
...@@ -384,7 +383,8 @@ class SimpleAssignmentTypeInferer(object): ...@@ -384,7 +383,8 @@ class SimpleAssignmentTypeInferer(object):
while True: while True:
while ready_to_infer: while ready_to_infer:
entry = ready_to_infer.pop() entry = ready_to_infer.pop()
types = [expr.infer_type(scope) for expr in entry.assignments] types = [assmt.rhs.infer_type(scope)
for assmt in entry.cf_assignments]
if types and Utils.all(types): if types and Utils.all(types):
entry.type = spanning_type(types, entry.might_overflow) entry.type = spanning_type(types, entry.might_overflow)
else: else:
...@@ -397,10 +397,13 @@ class SimpleAssignmentTypeInferer(object): ...@@ -397,10 +397,13 @@ class SimpleAssignmentTypeInferer(object):
# Deal with simple circular dependancies... # Deal with simple circular dependancies...
for entry, deps in dependancies_by_entry.items(): for entry, deps in dependancies_by_entry.items():
if len(deps) == 1 and deps == set([entry]): if len(deps) == 1 and deps == set([entry]):
types = [expr.infer_type(scope) for expr in entry.assignments if expr.type_dependencies(scope) == ()] types = [assmt.rhs.infer_type(scope)
for assmt in entry.cf_assignments
if assmt.rhs.type_dependencies(scope) == ()]
if types: if types:
entry.type = spanning_type(types, entry.might_overflow) entry.type = spanning_type(types, entry.might_overflow)
types = [expr.infer_type(scope) for expr in entry.assignments] types = [assmt.rhs.infer_type(scope)
for assmt in entry.cf_assignments]
entry.type = spanning_type(types, entry.might_overflow) # might be wider... entry.type = spanning_type(types, entry.might_overflow) # might be wider...
resolve_dependancy(entry) resolve_dependancy(entry)
del dependancies_by_entry[entry] del dependancies_by_entry[entry]
......
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