stage4/generate_iec/generate_iec.cc
changeset 690 6156ee2b4e32
parent 596 4efb11e44065
child 805 b737cfc92614
--- a/stage4/generate_iec/generate_iec.cc	Thu Oct 25 18:12:51 2012 +0100
+++ b/stage4/generate_iec/generate_iec.cc	Thu Oct 25 18:20:28 2012 +0100
@@ -1661,6 +1661,14 @@
 
 /* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */
 void *visit(il_expression_c *symbol) {
+  /* Since stage2 will insert an artificial (and equivalent) LD <il_operand> to the simple_instr_list when an 'il_operand' exists, we know
+   * that if (symbol->il_operand != NULL), then the first IL instruction in the simple_instr_list will be the equivalent and artificial
+   * 'LD <il_operand>' IL instruction.
+   * Since we do not want the extra LD instruction, we simply remove it!
+   */
+  if (symbol->il_operand != NULL)
+    ((list_c *)symbol->simple_instr_list)->remove_element(0);
+
   symbol->il_expr_operator->accept(*this);
   s4o.print("(");
   if (symbol->il_operand != NULL)