Search in sources :

Example 6 with BuilderInstruction10t

use of org.jf.dexlib2.builder.instruction.BuilderInstruction10t in project smali by JesusFreke.

the class FixGotoTest method testFixGotoToGoto32.

@Test
public void testFixGotoToGoto32() {
    MethodImplementationBuilder builder = new MethodImplementationBuilder(1);
    Label gotoTarget = builder.getLabel("gotoTarget");
    builder.addInstruction(new BuilderInstruction10t(Opcode.GOTO, gotoTarget));
    for (int i = 0; i < 70000; i++) {
        builder.addInstruction(new BuilderInstruction10x(Opcode.NOP));
    }
    builder.addLabel("gotoTarget");
    builder.addInstruction(new BuilderInstruction10x(Opcode.RETURN_VOID));
    MethodImplementation impl = builder.getMethodImplementation();
    List<? extends Instruction> instructions = Lists.newArrayList(impl.getInstructions());
    Assert.assertEquals(70002, instructions.size());
    Assert.assertEquals(Opcode.GOTO_32, instructions.get(0).getOpcode());
    Assert.assertEquals(70003, ((OffsetInstruction) instructions.get(0)).getCodeOffset());
}
Also used : MethodImplementation(org.jf.dexlib2.iface.MethodImplementation) BuilderInstruction10x(org.jf.dexlib2.builder.instruction.BuilderInstruction10x) BuilderInstruction10t(org.jf.dexlib2.builder.instruction.BuilderInstruction10t) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 BuilderInstruction10t (org.jf.dexlib2.builder.instruction.BuilderInstruction10t)4 BuilderInstruction10x (org.jf.dexlib2.builder.instruction.BuilderInstruction10x)4 MethodImplementation (org.jf.dexlib2.iface.MethodImplementation)4 Instruction (org.jf.dexlib2.iface.instruction.Instruction)2 OffsetInstruction (org.jf.dexlib2.iface.instruction.OffsetInstruction)2 BuilderInstruction20t (org.jf.dexlib2.builder.instruction.BuilderInstruction20t)1 ExceptionHandler (org.jf.dexlib2.iface.ExceptionHandler)1 DebugItem (org.jf.dexlib2.iface.debug.DebugItem)1 PackedSwitchPayload (org.jf.dexlib2.iface.instruction.formats.PackedSwitchPayload)1 SparseSwitchPayload (org.jf.dexlib2.iface.instruction.formats.SparseSwitchPayload)1