stage4/generate_c/generate_c_sfcdecl.cc
changeset 920 4369ce5e687f
parent 897 8c3e91c385f5
child 945 477393b00f95
equal deleted inserted replaced
919:8da635655f37 920:4369ce5e687f
   193         case actiondef_sd:
   193         case actiondef_sd:
   194           s4o.print("// Actions definitions\n");
   194           s4o.print("// Actions definitions\n");
   195           for(int i = 0; i < symbol->n; i++)
   195           for(int i = 0; i < symbol->n; i++)
   196              symbol->elements[i]->accept(*this);
   196              symbol->elements[i]->accept(*this);
   197           {
   197           {
       
   198             // first fill up the this->variable_list variable!
       
   199             wanted_sfcdeclaration = actioncount_sd;
       
   200             for(int i = 0; i < symbol->n; i++)
       
   201                symbol->elements[i]->accept(*this);
       
   202             wanted_sfcdeclaration = actiondef_sd;
       
   203             // Now do the defines for actions that reference a variable instead of an action block!
   198             std::list<VARIABLE>::iterator pt;
   204             std::list<VARIABLE>::iterator pt;
   199             for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
   205             for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
   200               s4o.print("#define ");
   206               s4o.print("#define ");
   201               s4o.print(SFC_STEP_ACTION_PREFIX);
   207               s4o.print(SFC_STEP_ACTION_PREFIX);
   202               pt->symbol->accept(*this);
   208               pt->symbol->accept(*this);
   214             symbol->elements[i]->accept(*this);
   220             symbol->elements[i]->accept(*this);
   215           s4o.print("\n");
   221           s4o.print("\n");
   216           break;
   222           break;
   217         case actionundef_sd:
   223         case actionundef_sd:
   218           s4o.print("// Actions undefinitions\n");
   224           s4o.print("// Actions undefinitions\n");
       
   225           for(int i = 0; i < symbol->n; i++)
       
   226             symbol->elements[i]->accept(*this);
   219           {
   227           {
       
   228             // first fill up the this->variable_list variable!
       
   229             wanted_sfcdeclaration = actioncount_sd;
       
   230             for(int i = 0; i < symbol->n; i++)
       
   231                symbol->elements[i]->accept(*this);
       
   232             wanted_sfcdeclaration = actionundef_sd;
   220             std::list<VARIABLE>::iterator pt;
   233             std::list<VARIABLE>::iterator pt;
   221             for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
   234             for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
   222               s4o.print("#undef ");
   235               s4o.print("#undef ");
   223               s4o.print(SFC_STEP_ACTION_PREFIX);
   236               s4o.print(SFC_STEP_ACTION_PREFIX);
   224               pt->symbol->accept(*this);
   237               pt->symbol->accept(*this);
   225               s4o.print("\n");
   238               s4o.print("\n");
   226             }
   239             }
   227           }
   240           }
   228           for(int i = 0; i < symbol->n; i++)
       
   229             symbol->elements[i]->accept(*this);
       
   230           s4o.print("\n");
   241           s4o.print("\n");
   231           break;
   242           break;
   232         default:
   243         default:
   233           break;
   244           break;
   234       }
   245       }
   329     }
   340     }
   330 
   341 
   331     void *visit(action_association_c *symbol) {
   342     void *visit(action_association_c *symbol) {
   332       /* we try to find the variable instance declaration, to determine if symbol is variable... */
   343       /* we try to find the variable instance declaration, to determine if symbol is variable... */
   333       symbol_c *var_decl = search_var_instance_decl->get_decl(symbol->action_name);
   344       symbol_c *var_decl = search_var_instance_decl->get_decl(symbol->action_name);
   334 
       
   335       if (var_decl != NULL) {
   345       if (var_decl != NULL) {
   336     	std::list<VARIABLE>::iterator pt;
   346         std::list<VARIABLE>::iterator pt;
   337         for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
   347         for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
   338           if (!compare_identifiers(pt->symbol, symbol->action_name))
   348           if (!compare_identifiers(pt->symbol, symbol->action_name))
   339             return NULL;
   349             return NULL;
   340         }
   350         }
   341         VARIABLE *variable;
   351         VARIABLE *variable;