Fixing code generation of array indexes in Function Blocks.
authorMario de Sousa <msousa@fe.up.pt>
Tue, 17 May 2011 10:34:00 +0100
changeset 298 022a874149ce
parent 297 5670eda90408
child 299 de1be61482fa
Fixing code generation of array indexes in Function Blocks.
stage4/generate_c/generate_c_st.cc
--- a/stage4/generate_c/generate_c_st.cc	Sun May 15 10:22:15 2011 +0100
+++ b/stage4/generate_c/generate_c_st.cc	Tue May 17 10:34:00 2011 +0100
@@ -205,22 +205,22 @@
 void *visit(symbolic_variable_c *symbol) {
   unsigned int vartype;
   if (wanted_variablegeneration == complextype_base_vg)
-	generate_c_base_c::visit(symbol);
+         generate_c_base_c::visit(symbol);
   else if (wanted_variablegeneration == complextype_suffix_vg)
-	return NULL;
+         return NULL;
   else if (this->is_variable_prefix_null()) {
-	vartype = search_varfb_instance_type->get_vartype(symbol);
-	if (wanted_variablegeneration == fparam_output_vg) {
-	  s4o.print("&(");
-      generate_c_base_c::visit(symbol);
-      s4o.print(")");
-    }
-    else {
-      generate_c_base_c::visit(symbol);
-    }
+         vartype = search_varfb_instance_type->get_vartype(symbol);
+         if (wanted_variablegeneration == fparam_output_vg) {
+           s4o.print("&(");
+           generate_c_base_c::visit(symbol);
+           s4o.print(")");
+         } 
+         else {
+           generate_c_base_c::visit(symbol);
+         }
   }
   else
-	print_getter(symbol);
+      print_getter(symbol);
   return NULL;
 }
 
@@ -301,7 +301,9 @@
       if (current_array_type == NULL) ERROR;
 
       s4o.print(".table");
+      wanted_variablegeneration = expression_vg;
       symbol->subscript_list->accept(*this);
+      wanted_variablegeneration = complextype_suffix_vg;
 
       current_array_type = NULL;
       break;