649 /*********************/ |
650 /*********************/ |
650 /* B 1.4 - Variables */ |
651 /* B 1.4 - Variables */ |
651 /*********************/ |
652 /*********************/ |
652 // SYM_REF1(symbolic_variable_c, var_name) |
653 // SYM_REF1(symbolic_variable_c, var_name) |
653 void *narrow_candidate_datatypes_c::visit(symbolic_variable_c *symbol) { |
654 void *narrow_candidate_datatypes_c::visit(symbolic_variable_c *symbol) { |
|
655 symbol->scope = current_scope; // the scope in which this variable was declared! |
654 symbol->var_name->datatype = symbol->datatype; |
656 symbol->var_name->datatype = symbol->datatype; |
655 return NULL; |
657 return NULL; |
656 } |
658 } |
657 /********************************************/ |
659 /********************************************/ |
658 /* B 1.4.1 - Directly Represented Variables */ |
660 /* B 1.4.1 - Directly Represented Variables */ |
762 void *narrow_candidate_datatypes_c::visit(function_declaration_c *symbol) { |
767 void *narrow_candidate_datatypes_c::visit(function_declaration_c *symbol) { |
763 /* set the function_declaration_c->datatype to the datatype returned by the function! */ |
768 /* set the function_declaration_c->datatype to the datatype returned by the function! */ |
764 symbol->type_name->datatype = search_base_type_c::get_basetype_decl(symbol->type_name); |
769 symbol->type_name->datatype = search_base_type_c::get_basetype_decl(symbol->type_name); |
765 symbol->datatype = symbol->type_name->datatype; |
770 symbol->datatype = symbol->type_name->datatype; |
766 |
771 |
|
772 current_scope = symbol; |
767 search_varfb_instance_type = new search_varfb_instance_type_c(symbol); |
773 search_varfb_instance_type = new search_varfb_instance_type_c(symbol); |
768 symbol->var_declarations_list->accept(*this); |
774 symbol->var_declarations_list->accept(*this); |
769 if (debug) printf("Narrowing candidate data types list in body of function %s\n", ((token_c *)(symbol->derived_function_name))->value); |
775 if (debug) printf("Narrowing candidate data types list in body of function %s\n", ((token_c *)(symbol->derived_function_name))->value); |
770 symbol->function_body->accept(*this); |
776 symbol->function_body->accept(*this); |
771 delete search_varfb_instance_type; |
777 delete search_varfb_instance_type; |
772 search_varfb_instance_type = NULL; |
778 search_varfb_instance_type = NULL; |
|
779 current_scope = NULL; |
773 return NULL; |
780 return NULL; |
774 } |
781 } |
775 |
782 |
776 /***************************/ |
783 /***************************/ |
777 /* B 1.5.2 Function blocks */ |
784 /* B 1.5.2 Function blocks */ |
778 /***************************/ |
785 /***************************/ |
779 void *narrow_candidate_datatypes_c::visit(function_block_declaration_c *symbol) { |
786 void *narrow_candidate_datatypes_c::visit(function_block_declaration_c *symbol) { |
|
787 current_scope = symbol; |
780 search_varfb_instance_type = new search_varfb_instance_type_c(symbol); |
788 search_varfb_instance_type = new search_varfb_instance_type_c(symbol); |
781 symbol->var_declarations->accept(*this); |
789 symbol->var_declarations->accept(*this); |
782 if (debug) printf("Narrowing candidate data types list in body of FB %s\n", ((token_c *)(symbol->fblock_name))->value); |
790 if (debug) printf("Narrowing candidate data types list in body of FB %s\n", ((token_c *)(symbol->fblock_name))->value); |
783 symbol->fblock_body->accept(*this); |
791 symbol->fblock_body->accept(*this); |
784 delete search_varfb_instance_type; |
792 delete search_varfb_instance_type; |
785 search_varfb_instance_type = NULL; |
793 search_varfb_instance_type = NULL; |
786 |
794 current_scope = NULL; |
|
795 |
787 // A FB declaration can also be used as a Datatype! We now do the narrow algorithm considering it as such! |
796 // A FB declaration can also be used as a Datatype! We now do the narrow algorithm considering it as such! |
788 if (symbol->candidate_datatypes.size() == 1) |
797 if (symbol->candidate_datatypes.size() == 1) |
789 symbol->datatype = symbol->candidate_datatypes[0]; |
798 symbol->datatype = symbol->candidate_datatypes[0]; |
790 return NULL; |
799 return NULL; |
791 } |
800 } |
792 |
801 |
793 /********************/ |
802 /********************/ |
794 /* B 1.5.3 Programs */ |
803 /* B 1.5.3 Programs */ |
795 /********************/ |
804 /********************/ |
796 void *narrow_candidate_datatypes_c::visit(program_declaration_c *symbol) { |
805 void *narrow_candidate_datatypes_c::visit(program_declaration_c *symbol) { |
|
806 current_scope = symbol; |
797 search_varfb_instance_type = new search_varfb_instance_type_c(symbol); |
807 search_varfb_instance_type = new search_varfb_instance_type_c(symbol); |
798 symbol->var_declarations->accept(*this); |
808 symbol->var_declarations->accept(*this); |
799 if (debug) printf("Narrowing candidate data types list in body of program %s\n", ((token_c *)(symbol->program_type_name))->value); |
809 if (debug) printf("Narrowing candidate data types list in body of program %s\n", ((token_c *)(symbol->program_type_name))->value); |
800 symbol->function_block_body->accept(*this); |
810 symbol->function_block_body->accept(*this); |
801 delete search_varfb_instance_type; |
811 delete search_varfb_instance_type; |
802 search_varfb_instance_type = NULL; |
812 search_varfb_instance_type = NULL; |
|
813 current_scope = NULL; |
803 return NULL; |
814 return NULL; |
804 } |
815 } |
805 |
816 |
806 /********************************************/ |
817 /********************************************/ |
807 /* B 1.6 Sequential function chart elements */ |
818 /* B 1.6 Sequential function chart elements */ |