stage4/generate_c/generate_c.cc
changeset 111 ee31ee39eaf6
parent 98 d0cdf1d00b74
child 112 0c8d1b0c957a
equal deleted inserted replaced
110:28af43a8f970 111:ee31ee39eaf6
    38 // #include <stdio.h>  /* required for NULL */
    38 // #include <stdio.h>  /* required for NULL */
    39 #include <string>
    39 #include <string>
    40 #include <iostream>
    40 #include <iostream>
    41 #include <sstream>
    41 #include <sstream>
    42 #include <typeinfo>
    42 #include <typeinfo>
       
    43 #include <list>
    43 
    44 
    44 #include "../../util/symtable.hh"
    45 #include "../../util/symtable.hh"
    45 #include "../../util/dsymtable.hh"
    46 #include "../../util/dsymtable.hh"
    46 #include "../../absyntax/visitor.hh"
    47 #include "../../absyntax/visitor.hh"
    47 
    48 
   179 #include "function_param_iterator.cc"
   180 #include "function_param_iterator.cc"
   180 #include "function_call_iterator.cc"
   181 #include "function_call_iterator.cc"
   181 #include "function_call_param_iterator.cc"
   182 #include "function_call_param_iterator.cc"
   182 #include "type_initial_value.cc"
   183 #include "type_initial_value.cc"
   183 #include "search_fb_instance_decl.cc"
   184 #include "search_fb_instance_decl.cc"
       
   185 #include "search_fb_typedecl.cc"
   184 #include "search_base_type.cc"
   186 #include "search_base_type.cc"
   185 #include "search_var_instance_decl.cc"
   187 #include "search_var_instance_decl.cc"
   186 #include "decompose_var_instance_name.cc"
   188 #include "decompose_var_instance_name.cc"
   187 #include "search_varfb_instance_type.cc"
   189 #include "search_varfb_instance_type.cc"
   188 #include "search_constant_type.cc"
   190 #include "search_constant_type.cc"
   192 #include "generate_c_typedecl.cc"
   194 #include "generate_c_typedecl.cc"
   193 #include "generate_c_sfcdecl.cc"
   195 #include "generate_c_sfcdecl.cc"
   194 #include "generate_c_vardecl.cc"
   196 #include "generate_c_vardecl.cc"
   195 #include "generate_c_configbody.cc"
   197 #include "generate_c_configbody.cc"
   196 #include "generate_location_list.cc"
   198 #include "generate_location_list.cc"
       
   199 #include "generate_var_list.cc"
   197 
   200 
   198 /***********************************************************************/
   201 /***********************************************************************/
   199 /***********************************************************************/
   202 /***********************************************************************/
   200 /***********************************************************************/
   203 /***********************************************************************/
   201 /***********************************************************************/
   204 /***********************************************************************/
  1430 class generate_c_c: public iterator_visitor_c {
  1433 class generate_c_c: public iterator_visitor_c {
  1431   protected:
  1434   protected:
  1432     stage4out_c &s4o;
  1435     stage4out_c &s4o;
  1433     stage4out_c pous_s4o;
  1436     stage4out_c pous_s4o;
  1434     stage4out_c located_variables_s4o;
  1437     stage4out_c located_variables_s4o;
       
  1438     stage4out_c variables_s4o;
  1435     generate_c_pous_c generate_c_pous;
  1439     generate_c_pous_c generate_c_pous;
  1436 
  1440     generate_var_list_c *generate_var_list;
       
  1441     
  1437     symbol_c *current_configuration;
  1442     symbol_c *current_configuration;
  1438 
  1443 
  1439     const char *current_name;
  1444     const char *current_name;
  1440     const char *current_builddir;
  1445     const char *current_builddir;
  1441 
  1446 
  1444   public:
  1449   public:
  1445     generate_c_c(stage4out_c *s4o_ptr, const char *builddir): 
  1450     generate_c_c(stage4out_c *s4o_ptr, const char *builddir): 
  1446             s4o(*s4o_ptr),
  1451             s4o(*s4o_ptr),
  1447             pous_s4o(builddir, "POUS", "c"),
  1452             pous_s4o(builddir, "POUS", "c"),
  1448             located_variables_s4o(builddir, "LOCATED_VARIABLES","h"),
  1453             located_variables_s4o(builddir, "LOCATED_VARIABLES","h"),
       
  1454             variables_s4o(builddir, "VARIABLES","h"),
  1449             generate_c_pous(&pous_s4o) {
  1455             generate_c_pous(&pous_s4o) {
  1450       current_builddir = builddir;
  1456       current_builddir = builddir;
  1451       current_configuration = NULL;
  1457       current_configuration = NULL;
  1452     }
  1458     }
  1453             
  1459             
  1455 
  1461 
  1456 /***************************/
  1462 /***************************/
  1457 /* B 0 - Programming Model */
  1463 /* B 0 - Programming Model */
  1458 /***************************/
  1464 /***************************/
  1459     void *visit(library_c *symbol) {
  1465     void *visit(library_c *symbol) {
       
  1466       generate_var_list = new generate_var_list_c(&variables_s4o, symbol);
       
  1467       
  1460       for(int i = 0; i < symbol->n; i++) {
  1468       for(int i = 0; i < symbol->n; i++) {
  1461         symbol->elements[i]->accept(*this);
  1469         symbol->elements[i]->accept(*this);
  1462       }
  1470       }
       
  1471       
       
  1472       delete generate_var_list;
       
  1473       
  1463       generate_location_list_c generate_location_list(&located_variables_s4o);
  1474       generate_location_list_c generate_location_list(&located_variables_s4o);
  1464       symbol->accept(generate_location_list);
  1475       symbol->accept(generate_location_list);
  1465       return NULL;
  1476       return NULL;
  1466     }
  1477     }
  1467 
  1478 
  1541       
  1552       
  1542       symbol->resource_declarations->accept(*this);
  1553       symbol->resource_declarations->accept(*this);
  1543 
  1554 
  1544       current_configuration = NULL;
  1555       current_configuration = NULL;
  1545       
  1556       
       
  1557       symbol->accept(*generate_var_list);
       
  1558       
  1546       return NULL;
  1559       return NULL;
  1547     }
  1560     }
  1548 
  1561 
  1549     void *visit(resource_declaration_c *symbol) {
  1562     void *visit(resource_declaration_c *symbol) {
  1550     	symbol->resource_name->accept(*this);
  1563     	symbol->resource_name->accept(*this);