stage4/generate_cc/generate_cc.cc
changeset 23 d5b55ac4efe6
parent 18 e6af5eb5f546
child 24 7e830409f72a
equal deleted inserted replaced
22:08bcc40be1fa 23:d5b55ac4efe6
   143  * e.g.:  FUNTION_BLOCK TEST
   143  * e.g.:  FUNTION_BLOCK TEST
   144  * is mapped onto a TEST data structure, and a TEST_body__ function.
   144  * is mapped onto a TEST data structure, and a TEST_body__ function.
   145  */
   145  */
   146 
   146 
   147 #define FB_FUNCTION_SUFFIX "_body__"
   147 #define FB_FUNCTION_SUFFIX "_body__"
       
   148 
       
   149 /* Idem as body, but for initializer FB function */
       
   150 #define FB_INIT_SUFFIX "_init__"
   148 
   151 
   149 /* The FB body function is passed as the only parameter a pointer to the FB data
   152 /* The FB body function is passed as the only parameter a pointer to the FB data
   150  * structure instance. The name of this parameter is given by the following constant.
   153  * structure instance. The name of this parameter is given by the following constant.
   151  * In order not to clash with any variable in the IL and ST source codem the
   154  * In order not to clash with any variable in the IL and ST source codem the
   152  * following constant should contain a double underscore, which is not allowed
   155  * following constant should contain a double underscore, which is not allowed
   522   s4o.print("\n");
   525   s4o.print("\n");
   523   /* (A.3) Private internal variables */
   526   /* (A.3) Private internal variables */
   524   s4o.print(s4o.indent_spaces + "// FB private variables - TEMP, private and located variables\n");
   527   s4o.print(s4o.indent_spaces + "// FB private variables - TEMP, private and located variables\n");
   525   vardecl = new generate_cc_vardecl_c(&s4o,
   528   vardecl = new generate_cc_vardecl_c(&s4o,
   526   				      generate_cc_vardecl_c::local_vf,
   529   				      generate_cc_vardecl_c::local_vf,
   527 				        generate_cc_vardecl_c::temp_vt |
   530 				      generate_cc_vardecl_c::temp_vt |
   528   				      generate_cc_vardecl_c::private_vt |
   531   				      generate_cc_vardecl_c::private_vt |
   529   				      generate_cc_vardecl_c::located_vt);
   532   				      generate_cc_vardecl_c::located_vt |
       
   533   				      generate_cc_vardecl_c::external_vt);
   530   vardecl->print(symbol->var_declarations);
   534   vardecl->print(symbol->var_declarations);
   531   delete vardecl;
   535   delete vardecl;
   532   s4o.print("\n");
   536   s4o.print("\n");
   533 
   537 
   534   /* (A.4) Function Block data structure type name. */
   538   /* (A.4) Function Block data structure type name. */
   535   s4o.indent_left();
   539   s4o.indent_left();
   536   s4o.print("} ");
   540   s4o.print("} ");
   537   symbol->fblock_name->accept(*this);
   541   symbol->fblock_name->accept(*this);
   538   s4o.print(";\n\n");
   542   s4o.print(";\n\n");
       
   543 
       
   544 
       
   545 
       
   546 
       
   547 
       
   548 
       
   549 
       
   550 
       
   551 
       
   552 
       
   553   /* (B) Constructor */
       
   554   /* (B.1) Constructor name... */
       
   555   s4o.print(s4o.indent_spaces + "void ");
       
   556   symbol->fblock_name->accept(*this);
       
   557   s4o.print(FB_INIT_SUFFIX);
       
   558   s4o.print("(");
       
   559 
       
   560   /* first and only parameter is a pointer to the data */
       
   561   symbol->fblock_name->accept(*this);
       
   562   s4o.print(" *");
       
   563   s4o.print(FB_FUNCTION_PARAM);
       
   564   s4o.print(") {\n");
       
   565   s4o.indent_right();
       
   566 
       
   567   /* (B.2) Member initializations... */
       
   568   s4o.print(s4o.indent_spaces);
       
   569   vardecl = new generate_cc_vardecl_c(&s4o,
       
   570   				      generate_cc_vardecl_c::constructorinit_vf,
       
   571   				      generate_cc_vardecl_c::input_vt |
       
   572   				      generate_cc_vardecl_c::output_vt |
       
   573   				      generate_cc_vardecl_c::inoutput_vt |
       
   574   				      generate_cc_vardecl_c::private_vt |
       
   575 				      generate_cc_vardecl_c::external_vt);
       
   576   vardecl->print(symbol->var_declarations, NULL,  FB_FUNCTION_PARAM"->");
       
   577   delete vardecl;
       
   578   s4o.indent_left();
       
   579   s4o.print("\n" + s4o.indent_spaces + "}\n\n");
       
   580 
       
   581   
       
   582 
       
   583 
   539 
   584 
   540 
   585 
   541   /* (B) Function with FB body */
   586   /* (B) Function with FB body */
   542   /* (B.1) Function declaration */
   587   /* (B.1) Function declaration */
   543   s4o.print("// Code part\n");
   588   s4o.print("// Code part\n");