stage4/generate_c/generate_c.cc
changeset 406 6381589697ff
parent 399 55b074ea7255
child 412 aad38592bdde
child 498 0637a4490c8c
equal deleted inserted replaced
405:7b5d67d1aeef 406:6381589697ff
   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;
       
   186     bool_type_name_c tmp_bool;
   185     bool_type_name_c tmp_bool;
   187 
   186 
   188     void print_list(symbol_c *var_list, symbol_c *data_type) { 
   187     void print_list(symbol_c *var_list, symbol_c *data_type) { 
   189       if (data_type != NULL) {
   188       if (data_type != NULL) {
   190         /* print out the data type once for every variable! */
   189         /* print out the data type once for every variable! */
   196         }  
   195         }  
   197       }
   196       }
   198     }
   197     }
   199     
   198     
   200   public:
   199   public:
   201     print_function_parameter_data_types_c(stage4out_c *s4o_ptr, symbol_c* return_type):
   200     print_function_parameter_data_types_c(stage4out_c *s4o_ptr):
   202       generate_c_base_c(s4o_ptr) {
   201       generate_c_base_c(s4o_ptr) {
   203     	current_type = NULL;
   202     	current_type = NULL;
   204     	this->return_type = return_type;
       
   205       }
   203       }
   206 
   204 
   207     /**************************************/
   205     /**************************************/
   208     /* B.1.5 - Program organization units */
   206     /* B.1.5 - Program organization units */
   209     /**************************************/
   207     /**************************************/
   212     /***********************/
   210     /***********************/
   213     /*   FUNCTION derived_function_name ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
   211     /*   FUNCTION derived_function_name ':' elementary_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     /* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
   215     void *visit(function_declaration_c *symbol) {
   213     void *visit(function_declaration_c *symbol) {
   216       /* return type */
   214       /* return type */
   217       if (this->return_type == NULL)
   215       symbol->type_name->accept(*this);
   218     	symbol->type_name->accept(*this);
       
   219       else
       
   220     	this->return_type->accept(*this);
       
   221       symbol->var_declarations_list->accept(*this);
   216       symbol->var_declarations_list->accept(*this);
   222       return NULL;
   217       return NULL;
   223     }
   218     }
   224 
   219 
   225     /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */
   220     /* already handled by iterator base class (note that generate_c_base_c inherits from iterator_c) */