1.1 --- a/simplify.py Sun Dec 03 00:51:30 2006 +0100
1.2 +++ b/simplify.py Sun Dec 03 01:25:17 2006 +0100
1.3 @@ -223,9 +223,9 @@
1.4 if not in_sequence:
1.5 expr = LoadTemp()
1.6 else:
1.7 - expr = InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"), star=None, dstar=None, args=[])
1.8 + expr = InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"))
1.9 result = Assign(asslist, 1)
1.10 - store = StoreTemp(expr=InvokeFunction(expr=LoadAttr(name="__iter__", expr=expr), star=None, dstar=None, args=[]))
1.11 + store = StoreTemp(expr=InvokeFunction(expr=LoadAttr(name="__iter__", expr=expr)))
1.12 release = ReleaseTemp()
1.13 result.code = [store] + self.dispatches(asslist.nodes, 1) + [release]
1.14 return result
1.15 @@ -236,7 +236,7 @@
1.16 if not in_sequence:
1.17 return LoadTemp()
1.18 else:
1.19 - return InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"), star=None, dstar=None, args=[])
1.20 + return InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"))
1.21
1.22 def visitAssName(self, assname, in_sequence=0):
1.23 expr = self._visitAssNameOrAttr(assname, in_sequence)
1.24 @@ -650,7 +650,7 @@
1.25 body=[
1.26 Assign(
1.27 code=[
1.28 - StoreTemp(expr=InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"), args=[], star=None, dstar=None)),
1.29 + StoreTemp(expr=InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"))),
1.30 self.dispatch(for_.assign),
1.31 ReleaseTemp()
1.32 ])
1.33 @@ -684,22 +684,26 @@
1.34 # Obtain an iterator for the sequence involved.
1.35 # Then, make an invocation of the subprogram.
1.36
1.37 - result = Assign(for_, 1)
1.38 - result.code = [
1.39 - StoreTemp(
1.40 - expr=InvokeFunction(
1.41 - expr=LoadAttr(
1.42 - name="__iter__",
1.43 - expr=self.dispatch(for_.list)
1.44 - ),
1.45 - args=[],
1.46 - star=None,
1.47 - dstar=None
1.48 - )
1.49 - ),
1.50 - InvokeBlock(expr=LoadRef(ref=subprogram)),
1.51 - ReleaseTemp()
1.52 - ]
1.53 + result = Assign(for_, 1,
1.54 + code=[
1.55 + StoreTemp(
1.56 + expr=InvokeFunction(
1.57 + expr=LoadAttr(
1.58 + name="__iter__",
1.59 + expr=self.dispatch(for_.list)
1.60 + )
1.61 + )
1.62 + ),
1.63 + InvokeBlock(expr=LoadRef(ref=subprogram)),
1.64 + ReleaseTemp()
1.65 + ]
1.66 + )
1.67 +
1.68 + # Make nice annotations for the viewer.
1.69 +
1.70 + for_._iter_call = result.code[0].expr
1.71 + for_._next_call = subprogram.code[0].body[0].code[0].expr
1.72 +
1.73 return result
1.74
1.75 def visitFrom(self, from_):
1.76 @@ -747,14 +751,14 @@
1.77 if has_star:
1.78 star = (
1.79 function.argnames[npositional],
1.80 - InvokeFunction(expr=LoadName(name="list"), args=[], star=None, dstar=None)
1.81 + InvokeFunction(expr=LoadName(name="list"))
1.82 )
1.83 else:
1.84 star = None
1.85 if has_dstar:
1.86 dstar = (
1.87 function.argnames[npositional + has_star],
1.88 - InvokeFunction(expr=LoadName(name="dict"), args=[], star=None, dstar=None)
1.89 + InvokeFunction(expr=LoadName(name="dict"))
1.90 )
1.91 else:
1.92 dstar = None
1.93 @@ -853,9 +857,7 @@
1.94 expr=self.dispatch(compare),
1.95 name="__bool__"
1.96 ),
1.97 - args=[],
1.98 - star=None,
1.99 - dstar=None)
1.100 + )
1.101 )
1.102 test.body = self.dispatch(stmt)
1.103 nodes.append(test)
1.104 @@ -921,9 +923,6 @@
1.105 expr=expr,
1.106 name="__bool__"
1.107 ),
1.108 - args=[],
1.109 - star=None,
1.110 - dstar=None
1.111 )
1.112 if not_ is not None:
1.113 result = Not(not_, 1, expr=invocation)
1.114 @@ -968,7 +967,7 @@
1.115
1.116 if node is not last:
1.117 nodes.append(StoreTemp(expr=expr))
1.118 - invocation = InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="__bool__"), args=[], star=None, dstar=None)
1.119 + invocation = InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="__bool__"))
1.120 test = Conditional(test=invocation, body=[ReturnFromBlock(expr=LoadTemp())])
1.121 nodes.append(test)
1.122
1.123 @@ -1328,9 +1327,6 @@
1.124 expr=LoadAttr(
1.125 expr=self.dispatch(while_.test),
1.126 name="__bool__"),
1.127 - args=[],
1.128 - star=None,
1.129 - dstar=None
1.130 ),
1.131 body=self.dispatch(while_.body) + [
1.132 InvokeBlock(
1.133 @@ -1358,6 +1354,11 @@
1.134 result = InvokeBlock(while_, 1,
1.135 expr=LoadRef(ref=subprogram)
1.136 )
1.137 +
1.138 + # Make nice annotations for the viewer.
1.139 +
1.140 + while_._test_call = subprogram.code[0].test
1.141 +
1.142 return result
1.143
1.144 # Convenience methods.
1.145 @@ -1412,8 +1413,16 @@
1.146 self.current_subprograms.pop()
1.147 self.subprograms.append(subprogram); self.subnames[subprogram.full_name()] = subprogram
1.148
1.149 - result = InvokeBlock(produces_result=1)
1.150 - result.expr = LoadRef(ref=subprogram)
1.151 + result = InvokeBlock(
1.152 + produces_result=1,
1.153 + expr=LoadRef(ref=subprogram)
1.154 + )
1.155 +
1.156 + # Make nice annotations for the viewer.
1.157 +
1.158 + binary._left_call = subprogram.code[0].body[0].expr
1.159 + binary._right_call = subprogram.code[0].handler[0].body[0].expr
1.160 +
1.161 return result
1.162
1.163 def _visitBuiltin(self, builtin, name):
1.164 @@ -1421,16 +1430,19 @@
1.165 return result
1.166
1.167 def _visitUnary(self, unary, name):
1.168 - return InvokeFunction(unary, 1,
1.169 + result = InvokeFunction(unary, 1,
1.170 expr=LoadAttr(
1.171 expr=self.dispatch(unary.expr),
1.172 name=name
1.173 - ),
1.174 - args=[],
1.175 - star=None,
1.176 - dstar=None
1.177 + )
1.178 )
1.179
1.180 + # Make nice annotations for the viewer.
1.181 +
1.182 + unary._unary_call = result
1.183 +
1.184 + return result
1.185 +
1.186 # Convenience functions.
1.187
1.188 def simplify(filename, builtins=0):