Fix handling of IL parenthesized expressions in generate_c_il_c
authorMario de Sousa <msousa@fe.up.pt>
Thu, 25 Oct 2012 12:48:48 +0100
changeset 687 81dcb3987cbb
parent 686 9b87606d4c07
child 688 c2c0084df58e
Fix handling of IL parenthesized expressions in generate_c_il_c
stage4/generate_c/generate_c_il.cc
--- a/stage4/generate_c/generate_c_il.cc	Thu Oct 25 12:39:01 2012 +0100
+++ b/stage4/generate_c/generate_c_il.cc	Thu Oct 25 12:48:48 2012 +0100
@@ -1462,7 +1462,18 @@
 
 
 // SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;)
-void *visit(il_simple_instruction_c *symbol)    {return symbol->il_simple_instruction->accept(*this);}
+void *visit(il_simple_instruction_c *symbol)    {
+  /* all previous IL instructions should have the same datatype (checked in stage3), so we get the datatype from the first previous IL instruction we find */
+  implicit_variable_current.datatype = (symbol->prev_il_instruction.empty())? NULL : symbol->prev_il_instruction[0]->datatype;
+  implicit_variable_result .datatype = symbol->datatype;
+  
+  symbol->il_simple_instruction->accept(*this);
+  
+  implicit_variable_result .datatype = NULL;
+  implicit_variable_current.datatype = NULL;
+  return NULL;
+}
+
 
 /* | il_initial_param_list il_param_instruction */
 // SYM_LIST(il_param_list_c)