stage4/generate_c/generate_c_inlinefcall.cc
changeset 625 c0bda77b37a0
parent 410 c6486bd97392
parent 594 c8092e909886
child 667 bd1360f29f15
child 706 31553c22f318
equal deleted inserted replaced
412:aad38592bdde 625:c0bda77b37a0
   104 	symbol_c *fbname;
   104 	symbol_c *fbname;
   105 
   105 
   106     search_expression_type_c *search_expression_type;
   106     search_expression_type_c *search_expression_type;
   107 
   107 
   108     search_varfb_instance_type_c *search_varfb_instance_type;
   108     search_varfb_instance_type_c *search_varfb_instance_type;
       
   109     search_var_instance_decl_c   *search_var_instance_decl;
   109 
   110 
   110     search_base_type_c search_base_type;
   111     search_base_type_c search_base_type;
   111 
   112 
   112     variablegeneration_t wanted_variablegeneration;
   113     variablegeneration_t wanted_variablegeneration;
   113 
   114 
   117       default_variable_name(IL_DEFVAR, NULL),
   118       default_variable_name(IL_DEFVAR, NULL),
   118       default_variable_back_name(IL_DEFVAR_BACK, NULL)
   119       default_variable_back_name(IL_DEFVAR_BACK, NULL)
   119     {
   120     {
   120       search_expression_type = new search_expression_type_c(scope);
   121       search_expression_type = new search_expression_type_c(scope);
   121       search_varfb_instance_type = new search_varfb_instance_type_c(scope);
   122       search_varfb_instance_type = new search_varfb_instance_type_c(scope);
       
   123       search_var_instance_decl   = new search_var_instance_decl_c(scope);
       
   124       
   122       this->set_variable_prefix(variable_prefix);
   125       this->set_variable_prefix(variable_prefix);
   123       current_operand = NULL;
   126       current_operand = NULL;
   124       current_operand_type = NULL;
   127       current_operand_type = NULL;
   125       il_default_variable_init_value = NULL;
   128       il_default_variable_init_value = NULL;
   126       fcall_number = 0;
   129       fcall_number = 0;
   130     }
   133     }
   131 
   134 
   132     virtual ~generate_c_inlinefcall_c(void) {
   135     virtual ~generate_c_inlinefcall_c(void) {
   133       delete search_expression_type;
   136       delete search_expression_type;
   134       delete search_varfb_instance_type;
   137       delete search_varfb_instance_type;
       
   138       delete search_var_instance_decl;
   135     }
   139     }
   136 
   140 
   137     void print(symbol_c* symbol) {
   141     void print(symbol_c* symbol) {
   138       function_call_iterator_c fc_iterator(symbol);
   142       function_call_iterator_c fc_iterator(symbol);
   139       symbol_c* function_call;
   143       symbol_c* function_call;
   173         f_decl->accept(overloaded_func_suf);
   177         f_decl->accept(overloaded_func_suf);
   174       }	
   178       }	
   175       if (function_type_suffix) {
   179       if (function_type_suffix) {
   176         function_type_suffix->accept(*this);
   180         function_type_suffix->accept(*this);
   177       }
   181       }
   178       s4o.print_integer(fcall_number);
   182       s4o.print(fcall_number);
   179       s4o.print("(");
   183       s4o.print("(");
   180       s4o.indent_right();
   184       s4o.indent_right();
   181 
   185 
   182       PARAM_LIST_ITERATOR() {
   186       PARAM_LIST_ITERATOR() {
   183         if (PARAM_DIRECTION == function_param_iterator_c::direction_in) {
   187         if (PARAM_DIRECTION == function_param_iterator_c::direction_in) {
   307 			   search_expression_type->is_literal_real_type(this->current_operand_type))
   311 			   search_expression_type->is_literal_real_type(this->current_operand_type))
   308 		this->current_operand_type = this->default_variable_name.current_type;
   312 		this->current_operand_type = this->default_variable_name.current_type;
   309 	}
   313 	}
   310 
   314 
   311     void *print_getter(symbol_c *symbol) {
   315     void *print_getter(symbol_c *symbol) {
   312       unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
   316       unsigned int vartype = search_var_instance_decl->get_vartype(symbol);
   313       if (vartype == search_var_instance_decl_c::external_vt)
   317       if (vartype == search_var_instance_decl_c::external_vt)
   314     	s4o.print(GET_EXTERNAL);
   318     	s4o.print(GET_EXTERNAL);
   315       else if (vartype == search_var_instance_decl_c::located_vt)
   319       else if (vartype == search_var_instance_decl_c::located_vt)
   316     	s4o.print(GET_LOCATED);
   320     	s4o.print(GET_LOCATED);
   317       else
   321       else
   318     	s4o.print(GET_VAR);
   322     	s4o.print(GET_VAR);
   319       s4o.print("(");
   323       s4o.print("(");
   320 
   324 
   321       wanted_variablegeneration = complextype_base_vg;
   325       wanted_variablegeneration = complextype_base_vg;
   322       symbol->accept(*this);
   326       symbol->accept(*this);
   323       if (search_varfb_instance_type->type_is_complex())
   327       if (search_var_instance_decl->type_is_complex(symbol))
   324     	s4o.print(",");
   328     	s4o.print(",");
   325       wanted_variablegeneration = complextype_suffix_vg;
   329       wanted_variablegeneration = complextype_suffix_vg;
   326       symbol->accept(*this);
   330       symbol->accept(*this);
   327       s4o.print(")");
   331       s4o.print(")");
   328       wanted_variablegeneration = expression_vg;
   332       wanted_variablegeneration = expression_vg;
   330     }
   334     }
   331 
   335 
   332     void *print_setter(symbol_c* symbol,
   336     void *print_setter(symbol_c* symbol,
   333     		symbol_c* type,
   337     		symbol_c* type,
   334     		symbol_c* value) {
   338     		symbol_c* value) {
   335       unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
   339       unsigned int vartype = search_var_instance_decl->get_vartype(symbol);
   336       if (vartype == search_var_instance_decl_c::external_vt)
   340       if (vartype == search_var_instance_decl_c::external_vt)
   337         s4o.print(SET_EXTERNAL);
   341         s4o.print(SET_EXTERNAL);
   338       else if (vartype == search_var_instance_decl_c::located_vt)
   342       else if (vartype == search_var_instance_decl_c::located_vt)
   339         s4o.print(SET_LOCATED);
   343         s4o.print(SET_LOCATED);
   340       else
   344       else
   344       wanted_variablegeneration = complextype_base_vg;
   348       wanted_variablegeneration = complextype_base_vg;
   345       symbol->accept(*this);
   349       symbol->accept(*this);
   346       s4o.print(",");
   350       s4o.print(",");
   347       wanted_variablegeneration = expression_vg;
   351       wanted_variablegeneration = expression_vg;
   348       print_check_function(type, value, NULL, true);
   352       print_check_function(type, value, NULL, true);
   349       if (search_varfb_instance_type->type_is_complex()) {
   353       if (search_var_instance_decl->type_is_complex(symbol)) {
   350         s4o.print(",");
   354         s4o.print(",");
   351         wanted_variablegeneration = complextype_suffix_vg;
   355         wanted_variablegeneration = complextype_suffix_vg;
   352         symbol->accept(*this);
   356         symbol->accept(*this);
   353       }
   357       }
   354       s4o.print(")");
   358       s4o.print(")");
   395     /*************************************/
   399     /*************************************/
   396 
   400 
   397     // SYM_REF2(structured_variable_c, record_variable, field_selector)
   401     // SYM_REF2(structured_variable_c, record_variable, field_selector)
   398     void *visit(structured_variable_c *symbol) {
   402     void *visit(structured_variable_c *symbol) {
   399       TRACE("structured_variable_c");
   403       TRACE("structured_variable_c");
   400       unsigned int vartype = search_varfb_instance_type->get_vartype(symbol->record_variable);
   404       bool type_is_complex = search_var_instance_decl->type_is_complex(symbol->record_variable);
   401       bool type_is_complex = search_varfb_instance_type->type_is_complex();
       
   402       if (generating_inlinefunction) {
   405       if (generating_inlinefunction) {
   403         switch (wanted_variablegeneration) {
   406         switch (wanted_variablegeneration) {
   404           case complextype_base_vg:
   407           case complextype_base_vg:
   405             symbol->record_variable->accept(*this);
   408             symbol->record_variable->accept(*this);
   406             if (!type_is_complex) {
   409             if (!type_is_complex) {
   831 	   * We also need to update the data type currently stored within
   834 	   * We also need to update the data type currently stored within
   832 	   * the variable used to pass the data to the outside scope...
   835 	   * the variable used to pass the data to the outside scope...
   833 	   */
   836 	   */
   834 	  this->default_variable_back_name.current_type = this->default_variable_name.current_type;
   837 	  this->default_variable_back_name.current_type = this->default_variable_name.current_type;
   835 	  return NULL;
   838 	  return NULL;
       
   839     }
       
   840     
       
   841     // SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;)
       
   842     void *visit(il_simple_instruction_c *symbol)	{
       
   843       return symbol->il_simple_instruction->accept(*this);
   836     }
   844     }
   837 
   845 
   838     void *visit(LD_operator_c *symbol)	{
   846     void *visit(LD_operator_c *symbol)	{
   839       /* the data type resulting from this operation... */
   847       /* the data type resulting from this operation... */
   840       this->default_variable_name.current_type = this->current_operand_type;
   848       this->default_variable_name.current_type = this->current_operand_type;