stage3/fill_candidate_datatypes.cc
changeset 729 3840cb4a623a
parent 728 3700fd83e5de
child 732 f6a46e29853b
equal deleted inserted replaced
728:3700fd83e5de 729:3840cb4a623a
   879 
   879 
   880 /*  enumerated_type_name ':' enumerated_spec_init */
   880 /*  enumerated_type_name ':' enumerated_spec_init */
   881 // SYM_REF2(enumerated_type_declaration_c, enumerated_type_name, enumerated_spec_init)
   881 // SYM_REF2(enumerated_type_declaration_c, enumerated_type_name, enumerated_spec_init)
   882 void *fill_candidate_datatypes_c::visit(enumerated_type_declaration_c *symbol) {
   882 void *fill_candidate_datatypes_c::visit(enumerated_type_declaration_c *symbol) {
   883   current_enumerated_spec_type = base_type(symbol);
   883   current_enumerated_spec_type = base_type(symbol);
   884   add_datatype_to_candidate_list(symbol, current_enumerated_spec_type);
   884   add_datatype_to_candidate_list(symbol,                       current_enumerated_spec_type);
       
   885   add_datatype_to_candidate_list(symbol->enumerated_type_name, current_enumerated_spec_type);
   885   symbol->enumerated_spec_init->accept(*this);
   886   symbol->enumerated_spec_init->accept(*this);
   886   current_enumerated_spec_type = NULL;  
   887   current_enumerated_spec_type = NULL;  
   887   return NULL;
   888   return NULL;
   888 }
   889 }
   889 
   890 
   892 // SYM_REF2(enumerated_spec_init_c, enumerated_specification, enumerated_value)
   893 // SYM_REF2(enumerated_spec_init_c, enumerated_specification, enumerated_value)
   893 void *fill_candidate_datatypes_c::visit(enumerated_spec_init_c *symbol) {
   894 void *fill_candidate_datatypes_c::visit(enumerated_spec_init_c *symbol) {
   894   /* If we are handling an anonymous datatype (i.e. a datatype implicitly declared inside a VAR ... END_VAR declaration)
   895   /* If we are handling an anonymous datatype (i.e. a datatype implicitly declared inside a VAR ... END_VAR declaration)
   895    * then the symbol->datatype has not yet been set by the previous visit(enumerated_spec_init_c) method!
   896    * then the symbol->datatype has not yet been set by the previous visit(enumerated_spec_init_c) method!
   896    */
   897    */
   897   if (NULL == current_enumerated_spec_type )
   898   if (NULL == current_enumerated_spec_type)
   898     current_enumerated_spec_type  = base_type(symbol);  
   899     current_enumerated_spec_type = base_type(symbol);  
   899   add_datatype_to_candidate_list(symbol, current_enumerated_spec_type);
   900   add_datatype_to_candidate_list(symbol, current_enumerated_spec_type);
   900   symbol->enumerated_specification->accept(*this); /* calls enumerated_value_list_c (or identifier_c, which we ignore!) visit method */
   901   symbol->enumerated_specification->accept(*this); /* calls enumerated_value_list_c (or identifier_c, which we ignore!) visit method */
   901   current_enumerated_spec_type = NULL;  
   902   current_enumerated_spec_type = NULL;  
   902   if (NULL != symbol->enumerated_value) symbol->enumerated_value->accept(*this);
   903   if (NULL != symbol->enumerated_value) symbol->enumerated_value->accept(*this);
   903   return NULL;
   904   return NULL;
   906 /* helper symbol for enumerated_specification->enumerated_spec_init */
   907 /* helper symbol for enumerated_specification->enumerated_spec_init */
   907 /* enumerated_value_list ',' enumerated_value */
   908 /* enumerated_value_list ',' enumerated_value */
   908 // SYM_LIST(enumerated_value_list_c)
   909 // SYM_LIST(enumerated_value_list_c)
   909 void *fill_candidate_datatypes_c::visit(enumerated_value_list_c *symbol) {
   910 void *fill_candidate_datatypes_c::visit(enumerated_value_list_c *symbol) {
   910   if (NULL == current_enumerated_spec_type) ERROR;  
   911   if (NULL == current_enumerated_spec_type) ERROR;  
       
   912   add_datatype_to_candidate_list(symbol, current_enumerated_spec_type);
   911   
   913   
   912   /* We already know the datatype of the enumerated_value(s) in the list, so we set them directly instead of recursively calling the enumerated_value_c visit method! */
   914   /* We already know the datatype of the enumerated_value(s) in the list, so we set them directly instead of recursively calling the enumerated_value_c visit method! */
   913   for(int i = 0; i < symbol->n; i++)
   915   for(int i = 0; i < symbol->n; i++)
   914     add_datatype_to_candidate_list(symbol->elements[i], current_enumerated_spec_type);
   916     add_datatype_to_candidate_list(symbol->elements[i], current_enumerated_spec_type);
   915 
   917