stage4/generate_cc/generate_cc_st.cc
changeset 25 e6a841e365b7
parent 24 7e830409f72a
child 26 fd67f54e64e1
equal deleted inserted replaced
24:7e830409f72a 25:e6a841e365b7
    64      * This object instance will then later be called while the
    64      * This object instance will then later be called while the
    65      * remaining st code is being handled.
    65      * remaining st code is being handled.
    66      */
    66      */
    67     search_expression_type_c *search_expression_type;
    67     search_expression_type_c *search_expression_type;
    68 
    68 
       
    69     search_varfb_instance_type_c *search_varfb_instance_type;
       
    70 
    69   public:
    71   public:
    70     generate_cc_st_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix = NULL)
    72     generate_cc_st_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix = NULL)
    71     : generate_cc_typedecl_c(s4o_ptr) {
    73     : generate_cc_typedecl_c(s4o_ptr) {
    72       search_fb_instance_decl = new search_fb_instance_decl_c(scope);
    74       search_fb_instance_decl = new search_fb_instance_decl_c(scope);
    73       search_expression_type = new search_expression_type_c(scope);
    75       search_expression_type = new search_expression_type_c(scope);
       
    76       search_varfb_instance_type = new search_varfb_instance_type_c(scope);
    74       this->set_variable_prefix(variable_prefix);
    77       this->set_variable_prefix(variable_prefix);
    75     }
    78     }
    76 
    79 
    77     virtual ~generate_cc_st_c(void) {
    80     virtual ~generate_cc_st_c(void) {
    78       delete search_fb_instance_decl;
    81       delete search_fb_instance_decl;
    79       delete search_expression_type;
    82       delete search_expression_type;
       
    83       delete search_varfb_instance_type;
    80     }
    84     }
    81 
    85 
    82 
    86 
    83   private:
    87   private:
    84     /* Some function calls in the body of functions or function blocks
    88     /* Some function calls in the body of functions or function blocks
   119       generate_cc_tempvardecl.generate(stl, &temp_var_name_factory);
   123       generate_cc_tempvardecl.generate(stl, &temp_var_name_factory);
   120       stl->accept(*this);
   124       stl->accept(*this);
   121     }
   125     }
   122 
   126 
   123   private:
   127   private:
   124   
   128 
       
   129 /*********************/
       
   130 /* B 1.4 - Variables */
       
   131 /*********************/
       
   132 void *visit(symbolic_variable_c *symbol) {
       
   133   unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
       
   134   if (vartype == search_var_instance_decl_c::external_vt) {
       
   135     s4o.print("*(");
       
   136     generate_cc_base_c::visit(symbol);
       
   137     s4o.print(")");
       
   138   }
       
   139   else {
       
   140     generate_cc_base_c::visit(symbol);
       
   141   }
       
   142   return NULL;
       
   143 }
       
   144 
   125 /***************************************/
   145 /***************************************/
   126 /* B.3 - Language ST (Structured Text) */
   146 /* B.3 - Language ST (Structured Text) */
   127 /***************************************/
   147 /***************************************/
   128 /***********************/
   148 /***********************/
   129 /* B 3.1 - Expressions */
   149 /* B 3.1 - Expressions */