397 /* B 1.3 - Data types */ |
397 /* B 1.3 - Data types */ |
398 /**********************/ |
398 /**********************/ |
399 /********************************/ |
399 /********************************/ |
400 /* B 1.3.3 - Derived data types */ |
400 /* B 1.3.3 - Derived data types */ |
401 /********************************/ |
401 /********************************/ |
|
402 /* simple_specification ASSIGN constant */ |
|
403 // SYM_REF2(simple_spec_init_c, simple_specification, constant) |
|
404 void *narrow_candidate_datatypes_c::visit(simple_spec_init_c *symbol) { |
|
405 if (symbol->candidate_datatypes.size() == 1) |
|
406 symbol->datatype = symbol->candidate_datatypes[0]; |
|
407 |
|
408 if (symbol->simple_specification->candidate_datatypes.size() == 1) |
|
409 symbol->simple_specification->datatype = symbol->simple_specification->candidate_datatypes[0]; |
|
410 |
|
411 if (NULL != symbol->constant) { |
|
412 set_datatype(symbol->datatype, symbol->constant); |
|
413 symbol->constant->accept(*this); |
|
414 } |
|
415 return NULL; |
|
416 } |
|
417 |
|
418 |
|
419 |
402 /* signed_integer DOTDOT signed_integer */ |
420 /* signed_integer DOTDOT signed_integer */ |
403 // SYM_REF2(subrange_c, lower_limit, upper_limit) |
421 // SYM_REF2(subrange_c, lower_limit, upper_limit) |
404 void *narrow_candidate_datatypes_c::visit(subrange_c *symbol) { |
422 void *narrow_candidate_datatypes_c::visit(subrange_c *symbol) { |
405 symbol->lower_limit->datatype = symbol->datatype; |
423 symbol->lower_limit->datatype = symbol->datatype; |
406 symbol->lower_limit->accept(*this); |
424 symbol->lower_limit->accept(*this); |
407 symbol->upper_limit->datatype = symbol->datatype; |
425 symbol->upper_limit->datatype = symbol->datatype; |
408 symbol->upper_limit->accept(*this); |
426 symbol->upper_limit->accept(*this); |
409 return NULL; |
427 return NULL; |
410 } |
428 } |
411 |
429 |
412 /* simple_specification ASSIGN constant */ |
|
413 // SYM_REF2(simple_spec_init_c, simple_specification, constant) |
|
414 void *narrow_candidate_datatypes_c::visit(simple_spec_init_c *symbol) { |
|
415 symbol_c *datatype = base_type(symbol->simple_specification); |
|
416 if (NULL != symbol->constant) { |
|
417 int typeoffset = search_in_candidate_datatype_list(datatype, symbol->constant->candidate_datatypes); |
|
418 if (typeoffset >= 0) |
|
419 symbol->constant->datatype = symbol->constant->candidate_datatypes[typeoffset]; |
|
420 } |
|
421 return NULL; |
|
422 } |
|
423 |
430 |
424 /*********************/ |
431 /*********************/ |
425 /* B 1.4 - Variables */ |
432 /* B 1.4 - Variables */ |
426 /*********************/ |
433 /*********************/ |
427 |
434 |
452 symbol->elements[i]->accept(*this); |
459 symbol->elements[i]->accept(*this); |
453 } |
460 } |
454 return NULL; |
461 return NULL; |
455 } |
462 } |
456 |
463 |
|
464 |
|
465 |
|
466 |
|
467 /******************************************/ |
|
468 /* B 1.4.3 - Declaration & Initialisation */ |
|
469 /******************************************/ |
|
470 |
|
471 void *narrow_candidate_datatypes_c::visit(var1_list_c *symbol) { |
|
472 #if 0 /* We don't really need to set the datatype of each variable. We just check the declaration itself! */ |
|
473 for(int i = 0; i < symbol->n; i++) { |
|
474 if (symbol->elements[i]->candidate_datatypes.size() == 1) |
|
475 symbol->elements[i]->datatype = symbol->elements[i]->candidate_datatypes[0]; |
|
476 } |
|
477 #endif |
|
478 return NULL; |
|
479 } |
|
480 |
|
481 |
|
482 /* AT direct_variable */ |
|
483 // SYM_REF1(location_c, direct_variable) |
|
484 void *narrow_candidate_datatypes_c::visit(location_c *symbol) { |
|
485 set_datatype(symbol->datatype, symbol->direct_variable); |
|
486 symbol->direct_variable->accept(*this); /* currently does nothing! */ |
|
487 return NULL; |
|
488 } |
|
489 |
|
490 |
|
491 /* [variable_name] location ':' located_var_spec_init */ |
|
492 /* variable_name -> may be NULL ! */ |
|
493 // SYM_REF3(located_var_decl_c, variable_name, location, located_var_spec_init) |
|
494 void *narrow_candidate_datatypes_c::visit(located_var_decl_c *symbol) { |
|
495 /* let the var_spec_init set its own symbol->datatype value */ |
|
496 symbol->located_var_spec_init->accept(*this); |
|
497 |
|
498 if (NULL != symbol->variable_name) |
|
499 set_datatype(symbol->located_var_spec_init->datatype, symbol->variable_name); |
|
500 |
|
501 set_datatype(symbol->located_var_spec_init->datatype, symbol->location); |
|
502 symbol->location->accept(*this); |
|
503 return NULL; |
|
504 } |
457 |
505 |
458 |
506 |
459 /************************************/ |
507 /************************************/ |
460 /* B 1.5 Program organization units */ |
508 /* B 1.5 Program organization units */ |
461 /************************************/ |
509 /************************************/ |