author | Mario de Sousa <msousa@fe.up.pt> |
Sat, 31 Mar 2012 15:30:38 +0100 | |
changeset 495 | 8c6823fee086 |
parent 417 | d48f53715f77 |
child 504 | f8d422b98315 |
permissions | -rwxr-xr-x |
181 | 1 |
/* |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
2 |
* matiec - a compiler for the programming languages defined in IEC 61131-3 |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
3 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
4 |
* Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) |
279
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
265
diff
changeset
|
5 |
* Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
6 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
7 |
* This program is free software: you can redistribute it and/or modify |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
8 |
* it under the terms of the GNU General Public License as published by |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
9 |
* the Free Software Foundation, either version 3 of the License, or |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
10 |
* (at your option) any later version. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
11 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
12 |
* This program is distributed in the hope that it will be useful, |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
15 |
* GNU General Public License for more details. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
16 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
19 |
* |
181 | 20 |
* |
21 |
* This code is made available on the understanding that it will not be |
|
22 |
* used in safety-critical situations without a full and competent review. |
|
23 |
*/ |
|
24 |
||
25 |
/* |
|
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
26 |
* An IEC 61131-3 compiler. |
181 | 27 |
* |
28 |
* Based on the |
|
29 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
|
30 |
* |
|
31 |
*/ |
|
32 |
||
33 |
/* Determine the data type of a specific variable instance, including |
|
34 |
* function block instances. |
|
35 |
* A reference to the relevant variable declaration is returned. |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
202
diff
changeset
|
36 |
* The variable instance may NOT be a member of a structure of a member |
181 | 37 |
* of a structure of an element of an array of ... |
38 |
* |
|
39 |
* example: |
|
40 |
* window.points[1].coordinate.x |
|
41 |
* window.points[1].colour |
|
42 |
* etc... ARE NOT ALLOWED! |
|
43 |
* |
|
44 |
* This class must only be passed the name of the variable that will appear |
|
45 |
* in the variable declaration. In the above examples, this would be |
|
46 |
* 'window' !! |
|
47 |
* |
|
48 |
* |
|
49 |
* If you need to pass a complete name of a variable instance (such as |
|
50 |
* 'window.points[1].coordinate.x') use the search_varfb_instance_type_c instead! |
|
51 |
*/ |
|
52 |
||
53 |
/* Note that current_type_decl that this class returns may reference the |
|
54 |
* name of a type, or the type declaration itself! |
|
55 |
* For an example of the first, consider a variable declared as ... |
|
56 |
* x : AAA; |
|
57 |
* where the AAA type is previously declared as whatever. |
|
58 |
* For an example of the second, consider a variable declared as ... |
|
59 |
* x : array of int [10]; ----> is allowed |
|
60 |
* |
|
61 |
* If it is the first, we will return a reference to the name, if the second |
|
62 |
* we return a reference to the declaration!! |
|
63 |
*/ |
|
64 |
#include "absyntax_utils.hh" |
|
65 |
||
66 |
||
67 |
search_var_instance_decl_c::search_var_instance_decl_c(symbol_c *search_scope) { |
|
68 |
this->current_vartype = none_vt; |
|
69 |
this->search_scope = search_scope; |
|
70 |
this->search_name = NULL; |
|
71 |
this->current_type_decl = NULL; |
|
72 |
} |
|
73 |
||
74 |
symbol_c *search_var_instance_decl_c::get_decl(symbol_c *variable_instance_name) { |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
202
diff
changeset
|
75 |
this->current_vartype = none_vt; |
181 | 76 |
this->search_name = variable_instance_name; |
77 |
return (symbol_c *)search_scope->accept(*this); |
|
78 |
} |
|
79 |
||
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
279
diff
changeset
|
80 |
unsigned int search_var_instance_decl_c::get_vartype(symbol_c *variable_instance_name) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
279
diff
changeset
|
81 |
this->current_vartype = none_vt; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
279
diff
changeset
|
82 |
this->search_name = variable_instance_name; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
279
diff
changeset
|
83 |
search_scope->accept(*this); |
181 | 84 |
return current_vartype; |
85 |
} |
|
86 |
||
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
279
diff
changeset
|
87 |
|
181 | 88 |
/***************************/ |
89 |
/* B 0 - Programming Model */ |
|
90 |
/***************************/ |
|
91 |
void *search_var_instance_decl_c::visit(library_c *symbol) { |
|
92 |
/* we do not want to search multiple declaration scopes, |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
202
diff
changeset
|
93 |
* so we do not visit all the functions, function blocks, etc... |
181 | 94 |
*/ |
95 |
return NULL; |
|
96 |
} |
|
97 |
||
98 |
||
99 |
||
100 |
/******************************************/ |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
202
diff
changeset
|
101 |
/* B 1.4.3 - Declaration & Initialization */ |
181 | 102 |
/******************************************/ |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
202
diff
changeset
|
103 |
|
181 | 104 |
/* edge -> The F_EDGE or R_EDGE directive */ |
105 |
// SYM_REF2(edge_declaration_c, edge, var1_list) |
|
106 |
// TODO |
|
107 |
||
108 |
void *search_var_instance_decl_c::visit(input_declarations_c *symbol) { |
|
109 |
current_vartype = input_vt; |
|
110 |
void *res = symbol->input_declaration_list->accept(*this); |
|
111 |
if (res == NULL) { |
|
112 |
current_vartype = none_vt; |
|
113 |
} |
|
114 |
return res; |
|
115 |
} |
|
116 |
||
117 |
/* VAR_OUTPUT [RETAIN | NON_RETAIN] var_init_decl_list END_VAR */ |
|
118 |
/* option -> may be NULL ! */ |
|
119 |
void *search_var_instance_decl_c::visit(output_declarations_c *symbol) { |
|
120 |
current_vartype = output_vt; |
|
121 |
void *res = symbol->var_init_decl_list->accept(*this); |
|
122 |
if (res == NULL) { |
|
123 |
current_vartype = none_vt; |
|
124 |
} |
|
125 |
return res; |
|
126 |
} |
|
127 |
||
128 |
/* VAR_IN_OUT var_declaration_list END_VAR */ |
|
129 |
void *search_var_instance_decl_c::visit(input_output_declarations_c *symbol) { |
|
130 |
current_vartype = inoutput_vt; |
|
131 |
void *res = symbol->var_declaration_list->accept(*this); |
|
132 |
if (res == NULL) { |
|
133 |
current_vartype = none_vt; |
|
134 |
} |
|
135 |
return res; |
|
136 |
} |
|
137 |
||
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
138 |
/* ENO : BOOL */ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
139 |
void *search_var_instance_decl_c::visit(eno_param_declaration_c *symbol) { |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
140 |
if (compare_identifiers(symbol->name, search_name) == 0) |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
141 |
return symbol->type; |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
142 |
return NULL; |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
143 |
} |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
144 |
|
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
145 |
|
181 | 146 |
/* VAR [CONSTANT] var_init_decl_list END_VAR */ |
147 |
/* option -> may be NULL ! */ |
|
148 |
/* helper symbol for input_declarations */ |
|
149 |
void *search_var_instance_decl_c::visit(var_declarations_c *symbol) { |
|
150 |
current_vartype = private_vt; |
|
151 |
void *res = symbol->var_init_decl_list->accept(*this); |
|
152 |
if (res == NULL) { |
|
153 |
current_vartype = none_vt; |
|
154 |
} |
|
155 |
return res; |
|
156 |
} |
|
157 |
||
158 |
/* VAR RETAIN var_init_decl_list END_VAR */ |
|
159 |
void *search_var_instance_decl_c::visit(retentive_var_declarations_c *symbol) { |
|
160 |
current_vartype = private_vt; |
|
161 |
void *res = symbol->var_init_decl_list->accept(*this); |
|
162 |
if (res == NULL) { |
|
163 |
current_vartype = none_vt; |
|
164 |
} |
|
165 |
return res; |
|
166 |
} |
|
167 |
||
168 |
/* VAR [CONSTANT|RETAIN|NON_RETAIN] located_var_decl_list END_VAR */ |
|
169 |
/* option -> may be NULL ! */ |
|
170 |
//SYM_REF2(located_var_declarations_c, option, located_var_decl_list) |
|
171 |
void *search_var_instance_decl_c::visit(located_var_declarations_c *symbol) { |
|
172 |
current_vartype = located_vt; |
|
173 |
void *res = symbol->located_var_decl_list->accept(*this); |
|
174 |
if (res == NULL) { |
|
175 |
current_vartype = none_vt; |
|
176 |
} |
|
177 |
return res; |
|
178 |
} |
|
179 |
||
180 |
/*| VAR_EXTERNAL [CONSTANT] external_declaration_list END_VAR */ |
|
181 |
/* option -> may be NULL ! */ |
|
182 |
//SYM_REF2(external_var_declarations_c, option, external_declaration_list) |
|
183 |
void *search_var_instance_decl_c::visit(external_var_declarations_c *symbol) { |
|
184 |
current_vartype = external_vt; |
|
185 |
void *res = symbol->external_declaration_list->accept(*this); |
|
186 |
if (res == NULL) { |
|
187 |
current_vartype = none_vt; |
|
188 |
} |
|
189 |
return res; |
|
190 |
} |
|
191 |
||
192 |
/*| VAR_GLOBAL [CONSTANT|RETAIN] global_var_decl_list END_VAR */ |
|
193 |
/* option -> may be NULL ! */ |
|
194 |
//SYM_REF2(global_var_declarations_c, option, global_var_decl_list) |
|
195 |
void *search_var_instance_decl_c::visit(global_var_declarations_c *symbol) { |
|
196 |
current_vartype = global_vt; |
|
197 |
void *res = symbol->global_var_decl_list->accept(*this); |
|
198 |
if (res == NULL) { |
|
199 |
current_vartype = none_vt; |
|
200 |
} |
|
201 |
return res; |
|
202 |
} |
|
203 |
||
204 |
/* var1_list is one of the following... |
|
205 |
* simple_spec_init_c * |
|
206 |
* subrange_spec_init_c * |
|
207 |
* enumerated_spec_init_c * |
|
208 |
*/ |
|
209 |
// SYM_REF2(var1_init_decl_c, var1_list, spec_init) |
|
210 |
void *search_var_instance_decl_c::visit(var1_init_decl_c *symbol) { |
|
211 |
current_type_decl = symbol->spec_init; |
|
212 |
return symbol->var1_list->accept(*this); |
|
213 |
} |
|
214 |
||
215 |
/* var1_list ',' variable_name */ |
|
216 |
// SYM_LIST(var1_list_c) |
|
217 |
void *search_var_instance_decl_c::visit(var1_list_c *symbol) { |
|
218 |
list_c *list = symbol; |
|
219 |
for(int i = 0; i < list->n; i++) { |
|
220 |
if (compare_identifiers(list->elements[i], search_name) == 0) |
|
221 |
/* by now, current_type_decl should be != NULL */ |
|
222 |
return current_type_decl; |
|
223 |
} |
|
224 |
return NULL; |
|
225 |
} |
|
226 |
||
227 |
/* name_list ':' function_block_type_name ASSIGN structure_initialization */ |
|
228 |
/* structure_initialization -> may be NULL ! */ |
|
229 |
void *search_var_instance_decl_c::visit(fb_name_decl_c *symbol) { |
|
230 |
current_type_decl = symbol->function_block_type_name; |
|
231 |
return symbol->fb_name_list->accept(*this); |
|
232 |
} |
|
233 |
||
234 |
/* name_list ',' fb_name */ |
|
235 |
void *search_var_instance_decl_c::visit(fb_name_list_c *symbol) { |
|
236 |
list_c *list = symbol; |
|
237 |
for(int i = 0; i < list->n; i++) { |
|
238 |
if (compare_identifiers(list->elements[i], search_name) == 0) |
|
239 |
/* by now, current_fb_declaration should be != NULL */ |
|
240 |
return current_type_decl; |
|
241 |
} |
|
242 |
return NULL; |
|
243 |
} |
|
244 |
||
245 |
/* var1_list ':' array_spec_init */ |
|
246 |
// SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init) |
|
247 |
void *search_var_instance_decl_c::visit(array_var_init_decl_c *symbol) { |
|
248 |
current_type_decl = symbol->array_spec_init; |
|
249 |
return symbol->var1_list->accept(*this); |
|
250 |
} |
|
251 |
||
252 |
/* var1_list ':' initialized_structure */ |
|
253 |
// SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure) |
|
254 |
void *search_var_instance_decl_c::visit(structured_var_init_decl_c *symbol) { |
|
255 |
current_type_decl = symbol->initialized_structure; |
|
256 |
return symbol->var1_list->accept(*this); |
|
257 |
} |
|
258 |
||
259 |
/* var1_list ':' array_specification */ |
|
260 |
// SYM_REF2(array_var_declaration_c, var1_list, array_specification) |
|
261 |
void *search_var_instance_decl_c::visit(array_var_declaration_c *symbol) { |
|
262 |
current_type_decl = symbol->array_specification; |
|
263 |
return symbol->var1_list->accept(*this); |
|
264 |
} |
|
265 |
||
266 |
/* var1_list ':' structure_type_name */ |
|
267 |
// SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name) |
|
268 |
void *search_var_instance_decl_c::visit(structured_var_declaration_c *symbol) { |
|
269 |
current_type_decl = symbol->structure_type_name; |
|
270 |
return symbol->var1_list->accept(*this); |
|
271 |
} |
|
272 |
||
273 |
/* [variable_name] location ':' located_var_spec_init */ |
|
274 |
/* variable_name -> may be NULL ! */ |
|
275 |
// SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused) |
|
276 |
// TODO!! |
|
277 |
||
278 |
/* global_var_name ':' (simple_specification|subrange_specification|enumerated_specification|array_specification|prev_declared_structure_type_name|function_block_type_name */ |
|
279 |
// SYM_REF2(external_declaration_c, global_var_name, specification) |
|
280 |
void *search_var_instance_decl_c::visit(external_declaration_c *symbol) { |
|
281 |
if (compare_identifiers(symbol->global_var_name, search_name) == 0) |
|
282 |
return symbol->specification; |
|
283 |
return NULL; |
|
284 |
} |
|
285 |
||
286 |
/*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */ |
|
287 |
/* type_specification ->may be NULL ! */ |
|
288 |
// SYM_REF2(global_var_decl_c, global_var_spec, type_specification) |
|
289 |
void *search_var_instance_decl_c::visit(global_var_decl_c *symbol) { |
|
290 |
if (symbol->type_specification != NULL) { |
|
291 |
current_type_decl = symbol->type_specification; |
|
292 |
return symbol->global_var_spec->accept(*this); |
|
293 |
} |
|
294 |
else |
|
295 |
return NULL; |
|
296 |
} |
|
297 |
||
298 |
/*| global_var_name location */ |
|
299 |
//SYM_REF2(global_var_spec_c, global_var_name, location) |
|
300 |
void *search_var_instance_decl_c::visit(global_var_spec_c *symbol) { |
|
301 |
if (symbol->global_var_name != NULL && compare_identifiers(symbol->global_var_name, search_name) == 0) |
|
302 |
return current_type_decl; |
|
303 |
else |
|
304 |
return symbol->location->accept(*this); |
|
305 |
} |
|
306 |
||
307 |
/*| global_var_list ',' global_var_name */ |
|
308 |
//SYM_LIST(global_var_list_c) |
|
309 |
void *search_var_instance_decl_c::visit(global_var_list_c *symbol) { |
|
310 |
list_c *list = symbol; |
|
311 |
for(int i = 0; i < list->n; i++) { |
|
312 |
if (compare_identifiers(list->elements[i], search_name) == 0) |
|
313 |
/* by now, current_type_decl should be != NULL */ |
|
314 |
return current_type_decl; |
|
315 |
} |
|
316 |
return NULL; |
|
317 |
} |
|
318 |
||
319 |
/* [variable_name] location ':' located_var_spec_init */ |
|
320 |
/* variable_name -> may be NULL ! */ |
|
321 |
//SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused) |
|
322 |
void *search_var_instance_decl_c::visit(located_var_decl_c *symbol) { |
|
323 |
if (symbol->variable_name != NULL && compare_identifiers(symbol->variable_name, search_name) == 0) |
|
324 |
return symbol->located_var_spec_init; |
|
325 |
else { |
|
326 |
current_type_decl = symbol->located_var_spec_init; |
|
327 |
return symbol->location->accept(*this); |
|
328 |
} |
|
329 |
} |
|
330 |
||
331 |
/*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */ |
|
332 |
/* type_specification ->may be NULL ! */ |
|
333 |
// SYM_REF2(global_var_decl_c, global_var_spec, type_specification) |
|
334 |
// TODO!! |
|
335 |
||
336 |
/* AT direct_variable */ |
|
337 |
// SYM_REF2(location_c, direct_variable, unused) |
|
338 |
void *search_var_instance_decl_c::visit(location_c *symbol) { |
|
339 |
if (compare_identifiers(symbol->direct_variable, search_name) == 0) |
|
340 |
return current_type_decl; |
|
341 |
else |
|
342 |
return NULL; |
|
343 |
} |
|
344 |
||
345 |
/*| global_var_list ',' global_var_name */ |
|
346 |
// SYM_LIST(global_var_list_c) |
|
347 |
// TODO!! |
|
348 |
||
349 |
/* var1_list ':' single_byte_string_spec */ |
|
350 |
// SYM_REF2(single_byte_string_var_declaration_c, var1_list, single_byte_string_spec) |
|
351 |
void *search_var_instance_decl_c::visit(single_byte_string_var_declaration_c *symbol) { |
|
352 |
current_type_decl = symbol->single_byte_string_spec; |
|
353 |
return symbol->var1_list->accept(*this); |
|
354 |
} |
|
355 |
||
356 |
/* STRING ['[' integer ']'] [ASSIGN single_byte_character_string] */ |
|
357 |
/* integer ->may be NULL ! */ |
|
358 |
/* single_byte_character_string ->may be NULL ! */ |
|
359 |
// SYM_REF2(single_byte_string_spec_c, integer, single_byte_character_string) |
|
360 |
// TODO!! |
|
361 |
||
362 |
/* var1_list ':' double_byte_string_spec */ |
|
363 |
// SYM_REF2(double_byte_string_var_declaration_c, var1_list, double_byte_string_spec) |
|
364 |
void *search_var_instance_decl_c::visit(double_byte_string_var_declaration_c *symbol) { |
|
365 |
current_type_decl = symbol->double_byte_string_spec; |
|
366 |
return symbol->var1_list->accept(*this); |
|
367 |
} |
|
368 |
||
369 |
/* WSTRING ['[' integer ']'] [ASSIGN double_byte_character_string] */ |
|
370 |
/* integer ->may be NULL ! */ |
|
371 |
/* double_byte_character_string ->may be NULL ! */ |
|
372 |
// SYM_REF2(double_byte_string_spec_c, integer, double_byte_character_string) |
|
373 |
// TODO!! |
|
374 |
||
375 |
/* variable_name incompl_location ':' var_spec */ |
|
376 |
// SYM_REF4(incompl_located_var_decl_c, variable_name, incompl_location, var_spec, unused) |
|
377 |
// TODO!! |
|
378 |
||
379 |
/* AT incompl_location_token */ |
|
380 |
// SYM_TOKEN(incompl_location_c) |
|
381 |
// TODO!! |
|
382 |
||
383 |
||
384 |
/**************************************/ |
|
385 |
/* B.1.5 - Program organization units */ |
|
386 |
/**************************************/ |
|
387 |
/***********************/ |
|
388 |
/* B 1.5.1 - Functions */ |
|
389 |
/***********************/ |
|
390 |
// SYM_REF4(function_declaration_c, derived_function_name, type_name, var_declarations_list, function_body) |
|
391 |
void *search_var_instance_decl_c::visit(function_declaration_c *symbol) { |
|
392 |
/* functions have a variable named after themselves, to store |
|
393 |
* the variable that will be returned!! |
|
394 |
*/ |
|
395 |
if (compare_identifiers(symbol->derived_function_name, search_name) == 0) |
|
396 |
return symbol->type_name; |
|
397 |
||
398 |
/* no need to search through all the body, so we only |
|
399 |
* visit the variable declarations...! |
|
400 |
*/ |
|
401 |
return symbol->var_declarations_list->accept(*this); |
|
402 |
} |
|
403 |
||
404 |
/*****************************/ |
|
405 |
/* B 1.5.2 - Function Blocks */ |
|
406 |
/*****************************/ |
|
407 |
void *search_var_instance_decl_c::visit(function_block_declaration_c *symbol) { |
|
408 |
/* no need to search through all the body, so we only |
|
409 |
* visit the variable declarations...! |
|
410 |
*/ |
|
411 |
return symbol->var_declarations->accept(*this); |
|
412 |
} |
|
413 |
||
414 |
/**********************/ |
|
415 |
/* B 1.5.3 - Programs */ |
|
416 |
/**********************/ |
|
417 |
void *search_var_instance_decl_c::visit(program_declaration_c *symbol) { |
|
418 |
/* no need to search through all the body, so we only |
|
419 |
* visit the variable declarations...! |
|
420 |
*/ |
|
421 |
return symbol->var_declarations->accept(*this); |
|
422 |
} |
|
423 |
||
424 |
||
425 |
/********************************/ |
|
426 |
/* B 1.7 Configuration elements */ |
|
427 |
/********************************/ |
|
428 |
||
429 |
/* |
|
430 |
CONFIGURATION configuration_name |
|
431 |
optional_global_var_declarations |
|
432 |
(resource_declaration_list | single_resource_declaration) |
|
433 |
optional_access_declarations |
|
434 |
optional_instance_specific_initializations |
|
435 |
END_CONFIGURATION |
|
436 |
*/ |
|
437 |
/* |
|
438 |
SYM_REF6(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations, unused) |
|
439 |
*/ |
|
440 |
void *search_var_instance_decl_c::visit(configuration_declaration_c *symbol) { |
|
441 |
/* no need to search through all the configuration, so we only |
|
442 |
* visit the global variable declarations...! |
|
443 |
*/ |
|
444 |
if (symbol->global_var_declarations != NULL) |
|
445 |
return symbol->global_var_declarations->accept(*this); |
|
446 |
else |
|
447 |
return NULL; |
|
448 |
} |
|
449 |
||
450 |
/* |
|
451 |
RESOURCE resource_name ON resource_type_name |
|
452 |
optional_global_var_declarations |
|
453 |
single_resource_declaration |
|
454 |
END_RESOURCE |
|
455 |
*/ |
|
456 |
// SYM_REF4(resource_declaration_c, resource_name, resource_type_name, global_var_declarations, resource_declaration) |
|
457 |
void *search_var_instance_decl_c::visit(resource_declaration_c *symbol) { |
|
458 |
/* no need to search through all the resource, so we only |
|
459 |
* visit the global variable declarations...! |
|
460 |
*/ |
|
461 |
if (symbol->global_var_declarations != NULL) |
|
462 |
return symbol->global_var_declarations->accept(*this); |
|
463 |
else |
|
464 |
return NULL; |
|
465 |
} |
|
466 |
||
467 |
/* task_configuration_list program_configuration_list */ |
|
468 |
// SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list) |
|
469 |
void *search_var_instance_decl_c::visit(single_resource_declaration_c *symbol) { |
|
470 |
/* no need to search through all the resource, |
|
471 |
* and there is no global variable declarations...! |
|
472 |
*/ |
|
473 |
return NULL; |
|
474 |
} |
|
475 |
||
476 |
#if 0 |
|
477 |
/*********************/ |
|
478 |
/* B 1.4 - Variables */ |
|
479 |
/*********************/ |
|
480 |
SYM_REF2(symbolic_variable_c, var_name, unused) |
|
481 |
||
482 |
/********************************************/ |
|
483 |
/* B.1.4.1 Directly Represented Variables */ |
|
484 |
/********************************************/ |
|
485 |
SYM_TOKEN(direct_variable_c) |
|
486 |
||
487 |
/*************************************/ |
|
488 |
/* B.1.4.2 Multi-element Variables */ |
|
489 |
/*************************************/ |
|
490 |
/* subscripted_variable '[' subscript_list ']' */ |
|
491 |
SYM_REF2(array_variable_c, subscripted_variable, subscript_list) |
|
492 |
||
493 |
/* subscript_list ',' subscript */ |
|
494 |
SYM_LIST(subscript_list_c) |
|
495 |
||
496 |
/* record_variable '.' field_selector */ |
|
497 |
/* WARNING: input and/or output variables of function blocks |
|
498 |
* may be accessed as fields of a tructured variable! |
|
499 |
* Code handling a structured_variable_c must take |
|
500 |
* this into account! |
|
501 |
*/ |
|
502 |
SYM_REF2(structured_variable_c, record_variable, field_selector) |
|
503 |
||
504 |
||
505 |
||
506 |
}; |
|
507 |
#endif |