902 |
902 |
903 |
903 |
904 /* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */ |
904 /* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */ |
905 // SYM_REF3(il_expression_c, il_expr_operator, il_operand, simple_instr_list); |
905 // SYM_REF3(il_expression_c, il_expr_operator, il_operand, simple_instr_list); |
906 void *fill_candidate_datatypes_c::visit(il_expression_c *symbol) { |
906 void *fill_candidate_datatypes_c::visit(il_expression_c *symbol) { |
|
907 symbol_c *prev_il_instruction_backup = prev_il_instruction; |
|
908 il_parenthesis_level++; |
|
909 |
907 if (NULL != symbol->il_operand) |
910 if (NULL != symbol->il_operand) |
908 symbol->il_operand->accept(*this); |
911 symbol->il_operand->accept(*this); |
909 |
912 |
910 il_parenthesis_level++; |
913 if(symbol->simple_instr_list != NULL) |
911 |
|
912 /* Note that prev_il_instruction will actually be used to get the current value store in the il_default_variable */ |
|
913 /* If a symbol->il_operand is provided, then that will be the result before executing the simple_instr_list. |
|
914 * If this symbol is NULL, then the current result is also NULL, which is correct for what we want to do! |
|
915 */ |
|
916 symbol_c *prev_il_instruction_backup = prev_il_instruction; |
|
917 prev_il_instruction = symbol->il_operand; |
|
918 |
|
919 if(symbol->simple_instr_list != NULL) { |
|
920 symbol->simple_instr_list->accept(*this); |
914 symbol->simple_instr_list->accept(*this); |
921 } |
|
922 |
915 |
923 il_parenthesis_level--; |
916 il_parenthesis_level--; |
924 if (il_parenthesis_level < 0) ERROR; |
917 if (il_parenthesis_level < 0) ERROR; |
925 |
|
926 |
918 |
927 /* Now check the if the data type semantics of operation are correct, */ |
919 /* Now check the if the data type semantics of operation are correct, */ |
928 il_operand = symbol->simple_instr_list; |
920 il_operand = symbol->simple_instr_list; |
929 prev_il_instruction = prev_il_instruction_backup; |
921 prev_il_instruction = prev_il_instruction_backup; |
930 symbol->il_expr_operator->accept(*this); |
922 symbol->il_expr_operator->accept(*this); |
1004 |
996 |
1005 |
997 |
1006 /* | simple_instr_list il_simple_instruction */ |
998 /* | simple_instr_list il_simple_instruction */ |
1007 /* This object is referenced by il_expression_c objects */ |
999 /* This object is referenced by il_expression_c objects */ |
1008 void *fill_candidate_datatypes_c::visit(simple_instr_list_c *symbol) { |
1000 void *fill_candidate_datatypes_c::visit(simple_instr_list_c *symbol) { |
1009 int i; |
1001 std::cout << "simple_instr_list_c [filling starting]\n"; |
1010 for(i = 0; i < symbol->n; i++) |
1002 if (symbol->n <= 0) |
|
1003 return NULL; /* List is empty! Nothing to do. */ |
|
1004 |
|
1005 for(int i = 0; i < symbol->n; i++) |
1011 symbol->elements[i]->accept(*this); |
1006 symbol->elements[i]->accept(*this); |
1012 /* This object has (inherits) the same candidate datatypes as the last il_instruction (if it exists!) */ |
1007 |
1013 if (i > 0) |
1008 /* This object has (inherits) the same candidate datatypes as the last il_instruction */ |
1014 copy_candidate_datatype_list(symbol->elements[i-1] /*from*/, symbol /*to*/); |
1009 copy_candidate_datatype_list(symbol->elements[symbol->n-1] /*from*/, symbol /*to*/); |
1015 |
1010 |
1016 if (debug) std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n"; |
1011 if (debug) std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n"; |
1017 std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n"; |
1012 std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n"; |
1018 return NULL; |
1013 return NULL; |
1019 } |
1014 } |
|
1015 |
|
1016 // SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;) |
|
1017 void *fill_candidate_datatypes_c::visit(il_simple_instruction_c *symbol) { |
|
1018 prev_il_instruction = symbol->prev_il_instruction; |
|
1019 symbol->il_simple_instruction->accept(*this); |
|
1020 prev_il_instruction = NULL; |
|
1021 |
|
1022 /* This object has (inherits) the same candidate datatypes as the il_simple_instruction it points to */ |
|
1023 copy_candidate_datatype_list(symbol->il_simple_instruction /*from*/, symbol /*to*/); |
|
1024 return NULL; |
|
1025 } |
|
1026 |
1020 |
1027 |
1021 /* |
1028 /* |
1022 void *visit(il_param_list_c *symbol); |
1029 void *visit(il_param_list_c *symbol); |
1023 void *visit(il_param_assignment_c *symbol); |
1030 void *visit(il_param_assignment_c *symbol); |
1024 void *visit(il_param_out_assignment_c *symbol); |
1031 void *visit(il_param_out_assignment_c *symbol); |
1169 if (is_type_equal(prev_instruction_type, operand_type) && |
1176 if (is_type_equal(prev_instruction_type, operand_type) && |
1170 is_ANY_BIT_compatible(operand_type)) |
1177 is_ANY_BIT_compatible(operand_type)) |
1171 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1178 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1172 } |
1179 } |
1173 } |
1180 } |
|
1181 if (debug) std::cout << "AND [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1174 return NULL; |
1182 return NULL; |
1175 } |
1183 } |
1176 |
1184 |
1177 void *fill_candidate_datatypes_c::visit(OR_operator_c *symbol) { |
1185 void *fill_candidate_datatypes_c::visit(OR_operator_c *symbol) { |
1178 symbol_c *prev_instruction_type, *operand_type; |
1186 symbol_c *prev_instruction_type, *operand_type; |
1185 if (is_type_equal(prev_instruction_type, operand_type) && |
1193 if (is_type_equal(prev_instruction_type, operand_type) && |
1186 is_ANY_BIT_compatible(operand_type)) |
1194 is_ANY_BIT_compatible(operand_type)) |
1187 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1195 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1188 } |
1196 } |
1189 } |
1197 } |
|
1198 if (debug) std::cout << "OR [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1190 return NULL; |
1199 return NULL; |
1191 } |
1200 } |
1192 |
1201 |
1193 void *fill_candidate_datatypes_c::visit(XOR_operator_c *symbol) { |
1202 void *fill_candidate_datatypes_c::visit(XOR_operator_c *symbol) { |
1194 symbol_c *prev_instruction_type, *operand_type; |
1203 symbol_c *prev_instruction_type, *operand_type; |
1201 if (is_type_equal(prev_instruction_type, operand_type) && |
1210 if (is_type_equal(prev_instruction_type, operand_type) && |
1202 is_ANY_BIT_compatible(operand_type)) |
1211 is_ANY_BIT_compatible(operand_type)) |
1203 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1212 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1204 } |
1213 } |
1205 } |
1214 } |
|
1215 if (debug) std::cout << "XOR [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1206 return NULL; |
1216 return NULL; |
1207 } |
1217 } |
1208 |
1218 |
1209 void *fill_candidate_datatypes_c::visit(ANDN_operator_c *symbol) { |
1219 void *fill_candidate_datatypes_c::visit(ANDN_operator_c *symbol) { |
1210 symbol_c *prev_instruction_type, *operand_type; |
1220 symbol_c *prev_instruction_type, *operand_type; |
1217 if (is_type_equal(prev_instruction_type, operand_type) && |
1227 if (is_type_equal(prev_instruction_type, operand_type) && |
1218 is_ANY_BIT_compatible(operand_type)) |
1228 is_ANY_BIT_compatible(operand_type)) |
1219 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1229 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1220 } |
1230 } |
1221 } |
1231 } |
|
1232 if (debug) std::cout << "ANDN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1222 return NULL; |
1233 return NULL; |
1223 } |
1234 } |
1224 |
1235 |
1225 void *fill_candidate_datatypes_c::visit(ORN_operator_c *symbol) { |
1236 void *fill_candidate_datatypes_c::visit(ORN_operator_c *symbol) { |
1226 symbol_c *prev_instruction_type, *operand_type; |
1237 symbol_c *prev_instruction_type, *operand_type; |
1233 if (is_type_equal(prev_instruction_type, operand_type) && |
1244 if (is_type_equal(prev_instruction_type, operand_type) && |
1234 is_ANY_BIT_compatible(operand_type)) |
1245 is_ANY_BIT_compatible(operand_type)) |
1235 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1246 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1236 } |
1247 } |
1237 } |
1248 } |
|
1249 if (debug) std::cout << "ORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1238 return NULL; |
1250 return NULL; |
1239 } |
1251 } |
1240 |
1252 |
1241 void *fill_candidate_datatypes_c::visit(XORN_operator_c *symbol) { |
1253 void *fill_candidate_datatypes_c::visit(XORN_operator_c *symbol) { |
1242 symbol_c *prev_instruction_type, *operand_type; |
1254 symbol_c *prev_instruction_type, *operand_type; |
1249 if (is_type_equal(prev_instruction_type, operand_type) && |
1261 if (is_type_equal(prev_instruction_type, operand_type) && |
1250 is_ANY_BIT_compatible(operand_type)) |
1262 is_ANY_BIT_compatible(operand_type)) |
1251 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1263 symbol->candidate_datatypes.push_back(prev_instruction_type); |
1252 } |
1264 } |
1253 } |
1265 } |
|
1266 if (debug) std::cout << "XORN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
1254 return NULL; |
1267 return NULL; |
1255 } |
1268 } |
1256 |
1269 |
1257 void *fill_candidate_datatypes_c::visit(ADD_operator_c *symbol) { |
1270 void *fill_candidate_datatypes_c::visit(ADD_operator_c *symbol) { |
1258 symbol_c *prev_instruction_type, *operand_type; |
1271 symbol_c *prev_instruction_type, *operand_type; |