stage4/generate_c/generate_c_st.cc
changeset 933 76324f461aed
parent 911 ef3347dbfa0c
child 936 0f7bcc160568
equal deleted inserted replaced
932:061824c45a5b 933:76324f461aed
   461 /* B.3 - Language ST (Structured Text) */
   461 /* B.3 - Language ST (Structured Text) */
   462 /***************************************/
   462 /***************************************/
   463 /***********************/
   463 /***********************/
   464 /* B 3.1 - Expressions */
   464 /* B 3.1 - Expressions */
   465 /***********************/
   465 /***********************/
       
   466 void *visit(deref_expression_c *symbol) {
       
   467   s4o.print("(");  
       
   468   if (this->is_variable_prefix_null()) {  
       
   469     /* For code in FUNCTIONs */
       
   470     s4o.print("*");  
       
   471     symbol->exp->accept(*this);    
       
   472     s4o.print("");  
       
   473   } else {
       
   474     /* For code in FBs, and PROGRAMS... */
       
   475     s4o.print("(");  
       
   476     unsigned int vartype = analyse_variable_c::first_nonfb_vardecltype(symbol->exp, scope_);
       
   477     if (vartype == search_var_instance_decl_c::external_vt) {
       
   478       if (!get_datatype_info_c::is_type_valid    (symbol->exp->datatype)) ERROR;
       
   479       if ( get_datatype_info_c::is_function_block(symbol->exp->datatype))
       
   480         s4o.print(GET_EXTERNAL_FB_DREF);
       
   481       else
       
   482         s4o.print(GET_EXTERNAL_DREF);
       
   483     }
       
   484     else if (vartype == search_var_instance_decl_c::located_vt)
       
   485       s4o.print(GET_LOCATED_DREF);
       
   486     else
       
   487       s4o.print(GET_VAR_DREF);
       
   488     
       
   489     variablegeneration_t old_wanted_variablegeneration = wanted_variablegeneration; 
       
   490     s4o.print("(");
       
   491     wanted_variablegeneration = complextype_base_vg;
       
   492     print_variable_prefix();
       
   493     symbol->exp->accept(*this);
       
   494     s4o.print(",");
       
   495     wanted_variablegeneration = complextype_suffix_vg;
       
   496     symbol->exp->accept(*this);
       
   497     s4o.print(")");
       
   498     wanted_variablegeneration = old_wanted_variablegeneration;
       
   499     
       
   500     s4o.print(")");  
       
   501   }
       
   502   s4o.print(")");  
       
   503 
       
   504   return NULL;
       
   505 }
       
   506 
       
   507 
   466 void *visit(ref_expression_c *symbol) {
   508 void *visit(ref_expression_c *symbol) {
   467   s4o.print("(");  
   509   s4o.print("(");  
   468   if (this->is_variable_prefix_null()) {  
   510   if (this->is_variable_prefix_null()) {  
   469     /* For code in FUNCTIONs */
   511     /* For code in FUNCTIONs */
   470     s4o.print("&(");  
   512     s4o.print("&(");