absyntax_utils/search_varfb_instance_type.cc
changeset 238 0919986a5c98
parent 235 ed66dc50f31a
child 265 4d222f46f8cc
equal deleted inserted replaced
237:cece842c7417 238:0919986a5c98
   178   this->current_rawtype = type_name;
   178   this->current_rawtype = type_name;
   179 
   179 
   180   /* No. It is not a function block, so we let
   180   /* No. It is not a function block, so we let
   181    * the base class take care of it...
   181    * the base class take care of it...
   182    */
   182    */
   183   current_structelement_name = decompose_var_instance_name->next_part();
   183   if (NULL == decompose_var_instance_name->next_part(false)) {
   184   if (NULL == current_structelement_name) {
       
   185 	/* this is it... !
       
   186      * No need to look any further...
       
   187      */
       
   188     /* NOTE: we could simply do a
       
   189      *   return (void *)symbol;
       
   190      *       nevertheless, note that this search_varfb_instance_type_c
       
   191      *       class inherits from the search_base_type_c class,
       
   192      *       which means that it will usually return the base type,
       
   193      *       and not the derived type (*). If we are to be consistent,
       
   194      *       we should guarantee that we always return the base type.
       
   195      *       To do this we could use
       
   196      *   return (void *)symbol->accept(*this);
       
   197      *       since this class inherits from the search_base_type_c.
       
   198      *       However, in this case we don't want it to follow
       
   199      *       the structs as this search_varfb_instance_type_c does.
       
   200      *       We therefore have to create a new search_base_type_c
       
   201      *       instance to search through this type without going
       
   202      *       through the structs...
       
   203      */
       
   204     return base_type(type_name);
   184     return base_type(type_name);
   205   }
   185   }
   206   else
   186   else {
   207     return search_base_type_c::visit(type_name);
   187 	return search_base_type_c::visit(type_name);
       
   188   }
   208 }
   189 }
   209 
   190 
   210 /********************************/
   191 /********************************/
   211 /* B 1.3.3 - Derived data types */
   192 /* B 1.3.3 - Derived data types */
   212 /********************************/
   193 /********************************/
   213 
   194 
   214 /*  identifier ':' array_spec_init */
   195 /*  identifier ':' array_spec_init */
   215 void *search_varfb_instance_type_c::visit(array_type_declaration_c *symbol) {
   196 void *search_varfb_instance_type_c::visit(array_type_declaration_c *symbol) {
       
   197   this->is_complex = true;
   216   return symbol->array_spec_init->accept(*this);
   198   return symbol->array_spec_init->accept(*this);
   217 }
   199 }
   218     
   200     
   219 /* array_specification [ASSIGN array_initialization} */
   201 /* array_specification [ASSIGN array_initialization] */
   220 /* array_initialization may be NULL ! */
   202 /* array_initialization may be NULL ! */
   221 void *search_varfb_instance_type_c::visit(array_spec_init_c *symbol) {
   203 void *search_varfb_instance_type_c::visit(array_spec_init_c *symbol) {
   222   this->is_complex = true;
   204   this->is_complex = true;
   223   return symbol->array_specification->accept(*this);
   205   return symbol->array_specification->accept(*this);
   224 }
   206 }
   225     
   207 
   226 /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */
   208 /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */
   227 void *search_varfb_instance_type_c::visit(array_specification_c *symbol) {
   209 void *search_varfb_instance_type_c::visit(array_specification_c *symbol) {
   228   this->is_complex = true;
   210   this->is_complex = true;
   229   return symbol->non_generic_type_name->accept(*this);
   211   return symbol->non_generic_type_name->accept(*this);
   230 }
   212 }
   251 
   233 
   252 /* helper symbol for structure_declaration */
   234 /* helper symbol for structure_declaration */
   253 /* structure_declaration:  STRUCT structure_element_declaration_list END_STRUCT */
   235 /* structure_declaration:  STRUCT structure_element_declaration_list END_STRUCT */
   254 /* structure_element_declaration_list structure_element_declaration ';' */
   236 /* structure_element_declaration_list structure_element_declaration ';' */
   255 void *search_varfb_instance_type_c::visit(structure_element_declaration_list_c *symbol)	{
   237 void *search_varfb_instance_type_c::visit(structure_element_declaration_list_c *symbol)	{
       
   238   /* make sure that we have decomposed all structure elements of the variable name */
       
   239   current_structelement_name = decompose_var_instance_name->next_part();
       
   240   /* now search the structure declaration */
   256   return visit_list(symbol);
   241   return visit_list(symbol);
   257 }
   242 }
   258 
   243 
   259 /*  structure_element_name ':' spec_init */
   244 /*  structure_element_name ':' spec_init */
   260 void *search_varfb_instance_type_c::visit(structure_element_declaration_c *symbol) {
   245 void *search_varfb_instance_type_c::visit(structure_element_declaration_c *symbol) {