@Nonnull private BuilderInstruction21c newBuilderInstruction21c(@Nonnull Instruction21c instruction) { return new BuilderInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), convertReference(instruction.getReference())); }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction21c instr = (Instruction21c) location.getInstruction(); int destRegister = instr.getRegisterA(); TypeReference typeRef = (TypeReference) instr.getReference(); String className = typeRef.getType(); VirtualClass virtualClass = vm.getClassManager().getVirtualClass(className); return new NewInstanceOp(location, child, destRegister, virtualClass, vm); }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction21c instr = (Instruction21c) location.getInstruction(); int targetRegister = instr.getRegisterA(); TypeReference reference = (TypeReference) instr.getReference(); VirtualType referenceType = vm.getClassManager().getVirtualType(reference); return new CheckCastOp(location, child, targetRegister, referenceType, vm.getClassManager(), vm.getExceptionFactory()); }
@Override public void jimplify(DexBody body) { if (!(instruction instanceof Instruction21c)) { throw new IllegalArgumentException("Expected Instruction21c but got: " + instruction.getClass()); } Instruction21c checkCastInstr = (Instruction21c) instruction; Local castValue = body.getRegisterLocal(checkCastInstr.getRegisterA()); Type checkCastType = DexType.toSoot((TypeReference) checkCastInstr.getReference()); CastExpr castExpr = Jimple.v().newCastExpr(castValue, checkCastType); // generate "x = (Type) x" // splitter will take care of the rest AssignStmt assign = Jimple.v().newAssignStmt(castValue, castExpr); setUnit(assign); addTags(assign); body.add(assign); if (IDalvikTyper.ENABLE_DVKTYPER) { DalvikTyper.v().setType(assign.getLeftOpBox(), checkCastType, false); } }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction21c instr = (Instruction21c) location.getInstruction(); int destRegister = instr.getRegisterA(); FieldReference fieldReference = (FieldReference) instr.getReference(); VirtualClass fieldClass = vm.getClassManager().getVirtualClass(fieldReference.getDefiningClass()); VirtualField actualField = fieldClass.getField(fieldReference.getName()); return new SPutOp(location, child, destRegister, fieldReference, actualField, vm); }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { MethodLocation child = Utils.getNextLocation(location, addressToLocation); Instruction21c instr = (Instruction21c) location.getInstruction(); int destRegister = instr.getRegisterA(); FieldReference fieldReference = (FieldReference) instr.getReference(); VirtualClass fieldClass = vm.getClassManager().getVirtualClass(fieldReference.getDefiningClass()); VirtualField actualField = fieldClass.getField(fieldReference.getName()); return new SGetOp(location, child, destRegister, fieldReference, actualField, vm); }
@Override public void jimplify(DexBody body) { Instruction21c i = (Instruction21c) instruction; int dest = i.getRegisterA(); String className = dottedClassName(((TypeReference) (i.getReference())).toString()); RefType type = RefType.v(className); NewExpr n = Jimple.v().newNewExpr(type); AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), n); setUnit(assign); addTags(assign); body.add(assign); if (IDalvikTyper.ENABLE_DVKTYPER) { // DalvikTyper.v().captureAssign((JAssignStmt)assign, op); // TODO: ref. type may be null! DalvikTyper.v().setType(assign.getLeftOpBox(), type, false); } }
@Override public void jimplify(DexBody body) { int dest = ((OneRegisterInstruction) instruction).getRegisterA(); String s; if (instruction instanceof Instruction21c) { Instruction21c i = (Instruction21c) instruction; s = ((StringReference) (i.getReference())).getString(); } else if (instruction instanceof Instruction31c) { Instruction31c i = (Instruction31c) instruction; s = ((StringReference) (i.getReference())).getString(); } else { throw new IllegalArgumentException("Expected Instruction21c or Instruction31c but got neither."); } StringConstant sc = StringConstant.v(s); AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), sc); setUnit(assign); addTags(assign); body.add(assign); if (IDalvikTyper.ENABLE_DVKTYPER) { DalvikTyper.v().setType(assign.getLeftOpBox(), sc.getType(), false); } }
@Nonnull private BuilderInstruction21c newBuilderInstruction21c(@Nonnull Instruction21c instruction) { return new BuilderInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
@Nonnull private BuilderInstruction21c newBuilderInstruction21c(@Nonnull Instruction21c instruction) { return new BuilderInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
@Nonnull private BuilderInstruction21c newBuilderInstruction21c(@Nonnull Instruction21c instruction) { return new BuilderInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
@Nonnull private BuilderInstruction21c newBuilderInstruction21c(@Nonnull Instruction21c instruction) { return new BuilderInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), convertReference(instruction.getReference())); }
public static ImmutableInstruction21c of(Instruction21c instruction) { if (instruction instanceof ImmutableInstruction21c) { return (ImmutableInstruction21c)instruction; } return new ImmutableInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
public static ImmutableInstruction21c of(Instruction21c instruction) { if (instruction instanceof ImmutableInstruction21c) { return (ImmutableInstruction21c)instruction; } return new ImmutableInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
public static ImmutableInstruction21c of(Instruction21c instruction) { if (instruction instanceof ImmutableInstruction21c) { return (ImmutableInstruction21c)instruction; } return new ImmutableInstruction21c( instruction.getOpcode(), instruction.getRegisterA(), instruction.getReference()); }
FieldReference fieldRef = null; try { fieldRef = (FieldReference)ins.getReference(); } catch (InvalidItemIndex ex) {
FieldReference fieldRef = null; try { fieldRef = (FieldReference)ins.getReference(); } catch (InvalidItemIndex ex) {
FieldReference fieldRef = null; try { fieldRef = (FieldReference)ins.getReference(); } catch (InvalidItemIndex ex) {
FieldReference fieldRef = null; try { fieldRef = (FieldReference) ins.getReference(); } catch (InvalidItemIndex ex) {
Assert.assertNotNull(instruction); Assert.assertEquals(Opcode.SGET_OBJECT, instruction.getOpcode()); FieldReference field = (FieldReference)instruction.getReference(); Assert.assertEquals(classDef.getType(), field.getDefiningClass()); Assert.assertEquals("someField", field.getName()); Assert.assertNotNull(instruction); Assert.assertEquals(Opcode.SGET_OBJECT, instruction.getOpcode()); field = (FieldReference)instruction.getReference(); Assert.assertEquals(classDef.getType(), field.getDefiningClass()); Assert.assertEquals("V", field.getName()); Assert.assertNotNull(instruction); Assert.assertEquals(Opcode.SGET_OBJECT, instruction.getOpcode()); field = (FieldReference)instruction.getReference(); Assert.assertEquals(classDef.getType(), field.getDefiningClass()); Assert.assertEquals("I", field.getName());