147 */ |
147 */ |
148 #define VAR_LEADER "__" |
148 #define VAR_LEADER "__" |
149 #define TEMP_VAR VAR_LEADER "TMP_" |
149 #define TEMP_VAR VAR_LEADER "TMP_" |
150 #define SOURCE_VAR VAR_LEADER "SRC_" |
150 #define SOURCE_VAR VAR_LEADER "SRC_" |
151 |
151 |
152 #include "generate_c_tempvardecl.cc" |
|
153 |
|
154 #include "generate_c_st.cc" |
152 #include "generate_c_st.cc" |
155 #include "generate_c_il.cc" |
153 #include "generate_c_il.cc" |
156 |
154 |
157 #include "generate_c.hh" |
155 #include "generate_c.hh" |
158 |
156 |
496 s4o.print("("); |
494 s4o.print("("); |
497 |
495 |
498 /* (A.3) Function parameters */ |
496 /* (A.3) Function parameters */ |
499 s4o.indent_right(); |
497 s4o.indent_right(); |
500 vardecl = new generate_c_vardecl_c(&s4o, |
498 vardecl = new generate_c_vardecl_c(&s4o, |
501 generate_c_vardecl_c::finterface_vf, |
499 generate_c_vardecl_c::finterface_vf, |
502 generate_c_vardecl_c::input_vt | |
500 generate_c_vardecl_c::input_vt | |
503 generate_c_vardecl_c::output_vt | |
501 generate_c_vardecl_c::output_vt | |
504 generate_c_vardecl_c::inoutput_vt | |
502 generate_c_vardecl_c::inoutput_vt | |
505 generate_c_vardecl_c::eneno_vt); |
503 generate_c_vardecl_c::en_vt | |
|
504 generate_c_vardecl_c::eno_vt); |
506 vardecl->print(symbol->var_declarations_list); |
505 vardecl->print(symbol->var_declarations_list); |
507 vardecl->print_eneno(); |
|
508 delete vardecl; |
506 delete vardecl; |
509 |
507 |
510 s4o.indent_left(); |
508 s4o.indent_left(); |
511 |
509 |
512 s4o.print(")\n" + s4o.indent_spaces + "{\n"); |
510 s4o.print(")\n" + s4o.indent_spaces + "{\n"); |
513 |
511 |
514 /* (B) Function local variable declaration */ |
512 /* (B) Function local variable declaration */ |
515 /* (B.1) Variables declared in ST source code */ |
513 /* (B.1) Variables declared in ST source code */ |
516 s4o.indent_right(); |
514 s4o.indent_right(); |
517 |
515 |
518 vardecl = new generate_c_vardecl_c(&s4o, |
516 vardecl = new generate_c_vardecl_c(&s4o, |
519 generate_c_vardecl_c::localinit_vf, |
517 generate_c_vardecl_c::localinit_vf, |
520 generate_c_vardecl_c::output_vt | |
518 generate_c_vardecl_c::output_vt | |
521 generate_c_vardecl_c::inoutput_vt | |
519 generate_c_vardecl_c::inoutput_vt | |
522 generate_c_vardecl_c::private_vt); |
520 generate_c_vardecl_c::private_vt | |
|
521 generate_c_vardecl_c::eno_vt); |
523 vardecl->print(symbol->var_declarations_list); |
522 vardecl->print(symbol->var_declarations_list); |
524 delete vardecl; |
523 delete vardecl; |
525 |
524 |
526 /* (B.2) Temporary variable for function's return value */ |
525 /* (B.2) Temporary variable for function's return value */ |
527 /* It will have the same name as the function itself! */ |
526 /* It will have the same name as the function itself! */ |
539 s4o.print(";\n\n"); |
538 s4o.print(";\n\n"); |
540 |
539 |
541 s4o.print(s4o.indent_spaces + "// Control execution\n"); |
540 s4o.print(s4o.indent_spaces + "// Control execution\n"); |
542 s4o.print(s4o.indent_spaces + "if (!EN) {\n"); |
541 s4o.print(s4o.indent_spaces + "if (!EN) {\n"); |
543 s4o.indent_right(); |
542 s4o.indent_right(); |
544 s4o.print(s4o.indent_spaces + "if (ENO != NULL) {\n"); |
543 s4o.print(s4o.indent_spaces + "if (__ENO != NULL) {\n"); |
545 s4o.indent_right(); |
544 s4o.indent_right(); |
546 s4o.print(s4o.indent_spaces + "*ENO = __BOOL_LITERAL(FALSE);\n"); |
545 s4o.print(s4o.indent_spaces + "*__ENO = __BOOL_LITERAL(FALSE);\n"); |
547 s4o.indent_left(); |
546 s4o.indent_left(); |
548 s4o.print(s4o.indent_spaces + "}\n"); |
547 s4o.print(s4o.indent_spaces + "}\n"); |
549 s4o.print(s4o.indent_spaces + "return "); |
548 s4o.print(s4o.indent_spaces + "return "); |
550 symbol->derived_function_name->accept(*this); |
549 symbol->derived_function_name->accept(*this); |
551 s4o.print(";\n"); |
550 s4o.print(";\n"); |
552 s4o.indent_left(); |
551 s4o.indent_left(); |
553 s4o.print(s4o.indent_spaces + "}\n"); |
552 s4o.print(s4o.indent_spaces + "}\n"); |
554 s4o.print(s4o.indent_spaces + "else {\n"); |
553 |
555 s4o.indent_right(); |
|
556 s4o.print(s4o.indent_spaces + "if (ENO != NULL) {\n"); |
|
557 s4o.indent_right(); |
|
558 s4o.print(s4o.indent_spaces + "*ENO = __BOOL_LITERAL(TRUE);\n"); |
|
559 s4o.indent_left(); |
|
560 s4o.print(s4o.indent_spaces + "}\n"); |
|
561 s4o.indent_left(); |
|
562 s4o.print(s4o.indent_spaces + "}\n"); |
|
563 |
|
564 /* (C) Function body */ |
554 /* (C) Function body */ |
565 generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol); |
555 generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol); |
566 symbol->function_body->accept(generate_c_code); |
556 symbol->function_body->accept(generate_c_code); |
567 |
557 |
568 vardecl = new generate_c_vardecl_c(&s4o, |
558 vardecl = new generate_c_vardecl_c(&s4o, |
569 generate_c_vardecl_c::foutputassign_vf, |
559 generate_c_vardecl_c::foutputassign_vf, |
570 generate_c_vardecl_c::output_vt | |
560 generate_c_vardecl_c::output_vt | |
571 generate_c_vardecl_c::inoutput_vt); |
561 generate_c_vardecl_c::inoutput_vt | |
|
562 generate_c_vardecl_c::eno_vt); |
572 vardecl->print(symbol->var_declarations_list); |
563 vardecl->print(symbol->var_declarations_list); |
573 delete vardecl; |
564 delete vardecl; |
574 |
565 |
575 s4o.print(s4o.indent_spaces + "return "); |
566 s4o.print(s4o.indent_spaces + "return "); |
576 symbol->derived_function_name->accept(*this); |
567 symbol->derived_function_name->accept(*this); |
608 s4o_incl.print("typedef struct {\n"); |
599 s4o_incl.print("typedef struct {\n"); |
609 s4o_incl.indent_right(); |
600 s4o_incl.indent_right(); |
610 /* (A.2) Public variables: i.e. the function parameters... */ |
601 /* (A.2) Public variables: i.e. the function parameters... */ |
611 s4o_incl.print(s4o_incl.indent_spaces + "// FB Interface - IN, OUT, IN_OUT variables\n"); |
602 s4o_incl.print(s4o_incl.indent_spaces + "// FB Interface - IN, OUT, IN_OUT variables\n"); |
612 vardecl = new generate_c_vardecl_c(&s4o_incl, |
603 vardecl = new generate_c_vardecl_c(&s4o_incl, |
613 generate_c_vardecl_c::local_vf, |
604 generate_c_vardecl_c::local_vf, |
614 generate_c_vardecl_c::input_vt | |
605 generate_c_vardecl_c::input_vt | |
615 generate_c_vardecl_c::output_vt | |
606 generate_c_vardecl_c::output_vt | |
616 generate_c_vardecl_c::inoutput_vt | |
607 generate_c_vardecl_c::inoutput_vt | |
617 generate_c_vardecl_c::eneno_vt); |
608 generate_c_vardecl_c::en_vt | |
|
609 generate_c_vardecl_c::eno_vt); |
618 vardecl->print(symbol->var_declarations); |
610 vardecl->print(symbol->var_declarations); |
619 vardecl->print_eneno(); |
|
620 delete vardecl; |
611 delete vardecl; |
621 s4o_incl.print("\n"); |
612 s4o_incl.print("\n"); |
622 /* (A.3) Private internal variables */ |
613 /* (A.3) Private internal variables */ |
623 s4o_incl.print(s4o_incl.indent_spaces + "// FB private variables - TEMP, private and located variables\n"); |
614 s4o_incl.print(s4o_incl.indent_spaces + "// FB private variables - TEMP, private and located variables\n"); |
624 vardecl = new generate_c_vardecl_c(&s4o_incl, |
615 vardecl = new generate_c_vardecl_c(&s4o_incl, |
625 generate_c_vardecl_c::local_vf, |
616 generate_c_vardecl_c::local_vf, |
626 generate_c_vardecl_c::temp_vt | |
617 generate_c_vardecl_c::temp_vt | |
627 generate_c_vardecl_c::private_vt | |
618 generate_c_vardecl_c::private_vt | |
628 generate_c_vardecl_c::located_vt | |
619 generate_c_vardecl_c::located_vt | |
629 generate_c_vardecl_c::external_vt); |
620 generate_c_vardecl_c::external_vt); |
630 vardecl->print(symbol->var_declarations); |
621 vardecl->print(symbol->var_declarations); |
631 delete vardecl; |
622 delete vardecl; |
632 |
623 |
633 /* (A.4) Generate private internal variables for SFC */ |
624 /* (A.4) Generate private internal variables for SFC */ |
634 sfcdecl = new generate_c_sfcdecl_c(&s4o_incl, generate_c_sfcdecl_c::sfcdecl_sd); |
625 sfcdecl = new generate_c_sfcdecl_c(&s4o_incl, generate_c_sfcdecl_c::sfcdecl_sd); |
658 s4o.indent_right(); |
649 s4o.indent_right(); |
659 |
650 |
660 /* (B.2) Member initializations... */ |
651 /* (B.2) Member initializations... */ |
661 s4o.print(s4o.indent_spaces); |
652 s4o.print(s4o.indent_spaces); |
662 vardecl = new generate_c_vardecl_c(&s4o, |
653 vardecl = new generate_c_vardecl_c(&s4o, |
663 generate_c_vardecl_c::constructorinit_vf, |
654 generate_c_vardecl_c::constructorinit_vf, |
664 generate_c_vardecl_c::input_vt | |
655 generate_c_vardecl_c::input_vt | |
665 generate_c_vardecl_c::output_vt | |
656 generate_c_vardecl_c::output_vt | |
666 generate_c_vardecl_c::inoutput_vt | |
657 generate_c_vardecl_c::inoutput_vt | |
667 generate_c_vardecl_c::private_vt | |
658 generate_c_vardecl_c::private_vt | |
668 generate_c_vardecl_c::located_vt | |
659 generate_c_vardecl_c::located_vt | |
669 generate_c_vardecl_c::external_vt | |
660 generate_c_vardecl_c::external_vt | |
670 generate_c_vardecl_c::eneno_vt); |
661 generate_c_vardecl_c::en_vt | |
|
662 generate_c_vardecl_c::eno_vt); |
671 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
663 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
672 if (!vardecl->is_en_declared()) { |
|
673 s4o.print("\n" + s4o.indent_spaces); |
|
674 s4o.print(FB_FUNCTION_PARAM); |
|
675 s4o.print("->EN = __BOOL_LITERAL(TRUE);"); |
|
676 } |
|
677 if (!vardecl->is_eno_declared()) { |
|
678 s4o.print("\n" + s4o.indent_spaces); |
|
679 s4o.print(FB_FUNCTION_PARAM); |
|
680 s4o.print("->ENO = __BOOL_LITERAL(TRUE);"); |
|
681 } |
|
682 delete vardecl; |
664 delete vardecl; |
683 s4o.print("\n"); |
665 s4o.print("\n"); |
684 /* (B.3) Generate private internal variables for SFC */ |
666 /* (B.3) Generate private internal variables for SFC */ |
685 sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::sfcinit_sd); |
667 sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::sfcinit_sd); |
686 sfcdecl->print(symbol->fblock_body, FB_FUNCTION_PARAM"->"); |
668 sfcdecl->print(symbol->fblock_body, FB_FUNCTION_PARAM"->"); |
735 |
717 |
736 /* (C.4) Initialize TEMP variables */ |
718 /* (C.4) Initialize TEMP variables */ |
737 /* function body */ |
719 /* function body */ |
738 s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n"); |
720 s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n"); |
739 vardecl = new generate_c_vardecl_c(&s4o, |
721 vardecl = new generate_c_vardecl_c(&s4o, |
740 generate_c_vardecl_c::init_vf, |
722 generate_c_vardecl_c::init_vf, |
741 generate_c_vardecl_c::temp_vt); |
723 generate_c_vardecl_c::temp_vt); |
742 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
724 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
743 delete vardecl; |
725 delete vardecl; |
744 s4o.print("\n"); |
726 s4o.print("\n"); |
745 |
727 |
746 /* (C.5) Function code */ |
728 /* (C.5) Function code */ |
799 s4o_incl.indent_right(); |
781 s4o_incl.indent_right(); |
800 |
782 |
801 /* (A.2) Public variables: i.e. the program parameters... */ |
783 /* (A.2) Public variables: i.e. the program parameters... */ |
802 s4o_incl.print(s4o_incl.indent_spaces + "// PROGRAM Interface - IN, OUT, IN_OUT variables\n"); |
784 s4o_incl.print(s4o_incl.indent_spaces + "// PROGRAM Interface - IN, OUT, IN_OUT variables\n"); |
803 vardecl = new generate_c_vardecl_c(&s4o_incl, |
785 vardecl = new generate_c_vardecl_c(&s4o_incl, |
804 generate_c_vardecl_c::local_vf, |
786 generate_c_vardecl_c::local_vf, |
805 generate_c_vardecl_c::input_vt | |
787 generate_c_vardecl_c::input_vt | |
806 generate_c_vardecl_c::output_vt | |
788 generate_c_vardecl_c::output_vt | |
807 generate_c_vardecl_c::inoutput_vt); |
789 generate_c_vardecl_c::inoutput_vt); |
808 vardecl->print(symbol->var_declarations); |
790 vardecl->print(symbol->var_declarations); |
809 delete vardecl; |
791 delete vardecl; |
810 s4o_incl.print("\n"); |
792 s4o_incl.print("\n"); |
811 /* (A.3) Private internal variables */ |
793 /* (A.3) Private internal variables */ |
812 s4o_incl.print(s4o_incl.indent_spaces + "// PROGRAM private variables - TEMP, private and located variables\n"); |
794 s4o_incl.print(s4o_incl.indent_spaces + "// PROGRAM private variables - TEMP, private and located variables\n"); |
813 vardecl = new generate_c_vardecl_c(&s4o_incl, |
795 vardecl = new generate_c_vardecl_c(&s4o_incl, |
814 generate_c_vardecl_c::local_vf, |
796 generate_c_vardecl_c::local_vf, |
815 generate_c_vardecl_c::temp_vt | |
797 generate_c_vardecl_c::temp_vt | |
816 generate_c_vardecl_c::private_vt | |
798 generate_c_vardecl_c::private_vt | |
817 generate_c_vardecl_c::located_vt | |
799 generate_c_vardecl_c::located_vt | |
818 generate_c_vardecl_c::external_vt); |
800 generate_c_vardecl_c::external_vt); |
819 vardecl->print(symbol->var_declarations); |
801 vardecl->print(symbol->var_declarations); |
820 delete vardecl; |
802 delete vardecl; |
845 s4o.indent_right(); |
827 s4o.indent_right(); |
846 |
828 |
847 /* (B.2) Member initializations... */ |
829 /* (B.2) Member initializations... */ |
848 s4o.print(s4o.indent_spaces); |
830 s4o.print(s4o.indent_spaces); |
849 vardecl = new generate_c_vardecl_c(&s4o, |
831 vardecl = new generate_c_vardecl_c(&s4o, |
850 generate_c_vardecl_c::constructorinit_vf, |
832 generate_c_vardecl_c::constructorinit_vf, |
851 generate_c_vardecl_c::input_vt | |
833 generate_c_vardecl_c::input_vt | |
852 generate_c_vardecl_c::output_vt | |
834 generate_c_vardecl_c::output_vt | |
853 generate_c_vardecl_c::inoutput_vt | |
835 generate_c_vardecl_c::inoutput_vt | |
854 generate_c_vardecl_c::private_vt | |
836 generate_c_vardecl_c::private_vt | |
855 generate_c_vardecl_c::located_vt | |
837 generate_c_vardecl_c::located_vt | |
856 generate_c_vardecl_c::external_vt); |
838 generate_c_vardecl_c::external_vt); |
857 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
839 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
858 delete vardecl; |
840 delete vardecl; |
859 s4o.print("\n"); |
841 s4o.print("\n"); |
860 /* (B.3) Generate private internal variables for SFC */ |
842 /* (B.3) Generate private internal variables for SFC */ |
861 sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::sfcinit_sd); |
843 sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::sfcinit_sd); |
892 |
874 |
893 /* (C.4) Initialize TEMP variables */ |
875 /* (C.4) Initialize TEMP variables */ |
894 /* function body */ |
876 /* function body */ |
895 s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n"); |
877 s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n"); |
896 vardecl = new generate_c_vardecl_c(&s4o, |
878 vardecl = new generate_c_vardecl_c(&s4o, |
897 generate_c_vardecl_c::init_vf, |
879 generate_c_vardecl_c::init_vf, |
898 generate_c_vardecl_c::temp_vt); |
880 generate_c_vardecl_c::temp_vt); |
899 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
881 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
900 delete vardecl; |
882 delete vardecl; |
901 s4o.print("\n"); |
883 s4o.print("\n"); |
902 |
884 |
903 /* (C.5) Function code */ |
885 /* (C.5) Function code */ |
985 symbol->configuration_name->accept(*this); |
967 symbol->configuration_name->accept(*this); |
986 s4o.print("\n"); |
968 s4o.print("\n"); |
987 |
969 |
988 /* (A.2) Global variables */ |
970 /* (A.2) Global variables */ |
989 vardecl = new generate_c_vardecl_c(&s4o, |
971 vardecl = new generate_c_vardecl_c(&s4o, |
990 generate_c_vardecl_c::local_vf, |
972 generate_c_vardecl_c::local_vf, |
991 generate_c_vardecl_c::global_vt); |
973 generate_c_vardecl_c::global_vt); |
992 vardecl->print(symbol); |
974 vardecl->print(symbol); |
993 delete vardecl; |
975 delete vardecl; |
994 s4o.print("\n"); |
976 s4o.print("\n"); |
995 |
977 |
996 /* (B) Initialisation Function */ |
978 /* (B) Initialisation Function */ |
1006 s4o.indent_right(); |
988 s4o.indent_right(); |
1007 |
989 |
1008 /* (B.3) Global variables initializations... */ |
990 /* (B.3) Global variables initializations... */ |
1009 s4o.print(s4o.indent_spaces); |
991 s4o.print(s4o.indent_spaces); |
1010 vardecl = new generate_c_vardecl_c(&s4o, |
992 vardecl = new generate_c_vardecl_c(&s4o, |
1011 generate_c_vardecl_c::constructorinit_vf, |
993 generate_c_vardecl_c::constructorinit_vf, |
1012 generate_c_vardecl_c::global_vt); |
994 generate_c_vardecl_c::global_vt); |
1013 vardecl->print(symbol); |
995 vardecl->print(symbol); |
1014 delete vardecl; |
996 delete vardecl; |
1015 s4o.print("\n"); |
997 s4o.print("\n"); |
1016 |
998 |
1017 /* (B.3) Resources initializations... */ |
999 /* (B.3) Resources initializations... */ |
1123 symbol_c *current_global_vars; |
1105 symbol_c *current_global_vars; |
1124 |
1106 |
1125 public: |
1107 public: |
1126 generate_c_resources_c(stage4out_c *s4o_ptr, symbol_c *config_scope, symbol_c *resource_scope, unsigned long time) |
1108 generate_c_resources_c(stage4out_c *s4o_ptr, symbol_c *config_scope, symbol_c *resource_scope, unsigned long time) |
1127 : generate_c_typedecl_c(s4o_ptr) { |
1109 : generate_c_typedecl_c(s4o_ptr) { |
1128 search_config_instance = new search_var_instance_decl_c(config_scope); |
1110 search_config_instance = new search_var_instance_decl_c(config_scope); |
1129 search_resource_instance = new search_var_instance_decl_c(resource_scope); |
1111 search_resource_instance = new search_var_instance_decl_c(resource_scope); |
1130 common_ticktime = time; |
1112 common_ticktime = time; |
1131 current_resource_name = NULL; |
1113 current_resource_name = NULL; |
1132 current_task_name = NULL; |
1114 current_task_name = NULL; |
1133 current_global_vars = NULL; |
1115 current_global_vars = NULL; |
1179 } |
1161 } |
1180 |
1162 |
1181 /* task_configuration_list program_configuration_list */ |
1163 /* task_configuration_list program_configuration_list */ |
1182 // SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list) |
1164 // SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list) |
1183 void *visit(single_resource_declaration_c *symbol) { |
1165 void *visit(single_resource_declaration_c *symbol) { |
1184 bool single_resource = current_resource_name == NULL; |
1166 bool single_resource = current_resource_name == NULL; |
1185 if (single_resource) |
1167 if (single_resource) |
1186 current_resource_name = new identifier_c("RESOURCE"); |
1168 current_resource_name = new identifier_c("RESOURCE"); |
1187 generate_c_vardecl_c *vardecl; |
1169 generate_c_vardecl_c *vardecl; |
1188 |
1170 |
1189 /* Insert the header... */ |
1171 /* Insert the header... */ |
1202 s4o.print("extern int common_ticktime__;\n\n"); |
1184 s4o.print("extern int common_ticktime__;\n\n"); |
1203 |
1185 |
1204 /* (A.2) Global variables... */ |
1186 /* (A.2) Global variables... */ |
1205 if (current_global_vars != NULL) { |
1187 if (current_global_vars != NULL) { |
1206 vardecl = new generate_c_vardecl_c(&s4o, |
1188 vardecl = new generate_c_vardecl_c(&s4o, |
1207 generate_c_vardecl_c::local_vf, |
1189 generate_c_vardecl_c::local_vf, |
1208 generate_c_vardecl_c::global_vt, |
1190 generate_c_vardecl_c::global_vt, |
1209 current_resource_name); |
1191 current_resource_name); |
1210 vardecl->print(current_global_vars); |
1192 vardecl->print(current_global_vars); |
1211 delete vardecl; |
1193 delete vardecl; |
1212 s4o.print("\n"); |
1194 s4o.print("\n"); |
1213 } |
1195 } |
1214 |
1196 |
1236 |
1218 |
1237 /* (B.2) Global variables initialisations... */ |
1219 /* (B.2) Global variables initialisations... */ |
1238 if (current_global_vars != NULL) { |
1220 if (current_global_vars != NULL) { |
1239 s4o.print(s4o.indent_spaces); |
1221 s4o.print(s4o.indent_spaces); |
1240 vardecl = new generate_c_vardecl_c(&s4o, |
1222 vardecl = new generate_c_vardecl_c(&s4o, |
1241 generate_c_vardecl_c::constructorinit_vf, |
1223 generate_c_vardecl_c::constructorinit_vf, |
1242 generate_c_vardecl_c::global_vt); |
1224 generate_c_vardecl_c::global_vt); |
1243 vardecl->print(current_global_vars); |
1225 vardecl->print(current_global_vars); |
1244 delete vardecl; |
1226 delete vardecl; |
1245 } |
1227 } |
1246 s4o.print("\n"); |
1228 s4o.print("\n"); |
1247 |
1229 |
1473 else |
1455 else |
1474 vartype = search_resource_instance->get_vartype(); |
1456 vartype = search_resource_instance->get_vartype(); |
1475 |
1457 |
1476 s4o.print(s4o.indent_spaces + "{extern "); |
1458 s4o.print(s4o.indent_spaces + "{extern "); |
1477 var_decl->accept(*this); |
1459 var_decl->accept(*this); |
1478 s4o.print(" "); |
1460 s4o.print(" *"); |
1479 symbol->prog_data_source->accept(*this); |
1461 symbol->prog_data_source->accept(*this); |
1480 s4o.print("; "); |
1462 s4o.print("; "); |
1481 s4o.print(current_program_name); |
1463 s4o.printupper(current_program_name); |
1482 s4o.print("."); |
1464 s4o.print("."); |
1483 symbol->symbolic_variable->accept(*this); |
1465 symbol->symbolic_variable->accept(*this); |
1484 s4o.print(" = "); |
1466 s4o.print(" = "); |
1485 if (vartype || search_var_instance_decl_c::global_vt) |
1467 if (vartype || search_var_instance_decl_c::global_vt) |
1486 s4o.print("*"); |
1468 s4o.print("*"); |
1506 vartype = search_config_instance->get_vartype(); |
1488 vartype = search_config_instance->get_vartype(); |
1507 } |
1489 } |
1508 else |
1490 else |
1509 vartype = search_resource_instance->get_vartype(); |
1491 vartype = search_resource_instance->get_vartype(); |
1510 |
1492 |
1511 s4o.print(s4o.indent_spaces); |
|
1512 s4o.print(s4o.indent_spaces + "{extern "); |
1493 s4o.print(s4o.indent_spaces + "{extern "); |
1513 var_decl->accept(*this); |
1494 var_decl->accept(*this); |
1514 s4o.print(" "); |
1495 s4o.print(" *"); |
1515 symbol->data_sink->accept(*this); |
1496 symbol->data_sink->accept(*this); |
1516 s4o.print("; "); |
1497 s4o.print("; "); |
1517 if (vartype || search_var_instance_decl_c::global_vt) |
1498 if (vartype || search_var_instance_decl_c::global_vt) |
1518 s4o.print("*"); |
1499 s4o.print("*"); |
1519 symbol->data_sink->accept(*this); |
1500 symbol->data_sink->accept(*this); |
1520 s4o.print(" = "); |
1501 s4o.print(" = "); |
1521 s4o.print(current_program_name); |
1502 s4o.printupper(current_program_name); |
1522 s4o.print("."); |
1503 s4o.print("."); |
1523 symbol->symbolic_variable->accept(*this); |
1504 symbol->symbolic_variable->accept(*this); |
1524 s4o.print("};\n"); |
1505 s4o.print(";};\n"); |
1525 } |
1506 } |
1526 return NULL; |
1507 return NULL; |
1527 } |
1508 } |
1528 |
1509 |
1529 }; |
1510 }; |
1666 |
1647 |
1667 return NULL; |
1648 return NULL; |
1668 } |
1649 } |
1669 |
1650 |
1670 void *visit(resource_declaration_c *symbol) { |
1651 void *visit(resource_declaration_c *symbol) { |
1671 symbol->resource_name->accept(*this); |
1652 symbol->resource_name->accept(*this); |
1672 stage4out_c resources_s4o(current_builddir, current_name, "c"); |
1653 stage4out_c resources_s4o(current_builddir, current_name, "c"); |
1673 generate_c_resources_c generate_c_resources(&resources_s4o, current_configuration, symbol, common_ticktime); |
1654 generate_c_resources_c generate_c_resources(&resources_s4o, current_configuration, symbol, common_ticktime); |
1674 symbol->accept(generate_c_resources); |
1655 symbol->accept(generate_c_resources); |
1675 return NULL; |
1656 return NULL; |
1676 } |
1657 } |
1677 |
1658 |
1678 void *visit(single_resource_declaration_c *symbol) { |
1659 void *visit(single_resource_declaration_c *symbol) { |
1679 stage4out_c resources_s4o(current_builddir, "RESOURCE", "c"); |
1660 stage4out_c resources_s4o(current_builddir, "RESOURCE", "c"); |
1680 generate_c_resources_c generate_c_resources(&resources_s4o, current_configuration, symbol, common_ticktime); |
1661 generate_c_resources_c generate_c_resources(&resources_s4o, current_configuration, symbol, common_ticktime); |
1681 symbol->accept(generate_c_resources); |
1662 symbol->accept(generate_c_resources); |
1682 return NULL; |
1663 return NULL; |
1683 } |
1664 } |
1684 |
1665 |
1685 }; |
1666 }; |
1686 |
1667 |
1687 /***********************************************************************/ |
1668 /***********************************************************************/ |