author | Edouard Tisserant |
Thu, 07 Apr 2011 11:40:03 +0200 | |
changeset 285 | 3a60c6ff98b1 |
parent 279 | c0453b7f99df |
child 412 | aad38592bdde |
child 417 | d48f53715f77 |
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 |
||
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
80 |
unsigned int search_var_instance_decl_c::get_vartype(void) { |
181 | 81 |
return current_vartype; |
82 |
} |
|
83 |
||
84 |
/***************************/ |
|
85 |
/* B 0 - Programming Model */ |
|
86 |
/***************************/ |
|
87 |
void *search_var_instance_decl_c::visit(library_c *symbol) { |
|
88 |
/* 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
|
89 |
* so we do not visit all the functions, function blocks, etc... |
181 | 90 |
*/ |
91 |
return NULL; |
|
92 |
} |
|
93 |
||
94 |
||
95 |
||
96 |
/******************************************/ |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
202
diff
changeset
|
97 |
/* B 1.4.3 - Declaration & Initialization */ |
181 | 98 |
/******************************************/ |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
202
diff
changeset
|
99 |
|
181 | 100 |
/* edge -> The F_EDGE or R_EDGE directive */ |
101 |
// SYM_REF2(edge_declaration_c, edge, var1_list) |
|
102 |
// TODO |
|
103 |
||
104 |
void *search_var_instance_decl_c::visit(input_declarations_c *symbol) { |
|
105 |
current_vartype = input_vt; |
|
106 |
void *res = symbol->input_declaration_list->accept(*this); |
|
107 |
if (res == NULL) { |
|
108 |
current_vartype = none_vt; |
|
109 |
} |
|
110 |
return res; |
|
111 |
} |
|
112 |
||
113 |
/* VAR_OUTPUT [RETAIN | NON_RETAIN] var_init_decl_list END_VAR */ |
|
114 |
/* option -> may be NULL ! */ |
|
115 |
void *search_var_instance_decl_c::visit(output_declarations_c *symbol) { |
|
116 |
current_vartype = output_vt; |
|
117 |
void *res = symbol->var_init_decl_list->accept(*this); |
|
118 |
if (res == NULL) { |
|
119 |
current_vartype = none_vt; |
|
120 |
} |
|
121 |
return res; |
|
122 |
} |
|
123 |
||
124 |
/* VAR_IN_OUT var_declaration_list END_VAR */ |
|
125 |
void *search_var_instance_decl_c::visit(input_output_declarations_c *symbol) { |
|
126 |
current_vartype = inoutput_vt; |
|
127 |
void *res = symbol->var_declaration_list->accept(*this); |
|
128 |
if (res == NULL) { |
|
129 |
current_vartype = none_vt; |
|
130 |
} |
|
131 |
return res; |
|
132 |
} |
|
133 |
||
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
134 |
/* ENO : BOOL */ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
135 |
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
|
136 |
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
|
137 |
return symbol->type; |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
138 |
return NULL; |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
139 |
} |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
140 |
|
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
141 |
|
181 | 142 |
/* VAR [CONSTANT] var_init_decl_list END_VAR */ |
143 |
/* option -> may be NULL ! */ |
|
144 |
/* helper symbol for input_declarations */ |
|
145 |
void *search_var_instance_decl_c::visit(var_declarations_c *symbol) { |
|
146 |
current_vartype = private_vt; |
|
147 |
void *res = symbol->var_init_decl_list->accept(*this); |
|
148 |
if (res == NULL) { |
|
149 |
current_vartype = none_vt; |
|
150 |
} |
|
151 |
return res; |
|
152 |
} |
|
153 |
||
154 |
/* VAR RETAIN var_init_decl_list END_VAR */ |
|
155 |
void *search_var_instance_decl_c::visit(retentive_var_declarations_c *symbol) { |
|
156 |
current_vartype = private_vt; |
|
157 |
void *res = symbol->var_init_decl_list->accept(*this); |
|
158 |
if (res == NULL) { |
|
159 |
current_vartype = none_vt; |
|
160 |
} |
|
161 |
return res; |
|
162 |
} |
|
163 |
||
164 |
/* VAR [CONSTANT|RETAIN|NON_RETAIN] located_var_decl_list END_VAR */ |
|
165 |
/* option -> may be NULL ! */ |
|
166 |
//SYM_REF2(located_var_declarations_c, option, located_var_decl_list) |
|
167 |
void *search_var_instance_decl_c::visit(located_var_declarations_c *symbol) { |
|
168 |
current_vartype = located_vt; |
|
169 |
void *res = symbol->located_var_decl_list->accept(*this); |
|
170 |
if (res == NULL) { |
|
171 |
current_vartype = none_vt; |
|
172 |
} |
|
173 |
return res; |
|
174 |
} |
|
175 |
||
176 |
/*| VAR_EXTERNAL [CONSTANT] external_declaration_list END_VAR */ |
|
177 |
/* option -> may be NULL ! */ |
|
178 |
//SYM_REF2(external_var_declarations_c, option, external_declaration_list) |
|
179 |
void *search_var_instance_decl_c::visit(external_var_declarations_c *symbol) { |
|
180 |
current_vartype = external_vt; |
|
181 |
void *res = symbol->external_declaration_list->accept(*this); |
|
182 |
if (res == NULL) { |
|
183 |
current_vartype = none_vt; |
|
184 |
} |
|
185 |
return res; |
|
186 |
} |
|
187 |
||
188 |
/*| VAR_GLOBAL [CONSTANT|RETAIN] global_var_decl_list END_VAR */ |
|
189 |
/* option -> may be NULL ! */ |
|
190 |
//SYM_REF2(global_var_declarations_c, option, global_var_decl_list) |
|
191 |
void *search_var_instance_decl_c::visit(global_var_declarations_c *symbol) { |
|
192 |
current_vartype = global_vt; |
|
193 |
void *res = symbol->global_var_decl_list->accept(*this); |
|
194 |
if (res == NULL) { |
|
195 |
current_vartype = none_vt; |
|
196 |
} |
|
197 |
return res; |
|
198 |
} |
|
199 |
||
200 |
/* var1_list is one of the following... |
|
201 |
* simple_spec_init_c * |
|
202 |
* subrange_spec_init_c * |
|
203 |
* enumerated_spec_init_c * |
|
204 |
*/ |
|
205 |
// SYM_REF2(var1_init_decl_c, var1_list, spec_init) |
|
206 |
void *search_var_instance_decl_c::visit(var1_init_decl_c *symbol) { |
|
207 |
current_type_decl = symbol->spec_init; |
|
208 |
return symbol->var1_list->accept(*this); |
|
209 |
} |
|
210 |
||
211 |
/* var1_list ',' variable_name */ |
|
212 |
// SYM_LIST(var1_list_c) |
|
213 |
void *search_var_instance_decl_c::visit(var1_list_c *symbol) { |
|
214 |
list_c *list = symbol; |
|
215 |
for(int i = 0; i < list->n; i++) { |
|
216 |
if (compare_identifiers(list->elements[i], search_name) == 0) |
|
217 |
/* by now, current_type_decl should be != NULL */ |
|
218 |
return current_type_decl; |
|
219 |
} |
|
220 |
return NULL; |
|
221 |
} |
|
222 |
||
223 |
/* name_list ':' function_block_type_name ASSIGN structure_initialization */ |
|
224 |
/* structure_initialization -> may be NULL ! */ |
|
225 |
void *search_var_instance_decl_c::visit(fb_name_decl_c *symbol) { |
|
226 |
current_type_decl = symbol->function_block_type_name; |
|
227 |
return symbol->fb_name_list->accept(*this); |
|
228 |
} |
|
229 |
||
230 |
/* name_list ',' fb_name */ |
|
231 |
void *search_var_instance_decl_c::visit(fb_name_list_c *symbol) { |
|
232 |
list_c *list = symbol; |
|
233 |
for(int i = 0; i < list->n; i++) { |
|
234 |
if (compare_identifiers(list->elements[i], search_name) == 0) |
|
235 |
/* by now, current_fb_declaration should be != NULL */ |
|
236 |
return current_type_decl; |
|
237 |
} |
|
238 |
return NULL; |
|
239 |
} |
|
240 |
||
241 |
/* var1_list ':' array_spec_init */ |
|
242 |
// SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init) |
|
243 |
void *search_var_instance_decl_c::visit(array_var_init_decl_c *symbol) { |
|
244 |
current_type_decl = symbol->array_spec_init; |
|
245 |
return symbol->var1_list->accept(*this); |
|
246 |
} |
|
247 |
||
248 |
/* var1_list ':' initialized_structure */ |
|
249 |
// SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure) |
|
250 |
void *search_var_instance_decl_c::visit(structured_var_init_decl_c *symbol) { |
|
251 |
current_type_decl = symbol->initialized_structure; |
|
252 |
return symbol->var1_list->accept(*this); |
|
253 |
} |
|
254 |
||
255 |
/* var1_list ':' array_specification */ |
|
256 |
// SYM_REF2(array_var_declaration_c, var1_list, array_specification) |
|
257 |
void *search_var_instance_decl_c::visit(array_var_declaration_c *symbol) { |
|
258 |
current_type_decl = symbol->array_specification; |
|
259 |
return symbol->var1_list->accept(*this); |
|
260 |
} |
|
261 |
||
262 |
/* var1_list ':' structure_type_name */ |
|
263 |
// SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name) |
|
264 |
void *search_var_instance_decl_c::visit(structured_var_declaration_c *symbol) { |
|
265 |
current_type_decl = symbol->structure_type_name; |
|
266 |
return symbol->var1_list->accept(*this); |
|
267 |
} |
|
268 |
||
269 |
/* [variable_name] location ':' located_var_spec_init */ |
|
270 |
/* variable_name -> may be NULL ! */ |
|
271 |
// SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused) |
|
272 |
// TODO!! |
|
273 |
||
274 |
/* global_var_name ':' (simple_specification|subrange_specification|enumerated_specification|array_specification|prev_declared_structure_type_name|function_block_type_name */ |
|
275 |
// SYM_REF2(external_declaration_c, global_var_name, specification) |
|
276 |
void *search_var_instance_decl_c::visit(external_declaration_c *symbol) { |
|
277 |
if (compare_identifiers(symbol->global_var_name, search_name) == 0) |
|
278 |
return symbol->specification; |
|
279 |
return NULL; |
|
280 |
} |
|
281 |
||
282 |
/*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */ |
|
283 |
/* type_specification ->may be NULL ! */ |
|
284 |
// SYM_REF2(global_var_decl_c, global_var_spec, type_specification) |
|
285 |
void *search_var_instance_decl_c::visit(global_var_decl_c *symbol) { |
|
286 |
if (symbol->type_specification != NULL) { |
|
287 |
current_type_decl = symbol->type_specification; |
|
288 |
return symbol->global_var_spec->accept(*this); |
|
289 |
} |
|
290 |
else |
|
291 |
return NULL; |
|
292 |
} |
|
293 |
||
294 |
/*| global_var_name location */ |
|
295 |
//SYM_REF2(global_var_spec_c, global_var_name, location) |
|
296 |
void *search_var_instance_decl_c::visit(global_var_spec_c *symbol) { |
|
297 |
if (symbol->global_var_name != NULL && compare_identifiers(symbol->global_var_name, search_name) == 0) |
|
298 |
return current_type_decl; |
|
299 |
else |
|
300 |
return symbol->location->accept(*this); |
|
301 |
} |
|
302 |
||
303 |
/*| global_var_list ',' global_var_name */ |
|
304 |
//SYM_LIST(global_var_list_c) |
|
305 |
void *search_var_instance_decl_c::visit(global_var_list_c *symbol) { |
|
306 |
list_c *list = symbol; |
|
307 |
for(int i = 0; i < list->n; i++) { |
|
308 |
if (compare_identifiers(list->elements[i], search_name) == 0) |
|
309 |
/* by now, current_type_decl should be != NULL */ |
|
310 |
return current_type_decl; |
|
311 |
} |
|
312 |
return NULL; |
|
313 |
} |
|
314 |
||
315 |
/* [variable_name] location ':' located_var_spec_init */ |
|
316 |
/* variable_name -> may be NULL ! */ |
|
317 |
//SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused) |
|
318 |
void *search_var_instance_decl_c::visit(located_var_decl_c *symbol) { |
|
319 |
if (symbol->variable_name != NULL && compare_identifiers(symbol->variable_name, search_name) == 0) |
|
320 |
return symbol->located_var_spec_init; |
|
321 |
else { |
|
322 |
current_type_decl = symbol->located_var_spec_init; |
|
323 |
return symbol->location->accept(*this); |
|
324 |
} |
|
325 |
} |
|
326 |
||
327 |
/*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */ |
|
328 |
/* type_specification ->may be NULL ! */ |
|
329 |
// SYM_REF2(global_var_decl_c, global_var_spec, type_specification) |
|
330 |
// TODO!! |
|
331 |
||
332 |
/* AT direct_variable */ |
|
333 |
// SYM_REF2(location_c, direct_variable, unused) |
|
334 |
void *search_var_instance_decl_c::visit(location_c *symbol) { |
|
335 |
if (compare_identifiers(symbol->direct_variable, search_name) == 0) |
|
336 |
return current_type_decl; |
|
337 |
else |
|
338 |
return NULL; |
|
339 |
} |
|
340 |
||
341 |
/*| global_var_list ',' global_var_name */ |
|
342 |
// SYM_LIST(global_var_list_c) |
|
343 |
// TODO!! |
|
344 |
||
345 |
/* var1_list ':' single_byte_string_spec */ |
|
346 |
// SYM_REF2(single_byte_string_var_declaration_c, var1_list, single_byte_string_spec) |
|
347 |
void *search_var_instance_decl_c::visit(single_byte_string_var_declaration_c *symbol) { |
|
348 |
current_type_decl = symbol->single_byte_string_spec; |
|
349 |
return symbol->var1_list->accept(*this); |
|
350 |
} |
|
351 |
||
352 |
/* STRING ['[' integer ']'] [ASSIGN single_byte_character_string] */ |
|
353 |
/* integer ->may be NULL ! */ |
|
354 |
/* single_byte_character_string ->may be NULL ! */ |
|
355 |
// SYM_REF2(single_byte_string_spec_c, integer, single_byte_character_string) |
|
356 |
// TODO!! |
|
357 |
||
358 |
/* var1_list ':' double_byte_string_spec */ |
|
359 |
// SYM_REF2(double_byte_string_var_declaration_c, var1_list, double_byte_string_spec) |
|
360 |
void *search_var_instance_decl_c::visit(double_byte_string_var_declaration_c *symbol) { |
|
361 |
current_type_decl = symbol->double_byte_string_spec; |
|
362 |
return symbol->var1_list->accept(*this); |
|
363 |
} |
|
364 |
||
365 |
/* WSTRING ['[' integer ']'] [ASSIGN double_byte_character_string] */ |
|
366 |
/* integer ->may be NULL ! */ |
|
367 |
/* double_byte_character_string ->may be NULL ! */ |
|
368 |
// SYM_REF2(double_byte_string_spec_c, integer, double_byte_character_string) |
|
369 |
// TODO!! |
|
370 |
||
371 |
/* variable_name incompl_location ':' var_spec */ |
|
372 |
// SYM_REF4(incompl_located_var_decl_c, variable_name, incompl_location, var_spec, unused) |
|
373 |
// TODO!! |
|
374 |
||
375 |
/* AT incompl_location_token */ |
|
376 |
// SYM_TOKEN(incompl_location_c) |
|
377 |
// TODO!! |
|
378 |
||
379 |
||
380 |
/**************************************/ |
|
381 |
/* B.1.5 - Program organization units */ |
|
382 |
/**************************************/ |
|
383 |
/***********************/ |
|
384 |
/* B 1.5.1 - Functions */ |
|
385 |
/***********************/ |
|
386 |
// SYM_REF4(function_declaration_c, derived_function_name, type_name, var_declarations_list, function_body) |
|
387 |
void *search_var_instance_decl_c::visit(function_declaration_c *symbol) { |
|
388 |
/* functions have a variable named after themselves, to store |
|
389 |
* the variable that will be returned!! |
|
390 |
*/ |
|
391 |
if (compare_identifiers(symbol->derived_function_name, search_name) == 0) |
|
392 |
return symbol->type_name; |
|
393 |
||
394 |
/* no need to search through all the body, so we only |
|
395 |
* visit the variable declarations...! |
|
396 |
*/ |
|
397 |
return symbol->var_declarations_list->accept(*this); |
|
398 |
} |
|
399 |
||
400 |
/*****************************/ |
|
401 |
/* B 1.5.2 - Function Blocks */ |
|
402 |
/*****************************/ |
|
403 |
void *search_var_instance_decl_c::visit(function_block_declaration_c *symbol) { |
|
404 |
/* no need to search through all the body, so we only |
|
405 |
* visit the variable declarations...! |
|
406 |
*/ |
|
407 |
return symbol->var_declarations->accept(*this); |
|
408 |
} |
|
409 |
||
410 |
/**********************/ |
|
411 |
/* B 1.5.3 - Programs */ |
|
412 |
/**********************/ |
|
413 |
void *search_var_instance_decl_c::visit(program_declaration_c *symbol) { |
|
414 |
/* no need to search through all the body, so we only |
|
415 |
* visit the variable declarations...! |
|
416 |
*/ |
|
417 |
return symbol->var_declarations->accept(*this); |
|
418 |
} |
|
419 |
||
420 |
||
421 |
/********************************/ |
|
422 |
/* B 1.7 Configuration elements */ |
|
423 |
/********************************/ |
|
424 |
||
425 |
/* |
|
426 |
CONFIGURATION configuration_name |
|
427 |
optional_global_var_declarations |
|
428 |
(resource_declaration_list | single_resource_declaration) |
|
429 |
optional_access_declarations |
|
430 |
optional_instance_specific_initializations |
|
431 |
END_CONFIGURATION |
|
432 |
*/ |
|
433 |
/* |
|
434 |
SYM_REF6(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations, unused) |
|
435 |
*/ |
|
436 |
void *search_var_instance_decl_c::visit(configuration_declaration_c *symbol) { |
|
437 |
/* no need to search through all the configuration, so we only |
|
438 |
* visit the global variable declarations...! |
|
439 |
*/ |
|
440 |
if (symbol->global_var_declarations != NULL) |
|
441 |
return symbol->global_var_declarations->accept(*this); |
|
442 |
else |
|
443 |
return NULL; |
|
444 |
} |
|
445 |
||
446 |
/* |
|
447 |
RESOURCE resource_name ON resource_type_name |
|
448 |
optional_global_var_declarations |
|
449 |
single_resource_declaration |
|
450 |
END_RESOURCE |
|
451 |
*/ |
|
452 |
// SYM_REF4(resource_declaration_c, resource_name, resource_type_name, global_var_declarations, resource_declaration) |
|
453 |
void *search_var_instance_decl_c::visit(resource_declaration_c *symbol) { |
|
454 |
/* no need to search through all the resource, so we only |
|
455 |
* visit the global variable declarations...! |
|
456 |
*/ |
|
457 |
if (symbol->global_var_declarations != NULL) |
|
458 |
return symbol->global_var_declarations->accept(*this); |
|
459 |
else |
|
460 |
return NULL; |
|
461 |
} |
|
462 |
||
463 |
/* task_configuration_list program_configuration_list */ |
|
464 |
// SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list) |
|
465 |
void *search_var_instance_decl_c::visit(single_resource_declaration_c *symbol) { |
|
466 |
/* no need to search through all the resource, |
|
467 |
* and there is no global variable declarations...! |
|
468 |
*/ |
|
469 |
return NULL; |
|
470 |
} |
|
471 |
||
472 |
#if 0 |
|
473 |
/*********************/ |
|
474 |
/* B 1.4 - Variables */ |
|
475 |
/*********************/ |
|
476 |
SYM_REF2(symbolic_variable_c, var_name, unused) |
|
477 |
||
478 |
/********************************************/ |
|
479 |
/* B.1.4.1 Directly Represented Variables */ |
|
480 |
/********************************************/ |
|
481 |
SYM_TOKEN(direct_variable_c) |
|
482 |
||
483 |
/*************************************/ |
|
484 |
/* B.1.4.2 Multi-element Variables */ |
|
485 |
/*************************************/ |
|
486 |
/* subscripted_variable '[' subscript_list ']' */ |
|
487 |
SYM_REF2(array_variable_c, subscripted_variable, subscript_list) |
|
488 |
||
489 |
/* subscript_list ',' subscript */ |
|
490 |
SYM_LIST(subscript_list_c) |
|
491 |
||
492 |
/* record_variable '.' field_selector */ |
|
493 |
/* WARNING: input and/or output variables of function blocks |
|
494 |
* may be accessed as fields of a tructured variable! |
|
495 |
* Code handling a structured_variable_c must take |
|
496 |
* this into account! |
|
497 |
*/ |
|
498 |
SYM_REF2(structured_variable_c, record_variable, field_selector) |
|
499 |
||
500 |
||
501 |
||
502 |
}; |
|
503 |
#endif |