1.1 --- a/simplify.py Sat Oct 21 02:56:25 2006 +0200
1.2 +++ b/simplify.py Sat Oct 21 18:20:00 2006 +0200
1.3 @@ -603,19 +603,53 @@
1.4 return result
1.5
1.6 def visitNot(self, not_):
1.7 - result = Not(not_, 1, expr=InvokeFunction(not_, expr=LoadAttr(not_, expr=self.dispatch(not_.expr), name="__true__"), args=[], star=None, dstar=None))
1.8 + result = Not(not_, 1,
1.9 + expr=InvokeFunction(not_,
1.10 + expr=LoadAttr(not_,
1.11 + expr=self.dispatch(not_.expr),
1.12 + name="__true__"
1.13 + ),
1.14 + args=[],
1.15 + star=None,
1.16 + dstar=None
1.17 + )
1.18 + )
1.19 return result
1.20
1.21 # Operators.
1.22
1.23 def visitUnaryAdd(self, unaryadd):
1.24 - return InvokeFunction(unaryadd, 1, expr=LoadAttr(unaryadd, expr=self.dispatch(unaryadd.expr), name="__pos__"), args=[], star=None, dstar=None)
1.25 + return InvokeFunction(unaryadd, 1,
1.26 + expr=LoadAttr(unaryadd,
1.27 + expr=self.dispatch(unaryadd.expr),
1.28 + name="__pos__"
1.29 + ),
1.30 + args=[],
1.31 + star=None,
1.32 + dstar=None
1.33 + )
1.34
1.35 def visitUnarySub(self, unarysub):
1.36 - return InvokeFunction(unarysub, 1, expr=LoadAttr(unarysub, expr=self.dispatch(unarysub.expr), name="__neg__"), args=[], star=None, dstar=None)
1.37 + return InvokeFunction(unarysub, 1,
1.38 + expr=LoadAttr(unarysub,
1.39 + expr=self.dispatch(unarysub.expr),
1.40 + name="__neg__"
1.41 + ),
1.42 + args=[],
1.43 + star=None,
1.44 + dstar=None
1.45 + )
1.46
1.47 def visitInvert(self, invert):
1.48 - return InvokeFunction(invert, 1, expr=LoadAttr(invert, expr=self.dispatch(invert.expr), name="__invert__"), args=[], star=None, dstar=None)
1.49 + return InvokeFunction(invert, 1,
1.50 + expr=LoadAttr(invert,
1.51 + expr=self.dispatch(invert.expr),
1.52 + name="__invert__"
1.53 + ),
1.54 + args=[],
1.55 + star=None,
1.56 + dstar=None
1.57 + )
1.58
1.59 def visitAdd(self, add):
1.60
1.61 @@ -669,6 +703,23 @@
1.62 }
1.63
1.64 def visitAugAssign(self, augassign):
1.65 +
1.66 + """
1.67 + Convert the augmented assignment...
1.68 +
1.69 + AugAssign (node) -> Name | Getattr | Slice | Subscript
1.70 + (op)
1.71 + (expr)
1.72 +
1.73 + ...to:
1.74 +
1.75 + Assign (code) -> StoreTemp (expr) -> InvokeFunction (expr) -> LoadAttr (expr) -> <name>
1.76 + (name) -> <op>
1.77 + StoreName (name) -> <name>
1.78 + (expr) -> LoadTemp
1.79 + ReleaseTemp
1.80 + """
1.81 +
1.82 result = Assign(augassign, 1)
1.83 expr = self.dispatch(augassign.expr)
1.84
1.85 @@ -708,7 +759,7 @@
1.86 expr=InvokeFunction(augassign,
1.87 args=[expr], star=None, dstar=None,
1.88 expr=LoadAttr(augassign,
1.89 - expr=LoadAttr(augassign,
1.90 + expr=LoadAttr(augassign.node, 1,
1.91 expr=LoadTemp(augassign, index="expr"),
1.92 name=augassign.node.attrname
1.93 ),