stage4/generate_cc/search_var_instance_decl.cc
changeset 28 5b170c9ce134
parent 26 fd67f54e64e1
child 41 8998c8b24b60
equal deleted inserted replaced
27:667721cf52c5 28:5b170c9ce134
    88     static const unsigned int output_vt   = 0x0002;  // VAR_OUTPUT
    88     static const unsigned int output_vt   = 0x0002;  // VAR_OUTPUT
    89     static const unsigned int inoutput_vt = 0x0004;  // VAR_IN_OUT
    89     static const unsigned int inoutput_vt = 0x0004;  // VAR_IN_OUT
    90     static const unsigned int private_vt  = 0x0008;  // VAR
    90     static const unsigned int private_vt  = 0x0008;  // VAR
    91     static const unsigned int temp_vt   = 0x0010;  // VAR_TEMP
    91     static const unsigned int temp_vt   = 0x0010;  // VAR_TEMP
    92     static const unsigned int external_vt = 0x0020;  // VAR_EXTERNAL
    92     static const unsigned int external_vt = 0x0020;  // VAR_EXTERNAL
       
    93     static const unsigned int global_vt = 0x0040;  // VAR_GLOBAL
    93     static const unsigned int located_vt  = 0x0080;  // VAR <var_name> AT <location>
    94     static const unsigned int located_vt  = 0x0080;  // VAR <var_name> AT <location>
    94 
    95 
    95 
    96 
    96 /***************************/
    97 /***************************/
    97 /* B 0 - Programming Model */
    98 /* B 0 - Programming Model */
   180 /* option -> may be NULL ! */
   181 /* option -> may be NULL ! */
   181 //SYM_REF2(external_var_declarations_c, option, external_declaration_list)
   182 //SYM_REF2(external_var_declarations_c, option, external_declaration_list)
   182     void *visit(external_var_declarations_c *symbol) {
   183     void *visit(external_var_declarations_c *symbol) {
   183       current_vartype = external_vt;
   184       current_vartype = external_vt;
   184       void *res = symbol->external_declaration_list->accept(*this);
   185       void *res = symbol->external_declaration_list->accept(*this);
       
   186       if (res == NULL) {
       
   187         current_vartype = none_vt;
       
   188       }
       
   189       return res;
       
   190     }
       
   191 
       
   192 /*| VAR_GLOBAL [CONSTANT|RETAIN] global_var_decl_list END_VAR */
       
   193 /* option -> may be NULL ! */
       
   194 //SYM_REF2(global_var_declarations_c, option, global_var_decl_list)
       
   195     void *visit(global_var_declarations_c *symbol) {
       
   196       current_vartype = global_vt;
       
   197       void *res = symbol->global_var_decl_list->accept(*this);
   185       if (res == NULL) {
   198       if (res == NULL) {
   186         current_vartype = none_vt;
   199         current_vartype = none_vt;
   187       }
   200       }
   188       return res;
   201       return res;
   189     }
   202     }
   266 // SYM_REF2(external_declaration_c, global_var_name, specification)
   279 // SYM_REF2(external_declaration_c, global_var_name, specification)
   267     void *visit(external_declaration_c *symbol) {
   280     void *visit(external_declaration_c *symbol) {
   268       if (compare_identifiers(symbol->global_var_name, search_name) == 0)
   281       if (compare_identifiers(symbol->global_var_name, search_name) == 0)
   269           return symbol->specification;
   282           return symbol->specification;
   270       return NULL;
   283       return NULL;
       
   284     }
       
   285 
       
   286 /*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */
       
   287 /* type_specification ->may be NULL ! */
       
   288 // SYM_REF2(global_var_decl_c, global_var_spec, type_specification)
       
   289     void *visit(global_var_decl_c *symbol) {
       
   290       if (symbol->type_specification != NULL) {
       
   291         current_type_decl = symbol->type_specification;
       
   292         return symbol->global_var_spec->accept(*this);
       
   293       }
       
   294       else
       
   295         return NULL;
       
   296     }
       
   297 
       
   298 /*| global_var_name location */
       
   299 //SYM_REF2(global_var_spec_c, global_var_name, location)
       
   300     void *visit(global_var_spec_c *symbol) {
       
   301       if (symbol->global_var_name != NULL && compare_identifiers(symbol->global_var_name, search_name) == 0)
       
   302           return current_type_decl;
       
   303       else 
       
   304         return symbol->location->accept(*this);
       
   305     }
       
   306 
       
   307 /*| global_var_list ',' global_var_name */
       
   308 //SYM_LIST(global_var_list_c)
       
   309     void *visit(global_var_list_c *symbol) {
       
   310       list_c *list = symbol;
       
   311       for(int i = 0; i < list->n; i++) {
       
   312         if (compare_identifiers(list->elements[i], search_name) == 0)
       
   313           /* by now, current_type_decl should be != NULL */
       
   314           return current_type_decl;
       
   315       }
       
   316       return NULL;
       
   317     }
       
   318 
       
   319 /*  AT direct_variable */
       
   320 //SYM_REF2(location_c, direct_variable, unused)
       
   321     void *visit(location_c *symbol) {
       
   322       if (compare_identifiers(symbol->direct_variable, search_name) == 0) {
       
   323         current_vartype = located_vt;
       
   324         return current_type_decl;
       
   325       }
       
   326       else
       
   327         return NULL;
   271     }
   328     }
   272 
   329 
   273 /*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */
   330 /*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */
   274 /* type_specification ->may be NULL ! */
   331 /* type_specification ->may be NULL ! */
   275 // SYM_REF2(global_var_decl_c, global_var_spec, type_specification)
   332 // SYM_REF2(global_var_decl_c, global_var_spec, type_specification)
   361        */
   418        */
   362       return symbol->var_declarations->accept(*this);
   419       return symbol->var_declarations->accept(*this);
   363     }
   420     }
   364 
   421 
   365 
   422 
       
   423 /********************************/
       
   424 /* B 1.7 Configuration elements */
       
   425 /********************************/
       
   426 
       
   427 /*
       
   428 CONFIGURATION configuration_name
       
   429    optional_global_var_declarations
       
   430    (resource_declaration_list | single_resource_declaration)
       
   431    optional_access_declarations
       
   432    optional_instance_specific_initializations
       
   433 END_CONFIGURATION
       
   434 */
       
   435 /*
       
   436 SYM_REF6(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations, unused)
       
   437 */
       
   438     void *visit(configuration_declaration_c *symbol) {
       
   439       /* no need to search through all the configuration, so we only
       
   440        * visit the global variable declarations...!
       
   441        */
       
   442       if (symbol->global_var_declarations != NULL)
       
   443         return symbol->global_var_declarations->accept(*this);
       
   444       else
       
   445         return NULL;
       
   446     }
       
   447 
       
   448 /*
       
   449 RESOURCE resource_name ON resource_type_name
       
   450    optional_global_var_declarations
       
   451    single_resource_declaration
       
   452 END_RESOURCE
       
   453 */
       
   454 // SYM_REF4(resource_declaration_c, resource_name, resource_type_name, global_var_declarations, resource_declaration)
       
   455     void *visit(resource_declaration_c *symbol) {
       
   456       /* no need to search through all the resource, so we only
       
   457        * visit the global variable declarations...!
       
   458        */
       
   459       if (symbol->global_var_declarations != NULL)
       
   460         return symbol->global_var_declarations->accept(*this);
       
   461       else
       
   462         return NULL;
       
   463     }
       
   464 
       
   465 /* task_configuration_list program_configuration_list */
       
   466 // SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list)
       
   467     void *visit(single_resource_declaration_c *symbol) {
       
   468       /* no need to search through all the resource,
       
   469        * and there is no global variable declarations...!
       
   470        */
       
   471       return NULL;
       
   472     }
       
   473 
   366 #if 0
   474 #if 0
   367 /*********************/
   475 /*********************/
   368 /* B 1.4 - Variables */
   476 /* B 1.4 - Variables */
   369 /*********************/
   477 /*********************/
   370 SYM_REF2(symbolic_variable_c, var_name, unused)
   478 SYM_REF2(symbolic_variable_c, var_name, unused)
   393 
   501 
   394 
   502 
   395 #endif
   503 #endif
   396 };
   504 };
   397 
   505 
   398 
       
   399 
       
   400 
       
   401