540 s4o.print("} "); |
540 s4o.print("} "); |
541 symbol->fblock_name->accept(*this); |
541 symbol->fblock_name->accept(*this); |
542 s4o.print(";\n\n"); |
542 s4o.print(";\n\n"); |
543 |
543 |
544 |
544 |
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 /* (B) Constructor */ |
545 /* (B) Constructor */ |
554 /* (B.1) Constructor name... */ |
546 /* (B.1) Constructor name... */ |
555 s4o.print(s4o.indent_spaces + "void "); |
547 s4o.print(s4o.indent_spaces + "void "); |
556 symbol->fblock_name->accept(*this); |
548 symbol->fblock_name->accept(*this); |
557 s4o.print(FB_INIT_SUFFIX); |
549 s4o.print(FB_INIT_SUFFIX); |
577 delete vardecl; |
569 delete vardecl; |
578 s4o.indent_left(); |
570 s4o.indent_left(); |
579 s4o.print("\n" + s4o.indent_spaces + "}\n\n"); |
571 s4o.print("\n" + s4o.indent_spaces + "}\n\n"); |
580 |
572 |
581 |
573 |
582 |
574 /* (C) Function with FB body */ |
583 |
575 /* (C.1) Function declaration */ |
584 |
|
585 |
|
586 /* (B) Function with FB body */ |
|
587 /* (B.1) Function declaration */ |
|
588 s4o.print("// Code part\n"); |
576 s4o.print("// Code part\n"); |
589 /* function interface */ |
577 /* function interface */ |
590 s4o.print("void "); |
578 s4o.print("void "); |
591 symbol->fblock_name->accept(*this); |
579 symbol->fblock_name->accept(*this); |
592 s4o.print(FB_FUNCTION_SUFFIX); |
580 s4o.print(FB_FUNCTION_SUFFIX); |
596 s4o.print(" *"); |
584 s4o.print(" *"); |
597 s4o.print(FB_FUNCTION_PARAM); |
585 s4o.print(FB_FUNCTION_PARAM); |
598 s4o.print(") {\n"); |
586 s4o.print(") {\n"); |
599 s4o.indent_right(); |
587 s4o.indent_right(); |
600 |
588 |
601 /* (B.2) Initialize TEMP variables */ |
589 /* (C.2) Initialize TEMP variables */ |
602 /* function body */ |
590 /* function body */ |
603 s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n"); |
591 s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n"); |
604 vardecl = new generate_cc_vardecl_c(&s4o, |
592 vardecl = new generate_cc_vardecl_c(&s4o, |
605 generate_cc_vardecl_c::init_vf, |
593 generate_cc_vardecl_c::init_vf, |
606 generate_cc_vardecl_c::temp_vt); |
594 generate_cc_vardecl_c::temp_vt); |
607 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
595 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
608 delete vardecl; |
596 delete vardecl; |
609 s4o.print("\n"); |
597 s4o.print("\n"); |
610 |
598 |
611 /* (B.3) Function code */ |
599 /* (C.3) Function code */ |
612 generate_cc_SFC_IL_ST_c generate_cc_code(&s4o, symbol, FB_FUNCTION_PARAM"->"); |
600 generate_cc_SFC_IL_ST_c generate_cc_code(&s4o, symbol, FB_FUNCTION_PARAM"->"); |
613 symbol->fblock_body->accept(generate_cc_code); |
601 symbol->fblock_body->accept(generate_cc_code); |
614 s4o.indent_left(); |
602 s4o.indent_left(); |
615 s4o.print(s4o.indent_spaces + "} // "); |
603 s4o.print(s4o.indent_spaces + "} // "); |
616 symbol->fblock_name->accept(*this); |
604 symbol->fblock_name->accept(*this); |
684 s4o.indent_left(); |
672 s4o.indent_left(); |
685 s4o.print("} "); |
673 s4o.print("} "); |
686 symbol->program_type_name->accept(*this); |
674 symbol->program_type_name->accept(*this); |
687 s4o.print(";\n\n"); |
675 s4o.print(";\n\n"); |
688 |
676 |
689 /* (B) Function with PROGRAM body */ |
677 |
690 /* (B.1) Step and Action definitions */ |
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 |
|
684 /* (B) Constructor */ |
|
685 /* (B.1) Constructor name... */ |
|
686 s4o.print(s4o.indent_spaces + "void "); |
|
687 symbol->program_type_name->accept(*this); |
|
688 s4o.print(FB_INIT_SUFFIX); |
|
689 s4o.print("("); |
|
690 |
|
691 /* first and only parameter is a pointer to the data */ |
|
692 symbol->program_type_name->accept(*this); |
|
693 s4o.print(" *"); |
|
694 s4o.print(FB_FUNCTION_PARAM); |
|
695 s4o.print(") {\n"); |
|
696 s4o.indent_right(); |
|
697 |
|
698 /* (B.2) Member initializations... */ |
|
699 s4o.print(s4o.indent_spaces); |
|
700 vardecl = new generate_cc_vardecl_c(&s4o, |
|
701 generate_cc_vardecl_c::constructorinit_vf, |
|
702 generate_cc_vardecl_c::input_vt | |
|
703 generate_cc_vardecl_c::output_vt | |
|
704 generate_cc_vardecl_c::inoutput_vt | |
|
705 generate_cc_vardecl_c::private_vt | |
|
706 generate_cc_vardecl_c::external_vt); |
|
707 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
|
708 delete vardecl; |
|
709 s4o.indent_left(); |
|
710 s4o.print("\n" + s4o.indent_spaces + "}\n\n"); |
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 |
|
719 |
|
720 /* (C) Function with PROGRAM body */ |
|
721 /* (C.1) Step and Action definitions */ |
691 generate_cc_sfcdecl_c generate_cc_sfcdecl(&s4o); |
722 generate_cc_sfcdecl_c generate_cc_sfcdecl(&s4o); |
692 symbol->function_block_body->accept(generate_cc_sfcdecl); |
723 symbol->function_block_body->accept(generate_cc_sfcdecl); |
693 |
724 |
694 /* (B.2) Function declaration */ |
725 /* (C.2) Function declaration */ |
695 s4o.print("// Code part\n"); |
726 s4o.print("// Code part\n"); |
696 /* function interface */ |
727 /* function interface */ |
697 s4o.print("void "); |
728 s4o.print("void "); |
698 symbol->program_type_name->accept(*this); |
729 symbol->program_type_name->accept(*this); |
699 s4o.print(FB_FUNCTION_SUFFIX); |
730 s4o.print(FB_FUNCTION_SUFFIX); |
703 s4o.print(" *"); |
734 s4o.print(" *"); |
704 s4o.print(FB_FUNCTION_PARAM); |
735 s4o.print(FB_FUNCTION_PARAM); |
705 s4o.print(") {\n"); |
736 s4o.print(") {\n"); |
706 s4o.indent_right(); |
737 s4o.indent_right(); |
707 |
738 |
708 /* (B.3) Initialize TEMP variables */ |
739 /* (C.3) Initialize TEMP variables */ |
709 /* function body */ |
740 /* function body */ |
710 s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n"); |
741 s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n"); |
711 vardecl = new generate_cc_vardecl_c(&s4o, |
742 vardecl = new generate_cc_vardecl_c(&s4o, |
712 generate_cc_vardecl_c::init_vf, |
743 generate_cc_vardecl_c::init_vf, |
713 generate_cc_vardecl_c::temp_vt); |
744 generate_cc_vardecl_c::temp_vt); |
714 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
745 vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
715 delete vardecl; |
746 delete vardecl; |
716 s4o.print("\n"); |
747 s4o.print("\n"); |
717 |
748 |
718 /* (B.4) Function code */ |
749 /* (C.4) Function code */ |
719 generate_cc_SFC_IL_ST_c generate_cc_code(&s4o, symbol, FB_FUNCTION_PARAM"->"); |
750 generate_cc_SFC_IL_ST_c generate_cc_code(&s4o, symbol, FB_FUNCTION_PARAM"->"); |
720 symbol->function_block_body->accept(generate_cc_code); |
751 symbol->function_block_body->accept(generate_cc_code); |
721 s4o.indent_left(); |
752 s4o.indent_left(); |
722 s4o.print(s4o.indent_spaces + "} // "); |
753 s4o.print(s4o.indent_spaces + "} // "); |
723 symbol->program_type_name->accept(*this); |
754 symbol->program_type_name->accept(*this); |
724 s4o.print(FB_FUNCTION_SUFFIX); |
755 s4o.print(FB_FUNCTION_SUFFIX); |
725 s4o.print(s4o.indent_spaces + "() \n\n"); |
756 s4o.print(s4o.indent_spaces + "() \n\n"); |
726 |
757 |
727 /* (B.5) Step and Action undefinitions */ |
758 /* (C.5) Step and Action undefinitions */ |
728 generate_cc_sfcundecl_c generate_cc_sfcundecl(&s4o); |
759 generate_cc_sfcundecl_c generate_cc_sfcundecl(&s4o); |
729 symbol->function_block_body->accept(generate_cc_sfcundecl); |
760 symbol->function_block_body->accept(generate_cc_sfcundecl); |
730 |
761 |
731 s4o.indent_left(); |
762 s4o.indent_left(); |
732 s4o.print("\n\n\n\n"); |
763 s4o.print("\n\n\n\n"); |