75 * option (2) will return INT |
75 * option (2) will return INT |
76 * |
76 * |
77 * |
77 * |
78 * Member functions: |
78 * Member functions: |
79 * ================ |
79 * ================ |
|
80 * get_basetype_id() ---> returns 2A (implemented, although currently it is not needed! ) |
80 * get_basetype_decl() ---> returns 2B |
81 * get_basetype_decl() ---> returns 2B |
81 * get_type_id() ---> returns 1A |
82 * get_type_id() ---> returns 1A |
82 * |
83 * |
83 * Since we haven't yet needed them, we don't yet implement |
84 * Since we haven't yet needed it, we don't yet implement |
84 * get_basetype_id() ----> would return 2A |
85 * get_type_decl() ---> returns 1B |
85 * get_type_decl() ----> would return 1B |
|
86 */ |
86 */ |
87 |
87 |
88 class search_varfb_instance_type_c: public search_base_type_c { |
88 class search_varfb_instance_type_c : null_visitor_c { |
89 |
89 |
90 private: |
90 private: |
91 search_var_instance_decl_c search_var_instance_decl; |
91 search_var_instance_decl_c search_var_instance_decl; |
92 decompose_var_instance_name_c *decompose_var_instance_name; |
92 search_base_type_c search_base_type; |
93 symbol_c *current_structelement_name; |
93 |
94 symbol_c *current_typeid; |
94 // symbol_c *current_type_decl; |
95 symbol_c *current_basetypeid; |
95 symbol_c *current_type_id; |
96 bool is_complex; |
96 symbol_c *current_basetype_decl; |
|
97 symbol_c *current_basetype_id; |
|
98 |
|
99 symbol_c *current_field_selector; |
|
100 |
|
101 /* sets all the above variables to NULL, or false */ |
|
102 void init(void); |
97 |
103 |
98 public: |
104 public: |
99 search_varfb_instance_type_c(symbol_c *search_scope); |
105 search_varfb_instance_type_c(symbol_c *search_scope ); |
100 symbol_c *get_basetype_decl(symbol_c *variable_name); |
106 symbol_c *get_basetype_decl (symbol_c *variable_name); |
101 symbol_c *get_type_decl(symbol_c *variable_name); |
107 symbol_c *get_basetype_id (symbol_c *variable_name); |
102 symbol_c *get_type_id(symbol_c *variable_name); |
108 // symbol_c *get_type_decl (symbol_c *variable_name); |
103 |
109 symbol_c *get_type_id (symbol_c *variable_name); |
104 /* NOTE: this function should be remvoed/deleted. |
110 |
105 * However, it is currently used in stage 4, and before deleting it |
111 |
106 * requires that the stage4 code be analysed and fixed (i.e. replace by |
|
107 * a call to one of the above functions get_basetype_decl(), |
|
108 * get_type_decl(), get_type_id(). |
|
109 * |
|
110 * At the moment, I have a feeling that this whole class search_varfb_instance_type_c |
|
111 * will not be needed in the future (i.e. when we finish implementing type checking |
|
112 * in stage 3 correctly, where we store on each symbol in the abstract syntax |
|
113 * tree it's data type, so stage4 implementations will not need to deduce the data |
|
114 * types again), so it does not make much sense to spend more time on it. |
|
115 */ |
|
116 unsigned int get_vartype(symbol_c *variable_name); |
|
117 bool type_is_complex(void); |
|
118 |
112 |
119 private: |
113 private: |
120 /* a helper function... */ |
114 /* a helper function... */ |
121 void *visit_list(list_c *list); |
115 void *visit_list(list_c *list); |
122 |
116 |
123 /* a helper function... */ |
117 /* a helper function... */ |
124 void *base_type(symbol_c *symbol); |
118 void *base_type(symbol_c *symbol); |
125 |
119 |
126 |
120 |
127 private: |
121 private: |
128 /* We override the base class' visitor to identifier_c. |
122 /*************************/ |
129 * This is so because the base class does not consider a function block |
123 /* B.1 - Common elements */ |
130 * to be a type, unlike this class that allows a variable instance |
124 /*************************/ |
131 * of a function block type... |
125 /*******************************************/ |
132 */ |
126 /* B 1.1 - Letters, digits and identifiers */ |
133 void *visit(identifier_c *type_name); |
127 /*******************************************/ |
134 |
128 void *visit(identifier_c *variable_name); |
|
129 |
135 /********************************/ |
130 /********************************/ |
136 /* B 1.3.3 - Derived data types */ |
131 /* B 1.3.3 - Derived data types */ |
137 /********************************/ |
132 /********************************/ |
138 |
|
139 /* identifier ':' array_spec_init */ |
133 /* identifier ':' array_spec_init */ |
140 void *visit(array_type_declaration_c *symbol); |
134 void *visit(array_type_declaration_c *symbol); |
141 |
135 |
142 /* array_specification [ASSIGN array_initialization} */ |
136 /* array_specification [ASSIGN array_initialization} */ |
143 /* array_initialization may be NULL ! */ |
137 /* array_initialization may be NULL ! */ |
146 /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ |
140 /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ |
147 void *visit(array_specification_c *symbol); |
141 void *visit(array_specification_c *symbol); |
148 |
142 |
149 /* structure_type_name ':' structure_specification */ |
143 /* structure_type_name ':' structure_specification */ |
150 void *visit(structure_type_declaration_c *symbol); |
144 void *visit(structure_type_declaration_c *symbol); |
151 |
|
152 /* var1_list ':' structure_type_name */ |
|
153 void *visit(structured_var_declaration_c *symbol); |
|
154 |
145 |
155 /* structure_type_name ASSIGN structure_initialization */ |
146 /* structure_type_name ASSIGN structure_initialization */ |
156 /* structure_initialization may be NULL ! */ |
147 /* structure_initialization may be NULL ! */ |
157 // SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization) |
148 // SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization) |
158 void *visit(initialized_structure_c *symbol); |
149 void *visit(initialized_structure_c *symbol); |
171 void *visit(structure_element_initialization_list_c *symbol); /* should never get called... */ |
162 void *visit(structure_element_initialization_list_c *symbol); /* should never get called... */ |
172 /* structure_element_name ASSIGN value */ |
163 /* structure_element_name ASSIGN value */ |
173 void *visit(structure_element_initialization_c *symbol); /* should never get called... */ |
164 void *visit(structure_element_initialization_c *symbol); /* should never get called... */ |
174 |
165 |
175 |
166 |
176 |
167 /*********************/ |
|
168 /* B 1.4 - Variables */ |
|
169 /*********************/ |
|
170 void *visit(symbolic_variable_c *symbol); |
|
171 |
|
172 /********************************************/ |
|
173 /* B.1.4.1 Directly Represented Variables */ |
|
174 /********************************************/ |
|
175 /*************************************/ |
|
176 /* B 1.4.2 - Multi-element variables */ |
|
177 /*************************************/ |
|
178 void *visit(array_variable_c *symbol); |
|
179 void *visit(structured_variable_c *symbol); |
|
180 |
177 /**************************************/ |
181 /**************************************/ |
178 /* B.1.5 - Program organization units */ |
182 /* B.1.5 - Program organization units */ |
179 /**************************************/ |
183 /**************************************/ |
180 /*****************************/ |
184 /*****************************/ |
181 /* B 1.5.2 - Function Blocks */ |
185 /* B 1.5.2 - Function Blocks */ |
182 /*****************************/ |
186 /*****************************/ |
183 /* FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */ |
187 /* FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */ |
184 // SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused) |
188 // SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused) |
185 void *visit(function_block_declaration_c *symbol); |
189 void *visit(function_block_declaration_c *symbol); |
186 |
190 |
|
191 |
|
192 /*********************************************/ |
|
193 /* B.1.6 Sequential function chart elements */ |
|
194 /*********************************************/ |
|
195 /* INITIAL_STEP step_name ':' action_association_list END_STEP */ |
|
196 // SYM_REF2(initial_step_c, step_name, action_association_list) |
|
197 void *visit(initial_step_c *symbol); |
|
198 /* STEP step_name ':' action_association_list END_STEP */ |
|
199 // SYM_REF2(step_c, step_name, action_association_list) |
|
200 void *visit(step_c *symbol); |
|
201 |
187 }; // search_varfb_instance_type_c |
202 }; // search_varfb_instance_type_c |
188 |
203 |
189 |
204 |
190 |
205 |
191 |
206 |