|
@@ -455,13 +455,13 @@ class CompoundInstruction(Instruction):
|
|
|
|
|
|
def has_result(self):
|
|
|
"""Tells if this instruction has a result."""
|
|
|
- return self.second.has_result()
|
|
|
+ return self.second.has_result() or self.first.has_result()
|
|
|
|
|
|
def simplify(self):
|
|
|
"""Applies basic simplification to this instruction and its children."""
|
|
|
-
|
|
|
simple_fst, simple_snd = self.first.simplify(), self.second.simplify()
|
|
|
- if not simple_fst.has_definition():
|
|
|
+ if not simple_fst.has_definition() and (
|
|
|
+ not simple_fst.has_result() or simple_snd.has_result()):
|
|
|
return simple_snd
|
|
|
elif (not simple_snd.has_definition()) and (not simple_snd.has_result()):
|
|
|
return simple_fst
|
|
@@ -470,8 +470,15 @@ class CompoundInstruction(Instruction):
|
|
|
|
|
|
def generate_python_def(self, code_generator):
|
|
|
"""Generates Python code for this instruction."""
|
|
|
- self.first.generate_python_def(code_generator)
|
|
|
- code_generator.append_move_definition(self, self.second)
|
|
|
+ if self.second.has_result():
|
|
|
+ self.first.generate_python_def(code_generator)
|
|
|
+ code_generator.append_move_definition(self, self.second)
|
|
|
+ elif self.first.has_result():
|
|
|
+ code_generator.append_move_definition(self, self.first)
|
|
|
+ self.second.generate_python_def(code_generator)
|
|
|
+ else:
|
|
|
+ self.first.generate_python_def(code_generator)
|
|
|
+ self.second.generate_python_def(code_generator)
|
|
|
|
|
|
class LiteralInstruction(Instruction):
|
|
|
"""Represents an integer, floating-point, string or Boolean literal."""
|