stage4/generate_c/generate_c_il.cc
changeset 505 21be0f2f242d
parent 498 0637a4490c8c
child 531 e7d6f28fc882
equal deleted inserted replaced
504:f8d422b98315 505:21be0f2f242d
   230      * a function declaration.
   230      * a function declaration.
   231      */
   231      */
   232     search_fb_instance_decl_c *search_fb_instance_decl;
   232     search_fb_instance_decl_c *search_fb_instance_decl;
   233 
   233 
   234     search_varfb_instance_type_c *search_varfb_instance_type;
   234     search_varfb_instance_type_c *search_varfb_instance_type;
       
   235     search_var_instance_decl_c   *search_var_instance_decl;
   235 
   236 
   236     search_base_type_c search_base_type;
   237     search_base_type_c search_base_type;
   237 
   238 
   238     symbol_c* current_array_type;
   239     symbol_c* current_array_type;
   239     symbol_c* current_param_type;
   240     symbol_c* current_param_type;
   250       default_variable_back_name(IL_DEFVAR_BACK, NULL)
   251       default_variable_back_name(IL_DEFVAR_BACK, NULL)
   251     {
   252     {
   252       search_expression_type = new search_expression_type_c(scope);
   253       search_expression_type = new search_expression_type_c(scope);
   253       search_fb_instance_decl = new search_fb_instance_decl_c(scope);
   254       search_fb_instance_decl = new search_fb_instance_decl_c(scope);
   254       search_varfb_instance_type = new search_varfb_instance_type_c(scope);
   255       search_varfb_instance_type = new search_varfb_instance_type_c(scope);
       
   256       search_var_instance_decl   = new search_var_instance_decl_c(scope);
       
   257       
   255       current_operand = NULL;
   258       current_operand = NULL;
   256       current_operand_type = NULL;
   259       current_operand_type = NULL;
   257       il_default_variable_init_value = NULL;
   260       il_default_variable_init_value = NULL;
   258       current_array_type = NULL;
   261       current_array_type = NULL;
   259       current_param_type = NULL;
   262       current_param_type = NULL;
   265 
   268 
   266     virtual ~generate_c_il_c(void) {
   269     virtual ~generate_c_il_c(void) {
   267       delete search_fb_instance_decl;
   270       delete search_fb_instance_decl;
   268       delete search_expression_type;
   271       delete search_expression_type;
   269       delete search_varfb_instance_type;
   272       delete search_varfb_instance_type;
       
   273       delete search_var_instance_decl;
   270     }
   274     }
   271 
   275 
   272     void generate(instruction_list_c *il) {
   276     void generate(instruction_list_c *il) {
   273       il->accept(*this);
   277       il->accept(*this);
   274     }
   278     }
   433                search_expression_type->is_literal_real_type(this->current_operand_type))
   437                search_expression_type->is_literal_real_type(this->current_operand_type))
   434         this->current_operand_type = this->default_variable_name.current_type;
   438         this->current_operand_type = this->default_variable_name.current_type;
   435     }
   439     }
   436 
   440 
   437     void *print_getter(symbol_c *symbol) {
   441     void *print_getter(symbol_c *symbol) {
   438       unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
   442       unsigned int vartype = search_var_instance_decl->get_vartype(symbol);
   439       if (wanted_variablegeneration == fparam_output_vg) {
   443       if (wanted_variablegeneration == fparam_output_vg) {
   440       	if (vartype == search_var_instance_decl_c::external_vt)
   444       	if (vartype == search_var_instance_decl_c::external_vt)
   441           s4o.print(GET_EXTERNAL_BY_REF);
   445           s4o.print(GET_EXTERNAL_BY_REF);
   442         else if (vartype == search_var_instance_decl_c::located_vt)
   446         else if (vartype == search_var_instance_decl_c::located_vt)
   443           s4o.print(GET_LOCATED_BY_REF);
   447           s4o.print(GET_LOCATED_BY_REF);
   455       s4o.print("(");
   459       s4o.print("(");
   456 
   460 
   457       variablegeneration_t old_wanted_variablegeneration = wanted_variablegeneration;
   461       variablegeneration_t old_wanted_variablegeneration = wanted_variablegeneration;
   458       wanted_variablegeneration = complextype_base_vg;
   462       wanted_variablegeneration = complextype_base_vg;
   459       symbol->accept(*this);
   463       symbol->accept(*this);
   460       if (search_varfb_instance_type->type_is_complex())
   464       if (search_varfb_instance_type->type_is_complex(symbol))
   461         s4o.print(",");
   465         s4o.print(",");
   462       wanted_variablegeneration = complextype_suffix_vg;
   466       wanted_variablegeneration = complextype_suffix_vg;
   463       symbol->accept(*this);
   467       symbol->accept(*this);
   464       s4o.print(")");
   468       s4o.print(")");
   465       wanted_variablegeneration = old_wanted_variablegeneration;
   469       wanted_variablegeneration = old_wanted_variablegeneration;
   473     		symbol_c* fb_value = NULL,
   477     		symbol_c* fb_value = NULL,
   474     		bool negative = false) {
   478     		bool negative = false) {
   475 
   479 
   476       bool type_is_complex = false;
   480       bool type_is_complex = false;
   477       if (fb_symbol == NULL) {
   481       if (fb_symbol == NULL) {
   478         unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
   482         unsigned int vartype = search_var_instance_decl->get_vartype(symbol);
   479         type_is_complex = search_varfb_instance_type->type_is_complex();
   483         type_is_complex = search_varfb_instance_type->type_is_complex(symbol);
   480         if (vartype == search_var_instance_decl_c::external_vt)
   484         if (vartype == search_var_instance_decl_c::external_vt)
   481           s4o.print(SET_EXTERNAL);
   485           s4o.print(SET_EXTERNAL);
   482         else if (vartype == search_var_instance_decl_c::located_vt)
   486         else if (vartype == search_var_instance_decl_c::located_vt)
   483           s4o.print(SET_LOCATED);
   487           s4o.print(SET_LOCATED);
   484         else
   488         else
   589       break;
   593       break;
   590     case complextype_suffix_vg:
   594     case complextype_suffix_vg:
   591 	  break;
   595 	  break;
   592     default:
   596     default:
   593       if (this->is_variable_prefix_null()) {
   597       if (this->is_variable_prefix_null()) {
   594 	    vartype = search_varfb_instance_type->get_vartype(symbol);
   598 	    vartype = search_var_instance_decl->get_vartype(symbol);
   595         if (wanted_variablegeneration == fparam_output_vg) {
   599         if (wanted_variablegeneration == fparam_output_vg) {
   596           s4o.print("&(");
   600           s4o.print("&(");
   597           generate_c_base_c::visit(symbol);
   601           generate_c_base_c::visit(symbol);
   598           s4o.print(")");
   602           s4o.print(")");
   599         }
   603         }