694 /* Now let the base class iterator_visitor_c iterate through all the library elements */ |
694 /* Now let the base class iterator_visitor_c iterate through all the library elements */ |
695 return iterator_visitor_c::visit(symbol); |
695 return iterator_visitor_c::visit(symbol); |
696 } |
696 } |
697 |
697 |
698 |
698 |
|
699 /*************************/ |
|
700 /* B.1 - Common elements */ |
|
701 /*************************/ |
|
702 /*******************************************/ |
|
703 /* B 1.1 - Letters, digits and identifiers */ |
|
704 /*******************************************/ |
|
705 |
|
706 /* Before the existance of this derived_datatype_identifier_c class, all identifiers were stored in the generic identifier_c class. |
|
707 * Since not all identifiers are used to identify a datatype, the fill/narrow algorithms could not do fill/narrow on all identifiers, and relied |
|
708 * on the parent class to do the fill/narrow when apropriate (i.e. when the identifier was known to reference a datatype |
|
709 * for example, in a variable declaration --> var1: some_user_defined_type;) |
|
710 * |
|
711 * However, at least one location where an identifier may reference a datatype has not yet been covered: |
|
712 * array1: ARRAY [1..2] OF INT; |
|
713 * array2: ARRAY [1..2] OF array1; (* array1 here is stored as a derived_datatype_identifier_c) |
|
714 * |
|
715 * Instead of doing it like the old way, I have opted to do a generic fill/narrow for all derived_datatype_identifier_c |
|
716 * This means that we can now delete the code of all parents of derived_datatype_identifier_c that are still doing the fill/narrow |
|
717 * explicitly (assuming we do also implement the visitor for poutype_identifier_c). However, I will leave this code cleanup for some later oportunity. |
|
718 */ |
|
719 void *fill_candidate_datatypes_c::visit(derived_datatype_identifier_c *symbol) { |
|
720 add_datatype_to_candidate_list(symbol, base_type( type_symtable[symbol->value])); // will only add if datatype is not NULL! |
|
721 return NULL; |
|
722 } |
|
723 |
|
724 /* The datatype of a poutype_identifier_c is currently always being set by the parent object, so we leave this code commented out for now. */ |
|
725 /* |
|
726 void *fill_candidate_datatypes_c::visit( poutype_identifier_c *symbol) { |
|
727 add_datatype_to_candidate_list(symbol, base_type( function_block_type_symtable[symbol->value])); // will only add if datatype is not NULL! |
|
728 add_datatype_to_candidate_list(symbol, base_type( program_type_symtable[symbol->value])); // will only add if datatype is not NULL! |
|
729 //add_datatype_to_candidate_list(symbol, base_type( function_symtable[symbol->value])); // will only add if datatype is not NULL! |
|
730 // NOTE: Although poutype_identifier_c is also used to identify functions, these symbols are not used as a datatype, |
|
731 // so we do NOT add it as a candidate datatype! |
|
732 return NULL; |
|
733 } |
|
734 */ |
|
735 |
|
736 |
699 /*********************/ |
737 /*********************/ |
700 /* B 1.2 - Constants */ |
738 /* B 1.2 - Constants */ |
701 /*********************/ |
739 /*********************/ |
702 /*********************************/ |
740 /*********************************/ |
703 /* B 1.2.XX - Reference Literals */ |
741 /* B 1.2.XX - Reference Literals */ |
1086 // SYM_REF2(array_spec_init_c, array_specification, array_initialization) |
1124 // SYM_REF2(array_spec_init_c, array_specification, array_initialization) |
1087 void *fill_candidate_datatypes_c::visit(array_spec_init_c *symbol) {return fill_spec_init(symbol, symbol->array_specification, symbol->array_initialization);} |
1125 void *fill_candidate_datatypes_c::visit(array_spec_init_c *symbol) {return fill_spec_init(symbol, symbol->array_specification, symbol->array_initialization);} |
1088 |
1126 |
1089 /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ |
1127 /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ |
1090 // SYM_REF2(array_specification_c, array_subrange_list, non_generic_type_name) |
1128 // SYM_REF2(array_specification_c, array_subrange_list, non_generic_type_name) |
|
1129 // void *fill_candidate_datatypes_c::visit(array_specification_c *symbol) |
|
1130 // NOTE: This visitor does not need to be implemented as fill_candidate_datatypes_c inherits from iterator_visitor_c |
1091 |
1131 |
1092 /* helper symbol for array_specification */ |
1132 /* helper symbol for array_specification */ |
1093 /* array_subrange_list ',' subrange */ |
1133 /* array_subrange_list ',' subrange */ |
1094 // SYM_LIST(array_subrange_list_c) |
1134 // SYM_LIST(array_subrange_list_c) |
1095 |
1135 |