stage3/datatype_functions.cc
changeset 459 01f6664bf8c5
parent 458 587884880be6
child 467 4910eaa1206a
equal deleted inserted replaced
458:587884880be6 459:01f6664bf8c5
   226 }
   226 }
   227 
   227 
   228 
   228 
   229 
   229 
   230 
   230 
       
   231 /* intersect the candidate_datatype lists of all prev_il_intructions, and set the local candidate_datatype list to the result! */
       
   232 void intersect_prev_candidate_datatype_lists(il_instruction_c *symbol) {
       
   233 	if (symbol->prev_il_instruction.empty())
       
   234 		return;
       
   235 	
       
   236 	copy_candidate_datatype_list(symbol->prev_il_instruction[0] /*from*/, symbol /*to*/);
       
   237 	for (unsigned int i = 1; i < symbol->prev_il_instruction.size(); i++) {
       
   238 		intersect_candidate_datatype_list(symbol /*origin, dest.*/, symbol->prev_il_instruction[i] /*with*/);
       
   239 	}  
       
   240 }
       
   241 
       
   242 
       
   243 
       
   244 
   231 /* A helper function... */
   245 /* A helper function... */
   232 bool is_ANY_ELEMENTARY_type(symbol_c *type_symbol) {
   246 bool is_ANY_ELEMENTARY_type(symbol_c *type_symbol) {
   233   if (type_symbol == NULL) {return false;}
   247   if (type_symbol == NULL) {return false;}
   234   return is_ANY_MAGNITUDE_type(type_symbol)
   248   return is_ANY_MAGNITUDE_type(type_symbol)
   235       || is_ANY_BIT_type      (type_symbol)
   249       || is_ANY_BIT_type      (type_symbol)
   542 
   556 
   543 
   557 
   544 
   558 
   545 
   559 
   546 
   560 
   547 bool is_type_equal(symbol_c *first_type, symbol_c *second_type)
   561 bool is_type_equal(symbol_c *first_type, symbol_c *second_type) {
   548 {
   562   if ((NULL == first_type) || (NULL == second_type))
   549     if (first_type == NULL || second_type == NULL) {
   563       return false;
   550         return false;
   564   if (typeid(* first_type) == typeid(invalid_type_name_c))
   551     }
   565       return false;
   552     if (is_ANY_ELEMENTARY_type(first_type)) {
   566   if (typeid(*second_type) == typeid(invalid_type_name_c))
   553         if (typeid(*first_type) == typeid(*second_type))
   567       return false;
   554             return true;
   568     
   555     } else   /* ANY_DERIVED */
   569   if (is_ANY_ELEMENTARY_type(first_type)) {
   556         return (first_type == second_type);
   570       if (typeid(*first_type) == typeid(*second_type))
   557 
   571           return true;
   558     return false;
   572   } else   /* ANY_DERIVED */
   559 }
   573       return (first_type == second_type);
       
   574 
       
   575   return false;
       
   576 }
       
   577 
       
   578 
       
   579 
       
   580 bool is_type_valid(symbol_c *type) {
       
   581   if (NULL == type)
       
   582       return false;
       
   583   if (typeid(*type) == typeid(invalid_type_name_c))
       
   584       return false;
       
   585 
       
   586   return true;
       
   587 }