Commit 025ae157 authored by Vitja Makarov's avatar Vitja Makarov

mark_assignment: lookup for entry in current scope if None

--HG--
extra : transplant_source : %05%25%06%D81g%C21%BB%0Fj%D5%C9%82%A4%8E%28%C9lA
parent 64bc49f4
......@@ -54,7 +54,7 @@ cdef class ControlFlow:
cpdef nextblock(self, parent=*)
cpdef bint is_tracked(self, entry)
cpdef mark_position(self, node)
cpdef mark_assignment(self, lhs, rhs, entry=*)
cpdef mark_assignment(self, lhs, rhs, entry)
cpdef mark_argument(self, lhs, rhs, entry)
cpdef mark_deletion(self, node, entry)
cpdef mark_reference(self, node, entry)
......
......@@ -153,10 +153,8 @@ class ControlFlow(object):
if self.block:
self.block.positions.add(node.pos[:2])
def mark_assignment(self, lhs, rhs, entry=None):
def mark_assignment(self, lhs, rhs, entry):
if self.block:
if entry is None:
entry = lhs.entry
if not self.is_tracked(entry):
return
assignment = NameAssignment(lhs, rhs, entry)
......@@ -625,7 +623,10 @@ class CreateControlFlowGraph(CythonTransform):
def visit_DefNode(self, node):
## XXX: no target name node here
node.used = True
self.flow.mark_assignment(node, object_expr, self.env.lookup(node.name))
entry = node.entry
if entry.is_anonymous:
entry = self.env.lookup(node.name)
self.flow.mark_assignment(node, object_expr, entry)
return self.visit_FuncDefNode(node)
def visit_GeneratorBodyDefNode(self, node):
......@@ -649,10 +650,13 @@ class CreateControlFlowGraph(CythonTransform):
if not rhs:
rhs = object_expr
if lhs.is_name:
if lhs.entry is None:
# TODO: This shouldn't happen...
if lhs.entry is not None:
entry = lhs.entry
else:
entry = self.env.lookup(lhs.name)
if entry is None: # TODO: This shouldn't happen...
return
self.flow.mark_assignment(lhs, rhs)
self.flow.mark_assignment(lhs, rhs, entry)
elif isinstance(lhs, ExprNodes.SequenceNode):
for arg in lhs.args:
self.mark_assignment(arg)
......
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