stage4/generate_c/generate_c_st.cc
changeset 933 76324f461aed
parent 911 ef3347dbfa0c
child 936 0f7bcc160568
--- a/stage4/generate_c/generate_c_st.cc	Sat Sep 27 20:09:19 2014 +0100
+++ b/stage4/generate_c/generate_c_st.cc	Sun Sep 28 16:35:44 2014 +0100
@@ -463,6 +463,48 @@
 /***********************/
 /* B 3.1 - Expressions */
 /***********************/
+void *visit(deref_expression_c *symbol) {
+  s4o.print("(");  
+  if (this->is_variable_prefix_null()) {  
+    /* For code in FUNCTIONs */
+    s4o.print("*");  
+    symbol->exp->accept(*this);    
+    s4o.print("");  
+  } else {
+    /* For code in FBs, and PROGRAMS... */
+    s4o.print("(");  
+    unsigned int vartype = analyse_variable_c::first_nonfb_vardecltype(symbol->exp, scope_);
+    if (vartype == search_var_instance_decl_c::external_vt) {
+      if (!get_datatype_info_c::is_type_valid    (symbol->exp->datatype)) ERROR;
+      if ( get_datatype_info_c::is_function_block(symbol->exp->datatype))
+        s4o.print(GET_EXTERNAL_FB_DREF);
+      else
+        s4o.print(GET_EXTERNAL_DREF);
+    }
+    else if (vartype == search_var_instance_decl_c::located_vt)
+      s4o.print(GET_LOCATED_DREF);
+    else
+      s4o.print(GET_VAR_DREF);
+    
+    variablegeneration_t old_wanted_variablegeneration = wanted_variablegeneration; 
+    s4o.print("(");
+    wanted_variablegeneration = complextype_base_vg;
+    print_variable_prefix();
+    symbol->exp->accept(*this);
+    s4o.print(",");
+    wanted_variablegeneration = complextype_suffix_vg;
+    symbol->exp->accept(*this);
+    s4o.print(")");
+    wanted_variablegeneration = old_wanted_variablegeneration;
+    
+    s4o.print(")");  
+  }
+  s4o.print(")");  
+
+  return NULL;
+}
+
+
 void *visit(ref_expression_c *symbol) {
   s4o.print("(");  
   if (this->is_variable_prefix_null()) {