stage4/generate_c/generate_c.cc
changeset 178 1622dc05c6ca
parent 146 eef5e62048c7
child 181 38d6eb056260
equal deleted inserted replaced
177:697562a5da7c 178:1622dc05c6ca
    71 
    71 
    72 
    72 
    73 
    73 
    74 
    74 
    75 
    75 
    76 
    76 #if 0
    77 
       
    78 /* A symbol table with all globally declared functions... */
    77 /* A symbol table with all globally declared functions... */
    79 function_declaration_c null_symbol1(NULL,NULL,NULL,NULL);
    78 function_declaration_c null_symbol1(NULL,NULL,NULL,NULL);
    80 dsymtable_c<function_declaration_c *, &null_symbol1> function_symtable;
    79 dsymtable_c<function_declaration_c *, &null_symbol1> function_symtable;
    81 
    80 
    82 /* A symbol table with all globally declared functions block types... */
    81 /* A symbol table with all globally declared functions block types... */
    91 /* Note that function block types and program types have their
    90 /* Note that function block types and program types have their
    92  * own symbol tables, so do not get placed in this symbol table!
    91  * own symbol tables, so do not get placed in this symbol table!
    93  */
    92  */
    94 symbol_c null_symbol4;
    93 symbol_c null_symbol4;
    95 symtable_c<symbol_c *, &null_symbol4> type_symtable;
    94 symtable_c<symbol_c *, &null_symbol4> type_symtable;
    96 
    95 #else
    97 
    96 
       
    97 #include "../../search_utils/search_utils.hh"
       
    98 
       
    99 #endif
    98 
   100 
    99 /***********************************************************************/
   101 /***********************************************************************/
   100 /***********************************************************************/
   102 /***********************************************************************/
   101 /***********************************************************************/
   103 /***********************************************************************/
   102 /***********************************************************************/
   104 /***********************************************************************/
   547 /*   FUNCTION derived_function_name ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
   549 /*   FUNCTION derived_function_name ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
   548 /* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
   550 /* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
   549 void *visit(function_declaration_c *symbol) {
   551 void *visit(function_declaration_c *symbol) {
   550   generate_c_vardecl_c *vardecl;
   552   generate_c_vardecl_c *vardecl;
   551   TRACE("function_declaration_c");
   553   TRACE("function_declaration_c");
   552 
       
   553   /* start off by adding this declaration to the global
       
   554    * function declaration symbol table...
       
   555    */
       
   556   function_symtable.insert(symbol->derived_function_name, symbol);
       
   557 
   554 
   558   /* (A) Function declaration... */
   555   /* (A) Function declaration... */
   559   /* (A.1) Function return type */
   556   /* (A.1) Function return type */
   560   s4o.print("// FUNCTION\n");
   557   s4o.print("// FUNCTION\n");
   561   symbol->type_name->accept(*this); /* return type */
   558   symbol->type_name->accept(*this); /* return type */
   671   generate_c_vardecl_c *vardecl;
   668   generate_c_vardecl_c *vardecl;
   672   generate_c_sfcdecl_c *sfcdecl;
   669   generate_c_sfcdecl_c *sfcdecl;
   673   generate_c_typedecl_c *typedecl;
   670   generate_c_typedecl_c *typedecl;
   674   TRACE("function_block_declaration_c");
   671   TRACE("function_block_declaration_c");
   675 
   672 
   676   /* start off by adding this declaration to the global
       
   677    * function block declaration symbol table...
       
   678    */
       
   679   function_block_type_symtable.insert(symbol->fblock_name, symbol);
       
   680   
       
   681   /* (A) Function Block data structure declaration... */
   673   /* (A) Function Block data structure declaration... */
   682   typedecl = new generate_c_typedecl_c(&s4o_incl);
   674   typedecl = new generate_c_typedecl_c(&s4o_incl);
   683   /* (A.1) Data structure declaration */
   675   /* (A.1) Data structure declaration */
   684   s4o_incl.print("// FUNCTION_BLOCK ");
   676   s4o_incl.print("// FUNCTION_BLOCK ");
   685   symbol->fblock_name->accept(*typedecl);
   677   symbol->fblock_name->accept(*typedecl);
   870 void *visit(program_declaration_c *symbol) {
   862 void *visit(program_declaration_c *symbol) {
   871   generate_c_vardecl_c *vardecl;
   863   generate_c_vardecl_c *vardecl;
   872   generate_c_sfcdecl_c *sfcdecl;
   864   generate_c_sfcdecl_c *sfcdecl;
   873   generate_c_typedecl_c *typedecl;
   865   generate_c_typedecl_c *typedecl;
   874   TRACE("program_declaration_c");
   866   TRACE("program_declaration_c");
   875 
       
   876   /* start off by adding this declaration to the global
       
   877    * program declaration symbol table...
       
   878    */
       
   879   program_type_symtable.insert(symbol->program_type_name, symbol);
       
   880 
   867 
   881   /* (A) Program data structure declaration... */
   868   /* (A) Program data structure declaration... */
   882   typedecl = new generate_c_typedecl_c(&s4o_incl);
   869   typedecl = new generate_c_typedecl_c(&s4o_incl);
   883   /* (A.1) Data structure declaration */
   870   /* (A.1) Data structure declaration */
   884   s4o_incl.print("// PROGRAM ");
   871   s4o_incl.print("// PROGRAM ");