stage4/generate_c/generate_c_st.cc
changeset 1095 36bbd0b64816
parent 1076 efaa818ef637
child 1098 84bbafb4fb26
equal deleted inserted replaced
1094:068c28266332 1095:36bbd0b64816
   167         symbol_c* type,
   167         symbol_c* type,
   168         symbol_c* value,
   168         symbol_c* value,
   169         symbol_c* fb_symbol = NULL,
   169         symbol_c* fb_symbol = NULL,
   170         symbol_c* fb_value = NULL) {
   170         symbol_c* fb_value = NULL) {
   171  
   171  
       
   172   unsigned int vartype;
   172   if (fb_symbol == NULL) {
   173   if (fb_symbol == NULL) {
   173     unsigned int vartype = analyse_variable_c::first_nonfb_vardecltype(symbol, scope_);
   174     vartype = analyse_variable_c::first_nonfb_vardecltype(symbol, scope_);
   174     symbol_c *first_nonfb = analyse_variable_c::find_first_nonfb(symbol);
   175     symbol_c *first_nonfb = analyse_variable_c::find_first_nonfb(symbol);
   175     if (first_nonfb == NULL) ERROR;
   176     if (first_nonfb == NULL) ERROR;
   176     if (vartype == search_var_instance_decl_c::external_vt) {
   177     if (vartype == search_var_instance_decl_c::external_vt) {
   177       if (!get_datatype_info_c::is_type_valid    (first_nonfb->datatype)) ERROR;
   178       if (!get_datatype_info_c::is_type_valid    (first_nonfb->datatype)) ERROR;
   178       if ( get_datatype_info_c::is_function_block(first_nonfb->datatype)) // handle situation where we are copying a complete fb -> fb1.fb2.fb3 := fb4 (and fb3 is external!)
   179       if ( get_datatype_info_c::is_function_block(first_nonfb->datatype)) // handle situation where we are copying a complete fb -> fb1.fb2.fb3 := fb4 (and fb3 is external!)
   184       s4o.print(SET_LOCATED);
   185       s4o.print(SET_LOCATED);
   185     else
   186     else
   186       s4o.print(SET_VAR);
   187       s4o.print(SET_VAR);
   187   }
   188   }
   188   else {
   189   else {
   189     unsigned int vartype = search_var_instance_decl->get_vartype(fb_symbol);
   190     vartype = search_var_instance_decl->get_vartype(fb_symbol);
   190     if (vartype == search_var_instance_decl_c::external_vt)
   191     if (vartype == search_var_instance_decl_c::external_vt)
   191       s4o.print(SET_EXTERNAL_FB);
   192       s4o.print(SET_EXTERNAL_FB);
   192     else
   193     else
   193       s4o.print(SET_VAR);
   194       s4o.print(SET_VAR);
   194   }
   195   }
   195   s4o.print("(");
   196   s4o.print("(");
   196   
   197   
   197   if (fb_symbol != NULL) {
   198   if (fb_symbol != NULL) {
   198     print_variable_prefix();
   199     if (vartype == search_var_instance_decl_c::external_vt){
   199     // It is my (MJS) conviction that by this time the following will always be true...
   200         print_variable_prefix();
   200     //   wanted_variablegeneration == expression_vg;
   201         s4o.print(",");
   201     fb_symbol->accept(*this);
   202         fb_symbol->accept(*this);
   202     s4o.print(".,");
   203         s4o.print("->");
   203     symbol->accept(*this);
   204         symbol->accept(*this);
       
   205     }else{
       
   206         print_variable_prefix();
       
   207         // It is my (MJS) conviction that by this time the following will always be true...
       
   208         //   wanted_variablegeneration == expression_vg;
       
   209         fb_symbol->accept(*this);
       
   210         s4o.print(".,");
       
   211         symbol->accept(*this);
       
   212     }
   204     s4o.print(",");
   213     s4o.print(",");
   205     s4o.print(",");    
   214     s4o.print(",");    
   206   } else {
   215   } else {
   207     print_variable_prefix();
   216     print_variable_prefix();
   208     s4o.print(",");    
   217     s4o.print(",");