split param stuff from remove_statements - which is now finally a simple method

This commit is contained in:
Dave Halter
2014-01-07 12:02:33 +01:00
parent 66ec389f5c
commit 35640abd82
+28 -23
View File
@@ -161,14 +161,13 @@ class NameFinder(object):
elif typ.isinstance(pr.Statement): elif typ.isinstance(pr.Statement):
types += self._remove_statements(typ, resolve_decorator) types += self._remove_statements(typ, resolve_decorator)
else: else:
r = typ if isinstance(typ, pr.Class):
if isinstance(r, pr.Class): typ = er.Class(self._evaluator, typ)
r = er.Class(self._evaluator, r) elif isinstance(typ, pr.Function):
elif isinstance(r, pr.Function): typ = er.Function(self._evaluator, typ)
r = er.Function(self._evaluator, r) if typ.isinstance(er.Function) and resolve_decorator:
if r.isinstance(er.Function) and resolve_decorator: typ = typ.get_decorated_func()
r = r.get_decorated_func() types.append(typ)
types.append(r)
return types return types
def _remove_statements(self, r, resolve_decorator=False): def _remove_statements(self, r, resolve_decorator=False):
@@ -190,12 +189,31 @@ class NameFinder(object):
if r.is_global(): if r.is_global():
for token_name in r.token_list[1:]: for token_name in r.token_list[1:]:
if isinstance(token_name, pr.Name): if isinstance(token_name, pr.Name):
add = evaluator.find_types(r.parent, str(token_name)) return evaluator.find_types(r.parent, str(token_name))
else: else:
# generated objects are used within executions, but these # generated objects are used within executions, but these
# objects are in functions, and we have to dynamically # objects are in functions, and we have to dynamically
# execute first. # execute first.
if isinstance(r, pr.Param): if isinstance(r, pr.Param):
return self._eval_param(r)
# Remove the statement docstr stuff for now, that has to be
# implemented with the evaluator class.
#if r.docstr:
#res_new.append(r)
add += evaluator.eval_statement(r, seek_name=self.name_str)
if check_instance is not None:
# class renames
add = [er.InstanceElement(evaluator, check_instance, a, True)
if isinstance(a, (er.Function, pr.Function))
else a for a in add]
return res_new + add
def _eval_param(self, r):
evaluator = self._evaluator
res_new = []
func = r.parent func = r.parent
exc = pr.Class, pr.Function exc = pr.Class, pr.Function
@@ -243,20 +261,7 @@ class NameFinder(object):
# this means that there are no default params, # this means that there are no default params,
# so just ignore it. # so just ignore it.
return res_new return res_new
# Remove the statement docstr stuff for now, that has to be return set(res_new) | evaluator.eval_statement(r, seek_name=self.name_str)
# implemented with the evaluator class.
#if r.docstr:
#res_new.append(r)
add += evaluator.eval_statement(r, seek_name=self.name_str)
if check_instance is not None:
# class renames
add = [er.InstanceElement(evaluator, check_instance, a, True)
if isinstance(a, (er.Function, pr.Function))
else a for a in add]
return res_new + add
def _handle_for_loops(self, loop): def _handle_for_loops(self, loop):
# Take the first statement (for has always only # Take the first statement (for has always only