stage4/generate_c/generate_var_list.cc
changeset 157 3e12726f9d6b
parent 141 d2dc99c319b6
child 158 eb8a5df69bb0
equal deleted inserted replaced
156:6b16b7f8b527 157:3e12726f9d6b
   137         declare_variable(list->elements[i], type);
   137         declare_variable(list->elements[i], type);
   138       }
   138       }
   139     }
   139     }
   140     
   140     
   141     void declare_variable(symbol_c *symbol, const char* type = "VAR") {
   141     void declare_variable(symbol_c *symbol, const char* type = "VAR") {
       
   142       print_var_number();
       
   143       s4o.print(";");
       
   144       s4o.print(type);
       
   145       s4o.print(";");
       
   146       print_symbol_list();
       
   147       symbol->accept(*this);
       
   148       s4o.print(";");
       
   149       print_symbol_list();
       
   150       symbol->accept(*this);
       
   151       s4o.print(";");
   142       if (strcmp(type, "FB") == 0) {
   152       if (strcmp(type, "FB") == 0) {
   143         SYMBOL *current_name;
   153         SYMBOL *current_name;
   144         current_name = new SYMBOL;
   154         current_name = new SYMBOL;
   145         current_name->symbol = symbol;
   155         current_name->symbol = symbol;
   146         current_symbol_list.push_back(*current_name);
   156         current_symbol_list.push_back(*current_name);
   147         this->current_var_type_symbol->accept(*this);
   157         this->current_var_type_symbol->accept(*this);
   148         current_symbol_list.pop_back();
   158         current_symbol_list.pop_back();
   149       }
   159       }
   150       else {
   160       else {
   151         print_var_number();
       
   152         s4o.print(";");
       
   153         s4o.print(type);
       
   154         s4o.print(";");
       
   155         print_symbol_list();
       
   156         symbol->accept(*this);
       
   157         s4o.print(";");
       
   158         print_symbol_list();
       
   159         symbol->accept(*this);
       
   160         s4o.print(";");
       
   161         this->current_var_type_symbol->accept(*this);
   161         this->current_var_type_symbol->accept(*this);
   162         s4o.print(";\n");
   162         s4o.print(";\n");
   163       }
   163       }
   164     }
   164     }
   165     
   165     
   395 /*****************************/
   395 /*****************************/
   396 /* B 1.5.2 - Function Blocks */
   396 /* B 1.5.2 - Function Blocks */
   397 /*****************************/
   397 /*****************************/
   398     void *visit(function_block_declaration_c *symbol) {
   398     void *visit(function_block_declaration_c *symbol) {
   399       if (current_declarationtype == variables_dt && configuration_defined) {
   399       if (current_declarationtype == variables_dt && configuration_defined) {
       
   400         symbol->fblock_name->accept(*this);
       
   401         s4o.print(";\n");
   400         symbol->var_declarations->accept(*this);
   402         symbol->var_declarations->accept(*this);
   401         symbol->fblock_body->accept(*this);
   403         symbol->fblock_body->accept(*this);
   402       }
   404       }
   403       return NULL;
   405       return NULL;
   404     }
   406     }