equal
deleted
inserted
replaced
94 /* Returns true if it really did add the datatype to the list, or false if it was already present in the list! */ |
94 /* Returns true if it really did add the datatype to the list, or false if it was already present in the list! */ |
95 bool fill_candidate_datatypes_c::add_datatype_to_candidate_list(symbol_c *symbol, symbol_c *datatype) { |
95 bool fill_candidate_datatypes_c::add_datatype_to_candidate_list(symbol_c *symbol, symbol_c *datatype) { |
96 /* If it is an invalid data type, do not insert! |
96 /* If it is an invalid data type, do not insert! |
97 * NOTE: it reduces overall code size to do this test here, instead of doing every time before calling the add_datatype_to_candidate_list() function. |
97 * NOTE: it reduces overall code size to do this test here, instead of doing every time before calling the add_datatype_to_candidate_list() function. |
98 */ |
98 */ |
99 if (!is_type_valid(datatype)) /* checks for NULL and invalid_type_name_c */ |
99 if (!get_datatype_info_c::is_type_valid(datatype)) /* checks for NULL and invalid_type_name_c */ |
100 return false; |
100 return false; |
101 |
101 |
102 if (search_in_candidate_datatype_list(datatype, symbol->candidate_datatypes) >= 0) |
102 if (search_in_candidate_datatype_list(datatype, symbol->candidate_datatypes) >= 0) |
103 /* already in the list, Just return! */ |
103 /* already in the list, Just return! */ |
104 return false; |
104 return false; |
610 symbol->lower_limit->accept(*this); |
610 symbol->lower_limit->accept(*this); |
611 symbol->upper_limit->accept(*this); |
611 symbol->upper_limit->accept(*this); |
612 |
612 |
613 for (unsigned int u = 0; u < symbol->upper_limit->candidate_datatypes.size(); u++) { |
613 for (unsigned int u = 0; u < symbol->upper_limit->candidate_datatypes.size(); u++) { |
614 for(unsigned int l = 0; l < symbol->lower_limit->candidate_datatypes.size(); l++) { |
614 for(unsigned int l = 0; l < symbol->lower_limit->candidate_datatypes.size(); l++) { |
615 if (is_type_equal(symbol->upper_limit->candidate_datatypes[u], symbol->lower_limit->candidate_datatypes[l])) |
615 if (get_datatype_info_c::is_type_equal(symbol->upper_limit->candidate_datatypes[u], symbol->lower_limit->candidate_datatypes[l])) |
616 add_datatype_to_candidate_list(symbol, symbol->lower_limit->candidate_datatypes[l]); |
616 add_datatype_to_candidate_list(symbol, symbol->lower_limit->candidate_datatypes[l]); |
617 } |
617 } |
618 } |
618 } |
619 return NULL; |
619 return NULL; |
620 } |
620 } |
1188 if (NULL == prev_il_instruction) return NULL; |
1188 if (NULL == prev_il_instruction) return NULL; |
1189 for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { |
1189 for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { |
1190 for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) { |
1190 for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) { |
1191 prev_instruction_type = prev_il_instruction->candidate_datatypes[i]; |
1191 prev_instruction_type = prev_il_instruction->candidate_datatypes[i]; |
1192 operand_type = il_operand->candidate_datatypes[j]; |
1192 operand_type = il_operand->candidate_datatypes[j]; |
1193 if (is_type_equal(prev_instruction_type, operand_type)) |
1193 if (get_datatype_info_c::is_type_equal(prev_instruction_type, operand_type)) |
1194 add_datatype_to_candidate_list(symbol, prev_instruction_type); |
1194 add_datatype_to_candidate_list(symbol, prev_instruction_type); |
1195 } |
1195 } |
1196 } |
1196 } |
1197 if (debug) std::cout << "ST [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1197 if (debug) std::cout << "ST [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1198 return NULL; |
1198 return NULL; |
1204 if (NULL == prev_il_instruction) return NULL; |
1204 if (NULL == prev_il_instruction) return NULL; |
1205 for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { |
1205 for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { |
1206 for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) { |
1206 for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) { |
1207 prev_instruction_type = prev_il_instruction->candidate_datatypes[i]; |
1207 prev_instruction_type = prev_il_instruction->candidate_datatypes[i]; |
1208 operand_type = il_operand->candidate_datatypes[j]; |
1208 operand_type = il_operand->candidate_datatypes[j]; |
1209 if (is_type_equal(prev_instruction_type,operand_type) && get_datatype_info_c::is_ANY_BIT_compatible(operand_type)) |
1209 if (get_datatype_info_c::is_type_equal(prev_instruction_type,operand_type) && get_datatype_info_c::is_ANY_BIT_compatible(operand_type)) |
1210 add_datatype_to_candidate_list(symbol, prev_instruction_type); |
1210 add_datatype_to_candidate_list(symbol, prev_instruction_type); |
1211 } |
1211 } |
1212 } |
1212 } |
1213 if (debug) std::cout << "STN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1213 if (debug) std::cout << "STN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1214 return NULL; |
1214 return NULL; |
1242 operand_type = il_operand->candidate_datatypes[j]; |
1242 operand_type = il_operand->candidate_datatypes[j]; |
1243 /* TODO: I believe the following is wrong! The data types of prev_instruction_type and operand_type DO NOT have to be equal. |
1243 /* TODO: I believe the following is wrong! The data types of prev_instruction_type and operand_type DO NOT have to be equal. |
1244 * the prev_instruction_type MUST be BOOL compatible. |
1244 * the prev_instruction_type MUST be BOOL compatible. |
1245 * I am not too sure about operand_type, does it have to be BOOL compatible, or can it be ANY_BIT compatible? Must check! |
1245 * I am not too sure about operand_type, does it have to be BOOL compatible, or can it be ANY_BIT compatible? Must check! |
1246 */ |
1246 */ |
1247 if (is_type_equal(prev_instruction_type,operand_type) && get_datatype_info_c::is_BOOL_compatible(operand_type)) |
1247 if (get_datatype_info_c::is_type_equal(prev_instruction_type,operand_type) && get_datatype_info_c::is_BOOL_compatible(operand_type)) |
1248 add_datatype_to_candidate_list(symbol, prev_instruction_type); |
1248 add_datatype_to_candidate_list(symbol, prev_instruction_type); |
1249 } |
1249 } |
1250 } |
1250 } |
1251 if (debug) std::cout << "S [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1251 if (debug) std::cout << "S [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1252 return NULL; |
1252 return NULL; |
1264 operand_type = il_operand->candidate_datatypes[j]; |
1264 operand_type = il_operand->candidate_datatypes[j]; |
1265 /* TODO: I believe the following is wrong! The data types of prev_instruction_type and operand_type DO NOT have to be equal. |
1265 /* TODO: I believe the following is wrong! The data types of prev_instruction_type and operand_type DO NOT have to be equal. |
1266 * the prev_instruction_type MUST be BOOL compatible. |
1266 * the prev_instruction_type MUST be BOOL compatible. |
1267 * I am not too sure about operand_type, does it have to be BOOL compatible, or can it be ANY_BIT compatible? Must check! |
1267 * I am not too sure about operand_type, does it have to be BOOL compatible, or can it be ANY_BIT compatible? Must check! |
1268 */ |
1268 */ |
1269 if (is_type_equal(prev_instruction_type,operand_type) && get_datatype_info_c::is_BOOL_compatible(operand_type)) |
1269 if (get_datatype_info_c::is_type_equal(prev_instruction_type,operand_type) && get_datatype_info_c::is_BOOL_compatible(operand_type)) |
1270 add_datatype_to_candidate_list(symbol, prev_instruction_type); |
1270 add_datatype_to_candidate_list(symbol, prev_instruction_type); |
1271 } |
1271 } |
1272 } |
1272 } |
1273 if (debug) std::cout << "R [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1273 if (debug) std::cout << "R [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1274 return NULL; |
1274 return NULL; |
1456 symbol->r_exp->accept(*this); |
1456 symbol->r_exp->accept(*this); |
1457 for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) { |
1457 for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) { |
1458 for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) { |
1458 for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) { |
1459 left_type = symbol->l_exp->candidate_datatypes[i]; |
1459 left_type = symbol->l_exp->candidate_datatypes[i]; |
1460 right_type = symbol->r_exp->candidate_datatypes[j]; |
1460 right_type = symbol->r_exp->candidate_datatypes[j]; |
1461 if (is_type_equal(left_type, right_type)) |
1461 if (get_datatype_info_c::is_type_equal(left_type, right_type)) |
1462 add_datatype_to_candidate_list(symbol, left_type); |
1462 add_datatype_to_candidate_list(symbol, left_type); |
1463 } |
1463 } |
1464 } |
1464 } |
1465 if (debug) std::cout << ":= [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1465 if (debug) std::cout << ":= [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1466 return NULL; |
1466 return NULL; |