stage3/fill_candidate_datatypes.cc
changeset 480 8a58d7b8b26c
parent 479 a174d61f2087
child 481 16f943328696
equal deleted inserted replaced
479:a174d61f2087 480:8a58d7b8b26c
  1211 
  1211 
  1212 void *fill_candidate_datatypes_c::visit(ADD_operator_c *symbol) {return handle_binary_operator(widen_ADD_table, symbol, prev_il_instruction, il_operand);}
  1212 void *fill_candidate_datatypes_c::visit(ADD_operator_c *symbol) {return handle_binary_operator(widen_ADD_table, symbol, prev_il_instruction, il_operand);}
  1213 void *fill_candidate_datatypes_c::visit(SUB_operator_c *symbol) {return handle_binary_operator(widen_SUB_table, symbol, prev_il_instruction, il_operand);}
  1213 void *fill_candidate_datatypes_c::visit(SUB_operator_c *symbol) {return handle_binary_operator(widen_SUB_table, symbol, prev_il_instruction, il_operand);}
  1214 void *fill_candidate_datatypes_c::visit(MUL_operator_c *symbol) {return handle_binary_operator(widen_MUL_table, symbol, prev_il_instruction, il_operand);}
  1214 void *fill_candidate_datatypes_c::visit(MUL_operator_c *symbol) {return handle_binary_operator(widen_MUL_table, symbol, prev_il_instruction, il_operand);}
  1215 void *fill_candidate_datatypes_c::visit(DIV_operator_c *symbol) {return handle_binary_operator(widen_DIV_table, symbol, prev_il_instruction, il_operand);}
  1215 void *fill_candidate_datatypes_c::visit(DIV_operator_c *symbol) {return handle_binary_operator(widen_DIV_table, symbol, prev_il_instruction, il_operand);}
  1216 
  1216 void *fill_candidate_datatypes_c::visit(MOD_operator_c *symbol) {return handle_binary_operator(widen_MOD_table, symbol, prev_il_instruction, il_operand);}
  1217 
  1217 
  1218 void *fill_candidate_datatypes_c::visit(MOD_operator_c *symbol) {
  1218 
  1219 	symbol_c *prev_instruction_type, *operand_type;
       
  1220 
       
  1221 	if (NULL == prev_il_instruction) return NULL;
       
  1222 	for(unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
       
  1223 		for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
       
  1224 			prev_instruction_type = prev_il_instruction->candidate_datatypes[i];
       
  1225 			operand_type = il_operand->candidate_datatypes[j];
       
  1226 			if (is_type_equal(prev_instruction_type, operand_type) &&
       
  1227 					is_ANY_INT_compatible(prev_instruction_type))
       
  1228 				add_datatype_to_candidate_list(symbol, prev_instruction_type);
       
  1229 		}
       
  1230 	}
       
  1231 	if (debug) std::cout <<  "MOD [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
       
  1232 	return NULL;
       
  1233 }
       
  1234 
  1219 
  1235 void *fill_candidate_datatypes_c::visit(GT_operator_c *symbol) {
  1220 void *fill_candidate_datatypes_c::visit(GT_operator_c *symbol) {
  1236 	bool found = false;
  1221 	bool found = false;
  1237 
  1222 
  1238 	if (NULL == prev_il_instruction) return NULL;
  1223 	if (NULL == prev_il_instruction) return NULL;
  1617  */
  1602  */
  1618 void *fill_candidate_datatypes_c::visit(add_expression_c *symbol) {return handle_binary_expression(widen_ADD_table, symbol, symbol->l_exp, symbol->r_exp);}
  1603 void *fill_candidate_datatypes_c::visit(add_expression_c *symbol) {return handle_binary_expression(widen_ADD_table, symbol, symbol->l_exp, symbol->r_exp);}
  1619 void *fill_candidate_datatypes_c::visit(sub_expression_c *symbol) {return handle_binary_expression(widen_SUB_table, symbol, symbol->l_exp, symbol->r_exp);}
  1604 void *fill_candidate_datatypes_c::visit(sub_expression_c *symbol) {return handle_binary_expression(widen_SUB_table, symbol, symbol->l_exp, symbol->r_exp);}
  1620 void *fill_candidate_datatypes_c::visit(mul_expression_c *symbol) {return handle_binary_expression(widen_MUL_table, symbol, symbol->l_exp, symbol->r_exp);}
  1605 void *fill_candidate_datatypes_c::visit(mul_expression_c *symbol) {return handle_binary_expression(widen_MUL_table, symbol, symbol->l_exp, symbol->r_exp);}
  1621 void *fill_candidate_datatypes_c::visit(div_expression_c *symbol) {return handle_binary_expression(widen_DIV_table, symbol, symbol->l_exp, symbol->r_exp);}
  1606 void *fill_candidate_datatypes_c::visit(div_expression_c *symbol) {return handle_binary_expression(widen_DIV_table, symbol, symbol->l_exp, symbol->r_exp);}
  1622 
  1607 void *fill_candidate_datatypes_c::visit(mod_expression_c *symbol) {return handle_binary_expression(widen_MOD_table, symbol, symbol->l_exp, symbol->r_exp);}
  1623 
       
  1624 void *fill_candidate_datatypes_c::visit(mod_expression_c *symbol) {
       
  1625 	symbol_c *left_type, *right_type;
       
  1626 
       
  1627 	symbol->l_exp->accept(*this);
       
  1628 	symbol->r_exp->accept(*this);
       
  1629 	for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
       
  1630 		for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
       
  1631 			left_type = symbol->l_exp->candidate_datatypes[i];
       
  1632 			right_type = symbol->r_exp->candidate_datatypes[j];
       
  1633 			if (is_type_equal(left_type, right_type) && is_ANY_INT_compatible(left_type))
       
  1634 				add_datatype_to_candidate_list(symbol, left_type);
       
  1635 		}
       
  1636 	}
       
  1637 	if (debug) std::cout << "mod [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
       
  1638 	return NULL;
       
  1639 }
       
  1640 
  1608 
  1641 
  1609 
  1642 void *fill_candidate_datatypes_c::visit(power_expression_c *symbol) {
  1610 void *fill_candidate_datatypes_c::visit(power_expression_c *symbol) {
  1643 	symbol_c *left_type, *right_type;
  1611 	symbol_c *left_type, *right_type;
  1644 	bool check_ok;
  1612 	bool check_ok;