1.1 --- a/micropython/inspect.py Mon Sep 06 01:08:58 2010 +0200
1.2 +++ b/micropython/inspect.py Tue Sep 07 01:07:23 2010 +0200
1.3 @@ -350,8 +350,8 @@
1.4 def new_branchpoint(self):
1.5 self.get_namespace()._new_branchpoint()
1.6
1.7 - def new_branch(self, loop_node=None):
1.8 - self.get_namespace()._new_branch(loop_node)
1.9 + def new_branch(self, node, loop=0):
1.10 + self.get_namespace()._new_branch(node, loop)
1.11
1.12 def abandon_branch(self):
1.13 self.get_namespace()._abandon_branch()
1.14 @@ -359,8 +359,8 @@
1.15 def shelve_branch(self):
1.16 self.get_namespace()._shelve_branch()
1.17
1.18 - def merge_branches(self):
1.19 - self.get_namespace()._merge_branches()
1.20 + def merge_branches(self, loop=0):
1.21 + self.get_namespace()._merge_branches(loop)
1.22
1.23 def define_attribute_user(self, node):
1.24
1.25 @@ -786,21 +786,20 @@
1.26 # Enter the loop.
1.27 # Propagate attribute usage to branches.
1.28
1.29 - self.new_branch(node)
1.30 + self.new_branch(node, 1)
1.31 self.dispatch(node.body)
1.32 self.shelve_branch()
1.33
1.34 self.in_loop = in_loop
1.35
1.36 - # Maintain a branch for the else clause or the current retained usage
1.37 - # where execution avoids the conditional clauses.
1.38 + # Maintain a branch for the else clause.
1.39
1.40 - self.new_branch()
1.41 if node.else_ is not None:
1.42 + self.new_branch(node.else_)
1.43 self.dispatch(node.else_)
1.44 - self.shelve_branch()
1.45 + self.shelve_branch()
1.46
1.47 - self.merge_branches()
1.48 + self.merge_branches(1)
1.49 return None
1.50
1.51 def visitFrom(self, node):
1.52 @@ -866,17 +865,16 @@
1.53 for test, body in node.tests:
1.54 self.dispatch(test)
1.55
1.56 - self.new_branch()
1.57 + self.new_branch(body)
1.58 self.dispatch(body)
1.59 self.shelve_branch()
1.60
1.61 - # Maintain a branch for the else clause or the current retained usage
1.62 - # where execution avoids the conditional clauses.
1.63 + # Maintain a branch for the else clause.
1.64
1.65 - self.new_branch()
1.66 if node.else_ is not None:
1.67 + self.new_branch(node.else_)
1.68 self.dispatch(node.else_)
1.69 - self.shelve_branch()
1.70 + self.shelve_branch()
1.71
1.72 self.merge_branches()
1.73 return None
1.74 @@ -934,7 +932,7 @@
1.75 # Enter the loop.
1.76 # Propagate attribute usage to branches.
1.77
1.78 - self.new_branch(node)
1.79 + self.new_branch(node, 1)
1.80
1.81 for if_ in node.ifs:
1.82 self.dispatch(if_)
1.83 @@ -942,7 +940,7 @@
1.84 self.shelve_branch()
1.85 self.in_loop = in_loop
1.86
1.87 - self.merge_branches()
1.88 + self.merge_branches(1)
1.89 return None
1.90
1.91 visitListCompIf = NOP
1.92 @@ -1000,7 +998,7 @@
1.93 self.new_branchpoint()
1.94
1.95 for name, var, n in node.handlers:
1.96 - self.new_branch()
1.97 + self.new_branch(name)
1.98
1.99 # Establish the local for the handler.
1.100
1.101 @@ -1011,10 +1009,10 @@
1.102
1.103 self.shelve_branch()
1.104
1.105 - self.new_branch()
1.106 if node.else_ is not None:
1.107 + self.new_branch(node.else_)
1.108 self.dispatch(node.else_)
1.109 - self.shelve_branch()
1.110 + self.shelve_branch()
1.111
1.112 self.merge_branches()
1.113 return None
1.114 @@ -1035,19 +1033,18 @@
1.115 in_loop = self.in_loop
1.116 self.in_loop = 1
1.117 self.dispatch(node.test)
1.118 - self.new_branch(node)
1.119 + self.new_branch(node, 1)
1.120 self.dispatch(node.body)
1.121 self.shelve_branch()
1.122 self.in_loop = in_loop
1.123
1.124 - # Maintain a branch for the else clause or the current retained usage
1.125 - # where execution avoids the conditional clauses.
1.126 + # Maintain a branch for the else clause.
1.127 # NOTE: Consider merging here before the else clause.
1.128
1.129 - self.new_branch()
1.130 if node.else_ is not None:
1.131 + self.new_branch(node.else_)
1.132 self.dispatch(node.else_)
1.133 - self.shelve_branch()
1.134 + self.shelve_branch()
1.135
1.136 self.merge_branches()
1.137 return None