diff -r 70c4c259bc3e -r c5f145364a4f absyntax_utils/search_base_type.cc --- a/absyntax_utils/search_base_type.cc Sat Feb 08 10:48:20 2014 +0000 +++ b/absyntax_utils/search_base_type.cc Sat Feb 08 18:33:32 2014 +0000 @@ -54,7 +54,7 @@ -search_base_type_c::search_base_type_c(void) {current_type_name = NULL; current_basetype = NULL;} +search_base_type_c::search_base_type_c(void) {current_basetype_name = NULL; current_basetype = NULL; current_equivtype = NULL;} /* static method! */ void search_base_type_c::create_singleton(void) { @@ -63,11 +63,25 @@ } /* static method! */ +symbol_c *search_base_type_c::get_equivtype_decl(symbol_c *symbol) { + create_singleton(); + if (NULL == symbol) return NULL; + search_base_type_singleton->current_basetype_name = NULL; + search_base_type_singleton->current_basetype = NULL; + search_base_type_singleton->current_equivtype = NULL; + symbol_c *basetype = (symbol_c *)symbol->accept(*search_base_type_singleton); + if (NULL != search_base_type_singleton->current_equivtype) + return search_base_type_singleton->current_equivtype; + return basetype; +} + +/* static method! */ symbol_c *search_base_type_c::get_basetype_decl(symbol_c *symbol) { create_singleton(); if (NULL == symbol) return NULL; - search_base_type_singleton->current_type_name = NULL; + search_base_type_singleton->current_basetype_name = NULL; search_base_type_singleton->current_basetype = NULL; + search_base_type_singleton->current_equivtype = NULL; return (symbol_c *)symbol->accept(*search_base_type_singleton); } @@ -75,10 +89,11 @@ symbol_c *search_base_type_c::get_basetype_id (symbol_c *symbol) { create_singleton(); if (NULL == symbol) return NULL; - search_base_type_singleton->current_type_name = NULL; + search_base_type_singleton->current_basetype_name = NULL; search_base_type_singleton->current_basetype = NULL; + search_base_type_singleton->current_equivtype = NULL; symbol->accept(*search_base_type_singleton); - return (symbol_c *)search_base_type_singleton->current_type_name; + return (symbol_c *)search_base_type_singleton->current_basetype_name; } @@ -93,7 +108,7 @@ void *search_base_type_c::visit(identifier_c *type_name) { symbol_c *type_decl; - this->current_type_name = type_name; + this->current_basetype_name = type_name; /* if we have reached this point, it is because the current_basetype is not yet pointing to the base datatype we are looking for, * so we will be searching for the delcaration of the type named in type_name, which might be the base datatype (we search recursively!) */ @@ -210,16 +225,21 @@ /* subrange_type_name ':' subrange_spec_init */ void *search_base_type_c::visit(subrange_type_declaration_c *symbol) { + this->current_equivtype = symbol; return symbol->subrange_spec_init->accept(*this); } /* subrange_specification ASSIGN signed_integer */ void *search_base_type_c::visit(subrange_spec_init_c *symbol) { + if (NULL == this->current_equivtype) + this->current_equivtype = symbol; return symbol->subrange_specification->accept(*this); } /* integer_type_name '(' subrange')' */ void *search_base_type_c::visit(subrange_specification_c *symbol) { + if (NULL == this->current_equivtype) + this->current_equivtype = symbol; return symbol->integer_type_name->accept(*this); } @@ -228,7 +248,7 @@ /* enumerated_type_name ':' enumerated_spec_init */ void *search_base_type_c::visit(enumerated_type_declaration_c *symbol) { - this->current_type_name = symbol->enumerated_type_name; + this->current_basetype_name = symbol->enumerated_type_name; /* NOTE: We want search_base_type_c to return a enumerated_type_declaration_c as the base datatpe if possible * (i.e. if it is a named datatype declared inside a TYPE ... END_TYPE declarations, as opposed to an * anonymous datatype declared in a VAR ... AND_VAR declaration). @@ -266,7 +286,7 @@ /* identifier ':' array_spec_init */ void *search_base_type_c::visit(array_type_declaration_c *symbol) { - this->current_type_name = symbol->identifier; + this->current_basetype_name = symbol->identifier; return symbol->array_spec_init->accept(*this); } @@ -303,7 +323,7 @@ * structure_element_declaration_list_c */ void *search_base_type_c::visit(structure_type_declaration_c *symbol) { - this->current_type_name = symbol->structure_type_name; + this->current_basetype_name = symbol->structure_type_name; return symbol->structure_specification->accept(*this); } @@ -370,14 +390,14 @@ /* INITIAL_STEP step_name ':' action_association_list END_STEP */ // SYM_REF2(initial_step_c, step_name, action_association_list) void *search_base_type_c::visit(initial_step_c *symbol) { - this->current_type_name = NULL; /* this pseudo data type does not have a type name! */ + this->current_basetype_name = NULL; /* this pseudo data type does not have a type name! */ return (void *)symbol; } /* STEP step_name ':' action_association_list END_STEP */ // SYM_REF2(step_c, step_name, action_association_list) void *search_base_type_c::visit(step_c *symbol) { - this->current_type_name = NULL; /* this pseudo data type does not have a type name! */ + this->current_basetype_name = NULL; /* this pseudo data type does not have a type name! */ return (void *)symbol; }