527 /* B 1.3 - Data types */ |
527 /* B 1.3 - Data types */ |
528 /**********************/ |
528 /**********************/ |
529 /********************************/ |
529 /********************************/ |
530 /* B 1.3.3 - Derived data types */ |
530 /* B 1.3.3 - Derived data types */ |
531 /********************************/ |
531 /********************************/ |
|
532 void *print_datatypes_error_c::visit(simple_spec_init_c *symbol) { |
|
533 if (!is_type_valid(symbol->simple_specification->datatype)) { |
|
534 STAGE3_ERROR(0, symbol->simple_specification, symbol->simple_specification, "Invalid data type."); |
|
535 } else if (NULL != symbol->constant) { |
|
536 if (!is_type_valid(symbol->constant->datatype)) |
|
537 STAGE3_ERROR(0, symbol->constant, symbol->constant, "Initial value has incompatible data type."); |
|
538 } else if (!is_type_valid(symbol->datatype)) { |
|
539 ERROR; /* If we have an error here, then we must also have an error in one of |
|
540 * the two previous tests. If we reach this point, some strange error is ocurring! |
|
541 */ |
|
542 } |
|
543 return NULL; |
|
544 } |
|
545 |
532 void *print_datatypes_error_c::visit(data_type_declaration_c *symbol) { |
546 void *print_datatypes_error_c::visit(data_type_declaration_c *symbol) { |
533 // TODO !!! |
547 // TODO !!! |
534 /* for the moment we must return NULL so semantic analysis of remaining code is not interrupted! */ |
548 /* for the moment we must return NULL so semantic analysis of remaining code is not interrupted! */ |
535 return NULL; |
549 return NULL; |
536 } |
550 } |
553 |
567 |
554 /********************************************/ |
568 /********************************************/ |
555 /* B 1.4.1 - Directly Represented Variables */ |
569 /* B 1.4.1 - Directly Represented Variables */ |
556 /********************************************/ |
570 /********************************************/ |
557 void *print_datatypes_error_c::visit(direct_variable_c *symbol) { |
571 void *print_datatypes_error_c::visit(direct_variable_c *symbol) { |
558 if (symbol->candidate_datatypes.size() == 0) |
572 if (symbol->candidate_datatypes.size() == 0) ERROR; |
559 STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for located variable data type."); |
573 if (!is_type_valid(symbol->datatype)) |
|
574 STAGE3_ERROR(4, symbol, symbol, "Direct variable has incompatible data type with expression."); |
560 return NULL; |
575 return NULL; |
561 } |
576 } |
562 |
577 |
563 /*************************************/ |
578 /*************************************/ |
564 /* B 1.4.2 - Multi-element variables */ |
579 /* B 1.4.2 - Multi-element variables */ |
594 void *print_datatypes_error_c::visit(structured_variable_c *symbol) { |
609 void *print_datatypes_error_c::visit(structured_variable_c *symbol) { |
595 if (symbol->candidate_datatypes.size() == 0) |
610 if (symbol->candidate_datatypes.size() == 0) |
596 STAGE3_ERROR(0, symbol, symbol, "Undeclared structured/FB variable."); |
611 STAGE3_ERROR(0, symbol, symbol, "Undeclared structured/FB variable."); |
597 return NULL; |
612 return NULL; |
598 } |
613 } |
|
614 |
|
615 |
|
616 |
|
617 /******************************************/ |
|
618 /* B 1.4.3 - Declaration & Initialisation */ |
|
619 /******************************************/ |
|
620 |
|
621 /* AT direct_variable */ |
|
622 // SYM_REF1(location_c, direct_variable) |
|
623 void *print_datatypes_error_c::visit(location_c *symbol) { |
|
624 symbol->direct_variable->accept(*this); |
|
625 return NULL; |
|
626 } |
|
627 |
|
628 |
|
629 /* [variable_name] location ':' located_var_spec_init */ |
|
630 /* variable_name -> may be NULL ! */ |
|
631 // SYM_REF3(located_var_decl_c, variable_name, location, located_var_spec_init) |
|
632 void *print_datatypes_error_c::visit(located_var_decl_c *symbol) { |
|
633 symbol->located_var_spec_init->accept(*this); |
|
634 /* It does not make sense to call symbol->location->accept(*this). The check is done right here if the following if() */ |
|
635 // symbol->location->accept(*this); |
|
636 if ((is_type_valid(symbol->located_var_spec_init->datatype)) && (!is_type_valid(symbol->location->datatype))) |
|
637 STAGE3_ERROR(0, symbol, symbol, "Location is incompatible with data type."); |
|
638 return NULL; |
|
639 } |
|
640 |
599 |
641 |
600 /************************************/ |
642 /************************************/ |
601 /* B 1.5 Program organization units */ |
643 /* B 1.5 Program organization units */ |
602 /************************************/ |
644 /************************************/ |
603 /*********************/ |
645 /*********************/ |
636 /* B 1.5.3 - Programs */ |
678 /* B 1.5.3 - Programs */ |
637 /**********************/ |
679 /**********************/ |
638 void *print_datatypes_error_c::visit(program_declaration_c *symbol) { |
680 void *print_datatypes_error_c::visit(program_declaration_c *symbol) { |
639 search_varfb_instance_type = new search_varfb_instance_type_c(symbol); |
681 search_varfb_instance_type = new search_varfb_instance_type_c(symbol); |
640 /* We do not check for data type errors in variable declarations, Skip this for now... */ |
682 /* We do not check for data type errors in variable declarations, Skip this for now... */ |
641 // symbol->var_declarations->accept(*this); |
683 symbol->var_declarations->accept(*this); |
642 if (debug) printf("Print error data types list in body of program %s\n", ((token_c *)(symbol->program_type_name))->value); |
684 if (debug) printf("Print error data types list in body of program %s\n", ((token_c *)(symbol->program_type_name))->value); |
643 il_parenthesis_level = 0; |
685 il_parenthesis_level = 0; |
644 il_error = false; |
686 il_error = false; |
645 symbol->function_block_body->accept(*this); |
687 symbol->function_block_body->accept(*this); |
646 delete search_varfb_instance_type; |
688 delete search_varfb_instance_type; |