1.1 --- a/simplify.py Sun Oct 22 00:23:03 2006 +0200
1.2 +++ b/simplify.py Sun Oct 22 01:43:53 2006 +0200
1.3 @@ -124,10 +124,10 @@
1.4 init_code = []
1.5 for value, constant in self.constants.items():
1.6 init_code.append(
1.7 - StoreAttr(module,
1.8 - lvalue=LoadRef(module, ref=constant),
1.9 + StoreAttr(
1.10 + lvalue=LoadRef(ref=constant),
1.11 name="__class__",
1.12 - expr=LoadName(module, name=constant.typename)
1.13 + expr=LoadName(name=constant.typename)
1.14 )
1.15 )
1.16
1.17 @@ -163,26 +163,26 @@
1.18 result = Assign(import_, 1)
1.19 code = []
1.20 for path, alias in import_.names:
1.21 - importer = Import(import_, name=path)
1.22 + importer = Import(name=path)
1.23 top = alias or path.split(".")[0]
1.24 - code.append(StoreName(import_, expr=importer, name=top))
1.25 + code.append(StoreName(expr=importer, name=top))
1.26 result.code = code
1.27 return result
1.28
1.29 def visitFrom(self, from_):
1.30 result = Assign(from_, 1)
1.31 code = []
1.32 - code.append(StoreTemp(from_, expr=Import(from_, name=from_.modname)))
1.33 + code.append(StoreTemp(expr=Import(name=from_.modname)))
1.34 for name, alias in from_.names:
1.35 code.append(
1.36 - StoreName(from_,
1.37 - expr=LoadAttr(from_,
1.38 - expr=LoadTemp(from_),
1.39 + StoreName(
1.40 + expr=LoadAttr(
1.41 + expr=LoadTemp(),
1.42 name=name),
1.43 name=(alias or name)
1.44 )
1.45 )
1.46 - code.append(ReleaseTemp(from_))
1.47 + code.append(ReleaseTemp())
1.48 result.code = code
1.49 return result
1.50
1.51 @@ -192,7 +192,7 @@
1.52
1.53 def visitConst(self, const):
1.54 if not self.constants.has_key(const.value):
1.55 - self.constants[const.value] = Constant(const, name=repr(const.value), value=const.value)
1.56 + self.constants[const.value] = Constant(name=repr(const.value), value=const.value)
1.57 result = LoadRef(const, 1, ref=self.constants[const.value])
1.58 return result
1.59
1.60 @@ -208,7 +208,7 @@
1.61
1.62 def visitContinue(self, continue_):
1.63 result = InvokeBlock(continue_, 1,
1.64 - expr=LoadRef(continue_, ref=self.current_subprograms[-1])
1.65 + expr=LoadRef(ref=self.current_subprograms[-1])
1.66 )
1.67 return result
1.68
1.69 @@ -221,7 +221,7 @@
1.70 return result
1.71
1.72 def _visitBuiltin(self, builtin, name):
1.73 - result = InvokeFunction(builtin, 1, expr=LoadName(builtin, name=name), args=self.dispatches(builtin.nodes), star=None, dstar=None)
1.74 + result = InvokeFunction(builtin, 1, expr=LoadName(name=name), args=self.dispatches(builtin.nodes), star=None, dstar=None)
1.75 return result
1.76
1.77 def visitTuple(self, tuple):
1.78 @@ -231,10 +231,10 @@
1.79 return self._visitBuiltin(list, "list")
1.80
1.81 def visitDict(self, dict):
1.82 - result = InvokeFunction(dict, 1, expr=LoadName(dict, name="dict"), star=None, dstar=None)
1.83 + result = InvokeFunction(dict, 1, expr=LoadName(name="dict"), star=None, dstar=None)
1.84 args = []
1.85 for key, value in dict.items:
1.86 - tuple = InvokeFunction(dict, expr=LoadName(dict, name="tuple"), star=None, dstar=None)
1.87 + tuple = InvokeFunction(expr=LoadName(name="tuple"), star=None, dstar=None)
1.88 tuple.set_args([self.dispatch(key), self.dispatch(value)])
1.89 args.append(tuple)
1.90 result.set_args(args)
1.91 @@ -275,8 +275,8 @@
1.92 # Set the first as the defining node.
1.93
1.94 test = Conditional(if_, first,
1.95 - test=InvokeFunction(if_,
1.96 - expr=LoadAttr(if_,
1.97 + test=InvokeFunction(
1.98 + expr=LoadAttr(
1.99 expr=self.dispatch(compare),
1.100 name="__true__"
1.101 ),
1.102 @@ -340,10 +340,10 @@
1.103
1.104 else:
1.105 new_spec = self.dispatch(spec)
1.106 - test = Conditional(tryexcept,
1.107 - test=InvokeFunction(tryexcept,
1.108 - expr=LoadName(tryexcept, name="isinstance"),
1.109 - args=[LoadExc(tryexcept), new_spec],
1.110 + test = Conditional(
1.111 + test=InvokeFunction(
1.112 + expr=LoadName(name="isinstance"),
1.113 + args=[LoadExc(), new_spec],
1.114 star=None,
1.115 dstar=None)
1.116 )
1.117 @@ -351,26 +351,26 @@
1.118
1.119 if assign is not None:
1.120 test.body.append(
1.121 - Assign(tryexcept,
1.122 + Assign(
1.123 code=[
1.124 - StoreTemp(expr=LoadExc(tryexcept)),
1.125 + StoreTemp(expr=LoadExc()),
1.126 self.dispatch(assign),
1.127 - ReleaseTemp(tryexcept)
1.128 + ReleaseTemp()
1.129 ]
1.130 )
1.131 )
1.132
1.133 # Always return from conditional sections.
1.134
1.135 - test.body += self.dispatch(stmt) + [Return(tryexcept)]
1.136 + test.body += self.dispatch(stmt) + [Return()]
1.137 nodes.append(test)
1.138 nodes = test.else_ = []
1.139
1.140 # Add a raise operation to deal with unhandled exceptions.
1.141
1.142 nodes.append(
1.143 - Raise(tryexcept,
1.144 - expr=LoadExc(tryexcept))
1.145 + Raise(
1.146 + expr=LoadExc())
1.147 )
1.148
1.149 result.handler = results
1.150 @@ -398,7 +398,7 @@
1.151 (else) -> ...
1.152 """
1.153
1.154 - subprogram = Subprogram(compare, name=None, acquire_locals=1, returns_value=1, params=[], star=None, dstar=None)
1.155 + subprogram = Subprogram(name=None, acquire_locals=1, returns_value=1, params=[], star=None, dstar=None)
1.156 self.current_subprograms.append(subprogram)
1.157
1.158 # In the subprogram, make instructions which invoke a method on the
1.159 @@ -417,8 +417,8 @@
1.160
1.161 method_name = self.comparison_methods[op_name]
1.162 if method_name:
1.163 - invocation = InvokeFunction(compare,
1.164 - expr=LoadAttr(compare,
1.165 + invocation = InvokeFunction(
1.166 + expr=LoadAttr(
1.167 expr=previous,
1.168 name=method_name),
1.169 args=[expr],
1.170 @@ -426,16 +426,16 @@
1.171 dstar=None)
1.172
1.173 elif op_name == "is":
1.174 - invocation = InvokeFunction(compare,
1.175 - expr=LoadName(compare, name="__is__"),
1.176 + invocation = InvokeFunction(
1.177 + expr=LoadName(name="__is__"),
1.178 args=[previous, expr],
1.179 star=None,
1.180 dstar=None)
1.181
1.182 elif op_name == "is not":
1.183 - invocation = Not(compare,
1.184 - expr=InvokeFunction(compare,
1.185 - expr=LoadName(compare, name="__is__"),
1.186 + invocation = Not(
1.187 + expr=InvokeFunction(
1.188 + expr=LoadName(name="__is__"),
1.189 args=[previous, expr],
1.190 star=None,
1.191 dstar=None)
1.192 @@ -443,26 +443,26 @@
1.193 else:
1.194 raise NotImplementedError, op_name
1.195
1.196 - nodes.append(StoreTemp(compare, expr=invocation))
1.197 + nodes.append(StoreTemp(expr=invocation))
1.198
1.199 # Return from the subprogram where the test is not satisfied.
1.200
1.201 if op is not last:
1.202 nodes.append(
1.203 - Conditional(compare,
1.204 - test=Not(compare, expr=LoadTemp(compare)),
1.205 - body=[Return(compare, expr=LoadTemp(compare))])
1.206 + Conditional(
1.207 + test=Not(expr=LoadTemp()),
1.208 + body=[Return(expr=LoadTemp())])
1.209 )
1.210
1.211 # Put subsequent operations in the else section of this conditional.
1.212
1.213 - nodes = test.else_ = [ReleaseTemp(compare)]
1.214 + nodes = test.else_ = [ReleaseTemp()]
1.215
1.216 # For the last operation, return the result.
1.217
1.218 else:
1.219 nodes.append(
1.220 - Return(compare, expr=LoadTemp(compare, release=1))
1.221 + Return(expr=LoadTemp(release=1))
1.222 )
1.223
1.224 previous = expr
1.225 @@ -477,7 +477,7 @@
1.226 # Make an invocation of the subprogram.
1.227
1.228 result = InvokeBlock(compare, 1, produces_result=1)
1.229 - result.expr = LoadRef(compare, ref=subprogram)
1.230 + result.expr = LoadRef(ref=subprogram)
1.231 return result
1.232
1.233 def visitAnd(self, and_):
1.234 @@ -497,7 +497,7 @@
1.235 (else) -> ...
1.236 """
1.237
1.238 - subprogram = Subprogram(and_, name=None, acquire_locals=1, returns_value=1, params=[], star=None, dstar=None)
1.239 + subprogram = Subprogram(name=None, acquire_locals=1, returns_value=1, params=[], star=None, dstar=None)
1.240 self.current_subprograms.append(subprogram)
1.241
1.242 # In the subprogram, make instructions which store each operand, test
1.243 @@ -513,19 +513,19 @@
1.244 # Return from the subprogram where the test is not satisfied.
1.245
1.246 if node is not last:
1.247 - nodes.append(StoreTemp(and_, expr=expr))
1.248 - invocation = InvokeFunction(and_, expr=LoadAttr(and_, expr=LoadTemp(and_), name="__true__"), args=[], star=None, dstar=None)
1.249 - test = Conditional(and_, test=Not(and_, expr=invocation), body=[Return(and_, expr=LoadTemp(and_))])
1.250 + nodes.append(StoreTemp(expr=expr))
1.251 + invocation = InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="__true__"), args=[], star=None, dstar=None)
1.252 + test = Conditional(test=Not(expr=invocation), body=[Return(expr=LoadTemp())])
1.253 nodes.append(test)
1.254
1.255 # Put subsequent operations in the else section of this conditional.
1.256
1.257 - nodes = test.else_ = [ReleaseTemp(and_)]
1.258 + nodes = test.else_ = [ReleaseTemp()]
1.259
1.260 # For the last operation, return the result.
1.261
1.262 else:
1.263 - nodes.append(Return(and_, expr=expr))
1.264 + nodes.append(Return(expr=expr))
1.265
1.266 # Finish the subprogram definition.
1.267
1.268 @@ -537,7 +537,7 @@
1.269 # Make an invocation of the subprogram.
1.270
1.271 result = InvokeBlock(and_, 1, produces_result=1)
1.272 - result.expr = LoadRef(and_, ref=subprogram)
1.273 + result.expr = LoadRef(ref=subprogram)
1.274 return result
1.275
1.276 def visitOr(self, or_):
1.277 @@ -557,7 +557,7 @@
1.278 (else) -> ...
1.279 """
1.280
1.281 - subprogram = Subprogram(or_, name=None, acquire_locals=1, returns_value=1, params=[], star=None, dstar=None)
1.282 + subprogram = Subprogram(name=None, acquire_locals=1, returns_value=1, params=[], star=None, dstar=None)
1.283 self.current_subprograms.append(subprogram)
1.284
1.285 # In the subprogram, make instructions which store each operand, test
1.286 @@ -573,20 +573,20 @@
1.287 # Return from the subprogram where the test is satisfied.
1.288
1.289 if node is not last:
1.290 - nodes.append(StoreTemp(or_, expr=expr))
1.291 - invocation = InvokeFunction(or_, expr=LoadAttr(or_, expr=LoadTemp(or_), name="__true__"), args=[], star=None, dstar=None)
1.292 - test = Conditional(or_, test=invocation, body=[Return(or_, expr=LoadTemp(or_))])
1.293 + nodes.append(StoreTemp(expr=expr))
1.294 + invocation = InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="__true__"), args=[], star=None, dstar=None)
1.295 + test = Conditional(test=invocation, body=[Return(expr=LoadTemp())])
1.296 nodes.append(test)
1.297
1.298 # Put subsequent operations in the else section of this conditional.
1.299
1.300 - nodes = test.else_ = [ReleaseTemp(or_)]
1.301 + nodes = test.else_ = [ReleaseTemp()]
1.302
1.303 # For the last operation, return the result.
1.304
1.305 else:
1.306 nodes.append(
1.307 - Return(or_, expr=expr)
1.308 + Return(expr=expr)
1.309 )
1.310
1.311 # Finish the subprogram definition.
1.312 @@ -599,13 +599,13 @@
1.313 # Make an invocation of the subprogram.
1.314
1.315 result = InvokeBlock(or_, 1, produces_result=1)
1.316 - result.expr = LoadRef(or_, ref=subprogram)
1.317 + result.expr = LoadRef(ref=subprogram)
1.318 return result
1.319
1.320 def visitNot(self, not_):
1.321 result = Not(not_, 1,
1.322 - expr=InvokeFunction(not_,
1.323 - expr=LoadAttr(not_,
1.324 + expr=InvokeFunction(
1.325 + expr=LoadAttr(
1.326 expr=self.dispatch(not_.expr),
1.327 name="__true__"
1.328 ),
1.329 @@ -620,7 +620,7 @@
1.330
1.331 def visitUnaryAdd(self, unaryadd):
1.332 return InvokeFunction(unaryadd, 1,
1.333 - expr=LoadAttr(unaryadd,
1.334 + expr=LoadAttr(
1.335 expr=self.dispatch(unaryadd.expr),
1.336 name="__pos__"
1.337 ),
1.338 @@ -631,7 +631,7 @@
1.339
1.340 def visitUnarySub(self, unarysub):
1.341 return InvokeFunction(unarysub, 1,
1.342 - expr=LoadAttr(unarysub,
1.343 + expr=LoadAttr(
1.344 expr=self.dispatch(unarysub.expr),
1.345 name="__neg__"
1.346 ),
1.347 @@ -642,7 +642,7 @@
1.348
1.349 def visitInvert(self, invert):
1.350 return InvokeFunction(invert, 1,
1.351 - expr=LoadAttr(invert,
1.352 + expr=LoadAttr(
1.353 expr=self.dispatch(invert.expr),
1.354 name="__invert__"
1.355 ),
1.356 @@ -665,8 +665,8 @@
1.357
1.358 result = Try(add, 1,
1.359 body=[
1.360 - InvokeFunction(add,
1.361 - expr=LoadAttr(add, expr=self.dispatch(add.left), name="__add__"),
1.362 + InvokeFunction(
1.363 + expr=LoadAttr(expr=self.dispatch(add.left), name="__add__"),
1.364 args=[self.dispatch(add.right)],
1.365 star=None,
1.366 dstar=None)
1.367 @@ -674,15 +674,15 @@
1.368 else_=[],
1.369 finally_=[],
1.370 handler=[
1.371 - Conditional(add,
1.372 - test=InvokeFunction(add,
1.373 - expr=LoadName(add, name="isinstance"),
1.374 - args=[LoadExc(add), LoadName(add, name="TypeError")],
1.375 + Conditional(
1.376 + test=InvokeFunction(
1.377 + expr=LoadName(name="isinstance"),
1.378 + args=[LoadExc(), LoadName(name="TypeError")],
1.379 star=None,
1.380 dstar=None),
1.381 body=[
1.382 - InvokeFunction(add,
1.383 - expr=LoadAttr(add, expr=self.dispatch(add.right), name="__radd__"),
1.384 + InvokeFunction(
1.385 + expr=LoadAttr(expr=self.dispatch(add.right), name="__radd__"),
1.386 args=[self.dispatch(add.left)],
1.387 star=None,
1.388 dstar=None)
1.389 @@ -727,21 +727,21 @@
1.390
1.391 if isinstance(augassign.node, compiler.ast.Name):
1.392 result.code = [
1.393 - StoreTemp(augassign,
1.394 - expr=InvokeFunction(augassign,
1.395 + StoreTemp(
1.396 + expr=InvokeFunction(
1.397 args=[expr],
1.398 star=None,
1.399 dstar=None,
1.400 - expr=LoadAttr(augassign,
1.401 + expr=LoadAttr(
1.402 expr=self.dispatch(augassign.node),
1.403 name=self.augassign_methods[augassign.op]
1.404 )
1.405 )
1.406 ),
1.407 - StoreName(augassign,
1.408 - expr=LoadTemp(augassign),
1.409 + StoreName(
1.410 + expr=LoadTemp(),
1.411 name=augassign.node.name),
1.412 - ReleaseTemp(augassign)
1.413 + ReleaseTemp()
1.414 ]
1.415
1.416 # Complicated augmented assignment: lvalue.attr += expr
1.417 @@ -751,29 +751,29 @@
1.418 # <lvalue> -> setattr(<lvalue>, getattr(<lvalue>, "attr").__xxx__(expr))
1.419
1.420 result.code = [
1.421 - StoreTemp(augassign,
1.422 + StoreTemp(
1.423 index="expr",
1.424 expr=self.dispatch(augassign.node.expr)
1.425 ),
1.426 - StoreTemp(augassign,
1.427 - expr=InvokeFunction(augassign,
1.428 + StoreTemp(
1.429 + expr=InvokeFunction(
1.430 args=[expr], star=None, dstar=None,
1.431 - expr=LoadAttr(augassign,
1.432 + expr=LoadAttr(
1.433 expr=LoadAttr(augassign.node, 1,
1.434 - expr=LoadTemp(augassign, index="expr"),
1.435 + expr=LoadTemp(index="expr"),
1.436 name=augassign.node.attrname
1.437 ),
1.438 name=self.augassign_methods[augassign.op]
1.439 )
1.440 )
1.441 ),
1.442 - StoreAttr(augassign,
1.443 - expr=LoadTemp(augassign),
1.444 - lvalue=LoadTemp(augassign, index="expr"),
1.445 + StoreAttr(
1.446 + expr=LoadTemp(),
1.447 + lvalue=LoadTemp(index="expr"),
1.448 name=augassign.node.attrname
1.449 ),
1.450 - ReleaseTemp(augassign, index="expr"),
1.451 - ReleaseTemp(augassign)
1.452 + ReleaseTemp(index="expr"),
1.453 + ReleaseTemp()
1.454 ]
1.455
1.456 # Complicated augassign using slices: lvalue[lower:upper] += expr
1.457 @@ -783,27 +783,27 @@
1.458 # <lvalue>, <lower>, <upper> -> <lvalue>.__setslice__(<lower>, <upper>, <lvalue>.__getslice__(<lower>, <upper>).__xxx__(expr))
1.459
1.460 result.code = [
1.461 - StoreTemp(augassign,
1.462 + StoreTemp(
1.463 index="expr",
1.464 expr=self.dispatch(augassign.node.expr)
1.465 ),
1.466 - StoreTemp(augassign,
1.467 + StoreTemp(
1.468 index="lower",
1.469 expr=self.dispatch_or_none(augassign.node.lower)
1.470 ),
1.471 - StoreTemp(augassign,
1.472 + StoreTemp(
1.473 index="upper",
1.474 expr=self.dispatch_or_none(augassign.node.upper)
1.475 ),
1.476 - StoreTemp(augassign,
1.477 - expr=InvokeFunction(augassign,
1.478 + StoreTemp(
1.479 + expr=InvokeFunction(
1.480 args=[expr], star=None, dstar=None,
1.481 - expr=LoadAttr(augassign,
1.482 + expr=LoadAttr(
1.483 expr=self._visitSlice(
1.484 augassign.node,
1.485 - LoadTemp(augassign, index="expr"),
1.486 - LoadTemp(augassign, index="lower"),
1.487 - LoadTemp(augassign, index="upper"),
1.488 + LoadTemp(index="expr"),
1.489 + LoadTemp(index="lower"),
1.490 + LoadTemp(index="upper"),
1.491 "OP_APPLY"),
1.492 name=self.augassign_methods[augassign.op]
1.493 )
1.494 @@ -811,16 +811,16 @@
1.495 ),
1.496 self._visitSlice(
1.497 augassign.node,
1.498 - LoadTemp(augassign, index="expr"),
1.499 - LoadTemp(augassign, index="lower"),
1.500 - LoadTemp(augassign, index="upper"),
1.501 + LoadTemp(index="expr"),
1.502 + LoadTemp(index="lower"),
1.503 + LoadTemp(index="upper"),
1.504 "OP_ASSIGN",
1.505 - LoadTemp(augassign)
1.506 + LoadTemp()
1.507 ),
1.508 - ReleaseTemp(augassign, index="expr"),
1.509 - ReleaseTemp(augassign, index="lower"),
1.510 - ReleaseTemp(augassign, index="upper"),
1.511 - ReleaseTemp(augassign)
1.512 + ReleaseTemp(index="expr"),
1.513 + ReleaseTemp(index="lower"),
1.514 + ReleaseTemp(index="upper"),
1.515 + ReleaseTemp()
1.516 ]
1.517
1.518 # Complicated augassign using subscripts: lvalue[subs] += expr
1.519 @@ -830,16 +830,16 @@
1.520 # <lvalue>, <subs> -> <lvalue>.__setitem__(<subs>, <lvalue>.__getitem__(<subs>).__xxx__(expr))
1.521
1.522 result.code = [
1.523 - StoreTemp(augassign, index="expr", expr=self.dispatch(augassign.node.expr)),
1.524 - StoreTemp(augassign, index="subs", expr=self._visitSubscriptSubs(augassign.node, augassign.node.subs)),
1.525 - StoreTemp(augassign,
1.526 - expr=InvokeFunction(augassign,
1.527 + StoreTemp(index="expr", expr=self.dispatch(augassign.node.expr)),
1.528 + StoreTemp(index="subs", expr=self._visitSubscriptSubs(augassign.node, augassign.node.subs)),
1.529 + StoreTemp(
1.530 + expr=InvokeFunction(
1.531 args=[expr], star=None, dstar=None,
1.532 - expr=LoadAttr(augassign,
1.533 + expr=LoadAttr(
1.534 expr=self._visitSubscript(
1.535 augassign.node,
1.536 - LoadTemp(augassign, index="expr"),
1.537 - LoadTemp(augassign, index="subs"),
1.538 + LoadTemp(index="expr"),
1.539 + LoadTemp(index="subs"),
1.540 "OP_APPLY"
1.541 ),
1.542 name=self.augassign_methods[augassign.op]
1.543 @@ -848,14 +848,14 @@
1.544 ),
1.545 self._visitSubscript(
1.546 augassign.node,
1.547 - LoadTemp(augassign, index="expr"),
1.548 - LoadTemp(augassign, index="subs"),
1.549 + LoadTemp(index="expr"),
1.550 + LoadTemp(index="subs"),
1.551 "OP_ASSIGN",
1.552 - LoadTemp(augassign)
1.553 + LoadTemp()
1.554 ),
1.555 - ReleaseTemp(augassign, index="expr"),
1.556 - ReleaseTemp(augassign, index="subs"),
1.557 - ReleaseTemp(augassign)
1.558 + ReleaseTemp(index="expr"),
1.559 + ReleaseTemp(index="subs"),
1.560 + ReleaseTemp()
1.561 ]
1.562
1.563 else:
1.564 @@ -865,19 +865,19 @@
1.565
1.566 def visitAssign(self, assign):
1.567 result = Assign(assign, 1)
1.568 - store = StoreTemp(assign, expr=self.dispatch(assign.expr))
1.569 - release = ReleaseTemp(assign)
1.570 + store = StoreTemp(expr=self.dispatch(assign.expr))
1.571 + release = ReleaseTemp()
1.572 result.code = [store] + self.dispatches(assign.nodes, 0) + [release]
1.573 return result
1.574
1.575 def visitAssList(self, asslist, in_sequence=0):
1.576 if not in_sequence:
1.577 - expr = LoadTemp(asslist)
1.578 + expr = LoadTemp()
1.579 else:
1.580 - expr = InvokeFunction(asslist, expr=LoadAttr(asslist, expr=LoadTemp(asslist), name="next"), star=None, dstar=None, args=[])
1.581 + expr = InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"), star=None, dstar=None, args=[])
1.582 result = Assign(asslist, 1)
1.583 - store = StoreTemp(asslist, expr=InvokeFunction(asslist, expr=LoadAttr(asslist, name="__iter__", expr=expr), star=None, dstar=None, args=[]))
1.584 - release = ReleaseTemp(asslist)
1.585 + store = StoreTemp(expr=InvokeFunction(expr=LoadAttr(name="__iter__", expr=expr), star=None, dstar=None, args=[]))
1.586 + release = ReleaseTemp()
1.587 result.code = [store] + self.dispatches(asslist.nodes, 1) + [release]
1.588 return result
1.589
1.590 @@ -885,9 +885,9 @@
1.591
1.592 def _visitAssNameOrAttr(self, node, in_sequence):
1.593 if not in_sequence:
1.594 - return LoadTemp(node)
1.595 + return LoadTemp()
1.596 else:
1.597 - return InvokeFunction(node, expr=LoadAttr(node, expr=LoadTemp(node), name="next"), star=None, dstar=None, args=[])
1.598 + return InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"), star=None, dstar=None, args=[])
1.599
1.600 def visitAssName(self, assname, in_sequence=0):
1.601 expr = self._visitAssNameOrAttr(assname, in_sequence)
1.602 @@ -903,7 +903,7 @@
1.603 def _visitSlice(self, slice, expr, lower, upper, flags, value=None):
1.604 if flags == "OP_ASSIGN":
1.605 result = InvokeFunction(slice, 1,
1.606 - expr=LoadAttr(slice,
1.607 + expr=LoadAttr(
1.608 expr=expr,
1.609 name="__setslice__"
1.610 ),
1.611 @@ -914,7 +914,7 @@
1.612 elif flags == "OP_APPLY":
1.613 args = []
1.614 result = InvokeFunction(slice, 1,
1.615 - expr=LoadAttr(slice,
1.616 + expr=LoadAttr(
1.617 expr=expr,
1.618 name="__getslice__"
1.619 ),
1.620 @@ -925,7 +925,7 @@
1.621 elif flags == "OP_DELETE":
1.622 args = []
1.623 result = InvokeFunction(slice, 1,
1.624 - expr=LoadAttr(slice,
1.625 + expr=LoadAttr(
1.626 expr=expr,
1.627 name="__delslice__"
1.628 ),
1.629 @@ -945,7 +945,7 @@
1.630 def _visitSubscript(self, subscript, expr, subs, flags, value=None):
1.631 if flags == "OP_ASSIGN":
1.632 result = InvokeFunction(subscript, 1,
1.633 - expr=LoadAttr(subscript,
1.634 + expr=LoadAttr(
1.635 expr=expr,
1.636 name="__setitem__"
1.637 ),
1.638 @@ -956,7 +956,7 @@
1.639 elif flags == "OP_APPLY":
1.640 args = []
1.641 result = InvokeFunction(subscript, 1,
1.642 - expr=LoadAttr(subscript,
1.643 + expr=LoadAttr(
1.644 expr=expr,
1.645 name="__getitem__"
1.646 ),
1.647 @@ -967,7 +967,7 @@
1.648 elif flags == "OP_DELETE":
1.649 args = []
1.650 result = InvokeFunction(subscript, 1,
1.651 - expr=LoadAttr(subscript,
1.652 + expr=LoadAttr(
1.653 expr=expr,
1.654 name="__delitem__"
1.655 ),
1.656 @@ -985,7 +985,7 @@
1.657 return self.dispatch(subs[0])
1.658 else:
1.659 return InvokeFunction(node, 1,
1.660 - expr=LoadName(node, name="tuple"),
1.661 + expr=LoadName(name="tuple"),
1.662 args=self.dispatches(subs),
1.663 star=None,
1.664 dstar=None
1.665 @@ -1000,31 +1000,31 @@
1.666 # Invocation and subprogram transformations.
1.667
1.668 def visitClass(self, class_):
1.669 - structure = Class(class_, name=class_.name, bases=self.dispatches(class_.bases))
1.670 + structure = Class(name=class_.name, bases=self.dispatches(class_.bases))
1.671 self.structures.append(structure)
1.672
1.673 # Make a subprogram which initialises the class structure.
1.674
1.675 - subprogram = Subprogram(class_, name=None, structure=structure, params=[], star=None, dstar=None)
1.676 + subprogram = Subprogram(name=None, structure=structure, params=[], star=None, dstar=None)
1.677 self.current_subprograms.append(subprogram)
1.678
1.679 # The class is initialised using the code found inside.
1.680
1.681 - subprogram.code = self.dispatch(class_.code) + [Return(class_)]
1.682 + subprogram.code = self.dispatch(class_.code) + [Return()]
1.683
1.684 self.current_subprograms.pop()
1.685 self.subprograms.append(subprogram); self.subnames[subprogram.full_name()] = subprogram
1.686
1.687 # Make a definition of the class associating it with a name.
1.688
1.689 - result = Assign(class_,
1.690 + result = Assign(
1.691 code=[
1.692 StoreName(class_, 1, # defines the class
1.693 name=class_.name,
1.694 - expr=LoadRef(class_, ref=structure)
1.695 + expr=LoadRef(ref=structure)
1.696 ),
1.697 - InvokeBlock(class_,
1.698 - expr=LoadRef(class_, ref=subprogram)
1.699 + InvokeBlock(
1.700 + expr=LoadRef(ref=subprogram)
1.701 )
1.702 ]
1.703 )
1.704 @@ -1058,14 +1058,14 @@
1.705 if has_star:
1.706 star = (
1.707 function.argnames[npositional],
1.708 - InvokeFunction(expr=LoadName(function, name="list"), args=[], star=None, dstar=None)
1.709 + InvokeFunction(expr=LoadName(name="list"), args=[], star=None, dstar=None)
1.710 )
1.711 else:
1.712 star = None
1.713 if has_dstar:
1.714 dstar = (
1.715 function.argnames[npositional + has_star],
1.716 - InvokeFunction(expr=LoadName(function, name="dict"), args=[], star=None, dstar=None)
1.717 + InvokeFunction(expr=LoadName(name="dict"), args=[], star=None, dstar=None)
1.718 )
1.719 else:
1.720 dstar = None
1.721 @@ -1100,15 +1100,15 @@
1.722 (dstar)
1.723 """
1.724
1.725 - subprogram = Subprogram(function, name=function.name, acquire_locals=0, returns_value=1, star=None, dstar=None)
1.726 + subprogram = Subprogram(name=function.name, acquire_locals=0, returns_value=1, star=None, dstar=None)
1.727 self.current_subprograms.append(subprogram)
1.728 - subprogram.code = self.dispatch(function.code) + [Return(function)]
1.729 + subprogram.code = self.dispatch(function.code) + [Return()]
1.730 self.current_subprograms.pop()
1.731 self._visitFunction(function, subprogram)
1.732
1.733 # Make a definition of the function associating it with a name.
1.734
1.735 - result = StoreName(function, 1, name=function.name, expr=LoadRef(function, ref=subprogram))
1.736 + result = StoreName(function, 1, name=function.name, expr=LoadRef(ref=subprogram))
1.737 return result
1.738
1.739 def visitLambda(self, lambda_):
1.740 @@ -1116,9 +1116,9 @@
1.741 # Make a subprogram for the function and record it outside the main
1.742 # tree.
1.743
1.744 - subprogram = Subprogram(lambda_, name=None, acquire_locals=0, returns_value=1, star=None, dstar=None)
1.745 + subprogram = Subprogram(name=None, acquire_locals=0, returns_value=1, star=None, dstar=None)
1.746 self.current_subprograms.append(subprogram)
1.747 - subprogram.code = [Return(lambda_, expr=self.dispatch(lambda_.code))]
1.748 + subprogram.code = [Return(expr=self.dispatch(lambda_.code))]
1.749 self.current_subprograms.pop()
1.750 self._visitFunction(lambda_, subprogram)
1.751
1.752 @@ -1151,28 +1151,28 @@
1.753 (else) -> ...
1.754 """
1.755
1.756 - subprogram = Subprogram(while_, name=None, acquire_locals=1, returns_value=0, params=[], star=None, dstar=None)
1.757 + subprogram = Subprogram(name=None, acquire_locals=1, returns_value=0, params=[], star=None, dstar=None)
1.758 self.current_subprograms.append(subprogram)
1.759
1.760 # Include a conditional statement in the subprogram.
1.761
1.762 - test = Conditional(while_, else_=[])
1.763 - test.test = InvokeFunction(while_, expr=LoadAttr(while_, expr=self.dispatch(while_.test), name="__true__"), args=[], star=None, dstar=None)
1.764 + test = Conditional(else_=[])
1.765 + test.test = InvokeFunction(expr=LoadAttr(expr=self.dispatch(while_.test), name="__true__"), args=[], star=None, dstar=None)
1.766
1.767 # Inside the conditional, add a recursive invocation to the subprogram
1.768 # if the test condition was satisfied.
1.769
1.770 - continuation = InvokeBlock(while_)
1.771 - continuation.expr = LoadRef(while_, ref=subprogram)
1.772 + continuation = InvokeBlock()
1.773 + continuation.expr = LoadRef(ref=subprogram)
1.774
1.775 # Return within the main section of the loop.
1.776
1.777 - test.body = self.dispatch(while_.body) + [continuation, Return(while_)]
1.778 + test.body = self.dispatch(while_.body) + [continuation, Return()]
1.779
1.780 # Provide the else section, if present, along with an explicit return.
1.781
1.782 if while_.else_ is not None:
1.783 - test.else_ = self.dispatch(while_.else_) + [Return(while_)]
1.784 + test.else_ = self.dispatch(while_.else_) + [Return()]
1.785
1.786 # Finish the subprogram definition.
1.787
1.788 @@ -1184,7 +1184,7 @@
1.789 # Make an invocation of the subprogram.
1.790
1.791 result = InvokeBlock(while_, 1)
1.792 - result.expr = LoadRef(while_, ref=subprogram)
1.793 + result.expr = LoadRef(ref=subprogram)
1.794 return result
1.795
1.796 def visitFor(self, for_):
1.797 @@ -1207,43 +1207,43 @@
1.798 (else) -> ...
1.799 """
1.800
1.801 - subprogram = Subprogram(for_, name=None, acquire_locals=1, returns_value=0, params=[], star=None, dstar=None)
1.802 + subprogram = Subprogram(name=None, acquire_locals=1, returns_value=0, params=[], star=None, dstar=None)
1.803 self.current_subprograms.append(subprogram)
1.804
1.805 # Always return from conditional sections/subprograms.
1.806
1.807 if for_.else_ is not None:
1.808 - else_stmt = self.dispatch(for_.else_) + [Return(for_)]
1.809 + else_stmt = self.dispatch(for_.else_) + [Return()]
1.810 else:
1.811 - else_stmt = [Return(for_)]
1.812 + else_stmt = [Return()]
1.813
1.814 # Wrap the assignment in a try...except statement.
1.815
1.816 - try_except = Try(for_, body=[], else_=[], finally_=[])
1.817 - test = Conditional(for_,
1.818 - test=InvokeFunction(for_,
1.819 - expr=LoadName(for_, name="isinstance"),
1.820 - args=[LoadExc(for_), LoadName(for_, name="StopIteration")],
1.821 + try_except = Try(body=[], else_=[], finally_=[])
1.822 + test = Conditional(
1.823 + test=InvokeFunction(
1.824 + expr=LoadName(name="isinstance"),
1.825 + args=[LoadExc(), LoadName(name="StopIteration")],
1.826 star=None,
1.827 dstar=None),
1.828 body=else_stmt,
1.829 - else_=[Raise(for_, expr=LoadExc(for_))])
1.830 + else_=[Raise(expr=LoadExc())])
1.831 try_except.handler = [test]
1.832
1.833 - assign = Assign(for_,
1.834 + assign = Assign(
1.835 code=[
1.836 - StoreTemp(for_, expr=InvokeFunction(for_, expr=LoadAttr(for_, expr=LoadTemp(for_), name="next"), args=[], star=None, dstar=None)),
1.837 + StoreTemp(expr=InvokeFunction(expr=LoadAttr(expr=LoadTemp(), name="next"), args=[], star=None, dstar=None)),
1.838 self.dispatch(for_.assign),
1.839 - ReleaseTemp(for_)
1.840 + ReleaseTemp()
1.841 ])
1.842
1.843 # Inside the conditional, add a recursive invocation to the subprogram
1.844 # if the test condition was satisfied.
1.845
1.846 - continuation = InvokeBlock(for_)
1.847 - continuation.expr = LoadRef(for_, ref=subprogram)
1.848 + continuation = InvokeBlock()
1.849 + continuation.expr = LoadRef(ref=subprogram)
1.850 try_except.body = [assign] + self.dispatch(for_.body) + [continuation]
1.851 - subprogram.code = [try_except, Return(for_)]
1.852 + subprogram.code = [try_except, Return()]
1.853
1.854 # Finish the subprogram definition.
1.855
1.856 @@ -1255,9 +1255,9 @@
1.857
1.858 result = Assign(for_, 1)
1.859 result.code = [
1.860 - StoreTemp(for_,
1.861 - expr=InvokeFunction(for_,
1.862 - expr=LoadAttr(for_,
1.863 + StoreTemp(
1.864 + expr=InvokeFunction(
1.865 + expr=LoadAttr(
1.866 name="__iter__",
1.867 expr=self.dispatch(for_.list)
1.868 ),
1.869 @@ -1266,8 +1266,8 @@
1.870 dstar=None
1.871 )
1.872 ),
1.873 - InvokeBlock(for_, expr=LoadRef(for_, ref=subprogram)),
1.874 - ReleaseTemp(for_)
1.875 + InvokeBlock(expr=LoadRef(ref=subprogram)),
1.876 + ReleaseTemp()
1.877 ]
1.878 return result
1.879