stage3/datatype_functions.cc
changeset 676 ca4f17211251
parent 666 8ba9ec4bae50
child 693 51a2fa6441b9
equal deleted inserted replaced
675:59fc28d4b06c 676:ca4f17211251
   401 int search_in_candidate_datatype_list(symbol_c *datatype, const std::vector <symbol_c *> &candidate_datatypes) {
   401 int search_in_candidate_datatype_list(symbol_c *datatype, const std::vector <symbol_c *> &candidate_datatypes) {
   402 	if (NULL == datatype) 
   402 	if (NULL == datatype) 
   403 		return -1;
   403 		return -1;
   404 
   404 
   405 	for(unsigned int i = 0; i < candidate_datatypes.size(); i++)
   405 	for(unsigned int i = 0; i < candidate_datatypes.size(); i++)
   406 		if (is_type_equal(datatype, candidate_datatypes[i]))
   406 		if (get_datatype_info_c::is_type_equal(datatype, candidate_datatypes[i]))
   407 			return i;
   407 			return i;
   408 	/* Not found ! */
   408 	/* Not found ! */
   409 	return -1;
   409 	return -1;
   410 }
   410 }
   411 
   411 
   462 
   462 
   463 
   463 
   464 
   464 
   465 
   465 
   466 
   466 
   467 bool is_type_equal(symbol_c *first_type, symbol_c *second_type) {
       
   468   if ((NULL == first_type) || (NULL == second_type))
       
   469       return false;
       
   470   if (typeid(* first_type) == typeid(invalid_type_name_c))
       
   471       return false;
       
   472   if (typeid(*second_type) == typeid(invalid_type_name_c))
       
   473       return false;
       
   474     
       
   475   if (get_datatype_info_c::is_ANY_ELEMENTARY(first_type)) {
       
   476       if (typeid(*first_type) == typeid(*second_type))
       
   477           return true;
       
   478   } else   /* ANY_DERIVED */
       
   479       return (first_type == second_type);
       
   480 
       
   481   return false;
       
   482 }
       
   483 
       
   484 
       
   485 
       
   486 bool is_type_valid(symbol_c *type) {
       
   487   if (NULL == type)
       
   488       return false;
       
   489   if (typeid(*type) == typeid(invalid_type_name_c))
       
   490       return false;
       
   491 
       
   492   return true;
       
   493 }