936 symbol_c *global_enumerated_type; |
936 symbol_c *global_enumerated_type; |
937 symbol_c *local_enumerated_type; |
937 symbol_c *local_enumerated_type; |
938 symbol_c *enumerated_type; |
938 symbol_c *enumerated_type; |
939 |
939 |
940 if (NULL != symbol->type) { |
940 if (NULL != symbol->type) { |
941 #if 1 |
941 /* NOTE: This code must take into account the following situation: |
942 enumerated_type = symbol->type; |
|
943 #else |
|
944 /* NOTE: The following code works but is not complete, that is why it is currently commented out! |
|
945 * |
|
946 * It is not complete because it does not yet consider the following situation: |
|
947 * |
942 * |
948 * TYPE |
943 * TYPE |
949 * base_enum_t: (x1, x2, x3); |
944 * base_enum_t: (x1, x2, x3); |
950 * enum_t1 : base_enum_t := x1; |
945 * enum_t1 : base_enum_t := x1; |
951 * enum_t2 : base_enum_t := x2; |
946 * enum_t2 : base_enum_t := x2; |
955 * considering the above, ALL of the following are correct! |
950 * considering the above, ALL of the following are correct! |
956 * base_enum_t#x1 |
951 * base_enum_t#x1 |
957 * enum_t1#x1 |
952 * enum_t1#x1 |
958 * enum_t2#x1 |
953 * enum_t2#x1 |
959 * enum_t12#x1 |
954 * enum_t12#x1 |
960 * |
|
961 * However, the following code only considers |
|
962 * base_enum_t#x1 |
|
963 * as correct, and all the others as incorrect! |
|
964 */ |
955 */ |
965 /* check whether the value really belongs to that datatype!! */ |
956 /* check whether the value really belongs to that datatype!! */ |
966 /* All local enum values are declared inside anonymous enumeration datatypes (i.e. inside a VAR ... END_VAR declaration, with |
957 /* All local enum values are declared inside anonymous enumeration datatypes (i.e. inside a VAR ... END_VAR declaration, with |
967 * the enum type having no type name), so thay cannot possibly be referenced using a datatype_t#enumvalue syntax. |
958 * the enum type having no type name), so thay cannot possibly be referenced using a datatype_t#enumvalue syntax. |
968 * Because of this, we only look for the datatype identifier in the global enum value symbol table! |
959 * Because of this, we only look for the datatype identifier in the global enum value symbol table! |
969 */ |
960 */ |
970 enumerated_type = NULL; // assume error... |
961 enumerated_type = NULL; // assume error... |
971 enumerated_value_symtable_t::iterator lower = global_enumerated_value_symtable.lower_bound(symbol->value); |
962 enumerated_value_symtable_t::iterator lower = global_enumerated_value_symtable.lower_bound(symbol->value); |
972 enumerated_value_symtable_t::iterator upper = global_enumerated_value_symtable.upper_bound(symbol->value); |
963 enumerated_value_symtable_t::iterator upper = global_enumerated_value_symtable.upper_bound(symbol->value); |
973 for (; lower != upper; lower++) |
964 for (; lower != upper; lower++) |
974 if (compare_identifiers(search_base_type_c::get_basetype_id(lower->second), symbol->type) == 0) // returns 0 if identifiers are equal!! |
965 if (get_datatype_info_c::is_type_equal(base_type(lower->second), base_type(symbol->type))) |
975 enumerated_type = symbol->type; |
966 enumerated_type = symbol->type; |
976 #endif |
|
977 } |
967 } |
978 else { |
968 else { |
979 symbol_c *global_enumerated_type = global_enumerated_value_symtable.find_value (symbol->value); |
969 symbol_c *global_enumerated_type = global_enumerated_value_symtable.find_value (symbol->value); |
980 symbol_c * local_enumerated_type = local_enumerated_value_symtable.find_value (symbol->value); |
970 symbol_c * local_enumerated_type = local_enumerated_value_symtable.find_value (symbol->value); |
981 int global_multiplicity = global_enumerated_value_symtable.count(symbol->value); |
971 int global_multiplicity = global_enumerated_value_symtable.count(symbol->value); |