private void verifyIgetWide(AnalyzedInstruction analyzedInstruction) { TwoRegisterInstruction instruction = (TwoRegisterInstruction)analyzedInstruction.instruction; RegisterType objectRegisterType = getAndCheckSourceRegister(analyzedInstruction, instruction.getRegisterB(), ReferenceOrUninitThisCategories); //TODO: check access Item referencedItem = ((InstructionWithReference)analyzedInstruction.instruction).getReferencedItem(); assert referencedItem instanceof FieldIdItem; FieldIdItem field = (FieldIdItem)referencedItem; if (objectRegisterType.category != RegisterType.Category.Null && !objectRegisterType.type.extendsClass(ClassPath.getClassDef(field.getContainingClass()))) { throw new ValidationException(String.format("Cannot access field %s through type %s", field.getFieldString(), objectRegisterType.type.getClassType())); } 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())); } }
private void verifyIgetObject(AnalyzedInstruction analyzedInstruction) { TwoRegisterInstruction instruction = (TwoRegisterInstruction)analyzedInstruction.instruction; RegisterType objectRegisterType = getAndCheckSourceRegister(analyzedInstruction, instruction.getRegisterB(), ReferenceOrUninitThisCategories); //TODO: check access Item referencedItem = ((InstructionWithReference)analyzedInstruction.instruction).getReferencedItem(); assert referencedItem instanceof FieldIdItem; FieldIdItem field = (FieldIdItem)referencedItem; if (objectRegisterType.category != RegisterType.Category.Null && !objectRegisterType.type.extendsClass(ClassPath.getClassDef(field.getContainingClass()))) { throw new ValidationException(String.format("Cannot access field %s through type %s", field.getFieldString(), objectRegisterType.type.getClassType())); } RegisterType fieldType = RegisterType.getRegisterTypeForTypeIdItem(field.getFieldType()); if (fieldType.category != RegisterType.Category.Reference) { throw new ValidationException(String.format("Cannot use %s with field %s. Incorrect field type " + "for the instruction.", analyzedInstruction.instruction.opcode.name, field.getFieldString())); } }
private void verifyIputWide(AnalyzedInstruction analyzedInstruction) { TwoRegisterInstruction instruction = (TwoRegisterInstruction)analyzedInstruction.instruction; RegisterType objectRegisterType = getAndCheckSourceRegister(analyzedInstruction, instruction.getRegisterB(), ReferenceOrUninitThisCategories); getAndCheckSourceRegister(analyzedInstruction, instruction.getRegisterA(), WideLowCategories); //TODO: check access Item referencedItem = ((InstructionWithReference)analyzedInstruction.instruction).getReferencedItem(); assert referencedItem instanceof FieldIdItem; FieldIdItem field = (FieldIdItem)referencedItem; if (objectRegisterType.category != RegisterType.Category.Null && !objectRegisterType.type.extendsClass(ClassPath.getClassDef(field.getContainingClass()))) { throw new ValidationException(String.format("Cannot access field %s through type %s", field.getFieldString(), objectRegisterType.type.getClassType())); } 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())); } }
private void verify32BitPrimitiveIget(AnalyzedInstruction analyzedInstruction, RegisterType.Category instructionCategory) { TwoRegisterInstruction instruction = (TwoRegisterInstruction)analyzedInstruction.instruction; RegisterType objectRegisterType = getAndCheckSourceRegister(analyzedInstruction, instruction.getRegisterB(), ReferenceOrUninitThisCategories); //TODO: check access Item referencedItem = ((InstructionWithReference)analyzedInstruction.instruction).getReferencedItem(); assert referencedItem instanceof FieldIdItem; FieldIdItem field = (FieldIdItem)referencedItem; if (objectRegisterType.category != RegisterType.Category.Null && !objectRegisterType.type.extendsClass(ClassPath.getClassDef(field.getContainingClass()))) { throw new ValidationException(String.format("Cannot access field %s through type %s", field.getFieldString(), objectRegisterType.type.getClassType())); } RegisterType fieldType = RegisterType.getRegisterTypeForTypeIdItem(field.getFieldType()); if (!checkArrayFieldAssignment(fieldType.category, instructionCategory)) { throw new ValidationException(String.format("Cannot use %s with field %s. Incorrect field type " + "for the instruction.", analyzedInstruction.instruction.opcode.name, field.getFieldString())); } }
private void verifyIputObject(AnalyzedInstruction analyzedInstruction) { TwoRegisterInstruction instruction = (TwoRegisterInstruction)analyzedInstruction.instruction; RegisterType objectRegisterType = getAndCheckSourceRegister(analyzedInstruction, instruction.getRegisterB(), ReferenceOrUninitThisCategories); RegisterType sourceRegisterType = getAndCheckSourceRegister(analyzedInstruction, instruction.getRegisterA(), ReferenceCategories); //TODO: check access Item referencedItem = ((InstructionWithReference)analyzedInstruction.instruction).getReferencedItem(); assert referencedItem instanceof FieldIdItem; FieldIdItem field = (FieldIdItem)referencedItem; if (objectRegisterType.category != RegisterType.Category.Null && !objectRegisterType.type.extendsClass(ClassPath.getClassDef(field.getContainingClass()))) { throw new ValidationException(String.format("Cannot access field %s through type %s", field.getFieldString(), objectRegisterType.type.getClassType())); } RegisterType fieldType = RegisterType.getRegisterTypeForTypeIdItem(field.getFieldType()); if (fieldType.category != RegisterType.Category.Reference) { throw new ValidationException(String.format("Cannot use %s with field %s. Incorrect field type " + "for the instruction.", analyzedInstruction.instruction.opcode.name, field.getFieldString())); } if (sourceRegisterType.category != RegisterType.Category.Null && !fieldType.type.isInterface() && !sourceRegisterType.type.extendsClass(fieldType.type)) { throw new ValidationException(String.format("Cannot store a value of type %s into a field of type %s", sourceRegisterType.type.getClassType(), fieldType.type.getClassType())); } }
!objectRegisterType.type.extendsClass(ClassPath.getClassDef(field.getContainingClass()))) { throw new ValidationException(String.format("Cannot access field %s through type %s", field.getFieldString(), objectRegisterType.type.getClassType()));
!objectRegisterType.type.extendsClass(ClassPath.getClassDef(field.getContainingClass()))) { throw new ValidationException(String.format("Cannot access field %s through type %s", field.getFieldString(), objectRegisterType.type.getClassType()));
private void verifyIputWide(AnalyzedInstruction analyzedInstruction) { TwoRegisterInstruction instruction = (TwoRegisterInstruction)analyzedInstruction.instruction; RegisterType objectRegisterType = getAndCheckSourceRegister(analyzedInstruction, instruction.getRegisterB(), ReferenceOrUninitThisCategories); getAndCheckSourceRegister(analyzedInstruction, instruction.getRegisterA(), WideLowCategories); //TODO: check access Item referencedItem = ((InstructionWithReference)analyzedInstruction.instruction).getReferencedItem(); assert referencedItem instanceof FieldIdItem; FieldIdItem field = (FieldIdItem)referencedItem; if (objectRegisterType.category != RegisterType.Category.Null && !objectRegisterType.type.extendsClass(ClassPath.getClassDef(field.getContainingClass()))) { throw new ValidationException(String.format("Cannot access field %s through type %s", field.getFieldString(), objectRegisterType.type.getClassType())); } 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())); } }