stage4/generate_c/generate_var_list.cc
changeset 706 31553c22f318
parent 626 9f2cefb98e60
child 793 268bf4ca5fa1
equal deleted inserted replaced
705:f2323f79252e 706:31553c22f318
   130       }
   130       }
   131 
   131 
   132       var_type_symbol->accept(*this);
   132       var_type_symbol->accept(*this);
   133 
   133 
   134       if (this->current_var_type_symbol == NULL)
   134       if (this->current_var_type_symbol == NULL)
   135     	this->current_var_type_symbol = var_type_symbol;
   135         this->current_var_type_symbol = var_type_symbol;
   136 
   136 
   137       return (this->current_var_type_symbol);
   137       return (this->current_var_type_symbol);
   138     }
   138     }
   139 
   139 
   140     symbol_c *get_current_type_name(void) {
   140     symbol_c *get_current_type_name(void) {
   141       if (this->current_var_type_name == NULL)
   141       if (this->current_var_type_name == NULL)
   142     	return (this->current_var_type_symbol);
   142         return (this->current_var_type_symbol);
   143 
   143 
   144       return (this->current_var_type_name);
   144       return (this->current_var_type_name);
   145     }
   145     }
   146 
   146 
   147     void *visit(identifier_c* symbol) {
   147     void *visit(identifier_c* symbol) {
   186 /***********************************************************************/
   186 /***********************************************************************/
   187 
   187 
   188 class generate_var_list_c: protected generate_c_typedecl_c {
   188 class generate_var_list_c: protected generate_c_typedecl_c {
   189   
   189   
   190   public:
   190   public:
   191     typedef struct
   191     typedef struct {
   192     {
       
   193       symbol_c *symbol;
   192       symbol_c *symbol;
   194     } SYMBOL;
   193     } SYMBOL;
   195 
   194 
   196     typedef enum {
   195     typedef enum {
   197       none_dt,
   196       none_dt,
   327       switch (search_type_symbol->current_var_type_category) {
   326       switch (search_type_symbol->current_var_type_category) {
   328         case search_type_symbol_c::structure_vtc:
   327         case search_type_symbol_c::structure_vtc:
   329         case search_type_symbol_c::function_block_vtc:
   328         case search_type_symbol_c::function_block_vtc:
   330           this->current_var_type_name->accept(*this);
   329           this->current_var_type_name->accept(*this);
   331           s4o.print(";\n");
   330           s4o.print(";\n");
   332           SYMBOL *current_name;
   331           if (this->current_var_class_category != external_vcc) {
   333           current_name = new SYMBOL;
   332               SYMBOL *current_name;
   334           current_name->symbol = symbol;
   333               current_name = new SYMBOL;
   335           current_symbol_list.push_back(*current_name);
   334               current_name->symbol = symbol;
   336           this->current_var_type_symbol->accept(*this);
   335               current_symbol_list.push_back(*current_name);
   337           current_symbol_list.pop_back();
   336               this->current_var_type_symbol->accept(*this);
       
   337               current_symbol_list.pop_back();
       
   338           }
   338           break;
   339           break;
   339         case search_type_symbol_c::array_vtc:
   340         case search_type_symbol_c::array_vtc:
   340           this->current_var_type_name->accept(*this);
   341           this->current_var_type_name->accept(*this);
   341           s4o.print(";\n");
   342           s4o.print(";\n");
   342           break;
   343           break;
   370       char str[10];
   371       char str[10];
   371       sprintf(str, "%d", action_number);
   372       sprintf(str, "%d", action_number);
   372       s4o.print(str);
   373       s4o.print(str);
   373     }
   374     }
   374     
   375     
   375     void print_symbol_list(void) {
   376     void print_symbol_list() {
   376       std::list<SYMBOL>::iterator pt;
   377       std::list<SYMBOL>::iterator pt;
   377       for(pt = current_symbol_list.begin(); pt != current_symbol_list.end(); pt++) {
   378       for(pt = current_symbol_list.begin(); pt != current_symbol_list.end(); pt++) {
   378         pt->symbol->accept(*this);
   379         pt->symbol->accept(*this);
   379         s4o.print(".");
   380         s4o.print(".");
   380       }
   381       }
   646     
   647     
   647     /*| global_var_name location */
   648     /*| global_var_name location */
   648     // SYM_REF2(global_var_spec_c, global_var_name, location)
   649     // SYM_REF2(global_var_spec_c, global_var_name, location)
   649     void *visit(global_var_spec_c *symbol) {
   650     void *visit(global_var_spec_c *symbol) {
   650       search_location_type_c search_location_type;
   651       search_location_type_c search_location_type;
   651 	  switch (search_location_type.get_location_type(symbol->location)) {
   652       switch (search_location_type.get_location_type(symbol->location)) {
   652 		case search_location_type_c::input_lt:
   653         case search_location_type_c::input_lt:
   653 		  this->current_var_class_category = located_input_vcc;
   654           this->current_var_class_category = located_input_vcc;
   654 		  break;
   655           break;
   655 		case search_location_type_c::memory_lt:
   656         case search_location_type_c::memory_lt:
   656 		  this->current_var_class_category = located_memory_vcc;
   657           this->current_var_class_category = located_memory_vcc;
   657 		  break;
   658           break;
   658 		case search_location_type_c::output_lt:
   659         case search_location_type_c::output_lt:
   659 		  this->current_var_class_category = located_output_vcc;
   660           this->current_var_class_category = located_output_vcc;
   660 		  break;
   661           break;
   661 		default:
   662         default:
   662 		  ERROR;
   663           ERROR;
   663 	      break;
   664           break;
   664 	  }
   665       }
   665 
   666 
   666       if (symbol->global_var_name != NULL)
   667       if (symbol->global_var_name != NULL)
   667         declare_variable(symbol->global_var_name);
   668         declare_variable(symbol->global_var_name);
   668       else
   669       else
   669         declare_variable(symbol->location);
   670         declare_variable(symbol->location);