absyntax_utils/search_varfb_instance_type.cc
changeset 718 a9f8cc778444
parent 693 51a2fa6441b9
child 830 6f45ec6ed011
equal deleted inserted replaced
717:44f74fad2cc0 718:a9f8cc778444
   134 // SYM_TOKEN(identifier_c)
   134 // SYM_TOKEN(identifier_c)
   135 void *search_varfb_instance_type_c::visit(identifier_c *variable_name) {
   135 void *search_varfb_instance_type_c::visit(identifier_c *variable_name) {
   136   /* symbol should be a variable name!! */
   136   /* symbol should be a variable name!! */
   137   /* Note: although the method is called get_decl(), it is getting the declaration of the variable, which for us is the type_id of that variable! */
   137   /* Note: although the method is called get_decl(), it is getting the declaration of the variable, which for us is the type_id of that variable! */
   138   current_type_id       = search_var_instance_decl.get_decl (variable_name);
   138   current_type_id       = search_var_instance_decl.get_decl (variable_name);
   139   current_basetype_decl = search_base_type.get_basetype_decl(current_type_id);
   139   current_basetype_decl = search_base_type_c::get_basetype_decl(current_type_id);
   140   current_basetype_id   = search_base_type.get_basetype_id  (current_type_id);
   140   current_basetype_id   = search_base_type_c::get_basetype_id  (current_type_id);
   141     
   141     
   142   /* What if the variable has not been declared?  Then this should not be a compiler error! 
   142   /* What if the variable has not been declared?  Then this should not be a compiler error! 
   143    * However, currently stage 2 of the compiler already detects when variables have not been delcared,
   143    * However, currently stage 2 of the compiler already detects when variables have not been delcared,
   144    * so if the variable's declaration is not found, then that means that we have an internal compiler error!
   144    * so if the variable's declaration is not found, then that means that we have an internal compiler error!
   145    * 
   145    * 
   191  * and not the data type of the array itself!
   191  * and not the data type of the array itself!
   192  */
   192  */
   193 void *search_varfb_instance_type_c::visit(array_specification_c *symbol) {
   193 void *search_varfb_instance_type_c::visit(array_specification_c *symbol) {
   194   /* found the type of the element we were looking for! */
   194   /* found the type of the element we were looking for! */
   195   current_type_id       = symbol->non_generic_type_name;
   195   current_type_id       = symbol->non_generic_type_name;
   196   current_basetype_decl = search_base_type.get_basetype_decl(current_type_id);
   196   current_basetype_decl = search_base_type_c::get_basetype_decl(current_type_id);
   197   current_basetype_id   = search_base_type.get_basetype_id  (current_type_id);
   197   current_basetype_id   = search_base_type_c::get_basetype_id  (current_type_id);
   198     
   198     
   199   return NULL; 
   199   return NULL; 
   200 }
   200 }
   201 
   201 
   202 
   202 
   254   if (NULL == current_field_selector) ERROR;
   254   if (NULL == current_field_selector) ERROR;
   255 
   255 
   256   if (compare_identifiers(symbol->structure_element_name, current_field_selector) == 0) {
   256   if (compare_identifiers(symbol->structure_element_name, current_field_selector) == 0) {
   257     /* found the type of the element we were looking for! */
   257     /* found the type of the element we were looking for! */
   258     current_type_id       = symbol->spec_init;
   258     current_type_id       = symbol->spec_init;
   259     current_basetype_decl = search_base_type.get_basetype_decl(current_type_id);
   259     current_basetype_decl = search_base_type_c::get_basetype_decl(current_type_id);
   260     current_basetype_id   = search_base_type.get_basetype_id  (current_type_id);
   260     current_basetype_id   = search_base_type_c::get_basetype_id  (current_type_id);
   261   }  
   261   }  
   262 
   262 
   263   /* Did not find the type of the element we were looking for! */
   263   /* Did not find the type of the element we were looking for! */
   264   /* Will keep looking... */
   264   /* Will keep looking... */
   265   return NULL;
   265   return NULL;
   361 
   361 
   362   /* now search the function block declaration for the variable... */
   362   /* now search the function block declaration for the variable... */
   363   /* If not found, these pointers will all be set to NULL!! */
   363   /* If not found, these pointers will all be set to NULL!! */
   364   search_var_instance_decl_c search_decl(symbol);
   364   search_var_instance_decl_c search_decl(symbol);
   365   current_type_id       = search_decl.get_decl(current_field_selector);
   365   current_type_id       = search_decl.get_decl(current_field_selector);
   366   current_basetype_decl = search_base_type.get_basetype_decl(current_type_id);
   366   current_basetype_decl = search_base_type_c::get_basetype_decl(current_type_id);
   367   current_basetype_id   = search_base_type.get_basetype_id  (current_type_id);
   367   current_basetype_id   = search_base_type_c::get_basetype_id  (current_type_id);
   368   
   368   
   369   return NULL;
   369   return NULL;
   370 }
   370 }
   371 
   371 
   372 
   372 
   387   if (compare_identifiers(&T, current_field_selector) == 0)   
   387   if (compare_identifiers(&T, current_field_selector) == 0)   
   388     current_type_id = &get_datatype_info_c::time_type_name;
   388     current_type_id = &get_datatype_info_c::time_type_name;
   389   if (compare_identifiers(&X, current_field_selector) == 0)   
   389   if (compare_identifiers(&X, current_field_selector) == 0)   
   390     current_type_id = &get_datatype_info_c::bool_type_name;
   390     current_type_id = &get_datatype_info_c::bool_type_name;
   391   
   391   
   392   current_basetype_decl = search_base_type.get_basetype_decl(current_type_id);
   392   current_basetype_decl = search_base_type_c::get_basetype_decl(current_type_id);
   393   current_basetype_id   = search_base_type.get_basetype_id  (current_type_id);
   393   current_basetype_id   = search_base_type_c::get_basetype_id  (current_type_id);
   394 
   394 
   395   return NULL;
   395   return NULL;
   396 }
   396 }
   397 
   397 
   398 
   398