moved a few closures around in NameFinder
This commit is contained in:
1 parent
53dbec52ab
commit
0e69ad478b
1 file changed
+10
-10
+10
-10
@@ -110,12 +110,7 @@ class NameFinder(object):
|
||||
debug.dbg('sfn remove, new: %s, old: %s' % (res_new, result))
|
||||
return res_new
|
||||
|
||||
def filter_name(self, scope_generator, is_goto=False):
|
||||
"""
|
||||
Filters all variables of a scope (which are defined in the
|
||||
`scope_generator`), until the name fits.
|
||||
"""
|
||||
def handle_for_loops(loop):
|
||||
def _handle_for_loops(self, loop):
|
||||
# Take the first statement (for has always only
|
||||
# one, remember `in`). And follow it.
|
||||
if not loop.inputs:
|
||||
@@ -128,7 +123,7 @@ class NameFinder(object):
|
||||
result = evaluate._assign_tuples(expression_list[0], result, self.name_str)
|
||||
return result
|
||||
|
||||
def process(name):
|
||||
def _process(self, name):
|
||||
"""
|
||||
Returns the parent of a name, which means the element which stands
|
||||
behind a name.
|
||||
@@ -144,7 +139,7 @@ class NameFinder(object):
|
||||
pass
|
||||
elif par.isinstance(pr.Flow):
|
||||
if par.command == 'for':
|
||||
result += handle_for_loops(par)
|
||||
result += self._handle_for_loops(par)
|
||||
else:
|
||||
debug.warning('Flow: Why are you here? %s' % par.command)
|
||||
elif par.isinstance(pr.Param) \
|
||||
@@ -203,6 +198,11 @@ class NameFinder(object):
|
||||
result.append(par)
|
||||
return result, no_break_scope, is_array_assignment
|
||||
|
||||
def filter_name(self, scope_generator, is_goto=False):
|
||||
"""
|
||||
Filters all variables of a scope (which are defined in the
|
||||
`scope_generator`), until the name fits.
|
||||
"""
|
||||
flow_scope = self.scope
|
||||
result = []
|
||||
# compare func uses the tuple of line/indent = line/column
|
||||
@@ -217,7 +217,7 @@ class NameFinder(object):
|
||||
and isinstance(p.var, pr.Class):
|
||||
p = p.var
|
||||
if self.name_str == name.get_code() and p not in break_scopes:
|
||||
r, no_break_scope, is_array_assignment = process(name)
|
||||
r, no_break_scope, is_array_assignment = self._process(name)
|
||||
if is_goto:
|
||||
if not is_array_assignment: # shouldn't goto arr[1] =
|
||||
result.append(name)
|
||||
@@ -258,7 +258,7 @@ class NameFinder(object):
|
||||
|
||||
def find(self, scopes, resolve_decorator=True):
|
||||
filtered = self.filter_name(scopes)
|
||||
print 'f', filtered
|
||||
#print 'f', filtered
|
||||
return self._resolve_descriptors(self._remove_statements(filtered,
|
||||
resolve_decorator))
|
||||
|
||||
|
||||
Reference in new issue
Block a user