113 |
116 |
114 visit_expression_type_c::~visit_expression_type_c(void) { |
117 visit_expression_type_c::~visit_expression_type_c(void) { |
115 } |
118 } |
116 |
119 |
117 |
120 |
|
121 |
|
122 |
|
123 /* NOTE on data type handling and literals... |
|
124 * ========================================== |
|
125 * |
|
126 * Literals that are explicitly type cast |
|
127 * e.g.: BYTE#42 |
|
128 * INT#65 |
|
129 * TIME#45h23m |
|
130 * etc... |
|
131 * are NOT considered literals in the following code. |
|
132 * Since they are type cast, and their data type is fixed and well known, |
|
133 * they are treated as a variable of that data type (except when determining lvalues) |
|
134 * In other words, when calling search_constant_type_c on these constants, it returns |
|
135 * a xxxxx_type_name_c, and not one of the xxxx_literal_c ! |
|
136 * |
|
137 * When the following code handles a literal, it is really a literal of unknown data type. |
|
138 * e.g. 42, may be considered an int, a byte, a word, etc... |
|
139 */ |
|
140 |
118 /* A helper function... */ |
141 /* A helper function... */ |
119 bool visit_expression_type_c::is_ANY_ELEMENTARY_type(symbol_c *type_symbol) { |
142 bool visit_expression_type_c::is_ANY_ELEMENTARY_type(symbol_c *type_symbol) { |
120 if (type_symbol == NULL) {ERROR;} |
143 if (type_symbol == NULL) {ERROR;} |
121 return is_ANY_MAGNITUDE_type(type_symbol) |
144 return is_ANY_MAGNITUDE_type(type_symbol) |
122 || is_ANY_BIT_type(type_symbol) |
145 || is_ANY_BIT_type (type_symbol) |
123 || is_ANY_STRING_type(type_symbol) |
146 || is_ANY_STRING_type (type_symbol) |
124 || is_ANY_DATE_type(type_symbol); |
147 || is_ANY_DATE_type (type_symbol); |
|
148 } |
|
149 |
|
150 /* A helper function... */ |
|
151 bool visit_expression_type_c::is_ANY_SAFEELEMENTARY_type(symbol_c *type_symbol) { |
|
152 if (type_symbol == NULL) {ERROR;} |
|
153 return is_ANY_SAFEMAGNITUDE_type(type_symbol) |
|
154 || is_ANY_SAFEBIT_type (type_symbol) |
|
155 || is_ANY_SAFESTRING_type (type_symbol) |
|
156 || is_ANY_SAFEDATE_type (type_symbol); |
|
157 } |
|
158 |
|
159 /* A helper function... */ |
|
160 bool visit_expression_type_c::is_ANY_ELEMENTARY_compatible(symbol_c *type_symbol) { |
|
161 if (type_symbol == NULL) {ERROR;} |
|
162 /* NOTE: doing |
|
163 * return is_ANY_SAFEELEMENTARY_type() || is_ANY_ELEMENTARY_type() |
|
164 * is incorrect, as the literals would never be considered compatible... |
|
165 */ |
|
166 return is_ANY_MAGNITUDE_compatible(type_symbol) |
|
167 || is_ANY_BIT_compatible (type_symbol) |
|
168 || is_ANY_STRING_compatible (type_symbol) |
|
169 || is_ANY_DATE_compatible (type_symbol); |
125 } |
170 } |
126 |
171 |
127 |
172 |
128 /* A helper function... */ |
173 /* A helper function... */ |
129 bool visit_expression_type_c::is_ANY_MAGNITUDE_type(symbol_c *type_symbol) { |
174 bool visit_expression_type_c::is_ANY_MAGNITUDE_type(symbol_c *type_symbol) { |
130 if (type_symbol == NULL) {ERROR;} |
175 if (type_symbol == NULL) {ERROR;} |
131 if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;} |
176 if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;} |
132 return is_ANY_NUM_type(type_symbol); |
177 return is_ANY_NUM_type(type_symbol); |
133 } |
178 } |
134 |
179 |
|
180 /* A helper function... */ |
|
181 bool visit_expression_type_c::is_ANY_SAFEMAGNITUDE_type(symbol_c *type_symbol) { |
|
182 if (type_symbol == NULL) {ERROR;} |
|
183 if (typeid(*type_symbol) == typeid(safetime_type_name_c)) {return true;} |
|
184 return is_ANY_SAFENUM_type(type_symbol); |
|
185 } |
|
186 |
|
187 /* A helper function... */ |
|
188 bool visit_expression_type_c::is_ANY_MAGNITUDE_compatible(symbol_c *type_symbol) { |
|
189 if (type_symbol == NULL) {ERROR;} |
|
190 if (is_ANY_MAGNITUDE_type (type_symbol)) {return true;} |
|
191 if (is_ANY_SAFEMAGNITUDE_type(type_symbol)) {return true;} |
|
192 |
|
193 return is_ANY_NUM_compatible(type_symbol); |
|
194 } |
135 |
195 |
136 /* A helper function... */ |
196 /* A helper function... */ |
137 bool visit_expression_type_c::is_ANY_NUM_type(symbol_c *type_symbol) { |
197 bool visit_expression_type_c::is_ANY_NUM_type(symbol_c *type_symbol) { |
138 if (type_symbol == NULL) {ERROR;} |
198 if (type_symbol == NULL) {ERROR;} |
139 return is_ANY_REAL_type(type_symbol) || is_ANY_INT_type(type_symbol); |
199 if (is_ANY_REAL_type(type_symbol)) {return true;} |
140 } |
200 if (is_ANY_INT_type(type_symbol)) {return true;} |
141 |
201 return false; |
|
202 } |
|
203 |
|
204 /* A helper function... */ |
|
205 bool visit_expression_type_c::is_ANY_SAFENUM_type(symbol_c *type_symbol) { |
|
206 if (type_symbol == NULL) {ERROR;} |
|
207 return is_ANY_SAFEREAL_type(type_symbol) |
|
208 || is_ANY_SAFEINT_type (type_symbol); |
|
209 } |
|
210 |
|
211 /* A helper function... */ |
|
212 bool visit_expression_type_c::is_ANY_NUM_compatible(symbol_c *type_symbol) { |
|
213 if (type_symbol == NULL) {ERROR;} |
|
214 if (is_ANY_REAL_compatible(type_symbol)) {return true;} |
|
215 if (is_ANY_INT_compatible(type_symbol)) {return true;} |
|
216 return false; |
|
217 } |
142 |
218 |
143 /* A helper function... */ |
219 /* A helper function... */ |
144 bool visit_expression_type_c::is_ANY_DATE_type(symbol_c *type_symbol) { |
220 bool visit_expression_type_c::is_ANY_DATE_type(symbol_c *type_symbol) { |
145 if (type_symbol == NULL) {ERROR;} |
221 if (type_symbol == NULL) {ERROR;} |
146 if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;} |
222 if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;} |
147 if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;} |
223 if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;} |
148 if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;} |
224 if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;} |
149 return false; |
225 return false; |
150 } |
226 } |
151 |
227 |
|
228 /* A helper function... */ |
|
229 bool visit_expression_type_c::is_ANY_SAFEDATE_type(symbol_c *type_symbol) { |
|
230 if (type_symbol == NULL) {ERROR;} |
|
231 if (typeid(*type_symbol) == typeid(safedate_type_name_c)) {return true;} |
|
232 if (typeid(*type_symbol) == typeid(safetod_type_name_c)) {return true;} |
|
233 if (typeid(*type_symbol) == typeid(safedt_type_name_c)) {return true;} |
|
234 return false; |
|
235 } |
|
236 |
|
237 /* A helper function... */ |
|
238 bool visit_expression_type_c::is_ANY_DATE_compatible(symbol_c *type_symbol) { |
|
239 if (type_symbol == NULL) {ERROR;} |
|
240 if (is_ANY_DATE_type (type_symbol)) {return true;} |
|
241 if (is_ANY_SAFEDATE_type(type_symbol)) {return true;} |
|
242 return false; |
|
243 } |
152 |
244 |
153 /* A helper function... */ |
245 /* A helper function... */ |
154 bool visit_expression_type_c::is_ANY_STRING_type(symbol_c *type_symbol) { |
246 bool visit_expression_type_c::is_ANY_STRING_type(symbol_c *type_symbol) { |
155 if (type_symbol == NULL) {ERROR;} |
247 if (type_symbol == NULL) {ERROR;} |
156 if (typeid(*type_symbol) == typeid(string_type_name_c)) {return true;} |
248 if (typeid(*type_symbol) == typeid(string_type_name_c)) {return true;} |
157 if (typeid(*type_symbol) == typeid(wstring_type_name_c)) {return true;} |
249 if (typeid(*type_symbol) == typeid(wstring_type_name_c)) {return true;} |
|
250 // TODO literal_string ??? |
158 return false; |
251 return false; |
159 } |
252 } |
160 |
253 |
|
254 /* A helper function... */ |
|
255 bool visit_expression_type_c::is_ANY_SAFESTRING_type(symbol_c *type_symbol) { |
|
256 if (type_symbol == NULL) {ERROR;} |
|
257 if (typeid(*type_symbol) == typeid(safestring_type_name_c)) {return true;} |
|
258 if (typeid(*type_symbol) == typeid(safewstring_type_name_c)) {return true;} |
|
259 return false; |
|
260 } |
|
261 |
|
262 /* A helper function... */ |
|
263 bool visit_expression_type_c::is_ANY_STRING_compatible(symbol_c *type_symbol) { |
|
264 if (type_symbol == NULL) {ERROR;} |
|
265 if (is_ANY_STRING_type (type_symbol)) {return true;} |
|
266 if (is_ANY_SAFESTRING_type(type_symbol)) {return true;} |
|
267 return false; |
|
268 } |
161 |
269 |
162 /* A helper function... */ |
270 /* A helper function... */ |
163 bool visit_expression_type_c::is_ANY_INT_type(symbol_c *type_symbol) { |
271 bool visit_expression_type_c::is_ANY_INT_type(symbol_c *type_symbol) { |
164 if (type_symbol == NULL) {ERROR;} |
272 if (type_symbol == NULL) {ERROR;} |
165 if (typeid(*type_symbol) == typeid(sint_type_name_c)) {return true;} |
273 if (typeid(*type_symbol) == typeid(sint_type_name_c)) {return true;} |
168 if (typeid(*type_symbol) == typeid(lint_type_name_c)) {return true;} |
276 if (typeid(*type_symbol) == typeid(lint_type_name_c)) {return true;} |
169 if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
277 if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
170 if (typeid(*type_symbol) == typeid(uint_type_name_c)) {return true;} |
278 if (typeid(*type_symbol) == typeid(uint_type_name_c)) {return true;} |
171 if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;} |
279 if (typeid(*type_symbol) == typeid(udint_type_name_c)) {return true;} |
172 if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;} |
280 if (typeid(*type_symbol) == typeid(ulint_type_name_c)) {return true;} |
173 if (is_literal_integer_type(type_symbol)) {return true;} |
|
174 return false; |
281 return false; |
175 } |
282 } |
176 |
283 |
|
284 /* A helper function... */ |
|
285 bool visit_expression_type_c::is_ANY_SAFEINT_type(symbol_c *type_symbol) { |
|
286 if (type_symbol == NULL) {ERROR;} |
|
287 if (typeid(*type_symbol) == typeid(safesint_type_name_c)) {return true;} |
|
288 if (typeid(*type_symbol) == typeid(safeint_type_name_c)) {return true;} |
|
289 if (typeid(*type_symbol) == typeid(safedint_type_name_c)) {return true;} |
|
290 if (typeid(*type_symbol) == typeid(safelint_type_name_c)) {return true;} |
|
291 if (typeid(*type_symbol) == typeid(safeusint_type_name_c)) {return true;} |
|
292 if (typeid(*type_symbol) == typeid(safeuint_type_name_c)) {return true;} |
|
293 if (typeid(*type_symbol) == typeid(safeudint_type_name_c)) {return true;} |
|
294 if (typeid(*type_symbol) == typeid(safeulint_type_name_c)) {return true;} |
|
295 return false; |
|
296 } |
|
297 |
|
298 /* A helper function... */ |
|
299 bool visit_expression_type_c::is_ANY_INT_compatible(symbol_c *type_symbol) { |
|
300 if (type_symbol == NULL) {ERROR;} |
|
301 if (is_ANY_INT_type (type_symbol)) {return true;} |
|
302 if (is_ANY_SAFEINT_type(type_symbol)) {return true;} |
|
303 if (is_literal_integer_type(type_symbol)) {return true;} |
|
304 return false; |
|
305 } |
177 |
306 |
178 /* A helper function... */ |
307 /* A helper function... */ |
179 bool visit_expression_type_c::is_ANY_REAL_type(symbol_c *type_symbol) { |
308 bool visit_expression_type_c::is_ANY_REAL_type(symbol_c *type_symbol) { |
180 if (type_symbol == NULL) {ERROR;} |
309 if (type_symbol == NULL) {ERROR;} |
181 if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
310 if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
182 if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
311 if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
183 if (is_literal_real_type(type_symbol)) {return true;} |
|
184 return false; |
312 return false; |
185 } |
313 } |
186 |
314 |
|
315 /* A helper function... */ |
|
316 bool visit_expression_type_c::is_ANY_SAFEREAL_type(symbol_c *type_symbol) { |
|
317 if (type_symbol == NULL) {ERROR;} |
|
318 if (typeid(*type_symbol) == typeid(safereal_type_name_c)) {return true;} |
|
319 if (typeid(*type_symbol) == typeid(safelreal_type_name_c)) {return true;} |
|
320 return false; |
|
321 } |
|
322 |
|
323 /* A helper function... */ |
|
324 bool visit_expression_type_c::is_ANY_REAL_compatible(symbol_c *type_symbol) { |
|
325 if (type_symbol == NULL) {ERROR;} |
|
326 if (is_ANY_REAL_type (type_symbol)) {return true;} |
|
327 if (is_ANY_SAFEREAL_type(type_symbol)) {return true;} |
|
328 if (is_literal_real_type(type_symbol)) {return true;} |
|
329 return false; |
|
330 } |
187 |
331 |
188 /* A helper function... */ |
332 /* A helper function... */ |
189 bool visit_expression_type_c::is_ANY_BIT_type(symbol_c *type_symbol) { |
333 bool visit_expression_type_c::is_ANY_BIT_type(symbol_c *type_symbol) { |
190 if (type_symbol == NULL) {ERROR;} |
334 if (type_symbol == NULL) {ERROR;} |
191 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
335 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
192 if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
336 if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
193 if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
337 if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
194 if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
338 if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
195 if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
339 if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
196 if (is_literal_integer_type(type_symbol)) {return true;} |
|
197 return false; |
340 return false; |
198 } |
341 } |
199 |
342 |
|
343 /* A helper function... */ |
|
344 bool visit_expression_type_c::is_ANY_SAFEBIT_type(symbol_c *type_symbol) { |
|
345 if (type_symbol == NULL) {ERROR;} |
|
346 if (typeid(*type_symbol) == typeid(safebool_type_name_c)) {return true;} |
|
347 if (typeid(*type_symbol) == typeid(safebyte_type_name_c)) {return true;} |
|
348 if (typeid(*type_symbol) == typeid(safeword_type_name_c)) {return true;} |
|
349 if (typeid(*type_symbol) == typeid(safedword_type_name_c)) {return true;} |
|
350 if (typeid(*type_symbol) == typeid(safelword_type_name_c)) {return true;} |
|
351 return false; |
|
352 } |
|
353 |
|
354 /* A helper function... */ |
|
355 bool visit_expression_type_c::is_ANY_BIT_compatible(symbol_c *type_symbol) { |
|
356 if (type_symbol == NULL) {ERROR;} |
|
357 if (is_ANY_BIT_type (type_symbol)) {return true;} |
|
358 if (is_ANY_SAFEBIT_type(type_symbol)) {return true;} |
|
359 if (is_nonneg_literal_integer_type(type_symbol)) {return true;} |
|
360 if (is_literal_bool_type(type_symbol)) {return true;} |
|
361 return false; |
|
362 } |
200 |
363 |
201 /* A helper function... */ |
364 /* A helper function... */ |
202 bool visit_expression_type_c::is_BOOL_type(symbol_c *type_symbol) { |
365 bool visit_expression_type_c::is_BOOL_type(symbol_c *type_symbol) { |
203 if (type_symbol == NULL) {ERROR;} |
366 if (type_symbol == NULL) {ERROR;} |
204 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
367 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
205 if (is_literal_bool_type(type_symbol)) {return true;} |
|
206 return false; |
368 return false; |
207 } |
369 } |
208 |
370 |
|
371 /* A helper function... */ |
|
372 bool visit_expression_type_c::is_SAFEBOOL_type(symbol_c *type_symbol){ |
|
373 if (type_symbol == NULL) {ERROR;} |
|
374 if (typeid(*type_symbol) == typeid(safebool_type_name_c)) {return true;} |
|
375 return false; |
|
376 } |
|
377 |
|
378 /* A helper function... */ |
|
379 bool visit_expression_type_c::is_ANY_BOOL_compatible(symbol_c *type_symbol) { |
|
380 if (type_symbol == NULL) {ERROR;} |
|
381 if (is_BOOL_type (type_symbol)) {return true;} |
|
382 if (is_SAFEBOOL_type(type_symbol)) {return true;} |
|
383 if (is_literal_bool_type(type_symbol)) {return true;} |
|
384 return false; |
|
385 } |
|
386 |
|
387 |
|
388 #define is_type(type_name_symbol, type_name_class) (typeid(*type_name_symbol) == typeid(type_name_class)) |
|
389 |
209 |
390 |
210 #define sizeoftype(symbol) get_sizeof_datatype_c::getsize(symbol) |
391 #define sizeoftype(symbol) get_sizeof_datatype_c::getsize(symbol) |
211 |
392 |
212 |
393 |
213 /* A helper function... */ |
394 /* A helper function... */ |
214 bool visit_expression_type_c::is_literal_integer_type(symbol_c *type_symbol) { |
395 bool visit_expression_type_c::is_literal_integer_type(symbol_c *type_symbol) { |
215 if (type_symbol == NULL) {return true;} |
396 if (type_symbol == NULL) {ERROR;} |
|
397 if (typeid(*type_symbol) == typeid(neg_integer_c)) {return true;} |
|
398 return is_nonneg_literal_integer_type(type_symbol); |
|
399 } |
|
400 |
|
401 |
|
402 /* A helper function... */ |
|
403 bool visit_expression_type_c::is_nonneg_literal_integer_type(symbol_c *type_symbol) { |
|
404 if (type_symbol == NULL) {ERROR;} |
216 if (typeid(*type_symbol) == typeid(integer_c)) {return true;} |
405 if (typeid(*type_symbol) == typeid(integer_c)) {return true;} |
217 if (typeid(*type_symbol) == typeid(binary_integer_c)) {return true;} |
406 if (typeid(*type_symbol) == typeid(binary_integer_c)) {return true;} |
218 if (typeid(*type_symbol) == typeid(octal_integer_c)) {return true;} |
407 if (typeid(*type_symbol) == typeid(octal_integer_c)) {return true;} |
219 if (typeid(*type_symbol) == typeid(hex_integer_c)) {return true;} |
408 if (typeid(*type_symbol) == typeid(hex_integer_c)) {return true;} |
220 return false; |
409 return false; |
221 } |
410 } |
222 |
411 |
223 |
412 |
224 /* A helper function... */ |
413 /* A helper function... */ |
225 bool visit_expression_type_c::is_literal_real_type(symbol_c *type_symbol) { |
414 bool visit_expression_type_c::is_literal_real_type(symbol_c *type_symbol) { |
226 if (type_symbol == NULL) {return true;} |
415 if (type_symbol == NULL) {ERROR;} |
227 if (typeid(*type_symbol) == typeid(real_c)) {return true;} |
416 if (typeid(*type_symbol) == typeid(real_c)) {return true;} |
|
417 if (typeid(*type_symbol) == typeid(neg_real_c)) {return true;} |
228 return false; |
418 return false; |
229 } |
419 } |
230 |
420 |
231 |
421 |
232 /* A helper function... */ |
422 /* A helper function... */ |
233 bool visit_expression_type_c::is_literal_bool_type(symbol_c *type_symbol) { |
423 bool visit_expression_type_c::is_literal_bool_type(symbol_c *type_symbol) { |
234 bool_type_name_c bool_t; |
424 bool_type_name_c bool_t; |
235 |
425 |
236 if (type_symbol == NULL) {return true;} |
426 if (type_symbol == NULL) {ERROR;} |
237 if (typeid(*type_symbol) == typeid(boolean_true_c)) {return true;} |
427 if (typeid(*type_symbol) == typeid(boolean_true_c)) {return true;} |
238 if (typeid(*type_symbol) == typeid(boolean_false_c)) {return true;} |
428 if (typeid(*type_symbol) == typeid(boolean_false_c)) {return true;} |
239 if (is_literal_integer_type(type_symbol)) |
429 if (is_nonneg_literal_integer_type(type_symbol)) |
240 if (sizeoftype(&bool_t) >= sizeoftype(type_symbol)) {return true;} |
430 if (sizeoftype(&bool_t) >= sizeoftype(type_symbol)) {return true;} |
241 return false; |
431 return false; |
242 } |
432 } |
243 |
|
244 |
433 |
245 /* Determine the common data type between two data types. |
434 /* Determine the common data type between two data types. |
246 * If no common data type found, return NULL. |
435 * If no common data type found, return NULL. |
247 * |
436 * |
248 * If data types are identical, return the first (actually any would do...). |
437 * If data types are identical, return the first (actually any would do...). |
265 {return ((sizeoftype(first_type) > sizeoftype(second_type))? first_type:second_type);} |
455 {return ((sizeoftype(first_type) > sizeoftype(second_type))? first_type:second_type);} |
266 |
456 |
267 if (is_literal_bool_type(first_type) && is_literal_bool_type(second_type)) |
457 if (is_literal_bool_type(first_type) && is_literal_bool_type(second_type)) |
268 {return first_type;} |
458 {return first_type;} |
269 |
459 |
270 /* This check can only be made after the is_literal_XXXX checks */ |
460 /* The following check can only be made after the is_literal_XXXX checks */ |
271 /* When two literals of the same type, with identical typeid's are checked, |
461 /* When two literals of the same type, with identical typeid's are checked, |
272 * we must return the one that occupies more bits... |
462 * we must return the one that occupies more bits... This is done above. |
273 */ |
463 */ |
274 if (typeid(*first_type) == typeid(*second_type)) {return first_type;} |
464 if (typeid(*first_type) == typeid(*second_type)) {return first_type;} |
275 |
465 |
276 if (is_BOOL_type(first_type) && is_literal_bool_type(second_type)) {return first_type;} |
466 /* NOTE Although a BOOL is also an ANY_BIT, we must check it explicitly since some |
277 if (is_BOOL_type(second_type) && is_literal_bool_type(first_type)) {return second_type;} |
467 * literal bool values are not literal integers... |
278 |
468 */ |
279 if (is_ANY_BIT_type(first_type) && is_literal_integer_type(second_type)) |
469 if (is_BOOL_type(first_type) && is_literal_bool_type(second_type)) {return first_type;} |
|
470 if (is_BOOL_type(second_type) && is_literal_bool_type(first_type)) {return second_type;} |
|
471 |
|
472 if (is_SAFEBOOL_type(first_type) && is_literal_bool_type(second_type)) {return first_type;} |
|
473 if (is_SAFEBOOL_type(second_type) && is_literal_bool_type(first_type)) {return second_type;} |
|
474 |
|
475 if (is_SAFEBOOL_type(first_type) && is_BOOL_type(second_type)) {return second_type;} |
|
476 if (is_SAFEBOOL_type(second_type) && is_BOOL_type(first_type)) {return first_type;} |
|
477 |
|
478 if (is_ANY_BIT_type(first_type) && is_nonneg_literal_integer_type(second_type)) |
280 {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);} |
479 {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);} |
281 if (is_ANY_BIT_type(second_type) && is_literal_integer_type(first_type)) |
480 if (is_ANY_BIT_type(second_type) && is_nonneg_literal_integer_type(first_type)) |
282 {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);} |
481 {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);} |
283 |
482 |
284 if (is_ANY_INT_type(first_type) && is_literal_integer_type(second_type)) |
483 if (is_ANY_SAFEBIT_type(first_type) && is_nonneg_literal_integer_type(second_type)) |
285 {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);} |
484 {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);} |
286 if (is_ANY_INT_type(second_type) && is_literal_integer_type(first_type)) |
485 if (is_ANY_SAFEBIT_type(second_type) && is_nonneg_literal_integer_type(first_type)) |
287 {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);} |
486 {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);} |
288 |
487 |
289 if (is_ANY_REAL_type(first_type) && is_literal_real_type(second_type)) |
488 if (is_ANY_SAFEBIT_type(first_type) && is_ANY_BIT_type(second_type)) |
|
489 {return ((sizeoftype(first_type) == sizeoftype(second_type))? second_type:NULL);} |
|
490 if (is_ANY_SAFEBIT_type(second_type) && is_ANY_BIT_type(first_type)) |
|
491 {return ((sizeoftype(first_type) == sizeoftype(second_type))? first_type :NULL);} |
|
492 |
|
493 if (is_ANY_INT_type(first_type) && is_literal_integer_type(second_type)) |
290 {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);} |
494 {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);} |
291 if (is_ANY_REAL_type(second_type) && is_literal_real_type(first_type)) |
495 if (is_ANY_INT_type(second_type) && is_literal_integer_type(first_type)) |
292 {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);} |
496 {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);} |
|
497 |
|
498 if (is_ANY_SAFEINT_type(first_type) && is_literal_integer_type(second_type)) |
|
499 {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);} |
|
500 if (is_ANY_SAFEINT_type(second_type) && is_literal_integer_type(first_type)) |
|
501 {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);} |
|
502 |
|
503 if (is_ANY_SAFEINT_type(first_type) && is_ANY_INT_type(second_type)) |
|
504 {return ((sizeoftype(first_type) == sizeoftype(second_type))? second_type:NULL);} |
|
505 if (is_ANY_SAFEINT_type(second_type) && is_ANY_INT_type(first_type)) |
|
506 {return ((sizeoftype(first_type) == sizeoftype(second_type))? first_type :NULL);} |
|
507 |
|
508 if (is_ANY_REAL_type(first_type) && is_literal_real_type(second_type)) |
|
509 {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);} |
|
510 if (is_ANY_REAL_type(second_type) && is_literal_real_type(first_type)) |
|
511 {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);} |
|
512 |
|
513 if (is_ANY_SAFEREAL_type(first_type) && is_literal_real_type(second_type)) |
|
514 {return ((sizeoftype(first_type) >= sizeoftype(second_type))? first_type :NULL);} |
|
515 if (is_ANY_SAFEREAL_type(second_type) && is_literal_real_type(first_type)) |
|
516 {return ((sizeoftype(second_type) >= sizeoftype(first_type)) ? second_type:NULL);} |
|
517 |
|
518 if (is_ANY_SAFEREAL_type(first_type) && is_ANY_REAL_type(second_type)) |
|
519 {return ((sizeoftype(first_type) == sizeoftype(second_type))? second_type:NULL);} |
|
520 if (is_ANY_SAFEREAL_type(second_type) && is_ANY_REAL_type(first_type)) |
|
521 {return ((sizeoftype(first_type) == sizeoftype(second_type))? first_type :NULL);} |
|
522 |
|
523 /* the Time and Date types... */ |
|
524 if (is_type(first_type, safetime_type_name_c) && is_type(second_type, time_type_name_c)) {return second_type;} |
|
525 if (is_type(second_type, safetime_type_name_c) && is_type( first_type, time_type_name_c)) {return first_type;} |
|
526 |
|
527 if (is_type(first_type, safedate_type_name_c) && is_type(second_type, date_type_name_c)) {return second_type;} |
|
528 if (is_type(second_type, safedate_type_name_c) && is_type( first_type, date_type_name_c)) {return first_type;} |
|
529 |
|
530 if (is_type(first_type, safedt_type_name_c) && is_type(second_type, dt_type_name_c)) {return second_type;} |
|
531 if (is_type(second_type, safedt_type_name_c) && is_type( first_type, dt_type_name_c)) {return first_type;} |
|
532 |
|
533 if (is_type(first_type, safetod_type_name_c) && is_type(second_type, tod_type_name_c)) {return second_type;} |
|
534 if (is_type(second_type, safetod_type_name_c) && is_type( first_type, tod_type_name_c)) {return first_type;} |
293 |
535 |
294 /* no common type */ |
536 /* no common type */ |
295 return NULL; |
537 return NULL; |
296 } |
538 } |
297 |
539 |
1052 } |
1353 } |
1053 |
1354 |
1054 //SYM_REF0(AND_operator_c) |
1355 //SYM_REF0(AND_operator_c) |
1055 void *visit_expression_type_c::visit(AND_operator_c *symbol) { |
1356 void *visit_expression_type_c::visit(AND_operator_c *symbol) { |
1056 verify_null(symbol); |
1357 verify_null(symbol); |
1057 il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type); |
1358 il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible); |
1058 return NULL; |
1359 return NULL; |
1059 } |
1360 } |
1060 |
1361 |
1061 //SYM_REF0(OR_operator_c) |
1362 //SYM_REF0(OR_operator_c) |
1062 void *visit_expression_type_c::visit(OR_operator_c *symbol) { |
1363 void *visit_expression_type_c::visit(OR_operator_c *symbol) { |
1063 verify_null(symbol); |
1364 verify_null(symbol); |
1064 il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type); |
1365 il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible); |
1065 return NULL; |
1366 return NULL; |
1066 } |
1367 } |
1067 |
1368 |
1068 //SYM_REF0(XOR_operator_c) |
1369 //SYM_REF0(XOR_operator_c) |
1069 void *visit_expression_type_c::visit(XOR_operator_c *symbol) { |
1370 void *visit_expression_type_c::visit(XOR_operator_c *symbol) { |
1070 verify_null(symbol); |
1371 verify_null(symbol); |
1071 il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type); |
1372 il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible); |
1072 return NULL; |
1373 return NULL; |
1073 } |
1374 } |
1074 |
1375 |
1075 // SYM_REF0(ANDN_operator_c) |
1376 // SYM_REF0(ANDN_operator_c) |
1076 void *visit_expression_type_c::visit(ANDN_operator_c *symbol) { |
1377 void *visit_expression_type_c::visit(ANDN_operator_c *symbol) { |
1077 verify_null(symbol); |
1378 verify_null(symbol); |
1078 il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type); |
1379 il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible); |
1079 return NULL; |
1380 return NULL; |
1080 } |
1381 } |
1081 |
1382 |
1082 // SYM_REF0(ORN_operator_c) |
1383 // SYM_REF0(ORN_operator_c) |
1083 void *visit_expression_type_c::visit(ORN_operator_c *symbol) { |
1384 void *visit_expression_type_c::visit(ORN_operator_c *symbol) { |
1084 verify_null(symbol); |
1385 verify_null(symbol); |
1085 il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type); |
1386 il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible); |
1086 return NULL; |
1387 return NULL; |
1087 } |
1388 } |
1088 |
1389 |
1089 // SYM_REF0(XORN_operator_c) |
1390 // SYM_REF0(XORN_operator_c) |
1090 void *visit_expression_type_c::visit(XORN_operator_c *symbol) { |
1391 void *visit_expression_type_c::visit(XORN_operator_c *symbol) { |
1091 verify_null(symbol); |
1392 verify_null(symbol); |
1092 il_default_variable_type = compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_type); |
1393 il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_BIT_compatible); |
1093 return NULL; |
1394 return NULL; |
1094 } |
1395 } |
1095 |
1396 |
1096 // SYM_REF0(ADD_operator_c) |
1397 // SYM_REF0(ADD_operator_c) |
1097 void *visit_expression_type_c::visit(ADD_operator_c *symbol) { |
1398 void *visit_expression_type_c::visit(ADD_operator_c *symbol) { |
1098 verify_null(symbol); |
1399 verify_null(symbol); |
1099 symbol_c *left_type = il_default_variable_type; |
1400 symbol_c *left_type = il_default_variable_type; |
1100 symbol_c *right_type = il_operand_type; |
1401 symbol_c *right_type = il_operand_type; |
1101 if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) |
1402 |
|
1403 /* The following is not required, it is already handled by compute_expression() ... */ |
|
1404 /* |
|
1405 if (is_type(left_type, time_type_name_c) && is_type(right_type, time_type_name_c)) |
1102 il_default_variable_type = &time_type_name; |
1406 il_default_variable_type = &time_type_name; |
1103 else if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) |
1407 */ |
|
1408 |
|
1409 if (is_type(left_type, tod_type_name_c) && is_type(right_type, time_type_name_c)) |
1104 il_default_variable_type = &tod_type_name; |
1410 il_default_variable_type = &tod_type_name; |
1105 else if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) |
1411 else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1412 il_default_variable_type = &tod_type_name; |
|
1413 else if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1414 il_default_variable_type = &tod_type_name; |
|
1415 else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1416 il_default_variable_type = &safetod_type_name; |
|
1417 |
|
1418 else if (is_type(left_type, dt_type_name_c) && is_type(right_type, time_type_name_c)) |
1106 il_default_variable_type = &dt_type_name; |
1419 il_default_variable_type = &dt_type_name; |
1107 else il_default_variable_type = compute_numeric_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_MAGNITUDE_type); |
1420 else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1421 il_default_variable_type = &dt_type_name; |
|
1422 else if (is_type(left_type, dt_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1423 il_default_variable_type = &dt_type_name; |
|
1424 else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1425 il_default_variable_type = &safedt_type_name; |
|
1426 |
|
1427 else il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_MAGNITUDE_compatible); |
1108 return NULL; |
1428 return NULL; |
1109 } |
1429 } |
1110 |
1430 |
1111 // SYM_REF0(SUB_operator_c) |
1431 // SYM_REF0(SUB_operator_c) |
1112 void *visit_expression_type_c::visit(SUB_operator_c *symbol) { |
1432 void *visit_expression_type_c::visit(SUB_operator_c *symbol) { |
1113 verify_null(symbol); |
1433 verify_null(symbol); |
1114 symbol_c *left_type = il_default_variable_type; |
1434 symbol_c *left_type = il_default_variable_type; |
1115 symbol_c *right_type = il_operand_type;; |
1435 symbol_c *right_type = il_operand_type;; |
|
1436 |
|
1437 /* The following is not required, it is already handled by compute_expression() ... */ |
|
1438 /* |
1116 if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) |
1439 if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) |
1117 il_default_variable_type = &time_type_name; |
1440 il_default_variable_type = &time_type_name; |
1118 else if (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) |
1441 */ |
|
1442 |
|
1443 if (is_type(left_type, tod_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1444 il_default_variable_type = &tod_type_name; |
|
1445 else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1446 il_default_variable_type = &tod_type_name; |
|
1447 else if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1448 il_default_variable_type = &tod_type_name; |
|
1449 else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1450 il_default_variable_type = &safetod_type_name; |
|
1451 |
|
1452 else if (is_type(left_type, dt_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1453 il_default_variable_type = &dt_type_name; |
|
1454 else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1455 il_default_variable_type = &dt_type_name; |
|
1456 else if (is_type(left_type, dt_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1457 il_default_variable_type = &dt_type_name; |
|
1458 else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1459 il_default_variable_type = &safedt_type_name; |
|
1460 |
|
1461 else if (is_type(left_type, date_type_name_c) && is_type(right_type, date_type_name_c)) |
1119 il_default_variable_type = &time_type_name; |
1462 il_default_variable_type = &time_type_name; |
1120 else if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) |
1463 else if (is_type(left_type, safedate_type_name_c) && is_type(right_type, date_type_name_c)) |
1121 il_default_variable_type = &tod_type_name; |
|
1122 else if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) |
|
1123 il_default_variable_type = &time_type_name; |
1464 il_default_variable_type = &time_type_name; |
1124 else if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) |
1465 else if (is_type(left_type, date_type_name_c) && is_type(right_type, safedate_type_name_c)) |
1125 il_default_variable_type = &dt_type_name; |
|
1126 else if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(dt_type_name_c)) |
|
1127 il_default_variable_type = &time_type_name; |
1466 il_default_variable_type = &time_type_name; |
1128 else il_default_variable_type = compute_numeric_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_MAGNITUDE_type); |
1467 else if (is_type(left_type, safedate_type_name_c) && is_type(right_type, safedate_type_name_c)) |
|
1468 il_default_variable_type = &safetime_type_name; |
|
1469 |
|
1470 else if (is_type(left_type, tod_type_name_c) && is_type(right_type, tod_type_name_c)) |
|
1471 il_default_variable_type = &time_type_name; |
|
1472 else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, tod_type_name_c)) |
|
1473 il_default_variable_type = &time_type_name; |
|
1474 else if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetod_type_name_c)) |
|
1475 il_default_variable_type = &time_type_name; |
|
1476 else if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetod_type_name_c)) |
|
1477 il_default_variable_type = &safetime_type_name; |
|
1478 |
|
1479 else if (is_type(left_type, dt_type_name_c) && is_type(right_type, dt_type_name_c)) |
|
1480 il_default_variable_type = &time_type_name; |
|
1481 else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, dt_type_name_c)) |
|
1482 il_default_variable_type = &time_type_name; |
|
1483 else if (is_type(left_type, dt_type_name_c) && is_type(right_type, safedt_type_name_c)) |
|
1484 il_default_variable_type = &time_type_name; |
|
1485 else if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safedt_type_name_c)) |
|
1486 il_default_variable_type = &safetime_type_name; |
|
1487 |
|
1488 else il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_MAGNITUDE_compatible); |
1129 return NULL; |
1489 return NULL; |
1130 } |
1490 } |
1131 |
1491 |
1132 // SYM_REF0(MUL_operator_c) |
1492 // SYM_REF0(MUL_operator_c) |
1133 void *visit_expression_type_c::visit(MUL_operator_c *symbol) { |
1493 void *visit_expression_type_c::visit(MUL_operator_c *symbol) { |
1134 verify_null(symbol); |
1494 verify_null(symbol); |
1135 symbol_c *left_type = il_default_variable_type; |
1495 symbol_c *left_type = il_default_variable_type; |
1136 symbol_c *right_type = il_operand_type; |
1496 symbol_c *right_type = il_operand_type; |
1137 if (typeid(*left_type) == typeid(time_type_name_c) && is_ANY_NUM_type(right_type)) |
1497 |
|
1498 if (is_type(left_type, time_type_name_c) && is_ANY_NUM_compatible(right_type)) |
1138 il_default_variable_type = &time_type_name; |
1499 il_default_variable_type = &time_type_name; |
1139 else il_default_variable_type = compute_numeric_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_NUM_type); |
1500 else if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_type(right_type)) |
|
1501 il_default_variable_type = &time_type_name; |
|
1502 else if (is_type(left_type, safetime_type_name_c) && is_ANY_SAFENUM_type(right_type)) |
|
1503 il_default_variable_type = &safetime_type_name; |
|
1504 /* Since we have already checked for ANY_NUM_type and ANY_SAFENUM_type in the previous lines, |
|
1505 * this next line is really only to check for integers/reals of undefined type on 'right_type'... |
|
1506 */ |
|
1507 else if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_compatible(right_type)) |
|
1508 il_default_variable_type = &safetime_type_name; |
|
1509 |
|
1510 else il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_NUM_compatible); |
1140 return NULL; |
1511 return NULL; |
1141 } |
1512 } |
1142 |
1513 |
1143 // SYM_REF0(DIV_operator_c) |
1514 // SYM_REF0(DIV_operator_c) |
1144 void *visit_expression_type_c::visit(DIV_operator_c *symbol) { |
1515 void *visit_expression_type_c::visit(DIV_operator_c *symbol) { |
1145 verify_null(symbol); |
1516 verify_null(symbol); |
1146 symbol_c *left_type = il_default_variable_type; |
1517 symbol_c *left_type = il_default_variable_type; |
1147 symbol_c *right_type = il_operand_type; |
1518 symbol_c *right_type = il_operand_type; |
1148 if (typeid(*left_type) == typeid(time_type_name_c) && is_ANY_NUM_type(right_type)) |
1519 |
|
1520 if (is_type(left_type, time_type_name_c) && is_ANY_NUM_compatible(right_type)) |
1149 il_default_variable_type = &time_type_name; |
1521 il_default_variable_type = &time_type_name; |
1150 else il_default_variable_type = compute_numeric_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_NUM_type); |
1522 else if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_type(right_type)) |
|
1523 il_default_variable_type = &time_type_name; |
|
1524 else if (is_type(left_type, safetime_type_name_c) && is_ANY_SAFENUM_type(right_type)) |
|
1525 il_default_variable_type = &safetime_type_name; |
|
1526 /* Since we have already checked for ANY_NUM_type and ANY_SAFENUM_type in the previous lines, |
|
1527 * this next line is really only to check for integers/reals of undefined type on 'right_type'... |
|
1528 */ |
|
1529 else if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_compatible(right_type)) |
|
1530 il_default_variable_type = &safetime_type_name; |
|
1531 |
|
1532 else il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_NUM_compatible); |
1151 return NULL; |
1533 return NULL; |
1152 } |
1534 } |
1153 |
1535 |
1154 // SYM_REF0(MOD_operator_c) |
1536 // SYM_REF0(MOD_operator_c) |
1155 void *visit_expression_type_c::visit(MOD_operator_c *symbol) { |
1537 void *visit_expression_type_c::visit(MOD_operator_c *symbol) { |
1156 verify_null(symbol); |
1538 verify_null(symbol); |
1157 il_default_variable_type = compute_numeric_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_INT_type); |
1539 il_default_variable_type = compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_INT_compatible); |
1158 return NULL; |
1540 return NULL; |
1159 } |
1541 } |
1160 |
1542 |
1161 // SYM_REF0(GT_operator_c) |
1543 // SYM_REF0(GT_operator_c) |
1162 void *visit_expression_type_c::visit(GT_operator_c *symbol) { |
1544 void *visit_expression_type_c::visit(GT_operator_c *symbol) { |
1163 verify_null(symbol); |
1545 verify_null(symbol); |
1164 compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1546 compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1165 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1547 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1166 return NULL; |
1548 return NULL; |
1167 } |
1549 } |
1168 |
1550 |
1169 //SYM_REF0(GE_operator_c) |
1551 //SYM_REF0(GE_operator_c) |
1170 void *visit_expression_type_c::visit(GE_operator_c *symbol) { |
1552 void *visit_expression_type_c::visit(GE_operator_c *symbol) { |
1171 verify_null(symbol); |
1553 verify_null(symbol); |
1172 compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1554 compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1173 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1555 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1174 return NULL; |
1556 return NULL; |
1175 } |
1557 } |
1176 |
1558 |
1177 //SYM_REF0(EQ_operator_c) |
1559 //SYM_REF0(EQ_operator_c) |
1178 void *visit_expression_type_c::visit(EQ_operator_c *symbol) { |
1560 void *visit_expression_type_c::visit(EQ_operator_c *symbol) { |
1179 verify_null(symbol); |
1561 verify_null(symbol); |
1180 compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1562 compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1181 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1563 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1182 return NULL; |
1564 return NULL; |
1183 } |
1565 } |
1184 |
1566 |
1185 //SYM_REF0(LT_operator_c) |
1567 //SYM_REF0(LT_operator_c) |
1186 void *visit_expression_type_c::visit(LT_operator_c *symbol) { |
1568 void *visit_expression_type_c::visit(LT_operator_c *symbol) { |
1187 verify_null(symbol); |
1569 verify_null(symbol); |
1188 compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1570 compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1189 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1571 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1190 return NULL; |
1572 return NULL; |
1191 } |
1573 } |
1192 |
1574 |
1193 //SYM_REF0(LE_operator_c) |
1575 //SYM_REF0(LE_operator_c) |
1194 void *visit_expression_type_c::visit(LE_operator_c *symbol) { |
1576 void *visit_expression_type_c::visit(LE_operator_c *symbol) { |
1195 verify_null(symbol); |
1577 verify_null(symbol); |
1196 compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1578 compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1197 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1579 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1198 return NULL; |
1580 return NULL; |
1199 } |
1581 } |
1200 |
1582 |
1201 //SYM_REF0(NE_operator_c) |
1583 //SYM_REF0(NE_operator_c) |
1202 void *visit_expression_type_c::visit(NE_operator_c *symbol) { |
1584 void *visit_expression_type_c::visit(NE_operator_c *symbol) { |
1203 verify_null(symbol); |
1585 verify_null(symbol); |
1204 compute_boolean_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1586 compute_expression(il_default_variable_type, il_operand_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1205 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1587 il_default_variable_type = &search_expression_type_c::bool_type_name; |
1206 return NULL; |
1588 return NULL; |
1207 } |
1589 } |
1208 |
1590 |
1209 // SYM_REF0(CAL_operator_c) |
1591 // SYM_REF0(CAL_operator_c) |
1297 /***********************/ |
1679 /***********************/ |
1298 |
1680 |
1299 void *visit_expression_type_c::visit(or_expression_c *symbol) { |
1681 void *visit_expression_type_c::visit(or_expression_c *symbol) { |
1300 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1682 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1301 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1683 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1302 return compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_type); |
1684 return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_compatible); |
1303 } |
1685 } |
1304 |
1686 |
1305 |
1687 |
1306 void *visit_expression_type_c::visit(xor_expression_c *symbol) { |
1688 void *visit_expression_type_c::visit(xor_expression_c *symbol) { |
1307 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1689 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1308 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1690 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1309 return compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_type); |
1691 return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_compatible); |
1310 } |
1692 } |
1311 |
1693 |
1312 |
1694 |
1313 void *visit_expression_type_c::visit(and_expression_c *symbol) { |
1695 void *visit_expression_type_c::visit(and_expression_c *symbol) { |
1314 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1696 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1315 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1697 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1316 return compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_type); |
1698 return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_BIT_compatible); |
1317 } |
1699 } |
1318 |
1700 |
1319 |
1701 |
1320 void *visit_expression_type_c::visit(equ_expression_c *symbol) { |
1702 void *visit_expression_type_c::visit(equ_expression_c *symbol) { |
1321 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1703 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1322 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1704 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1323 compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1705 compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1324 return &search_expression_type_c::bool_type_name; |
1706 return &search_expression_type_c::bool_type_name; |
1325 } |
1707 } |
1326 |
1708 |
1327 |
1709 |
1328 void *visit_expression_type_c::visit(notequ_expression_c *symbol) { |
1710 void *visit_expression_type_c::visit(notequ_expression_c *symbol) { |
1329 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1711 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1330 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1712 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1331 compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1713 compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1332 return &search_expression_type_c::bool_type_name; |
1714 return &search_expression_type_c::bool_type_name; |
1333 } |
1715 } |
1334 |
1716 |
1335 |
1717 |
1336 void *visit_expression_type_c::visit(lt_expression_c *symbol) { |
1718 void *visit_expression_type_c::visit(lt_expression_c *symbol) { |
1337 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1719 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1338 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1720 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1339 compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1721 compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1340 return &search_expression_type_c::bool_type_name; |
1722 return &search_expression_type_c::bool_type_name; |
1341 } |
1723 } |
1342 |
1724 |
1343 |
1725 |
1344 void *visit_expression_type_c::visit(gt_expression_c *symbol) { |
1726 void *visit_expression_type_c::visit(gt_expression_c *symbol) { |
1345 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1727 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1346 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1728 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1347 compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1729 compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1348 return &search_expression_type_c::bool_type_name; |
1730 return &search_expression_type_c::bool_type_name; |
1349 } |
1731 } |
1350 |
1732 |
1351 |
1733 |
1352 void *visit_expression_type_c::visit(le_expression_c *symbol) { |
1734 void *visit_expression_type_c::visit(le_expression_c *symbol) { |
1353 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1735 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1354 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1736 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1355 compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1737 compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1356 return &search_expression_type_c::bool_type_name; |
1738 return &search_expression_type_c::bool_type_name; |
1357 } |
1739 } |
1358 |
1740 |
1359 |
1741 |
1360 void *visit_expression_type_c::visit(ge_expression_c *symbol) { |
1742 void *visit_expression_type_c::visit(ge_expression_c *symbol) { |
1361 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1743 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1362 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1744 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1363 compute_boolean_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_type); |
1745 compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible); |
1364 return &search_expression_type_c::bool_type_name; |
1746 return &search_expression_type_c::bool_type_name; |
1365 } |
1747 } |
1366 |
1748 |
1367 |
1749 |
1368 void *visit_expression_type_c::visit(add_expression_c *symbol) { |
1750 void *visit_expression_type_c::visit(add_expression_c *symbol) { |
1369 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1751 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1370 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1752 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1371 if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&time_type_name;} |
1753 |
1372 if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;} |
1754 /* The following is already checked in compute_expression */ |
1373 if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&dt_type_name;} |
1755 /* |
1374 return compute_numeric_expression(left_type, right_type, &visit_expression_type_c::is_ANY_MAGNITUDE_type); |
1756 if (is_type(left_type, time_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1757 return (void *)&time_type_name; |
|
1758 */ |
|
1759 |
|
1760 if (is_type(left_type, tod_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1761 return (void *)&tod_type_name; |
|
1762 if (is_type(left_type, safetod_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1763 return (void *)&tod_type_name; |
|
1764 if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1765 return (void *)&tod_type_name; |
|
1766 if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1767 return (void *)&safetod_type_name; |
|
1768 |
|
1769 if (is_type(left_type, dt_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1770 return (void *)&dt_type_name; |
|
1771 if (is_type(left_type, safedt_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1772 return (void *)&dt_type_name; |
|
1773 if (is_type(left_type, dt_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1774 return (void *)&dt_type_name; |
|
1775 if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1776 return (void *)&safedt_type_name; |
|
1777 |
|
1778 return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_MAGNITUDE_compatible); |
1375 } |
1779 } |
1376 |
1780 |
1377 |
1781 |
1378 void *visit_expression_type_c::visit(sub_expression_c *symbol) { |
1782 void *visit_expression_type_c::visit(sub_expression_c *symbol) { |
1379 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1783 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1380 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1784 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1381 if (typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&time_type_name;} |
1785 |
1382 if (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) {return (void *)&time_type_name;} |
1786 /* The following is already checked in compute_expression */ |
1383 if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&tod_type_name;} |
1787 /* |
1384 if (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) {return (void *)&time_type_name;} |
1788 if (is_type(left_type, time_type_name_c) && is_type(right_type, time_type_name_c)) |
1385 if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) {return (void *)&dt_type_name;} |
1789 return (void *)&time_type_name; |
1386 if (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(dt_type_name_c)) {return (void *)&time_type_name;} |
1790 */ |
1387 return compute_numeric_expression(left_type, right_type, &visit_expression_type_c::is_ANY_MAGNITUDE_type); |
1791 |
|
1792 if (is_type(left_type, tod_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1793 return (void *)&tod_type_name; |
|
1794 if (is_type(left_type, safetod_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1795 return (void *)&tod_type_name; |
|
1796 if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1797 return (void *)&tod_type_name; |
|
1798 if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1799 return (void *)&safetod_type_name; |
|
1800 |
|
1801 if (is_type(left_type, dt_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1802 return (void *)&dt_type_name; |
|
1803 if (is_type(left_type, safedt_type_name_c) && is_type(right_type, time_type_name_c)) |
|
1804 return (void *)&dt_type_name; |
|
1805 if (is_type(left_type, dt_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1806 return (void *)&dt_type_name; |
|
1807 if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safetime_type_name_c)) |
|
1808 return (void *)&safedt_type_name; |
|
1809 |
|
1810 if (is_type(left_type, tod_type_name_c) && is_type(right_type, tod_type_name_c)) |
|
1811 return (void *)&time_type_name; |
|
1812 if (is_type(left_type, safetod_type_name_c) && is_type(right_type, tod_type_name_c)) |
|
1813 return (void *)&time_type_name; |
|
1814 if (is_type(left_type, tod_type_name_c) && is_type(right_type, safetod_type_name_c)) |
|
1815 return (void *)&time_type_name; |
|
1816 if (is_type(left_type, safetod_type_name_c) && is_type(right_type, safetod_type_name_c)) |
|
1817 return (void *)&safetime_type_name; |
|
1818 |
|
1819 if (is_type(left_type, date_type_name_c) && is_type(right_type, date_type_name_c)) |
|
1820 return (void *)&time_type_name; |
|
1821 if (is_type(left_type, safedate_type_name_c) && is_type(right_type, date_type_name_c)) |
|
1822 return (void *)&time_type_name; |
|
1823 if (is_type(left_type, date_type_name_c) && is_type(right_type, safedate_type_name_c)) |
|
1824 return (void *)&time_type_name; |
|
1825 if (is_type(left_type, safedate_type_name_c) && is_type(right_type, safedate_type_name_c)) |
|
1826 return (void *)&safetime_type_name; |
|
1827 |
|
1828 if (is_type(left_type, dt_type_name_c) && is_type(right_type, dt_type_name_c)) |
|
1829 return (void *)&time_type_name; |
|
1830 if (is_type(left_type, safedt_type_name_c) && is_type(right_type, dt_type_name_c)) |
|
1831 return (void *)&time_type_name; |
|
1832 if (is_type(left_type, dt_type_name_c) && is_type(right_type, safedt_type_name_c)) |
|
1833 return (void *)&time_type_name; |
|
1834 if (is_type(left_type, safedt_type_name_c) && is_type(right_type, safedt_type_name_c)) |
|
1835 return (void *)&safetime_type_name; |
|
1836 |
|
1837 return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_MAGNITUDE_compatible); |
1388 } |
1838 } |
1389 |
1839 |
1390 |
1840 |
1391 void *visit_expression_type_c::visit(mul_expression_c *symbol) { |
1841 void *visit_expression_type_c::visit(mul_expression_c *symbol) { |
1392 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1842 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1393 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1843 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1394 if (typeid(*left_type) == typeid(time_type_name_c) && is_ANY_NUM_type(right_type)) {return (void *)&time_type_name;} |
1844 |
1395 return compute_numeric_expression(left_type, right_type, &visit_expression_type_c::is_ANY_NUM_type); |
1845 if (is_type(left_type, time_type_name_c) && is_ANY_NUM_compatible(right_type)) |
|
1846 return (void *)&time_type_name; |
|
1847 if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_type(right_type)) |
|
1848 return (void *)&time_type_name; |
|
1849 if (is_type(left_type, safetime_type_name_c) && is_ANY_SAFENUM_type(right_type)) |
|
1850 return (void *)&safetime_type_name; |
|
1851 /* Since we have already checked for ANY_NUM_type and ANY_SAFENUM_type in the previous lines, |
|
1852 * this next line is really only to check for integers/reals of undefined type on 'right_type'... |
|
1853 */ |
|
1854 if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_compatible(right_type)) |
|
1855 return (void *)&safetime_type_name; |
|
1856 |
|
1857 return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_NUM_compatible); |
1396 } |
1858 } |
1397 |
1859 |
1398 |
1860 |
1399 void *visit_expression_type_c::visit(div_expression_c *symbol) { |
1861 void *visit_expression_type_c::visit(div_expression_c *symbol) { |
1400 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1862 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1401 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1863 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1402 if (typeid(*left_type) == typeid(time_type_name_c) && is_ANY_NUM_type(right_type)){return (void *)&time_type_name;} |
1864 |
1403 return compute_numeric_expression(left_type, right_type, &visit_expression_type_c::is_ANY_NUM_type); |
1865 if (is_type(left_type, time_type_name_c) && is_ANY_NUM_compatible(right_type)) |
|
1866 return (void *)&time_type_name; |
|
1867 if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_type(right_type)) |
|
1868 return (void *)&time_type_name; |
|
1869 if (is_type(left_type, safetime_type_name_c) && is_ANY_SAFENUM_type(right_type)) |
|
1870 return (void *)&safetime_type_name; |
|
1871 /* Since we have already checked for ANY_NUM_type and ANY_SAFENUM_type in the previous lines, |
|
1872 * this next line is really only to check for integers/reals of undefined type on 'right_type'... |
|
1873 */ |
|
1874 if (is_type(left_type, safetime_type_name_c) && is_ANY_NUM_compatible(right_type)) |
|
1875 return (void *)&safetime_type_name; |
|
1876 |
|
1877 return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_NUM_compatible); |
1404 } |
1878 } |
1405 |
1879 |
1406 |
1880 |
1407 void *visit_expression_type_c::visit(mod_expression_c *symbol) { |
1881 void *visit_expression_type_c::visit(mod_expression_c *symbol) { |
1408 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1882 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1409 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1883 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1410 return compute_numeric_expression(left_type, right_type, &visit_expression_type_c::is_ANY_INT_type); |
1884 return compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_INT_compatible); |
1411 } |
1885 } |
1412 |
1886 |
1413 |
1887 |
1414 void *visit_expression_type_c::visit(power_expression_c *symbol) { |
1888 void *visit_expression_type_c::visit(power_expression_c *symbol) { |
1415 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1889 symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); |
1416 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1890 symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); |
1417 if (!is_ANY_REAL_type(left_type)) |
1891 if (!is_ANY_REAL_compatible(left_type)) |
1418 STAGE3_ERROR(symbol->l_exp, symbol->l_exp, "first operand of ** operator has invalid data type, should be of type ANY_REAL."); |
1892 STAGE3_ERROR(symbol->l_exp, symbol->l_exp, "first operand of ** operator has invalid data type, should be of type ANY_REAL."); |
1419 if (!is_ANY_NUM_type(right_type)) |
1893 if (!is_ANY_NUM_compatible(right_type)) |
1420 STAGE3_ERROR(symbol->r_exp, symbol->r_exp, "second operand of ** operator has invalid data type, should be of type ANY_NUM."); |
1894 STAGE3_ERROR(symbol->r_exp, symbol->r_exp, "second operand of ** operator has invalid data type, should be of type ANY_NUM."); |
1421 |
1895 |
1422 return (void *)left_type; |
1896 return (void *)left_type; |
1423 } |
1897 } |
1424 |
1898 |
1425 |
1899 |
1426 void *visit_expression_type_c::visit(neg_expression_c *symbol) { |
1900 void *visit_expression_type_c::visit(neg_expression_c *symbol) { |
1427 symbol_c *exp_type = base_type((symbol_c *)symbol->exp->accept(*this)); |
1901 symbol_c *exp_type = base_type((symbol_c *)symbol->exp->accept(*this)); |
1428 if (!is_ANY_MAGNITUDE_type(exp_type)) |
1902 if (!is_ANY_MAGNITUDE_compatible(exp_type)) |
1429 STAGE3_ERROR(symbol, symbol, "operand of negate expression '-' has invalid data type, should be of type ANY_MAGNITUDE."); |
1903 STAGE3_ERROR(symbol, symbol, "operand of negate expression '-' has invalid data type, should be of type ANY_MAGNITUDE."); |
1430 |
1904 |
1431 return exp_type; |
1905 return exp_type; |
1432 } |
1906 } |
1433 |
1907 |
1434 |
1908 |
1435 void *visit_expression_type_c::visit(not_expression_c *symbol) { |
1909 void *visit_expression_type_c::visit(not_expression_c *symbol) { |
1436 symbol_c *type = base_type((symbol_c *)symbol->exp->accept(*this)); |
1910 symbol_c *type = base_type((symbol_c *)symbol->exp->accept(*this)); |
1437 return compute_boolean_expression(type, type, &visit_expression_type_c::is_ANY_BIT_type); |
1911 return compute_expression(type, type, &visit_expression_type_c::is_ANY_BIT_compatible); |
1438 } |
1912 } |
1439 |
1913 |
1440 |
1914 |
1441 void *visit_expression_type_c::visit(function_invocation_c *symbol) { |
1915 void *visit_expression_type_c::visit(function_invocation_c *symbol) { |
1442 function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name); |
1916 function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name); |