stage4/generate_cc/search_var_instance_decl.cc
changeset 25 e6a841e365b7
parent 0 fb772792efd1
child 26 fd67f54e64e1
equal deleted inserted replaced
24:7e830409f72a 25:e6a841e365b7
    56 
    56 
    57   private:
    57   private:
    58     symbol_c *search_scope;
    58     symbol_c *search_scope;
    59     symbol_c *search_name;
    59     symbol_c *search_name;
    60     symbol_c *current_type_decl;
    60     symbol_c *current_type_decl;
       
    61     
       
    62     /* variable used to store the type of variable currently being processed... */
       
    63     /* Will contain a single value of generate_cc_vardecl_c::XXXX_vt */
       
    64     unsigned int current_vartype;
    61 
    65 
    62   public:
    66   public:
    63     search_var_instance_decl_c(symbol_c *search_scope) {
    67     search_var_instance_decl_c(symbol_c *search_scope) {
       
    68       this->current_vartype = none_vt;
    64       this->search_scope = search_scope;
    69       this->search_scope = search_scope;
    65       this->search_name = NULL;
    70       this->search_name = NULL;
    66       this->current_type_decl = NULL;
    71       this->current_type_decl = NULL;
    67     }
    72     }
    68 
    73 
    69     symbol_c *get_decl(symbol_c *variable_instance_name) {
    74     symbol_c *get_decl(symbol_c *variable_instance_name) {
    70       this->search_name = variable_instance_name;
    75       this->search_name = variable_instance_name;
    71       return (symbol_c *)search_scope->accept(*this);
    76       return (symbol_c *)search_scope->accept(*this);
    72     }
    77     }
    73 
    78 
       
    79     unsigned int get_vartype() {
       
    80       return current_vartype;
       
    81     }
       
    82 
    74   public:
    83   public:
       
    84   
       
    85     /* the types of variables that need to be processed... */
       
    86     static const unsigned int none_vt   = 0x0000;
       
    87     static const unsigned int input_vt    = 0x0001;  // VAR_INPUT
       
    88     static const unsigned int output_vt   = 0x0002;  // VAR_OUTPUT
       
    89     static const unsigned int inoutput_vt = 0x0004;  // VAR_IN_OUT
       
    90     static const unsigned int private_vt  = 0x0008;  // VAR
       
    91     static const unsigned int temp_vt   = 0x0010;  // VAR_TEMP
       
    92     static const unsigned int external_vt = 0x0020;  // VAR_EXTERNAL
       
    93     static const unsigned int located_vt  = 0x0080;  // VAR <var_name> AT <location>
       
    94 
       
    95 
    75 /***************************/
    96 /***************************/
    76 /* B 0 - Programming Model */
    97 /* B 0 - Programming Model */
    77 /***************************/
    98 /***************************/
    78     void *visit(library_c *symbol) {
    99     void *visit(library_c *symbol) {
    79       /* we do not want to search multiple declaration scopes,
   100       /* we do not want to search multiple declaration scopes,
    88 /* B 1.4.3 - Declaration & Initialisation */
   109 /* B 1.4.3 - Declaration & Initialisation */
    89 /******************************************/
   110 /******************************************/
    90 /* edge -> The F_EDGE or R_EDGE directive */
   111 /* edge -> The F_EDGE or R_EDGE directive */
    91 // SYM_REF2(edge_declaration_c, edge, var1_list)
   112 // SYM_REF2(edge_declaration_c, edge, var1_list)
    92 // TODO
   113 // TODO
       
   114 
       
   115     void *visit(input_declarations_c *symbol) {
       
   116       current_vartype = input_vt;
       
   117       void *res = symbol->input_declaration_list->accept(*this);
       
   118       if (res == NULL) {
       
   119         current_vartype = none_vt;
       
   120       }
       
   121       return res;
       
   122     }
       
   123 
       
   124 /* VAR_OUTPUT [RETAIN | NON_RETAIN] var_init_decl_list END_VAR */
       
   125 /* option -> may be NULL ! */
       
   126     void *visit(output_declarations_c *symbol) {
       
   127       current_vartype = output_vt;
       
   128       void *res = symbol->var_init_decl_list->accept(*this);
       
   129       if (res == NULL) {
       
   130         current_vartype = none_vt;
       
   131       }
       
   132       return res;
       
   133     }
       
   134 
       
   135 /*  VAR_IN_OUT var_declaration_list END_VAR */
       
   136     void *visit(input_output_declarations_c *symbol) {
       
   137       current_vartype = inoutput_vt;
       
   138       void *res = symbol->var_declaration_list->accept(*this);
       
   139       if (res == NULL) {
       
   140         current_vartype = none_vt;
       
   141       }
       
   142       return res;
       
   143     }
       
   144 
       
   145 /* VAR [CONSTANT] var_init_decl_list END_VAR */
       
   146 /* option -> may be NULL ! */
       
   147 /* helper symbol for input_declarations */
       
   148     void *visit(var_declarations_c *symbol) {
       
   149       current_vartype = private_vt;
       
   150       void *res = symbol->var_init_decl_list->accept(*this);
       
   151       if (res == NULL) {
       
   152         current_vartype = none_vt;
       
   153       }
       
   154       return NULL;
       
   155     }
       
   156 
       
   157 /*  VAR RETAIN var_init_decl_list END_VAR */
       
   158     void *visit(retentive_var_declarations_c *symbol) {
       
   159       current_vartype = private_vt;
       
   160       void *res = symbol->var_init_decl_list->accept(*this);
       
   161       if (res == NULL) {
       
   162         current_vartype = none_vt;
       
   163       }
       
   164       return NULL;
       
   165     }
       
   166 
       
   167 /*  VAR [CONSTANT|RETAIN|NON_RETAIN] located_var_decl_list END_VAR */
       
   168 /* option -> may be NULL ! */
       
   169 //SYM_REF2(located_var_declarations_c, option, located_var_decl_list)
       
   170     void *visit(located_var_declarations_c *symbol) {
       
   171       current_vartype = located_vt;
       
   172       void *res = symbol->located_var_decl_list->accept(*this);
       
   173       if (res == NULL) {
       
   174         current_vartype = none_vt;
       
   175       }
       
   176       return NULL;
       
   177     }
       
   178 
       
   179 /*| VAR_EXTERNAL [CONSTANT] external_declaration_list END_VAR */
       
   180 /* option -> may be NULL ! */
       
   181 //SYM_REF2(external_var_declarations_c, option, external_declaration_list)
       
   182     void *visit(external_var_declarations_c *symbol) {
       
   183       current_vartype = external_vt;
       
   184       void *res = symbol->external_declaration_list->accept(*this);
       
   185       if (res == NULL) {
       
   186         current_vartype = none_vt;
       
   187       }
       
   188       return NULL;
       
   189     }
    93 
   190 
    94 /* var1_list is one of the following...
   191 /* var1_list is one of the following...
    95  *    simple_spec_init_c *
   192  *    simple_spec_init_c *
    96  *    subrange_spec_init_c *
   193  *    subrange_spec_init_c *
    97  *    enumerated_spec_init_c *
   194  *    enumerated_spec_init_c *