# HG changeset patch # User Mario de Sousa # Date 1334418293 -3600 # Node ID 21be0f2f242d521b343a0cad9e1d43b0ba68037c # Parent f8d422b98315c867a0432e1798862258593a3e8e Removing code from search_varfb_instance_type_c (use search_var_instance_decl_c instead). (Preparing to delete search_varfb_instance_type_c in the future!) diff -r f8d422b98315 -r 21be0f2f242d absyntax_utils/search_varfb_instance_type.cc --- a/absyntax_utils/search_varfb_instance_type.cc Sat Apr 14 15:19:17 2012 +0100 +++ b/absyntax_utils/search_varfb_instance_type.cc Sat Apr 14 16:44:53 2012 +0100 @@ -125,16 +125,9 @@ - - -unsigned int search_varfb_instance_type_c::get_vartype(symbol_c *variable_name) { - this->init(); - return search_var_instance_decl.get_vartype(variable_name); -} - - - -bool search_varfb_instance_type_c::type_is_complex(void) { +bool search_varfb_instance_type_c::type_is_complex(symbol_c *variable_name) { + this->init(); + variable_name->accept(*this); return this->is_complex; } diff -r f8d422b98315 -r 21be0f2f242d absyntax_utils/search_varfb_instance_type.hh --- a/absyntax_utils/search_varfb_instance_type.hh Sat Apr 14 15:19:17 2012 +0100 +++ b/absyntax_utils/search_varfb_instance_type.hh Sat Apr 14 16:44:53 2012 +0100 @@ -110,14 +110,10 @@ // symbol_c *get_type_decl(symbol_c *variable_name); symbol_c *get_type_id(symbol_c *variable_name); - /* NOTE: I have a feeling that this function should be remvoed/deleted. - * However, it is currently used in stage 4, and before deleting it - * requires that the stage4 code be analysed and fixed (i.e. replace by - * a call to one of the above functions get_basetype_decl(), - * get_type_decl(), get_type_id(). + /* NOTE: The following function should be moved to its own independent visitor class. + * In other words, it will be removed from this class in the future. */ - unsigned int get_vartype(symbol_c *variable_name); - bool type_is_complex(void); + bool type_is_complex(symbol_c *variable_name); private: /* a helper function... */ diff -r f8d422b98315 -r 21be0f2f242d stage4/generate_c/generate_c_il.cc --- a/stage4/generate_c/generate_c_il.cc Sat Apr 14 15:19:17 2012 +0100 +++ b/stage4/generate_c/generate_c_il.cc Sat Apr 14 16:44:53 2012 +0100 @@ -232,6 +232,7 @@ search_fb_instance_decl_c *search_fb_instance_decl; search_varfb_instance_type_c *search_varfb_instance_type; + search_var_instance_decl_c *search_var_instance_decl; search_base_type_c search_base_type; @@ -252,6 +253,8 @@ search_expression_type = new search_expression_type_c(scope); search_fb_instance_decl = new search_fb_instance_decl_c(scope); search_varfb_instance_type = new search_varfb_instance_type_c(scope); + search_var_instance_decl = new search_var_instance_decl_c(scope); + current_operand = NULL; current_operand_type = NULL; il_default_variable_init_value = NULL; @@ -267,6 +270,7 @@ delete search_fb_instance_decl; delete search_expression_type; delete search_varfb_instance_type; + delete search_var_instance_decl; } void generate(instruction_list_c *il) { @@ -435,7 +439,7 @@ } void *print_getter(symbol_c *symbol) { - unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); + unsigned int vartype = search_var_instance_decl->get_vartype(symbol); if (wanted_variablegeneration == fparam_output_vg) { if (vartype == search_var_instance_decl_c::external_vt) s4o.print(GET_EXTERNAL_BY_REF); @@ -457,7 +461,7 @@ variablegeneration_t old_wanted_variablegeneration = wanted_variablegeneration; wanted_variablegeneration = complextype_base_vg; symbol->accept(*this); - if (search_varfb_instance_type->type_is_complex()) + if (search_varfb_instance_type->type_is_complex(symbol)) s4o.print(","); wanted_variablegeneration = complextype_suffix_vg; symbol->accept(*this); @@ -475,8 +479,8 @@ bool type_is_complex = false; if (fb_symbol == NULL) { - unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); - type_is_complex = search_varfb_instance_type->type_is_complex(); + unsigned int vartype = search_var_instance_decl->get_vartype(symbol); + type_is_complex = search_varfb_instance_type->type_is_complex(symbol); if (vartype == search_var_instance_decl_c::external_vt) s4o.print(SET_EXTERNAL); else if (vartype == search_var_instance_decl_c::located_vt) @@ -591,7 +595,7 @@ break; default: if (this->is_variable_prefix_null()) { - vartype = search_varfb_instance_type->get_vartype(symbol); + vartype = search_var_instance_decl->get_vartype(symbol); if (wanted_variablegeneration == fparam_output_vg) { s4o.print("&("); generate_c_base_c::visit(symbol); diff -r f8d422b98315 -r 21be0f2f242d stage4/generate_c/generate_c_inlinefcall.cc --- a/stage4/generate_c/generate_c_inlinefcall.cc Sat Apr 14 15:19:17 2012 +0100 +++ b/stage4/generate_c/generate_c_inlinefcall.cc Sat Apr 14 16:44:53 2012 +0100 @@ -106,6 +106,7 @@ search_expression_type_c *search_expression_type; search_varfb_instance_type_c *search_varfb_instance_type; + search_var_instance_decl_c *search_var_instance_decl; search_base_type_c search_base_type; @@ -119,6 +120,8 @@ { search_expression_type = new search_expression_type_c(scope); search_varfb_instance_type = new search_varfb_instance_type_c(scope); + search_var_instance_decl = new search_var_instance_decl_c(scope); + this->set_variable_prefix(variable_prefix); current_operand = NULL; current_operand_type = NULL; @@ -132,6 +135,7 @@ virtual ~generate_c_inlinefcall_c(void) { delete search_expression_type; delete search_varfb_instance_type; + delete search_var_instance_decl; } void print(symbol_c* symbol) { @@ -309,7 +313,7 @@ } void *print_getter(symbol_c *symbol) { - unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); + unsigned int vartype = search_var_instance_decl->get_vartype(symbol); if (vartype == search_var_instance_decl_c::external_vt) s4o.print(GET_EXTERNAL); else if (vartype == search_var_instance_decl_c::located_vt) @@ -320,7 +324,7 @@ wanted_variablegeneration = complextype_base_vg; symbol->accept(*this); - if (search_varfb_instance_type->type_is_complex()) + if (search_varfb_instance_type->type_is_complex(symbol)) s4o.print(","); wanted_variablegeneration = complextype_suffix_vg; symbol->accept(*this); @@ -332,7 +336,7 @@ void *print_setter(symbol_c* symbol, symbol_c* type, symbol_c* value) { - unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); + unsigned int vartype = search_var_instance_decl->get_vartype(symbol); if (vartype == search_var_instance_decl_c::external_vt) s4o.print(SET_EXTERNAL); else if (vartype == search_var_instance_decl_c::located_vt) @@ -346,7 +350,7 @@ s4o.print(","); wanted_variablegeneration = expression_vg; print_check_function(type, value, NULL, true); - if (search_varfb_instance_type->type_is_complex()) { + if (search_varfb_instance_type->type_is_complex(symbol)) { s4o.print(","); wanted_variablegeneration = complextype_suffix_vg; symbol->accept(*this); diff -r f8d422b98315 -r 21be0f2f242d stage4/generate_c/generate_c_st.cc --- a/stage4/generate_c/generate_c_st.cc Sat Apr 14 15:19:17 2012 +0100 +++ b/stage4/generate_c/generate_c_st.cc Sat Apr 14 16:44:53 2012 +0100 @@ -89,6 +89,7 @@ search_expression_type_c *search_expression_type; search_varfb_instance_type_c *search_varfb_instance_type; + search_var_instance_decl_c *search_var_instance_decl; search_base_type_c search_base_type; @@ -109,6 +110,8 @@ search_fb_instance_decl = new search_fb_instance_decl_c(scope); search_expression_type = new search_expression_type_c(scope); search_varfb_instance_type = new search_varfb_instance_type_c(scope); + search_var_instance_decl = new search_var_instance_decl_c(scope); + this->set_variable_prefix(variable_prefix); current_array_type = NULL; current_param_type = NULL; @@ -122,6 +125,7 @@ delete search_fb_instance_decl; delete search_expression_type; delete search_varfb_instance_type; + delete search_var_instance_decl; } @@ -133,7 +137,7 @@ private: void *print_getter(symbol_c *symbol) { - unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); + unsigned int vartype = search_var_instance_decl->get_vartype(symbol); if (wanted_variablegeneration == fparam_output_vg) { if (vartype == search_var_instance_decl_c::external_vt) s4o.print(GET_EXTERNAL_BY_REF); @@ -155,7 +159,7 @@ variablegeneration_t old_wanted_variablegeneration = wanted_variablegeneration; wanted_variablegeneration = complextype_base_vg; symbol->accept(*this); - if (search_varfb_instance_type->type_is_complex()) + if (search_varfb_instance_type->type_is_complex(symbol)) s4o.print(","); wanted_variablegeneration = complextype_suffix_vg; symbol->accept(*this); @@ -172,8 +176,8 @@ bool type_is_complex = false; if (fb_symbol == NULL) { - unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); - type_is_complex = search_varfb_instance_type->type_is_complex(); + unsigned int vartype = search_var_instance_decl->get_vartype(symbol); + type_is_complex = search_varfb_instance_type->type_is_complex(symbol); if (vartype == search_var_instance_decl_c::external_vt) s4o.print(SET_EXTERNAL); else if (vartype == search_var_instance_decl_c::located_vt)