stage4/generate_c/generate_var_list.cc
changeset 377 60b012b7793f
parent 317 5b687021c6e7
child 409 8d876ad522f4
child 641 5681f600ac18
equal deleted inserted replaced
376:7dcbd8418771 377:60b012b7793f
    23  * Based on the
    23  * Based on the
    24  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
    24  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
    25  *
    25  *
    26  */
    26  */
    27 
    27 
    28 typedef struct
    28 
    29 {
    29 
    30   symbol_c *symbol;
    30 /***********************************************************************/
    31 } SYMBOL;
    31 /***********************************************************************/
    32 
    32 /***********************************************************************/
    33 typedef enum {
    33 /***********************************************************************/
    34   none_lt,
       
    35   input_lt,
       
    36   output_lt,
       
    37   memory_lt
       
    38 } locationtype_t;
       
    39 
       
    40 
       
    41 /***********************************************************************/
       
    42 /***********************************************************************/
       
    43 /***********************************************************************/
       
    44 /***********************************************************************/
       
    45 
       
    46 
    34 
    47 class search_location_type_c: public iterator_visitor_c {
    35 class search_location_type_c: public iterator_visitor_c {
    48 
    36 
    49   public:
    37   public:
       
    38     typedef enum {
       
    39       none_lt,
       
    40       input_lt,
       
    41       output_lt,
       
    42       memory_lt
       
    43     } locationtype_t;
       
    44 
    50     locationtype_t current_location_type;
    45     locationtype_t current_location_type;
    51 
    46 
    52   public:
    47   public:
    53 	search_location_type_c(void) {}
    48     search_location_type_c(void) {}
    54 
    49 
    55 	virtual ~search_location_type_c(void) {}
    50     virtual ~search_location_type_c(void) {}
    56 
    51 
    57 	locationtype_t get_location_type(symbol_c *symbol) {
    52     locationtype_t get_location_type(symbol_c *symbol) {
    58       current_location_type = none_lt;
    53       current_location_type = none_lt;
    59       symbol->accept(*this);
    54       symbol->accept(*this);
    60       if (current_location_type == none_lt) ERROR;
    55       if (current_location_type == none_lt) ERROR;
    61       return current_location_type;
    56       return current_location_type;
    62 	}
    57     }
    63 
    58 
    64   private:
    59   private:
    65 
    60 
    66 	void *visit(incompl_location_c* symbol) {
    61     void *visit(incompl_location_c* symbol) {
    67       if (symbol->value[1] == 'I')
    62       if (symbol->value[1] == 'I')
    68         current_location_type = input_lt;
    63         current_location_type = input_lt;
    69 	  else if (symbol->value[1] == 'Q')
    64      else if (symbol->value[1] == 'Q')
    70         current_location_type = output_lt;
    65         current_location_type = output_lt;
    71 	  else if (symbol->value[1] == 'M')
    66      else if (symbol->value[1] == 'M')
    72         current_location_type = memory_lt;
    67         current_location_type = memory_lt;
    73       return NULL;
    68       return NULL;
    74 	}
    69     }
    75 
    70 
    76 	void *visit(direct_variable_c *symbol) {
    71     void *visit(direct_variable_c *symbol) {
    77       if (symbol->value[1] == 'I')
    72       if (symbol->value[1] == 'I')
    78         current_location_type = input_lt;
    73         current_location_type = input_lt;
    79 	  else if (symbol->value[1] == 'Q')
    74      else if (symbol->value[1] == 'Q')
    80         current_location_type = output_lt;
    75         current_location_type = output_lt;
    81 	  else if (symbol->value[1] == 'M')
    76      else if (symbol->value[1] == 'M')
    82         current_location_type = memory_lt;
    77         current_location_type = memory_lt;
    83       return NULL;
    78       return NULL;
    84 	}
    79     }
    85 };
    80 };
    86 
    81 
       
    82 
       
    83 
       
    84 /***********************************************************************/
       
    85 /***********************************************************************/
       
    86 /***********************************************************************/
       
    87 /***********************************************************************/
       
    88 /***********************************************************************/
       
    89 /***********************************************************************/
       
    90 /***********************************************************************/
       
    91 /***********************************************************************/
       
    92 
       
    93 
       
    94 class search_type_symbol_c: public iterator_visitor_c {
       
    95 
       
    96   public:
       
    97     typedef enum {
       
    98       none_vtc,
       
    99       variable_vtc,
       
   100       array_vtc,
       
   101       structure_vtc,
       
   102       function_block_vtc
       
   103     } vartypecategory_t;
       
   104 
       
   105     vartypecategory_t current_var_type_category;
       
   106 
       
   107   private:
       
   108     symbol_c *current_var_type_symbol;
       
   109     symbol_c *current_var_type_name;
       
   110     search_base_type_c search_base_type;
       
   111     search_fb_typedecl_c *search_fb_typedecl;
       
   112 
       
   113   public:
       
   114     search_type_symbol_c(symbol_c *scope) {
       
   115       search_fb_typedecl = new search_fb_typedecl_c(scope);
       
   116     }
       
   117 
       
   118     virtual ~search_type_symbol_c(void) {
       
   119       delete search_fb_typedecl;
       
   120     }
       
   121 
       
   122     symbol_c *get_type_symbol(symbol_c* symbol) {
       
   123       this->current_var_type_category = variable_vtc;
       
   124       this->current_var_type_symbol = NULL;
       
   125       this->current_var_type_name = NULL;
       
   126 
       
   127       symbol_c* var_type_symbol = spec_init_sperator_c::get_spec(symbol);
       
   128       if (var_type_symbol == NULL) {
       
   129         var_type_symbol = symbol;
       
   130       }
       
   131 
       
   132       var_type_symbol->accept(*this);
       
   133 
       
   134       if (this->current_var_type_symbol == NULL)
       
   135     	this->current_var_type_symbol = var_type_symbol;
       
   136 
       
   137       return (this->current_var_type_symbol);
       
   138     }
       
   139 
       
   140     symbol_c *get_current_type_name(void) {
       
   141       if (this->current_var_type_name == NULL)
       
   142     	return (this->current_var_type_symbol);
       
   143 
       
   144       return (this->current_var_type_name);
       
   145     }
       
   146 
       
   147     void *visit(identifier_c* symbol) {
       
   148       if (this->current_var_type_name == NULL) {
       
   149         this->current_var_type_name = symbol;
       
   150 
       
   151         this->current_var_type_symbol = search_fb_typedecl->get_decl(this->current_var_type_name);
       
   152         if (this->current_var_type_symbol != NULL)
       
   153           this->current_var_type_category = function_block_vtc;
       
   154 
       
   155         else {
       
   156           this->current_var_type_symbol = (symbol_c *)(this->current_var_type_name->accept(search_base_type));
       
   157           this->current_var_type_symbol->accept(*this);
       
   158         }
       
   159       }
       
   160       return NULL;
       
   161     }
       
   162 
       
   163     void *visit(array_specification_c* symbol) {
       
   164       this->current_var_type_category = array_vtc;
       
   165 
       
   166       if (this->current_var_type_name == NULL)
       
   167         this->current_var_type_name = symbol->non_generic_type_name;
       
   168 
       
   169       return NULL;
       
   170     }
       
   171 
       
   172     void *visit(structure_element_declaration_list_c* symbol) {
       
   173       this->current_var_type_category = structure_vtc;
       
   174       return NULL;
       
   175     }
       
   176 
       
   177 };
    87 
   178 
    88 /***********************************************************************/
   179 /***********************************************************************/
    89 /***********************************************************************/
   180 /***********************************************************************/
    90 /***********************************************************************/
   181 /***********************************************************************/
    91 /***********************************************************************/
   182 /***********************************************************************/
    95 /***********************************************************************/
   186 /***********************************************************************/
    96 
   187 
    97 class generate_var_list_c: protected generate_c_typedecl_c {
   188 class generate_var_list_c: protected generate_c_typedecl_c {
    98   
   189   
    99   public:
   190   public:
       
   191     typedef struct
       
   192     {
       
   193       symbol_c *symbol;
       
   194     } SYMBOL;
       
   195 
   100     typedef enum {
   196     typedef enum {
   101       none_dt,
   197       none_dt,
   102       programs_dt,
   198       programs_dt,
   103       variables_dt
   199       variables_dt
   104     } declarationtype_t;
   200     } declarationtype_t;
   105 
   201 
   106     declarationtype_t current_declarationtype;
   202     declarationtype_t current_declarationtype;
   107     
   203     
   108     typedef enum {
   204     typedef enum {
   109       none_vtc,
   205       none_vcc,
   110       variable_vtc,
   206       external_vcc,
   111       external_vtc,
   207       located_input_vcc,
   112       located_input_vtc,
   208       located_memory_vcc,
   113       located_memory_vtc,
   209       located_output_vcc,
   114       located_output_vtc,
   210     } varclasscategory_t;
   115       array_vtc,
   211 
   116       structure_vtc,
   212     varclasscategory_t current_var_class_category;
   117       function_block_vtc
       
   118     } vartypecategory_t;
       
   119     
       
   120     vartypecategory_t current_var_type_category;
       
   121     
   213     
   122   private:
   214   private:
   123     symbol_c *current_var_type_symbol;
   215     symbol_c *current_var_type_symbol;
   124     symbol_c *current_var_type_name;
   216     symbol_c *current_var_type_name;
   125     unsigned int current_var_number;
   217     unsigned int current_var_number;
   126     unsigned int step_number;
   218     unsigned int step_number;
   127     unsigned int transition_number;
   219     unsigned int transition_number;
   128     unsigned int action_number;
   220     unsigned int action_number;
   129     bool configuration_defined;
   221     bool configuration_defined;
   130     std::list<SYMBOL> current_symbol_list;
   222     std::list<SYMBOL> current_symbol_list;
   131     search_base_type_c search_base_type;
   223     search_type_symbol_c *search_type_symbol;
   132     search_fb_typedecl_c *search_fb_typedecl;
       
   133     
   224     
   134   public:
   225   public:
   135     generate_var_list_c(stage4out_c *s4o_ptr, symbol_c *scope)
   226     generate_var_list_c(stage4out_c *s4o_ptr, symbol_c *scope)
   136     : generate_c_typedecl_c(s4o_ptr) {
   227     : generate_c_typedecl_c(s4o_ptr) {
   137       search_fb_typedecl = new search_fb_typedecl_c(scope);
   228       search_type_symbol = new search_type_symbol_c(scope);
   138       current_var_number = 0;
   229       current_var_number = 0;
   139       current_var_type_symbol = current_var_type_name = NULL;
   230       current_var_type_symbol = NULL;
       
   231       current_var_type_name = NULL;
   140       current_declarationtype = none_dt;
   232       current_declarationtype = none_dt;
   141       current_var_type_category = none_vtc;
   233       current_var_class_category = none_vcc;
   142     }
   234     }
   143     
   235     
   144     ~generate_var_list_c(void) {
   236     ~generate_var_list_c(void) {
   145       delete search_fb_typedecl;
   237       delete search_type_symbol;
   146     }
   238     }
   147     
   239     
   148     void update_var_type_symbol(symbol_c *symbol) {
   240     void update_var_type_symbol(symbol_c *symbol) {
   149       
   241       this->current_var_type_symbol = search_type_symbol->get_type_symbol(symbol);
   150       this->current_var_type_name = spec_init_sperator_c::get_spec(symbol);
   242       this->current_var_type_name = search_type_symbol->get_current_type_name();
   151       if (this->current_var_type_name == NULL) {
       
   152         std::list<SYMBOL>::iterator pt;
       
   153         for(pt = current_symbol_list.begin(); pt != current_symbol_list.end(); pt++) {
       
   154           fprintf(stderr, "%s.", ((identifier_c*)(pt->symbol))->value);
       
   155         }
       
   156         ERROR;
       
   157       }
       
   158       
       
   159       this->current_var_type_symbol = search_fb_typedecl->get_decl(this->current_var_type_name);
       
   160       if (this->current_var_type_symbol != NULL)
       
   161         this->current_var_type_category = function_block_vtc;
       
   162       else {
       
   163         this->current_var_type_symbol = (symbol_c *)(this->current_var_type_name->accept(search_base_type));
       
   164         
       
   165         structure_element_declaration_list_c *structure_symbol = dynamic_cast<structure_element_declaration_list_c *>(this->current_var_type_symbol);
       
   166         if (structure_symbol != NULL)
       
   167           this->current_var_type_category = structure_vtc;
       
   168         else
       
   169           this->current_var_type_category = variable_vtc;
       
   170       }
       
   171       
       
   172       if (this->current_var_type_symbol == NULL)
       
   173         ERROR;
       
   174     }
   243     }
   175 
   244 
   176     void reset_var_type_symbol(void) {
   245     void reset_var_type_symbol(void) {
   177       this->current_var_type_symbol = NULL;
   246       this->current_var_type_symbol = NULL;
   178     }
   247     }
   207       }
   276       }
   208     }
   277     }
   209     
   278     
   210     void declare_variable(symbol_c *symbol) {
   279     void declare_variable(symbol_c *symbol) {
   211       // Arrays and structures are not supported in debugging
   280       // Arrays and structures are not supported in debugging
   212       switch (this->current_var_type_category) {
   281       switch (search_type_symbol->current_var_type_category) {
   213       	case array_vtc:
   282           case search_type_symbol_c::array_vtc:
   214       	case structure_vtc:
   283           case search_type_symbol_c::structure_vtc:
   215           return;
   284           return;
   216       	default:
   285           default:
   217       	  break;
   286            break;
   218       }
   287       }
   219       print_var_number();
   288       print_var_number();
   220       s4o.print(";");
   289       s4o.print(";");
   221       switch (this->current_var_type_category) {
   290       switch (search_type_symbol->current_var_type_category) {
   222         case external_vtc:
   291         case search_type_symbol_c::array_vtc:
   223           s4o.print("EXT");
       
   224           break;
       
   225         case located_input_vtc:
       
   226           s4o.print("IN");
       
   227           break;
       
   228         case located_memory_vtc:
       
   229           s4o.print("MEM");
       
   230           break;
       
   231         case located_output_vtc:
       
   232           s4o.print("OUT");
       
   233           break;
       
   234         case array_vtc:
       
   235           s4o.print("ARRAY");
   292           s4o.print("ARRAY");
   236           break;
   293           break;
   237         case structure_vtc:
   294         case search_type_symbol_c::structure_vtc:
   238           s4o.print("STRUCT");
   295           s4o.print("STRUCT");
   239           break;
   296           break;
   240         case function_block_vtc:
   297         case search_type_symbol_c::function_block_vtc:
   241           s4o.print("FB");
   298           s4o.print("FB");
   242           break;
   299           break;
   243         default:
   300         default:
   244           s4o.print("VAR");
   301           switch (this->current_var_class_category) {
       
   302             case external_vcc:
       
   303              s4o.print("EXT");
       
   304              break;
       
   305             case located_input_vcc:
       
   306              s4o.print("IN");
       
   307              break;
       
   308             case located_memory_vcc:
       
   309              s4o.print("MEM");
       
   310              break;
       
   311             case located_output_vcc:
       
   312              s4o.print("OUT");
       
   313              break;
       
   314             default:
       
   315              s4o.print("VAR");
       
   316              break;
       
   317           }
   245           break;
   318           break;
   246       }
   319       }
   247       s4o.print(";");
   320       s4o.print(";");
   248       print_symbol_list();
   321       print_symbol_list();
   249       symbol->accept(*this);
   322       symbol->accept(*this);
   250       s4o.print(";");
   323       s4o.print(";");
   251       print_symbol_list();
   324       print_symbol_list();
   252       symbol->accept(*this);
   325       symbol->accept(*this);
   253       s4o.print(";");
   326       s4o.print(";");
   254       switch (this->current_var_type_category) {
   327       switch (search_type_symbol->current_var_type_category) {
   255         case structure_vtc:
   328         case search_type_symbol_c::structure_vtc:
   256         case function_block_vtc:
   329         case search_type_symbol_c::function_block_vtc:
   257           this->current_var_type_name->accept(*this);
   330           this->current_var_type_name->accept(*this);
   258           s4o.print(";\n");
   331           s4o.print(";\n");
   259           SYMBOL *current_name;
   332           SYMBOL *current_name;
   260           current_name = new SYMBOL;
   333           current_name = new SYMBOL;
   261           current_name->symbol = symbol;
   334           current_name->symbol = symbol;
   262           current_symbol_list.push_back(*current_name);
   335           current_symbol_list.push_back(*current_name);
   263           this->current_var_type_symbol->accept(*this);
   336           this->current_var_type_symbol->accept(*this);
   264           current_symbol_list.pop_back();
   337           current_symbol_list.pop_back();
   265           break;
   338           break;
   266         case array_vtc:
   339         case search_type_symbol_c::array_vtc:
   267           this->current_var_type_name->accept(*this);
   340           this->current_var_type_name->accept(*this);
   268           s4o.print(";\n");
   341           s4o.print(";\n");
   269           break;
   342           break;
   270         default:
   343         default:
   271           this->current_var_type_symbol->accept(*this);
   344           this->current_var_type_symbol->accept(*this);
   319          * current_var_init_symbol private variables...
   392          * current_var_init_symbol private variables...
   320          */
   393          */
   321         update_var_type_symbol(symbol->located_var_spec_init);
   394         update_var_type_symbol(symbol->located_var_spec_init);
   322         
   395         
   323         search_location_type_c search_location_type;
   396         search_location_type_c search_location_type;
   324         locationtype_t location_type = search_location_type.get_location_type(symbol->location);
   397         switch (search_location_type.get_location_type(symbol->location)) {
   325         if (location_type == input_lt)
   398           case search_location_type_c::input_lt:
   326           this->current_var_type_category = located_input_vtc;
   399             this->current_var_class_category = located_input_vcc;
   327         else if (location_type == memory_lt)
   400             break;
   328           this->current_var_type_category = located_memory_vtc;
   401           case search_location_type_c::memory_lt:
   329         else if (location_type == output_lt)
   402             this->current_var_class_category = located_memory_vcc;
   330           this->current_var_type_category = located_output_vtc;
   403             break;
       
   404           case search_location_type_c::output_lt:
       
   405               this->current_var_class_category = located_output_vcc;
       
   406               break;
       
   407           default:
       
   408             ERROR;
       
   409             break;
       
   410         }
   331 
   411 
   332         if (symbol->variable_name != NULL)
   412         if (symbol->variable_name != NULL)
   333           declare_variable(symbol->variable_name);
   413           declare_variable(symbol->variable_name);
   334         else
   414         else
   335           declare_variable(symbol->location);
   415           declare_variable(symbol->location);
   336         
   416         
   337         current_var_type_symbol = NULL;
   417         this->current_var_class_category = none_vcc;
       
   418 
       
   419         /* Values no longer in scope, and therefore no longer used.
       
   420          * Make an effort to keep them set to NULL when not in use
       
   421          * in order to catch bugs as soon as possible...
       
   422          */
       
   423         reset_var_type_symbol();
   338         return NULL;
   424         return NULL;
   339     }
   425     }
   340 
   426 
   341     /* variable_name incompl_location ':' var_spec */
   427     /* variable_name incompl_location ':' var_spec */
   342     /* variable_name -> may be NULL ! */
   428     /* variable_name -> may be NULL ! */
   346          * current_var_init_symbol private variables...
   432          * current_var_init_symbol private variables...
   347          */
   433          */
   348         update_var_type_symbol(symbol->var_spec);
   434         update_var_type_symbol(symbol->var_spec);
   349 
   435 
   350         search_location_type_c search_location_type;
   436         search_location_type_c search_location_type;
   351         locationtype_t location_type = search_location_type.get_location_type(symbol->incompl_location);
   437         switch (search_location_type.get_location_type(symbol->incompl_location)) {
   352         if (location_type == input_lt)
   438           case search_location_type_c::input_lt:
   353           this->current_var_type_category = located_input_vtc;
   439             this->current_var_class_category = located_input_vcc;
   354         else if (location_type == memory_lt)
   440             break;
   355           this->current_var_type_category = located_memory_vtc;
   441           case search_location_type_c::memory_lt:
   356         else if (location_type == output_lt)
   442             this->current_var_class_category = located_memory_vcc;
   357           this->current_var_type_category = located_output_vtc;
   443             break;
       
   444           case search_location_type_c::output_lt:
       
   445             this->current_var_class_category = located_output_vcc;
       
   446             break;
       
   447           default:
       
   448             ERROR;
       
   449             break;
       
   450         }
   358 
   451 
   359         if (symbol->variable_name != NULL)
   452         if (symbol->variable_name != NULL)
   360           declare_variable(symbol->variable_name);
   453           declare_variable(symbol->variable_name);
   361         else
   454         else
   362           declare_variable(symbol->incompl_location);
   455           declare_variable(symbol->incompl_location);
   363 
   456 
   364         current_var_type_symbol = NULL;
   457         this->current_var_class_category = none_vcc;
       
   458 
       
   459         /* Values no longer in scope, and therefore no longer used.
       
   460         * Make an effort to keep them set to NULL when not in use
       
   461         * in order to catch bugs as soon as possible...
       
   462         */
       
   463        reset_var_type_symbol();
   365         return NULL;
   464         return NULL;
   366     }
   465     }
   367     
   466     
   368     /*  var1_list ':' array_spec_init */
   467     /*  var1_list ':' array_spec_init */
   369     // SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init)
   468     // SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init)
   372       /* Start off by setting the current_var_type_symbol and
   471       /* Start off by setting the current_var_type_symbol and
   373        * current_var_init_symbol private variables...
   472        * current_var_init_symbol private variables...
   374        */
   473        */
   375       update_var_type_symbol(symbol->array_spec_init);
   474       update_var_type_symbol(symbol->array_spec_init);
   376       
   475       
   377       this->current_var_type_category = array_vtc;
       
   378       declare_variables(symbol->var1_list);
   476       declare_variables(symbol->var1_list);
   379     
   477     
   380       /* Values no longer in scope, and therefore no longer used.
   478       /* Values no longer in scope, and therefore no longer used.
   381        * Make an effort to keep them set to NULL when not in use
   479        * Make an effort to keep them set to NULL when not in use
   382        * in order to catch bugs as soon as possible...
   480        * in order to catch bugs as soon as possible...
   398        * current_var_init_symbol private variables...
   496        * current_var_init_symbol private variables...
   399        */
   497        */
   400       update_var_type_symbol(symbol->initialized_structure);
   498       update_var_type_symbol(symbol->initialized_structure);
   401     
   499     
   402       /* now to produce the c equivalent... */
   500       /* now to produce the c equivalent... */
   403       this->current_var_type_category = structure_vtc;
       
   404       declare_variables(symbol->var1_list);
   501       declare_variables(symbol->var1_list);
   405     
   502     
   406       /* Values no longer in scope, and therefore no longer used.
   503       /* Values no longer in scope, and therefore no longer used.
   407        * Make an effort to keep them set to NULL when not in use
   504        * Make an effort to keep them set to NULL when not in use
   408        * in order to catch bugs as soon as possible...
   505        * in order to catch bugs as soon as possible...
   448       /* Start off by setting the current_var_type_symbol and
   545       /* Start off by setting the current_var_type_symbol and
   449        * current_var_init_symbol private variables...
   546        * current_var_init_symbol private variables...
   450        */
   547        */
   451       update_var_type_symbol(symbol->specification);
   548       update_var_type_symbol(symbol->specification);
   452       
   549       
       
   550       this->current_var_class_category = external_vcc;
       
   551 
   453       /* now to produce the c equivalent... */
   552       /* now to produce the c equivalent... */
   454       this->current_var_type_category = external_vtc;
       
   455       declare_variable(symbol->global_var_name);
   553       declare_variable(symbol->global_var_name);
   456       
   554       
       
   555       this->current_var_class_category = none_vcc;
       
   556 
   457       /* Values no longer in scope, and therefore no longer used.
   557       /* Values no longer in scope, and therefore no longer used.
   458        * Make an effort to keep them set to NULL when not in use
   558        * Make an effort to keep them set to NULL when not in use
   459        * in order to catch bugs as soon as possible...
   559        * in order to catch bugs as soon as possible...
   460        */
   560        */
   461       reset_var_type_symbol();
   561       reset_var_type_symbol();
   462     
       
   463       return NULL;
   562       return NULL;
   464     }
   563     }
   465 
   564 
   466     /*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */
   565     /*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */
   467     /* type_specification ->may be NULL ! */
   566     /* type_specification ->may be NULL ! */
   496     
   595     
   497     /*| global_var_name location */
   596     /*| global_var_name location */
   498     // SYM_REF2(global_var_spec_c, global_var_name, location)
   597     // SYM_REF2(global_var_spec_c, global_var_name, location)
   499     void *visit(global_var_spec_c *symbol) {
   598     void *visit(global_var_spec_c *symbol) {
   500       search_location_type_c search_location_type;
   599       search_location_type_c search_location_type;
   501 	  locationtype_t location_type = search_location_type.get_location_type(symbol->location);
   600 	  switch (search_location_type.get_location_type(symbol->location)) {
   502 	  if (location_type == input_lt)
   601 		case search_location_type_c::input_lt:
   503         this->current_var_type_category = located_input_vtc;
   602 		  this->current_var_class_category = located_input_vcc;
   504       else if (location_type == memory_lt)
   603 		  break;
   505         this->current_var_type_category = located_memory_vtc;
   604 		case search_location_type_c::memory_lt:
   506       else if (location_type == output_lt)
   605 		  this->current_var_class_category = located_memory_vcc;
   507         this->current_var_type_category = located_output_vtc;
   606 		  break;
       
   607 		case search_location_type_c::output_lt:
       
   608 		  this->current_var_class_category = located_output_vcc;
       
   609 		  break;
       
   610 		default:
       
   611 		  ERROR;
       
   612 	      break;
       
   613 	  }
   508 
   614 
   509       if (symbol->global_var_name != NULL)
   615       if (symbol->global_var_name != NULL)
   510         declare_variable(symbol->global_var_name);
   616         declare_variable(symbol->global_var_name);
   511       else
   617       else
   512         declare_variable(symbol->location);
   618         declare_variable(symbol->location);
       
   619 
       
   620       this->current_var_class_category = none_vcc;
       
   621 
   513       return NULL;
   622       return NULL;
   514     }
   623     }
   515     
   624     
   516     void *visit(var1_init_decl_c *symbol) {
   625     void *visit(var1_init_decl_c *symbol) {
   517       TRACE("var1_init_decl_c");
   626       TRACE("var1_init_decl_c");
   537       TRACE("en_param_declaration_c");
   646       TRACE("en_param_declaration_c");
   538 
   647 
   539       /* Start off by setting the current_var_type_symbol and
   648       /* Start off by setting the current_var_type_symbol and
   540        * current_var_init_symbol private variables...
   649        * current_var_init_symbol private variables...
   541        */
   650        */
   542       this->current_var_type_symbol = symbol->type;
   651       update_var_type_symbol(symbol->type);
   543 
   652 
   544       /* now to produce the c equivalent... */
   653       /* now to produce the c equivalent... */
   545       declare_variable(symbol->name);
   654       declare_variable(symbol->name);
   546 
   655 
   547       /* Values no longer in scope, and therefore no longer used.
   656       /* Values no longer in scope, and therefore no longer used.
   557       TRACE("eno_param_declaration_c");
   666       TRACE("eno_param_declaration_c");
   558 
   667 
   559       /* Start off by setting the current_var_type_symbol and
   668       /* Start off by setting the current_var_type_symbol and
   560        * current_var_init_symbol private variables...
   669        * current_var_init_symbol private variables...
   561        */
   670        */
   562       this->current_var_type_symbol = symbol->type;
   671       update_var_type_symbol(symbol->type);
   563 
   672 
   564       /* now to produce the c equivalent... */
   673       /* now to produce the c equivalent... */
   565       declare_variable(symbol->name);
   674       declare_variable(symbol->name);
   566 
   675 
   567       /* Values no longer in scope, and therefore no longer used.
   676       /* Values no longer in scope, and therefore no longer used.