stage4/generate_c/generate_c_st.cc
changeset 863 06820d03a433
parent 854 13d0b67de111
child 864 300c27c08753
equal deleted inserted replaced
854:13d0b67de111 863:06820d03a433
    74      *
    74      *
    75      * Note that functions cannot contain calls to function blocks,
    75      * Note that functions cannot contain calls to function blocks,
    76      * so we do not create an object instance when handling
    76      * so we do not create an object instance when handling
    77      * a function declaration.
    77      * a function declaration.
    78      */
    78      */
    79     search_fb_instance_decl_c *search_fb_instance_decl;
    79     search_fb_instance_decl_c    *search_fb_instance_decl;
    80 
       
    81     search_varfb_instance_type_c *search_varfb_instance_type;
    80     search_varfb_instance_type_c *search_varfb_instance_type;
    82     search_var_instance_decl_c   *search_var_instance_decl;
    81     search_var_instance_decl_c   *search_var_instance_decl;
       
    82     
       
    83     symbol_c *scope_;
    83 
    84 
    84     symbol_c* current_array_type;
    85     symbol_c* current_array_type;
    85     symbol_c* current_param_type;
    86     symbol_c* current_param_type;
    86 
    87 
    87     int fcall_number;
    88     int fcall_number;
    96     generate_c_st_c(stage4out_c *s4o_ptr, symbol_c *name, symbol_c *scope, const char *variable_prefix = NULL)
    97     generate_c_st_c(stage4out_c *s4o_ptr, symbol_c *name, symbol_c *scope, const char *variable_prefix = NULL)
    97     : generate_c_typedecl_c(s4o_ptr) {
    98     : generate_c_typedecl_c(s4o_ptr) {
    98       search_fb_instance_decl    = new search_fb_instance_decl_c   (scope);
    99       search_fb_instance_decl    = new search_fb_instance_decl_c   (scope);
    99       search_varfb_instance_type = new search_varfb_instance_type_c(scope);
   100       search_varfb_instance_type = new search_varfb_instance_type_c(scope);
   100       search_var_instance_decl   = new search_var_instance_decl_c  (scope);
   101       search_var_instance_decl   = new search_var_instance_decl_c  (scope);
       
   102       scope_ = scope;
   101       
   103       
   102       this->set_variable_prefix(variable_prefix);
   104       this->set_variable_prefix(variable_prefix);
   103       current_array_type = NULL;
   105       current_array_type = NULL;
   104       current_param_type = NULL;
   106       current_param_type = NULL;
   105       fcall_number = 0;
   107       fcall_number = 0;
   126 
   128 
   127 
   129 
   128 
   130 
   129 
   131 
   130 void *print_getter(symbol_c *symbol) {
   132 void *print_getter(symbol_c *symbol) {
   131   unsigned int vartype = search_var_instance_decl->get_vartype(symbol);
   133   unsigned int vartype = analyse_variable_c::first_nonfb_vardecltype(symbol, scope_);
   132   if (wanted_variablegeneration == fparam_output_vg) {
   134   if (wanted_variablegeneration == fparam_output_vg) {
   133     if (vartype == search_var_instance_decl_c::external_vt) {
   135     if (vartype == search_var_instance_decl_c::external_vt) {
   134       if (!get_datatype_info_c::is_type_valid    (symbol->datatype)) ERROR;
   136       if (!get_datatype_info_c::is_type_valid    (symbol->datatype)) ERROR;
   135       if ( get_datatype_info_c::is_function_block(symbol->datatype))
   137       if ( get_datatype_info_c::is_function_block(symbol->datatype))
   136         s4o.print(GET_EXTERNAL_FB_BY_REF);
   138         s4o.print(GET_EXTERNAL_FB_BY_REF);
   176         symbol_c* fb_symbol = NULL,
   178         symbol_c* fb_symbol = NULL,
   177         symbol_c* fb_value = NULL) {
   179         symbol_c* fb_value = NULL) {
   178   
   180   
   179   bool type_is_complex = false;
   181   bool type_is_complex = false;
   180   if (fb_symbol == NULL) {
   182   if (fb_symbol == NULL) {
   181     unsigned int vartype = search_var_instance_decl->get_vartype(symbol);
   183     unsigned int vartype = analyse_variable_c::first_nonfb_vardecltype(symbol, scope_);
   182     type_is_complex = analyse_variable_c::contains_complex_type(symbol);
   184     type_is_complex = analyse_variable_c::contains_complex_type(symbol);
   183     if (vartype == search_var_instance_decl_c::external_vt) {
   185     if (vartype == search_var_instance_decl_c::external_vt) {
   184       if (!get_datatype_info_c::is_type_valid    (symbol->datatype)) ERROR;
   186       if (!get_datatype_info_c::is_type_valid    (symbol->datatype)) ERROR;
   185       if ( get_datatype_info_c::is_function_block(symbol->datatype))
   187       if ( get_datatype_info_c::is_function_block(symbol->datatype))
   186         s4o.print(SET_EXTERNAL_FB);
   188         s4o.print(SET_EXTERNAL_FB);