@Nonnull private BuilderInstruction22t newBuilderInstruction22t(int codeAddress, int[] codeAddressToIndex, @Nonnull Instruction22t instruction) { return new BuilderInstruction22t( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset())); }
private BuilderInstruction buildInstruction22t(Opcode opcode, int offset) { BuilderInstruction instruction = mock(BuilderInstruction.class, withSettings().extraInterfaces(Instruction22t.class)); when(location.getInstruction()).thenReturn(instruction); when(instruction.getLocation()).thenReturn(location); when(instruction.getCodeUnits()).thenReturn(0); when(instruction.getOpcode()).thenReturn(opcode); when(((Instruction22t) instruction).getRegisterA()).thenReturn(ARG1_REGISTER); when(((Instruction22t) instruction).getRegisterB()).thenReturn(ARG2_REGISTER); when(((Instruction22t) instruction).getCodeOffset()).thenReturn(offset); return instruction; }
@Override protected IfStmt ifStatement(DexBody body) { Instruction22t i = (Instruction22t) instruction; Local one = body.getRegisterLocal(i.getRegisterA()); Local other = body.getRegisterLocal(i.getRegisterB()); BinopExpr condition = getComparisonExpr(one, other); IfStmt jif = Jimple.v().newIfStmt(condition, targetInstruction.getUnit()); // setUnit() is called in ConditionalJumpInstruction addTags(jif); if (IDalvikTyper.ENABLE_DVKTYPER) { // Debug.printDbg(IDalvikTyper.DEBUG, "constraint if: "+ jif +" condition: "+ condition); DalvikTyper.v().addConstraint(condition.getOp1Box(), condition.getOp2Box()); } return jif; } }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { BuilderInstruction instruction = (BuilderInstruction) location.getInstruction(); int address = instruction.getLocation().getCodeAddress(); int branchOffset = ((OffsetInstruction) instruction).getCodeOffset(); int targetAddress = address + branchOffset; MethodLocation child = Utils.getNextLocation(location, addressToLocation); MethodLocation target = addressToLocation.get(targetAddress); String opName = instruction.getOpcode().name; IfType ifType = getIfType(opName); int register1 = ((OneRegisterInstruction) instruction).getRegisterA(); if (instruction instanceof Instruction22t) { // if-* vA, vB, :label Instruction22t instr = (Instruction22t) location.getInstruction(); return new IfOp(location, child, ifType, target, register1, instr.getRegisterB()); } else { // if-*z vA, vB, :label (Instruction 21t) return new IfOp(location, child, ifType, target, register1); } }
break; case IF_EQ: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.EQ, ((Instruction22t)inst).getRegisterA(), ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_NE: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.NE, ((Instruction22t)inst).getRegisterA(), ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_LT: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.LT, ((Instruction22t)inst).getRegisterA(), ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_GE: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.GE, ((Instruction22t)inst).getRegisterA(), ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_GT: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.GT, ((Instruction22t)inst).getRegisterA(), ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_LE: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.LE, ((Instruction22t)inst).getRegisterA(),
public static ImmutableInstruction22t of(Instruction22t instruction) { if (instruction instanceof ImmutableInstruction22t) { return (ImmutableInstruction22t)instruction; } return new ImmutableInstruction22t( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), instruction.getCodeOffset()); }
break; case IF_EQ: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.EQ, ((Instruction22t)inst).getRegisterA(), ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_NE: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.NE, ((Instruction22t)inst).getRegisterA(), ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_LT: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.LT, ((Instruction22t)inst).getRegisterA(), ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_GE: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.GE, ((Instruction22t)inst).getRegisterA(), ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_GT: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.GT, ((Instruction22t)inst).getRegisterA(), ((Instruction22t)inst).getRegisterB(), inst.getOpcode(), this)); break; case IF_LE: instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getCodeOffset(), Branch.BinaryBranch.CompareOp.LE, ((Instruction22t)inst).getRegisterA(),
public static ImmutableInstruction22t of(Instruction22t instruction) { if (instruction instanceof ImmutableInstruction22t) { return (ImmutableInstruction22t)instruction; } return new ImmutableInstruction22t( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), instruction.getCodeOffset()); }
public static ImmutableInstruction22t of(Instruction22t instruction) { if (instruction instanceof ImmutableInstruction22t) { return (ImmutableInstruction22t)instruction; } return new ImmutableInstruction22t( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), instruction.getCodeOffset()); }
@Nonnull private BuilderInstruction22t newBuilderInstruction22t(int codeAddress, int[] codeAddressToIndex, @Nonnull Instruction22t instruction) { return new BuilderInstruction22t( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset())); }
@Nonnull private BuilderInstruction22t newBuilderInstruction22t(int codeAddress, int[] codeAddressToIndex, @Nonnull Instruction22t instruction) { return new BuilderInstruction22t( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset())); }
@Nonnull private BuilderInstruction22t newBuilderInstruction22t(int codeAddress, int[] codeAddressToIndex, @Nonnull Instruction22t instruction) { return new BuilderInstruction22t( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset())); }
@Nonnull private BuilderInstruction22t newBuilderInstruction22t(int codeAddress, int[] codeAddressToIndex, @Nonnull Instruction22t instruction) { return new BuilderInstruction22t( instruction.getOpcode(), instruction.getRegisterA(), instruction.getRegisterB(), newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset())); }
public void write(@Nonnull Instruction22t instruction) { try { writer.write(instruction.getOpcode().value); writer.write(packNibbles(instruction.getRegisterA(), instruction.getRegisterB())); writer.writeShort(instruction.getCodeOffset()); } catch (IOException ex) { throw new RuntimeException(ex); } }
public void write(@Nonnull Instruction22t instruction) { try { writer.write(getOpcodeValue(instruction.getOpcode())); writer.write(packNibbles(instruction.getRegisterA(), instruction.getRegisterB())); writer.writeShort(instruction.getCodeOffset()); } catch (IOException ex) { throw new RuntimeException(ex); } }
public void write(@Nonnull Instruction22t instruction) { try { writer.write(getOpcodeValue(instruction.getOpcode())); writer.write(packNibbles(instruction.getRegisterA(), instruction.getRegisterB())); writer.writeShort(instruction.getCodeOffset()); } catch (IOException ex) { throw new RuntimeException(ex); } }