877 } |
877 } |
878 |
878 |
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 /* NOTE: Not required. already handled by iterator_visitor_c base class */ |
882 void *fill_candidate_datatypes_c::visit(enumerated_type_declaration_c *symbol) { |
|
883 current_enumerated_spec_type = base_type(symbol); |
|
884 add_datatype_to_candidate_list(symbol, current_enumerated_spec_type); |
|
885 symbol->enumerated_spec_init->accept(*this); |
|
886 current_enumerated_spec_type = NULL; |
|
887 return NULL; |
|
888 } |
883 |
889 |
884 |
890 |
885 /* enumerated_specification ASSIGN enumerated_value */ |
891 /* enumerated_specification ASSIGN enumerated_value */ |
886 // SYM_REF2(enumerated_spec_init_c, enumerated_specification, enumerated_value) |
892 // SYM_REF2(enumerated_spec_init_c, enumerated_specification, enumerated_value) |
887 void *fill_candidate_datatypes_c::visit(enumerated_spec_init_c *symbol) { |
893 void *fill_candidate_datatypes_c::visit(enumerated_spec_init_c *symbol) { |
888 current_enumerated_spec_type = symbol; |
894 /* 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 */ |
|
897 if (NULL == current_enumerated_spec_type ) |
|
898 current_enumerated_spec_type = base_type(symbol); |
|
899 add_datatype_to_candidate_list(symbol, current_enumerated_spec_type); |
889 symbol->enumerated_specification->accept(*this); /* calls enumerated_value_list_c (or identifier_c, which we ignore!) visit method */ |
900 symbol->enumerated_specification->accept(*this); /* calls enumerated_value_list_c (or identifier_c, which we ignore!) visit method */ |
890 current_enumerated_spec_type = NULL; |
901 current_enumerated_spec_type = NULL; |
891 if (NULL != symbol->enumerated_value) symbol->enumerated_value->accept(*this); |
902 if (NULL != symbol->enumerated_value) symbol->enumerated_value->accept(*this); |
892 return NULL; |
903 return NULL; |
893 } |
904 } |
895 /* helper symbol for enumerated_specification->enumerated_spec_init */ |
906 /* helper symbol for enumerated_specification->enumerated_spec_init */ |
896 /* enumerated_value_list ',' enumerated_value */ |
907 /* enumerated_value_list ',' enumerated_value */ |
897 // SYM_LIST(enumerated_value_list_c) |
908 // SYM_LIST(enumerated_value_list_c) |
898 void *fill_candidate_datatypes_c::visit(enumerated_value_list_c *symbol) { |
909 void *fill_candidate_datatypes_c::visit(enumerated_value_list_c *symbol) { |
899 if (NULL == current_enumerated_spec_type) ERROR; |
910 if (NULL == current_enumerated_spec_type) ERROR; |
900 current_enumerated_spec_type = base_type(current_enumerated_spec_type); |
|
901 if (NULL == current_enumerated_spec_type) ERROR; |
|
902 |
911 |
903 /* 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! */ |
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! */ |
904 for(int i = 0; i < symbol->n; i++) |
913 for(int i = 0; i < symbol->n; i++) |
905 add_datatype_to_candidate_list(symbol->elements[i], current_enumerated_spec_type); |
914 add_datatype_to_candidate_list(symbol->elements[i], current_enumerated_spec_type); |
906 |
915 |