stage4/generate_c/generate_c_st.cc
changeset 625 c0bda77b37a0
parent 411 3e21d98d0a71
parent 594 c8092e909886
child 667 bd1360f29f15
child 706 31553c22f318
--- a/stage4/generate_c/generate_c_st.cc	Tue Aug 14 19:40:01 2012 +0200
+++ b/stage4/generate_c/generate_c_st.cc	Wed Aug 22 16:46:17 2012 +0200
@@ -89,6 +89,7 @@
     search_expression_type_c *search_expression_type;
 
     search_varfb_instance_type_c *search_varfb_instance_type;
+    search_var_instance_decl_c   *search_var_instance_decl;
 
     search_base_type_c search_base_type;
 
@@ -109,6 +110,8 @@
       search_fb_instance_decl = new search_fb_instance_decl_c(scope);
       search_expression_type = new search_expression_type_c(scope);
       search_varfb_instance_type = new search_varfb_instance_type_c(scope);
+      search_var_instance_decl   = new search_var_instance_decl_c(scope);
+      
       this->set_variable_prefix(variable_prefix);
       current_array_type = NULL;
       current_param_type = NULL;
@@ -122,6 +125,7 @@
       delete search_fb_instance_decl;
       delete search_expression_type;
       delete search_varfb_instance_type;
+      delete search_var_instance_decl;
     }
 
 
@@ -131,11 +135,16 @@
     }
 
   private:
+    
+    
+
+
+
 
 void *print_getter(symbol_c *symbol) {
-  unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
+  unsigned int vartype = search_var_instance_decl->get_vartype(symbol);
   if (wanted_variablegeneration == fparam_output_vg) {
-  	if (vartype == search_var_instance_decl_c::external_vt)
+    if (vartype == search_var_instance_decl_c::external_vt)
       s4o.print(GET_EXTERNAL_BY_REF);
     else if (vartype == search_var_instance_decl_c::located_vt)
       s4o.print(GET_LOCATED_BY_REF);
@@ -143,19 +152,19 @@
       s4o.print(GET_VAR_BY_REF);
   }
   else {
-	if (vartype == search_var_instance_decl_c::external_vt)
-	  s4o.print(GET_EXTERNAL);
-	else if (vartype == search_var_instance_decl_c::located_vt)
-	  s4o.print(GET_LOCATED);
-	else
-	  s4o.print(GET_VAR);
+    if (vartype == search_var_instance_decl_c::external_vt)
+      s4o.print(GET_EXTERNAL);
+    else if (vartype == search_var_instance_decl_c::located_vt)
+      s4o.print(GET_LOCATED);
+    else
+      s4o.print(GET_VAR);
   }
   s4o.print("(");
 
   variablegeneration_t old_wanted_variablegeneration = wanted_variablegeneration;
   wanted_variablegeneration = complextype_base_vg;
   symbol->accept(*this);
-  if (search_varfb_instance_type->type_is_complex())
+  if (search_var_instance_decl->type_is_complex(symbol))
     s4o.print(",");
   wanted_variablegeneration = complextype_suffix_vg;
   symbol->accept(*this);
@@ -172,8 +181,8 @@
   
   bool type_is_complex = false;
   if (fb_symbol == NULL) {
-	unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
-    type_is_complex = search_varfb_instance_type->type_is_complex();
+    unsigned int vartype = search_var_instance_decl->get_vartype(symbol);
+    type_is_complex = search_var_instance_decl->type_is_complex(symbol);
     if (vartype == search_var_instance_decl_c::external_vt)
       s4o.print(SET_EXTERNAL);
     else if (vartype == search_var_instance_decl_c::located_vt)
@@ -239,7 +248,6 @@
 /* B 1.4 - Variables */
 /*********************/
 void *visit(symbolic_variable_c *symbol) {
-  unsigned int vartype;
   switch (wanted_variablegeneration) {
     case complextype_base_assignment_vg:
     case assignment_vg:
@@ -254,7 +262,6 @@
       break;
     default:
       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);
@@ -312,8 +319,7 @@
 // SYM_REF2(structured_variable_c, record_variable, field_selector)
 void *visit(structured_variable_c *symbol) {
   TRACE("structured_variable_c");
-  unsigned int vartype = search_varfb_instance_type->get_vartype(symbol->record_variable);
-  bool type_is_complex = search_varfb_instance_type->type_is_complex();
+  bool type_is_complex = search_var_instance_decl->type_is_complex(symbol->record_variable);
   switch (wanted_variablegeneration) {
     case complextype_base_vg:
     case complextype_base_assignment_vg:
@@ -359,7 +365,7 @@
     case complextype_suffix_vg:
       symbol->subscripted_variable->accept(*this);
 
-      current_array_type = search_varfb_instance_type->get_type_id(symbol->subscripted_variable);
+      current_array_type = search_varfb_instance_type->get_basetype_decl(symbol->subscripted_variable);
       if (current_array_type == NULL) ERROR;
 
       s4o.print(".table");
@@ -373,7 +379,7 @@
       if (this->is_variable_prefix_null()) {
     	symbol->subscripted_variable->accept(*this);
 
-    	current_array_type = search_varfb_instance_type->get_type_id(symbol->subscripted_variable);
+    	current_array_type = search_varfb_instance_type->get_basetype_decl(symbol->subscripted_variable);
     	if (current_array_type == NULL) ERROR;
 
     	s4o.print(".table");
@@ -797,7 +803,7 @@
       print_function_parameter_data_types_c overloaded_func_suf(&s4o);
       f_decl->accept(overloaded_func_suf);
     }
-    s4o.print_integer(fcall_number);
+    s4o.print(fcall_number);
   }
   else {
     function_name->accept(*this);