135 * In other words, when calling search_constant_type_c on these constants, it returns |
140 * In other words, when calling search_constant_type_c on these constants, it returns |
136 * a xxxxx_type_name_c, and not one of the xxxx_literal_c ! |
141 * a xxxxx_type_name_c, and not one of the xxxx_literal_c ! |
137 * |
142 * |
138 * When the following code handles a literal, it is really a literal of unknown data type. |
143 * When the following code handles a literal, it is really a literal of unknown data type. |
139 * e.g. 42, may be considered an int, a byte, a word, etc... |
144 * e.g. 42, may be considered an int, a byte, a word, etc... |
|
145 * |
|
146 * NOTE: type_symbol == NULL is valid! |
|
147 * This will occur, for example, when and undefined/undeclared symbolic_variable is used in the program. |
|
148 * This will not be of any type, so we always return false. |
140 */ |
149 */ |
141 |
150 |
142 /* A helper function... */ |
151 /* A helper function... */ |
143 bool visit_expression_type_c::is_ANY_ELEMENTARY_type(symbol_c *type_symbol) { |
152 bool visit_expression_type_c::is_ANY_ELEMENTARY_type(symbol_c *type_symbol) { |
144 if (type_symbol == NULL) {ERROR;} |
153 if (type_symbol == NULL) {return false;} |
145 return is_ANY_MAGNITUDE_type(type_symbol) |
154 return is_ANY_MAGNITUDE_type(type_symbol) |
146 || is_ANY_BIT_type (type_symbol) |
155 || is_ANY_BIT_type (type_symbol) |
147 || is_ANY_STRING_type (type_symbol) |
156 || is_ANY_STRING_type (type_symbol) |
148 || is_ANY_DATE_type (type_symbol); |
157 || is_ANY_DATE_type (type_symbol); |
149 } |
158 } |
150 |
159 |
151 /* A helper function... */ |
160 /* A helper function... */ |
152 bool visit_expression_type_c::is_ANY_SAFEELEMENTARY_type(symbol_c *type_symbol) { |
161 bool visit_expression_type_c::is_ANY_SAFEELEMENTARY_type(symbol_c *type_symbol) { |
153 if (type_symbol == NULL) {ERROR;} |
162 if (type_symbol == NULL) {return false;} |
154 return is_ANY_SAFEMAGNITUDE_type(type_symbol) |
163 return is_ANY_SAFEMAGNITUDE_type(type_symbol) |
155 || is_ANY_SAFEBIT_type (type_symbol) |
164 || is_ANY_SAFEBIT_type (type_symbol) |
156 || is_ANY_SAFESTRING_type (type_symbol) |
165 || is_ANY_SAFESTRING_type (type_symbol) |
157 || is_ANY_SAFEDATE_type (type_symbol); |
166 || is_ANY_SAFEDATE_type (type_symbol); |
158 } |
167 } |
159 |
168 |
160 /* A helper function... */ |
169 /* A helper function... */ |
161 bool visit_expression_type_c::is_ANY_ELEMENTARY_compatible(symbol_c *type_symbol) { |
170 bool visit_expression_type_c::is_ANY_ELEMENTARY_compatible(symbol_c *type_symbol) { |
162 if (type_symbol == NULL) {ERROR;} |
171 if (type_symbol == NULL) {return false;} |
163 /* NOTE: doing |
172 /* NOTE: doing |
164 * return is_ANY_SAFEELEMENTARY_type() || is_ANY_ELEMENTARY_type() |
173 * return is_ANY_SAFEELEMENTARY_type() || is_ANY_ELEMENTARY_type() |
165 * is incorrect, as the literals would never be considered compatible... |
174 * is incorrect, as the literals would never be considered compatible... |
166 */ |
175 */ |
167 return is_ANY_MAGNITUDE_compatible(type_symbol) |
176 return is_ANY_MAGNITUDE_compatible(type_symbol) |
171 } |
180 } |
172 |
181 |
173 |
182 |
174 /* A helper function... */ |
183 /* A helper function... */ |
175 bool visit_expression_type_c::is_ANY_MAGNITUDE_type(symbol_c *type_symbol) { |
184 bool visit_expression_type_c::is_ANY_MAGNITUDE_type(symbol_c *type_symbol) { |
176 if (type_symbol == NULL) {ERROR;} |
185 if (type_symbol == NULL) {return false;} |
177 if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;} |
186 if (typeid(*type_symbol) == typeid(time_type_name_c)) {return true;} |
178 return is_ANY_NUM_type(type_symbol); |
187 return is_ANY_NUM_type(type_symbol); |
179 } |
188 } |
180 |
189 |
181 /* A helper function... */ |
190 /* A helper function... */ |
182 bool visit_expression_type_c::is_ANY_SAFEMAGNITUDE_type(symbol_c *type_symbol) { |
191 bool visit_expression_type_c::is_ANY_SAFEMAGNITUDE_type(symbol_c *type_symbol) { |
183 if (type_symbol == NULL) {ERROR;} |
192 if (type_symbol == NULL) {return false;} |
184 if (typeid(*type_symbol) == typeid(safetime_type_name_c)) {return true;} |
193 if (typeid(*type_symbol) == typeid(safetime_type_name_c)) {return true;} |
185 return is_ANY_SAFENUM_type(type_symbol); |
194 return is_ANY_SAFENUM_type(type_symbol); |
186 } |
195 } |
187 |
196 |
188 /* A helper function... */ |
197 /* A helper function... */ |
189 bool visit_expression_type_c::is_ANY_MAGNITUDE_compatible(symbol_c *type_symbol) { |
198 bool visit_expression_type_c::is_ANY_MAGNITUDE_compatible(symbol_c *type_symbol) { |
190 if (type_symbol == NULL) {ERROR;} |
199 if (type_symbol == NULL) {return false;} |
191 if (is_ANY_MAGNITUDE_type (type_symbol)) {return true;} |
200 if (is_ANY_MAGNITUDE_type (type_symbol)) {return true;} |
192 if (is_ANY_SAFEMAGNITUDE_type(type_symbol)) {return true;} |
201 if (is_ANY_SAFEMAGNITUDE_type(type_symbol)) {return true;} |
193 |
202 |
194 return is_ANY_NUM_compatible(type_symbol); |
203 return is_ANY_NUM_compatible(type_symbol); |
195 } |
204 } |
196 |
205 |
197 /* A helper function... */ |
206 /* A helper function... */ |
198 bool visit_expression_type_c::is_ANY_NUM_type(symbol_c *type_symbol) { |
207 bool visit_expression_type_c::is_ANY_NUM_type(symbol_c *type_symbol) { |
199 if (type_symbol == NULL) {ERROR;} |
208 if (type_symbol == NULL) {return false;} |
200 if (is_ANY_REAL_type(type_symbol)) {return true;} |
209 if (is_ANY_REAL_type(type_symbol)) {return true;} |
201 if (is_ANY_INT_type(type_symbol)) {return true;} |
210 if (is_ANY_INT_type(type_symbol)) {return true;} |
202 return false; |
211 return false; |
203 } |
212 } |
204 |
213 |
205 /* A helper function... */ |
214 /* A helper function... */ |
206 bool visit_expression_type_c::is_ANY_SAFENUM_type(symbol_c *type_symbol) { |
215 bool visit_expression_type_c::is_ANY_SAFENUM_type(symbol_c *type_symbol) { |
207 if (type_symbol == NULL) {ERROR;} |
216 if (type_symbol == NULL) {return false;} |
208 return is_ANY_SAFEREAL_type(type_symbol) |
217 return is_ANY_SAFEREAL_type(type_symbol) |
209 || is_ANY_SAFEINT_type (type_symbol); |
218 || is_ANY_SAFEINT_type (type_symbol); |
210 } |
219 } |
211 |
220 |
212 /* A helper function... */ |
221 /* A helper function... */ |
213 bool visit_expression_type_c::is_ANY_NUM_compatible(symbol_c *type_symbol) { |
222 bool visit_expression_type_c::is_ANY_NUM_compatible(symbol_c *type_symbol) { |
214 if (type_symbol == NULL) {ERROR;} |
223 if (type_symbol == NULL) {return false;} |
215 if (is_ANY_REAL_compatible(type_symbol)) {return true;} |
224 if (is_ANY_REAL_compatible(type_symbol)) {return true;} |
216 if (is_ANY_INT_compatible(type_symbol)) {return true;} |
225 if (is_ANY_INT_compatible(type_symbol)) {return true;} |
217 return false; |
226 return false; |
218 } |
227 } |
219 |
228 |
220 /* A helper function... */ |
229 /* A helper function... */ |
221 bool visit_expression_type_c::is_ANY_DATE_type(symbol_c *type_symbol) { |
230 bool visit_expression_type_c::is_ANY_DATE_type(symbol_c *type_symbol) { |
222 if (type_symbol == NULL) {ERROR;} |
231 if (type_symbol == NULL) {return false;} |
223 if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;} |
232 if (typeid(*type_symbol) == typeid(date_type_name_c)) {return true;} |
224 if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;} |
233 if (typeid(*type_symbol) == typeid(tod_type_name_c)) {return true;} |
225 if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;} |
234 if (typeid(*type_symbol) == typeid(dt_type_name_c)) {return true;} |
226 return false; |
235 return false; |
227 } |
236 } |
228 |
237 |
229 /* A helper function... */ |
238 /* A helper function... */ |
230 bool visit_expression_type_c::is_ANY_SAFEDATE_type(symbol_c *type_symbol) { |
239 bool visit_expression_type_c::is_ANY_SAFEDATE_type(symbol_c *type_symbol) { |
231 if (type_symbol == NULL) {ERROR;} |
240 if (type_symbol == NULL) {return false;} |
232 if (typeid(*type_symbol) == typeid(safedate_type_name_c)) {return true;} |
241 if (typeid(*type_symbol) == typeid(safedate_type_name_c)) {return true;} |
233 if (typeid(*type_symbol) == typeid(safetod_type_name_c)) {return true;} |
242 if (typeid(*type_symbol) == typeid(safetod_type_name_c)) {return true;} |
234 if (typeid(*type_symbol) == typeid(safedt_type_name_c)) {return true;} |
243 if (typeid(*type_symbol) == typeid(safedt_type_name_c)) {return true;} |
235 return false; |
244 return false; |
236 } |
245 } |
237 |
246 |
238 /* A helper function... */ |
247 /* A helper function... */ |
239 bool visit_expression_type_c::is_ANY_DATE_compatible(symbol_c *type_symbol) { |
248 bool visit_expression_type_c::is_ANY_DATE_compatible(symbol_c *type_symbol) { |
240 if (type_symbol == NULL) {ERROR;} |
249 if (type_symbol == NULL) {return false;} |
241 if (is_ANY_DATE_type (type_symbol)) {return true;} |
250 if (is_ANY_DATE_type (type_symbol)) {return true;} |
242 if (is_ANY_SAFEDATE_type(type_symbol)) {return true;} |
251 if (is_ANY_SAFEDATE_type(type_symbol)) {return true;} |
243 return false; |
252 return false; |
244 } |
253 } |
245 |
254 |
246 /* A helper function... */ |
255 /* A helper function... */ |
247 bool visit_expression_type_c::is_ANY_STRING_type(symbol_c *type_symbol) { |
256 bool visit_expression_type_c::is_ANY_STRING_type(symbol_c *type_symbol) { |
248 if (type_symbol == NULL) {ERROR;} |
257 if (type_symbol == NULL) {return false;} |
249 if (typeid(*type_symbol) == typeid(string_type_name_c)) {return true;} |
258 if (typeid(*type_symbol) == typeid(string_type_name_c)) {return true;} |
250 if (typeid(*type_symbol) == typeid(wstring_type_name_c)) {return true;} |
259 if (typeid(*type_symbol) == typeid(wstring_type_name_c)) {return true;} |
251 // TODO literal_string ??? |
260 // TODO literal_string ??? |
252 return false; |
261 return false; |
253 } |
262 } |
254 |
263 |
255 /* A helper function... */ |
264 /* A helper function... */ |
256 bool visit_expression_type_c::is_ANY_SAFESTRING_type(symbol_c *type_symbol) { |
265 bool visit_expression_type_c::is_ANY_SAFESTRING_type(symbol_c *type_symbol) { |
257 if (type_symbol == NULL) {ERROR;} |
266 if (type_symbol == NULL) {return false;} |
258 if (typeid(*type_symbol) == typeid(safestring_type_name_c)) {return true;} |
267 if (typeid(*type_symbol) == typeid(safestring_type_name_c)) {return true;} |
259 if (typeid(*type_symbol) == typeid(safewstring_type_name_c)) {return true;} |
268 if (typeid(*type_symbol) == typeid(safewstring_type_name_c)) {return true;} |
260 return false; |
269 return false; |
261 } |
270 } |
262 |
271 |
263 /* A helper function... */ |
272 /* A helper function... */ |
264 bool visit_expression_type_c::is_ANY_STRING_compatible(symbol_c *type_symbol) { |
273 bool visit_expression_type_c::is_ANY_STRING_compatible(symbol_c *type_symbol) { |
265 if (type_symbol == NULL) {ERROR;} |
274 if (type_symbol == NULL) {return false;} |
266 if (is_ANY_STRING_type (type_symbol)) {return true;} |
275 if (is_ANY_STRING_type (type_symbol)) {return true;} |
267 if (is_ANY_SAFESTRING_type(type_symbol)) {return true;} |
276 if (is_ANY_SAFESTRING_type(type_symbol)) {return true;} |
268 return false; |
277 return false; |
269 } |
278 } |
270 |
279 |
271 /* A helper function... */ |
280 /* A helper function... */ |
272 bool visit_expression_type_c::is_ANY_INT_type(symbol_c *type_symbol) { |
281 bool visit_expression_type_c::is_ANY_INT_type(symbol_c *type_symbol) { |
273 if (type_symbol == NULL) {ERROR;} |
282 if (type_symbol == NULL) {return false;} |
274 if (typeid(*type_symbol) == typeid(sint_type_name_c)) {return true;} |
283 if (typeid(*type_symbol) == typeid(sint_type_name_c)) {return true;} |
275 if (typeid(*type_symbol) == typeid(int_type_name_c)) {return true;} |
284 if (typeid(*type_symbol) == typeid(int_type_name_c)) {return true;} |
276 if (typeid(*type_symbol) == typeid(dint_type_name_c)) {return true;} |
285 if (typeid(*type_symbol) == typeid(dint_type_name_c)) {return true;} |
277 if (typeid(*type_symbol) == typeid(lint_type_name_c)) {return true;} |
286 if (typeid(*type_symbol) == typeid(lint_type_name_c)) {return true;} |
278 if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
287 if (typeid(*type_symbol) == typeid(usint_type_name_c)) {return true;} |
296 return false; |
305 return false; |
297 } |
306 } |
298 |
307 |
299 /* A helper function... */ |
308 /* A helper function... */ |
300 bool visit_expression_type_c::is_ANY_INT_compatible(symbol_c *type_symbol) { |
309 bool visit_expression_type_c::is_ANY_INT_compatible(symbol_c *type_symbol) { |
301 if (type_symbol == NULL) {ERROR;} |
310 if (type_symbol == NULL) {return false;} |
302 if (is_ANY_INT_type (type_symbol)) {return true;} |
311 if (is_ANY_INT_type (type_symbol)) {return true;} |
303 if (is_ANY_SAFEINT_type(type_symbol)) {return true;} |
312 if (is_ANY_SAFEINT_type(type_symbol)) {return true;} |
304 if (is_literal_integer_type(type_symbol)) {return true;} |
313 if (is_literal_integer_type(type_symbol)) {return true;} |
305 return false; |
314 return false; |
306 } |
315 } |
307 |
316 |
308 /* A helper function... */ |
317 /* A helper function... */ |
309 bool visit_expression_type_c::is_ANY_REAL_type(symbol_c *type_symbol) { |
318 bool visit_expression_type_c::is_ANY_REAL_type(symbol_c *type_symbol) { |
310 if (type_symbol == NULL) {ERROR;} |
319 if (type_symbol == NULL) {return false;} |
311 if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
320 if (typeid(*type_symbol) == typeid(real_type_name_c)) {return true;} |
312 if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
321 if (typeid(*type_symbol) == typeid(lreal_type_name_c)) {return true;} |
313 return false; |
322 return false; |
314 } |
323 } |
315 |
324 |
316 /* A helper function... */ |
325 /* A helper function... */ |
317 bool visit_expression_type_c::is_ANY_SAFEREAL_type(symbol_c *type_symbol) { |
326 bool visit_expression_type_c::is_ANY_SAFEREAL_type(symbol_c *type_symbol) { |
318 if (type_symbol == NULL) {ERROR;} |
327 if (type_symbol == NULL) {return false;} |
319 if (typeid(*type_symbol) == typeid(safereal_type_name_c)) {return true;} |
328 if (typeid(*type_symbol) == typeid(safereal_type_name_c)) {return true;} |
320 if (typeid(*type_symbol) == typeid(safelreal_type_name_c)) {return true;} |
329 if (typeid(*type_symbol) == typeid(safelreal_type_name_c)) {return true;} |
321 return false; |
330 return false; |
322 } |
331 } |
323 |
332 |
324 /* A helper function... */ |
333 /* A helper function... */ |
325 bool visit_expression_type_c::is_ANY_REAL_compatible(symbol_c *type_symbol) { |
334 bool visit_expression_type_c::is_ANY_REAL_compatible(symbol_c *type_symbol) { |
326 if (type_symbol == NULL) {ERROR;} |
335 if (type_symbol == NULL) {return false;} |
327 if (is_ANY_REAL_type (type_symbol)) {return true;} |
336 if (is_ANY_REAL_type (type_symbol)) {return true;} |
328 if (is_ANY_SAFEREAL_type(type_symbol)) {return true;} |
337 if (is_ANY_SAFEREAL_type(type_symbol)) {return true;} |
329 if (is_literal_real_type(type_symbol)) {return true;} |
338 if (is_literal_real_type(type_symbol)) {return true;} |
330 return false; |
339 return false; |
331 } |
340 } |
332 |
341 |
333 /* A helper function... */ |
342 /* A helper function... */ |
334 bool visit_expression_type_c::is_ANY_BIT_type(symbol_c *type_symbol) { |
343 bool visit_expression_type_c::is_ANY_BIT_type(symbol_c *type_symbol) { |
335 if (type_symbol == NULL) {ERROR;} |
344 if (type_symbol == NULL) {return false;} |
336 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
345 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
337 if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
346 if (typeid(*type_symbol) == typeid(byte_type_name_c)) {return true;} |
338 if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
347 if (typeid(*type_symbol) == typeid(word_type_name_c)) {return true;} |
339 if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
348 if (typeid(*type_symbol) == typeid(dword_type_name_c)) {return true;} |
340 if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
349 if (typeid(*type_symbol) == typeid(lword_type_name_c)) {return true;} |
341 return false; |
350 return false; |
342 } |
351 } |
343 |
352 |
344 /* A helper function... */ |
353 /* A helper function... */ |
345 bool visit_expression_type_c::is_ANY_SAFEBIT_type(symbol_c *type_symbol) { |
354 bool visit_expression_type_c::is_ANY_SAFEBIT_type(symbol_c *type_symbol) { |
346 if (type_symbol == NULL) {ERROR;} |
355 if (type_symbol == NULL) {return false;} |
347 if (typeid(*type_symbol) == typeid(safebool_type_name_c)) {return true;} |
356 if (typeid(*type_symbol) == typeid(safebool_type_name_c)) {return true;} |
348 if (typeid(*type_symbol) == typeid(safebyte_type_name_c)) {return true;} |
357 if (typeid(*type_symbol) == typeid(safebyte_type_name_c)) {return true;} |
349 if (typeid(*type_symbol) == typeid(safeword_type_name_c)) {return true;} |
358 if (typeid(*type_symbol) == typeid(safeword_type_name_c)) {return true;} |
350 if (typeid(*type_symbol) == typeid(safedword_type_name_c)) {return true;} |
359 if (typeid(*type_symbol) == typeid(safedword_type_name_c)) {return true;} |
351 if (typeid(*type_symbol) == typeid(safelword_type_name_c)) {return true;} |
360 if (typeid(*type_symbol) == typeid(safelword_type_name_c)) {return true;} |
352 return false; |
361 return false; |
353 } |
362 } |
354 |
363 |
355 /* A helper function... */ |
364 /* A helper function... */ |
356 bool visit_expression_type_c::is_ANY_BIT_compatible(symbol_c *type_symbol) { |
365 bool visit_expression_type_c::is_ANY_BIT_compatible(symbol_c *type_symbol) { |
357 if (type_symbol == NULL) {ERROR;} |
366 if (type_symbol == NULL) {return false;} |
358 if (is_ANY_BIT_type (type_symbol)) {return true;} |
367 if (is_ANY_BIT_type (type_symbol)) {return true;} |
359 if (is_ANY_SAFEBIT_type(type_symbol)) {return true;} |
368 if (is_ANY_SAFEBIT_type(type_symbol)) {return true;} |
360 if (is_nonneg_literal_integer_type(type_symbol)) {return true;} |
369 if (is_nonneg_literal_integer_type(type_symbol)) {return true;} |
361 if (is_literal_bool_type(type_symbol)) {return true;} |
370 if (is_literal_bool_type(type_symbol)) {return true;} |
362 return false; |
371 return false; |
363 } |
372 } |
364 |
373 |
365 /* A helper function... */ |
374 /* A helper function... */ |
366 bool visit_expression_type_c::is_BOOL_type(symbol_c *type_symbol) { |
375 bool visit_expression_type_c::is_BOOL_type(symbol_c *type_symbol) { |
367 if (type_symbol == NULL) {ERROR;} |
376 if (type_symbol == NULL) {return false;} |
368 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
377 if (typeid(*type_symbol) == typeid(bool_type_name_c)) {return true;} |
369 return false; |
378 return false; |
370 } |
379 } |
371 |
380 |
372 /* A helper function... */ |
381 /* A helper function... */ |
373 bool visit_expression_type_c::is_SAFEBOOL_type(symbol_c *type_symbol){ |
382 bool visit_expression_type_c::is_SAFEBOOL_type(symbol_c *type_symbol){ |
374 if (type_symbol == NULL) {ERROR;} |
383 if (type_symbol == NULL) {return false;} |
375 if (typeid(*type_symbol) == typeid(safebool_type_name_c)) {return true;} |
384 if (typeid(*type_symbol) == typeid(safebool_type_name_c)) {return true;} |
376 return false; |
385 return false; |
377 } |
386 } |
378 |
387 |
379 /* A helper function... */ |
388 /* A helper function... */ |
380 bool visit_expression_type_c::is_ANY_BOOL_compatible(symbol_c *type_symbol) { |
389 bool visit_expression_type_c::is_ANY_BOOL_compatible(symbol_c *type_symbol) { |
381 if (type_symbol == NULL) {ERROR;} |
390 if (type_symbol == NULL) {return false;} |
382 if (is_BOOL_type (type_symbol)) {return true;} |
391 if (is_BOOL_type (type_symbol)) {return true;} |
383 if (is_SAFEBOOL_type(type_symbol)) {return true;} |
392 if (is_SAFEBOOL_type(type_symbol)) {return true;} |
384 if (is_literal_bool_type(type_symbol)) {return true;} |
393 if (is_literal_bool_type(type_symbol)) {return true;} |
385 return false; |
394 return false; |
386 } |
395 } |
392 #define sizeoftype(symbol) get_sizeof_datatype_c::getsize(symbol) |
401 #define sizeoftype(symbol) get_sizeof_datatype_c::getsize(symbol) |
393 |
402 |
394 |
403 |
395 /* A helper function... */ |
404 /* A helper function... */ |
396 bool visit_expression_type_c::is_literal_integer_type(symbol_c *type_symbol) { |
405 bool visit_expression_type_c::is_literal_integer_type(symbol_c *type_symbol) { |
397 if (type_symbol == NULL) {ERROR;} |
406 if (type_symbol == NULL) {return false;} |
398 if (typeid(*type_symbol) == typeid(neg_integer_c)) {return true;} |
407 if (typeid(*type_symbol) == typeid(neg_integer_c)) {return true;} |
399 return is_nonneg_literal_integer_type(type_symbol); |
408 return is_nonneg_literal_integer_type(type_symbol); |
400 } |
409 } |
401 |
410 |
402 |
411 |
403 /* A helper function... */ |
412 /* A helper function... */ |
404 bool visit_expression_type_c::is_nonneg_literal_integer_type(symbol_c *type_symbol) { |
413 bool visit_expression_type_c::is_nonneg_literal_integer_type(symbol_c *type_symbol) { |
405 if (type_symbol == NULL) {ERROR;} |
414 if (type_symbol == NULL) {return false;} |
406 if (typeid(*type_symbol) == typeid(integer_c)) {return true;} |
415 if (typeid(*type_symbol) == typeid(integer_c)) {return true;} |
407 if (typeid(*type_symbol) == typeid(binary_integer_c)) {return true;} |
416 if (typeid(*type_symbol) == typeid(binary_integer_c)) {return true;} |
408 if (typeid(*type_symbol) == typeid(octal_integer_c)) {return true;} |
417 if (typeid(*type_symbol) == typeid(octal_integer_c)) {return true;} |
409 if (typeid(*type_symbol) == typeid(hex_integer_c)) {return true;} |
418 if (typeid(*type_symbol) == typeid(hex_integer_c)) {return true;} |
410 return false; |
419 return false; |
411 } |
420 } |
412 |
421 |
413 |
422 |
414 /* A helper function... */ |
423 /* A helper function... */ |
415 bool visit_expression_type_c::is_literal_real_type(symbol_c *type_symbol) { |
424 bool visit_expression_type_c::is_literal_real_type(symbol_c *type_symbol) { |
416 if (type_symbol == NULL) {ERROR;} |
425 if (type_symbol == NULL) {return false;} |
417 if (typeid(*type_symbol) == typeid(real_c)) {return true;} |
426 if (typeid(*type_symbol) == typeid(real_c)) {return true;} |
418 if (typeid(*type_symbol) == typeid(neg_real_c)) {return true;} |
427 if (typeid(*type_symbol) == typeid(neg_real_c)) {return true;} |
419 return false; |
428 return false; |
420 } |
429 } |
421 |
430 |
422 |
431 |
423 /* A helper function... */ |
432 /* A helper function... */ |
424 bool visit_expression_type_c::is_literal_bool_type(symbol_c *type_symbol) { |
433 bool visit_expression_type_c::is_literal_bool_type(symbol_c *type_symbol) { |
425 bool_type_name_c bool_t; |
434 bool_type_name_c bool_t; |
426 |
435 |
427 if (type_symbol == NULL) {ERROR;} |
436 if (type_symbol == NULL) {return false;} |
428 if (typeid(*type_symbol) == typeid(boolean_true_c)) {return true;} |
437 if (typeid(*type_symbol) == typeid(boolean_true_c)) {return true;} |
429 if (typeid(*type_symbol) == typeid(boolean_false_c)) {return true;} |
438 if (typeid(*type_symbol) == typeid(boolean_false_c)) {return true;} |
430 if (is_nonneg_literal_integer_type(type_symbol)) |
439 if (is_nonneg_literal_integer_type(type_symbol)) |
431 if (sizeoftype(&bool_t) >= sizeoftype(type_symbol)) {return true;} |
440 if (sizeoftype(&bool_t) >= sizeoftype(type_symbol)) {return true;} |
432 return false; |
441 return false; |
632 /* A helper function... */ |
643 /* A helper function... */ |
633 /* |
644 /* |
634 symbol_c *visit_expression_type_c::compute_boolean_expression(symbol_c *left_type, symbol_c *right_type, |
645 symbol_c *visit_expression_type_c::compute_boolean_expression(symbol_c *left_type, symbol_c *right_type, |
635 is_data_type_t is_data_type) { |
646 is_data_type_t is_data_type) { |
636 */ |
647 */ |
637 symbol_c *visit_expression_type_c::compute_expression(symbol_c *left_type, symbol_c *right_type, |
648 symbol_c *visit_expression_type_c::compute_expression(symbol_c *left_type, symbol_c *right_type, is_data_type_t is_data_type, |
638 is_data_type_t is_data_type) { |
649 symbol_c *left_expr, symbol_c *right_expr) { |
639 bool error = false; |
650 bool error = false; |
640 |
651 |
641 if (!(this->*is_data_type)(left_type)) { |
652 if (!(this->*is_data_type)(left_type)) { |
642 STAGE3_ERROR(left_type, left_type, "Invalid data type of left operand."); |
653 if (left_expr != NULL) |
|
654 STAGE3_ERROR(left_expr, left_expr, "Invalid data type of left operand."); |
643 error = true; |
655 error = true; |
644 } |
656 } |
645 if (!(this->*is_data_type)(right_type)) { |
657 if (!(this->*is_data_type)(right_type)) { |
646 STAGE3_ERROR(right_type, right_type, "Invalid data type of right operand."); |
658 if (right_expr != NULL) |
|
659 STAGE3_ERROR(right_expr, right_expr, "Invalid data type of right operand."); |
647 error = true; |
660 error = true; |
648 } |
661 } |
649 if (!is_compatible_type(left_type, right_type)) { |
662 if (!is_compatible_type(left_type, right_type)) { |
650 STAGE3_ERROR(left_type, right_type, "Type mismatch between operands."); |
663 if ((left_expr != NULL) && (right_expr != NULL)) |
|
664 STAGE3_ERROR(left_expr, right_expr, "Type mismatch between operands."); |
651 error = true; |
665 error = true; |
652 } |
666 } |
653 |
667 |
654 if (error) |
668 if (error) |
655 return NULL; |
669 return NULL; |