1.1 --- a/simplify.py Sat Jul 15 15:26:54 2006 +0200
1.2 +++ b/simplify.py Sat Jul 15 15:29:26 2006 +0200
1.3 @@ -200,12 +200,17 @@
1.4 subprogram = Subprogram(name=hex(id(and_)), acquire_locals=1, returns_value=1, params=[], star=None, dstar=None)
1.5 self.current_subprograms.append(subprogram)
1.6
1.7 + # In the subprogram, make instructions which store each operand, test
1.8 + # for each operand's truth status, and if appropriate return from the
1.9 + # subprogram with the value of the operand.
1.10 +
1.11 nodes = []
1.12 last = and_.nodes[-1]
1.13 for node in and_.nodes:
1.14 expr = self.dispatch(node)
1.15 if node is not last:
1.16 - invocation = Not(expr=Invoke(expr=LoadAttr(expr=StoreTemp(expr=expr), name="__true__"),
1.17 + nodes.append(StoreTemp(expr=expr))
1.18 + invocation = Not(expr=Invoke(expr=LoadAttr(expr=LoadTemp(), name="__true__"),
1.19 params=[], star=None, dstar=None))
1.20 nodes.append(Conditional(test=invocation, body=[Return(expr=LoadTemp())]))
1.21 nodes.append(ReleaseTemp())
1.22 @@ -229,12 +234,17 @@
1.23 subprogram = Subprogram(name=hex(id(or_)), acquire_locals=1, returns_value=1, params=[], star=None, dstar=None)
1.24 self.current_subprograms.append(subprogram)
1.25
1.26 + # In the subprogram, make instructions which store each operand, test
1.27 + # for each operand's truth status, and if appropriate return from the
1.28 + # subprogram with the value of the operand.
1.29 +
1.30 nodes = []
1.31 last = or_.nodes[-1]
1.32 for node in or_.nodes:
1.33 expr = self.dispatch(node)
1.34 if node is not last:
1.35 - invocation = Invoke(expr=LoadAttr(expr=StoreTemp(expr=expr), name="__true__"),
1.36 + nodes.append(StoreTemp(expr=expr))
1.37 + invocation = Invoke(expr=LoadAttr(expr=LoadTemp(), name="__true__"),
1.38 params=[], star=None, dstar=None)
1.39 nodes.append(Conditional(test=invocation, body=[Return(expr=LoadTemp())]))
1.40 nodes.append(ReleaseTemp())