|
1 /* |
|
2 * matiec - a compiler for the programming languages defined in IEC 61131-3 |
|
3 * |
|
4 * Copyright (C) 2003-2012 Mario de Sousa (msousa@fe.up.pt) |
|
5 * Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant |
|
6 * |
|
7 * This program is free software: you can redistribute it and/or modify |
|
8 * it under the terms of the GNU General Public License as published by |
|
9 * the Free Software Foundation, either version 3 of the License, or |
|
10 * (at your option) any later version. |
|
11 * |
|
12 * This program is distributed in the hope that it will be useful, |
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 * GNU General Public License for more details. |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License |
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
19 * |
|
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 /* |
|
26 * An IEC 61131-3 compiler. |
|
27 * |
|
28 * Based on the |
|
29 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
|
30 * |
|
31 */ |
|
32 |
|
33 /* Determine the characteristics of a specific data type |
|
34 * e.g., is it an enumeration, is it an array, is it ANY_INT, etc... |
|
35 * |
|
36 * The methods of this class may be passed either: |
|
37 * - a data type declaration symbol_c, |
|
38 * OR |
|
39 * - the name of a data type (identifier_c) |
|
40 * In this case, we shall first serach for the basetype declaration using search_base_type_c, and then |
|
41 * run the normal process. |
|
42 */ |
|
43 #include "absyntax_utils.hh" |
|
44 |
|
45 #include "../main.hh" // required for ERROR() and ERROR_MSG() macros. |
|
46 |
|
47 |
|
48 |
|
49 #include <typeinfo> // required for typeid |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 static search_base_type_c search_base_type; |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 bool get_datatype_info_c::is_sfc_initstep(symbol_c *type_symbol) { |
|
62 symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); |
|
63 if (typeid(*type_decl) == typeid(initial_step_c)) {return true;} /* INITIAL_STEP step_name ':' action_association_list END_STEP */ /* A pseudo data type! */ |
|
64 return false; |
|
65 } |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 bool get_datatype_info_c::is_sfc_step(symbol_c *type_symbol) { |
|
72 symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); |
|
73 if (typeid(*type_decl) == typeid(initial_step_c)) {return true;} /* INITIAL_STEP step_name ':' action_association_list END_STEP */ /* A pseudo data type! */ |
|
74 if (typeid(*type_decl) == typeid( step_c)) {return true;} /* STEP step_name ':' action_association_list END_STEP */ /* A pseudo data type! */ |
|
75 return false; |
|
76 } |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 bool get_datatype_info_c::is_function_block(symbol_c *type_symbol) { |
|
82 symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); |
|
83 if (typeid(*type_decl) == typeid(function_block_declaration_c)) {return true;} /* FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */ |
|
84 return false; |
|
85 } |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 bool get_datatype_info_c::is_subrange(symbol_c *type_symbol) { |
|
92 symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); /* NOTE: will work correctly once we update the way search_base_type_c works, by adding a new search_effective_type:c */ |
|
93 |
|
94 if (typeid(*type_decl) == typeid(subrange_type_declaration_c)) {return true;} /* subrange_type_name ':' subrange_spec_init */ |
|
95 if (typeid(*type_decl) == typeid(subrange_spec_init_c)) {return true;} /* subrange_specification ASSIGN signed_integer */ |
|
96 if (typeid(*type_decl) == typeid(subrange_specification_c)) {return true;} /* integer_type_name '(' subrange')' */ |
|
97 |
|
98 if (typeid(*type_decl) == typeid(subrange_c)) {ERROR;} /* signed_integer DOTDOT signed_integer */ |
|
99 return false; |
|
100 } |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 bool get_datatype_info_c::is_enumerated(symbol_c *type_symbol) { |
|
107 symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); |
|
108 |
|
109 if (typeid(*type_decl) == typeid(enumerated_type_declaration_c)) {return true;} /* enumerated_type_name ':' enumerated_spec_init */ |
|
110 if (typeid(*type_decl) == typeid(enumerated_spec_init_c)) {return true;} /* enumerated_specification ASSIGN enumerated_value */ |
|
111 if (typeid(*type_decl) == typeid(enumerated_value_list_c)) {return true;} /* enumerated_value_list ',' enumerated_value */ /* once we change the way we handle enums, this will probably become an ERROR! */ |
|
112 |
|
113 if (typeid(*type_decl) == typeid(enumerated_value_c)) {ERROR;} /* enumerated_type_name '#' identifier */ |
|
114 return false; |
|
115 } |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 bool get_datatype_info_c::is_array(symbol_c *type_symbol) { |
|
122 symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); |
|
123 |
|
124 if (typeid(*type_decl) == typeid(array_type_declaration_c)) {return true;} /* identifier ':' array_spec_init */ |
|
125 if (typeid(*type_decl) == typeid(array_spec_init_c)) {return true;} /* array_specification [ASSIGN array_initialization} */ |
|
126 if (typeid(*type_decl) == typeid(array_specification_c)) {return true;} /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ |
|
127 |
|
128 if (typeid(*type_decl) == typeid(array_subrange_list_c)) {ERROR;} /* array_subrange_list ',' subrange */ |
|
129 if (typeid(*type_decl) == typeid(array_initial_elements_list_c)) {ERROR;} /* array_initialization: '[' array_initial_elements_list ']' */ /* array_initial_elements_list ',' array_initial_elements */ |
|
130 if (typeid(*type_decl) == typeid(array_initial_elements_c)) {ERROR;} /* integer '(' [array_initial_element] ')' */ |
|
131 return false; |
|
132 } |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 bool get_datatype_info_c::is_structure(symbol_c *type_symbol) { |
|
139 symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); |
|
140 |
|
141 if (typeid(*type_decl) == typeid(structure_type_declaration_c)) {return true;} /* structure_type_name ':' structure_specification */ |
|
142 if (typeid(*type_decl) == typeid(initialized_structure_c)) {return true;} /* structure_type_name ASSIGN structure_initialization */ |
|
143 if (typeid(*type_decl) == typeid(structure_element_declaration_list_c)) {return true;} /* structure_declaration: STRUCT structure_element_declaration_list END_STRUCT */ /* structure_element_declaration_list structure_element_declaration ';' */ |
|
144 |
|
145 if (typeid(*type_decl) == typeid(structure_element_declaration_c)) {ERROR;} /* structure_element_name ':' *_spec_init */ |
|
146 if (typeid(*type_decl) == typeid(structure_element_initialization_list_c)) {ERROR;} /* structure_initialization: '(' structure_element_initialization_list ')' */ /* structure_element_initialization_list ',' structure_element_initialization */ |
|
147 if (typeid(*type_decl) == typeid(structure_element_initialization_c)) {ERROR;} /* structure_element_name ASSIGN value */ |
|
148 return false; |
|
149 } |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 bool get_datatype_info_c::is_ANY_ELEMENTARY(symbol_c *type_symbol) { |
|
161 if (type_symbol == NULL) {return false;} |
|
162 if (is_ANY_MAGNITUDE(type_symbol)) {return true;} |
|
163 if (is_ANY_BIT (type_symbol)) {return true;} |
|
164 if (is_ANY_STRING (type_symbol)) {return true;} |
|
165 if (is_ANY_DATE (type_symbol)) {return true;} |
|
166 return false; |
|
167 } |
|
168 |
|
169 |
|
170 bool get_datatype_info_c::is_ANY_SAFEELEMENTARY(symbol_c *type_symbol) { |
|
171 if (type_symbol == NULL) {return false;} |
|
172 if (is_ANY_SAFEMAGNITUDE(type_symbol)) {return true;} |
|
173 if (is_ANY_SAFEBIT (type_symbol)) {return true;} |
|
174 if (is_ANY_SAFESTRING (type_symbol)) {return true;} |
|
175 if (is_ANY_SAFEDATE (type_symbol)) {return true;} |
|
176 return false; |
|
177 } |
|
178 |
|
179 |
|
180 bool get_datatype_info_c::is_ANY_ELEMENTARY_compatible(symbol_c *type_symbol) { |
|
181 if (type_symbol == NULL) {return false;} |
|
182 if (is_ANY_ELEMENTARY (type_symbol)) {return true;} |
|
183 if (is_ANY_SAFEELEMENTARY(type_symbol)) {return true;} |
|
184 return false; |
|
185 } |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 bool get_datatype_info_c::is_ANY_MAGNITUDE(symbol_c *type_symbol) { |
|
194 if (type_symbol == NULL) {return false;} |
|
195 if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;} |
|
196 if (is_ANY_NUM(type_symbol)) {return true;} |
|
197 return false; |
|
198 } |
|
199 |
|
200 |
|
201 bool get_datatype_info_c::is_ANY_SAFEMAGNITUDE(symbol_c *type_symbol) { |
|
202 if (type_symbol == NULL) {return false;} |
|
203 if (typeid(*type_symbol) == typeid(safetime_type_name_c)) {return true;} |
|
204 if (is_ANY_SAFENUM(type_symbol)) {return true;} |
|
205 return false; |
|
206 } |
|
207 |
|
208 |
|
209 bool get_datatype_info_c::is_ANY_MAGNITUDE_compatible(symbol_c *type_symbol) { |
|
210 if (type_symbol == NULL) {return false;} |
|
211 if (is_ANY_MAGNITUDE (type_symbol)) {return true;} |
|
212 if (is_ANY_SAFEMAGNITUDE(type_symbol)) {return true;} |
|
213 return false; |
|
214 } |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 bool get_datatype_info_c::is_ANY_signed_MAGNITUDE(symbol_c *type_symbol) { |
|
223 if (type_symbol == NULL) {return false;} |
|
224 if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;} |
|
225 if (is_ANY_signed_NUM(type_symbol)) {return true;} |
|
226 return false; |
|
227 } |
|
228 |
|
229 |
|
230 bool get_datatype_info_c::is_ANY_signed_SAFEMAGNITUDE(symbol_c *type_symbol) { |
|
231 if (type_symbol == NULL) {return false;} |
|
232 if (typeid(*type_symbol) == typeid(safetime_type_name_c)) {return true;} |
|
233 return is_ANY_signed_SAFENUM(type_symbol); |
|
234 } |
|
235 |
|
236 |
|
237 bool get_datatype_info_c::is_ANY_signed_MAGNITUDE_compatible(symbol_c *type_symbol) { |
|
238 if (type_symbol == NULL) {return false;} |
|
239 if (is_ANY_signed_MAGNITUDE (type_symbol)) {return true;} |
|
240 if (is_ANY_signed_SAFEMAGNITUDE(type_symbol)) {return true;} |
|
241 return false; |
|
242 } |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 bool get_datatype_info_c::is_ANY_NUM(symbol_c *type_symbol) { |
|
251 if (type_symbol == NULL) {return false;} |
|
252 if (is_ANY_REAL(type_symbol)) {return true;} |
|
253 if (is_ANY_INT (type_symbol)) {return true;} |
|
254 return false; |
|
255 } |
|
256 |
|
257 |
|
258 bool get_datatype_info_c::is_ANY_SAFENUM(symbol_c *type_symbol) { |
|
259 if (type_symbol == NULL) {return false;} |
|
260 if (is_ANY_SAFEREAL(type_symbol)) {return true;} |
|
261 if (is_ANY_SAFEINT (type_symbol)) {return true;} |
|
262 } |
|
263 |
|
264 |
|
265 bool get_datatype_info_c::is_ANY_NUM_compatible(symbol_c *type_symbol) { |
|
266 if (type_symbol == NULL) {return false;} |
|
267 if (is_ANY_NUM (type_symbol)) {return true;} |
|
268 if (is_ANY_SAFENUM(type_symbol)) {return true;} |
|
269 return false; |
|
270 } |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 bool get_datatype_info_c::is_ANY_signed_NUM(symbol_c *type_symbol) { |
|
279 if (type_symbol == NULL) {return false;} |
|
280 if (is_ANY_REAL (type_symbol)) {return true;} |
|
281 if (is_ANY_signed_INT(type_symbol)) {return true;} |
|
282 return false; |
|
283 } |
|
284 |
|
285 |
|
286 bool get_datatype_info_c::is_ANY_signed_SAFENUM(symbol_c *type_symbol) { |
|
287 if (type_symbol == NULL) {return false;} |
|
288 if (is_ANY_SAFEREAL (type_symbol)) {return true;} |
|
289 if (is_ANY_signed_SAFEINT(type_symbol)) {return true;} |
|
290 } |
|
291 |
|
292 |
|
293 bool get_datatype_info_c::is_ANY_signed_NUM_compatible(symbol_c *type_symbol) { |
|
294 if (type_symbol == NULL) {return false;} |
|
295 if (is_ANY_signed_NUM (type_symbol)) {return true;} |
|
296 if (is_ANY_signed_SAFENUM(type_symbol)) {return true;} |
|
297 return false; |
|
298 } |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 bool get_datatype_info_c::is_ANY_DATE(symbol_c *type_symbol) { |
|
307 if (type_symbol == NULL) {return false;} |
|
308 if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;} |
|
309 if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;} |
|
310 if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;} |
|
311 return false; |
|
312 } |
|
313 |
|
314 |
|
315 bool get_datatype_info_c::is_ANY_SAFEDATE(symbol_c *type_symbol) { |
|
316 if (type_symbol == NULL) {return false;} |
|
317 if (typeid(*type_symbol) == typeid(safedate_type_name_c)) {return true;} |
|
318 if (typeid(*type_symbol) == typeid(safetod_type_name_c)) {return true;} |
|
319 if (typeid(*type_symbol) == typeid(safedt_type_name_c)) {return true;} |
|
320 return false; |
|
321 } |
|
322 |
|
323 |
|
324 bool get_datatype_info_c::is_ANY_DATE_compatible(symbol_c *type_symbol) { |
|
325 if (type_symbol == NULL) {return false;} |
|
326 if (is_ANY_DATE (type_symbol)) {return true;} |
|
327 if (is_ANY_SAFEDATE(type_symbol)) {return true;} |
|
328 return false; |
|
329 } |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 bool get_datatype_info_c::is_ANY_STRING(symbol_c *type_symbol) { |
|
338 if (type_symbol == NULL) {return false;} |
|
339 if (typeid(*type_symbol) == typeid(string_type_name_c)) {return true;} |
|
340 if (typeid(*type_symbol) == typeid(wstring_type_name_c)) {return true;} |
|
341 return false; |
|
342 } |
|
343 |
|
344 |
|
345 bool get_datatype_info_c::is_ANY_SAFESTRING(symbol_c *type_symbol) { |
|
346 if (type_symbol == NULL) {return false;} |
|
347 if (typeid(*type_symbol) == typeid(safestring_type_name_c)) {return true;} |
|
348 if (typeid(*type_symbol) == typeid(safewstring_type_name_c)) {return true;} |
|
349 return false; |
|
350 } |
|
351 |
|
352 |
|
353 bool get_datatype_info_c::is_ANY_STRING_compatible(symbol_c *type_symbol) { |
|
354 if (type_symbol == NULL) {return false;} |
|
355 if (is_ANY_STRING (type_symbol)) {return true;} |
|
356 if (is_ANY_SAFESTRING(type_symbol)) {return true;} |
|
357 return false; |
|
358 } |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 bool get_datatype_info_c::is_ANY_INT(symbol_c *type_symbol) { |
|
367 if (type_symbol == NULL) {return false;} |
|
368 if (is_ANY_signed_INT (type_symbol)) {return true;} |
|
369 if (is_ANY_unsigned_INT(type_symbol)) {return true;} |
|
370 return false; |
|
371 } |
|
372 |
|
373 |
|
374 bool get_datatype_info_c::is_ANY_SAFEINT(symbol_c *type_symbol) { |
|
375 if (type_symbol == NULL) {return false;} |
|
376 if (is_ANY_signed_SAFEINT (type_symbol)) {return true;} |
|
377 if (is_ANY_unsigned_SAFEINT(type_symbol)) {return true;} |
|
378 return false; |
|
379 } |
|
380 |
|
381 |
|
382 bool get_datatype_info_c::is_ANY_INT_compatible(symbol_c *type_symbol) { |
|
383 if (type_symbol == NULL) {return false;} |
|
384 if (is_ANY_INT (type_symbol)) {return true;} |
|
385 if (is_ANY_SAFEINT(type_symbol)) {return true;} |
|
386 return false; |
|
387 } |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 bool get_datatype_info_c::is_ANY_signed_INT(symbol_c *type_symbol) { |
|
395 if (type_symbol == NULL) {return false;} |
|
396 if (typeid(*type_symbol) == typeid(sint_type_name_c)) {return true;} |
|
397 if (typeid(*type_symbol) == typeid(int_type_name_c)) {return true;} |
|
398 if (typeid(*type_symbol) == typeid(dint_type_name_c)) {return true;} |
|
399 if (typeid(*type_symbol) == typeid(lint_type_name_c)) {return true;} |
|
400 return false; |
|
401 } |
|
402 |
|
403 |
|
404 bool get_datatype_info_c::is_ANY_signed_SAFEINT(symbol_c *type_symbol) { |
|
405 if (type_symbol == NULL) {return false;} |
|
406 if (typeid(*type_symbol) == typeid(safesint_type_name_c)) {return true;} |
|
407 if (typeid(*type_symbol) == typeid(safeint_type_name_c)) {return true;} |
|
408 if (typeid(*type_symbol) == typeid(safedint_type_name_c)) {return true;} |
|
409 if (typeid(*type_symbol) == typeid(safelint_type_name_c)) {return true;} |
|
410 return false; |
|
411 } |
|
412 |
|
413 |
|
414 bool get_datatype_info_c::is_ANY_signed_INT_compatible(symbol_c *type_symbol) { |
|
415 if (type_symbol == NULL) {return false;} |
|
416 if (is_ANY_signed_INT (type_symbol)) {return true;} |
|
417 if (is_ANY_signed_SAFEINT(type_symbol)) {return true;} |
|
418 return false; |
|
419 } |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 bool get_datatype_info_c::is_ANY_unsigned_INT(symbol_c *type_symbol) { |
|
430 if (type_symbol == NULL) {return false;} |
|
431 if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
|
432 if (typeid(*type_symbol) == typeid(uint_type_name_c)) {return true;} |
|
433 if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;} |
|
434 if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;} |
|
435 return false; |
|
436 } |
|
437 |
|
438 |
|
439 bool get_datatype_info_c::is_ANY_unsigned_SAFEINT(symbol_c *type_symbol) { |
|
440 if (type_symbol == NULL) {return false;} |
|
441 if (typeid(*type_symbol) == typeid(safeusint_type_name_c)) {return true;} |
|
442 if (typeid(*type_symbol) == typeid(safeuint_type_name_c)) {return true;} |
|
443 if (typeid(*type_symbol) == typeid(safeudint_type_name_c)) {return true;} |
|
444 if (typeid(*type_symbol) == typeid(safeulint_type_name_c)) {return true;} |
|
445 return false; |
|
446 } |
|
447 |
|
448 |
|
449 bool get_datatype_info_c::is_ANY_unsigned_INT_compatible(symbol_c *type_symbol) { |
|
450 if (type_symbol == NULL) {return false;} |
|
451 if (is_ANY_unsigned_INT (type_symbol)) {return true;} |
|
452 if (is_ANY_unsigned_SAFEINT(type_symbol)) {return true;} |
|
453 return false; |
|
454 } |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 bool get_datatype_info_c::is_ANY_REAL(symbol_c *type_symbol) { |
|
465 if (type_symbol == NULL) {return false;} |
|
466 if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
|
467 if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
|
468 return false; |
|
469 } |
|
470 |
|
471 |
|
472 bool get_datatype_info_c::is_ANY_SAFEREAL(symbol_c *type_symbol) { |
|
473 if (type_symbol == NULL) {return false;} |
|
474 if (typeid(*type_symbol) == typeid(safereal_type_name_c)) {return true;} |
|
475 if (typeid(*type_symbol) == typeid(safelreal_type_name_c)) {return true;} |
|
476 return false; |
|
477 } |
|
478 |
|
479 |
|
480 bool get_datatype_info_c::is_ANY_REAL_compatible(symbol_c *type_symbol) { |
|
481 if (type_symbol == NULL) {return false;} |
|
482 if (is_ANY_REAL (type_symbol)) {return true;} |
|
483 if (is_ANY_SAFEREAL(type_symbol)) {return true;} |
|
484 return false; |
|
485 } |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 bool get_datatype_info_c::is_ANY_nBIT(symbol_c *type_symbol) { |
|
495 if (type_symbol == NULL) {return false;} |
|
496 if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
|
497 if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
|
498 if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
|
499 if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
|
500 return false; |
|
501 } |
|
502 |
|
503 |
|
504 bool get_datatype_info_c::is_ANY_SAFEnBIT(symbol_c *type_symbol) { |
|
505 if (type_symbol == NULL) {return false;} |
|
506 if (typeid(*type_symbol) == typeid(safebyte_type_name_c)) {return true;} |
|
507 if (typeid(*type_symbol) == typeid(safeword_type_name_c)) {return true;} |
|
508 if (typeid(*type_symbol) == typeid(safedword_type_name_c)) {return true;} |
|
509 if (typeid(*type_symbol) == typeid(safelword_type_name_c)) {return true;} |
|
510 return false; |
|
511 } |
|
512 |
|
513 |
|
514 bool get_datatype_info_c::is_ANY_nBIT_compatible(symbol_c *type_symbol) { |
|
515 if (type_symbol == NULL) {return false;} |
|
516 if (is_ANY_nBIT (type_symbol)) {return true;} |
|
517 if (is_ANY_SAFEnBIT(type_symbol)) {return true;} |
|
518 return false; |
|
519 } |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 bool get_datatype_info_c::is_BOOL(symbol_c *type_symbol) { |
|
531 if (type_symbol == NULL) {return false;} |
|
532 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
|
533 return false; |
|
534 } |
|
535 |
|
536 |
|
537 bool get_datatype_info_c::is_SAFEBOOL(symbol_c *type_symbol) { |
|
538 if (type_symbol == NULL) {return false;} |
|
539 if (typeid(*type_symbol) == typeid(safebool_type_name_c)) {return true;} |
|
540 return false; |
|
541 } |
|
542 |
|
543 |
|
544 bool get_datatype_info_c::is_BOOL_compatible(symbol_c *type_symbol) { |
|
545 if (type_symbol == NULL) {return false;} |
|
546 if (is_BOOL (type_symbol)) {return true;} |
|
547 if (is_SAFEBOOL(type_symbol)) {return true;} |
|
548 return false; |
|
549 } |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 bool get_datatype_info_c::is_ANY_BIT(symbol_c *type_symbol) { |
|
560 if (type_symbol == NULL) {return false;} |
|
561 if (is_BOOL (type_symbol)) {return true;} |
|
562 if (is_ANY_nBIT(type_symbol)) {return true;} |
|
563 return false; |
|
564 } |
|
565 |
|
566 |
|
567 bool get_datatype_info_c::is_ANY_SAFEBIT(symbol_c *type_symbol) { |
|
568 if (type_symbol == NULL) {return false;} |
|
569 if (is_SAFEBOOL (type_symbol)) {return true;} |
|
570 if (is_ANY_SAFEnBIT(type_symbol)) {return true;} |
|
571 return false; |
|
572 } |
|
573 |
|
574 |
|
575 bool get_datatype_info_c::is_ANY_BIT_compatible(symbol_c *type_symbol) { |
|
576 if (type_symbol == NULL) {return false;} |
|
577 if (is_ANY_BIT (type_symbol)) {return true;} |
|
578 if (is_ANY_SAFEBIT(type_symbol)) {return true;} |
|
579 return false; |
|
580 } |
|
581 |
|
582 |
|
583 |