1.1 --- a/translator.py Tue Feb 28 17:00:26 2017 +0100
1.2 +++ b/translator.py Tue Feb 28 17:18:48 2017 +0100
1.3 @@ -1396,7 +1396,7 @@
1.4
1.5 "Process the given operator node 'n'."
1.6
1.7 - return NegationResult(self.process_structure_node(n.expr))
1.8 + return self.make_negation(self.process_structure_node(n.expr))
1.9
1.10 def process_raise_node(self, n):
1.11
1.12 @@ -1610,7 +1610,7 @@
1.13
1.14 # Emit a negated test of the continuation condition.
1.15
1.16 - self.start_if(True, NegationResult(test))
1.17 + self.start_if(True, self.make_negation(test))
1.18 if n.else_:
1.19 self.process_structure_node(n.else_)
1.20 self.writestmt("break;")
1.21 @@ -1676,6 +1676,20 @@
1.22
1.23 return self.temp_usage.has_key(path) and name in self.temp_usage[path]
1.24
1.25 + def make_negation(self, expr):
1.26 +
1.27 + "Return a negated form of 'expr'."
1.28 +
1.29 + result = NegationResult(expr)
1.30 +
1.31 + # Negation discards the temporary results of its operand.
1.32 +
1.33 + temps = expr.discards_temporary()
1.34 + if temps:
1.35 + self.remove_temps(temps)
1.36 +
1.37 + return result
1.38 +
1.39 # Output generation.
1.40
1.41 def start_output(self):