Commit e8b82966 authored by Vitja Makarov's avatar Vitja Makarov

Use cf prefix for control-flow related members

parent 51af284d
...@@ -383,9 +383,9 @@ def check_definitions(flow, compiler_directives): ...@@ -383,9 +383,9 @@ def check_definitions(flow, compiler_directives):
else: else:
state[stat.entry] = set([Uninitialized]) state[stat.entry] = set([Uninitialized])
assignments.add(stat) assignments.add(stat)
stat.entry._assignments.append(stat) stat.entry.cf_assignments.append(stat)
elif isinstance(stat, NameReference): elif isinstance(stat, NameReference):
stat.entry.references.append(stat) stat.entry.cf_references.append(stat)
if Uninitialized in state[stat.entry]: if Uninitialized in state[stat.entry]:
if stat.entry.from_closure: if stat.entry.from_closure:
pass # Can be uninitialized here pass # Can be uninitialized here
...@@ -406,21 +406,21 @@ def check_definitions(flow, compiler_directives): ...@@ -406,21 +406,21 @@ def check_definitions(flow, compiler_directives):
for assmt in assignments: for assmt in assignments:
if not assmt.refs and not assmt.entry.is_pyclass_attr \ if not assmt.refs and not assmt.entry.is_pyclass_attr \
and not assmt.entry.in_closure: and not assmt.entry.in_closure:
if assmt.entry.references and warn_unused_result: if assmt.entry.cf_references and warn_unused_result:
if assmt.is_arg: if assmt.is_arg:
messages.warning(assmt.pos, "Unused argument value '%s'" % assmt.entry.name) messages.warning(assmt.pos, "Unused argument value '%s'" % assmt.entry.name)
else: else:
messages.warning(assmt.pos, "Unused result in '%s'" % assmt.entry.name) messages.warning(assmt.pos, "Unused result in '%s'" % assmt.entry.name)
assmt.lhs.used = False assmt.lhs.cf_used = False
for entry in flow.entries: for entry in flow.entries:
if not entry.references and not entry.is_pyclass_attr and not entry.in_closure: if not entry.cf_references and not entry.is_pyclass_attr and not entry.in_closure:
# TODO: handle unused buffers # TODO: handle unused buffers
if entry.type.is_buffer: if entry.type.is_buffer:
entry.used = True entry.cf_used = True
continue continue
# TODO: starred args entries are not marked with is_arg flag # TODO: starred args entries are not marked with is_arg flag
for assmt in entry._assignments: for assmt in entry.cf_assignments:
if assmt.is_arg: if assmt.is_arg:
is_arg = True is_arg = True
break break
...@@ -430,11 +430,11 @@ def check_definitions(flow, compiler_directives): ...@@ -430,11 +430,11 @@ def check_definitions(flow, compiler_directives):
if warn_unused_arg: if warn_unused_arg:
messages.warning(entry.pos, "Unused argument '%s'" % entry.name) messages.warning(entry.pos, "Unused argument '%s'" % entry.name)
# TODO: handle unused arguments # TODO: handle unused arguments
entry.used = True entry.cf_used = True
else: else:
if warn_unused: if warn_unused:
messages.warning(entry.pos, "Unused entry '%s'" % entry.name) messages.warning(entry.pos, "Unused entry '%s'" % entry.name)
entry.used = False entry.cf_used = False
# Sort warnings by position # Sort warnings by position
messages.sort() messages.sort()
......
...@@ -186,6 +186,8 @@ class Entry(object): ...@@ -186,6 +186,8 @@ class Entry(object):
self.init = init self.init = init
self.overloaded_alternatives = [] self.overloaded_alternatives = []
self.assignments = [] self.assignments = []
self.cf_assignments = []
self.cf_references = []
def __repr__(self): def __repr__(self):
return "Entry(name=%s, type=%s)" % (self.name, self.type) return "Entry(name=%s, type=%s)" % (self.name, self.type)
......
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