1.1 --- a/simplify.py Thu Aug 03 01:00:40 2006 +0200
1.2 +++ b/simplify.py Thu Aug 03 01:02:47 2006 +0200
1.3 @@ -161,8 +161,7 @@
1.4 return result
1.5
1.6 def _visitBuiltin(self, builtin, name):
1.7 - result = Invoke(builtin, expr=LoadName(name=name))
1.8 - result.args = self.dispatches(builtin.nodes)
1.9 + result = Invoke(builtin, expr=LoadName(name=name), args=self.dispatches(builtin.nodes), star=None, dstar=None)
1.10 return result
1.11
1.12 def visitTuple(self, tuple):
1.13 @@ -172,7 +171,7 @@
1.14 return self._visitBuiltin(list, "list")
1.15
1.16 def visitDict(self, dict):
1.17 - result = Invoke(dict, expr=LoadName(name="dict"))
1.18 + result = Invoke(dict, expr=LoadName(name="dict"), star=None, dstar=None)
1.19 args = []
1.20 for key, value in dict.items:
1.21 tuple = Invoke(expr=LoadName(name="tuple"), star=None, dstar=None)
1.22 @@ -210,8 +209,7 @@
1.23 for compare, stmt in if_.tests:
1.24 # Produce something like...
1.25 # expr.__true__() ? body
1.26 - test = Conditional(test=Invoke(expr=LoadAttr(expr=self.dispatch(compare), name="__true__"),
1.27 - args=[], star=None, dstar=None))
1.28 + test = Conditional(test=Invoke(expr=LoadAttr(expr=self.dispatch(compare), name="__true__"), args=[], star=None, dstar=None))
1.29 test.body = self.dispatch(stmt)
1.30 nodes.append(test)
1.31 nodes = test.else_ = []
1.32 @@ -485,20 +483,19 @@
1.33 return result
1.34
1.35 def visitNot(self, not_):
1.36 - result = Not(not_, expr=Invoke(expr=LoadAttr(expr=self.dispatch(not_.expr), name="__true__"),
1.37 - args=[], star=None, dstar=None))
1.38 + result = Not(not_, expr=Invoke(expr=LoadAttr(expr=self.dispatch(not_.expr), name="__true__"), args=[], star=None, dstar=None))
1.39 return result
1.40
1.41 # Operators.
1.42
1.43 def visitUnaryAdd(self, unaryadd):
1.44 - return Invoke(unaryadd, expr=LoadAttr(expr=self.dispatch(unaryadd.expr), name="__pos__"), args=[])
1.45 + return Invoke(unaryadd, expr=LoadAttr(expr=self.dispatch(unaryadd.expr), name="__pos__"), args=[], star=None, dstar=None)
1.46
1.47 def visitUnarySub(self, unarysub):
1.48 - return Invoke(unarysub, expr=LoadAttr(expr=self.dispatch(unarysub.expr), name="__neg__"), args=[])
1.49 + return Invoke(unarysub, expr=LoadAttr(expr=self.dispatch(unarysub.expr), name="__neg__"), args=[], star=None, dstar=None)
1.50
1.51 def visitInvert(self, invert):
1.52 - return Invoke(invert, expr=LoadAttr(expr=self.dispatch(invert.expr), name="__invert__"), args=[])
1.53 + return Invoke(invert, expr=LoadAttr(expr=self.dispatch(invert.expr), name="__invert__"), args=[], star=None, dstar=None)
1.54
1.55 def visitAdd(self, add):
1.56
1.57 @@ -506,8 +503,8 @@
1.58
1.59 result = Choice(add)
1.60 result.choices = [
1.61 - Invoke(expr=LoadAttr(expr=self.dispatch(add.left), name="__add__"), args=[self.dispatch(add.right)]),
1.62 - Invoke(expr=LoadAttr(expr=self.dispatch(add.right), name="__radd__"), args=[self.dispatch(add.left)])
1.63 + Invoke(expr=LoadAttr(expr=self.dispatch(add.left), name="__add__"), args=[self.dispatch(add.right)], star=None, dstar=None),
1.64 + Invoke(expr=LoadAttr(expr=self.dispatch(add.right), name="__radd__"), args=[self.dispatch(add.left)], star=None, dstar=None)
1.65 ]
1.66 return result
1.67
1.68 @@ -529,7 +526,7 @@
1.69 name = augassign.node
1.70 node = self.dispatch(name)
1.71 get_incremented = StoreTemp(
1.72 - expr=Invoke(expr=LoadAttr(expr=node, name=self.augassign_methods[augassign.op]), args=[expr])
1.73 + expr=Invoke(expr=LoadAttr(expr=node, name=self.augassign_methods[augassign.op]), args=[expr], star=None, dstar=None)
1.74 )
1.75 store = StoreName(expr=LoadTemp(), name=name.name)
1.76 result.code = [get_incremented, store, ReleaseTemp()]
1.77 @@ -544,7 +541,7 @@
1.78 store_expr = StoreTemp(index="expr", expr=self.dispatch(getattr.expr))
1.79 node_attr = LoadAttr(expr=LoadTemp(index="expr"), name=getattr.attrname)
1.80 get_incremented = StoreTemp(
1.81 - expr=Invoke(expr=LoadAttr(expr=node_attr, name=self.augassign_methods[augassign.op]), args=[expr])
1.82 + expr=Invoke(expr=LoadAttr(expr=node_attr, name=self.augassign_methods[augassign.op]), args=[expr], star=None, dstar=None)
1.83 )
1.84 store = StoreAttr(expr=LoadTemp(), lvalue=LoadTemp(index="expr"), name=getattr.attrname)
1.85 result.code = [store_expr, get_incremented, store, ReleaseTemp(index="expr"), ReleaseTemp()]
1.86 @@ -561,7 +558,7 @@
1.87 store_upper = StoreTemp(index="upper", expr=self.dispatch_or_none(slice.upper))
1.88 node_slice = self._visitSlice(slice, LoadTemp(index="expr"), LoadTemp(index="lower"), LoadTemp(index="upper"), "OP_APPLY")
1.89 get_incremented = StoreTemp(
1.90 - expr=Invoke(expr=LoadAttr(expr=node_slice, name=self.augassign_methods[augassign.op]), args=[expr])
1.91 + expr=Invoke(expr=LoadAttr(expr=node_slice, name=self.augassign_methods[augassign.op]), args=[expr], star=None, dstar=None)
1.92 )
1.93 store = self._visitSlice(slice, LoadTemp(index="expr"), LoadTemp(index="lower"), LoadTemp(index="upper"), "OP_ASSIGN", LoadTemp())
1.94 result.code = [store_expr, store_lower, store_upper, get_incremented, store,
1.95 @@ -579,7 +576,7 @@
1.96 store_subs = StoreTemp(index="subs", expr=subs)
1.97 node_subscript = self._visitSubscript(subscript, LoadTemp(index="expr"), LoadTemp(index="subs"), "OP_APPLY")
1.98 get_incremented = StoreTemp(
1.99 - expr=Invoke(expr=LoadAttr(expr=node_subscript, name=self.augassign_methods[augassign.op]), args=[expr])
1.100 + expr=Invoke(expr=LoadAttr(expr=node_subscript, name=self.augassign_methods[augassign.op]), args=[expr], star=None, dstar=None)
1.101 )
1.102 store = self._visitSubscript(subscript, LoadTemp(index="expr"), LoadTemp(index="subs"), "OP_ASSIGN", LoadTemp())
1.103 result.code = [store_expr, store_subs, get_incremented, store, ReleaseTemp(index="expr"), ReleaseTemp(index="subs"), ReleaseTemp()]
1.104 @@ -600,9 +597,9 @@
1.105 if not in_sequence:
1.106 expr = LoadTemp()
1.107 else:
1.108 - expr = Invoke(expr=LoadAttr(expr=LoadTemp(), name="next"))
1.109 + expr = Invoke(expr=LoadAttr(expr=LoadTemp(), name="next"), star=None, dstar=None, args=[])
1.110 result = Assign(asslist)
1.111 - store = StoreTemp(expr=Invoke(expr=LoadAttr(name="__iter__", expr=expr)))
1.112 + store = StoreTemp(expr=Invoke(expr=LoadAttr(name="__iter__", expr=expr), star=None, dstar=None, args=[]))
1.113 release = ReleaseTemp()
1.114 result.code = [store] + self.dispatches(asslist.nodes, 1) + [release]
1.115 return result
1.116 @@ -613,7 +610,7 @@
1.117 if not in_sequence:
1.118 return LoadTemp()
1.119 else:
1.120 - return Invoke(expr=LoadAttr(expr=LoadTemp(), name="next"))
1.121 + return Invoke(expr=LoadAttr(expr=LoadTemp(), name="next"), star=None, dstar=None, args=[])
1.122
1.123 def visitAssName(self, assname, in_sequence=0):
1.124 expr = self._visitAssNameOrAttr(assname, in_sequence)
1.125 @@ -629,13 +626,13 @@
1.126 def _visitSlice(self, slice, expr, lower, upper, flags, value=None):
1.127 if flags == "OP_ASSIGN":
1.128 args = [value]
1.129 - result = Invoke(expr=LoadAttr(expr=expr, name="__setslice__"))
1.130 + result = Invoke(expr=LoadAttr(expr=expr, name="__setslice__"), star=None, dstar=None, args=[])
1.131 elif flags == "OP_APPLY":
1.132 args = []
1.133 - result = Invoke(expr=LoadAttr(expr=expr, name="__getslice__"))
1.134 + result = Invoke(expr=LoadAttr(expr=expr, name="__getslice__"), star=None, dstar=None, args=[])
1.135 elif flags == "OP_DELETE":
1.136 args = []
1.137 - result = Invoke(expr=LoadAttr(expr=expr, name="__delslice__"))
1.138 + result = Invoke(expr=LoadAttr(expr=expr, name="__delslice__"), star=None, dstar=None, args=[])
1.139 else:
1.140 raise NotImplementedError, flags
1.141
1.142 @@ -656,13 +653,13 @@
1.143 def _visitSubscript(self, subscript, expr, subs, flags, value=None):
1.144 if flags == "OP_ASSIGN":
1.145 args = [value]
1.146 - result = Invoke(expr=LoadAttr(expr=expr, name="__setitem__"))
1.147 + result = Invoke(expr=LoadAttr(expr=expr, name="__setitem__"), star=None, dstar=None, args=[])
1.148 elif flags == "OP_APPLY":
1.149 args = []
1.150 - result = Invoke(expr=LoadAttr(expr=expr, name="__getitem__"))
1.151 + result = Invoke(expr=LoadAttr(expr=expr, name="__getitem__"), star=None, dstar=None, args=[])
1.152 elif flags == "OP_DELETE":
1.153 args = []
1.154 - result = Invoke(expr=LoadAttr(expr=expr, name="__delitem__"))
1.155 + result = Invoke(expr=LoadAttr(expr=expr, name="__delitem__"), star=None, dstar=None, args=[])
1.156 else:
1.157 raise NotImplementedError, flags
1.158
1.159 @@ -678,7 +675,7 @@
1.160 if len(subs) == 1:
1.161 return self.dispatch(subs[0])
1.162 else:
1.163 - return Invoke(expr=LoadName(name="tuple"), args=self.dispatches(subs))
1.164 + return Invoke(expr=LoadName(name="tuple"), args=self.dispatches(subs), star=None, dstar=None)
1.165
1.166 def visitSubscript(self, subscript, in_sequence=0):
1.167 value = self._visitAssNameOrAttr(subscript, in_sequence)
1.168 @@ -811,8 +808,7 @@
1.169 # Include a conditional statement in the subprogram.
1.170
1.171 test = Conditional(else_=[])
1.172 - test.test = Invoke(expr=LoadAttr(expr=self.dispatch(while_.test), name="__true__"),
1.173 - args=[], star=None, dstar=None)
1.174 + test.test = Invoke(expr=LoadAttr(expr=self.dispatch(while_.test), name="__true__"), args=[], star=None, dstar=None)
1.175
1.176 # Inside the conditional, add a recursive invocation to the subprogram
1.177 # if the test condition was satisfied.
1.178 @@ -876,17 +872,14 @@
1.179
1.180 try_except = Try(body=[], else_=[], finally_=[])
1.181 test = Conditional(
1.182 - test=Invoke(
1.183 - expr=LoadName(name="isinstance"),
1.184 - args=[LoadExc(), LoadName(name="StopIteration")], star=None, dstar=None
1.185 - ),
1.186 + test=Invoke(expr=LoadName(name="isinstance"), args=[LoadExc(), LoadName(name="StopIteration")], star=None, dstar=None),
1.187 body=else_stmt,
1.188 else_=[Raise(expr=LoadExc())])
1.189 try_except.handler = [test]
1.190
1.191 assign = Assign()
1.192 assign.code = [
1.193 - StoreTemp(expr=Invoke(expr=LoadAttr(expr=LoadTemp(), name="next"))),
1.194 + StoreTemp(expr=Invoke(expr=LoadAttr(expr=LoadTemp(), name="next"), args=[], star=None, dstar=None)),
1.195 self.dispatch(for_.assign),
1.196 ReleaseTemp()
1.197 ]
1.198 @@ -909,7 +902,7 @@
1.199
1.200 result = Assign(for_)
1.201 result.code = [
1.202 - StoreTemp(expr=Invoke(expr=LoadAttr(name="__iter__", expr=self.dispatch(for_.list)))),
1.203 + StoreTemp(expr=Invoke(expr=LoadAttr(name="__iter__", expr=self.dispatch(for_.list)), args=[], star=None, dstar=None)),
1.204 Invoke(expr=LoadRef(ref=subprogram), same_frame=1, produces_result=0, star=None, dstar=None, args=[]),
1.205 ReleaseTemp()
1.206 ]