fixed a little bug caused by not setting the parent of flows correctly

This commit is contained in:
David Halter
2012-07-05 15:55:19 +02:00
parent 70b3895e42
commit e88c11605b
3 changed files with 13 additions and 6 deletions

View File

@@ -314,7 +314,6 @@ class Function(object):
This is also the places where the decorators are processed.
"""
f = self.base_func
print 'dec', f
# only enter it, if has not already been processed
if not self.is_decorated:
@@ -347,7 +346,6 @@ class Function(object):
debug.dbg('decorator end', f)
if f != self.base_func and isinstance(f, parsing.Function):
f = Function(f)
print 'enddec', f
return f
def __getattr__(self, name):
@@ -455,7 +453,6 @@ class Execution(Executable):
result.append(self_name)
param_dict = {}
print 'base', self.base, self.base.params
for param in self.base.params:
param_dict[str(param.get_name())] = param
# There may be calls, which don't fit all the params, this just ignores
@@ -582,8 +579,6 @@ class Execution(Executable):
Call the default method with the own instance (self implements all
the necessary functions). Add also the params.
"""
a = self.get_params()
print 'params', a
return self.get_params() + parsing.Scope._get_set_vars(self)
@property

View File

@@ -363,6 +363,8 @@ class Flow(Scope):
:type set_vars: list
"""
def __init__(self, command, inits, indent, line_nr, set_vars=None):
self._parent = None
self.next = None
super(Flow, self).__init__(indent, line_nr, '')
self.command = command
# These have to be statements, because of with, which takes multiple.
@@ -375,7 +377,16 @@ class Flow(Scope):
self.set_vars = set_vars
for s in self.set_vars:
s.parent = self
self.next = None
@property
def parent(self):
return self._parent
@parent.setter
def parent(self, value):
self._parent = value
if self.next:
self.next.parent = value
def get_code(self, first_indent=False, indention=" "):
if self.set_vars:

View File

@@ -110,5 +110,6 @@ def memoize(function):
def follow_statement(stmt):
return stmt
# here we had problems with the else clause, because the parent was not right.
#? int()
follow_statement(1)