stage3/fill_candidate_datatypes.cc
changeset 445 e6c34ee82954
parent 443 ff4d26b7e51d
child 447 aad0f3e5df33
equal deleted inserted replaced
444:92d40d2a7adc 445:e6c34ee82954
    93 
    93 
    94 		/* Get the parameter type */
    94 		/* Get the parameter type */
    95 		param_type = base_type(fp_iterator.param_type());
    95 		param_type = base_type(fp_iterator.param_type());
    96 		
    96 		
    97 		/* check whether one of the candidate_data_types of the value being passed is the same as the param_type */
    97 		/* check whether one of the candidate_data_types of the value being passed is the same as the param_type */
    98 		if (search_in_datatype_list(param_type, call_param_value->candidate_datatypes) < 0)
    98 		if (search_in_candidate_datatype_list(param_type, call_param_value->candidate_datatypes) < 0)
    99 			return false; /* return false if param_type not in the list! */
    99 			return false; /* return false if param_type not in the list! */
   100 	}
   100 	}
   101 	/* call is compatible! */
   101 	/* call is compatible! */
   102 	return true;
   102 	return true;
   103 }
   103 }
   136 		param_name = fp_iterator.search(call_param_name);
   136 		param_name = fp_iterator.search(call_param_name);
   137 		if(param_name == NULL) return false;
   137 		if(param_name == NULL) return false;
   138 		/* Get the parameter type */
   138 		/* Get the parameter type */
   139 		param_type = base_type(fp_iterator.param_type());
   139 		param_type = base_type(fp_iterator.param_type());
   140 		/* check whether one of the candidate_data_types of the value being passed is the same as the param_type */
   140 		/* check whether one of the candidate_data_types of the value being passed is the same as the param_type */
   141 		if (search_in_datatype_list(param_type, call_param_types) < 0)
   141 		if (search_in_candidate_datatype_list(param_type, call_param_types) < 0)
   142 			return false; /* return false if param_type not in the list! */
   142 			return false; /* return false if param_type not in the list! */
   143 	}
   143 	}
   144 	/* call is compatible! */
   144 	/* call is compatible! */
   145 	return true;
   145 	return true;
   146 }
   146 }
   432 }
   432 }
   433 
   433 
   434 // SYM_REF2(integer_literal_c, type, value)
   434 // SYM_REF2(integer_literal_c, type, value)
   435 void *fill_candidate_datatypes_c::visit(integer_literal_c *symbol) {
   435 void *fill_candidate_datatypes_c::visit(integer_literal_c *symbol) {
   436 	symbol->value->accept(*this);
   436 	symbol->value->accept(*this);
   437 	if (search_in_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   437 	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   438 		symbol->candidate_datatypes.push_back(symbol->type);
   438 		symbol->candidate_datatypes.push_back(symbol->type);
   439 	if (debug) std::cout << "INT_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
   439 	if (debug) std::cout << "INT_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
   440 	return NULL;
   440 	return NULL;
   441 }
   441 }
   442 
   442 
   443 void *fill_candidate_datatypes_c::visit(real_literal_c *symbol) {
   443 void *fill_candidate_datatypes_c::visit(real_literal_c *symbol) {
   444 	symbol->value->accept(*this);
   444 	symbol->value->accept(*this);
   445 	if (search_in_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   445 	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   446 		symbol->candidate_datatypes.push_back(symbol->type);
   446 		symbol->candidate_datatypes.push_back(symbol->type);
   447 	if (debug) std::cout << "REAL_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
   447 	if (debug) std::cout << "REAL_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
   448 	return NULL;
   448 	return NULL;
   449 }
   449 }
   450 
   450 
   451 void *fill_candidate_datatypes_c::visit(bit_string_literal_c *symbol) {
   451 void *fill_candidate_datatypes_c::visit(bit_string_literal_c *symbol) {
   452 	symbol->value->accept(*this);
   452 	symbol->value->accept(*this);
   453 	if (search_in_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   453 	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   454 		symbol->candidate_datatypes.push_back(symbol->type);
   454 		symbol->candidate_datatypes.push_back(symbol->type);
   455 	return NULL;
   455 	return NULL;
   456 }
   456 }
   457 
   457 
   458 void *fill_candidate_datatypes_c::visit(boolean_literal_c *symbol) {
   458 void *fill_candidate_datatypes_c::visit(boolean_literal_c *symbol) {
   459  	symbol->value->accept(*this);
   459  	symbol->value->accept(*this);
   460  	if (search_in_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   460  	if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
   461 		/* if an explicit datat type has been provided (e.g. SAFEBOOL#true), check whether
   461 		/* if an explicit datat type has been provided (e.g. SAFEBOOL#true), check whether
   462 		 * the possible datatypes of the value is consistent with the desired type.
   462 		 * the possible datatypes of the value is consistent with the desired type.
   463 		 */
   463 		 */
   464 		symbol->candidate_datatypes.push_back(symbol->type);
   464 		symbol->candidate_datatypes.push_back(symbol->type);
   465 	else {
   465 	else {