1.1 --- a/simplify.py Thu Jan 25 01:03:33 2007 +0100
1.2 +++ b/simplify.py Fri Jan 26 00:05:20 2007 +0100
1.3 @@ -224,9 +224,9 @@
1.4 if not in_sequence:
1.5 expr = LoadTemp()
1.6 else:
1.7 - expr = InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"))
1.8 + expr = InvokeFunction(asslist, expr=LoadAttr(expr=LoadTemp(), name="next"))
1.9 result = Assign(asslist, 1)
1.10 - store = StoreTemp(expr=InvokeFunction(expr=LoadAttr(name="__iter__", expr=expr)))
1.11 + store = StoreTemp(expr=InvokeFunction(asslist, 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 @@ -237,7 +237,7 @@
1.16 if not in_sequence:
1.17 return LoadTemp()
1.18 else:
1.19 - return InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"))
1.20 + return InvokeFunction(node, 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 @@ -277,6 +277,7 @@
1.25 result.code = [
1.26 StoreTemp(
1.27 expr=InvokeFunction( # referenced below
1.28 + augassign,
1.29 args=[expr],
1.30 star=None,
1.31 dstar=None,
1.32 @@ -309,6 +310,7 @@
1.33 ),
1.34 StoreTemp(
1.35 expr=InvokeFunction( # referenced below
1.36 + augassign,
1.37 args=[expr], star=None, dstar=None,
1.38 expr=LoadAttr(
1.39 expr=LoadAttr(augassign.node, 1,
1.40 @@ -353,6 +355,7 @@
1.41 ),
1.42 StoreTemp(
1.43 expr=InvokeFunction( # referenced below
1.44 + augassign,
1.45 args=[expr], star=None, dstar=None,
1.46 expr=LoadAttr(
1.47 expr=self._visitSlice(
1.48 @@ -394,6 +397,7 @@
1.49 StoreTemp(index="subs", expr=self._visitSubscriptSubs(augassign.node, augassign.node.subs)),
1.50 StoreTemp(
1.51 expr=InvokeFunction( # referenced below
1.52 + augassign,
1.53 args=[expr], star=None, dstar=None,
1.54 expr=LoadAttr(
1.55 expr=self._visitSubscript(
1.56 @@ -478,6 +482,7 @@
1.57 expr=LoadRef(ref=structure)
1.58 ),
1.59 InvokeBlock(
1.60 + class_,
1.61 share_locals=0, # override the local sharing usually in InvokeBlock
1.62 expr=LoadRef(ref=subprogram)
1.63 )
1.64 @@ -531,6 +536,7 @@
1.65 method_name = self.comparison_methods[op_name]
1.66 if method_name:
1.67 invocation = InvokeFunction(
1.68 + compare,
1.69 expr=LoadAttr(
1.70 expr=previous,
1.71 name=method_name),
1.72 @@ -540,6 +546,7 @@
1.73
1.74 elif op_name == "is":
1.75 invocation = InvokeFunction(
1.76 + compare,
1.77 expr=LoadName(name="__is__"),
1.78 args=[previous, expr],
1.79 star=None,
1.80 @@ -548,6 +555,7 @@
1.81 elif op_name == "is not":
1.82 invocation = Not(
1.83 expr=InvokeFunction(
1.84 + compare,
1.85 expr=LoadName(name="__is__"),
1.86 args=[previous, expr],
1.87 star=None,
1.88 @@ -618,7 +626,7 @@
1.89 result = InvokeFunction(dict, 1, expr=LoadName(name="dict"), star=None, dstar=None)
1.90 args = []
1.91 for key, value in dict.items:
1.92 - tuple = InvokeFunction(expr=LoadName(name="tuple"), star=None, dstar=None)
1.93 + tuple = InvokeFunction(dict, expr=LoadName(name="tuple"), star=None, dstar=None)
1.94 tuple.set_args([self.dispatch(key), self.dispatch(value)])
1.95 args.append(tuple)
1.96 result.set_args(args)
1.97 @@ -671,18 +679,20 @@
1.98 body=[
1.99 Assign(
1.100 code=[
1.101 - StoreTemp(expr=InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"))),
1.102 + StoreTemp(expr=InvokeFunction(for_, expr=LoadAttr(expr=LoadTemp(), name="next"))),
1.103 self.dispatch(for_.assign),
1.104 ReleaseTemp()
1.105 ])
1.106 ] + self.dispatch(for_.body) + [
1.107 InvokeBlock(
1.108 + for_,
1.109 expr=LoadRef(ref=subprogram)
1.110 )
1.111 ],
1.112 handler=[
1.113 Conditional(
1.114 test=InvokeFunction(
1.115 + for_,
1.116 expr=LoadName(name="isinstance"),
1.117 args=[LoadExc(), LoadName(name="StopIteration")],
1.118 star=None,
1.119 @@ -709,13 +719,14 @@
1.120 code=[
1.121 StoreTemp(
1.122 expr=InvokeFunction(
1.123 + for_,
1.124 expr=LoadAttr(
1.125 name="__iter__",
1.126 expr=self.dispatch(for_.list)
1.127 )
1.128 )
1.129 ),
1.130 - InvokeBlock(expr=LoadRef(ref=subprogram)),
1.131 + InvokeBlock(for_, expr=LoadRef(ref=subprogram)),
1.132 ReleaseTemp()
1.133 ]
1.134 )
1.135 @@ -780,14 +791,14 @@
1.136 if has_star:
1.137 star = (
1.138 function.argnames[npositional],
1.139 - InvokeFunction(expr=LoadName(name="list"))
1.140 + self.dispatch(compiler.ast.List([]))
1.141 )
1.142 else:
1.143 star = None
1.144 if has_dstar:
1.145 dstar = (
1.146 function.argnames[npositional + has_star],
1.147 - InvokeFunction(expr=LoadName(name="dict"))
1.148 + self.dispatch(compiler.ast.Dict([]))
1.149 )
1.150 else:
1.151 dstar = None
1.152 @@ -887,6 +898,7 @@
1.153
1.154 test = Conditional(if_, first,
1.155 test=InvokeFunction(
1.156 + if_,
1.157 expr=LoadAttr(
1.158 expr=self.dispatch(compare),
1.159 name="__bool__"
1.160 @@ -959,6 +971,7 @@
1.161
1.162 def _visitNot(self, expr, not_=None):
1.163 invocation = InvokeFunction(
1.164 + not_, # NOTE: May need a real original node.
1.165 expr=LoadAttr(
1.166 expr=expr,
1.167 name="__bool__"
1.168 @@ -1007,7 +1020,7 @@
1.169
1.170 if node is not last:
1.171 nodes.append(StoreTemp(expr=expr))
1.172 - invocation = InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="__bool__"))
1.173 + invocation = InvokeFunction(or_, expr=LoadAttr(expr=LoadTemp(), name="__bool__"))
1.174 test = Conditional(test=invocation, body=[ReturnFromBlock(expr=LoadTemp())])
1.175 nodes.append(test)
1.176
1.177 @@ -1079,6 +1092,7 @@
1.178 for node in print_.nodes:
1.179 result.code.append(
1.180 InvokeFunction(
1.181 + print_,
1.182 expr=LoadTemp(index="print"),
1.183 args=[self.dispatch(node)],
1.184 star=None,
1.185 @@ -1097,6 +1111,7 @@
1.186 result.code.insert(
1.187 len(result.code) - 1,
1.188 InvokeFunction(
1.189 + printnl,
1.190 expr=LoadTemp(index="print"),
1.191 args=[self.dispatch(compiler.ast.Const("\n"))],
1.192 star=None,
1.193 @@ -1111,6 +1126,7 @@
1.194 result.expr = self.dispatch(raise_.expr1)
1.195 else:
1.196 result.expr = InvokeFunction(
1.197 + raise_,
1.198 expr=self.dispatch(raise_.expr1),
1.199 args=[self.dispatch(raise_.expr2)],
1.200 star=None,
1.201 @@ -1362,12 +1378,14 @@
1.202
1.203 test = Conditional(
1.204 test=InvokeFunction(
1.205 + while_,
1.206 expr=LoadAttr(
1.207 expr=self.dispatch(while_.test),
1.208 name="__bool__"),
1.209 ),
1.210 body=self.dispatch(while_.body) + [
1.211 InvokeBlock(
1.212 + while_,
1.213 expr=LoadRef(ref=subprogram)
1.214 ),
1.215 ReturnFromBlock()
1.216 @@ -1422,6 +1440,7 @@
1.217 body=[
1.218 ReturnFromBlock(
1.219 expr=InvokeFunction(
1.220 + binary,
1.221 expr=LoadAttr(expr=self.dispatch(binary.left), name=left_name),
1.222 args=[self.dispatch(binary.right)],
1.223 star=None,
1.224 @@ -1436,6 +1455,7 @@
1.225 body=[
1.226 ReturnFromBlock(
1.227 expr=InvokeFunction(
1.228 + binary,
1.229 expr=LoadAttr(expr=self.dispatch(binary.right), name=right_name),
1.230 args=[self.dispatch(binary.left)],
1.231 star=None,
1.232 @@ -1452,6 +1472,7 @@
1.233 self.subprograms.append(subprogram); self.subnames[subprogram.full_name()] = subprogram
1.234
1.235 result = InvokeBlock(
1.236 + binary,
1.237 produces_result=1,
1.238 expr=LoadRef(ref=subprogram)
1.239 )