|
@@ -8,9 +8,9 @@ class ConstructorsVisitor(Visitor):
|
|
|
self.free_id = 0
|
|
|
|
|
|
def dump(self):
|
|
|
+ print '\n'.join([repr(x) for x in self.constructors])
|
|
|
return self.constructors
|
|
|
# return pickle.dumps(self.constructors, pickle.HIGHEST_PROTOCOL)
|
|
|
- # return '\n'.join([repr(x) for x in self.constructors])
|
|
|
|
|
|
def add_constructors(self, *constructors):
|
|
|
self.constructors.extend(constructors)
|
|
@@ -27,7 +27,7 @@ class ConstructorsVisitor(Visitor):
|
|
|
# tree.get_tail_without(["newline", "funcdecl"])
|
|
|
last = tail[-1]
|
|
|
for child in tail[:-1]:
|
|
|
- if child.head == "return":
|
|
|
+ if child.head in ["return", "break", "continue"]:
|
|
|
last = child
|
|
|
break
|
|
|
else:
|
|
@@ -41,7 +41,7 @@ class ConstructorsVisitor(Visitor):
|
|
|
if last.head == "func_call": # pop 'false'
|
|
|
self.constructors.pop()
|
|
|
if new_constructors_were_added:
|
|
|
- if last.head not in frozenset(["return", "continue", "break"]):
|
|
|
+ if last.head not in ["return", "break", "continue"]:
|
|
|
self.add_constructors(False)
|
|
|
elif self.constructors:
|
|
|
self.constructors.pop() # pop 'true'
|
|
@@ -196,7 +196,7 @@ class ConstructorsVisitor(Visitor):
|
|
|
tail = tree.get_tail_without(["newline", "indent"])
|
|
|
last = tail[-1]
|
|
|
for child in tail[:-1]:
|
|
|
- if child.head == "return":
|
|
|
+ if child.head in ["return", "break", "continue"]:
|
|
|
last = child
|
|
|
break
|
|
|
else:
|
|
@@ -207,7 +207,7 @@ class ConstructorsVisitor(Visitor):
|
|
|
self.visit(last)
|
|
|
if last.head == "func_call": # pop 'false'
|
|
|
self.constructors.pop()
|
|
|
- if last.head != "return":
|
|
|
+ if last.head not in ["return", "break", "continue"]:
|
|
|
self.add_constructors(False)
|
|
|
|
|
|
def visit_func_body(self, tree):
|