Examples of MethodImplementation


Examples of org.jf.dexlib2.iface.MethodImplementation

        Label tryEnd = builder.getLabel("tryEnd");
        Label handler = builder.getLabel("handler");

        builder.addCatch(tryStart, tryEnd, handler);

        MethodImplementation impl = builder.getMethodImplementation();

        List<? extends Instruction> instructions = Lists.newArrayList(impl.getInstructions());
        Assert.assertEquals(1003, instructions.size());

        Assert.assertEquals(Opcode.GOTO_16, instructions.get(0).getOpcode());
        Assert.assertEquals(1004, ((OffsetInstruction)instructions.get(0)).getCodeOffset());

        Assert.assertEquals(Opcode.GOTO_16, instructions.get(501).getOpcode());
        Assert.assertEquals(502, ((OffsetInstruction)instructions.get(501)).getCodeOffset());

        List<? extends TryBlock<? extends ExceptionHandler>> exceptionHandlers = impl.getTryBlocks();

        Assert.assertEquals(1, exceptionHandlers.size());
        Assert.assertEquals(252, exceptionHandlers.get(0).getStartCodeAddress());
        Assert.assertEquals(752, exceptionHandlers.get(0).getCodeUnitCount());

        Assert.assertEquals(1, exceptionHandlers.get(0).getExceptionHandlers().size());

        ExceptionHandler exceptionHandler = exceptionHandlers.get(0).getExceptionHandlers().get(0);
        Assert.assertEquals(504, exceptionHandler.getHandlerCodeAddress());

        List<DebugItem> debugItems = Lists.newArrayList(impl.getDebugItems());

        Assert.assertEquals(5, debugItems.size());

        Assert.assertEquals(1, ((LineNumber)debugItems.get(0)).getLineNumber());
        Assert.assertEquals(2, debugItems.get(0).getCodeAddress());
View Full Code Here

Examples of org.jf.dexlib2.iface.MethodImplementation

        }

        builder.addLabel("gotoTarget");
        builder.addInstruction(new BuilderInstruction10x(Opcode.RETURN_VOID));

        MethodImplementation impl = builder.getMethodImplementation();

        List<? extends Instruction> instructions = Lists.newArrayList(impl.getInstructions());
        Assert.assertEquals(502, instructions.size());

        Assert.assertEquals(Opcode.GOTO_16, instructions.get(0).getOpcode());
        Assert.assertEquals(502, ((OffsetInstruction)instructions.get(0)).getCodeOffset());
    }
View Full Code Here

Examples of org.jf.dexlib2.iface.MethodImplementation

        }

        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());
    }
View Full Code Here

Examples of org.jf.dexlib2.iface.MethodImplementation

        }

        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());
    }
View Full Code Here

Examples of org.jf.dexlib2.iface.MethodImplementation

        }

        builder.addLabel("goto16Target");
        builder.addInstruction(new BuilderInstruction10x(Opcode.RETURN_VOID));

        MethodImplementation impl = builder.getMethodImplementation();

        List<? extends Instruction> instructions = Lists.newArrayList(impl.getInstructions());
        Assert.assertEquals(32767, instructions.size());

        Assert.assertEquals(Opcode.GOTO_32, instructions.get(0).getOpcode());
        Assert.assertEquals(32769, ((OffsetInstruction)instructions.get(0)).getCodeOffset());
View Full Code Here

Examples of org.jf.dexlib2.iface.MethodImplementation

                continue;
            }
            String type = m.group(1);
            String operation = m.group(2);

            MethodImplementation methodImpl = method.getImplementation();
            Assert.assertNotNull(methodImpl);

            for (Instruction instruction: methodImpl.getInstructions()) {
                Opcode opcode = instruction.getOpcode();
                if (opcode == Opcode.INVOKE_STATIC || opcode == Opcode.INVOKE_STATIC_RANGE) {
                    MethodReference accessorMethod =
                            (MethodReference)((ReferenceInstruction) instruction).getReference();
View Full Code Here

Examples of org.jf.dexlib2.iface.MethodImplementation

                mainMethod = method;
            }
        }
        Assert.assertNotNull(mainMethod);

        MethodImplementation methodImpl = mainMethod.getImplementation();
        Assert.assertNotNull(methodImpl);

        List<Instruction> instructions = Lists.newArrayList(methodImpl.getInstructions());

        Instruction35c instruction = (Instruction35c)instructions.get(0);
        Assert.assertNotNull(instruction);
        Assert.assertEquals(Opcode.INVOKE_STATIC, instruction.getOpcode());
        MethodReference method = (MethodReference)instruction.getReference();
View Full Code Here

Examples of org.jf.dexlib2.iface.MethodImplementation

                mainMethod = method;
            }
        }
        Assert.assertNotNull(mainMethod);

        MethodImplementation methodImpl = mainMethod.getImplementation();
        Assert.assertNotNull(methodImpl);

        List<Instruction> instructions = Lists.newArrayList(methodImpl.getInstructions());

        Instruction21c instruction = (Instruction21c)instructions.get(0);
        Assert.assertNotNull(instruction);
        Assert.assertEquals(Opcode.SGET_OBJECT, instruction.getOpcode());
        FieldReference field = (FieldReference)instruction.getReference();
View Full Code Here

Examples of org.jf.dexlib2.iface.MethodImplementation

        return null;
    }

    @Nullable @Override
    public Iterable<? extends DebugItem> getDebugItems(@Nonnull BuilderMethod builderMethod) {
        MethodImplementation impl = builderMethod.getImplementation();
        if (impl == null) {
            return null;
        }
        return impl.getDebugItems();
    }
View Full Code Here

Examples of org.jf.dexlib2.iface.MethodImplementation

            }
        });
    }

    @Override public int getRegisterCount(@Nonnull BuilderMethod builderMethod) {
        MethodImplementation impl = builderMethod.getImplementation();
        if (impl == null) {
            return 0;
        }
        return impl.getRegisterCount();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.