# HG changeset patch # User Mario de Sousa # Date 1308218713 -3600 # Node ID f763383992c912bc68027d827b863a11dd3f9eee # Parent d3f2ef59b310edb5f52222d953782be79b868750# Parent a96399ab57c274afc0f723d16fc5472c75d89584 Merging two previous commits. diff -r d3f2ef59b310 -r f763383992c9 absyntax_utils/search_expression_type.cc --- a/absyntax_utils/search_expression_type.cc Fri Jun 10 10:13:15 2011 +0100 +++ b/absyntax_utils/search_expression_type.cc Thu Jun 16 11:05:13 2011 +0100 @@ -231,7 +231,7 @@ symbol_c *res; /* Nope, now we assume it is a variable, and determine its type... */ - res = search_varfb_instance_type->get_type(symbol); + res = search_varfb_instance_type->get_basetype_decl(symbol); if (NULL != res) return res; return NULL; @@ -244,7 +244,7 @@ symbol_c *res; /* Nope, now we assume it is a variable, and determine its type... */ - res = search_varfb_instance_type->get_type(symbol); + res = search_varfb_instance_type->get_basetype_decl(symbol); if (NULL != res) return res; return NULL; @@ -258,7 +258,7 @@ symbol_c *res; /* Nope, now we assume it is a variable, and determine its type... */ - res = search_varfb_instance_type->get_type(symbol); + res = search_varfb_instance_type->get_basetype_decl(symbol); if (NULL != res) return res; return NULL; @@ -268,7 +268,7 @@ symbol_c *res; /* Nope, now we assume it is a variable, and determine its type... */ - res = search_varfb_instance_type->get_type(symbol); + res = search_varfb_instance_type->get_basetype_decl(symbol); if (NULL != res) return res; return NULL; diff -r d3f2ef59b310 -r f763383992c9 absyntax_utils/search_varfb_instance_type.cc --- a/absyntax_utils/search_varfb_instance_type.cc Fri Jun 10 10:13:15 2011 +0100 +++ b/absyntax_utils/search_varfb_instance_type.cc Thu Jun 16 11:05:13 2011 +0100 @@ -37,13 +37,6 @@ * A mixture of array element of a structure element of a structure element * of a .... is also suported! * - * A reference to the relevant base type __definition__ is returned. - * This means that if we find that the variable is of type MY_INT, - * which was previously declared to be - * TYPE MY_INT: INT := 9; - * this class wil return INT, and __not__ MY_INT !! - * - * * example: * window.points[1].coordinate.x * window.points[1].colour @@ -51,7 +44,44 @@ * * This class must be passed the scope within which the * variable was declared, and the variable name... - */ + * + * + * + * + * + * This class has several members, depending on the exact data the caller + * is looking for... + * + * - item i: we can get either the name of the data type(A), + * or it's declaration (B) + * (notice however that some variables belong to a data type that does + * not have a name, only a declaration as in + * VAR a: ARRAY [1..3] of INT; END_VAR + * ) + * - item ii: we can get either the direct data type (1), + * or the base type (2) + * + * By direct type, I mean the data type of the variable. By base type, I + * mean the data type on which the direct type is based on. For example, in + * a subrange on INT, the direct type is the subrange itself, while the + * base type is INT. + * e.g. + * This means that if we find that the variable is of type MY_INT, + * which was previously declared to be + * TYPE MY_INT: INT := 9; + * option (1) will return MY_INT + * option (2) will return INT + * + * + * Member functions: + * ================ + * get_basetype_decl() ---> returns 2B + * get_type_id() ---> returns 1A + * + * Since we haven't yet needed them, we don't yet implement + * get_basetype_id() ----> would return 2A + * get_type_decl() ----> would return 1B + */ /* @@ -67,7 +97,7 @@ this->current_rawtype = NULL; } -symbol_c *search_varfb_instance_type_c::get_type(symbol_c *variable_name) { +symbol_c *search_varfb_instance_type_c::get_basetype_decl(symbol_c *variable_name) { this->current_structelement_name = NULL; this->current_rawtype = NULL; this->decompose_var_instance_name = new decompose_var_instance_name_c(variable_name); @@ -140,8 +170,8 @@ return res; } -symbol_c *search_varfb_instance_type_c::get_rawtype(symbol_c *variable_name) { - symbol_c *rawtype = this->get_type(variable_name); +symbol_c *search_varfb_instance_type_c::get_type_id(symbol_c *variable_name) { + symbol_c *rawtype = this->get_basetype_decl(variable_name); if (this->current_rawtype != NULL) return this->current_rawtype; else diff -r d3f2ef59b310 -r f763383992c9 absyntax_utils/search_varfb_instance_type.hh --- a/absyntax_utils/search_varfb_instance_type.hh Fri Jun 10 10:13:15 2011 +0100 +++ b/absyntax_utils/search_varfb_instance_type.hh Thu Jun 16 11:05:13 2011 +0100 @@ -39,13 +39,6 @@ * A mixture of array element of a structure element of a structure element * of a .... is also suported! * - * A reference to the relevant base type __definition__ is returned. - * This means that if we find that the variable is of type MY_INT, - * which was previously declared to be - * TYPE MY_INT: INT := 9; - * this class wil return INT, and __not__ MY_INT !! - * - * * example: * window.points[1].coordinate.x * window.points[1].colour @@ -53,7 +46,44 @@ * * This class must be passed the scope within which the * variable was declared, and the variable name... - */ + * + * + * + * + * + * This class has several members, depending on the exact data the caller + * is looking for... + * + * - item i: we can get either the name of the data type(A), + * or it's declaration (B) + * (notice however that some variables belong to a data type that does + * not have a name, only a declaration as in + * VAR a: ARRAY [1..3] of INT; END_VAR + * ) + * - item ii: we can get either the direct data type (1), + * or the base type (2) + * + * By direct type, I mean the data type of the variable. By base type, I + * mean the data type on which the direct type is based on. For example, in + * a subrange on INT, the direct type is the subrange itself, while the + * base type is INT. + * e.g. + * This means that if we find that the variable is of type MY_INT, + * which was previously declared to be + * TYPE MY_INT: INT := 9; + * option (1) will return MY_INT + * option (2) will return INT + * + * + * Member functions: + * ================ + * get_basetype_decl() ---> returns 2B + * get_type_id() ---> returns 1A + * + * Since we haven't yet needed them, we don't yet implement + * get_basetype_id() ----> would return 2A + * get_type_decl() ----> would return 1B + */ class search_varfb_instance_type_c: public search_base_type_c { @@ -66,8 +96,8 @@ public: search_varfb_instance_type_c(symbol_c *search_scope); - symbol_c *get_type(symbol_c *variable_name); - symbol_c *get_rawtype(symbol_c *variable_name); + symbol_c *get_basetype_decl(symbol_c *variable_name); + symbol_c *get_type_id(symbol_c *variable_name); unsigned int get_vartype(symbol_c *variable_name); bool type_is_complex(void); diff -r d3f2ef59b310 -r f763383992c9 stage3/visit_expression_type.cc --- a/stage3/visit_expression_type.cc Fri Jun 10 10:13:15 2011 +0100 +++ b/stage3/visit_expression_type.cc Thu Jun 16 11:05:13 2011 +0100 @@ -900,7 +900,7 @@ /*********************/ void *visit_expression_type_c::visit(symbolic_variable_c *symbol) { - return search_varfb_instance_type->get_type(symbol); + return search_varfb_instance_type->get_basetype_decl(symbol); } /********************************************/ @@ -927,11 +927,11 @@ /* B 1.4.2 - Multi-element variables */ /*************************************/ void *visit_expression_type_c::visit(array_variable_c *symbol) { - return search_varfb_instance_type->get_type(symbol); + return search_varfb_instance_type->get_basetype_decl(symbol); } void *visit_expression_type_c::visit(structured_variable_c *symbol) { - return search_varfb_instance_type->get_type(symbol); + return search_varfb_instance_type->get_basetype_decl(symbol); } @@ -1120,12 +1120,12 @@ * fb1(...) * End_Program * - * search_varfb_instance_type->get_type( identifier_c("fb1") ) + * search_varfb_instance_type->get_basetype_decl( identifier_c("fb1") ) * in the scope of Program 'test' * will return the fb declaration of foo_fb_type !! */ #if 0 - symbol_c *fb_decl_symbol = search_varfb_instance_type->get_type(symbol->fb_name); + symbol_c *fb_decl_symbol = search_varfb_instance_type->get_basetype_decl(symbol->fb_name); /* The following should never occur. The function block must be defined, * and the FB type being called MUST be in the symtable... * This was all already checked at stage 2! @@ -1136,7 +1136,7 @@ /* should never occur. ... */ if (NULL == fb_decl) ERROR; #endif - symbol_c *fb_decl = search_varfb_instance_type->get_type(symbol->fb_name); + symbol_c *fb_decl = search_varfb_instance_type->get_basetype_decl(symbol->fb_name); /* The following should never occur. The function block must be defined, * and the FB type being called MUST be in the symtable... * This was all already checked at stage 2! @@ -2030,7 +2030,7 @@ /* param_assignment_list -> may be NULL ! */ // SYM_REF3(fb_invocation_c, fb_name, formal_param_list, nonformal_param_list) void *visit_expression_type_c::visit(fb_invocation_c *symbol) { - symbol_c *fb_decl = search_varfb_instance_type->get_type(symbol->fb_name); + symbol_c *fb_decl = search_varfb_instance_type->get_basetype_decl(symbol->fb_name); /* The following should never occur. The function block must be defined, * and the FB type being called MUST be in the symtable... * This was all already checked at stage 2! diff -r d3f2ef59b310 -r f763383992c9 stage4/generate_c/generate_c_il.cc --- a/stage4/generate_c/generate_c_il.cc Fri Jun 10 10:13:15 2011 +0100 +++ b/stage4/generate_c/generate_c_il.cc Thu Jun 16 11:05:13 2011 +0100 @@ -647,7 +647,7 @@ case complextype_suffix_vg: symbol->subscripted_variable->accept(*this); - current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable); + current_array_type = search_varfb_instance_type->get_type_id(symbol->subscripted_variable); if (current_array_type == NULL) ERROR; s4o.print(".table"); @@ -659,7 +659,7 @@ if (this->is_variable_prefix_null()) { symbol->subscripted_variable->accept(*this); - current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable); + current_array_type = search_varfb_instance_type->get_type_id(symbol->subscripted_variable); if (current_array_type == NULL) ERROR; s4o.print(".table"); @@ -1120,7 +1120,7 @@ if (param_value != NULL) if ((param_direction == function_param_iterator_c::direction_out) || (param_direction == function_param_iterator_c::direction_inout)) { - symbol_c *param_type = search_varfb_instance_type->get_rawtype(param_value); + symbol_c *param_type = search_varfb_instance_type->get_type_id(param_value); s4o.print(";\n" + s4o.indent_spaces); if (this->is_variable_prefix_null()) { param_value->accept(*this); @@ -1479,7 +1479,7 @@ } void *visit(ST_operator_c *symbol) { - symbol_c *operand_type = search_varfb_instance_type->get_rawtype(this->current_operand); + symbol_c *operand_type = search_varfb_instance_type->get_type_id(this->current_operand); if (search_expression_type->is_literal_integer_type(this->default_variable_name.current_type) || search_expression_type->is_literal_real_type(this->default_variable_name.current_type)) this->default_variable_name.current_type = this->current_operand_type; @@ -1496,7 +1496,7 @@ } void *visit(STN_operator_c *symbol) { - symbol_c *operand_type = search_varfb_instance_type->get_rawtype(this->current_operand); + symbol_c *operand_type = search_varfb_instance_type->get_type_id(this->current_operand); if (search_expression_type->is_literal_integer_type(this->default_variable_name.current_type)) this->default_variable_name.current_type = this->current_operand_type; diff -r d3f2ef59b310 -r f763383992c9 stage4/generate_c/generate_c_inlinefcall.cc --- a/stage4/generate_c/generate_c_inlinefcall.cc Fri Jun 10 10:13:15 2011 +0100 +++ b/stage4/generate_c/generate_c_inlinefcall.cc Thu Jun 16 11:05:13 2011 +0100 @@ -312,7 +312,7 @@ case complextype_suffix_vg: symbol->subscripted_variable->accept(*this); - current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable); + current_array_type = search_varfb_instance_type->get_type_id(symbol->subscripted_variable); if (current_array_type == NULL) ERROR; s4o.print(".table"); diff -r d3f2ef59b310 -r f763383992c9 stage4/generate_c/generate_c_st.cc --- a/stage4/generate_c/generate_c_st.cc Fri Jun 10 10:13:15 2011 +0100 +++ b/stage4/generate_c/generate_c_st.cc Thu Jun 16 11:05:13 2011 +0100 @@ -305,7 +305,7 @@ case complextype_suffix_vg: symbol->subscripted_variable->accept(*this); - current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable); + current_array_type = search_varfb_instance_type->get_type_id(symbol->subscripted_variable); if (current_array_type == NULL) ERROR; s4o.print(".table"); @@ -319,7 +319,7 @@ if (this->is_variable_prefix_null()) { symbol->subscripted_variable->accept(*this); - current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable); + current_array_type = search_varfb_instance_type->get_type_id(symbol->subscripted_variable); if (current_array_type == NULL) ERROR; s4o.print(".table"); @@ -789,7 +789,7 @@ /* B 3.2.1 Assignment Statements */ /*********************************/ void *visit(assignment_statement_c *symbol) { - symbol_c *left_type = search_varfb_instance_type->get_rawtype(symbol->l_exp); + symbol_c *left_type = search_varfb_instance_type->get_type_id(symbol->l_exp); if (this->is_variable_prefix_null()) { symbol->l_exp->accept(*this); @@ -893,7 +893,7 @@ if (param_value != NULL) if ((param_direction == function_param_iterator_c::direction_out) || (param_direction == function_param_iterator_c::direction_inout)) { - symbol_c *param_type = search_varfb_instance_type->get_rawtype(param_value); + symbol_c *param_type = search_varfb_instance_type->get_type_id(param_value); s4o.print(";\n" + s4o.indent_spaces); if (this->is_variable_prefix_null()) { param_value->accept(*this);