779 } |
779 } |
780 |
780 |
781 |
781 |
782 /* This class will generate a new datatype for each implicitly declared array datatype |
782 /* This class will generate a new datatype for each implicitly declared array datatype |
783 * (i.e. arrays declared in a variable declaration, or a struct datatype declaration...) |
783 * (i.e. arrays declared in a variable declaration, or a struct datatype declaration...) |
|
784 * It will do the same for implicitly declared RFE_TO datatypes. |
|
785 * |
|
786 * The class will be called once for each POU declaration, and once for each derived datatype declaration. |
784 * |
787 * |
785 * e.g.: |
788 * e.g.: |
786 * VAR a: ARRAY [1..3] OF INT; END_VAR <---- ARRAY datatype is implicitly declared inside the variable declaration |
789 * VAR a: ARRAY [1..3] OF INT; END_VAR <---- ARRAY datatype is implicitly declared inside the variable declaration |
787 * TYPE STRUCT |
790 * TYPE STRUCT |
788 * a: ARRAY [1..3] OF INT; <---- ARRAY datatype is implicitly declared inside the struct type declaration |
791 * a: ARRAY [1..3] OF INT; <---- ARRAY datatype is implicitly declared inside the struct type declaration |
812 /* B 1.3.3 - Derived data types */ |
815 /* B 1.3.3 - Derived data types */ |
813 /********************************/ |
816 /********************************/ |
814 /* identifier ':' array_spec_init */ |
817 /* identifier ':' array_spec_init */ |
815 void *visit(array_type_declaration_c *symbol) {return NULL;} // This is not an implicitly defined array! |
818 void *visit(array_type_declaration_c *symbol) {return NULL;} // This is not an implicitly defined array! |
816 |
819 |
|
820 /* ref_spec: REF_TO (non_generic_type_name | function_block_type_name) */ |
|
821 void *visit(ref_spec_c *symbol) { |
|
822 identifier_c *id = generate_unique_id(prefix, symbol); |
|
823 /* Warning: The following is dangerous... |
|
824 * We are asking the generate_c_typedecl_c visitor to visit a newly created ref_spec_init_c object |
|
825 * that has not been through stage 3, and therefore does not have stage 3 annotations filled in. |
|
826 * This will only work if generate_c_typedecl_c does ot depend on the stage 3 annotations! |
|
827 */ |
|
828 ref_spec_init_c ref_spec(symbol, NULL); |
|
829 ref_type_decl_c ref_decl(id, &ref_spec); |
|
830 ref_decl.accept(generate_c_typedecl); // Must be done _before_ adding the annotation, due to the way generate_c_typedecl_c works |
|
831 symbol->anotations_map["generate_c_annotaton__implicit_type_id"] = id; |
|
832 return NULL; |
|
833 } |
|
834 |
|
835 /* For the moment, we do not support initialising reference data types */ |
|
836 /* ref_spec_init: ref_spec [ ASSIGN ref_initialization ] */ |
|
837 /* NOTE: ref_initialization may be NULL!! */ |
|
838 // SYM_REF2(ref_spec_init_c, ref_spec, ref_initialization) |
|
839 void *visit(ref_spec_init_c *symbol) { |
|
840 symbol->ref_spec->accept(*this); |
|
841 int implicit_id_count = symbol->ref_spec->anotations_map.count("generate_c_annotaton__implicit_type_id"); |
|
842 if (implicit_id_count > 1) ERROR; |
|
843 if (implicit_id_count == 1) |
|
844 symbol->anotations_map["generate_c_annotaton__implicit_type_id"] = symbol->ref_spec->anotations_map["generate_c_annotaton__implicit_type_id"]; |
|
845 return NULL; |
|
846 } |
|
847 |
|
848 /* ref_type_decl: identifier ':' ref_spec_init */ |
|
849 void *visit(ref_type_decl_c *symbol) {return NULL;} // This is not an implicitly defined REF_TO! |
817 |
850 |
818 /******************************************/ |
851 /******************************************/ |
819 /* B 1.4.3 - Declaration & Initialization */ |
852 /* B 1.4.3 - Declaration & Initialization */ |
820 /******************************************/ |
853 /******************************************/ |
821 void *visit(edge_declaration_c *symbol) {return NULL;} |
854 void *visit(edge_declaration_c *symbol) {return NULL;} |
822 void *visit(en_param_declaration_c *symbol) {return NULL;} |
855 void *visit(en_param_declaration_c *symbol) {return NULL;} |
823 void *visit(eno_param_declaration_c *symbol) {return NULL;} |
856 void *visit(eno_param_declaration_c *symbol) {return NULL;} |
824 |
|
825 void *visit(var1_init_decl_c *symbol) {return NULL;} |
|
826 |
857 |
827 /* array_specification [ASSIGN array_initialization] */ |
858 /* array_specification [ASSIGN array_initialization] */ |
828 /* array_initialization may be NULL ! */ |
859 /* array_initialization may be NULL ! */ |
829 void *visit(array_spec_init_c *symbol) { |
860 void *visit(array_spec_init_c *symbol) { |
830 symbol->array_specification->accept(*this); |
861 symbol->array_specification->accept(*this); |
859 void *visit(fb_name_decl_c *symbol) {return NULL;} |
890 void *visit(fb_name_decl_c *symbol) {return NULL;} |
860 |
891 |
861 /* var1_list ':' structure_type_name */ |
892 /* var1_list ':' structure_type_name */ |
862 //SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name) |
893 //SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name) |
863 void *visit(structured_var_declaration_c *symbol) {return NULL;} |
894 void *visit(structured_var_declaration_c *symbol) {return NULL;} |
|
895 |
864 |
896 |
865 /***********************/ |
897 /***********************/ |
866 /* B 1.5.1 - Functions */ |
898 /* B 1.5.1 - Functions */ |
867 /***********************/ |
899 /***********************/ |
868 void *visit(function_declaration_c *symbol) { |
900 void *visit(function_declaration_c *symbol) { |