stage4/generate_c/generate_c_st.cc
changeset 888 4893e6b11b25
parent 887 a5e2eedeef53
child 889 5f380b99e95e
equal deleted inserted replaced
887:a5e2eedeef53 888:4893e6b11b25
   174 void *print_setter(symbol_c* symbol,
   174 void *print_setter(symbol_c* symbol,
   175         symbol_c* type,
   175         symbol_c* type,
   176         symbol_c* value,
   176         symbol_c* value,
   177         symbol_c* fb_symbol = NULL,
   177         symbol_c* fb_symbol = NULL,
   178         symbol_c* fb_value = NULL) {
   178         symbol_c* fb_value = NULL) {
   179   
   179  
   180   bool type_is_complex = false;
       
   181   if (fb_symbol == NULL) {
   180   if (fb_symbol == NULL) {
   182     unsigned int vartype = analyse_variable_c::first_nonfb_vardecltype(symbol, scope_);
   181     unsigned int vartype = analyse_variable_c::first_nonfb_vardecltype(symbol, scope_);
   183     type_is_complex = analyse_variable_c::contains_complex_type(symbol);
       
   184     if (vartype == search_var_instance_decl_c::external_vt) {
   182     if (vartype == search_var_instance_decl_c::external_vt) {
   185       if (!get_datatype_info_c::is_type_valid    (symbol->datatype)) ERROR;
   183       if (!get_datatype_info_c::is_type_valid    (symbol->datatype)) ERROR;
   186       if ( get_datatype_info_c::is_function_block(symbol->datatype))
   184       if ( get_datatype_info_c::is_function_block(symbol->datatype))
   187         s4o.print(SET_EXTERNAL_FB);
   185         s4o.print(SET_EXTERNAL_FB);
   188       else
   186       else
   199       s4o.print(SET_EXTERNAL_FB);
   197       s4o.print(SET_EXTERNAL_FB);
   200     else
   198     else
   201       s4o.print(SET_VAR);
   199       s4o.print(SET_VAR);
   202   }
   200   }
   203   s4o.print("(");
   201   s4o.print("(");
   204 
       
   205   
   202   
   206   if (fb_symbol != NULL) {
   203   if (fb_symbol != NULL) {
   207     print_variable_prefix();
   204     print_variable_prefix();
       
   205     // It is my (MJS) conviction that by this time the following will always be true...
       
   206     //   wanted_variablegeneration == expression_vg;
   208     fb_symbol->accept(*this);
   207     fb_symbol->accept(*this);
   209     s4o.print(".,");
   208     s4o.print(".,");
       
   209     symbol->accept(*this);
       
   210     s4o.print(",");
       
   211     s4o.print(",");    
   210   }
   212   }
   211   else {
   213   else {
   212     wanted_variablegeneration = complextype_base_vg;
       
   213     print_variable_prefix();
   214     print_variable_prefix();
   214     s4o.print(",");    
   215     s4o.print(",");    
   215   }  
   216     wanted_variablegeneration = complextype_base_vg;
   216 
   217     symbol->accept(*this);
   217   symbol->accept(*this);
   218     s4o.print(",");
   218   s4o.print(",");
       
   219   if (type_is_complex) {
       
   220     wanted_variablegeneration = complextype_suffix_vg;
   219     wanted_variablegeneration = complextype_suffix_vg;
   221     symbol->accept(*this);
   220     symbol->accept(*this);
   222   }
   221     s4o.print(",");
   223   s4o.print(",");
   222   }
   224   wanted_variablegeneration = expression_vg;
   223   wanted_variablegeneration = expression_vg;
   225   print_check_function(type, value, fb_value);
   224   print_check_function(type, value, fb_value);
   226   s4o.print(")");
   225   s4o.print(")");
   227   wanted_variablegeneration = expression_vg;
   226   wanted_variablegeneration = expression_vg;
   228   return NULL;
   227   return NULL;