absyntax_utils/search_base_type.cc
changeset 854 13d0b67de111
parent 810 d9c48ad646f1
child 858 c5f145364a4f
equal deleted inserted replaced
853:818c4ac5d64d 854:13d0b67de111
    80   symbol->accept(*search_base_type_singleton);
    80   symbol->accept(*search_base_type_singleton);
    81   return (symbol_c *)search_base_type_singleton->current_type_name;
    81   return (symbol_c *)search_base_type_singleton->current_type_name;
    82 }
    82 }
    83 
    83 
    84 
    84 
    85 /* Note by MJS: The following two functions definately do not belong in this class!! Maybe create a new utility class?
       
    86  * I will need to clean this up when the opportunity arises!
       
    87  */
       
    88 /* static method! */
       
    89 bool search_base_type_c::type_is_subrange(symbol_c* type_decl) {
       
    90   create_singleton();
       
    91   search_base_type_singleton->is_subrange = false;
       
    92   type_decl->accept(*search_base_type_singleton);
       
    93   return search_base_type_singleton->is_subrange;
       
    94 }
       
    95 
       
    96 
       
    97 /* static method! */
       
    98 bool search_base_type_c::type_is_enumerated(symbol_c* type_decl) {
       
    99   create_singleton();
       
   100   search_base_type_singleton->is_enumerated = false;
       
   101   type_decl->accept(*search_base_type_singleton);
       
   102   return search_base_type_singleton->is_enumerated;
       
   103 }
       
   104 
       
   105 bool search_base_type_c::type_is_fb(symbol_c* type_decl) {
       
   106   create_singleton();
       
   107   search_base_type_singleton->is_fb = false;
       
   108   type_decl->accept(*search_base_type_singleton);
       
   109   return search_base_type_singleton->is_fb;
       
   110 }
       
   111 
    85 
   112 /*************************/
    86 /*************************/
   113 /* B.1 - Common elements */
    87 /* B.1 - Common elements */
   114 /*************************/
    88 /*************************/
   115 
    89 
   239   return symbol->subrange_spec_init->accept(*this);
   213   return symbol->subrange_spec_init->accept(*this);
   240 }
   214 }
   241 
   215 
   242 /* subrange_specification ASSIGN signed_integer */
   216 /* subrange_specification ASSIGN signed_integer */
   243 void *search_base_type_c::visit(subrange_spec_init_c *symbol) {
   217 void *search_base_type_c::visit(subrange_spec_init_c *symbol) {
   244   this->is_subrange = true;
       
   245   return symbol->subrange_specification->accept(*this);
   218   return symbol->subrange_specification->accept(*this);
   246 }
   219 }
   247 
   220 
   248 /*  integer_type_name '(' subrange')' */
   221 /*  integer_type_name '(' subrange')' */
   249 void *search_base_type_c::visit(subrange_specification_c *symbol) {
   222 void *search_base_type_c::visit(subrange_specification_c *symbol) {
   266   return symbol->enumerated_spec_init->accept(*this);
   239   return symbol->enumerated_spec_init->accept(*this);
   267 }
   240 }
   268 
   241 
   269 /* enumerated_specification ASSIGN enumerated_value */
   242 /* enumerated_specification ASSIGN enumerated_value */
   270 void *search_base_type_c::visit(enumerated_spec_init_c *symbol) {
   243 void *search_base_type_c::visit(enumerated_spec_init_c *symbol) {
   271   this->is_enumerated = true;
       
   272   // current_basetype may have been set in the previous enumerated_type_declaration_c visitor, in which case we do not want to overwrite the value!
   244   // current_basetype may have been set in the previous enumerated_type_declaration_c visitor, in which case we do not want to overwrite the value!
   273   if (NULL == this->current_basetype)
   245   if (NULL == this->current_basetype)
   274     this->current_basetype  = symbol; 
   246     this->current_basetype  = symbol; 
   275   /* NOTE: the following line may call either the visitor to 
   247   /* NOTE: the following line may call either the visitor to 
   276    *         - identifier_c, in which case this is not yet the base datatype we are looking for (it will set current_basetype to NULL!)
   248    *         - identifier_c, in which case this is not yet the base datatype we are looking for (it will set current_basetype to NULL!)
   280 }
   252 }
   281 
   253 
   282 /* helper symbol for enumerated_specification->enumerated_spec_init */
   254 /* helper symbol for enumerated_specification->enumerated_spec_init */
   283 /* enumerated_value_list ',' enumerated_value */
   255 /* enumerated_value_list ',' enumerated_value */
   284 void *search_base_type_c::visit(enumerated_value_list_c *symbol) {
   256 void *search_base_type_c::visit(enumerated_value_list_c *symbol) {
   285   this->is_enumerated = true;
       
   286   // current_basetype may have been set in the previous enumerated_type_declaration_c or enumerated_spec_init_c visitors, in which case we do not want to overwrite the value!
   257   // current_basetype may have been set in the previous enumerated_type_declaration_c or enumerated_spec_init_c visitors, in which case we do not want to overwrite the value!
   287   if (NULL == this->current_basetype) 
   258   if (NULL == this->current_basetype) 
   288     this->current_basetype  = symbol; 
   259     this->current_basetype  = symbol; 
   289   return (void *)current_basetype;
   260   return (void *)current_basetype;
   290 }
   261 }
   386 /* B 1.5.2 - Function Blocks */
   357 /* B 1.5.2 - Function Blocks */
   387 /*****************************/
   358 /*****************************/
   388 /*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
   359 /*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
   389 // SYM_REF3(function_block_declaration_c, fblock_name, var_declarations, fblock_body)
   360 // SYM_REF3(function_block_declaration_c, fblock_name, var_declarations, fblock_body)
   390 void *search_base_type_c::visit(function_block_declaration_c *symbol)                   {
   361 void *search_base_type_c::visit(function_block_declaration_c *symbol)                   {
   391 	this->is_fb = true;
       
   392 	return (void *)symbol;
   362 	return (void *)symbol;
   393 }
   363 }
   394 
   364 
   395 
   365 
   396 
   366