stage4/generate_c/generate_c.cc
changeset 399 55b074ea7255
parent 397 85151b2f35ca
child 406 6381589697ff
child 495 8c6823fee086
equal deleted inserted replaced
398:f1f3facc59e7 399:55b074ea7255
   180  *     MUL(TIME, INT) : TIME  -> prints out ->  TIME__TIME__INT
   180  *     MUL(TIME, INT) : TIME  -> prints out ->  TIME__TIME__INT
   181  */
   181  */
   182 class print_function_parameter_data_types_c: public generate_c_base_c {
   182 class print_function_parameter_data_types_c: public generate_c_base_c {
   183   private:
   183   private:
   184     symbol_c *current_type;
   184     symbol_c *current_type;
       
   185     symbol_c *return_type;
   185     bool_type_name_c tmp_bool;
   186     bool_type_name_c tmp_bool;
   186 
   187 
   187     void print_list(symbol_c *var_list, symbol_c *data_type) { 
   188     void print_list(symbol_c *var_list, symbol_c *data_type) { 
   188       if (data_type != NULL) {
   189       if (data_type != NULL) {
   189         /* print out the data type once for every variable! */
   190         /* print out the data type once for every variable! */
   195         }  
   196         }  
   196       }
   197       }
   197     }
   198     }
   198     
   199     
   199   public:
   200   public:
   200     print_function_parameter_data_types_c(stage4out_c *s4o_ptr): 
   201     print_function_parameter_data_types_c(stage4out_c *s4o_ptr, symbol_c* return_type):
   201       generate_c_base_c(s4o_ptr)
   202       generate_c_base_c(s4o_ptr) {
   202       {current_type = NULL;}
   203     	current_type = NULL;
       
   204     	this->return_type = return_type;
       
   205       }
   203 
   206 
   204     /**************************************/
   207     /**************************************/
   205     /* B.1.5 - Program organization units */
   208     /* B.1.5 - Program organization units */
   206     /**************************************/
   209     /**************************************/
   207     /***********************/
   210     /***********************/
   208     /* B 1.5.1 - Functions */
   211     /* B 1.5.1 - Functions */
   209     /***********************/
   212     /***********************/
   210     /*   FUNCTION derived_function_name ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
   213     /*   FUNCTION derived_function_name ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
   211     /* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
   214     /* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
   212     void *visit(function_declaration_c *symbol) {
   215     void *visit(function_declaration_c *symbol) {
   213       symbol->type_name->accept(*this); /* return type */
   216       /* return type */
       
   217       if (this->return_type == NULL)
       
   218     	symbol->type_name->accept(*this);
       
   219       else
       
   220     	this->return_type->accept(*this);
   214       symbol->var_declarations_list->accept(*this);
   221       symbol->var_declarations_list->accept(*this);
   215       return NULL;
   222       return NULL;
   216     }
   223     }
   217 
   224 
   218     /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
   225     /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */