Implemented verification for sput-wide

git-svn-id: https://smali.googlecode.com/svn/trunk@604 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com
2010-01-27 07:09:26 +00:00
parent 9d45d563fe
commit f08a9e1c2c

View File

@ -580,6 +580,8 @@ public class MethodAnalyzer {
return handle32BitPrimitiveSput(analyzedInstruction, RegisterType.Category.Char);
case SPUT_SHORT:
return handle32BitPrimitiveSput(analyzedInstruction, RegisterType.Category.Short);
case SPUT_WIDE:
return handleSputWide(analyzedInstruction);
}
assert false;
@ -2103,6 +2105,34 @@ public class MethodAnalyzer {
return true;
}
private boolean handleSputWide(AnalyzedInstruction analyzedInstruction) {
SingleRegisterInstruction instruction = (SingleRegisterInstruction)analyzedInstruction.instruction;
RegisterType sourceRegisterType = getAndCheckWideSourcePair(analyzedInstruction, instruction.getRegisterA());
assert sourceRegisterType != null;
if (sourceRegisterType.category == RegisterType.Category.Unknown) {
return false;
}
//TODO: check access
Item referencedItem = ((InstructionWithReference)analyzedInstruction.instruction).getReferencedItem();
assert referencedItem instanceof FieldIdItem;
FieldIdItem field = (FieldIdItem)referencedItem;
RegisterType fieldType = RegisterType.getRegisterTypeForTypeIdItem(field.getFieldType());
if (!WideLowCategories.contains(fieldType.category)) {
throw new ValidationException(String.format("Cannot use %s with field %s. Incorrect field type " +
"for the instruction.", analyzedInstruction.instruction.opcode.name,
field.getFieldString()));
}
setWideDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, fieldType);
return true;
}
private static boolean checkArrayFieldAssignment(RegisterType.Category arrayFieldCategory,
RegisterType.Category instructionCategory) {
if (arrayFieldCategory == instructionCategory) {