Examples of Instruction


Examples of org.jf.dexlib2.iface.instruction.Instruction

        List<? extends Instruction> instructions =
                Lists.newArrayList(implBuilder.getMethodImplementation().getInstructions());

        Assert.assertEquals(instructions.size(), 3);

        Instruction instruction = instructions.get(0);
        Assert.assertEquals(instruction.getOpcode(), Opcode.MOVE);

        instruction = instructions.get(1);
        Assert.assertEquals(instruction.getOpcode(), Opcode.NOP);

        instruction = instructions.get(2);
        Assert.assertEquals(instruction.getOpcode(), Opcode.ARRAY_PAYLOAD);
    }
View Full Code Here

Examples of org.jf.dexlib2.iface.instruction.Instruction

            packedSwitchMap = new SparseIntArray(0);
            sparseSwitchMap = new SparseIntArray(0);
            instructionOffsetMap = new InstructionOffsetMap(instructions);

            for (int i=0; i<instructions.size(); i++) {
                Instruction instruction = instructions.get(i);

                Opcode opcode = instruction.getOpcode();
                if (opcode == Opcode.PACKED_SWITCH) {
                    boolean valid = true;
                    int codeOffset = instructionOffsetMap.getInstructionCodeOffset(i);
                    int targetOffset = codeOffset + ((OffsetInstruction)instruction).getCodeOffset();
                    try {
View Full Code Here

Examples of org.jf.dexlib2.iface.instruction.Instruction

        }

        //TODO: does dalvik let you pad with multiple nops?
        //TODO: does dalvik let a switch instruction point to a non-payload instruction?

        Instruction instruction = instructions.get(targetIndex);
        if (instruction.getOpcode() != type) {
            // maybe it's pointing to a NOP padding instruction. Look at the next instruction
            if (instruction.getOpcode() == Opcode.NOP) {
                targetIndex += 1;
                if (targetIndex < instructions.size()) {
                    instruction = instructions.get(targetIndex);
                    if (instruction.getOpcode() == type) {
                        return instructionOffsetMap.getInstructionCodeOffset(targetIndex);
                    }
                }
            }
            throw new InvalidSwitchPayload(targetOffset);
View Full Code Here

Examples of org.jf.dexlib2.iface.instruction.Instruction

    }

    private void addInstructionMethodItems(List<MethodItem> methodItems) {
        int currentCodeAddress = 0;
        for (int i=0; i<instructions.size(); i++) {
            Instruction instruction = instructions.get(i);

            MethodItem methodItem = InstructionMethodItemFactory.makeInstructionFormatMethodItem(this,
                    currentCodeAddress, instruction);

            methodItems.add(methodItem);

            if (i != instructions.size() - 1) {
                methodItems.add(new BlankMethodItem(currentCodeAddress));
            }

            if (classDef.options.addCodeOffsets) {
                methodItems.add(new MethodItem(currentCodeAddress) {

                    @Override
                    public double getSortOrder() {
                        return -1000;
                    }

                    @Override
                    public boolean writeTo(IndentingWriter writer) throws IOException {
                        writer.write("#@");
                        writer.printUnsignedLongAsHex(codeAddress & 0xFFFFFFFFL);
                        return true;
                    }
                });
            }

            if (!classDef.options.noAccessorComments && (instruction instanceof ReferenceInstruction)) {
                Opcode opcode = instruction.getOpcode();

                if (opcode.referenceType == ReferenceType.METHOD) {
                    MethodReference methodReference = null;
                    try {
                        methodReference = (MethodReference)((ReferenceInstruction)instruction).getReference();
                    } catch (InvalidItemIndex ex) {
                        // just ignore it for now. We'll deal with it later, when processing the instructions
                        // themselves
                    }

                    if (methodReference != null &&
                            SyntheticAccessorResolver.looksLikeSyntheticAccessor(methodReference.getName())) {
                        SyntheticAccessorResolver.AccessedMember accessedMember =
                                classDef.options.syntheticAccessorResolver.getAccessedMember(methodReference);
                        if (accessedMember != null) {
                            methodItems.add(new SyntheticAccessCommentMethodItem(accessedMember, currentCodeAddress));
                        }
                    }
                }
            }

            currentCodeAddress += instruction.getCodeUnits();
        }
    }
View Full Code Here

Examples of org.jitterbit.integration.client.project.UpgradeStrategy.Instruction

    /**
     * Runs this <code>DefaultPreLoader</code>, by asking the user to confirm that the upgrade
     * should be performed, and creating a backup Jitterpak if the user chooses to do so.
     */
    public void run() {
        Instruction instruction = strategy.getInstruction(projectName);
        switch (instruction) {
        case CANCEL:
            veto();
            break;
        case UPGRADE:
View Full Code Here

Examples of org.jreversepro.reflect.instruction.Instruction

        nextPc = parseLookupSwitchInstruction(startPc);
      } else {
        nextPc = currentPc
            + JVMInstructionSet.getOpcodeLength(curOpcode, bWide);
      }
      Instruction ins = new Instruction(currentPc, curOpcode, getArgArray(
          startPc, nextPc), nextPc, bWide);
      il.add(ins);
      bWide = (curOpcode == Opcodes.OPCODE_WIDE);
      currentPc = nextPc;
    }
View Full Code Here

Examples of org.jruby.ast.executable.YARVMachine.Instruction

import junit.framework.TestCase;

public class YARVMachineTest extends TestCase {
    public static Instruction[] getSimpleTest(Ruby runtime) {
        return new Instruction[] {
            new Instruction(YARVInstructions.PUTSTRING, "Hello, YARV!"),    // S: "HY"
            new Instruction(YARVInstructions.DUP),                          // S: "HY", "HY"
            new Instruction(YARVInstructions.SETLOCAL, 0),                  // S: "HY"; L: "HY"
            new Instruction(YARVInstructions.GETLOCAL, 0),                  // S: "HY", "HY"
            new Instruction(YARVInstructions.POP),                          // S: "HY"
            new Instruction(YARVInstructions.SETLOCAL, 1),                  // S: ; L: "HY", "HY"
            new Instruction(YARVInstructions.PUTOBJECT, runtime.getTrue()), // S: true; L: "HY", "HY"
            new Instruction(YARVInstructions.BRANCHIF, 10),                 // S: ; L: "HY", "HY"
            new Instruction(YARVInstructions.PUTSTRING, "Wrong String"),
            new Instruction(YARVInstructions.JUMP, 11),
            new Instruction(YARVInstructions.GETLOCAL, 1),                  // S: "HY"; L: "HY", "HY"
            new Instruction(YARVInstructions.PUTOBJECT, runtime.newFixnum(2)), // S: "HY", 2; L: "HY", "HY"
            new Instruction(YARVInstructions.SEND, "*", 1, null, 0),           // S: "HYHY"; L: "HY", "HY"
            new Instruction(YARVInstructions.PUTNIL),                          // S: "HYHY", nil; L: "HY", "HY"
            new Instruction(YARVInstructions.SEND, "to_s", 0, null, YARVInstructions.VCALL_FLAG | YARVInstructions.FCALL_FLAG), // S: "HYHY", Object; ...
            new Instruction(YARVInstructions.SEND, "+", 1, null, 0)            // S: "HYHYObject"; L: "HY", "HY"
        };
    };
View Full Code Here

Examples of serp.bytecode.Instruction

        code.invokevirtual().setMethod(Thread.class, "getContextClassLoader",
            ClassLoader.class, null);
        code.invokestatic().setMethod(Class.class, "forName", Class.class,
            new Class[]{ String.class, boolean.class, ClassLoader.class });
        code.putstatic().setField(type);
        Instruction go2 = code.go2();
        jumps.add(go2);
        handler.setTryEnd(go2);
        handler.setCatch(ClassNotFoundException.class);
        handler.setHandlerStart(throwException
            (code, InternalException.class));
View Full Code Here

Examples of serp.bytecode.Instruction

            code.getfield().setField(impl);
            code.constant().setValue(true);
            code.invokeinterface().setMethod(OpenJPAStateManager.class,
                "setImplData", void.class,
                new Class[]{ Object.class, boolean.class });
            Instruction ins = code.vreturn();
            ifins.setTarget(ins);
            ifins2.setTarget(ins);
        }
        code.calculateMaxStack();
        code.calculateMaxLocals();
View Full Code Here

Examples of serp.bytecode.Instruction

            int obj = code.getNextLocalsIndex();
            ifins.setTarget(code.constant().setNull());
            code.astore().setLocal(obj);

            // establish switch target, then move before it
            Instruction target = code.aload().setLocal(obj);
            code.previous();

            // switch(i)
            code.iload().setParam(1);
            LookupSwitchInstruction lswitch = code.lookupswitch();
            FieldMetaData[] fields = meta.getFields();
            int cacheable = 0;
            for (int i = 0; i < fields.length; i++) {
                if (!usesImplData(fields[i]))
                    continue;
                // case x: obj = fieldImpl[y]; break;
                lswitch.addCase(i, code.aload().setThis());
                code.getfield().setField(impl);
                code.constant().setValue(cacheable++);
                code.aaload();
                code.astore().setLocal(obj);
                code.go2().setTarget(target);
            }
            lswitch.setDefaultTarget(target);

            // if (obj != null)
            code.next();    // jump back over target
            ifins = code.ifnonnull();
            code.vreturn();

            // sm.setImplData(index, impl);
            ifins.setTarget(code.aload().setParam(0));
            code.iload().setParam(1);
            code.aload().setLocal(obj);
            code.invokeinterface().setMethod(OpenJPAStateManager.class,
                "setImplData", void.class,
                new Class[]{ int.class, Object.class });
            code.vreturn();
        }
        code.calculateMaxLocals();
        code.calculateMaxStack();

        // void storeImplData(OpenJPAStateManager sm, int index, boolean loaded)
        meth = bc.declareMethod("storeImplData", void.class,
            new Class[]{ OpenJPAStateManager.class, int.class, boolean.class });
        code = meth.getCode(true);
        if (count == 0)
            code.vreturn();
        else {
            // int arrIdx = -1;
            // switch(index)
            int arrIdx = code.getNextLocalsIndex();
            code.constant().setValue(-1);
            code.istore().setLocal(arrIdx);
            code.iload().setParam(1);
            LookupSwitchInstruction lswitch = code.lookupswitch();

            // establish switch target, then move before it
            Instruction switchTarget = code.iload().setLocal(arrIdx);
            code.previous();

            FieldMetaData[] fields = meta.getFields();
            int cacheable = 0;
            for (int i = 0; i < fields.length; i++) {
                if (!usesImplData(fields[i]))
                    continue;
                // case x: arrIdx = y; break;
                lswitch.addCase(i, code.constant().setValue(cacheable++));
                code.istore().setLocal(arrIdx);
                code.go2().setTarget(switchTarget);
            }
            lswitch.setDefaultTarget(switchTarget);
            code.next();    // step over switch target

            // if (arrIdx != -1)
            code.constant().setValue(-1);
            JumpInstruction ifins = code.ificmpne();
            code.vreturn();

            // create null target, then move before it
            Instruction nullTarget = code.aload().setThis();
            code.previous();

            // if (loaded)
            ifins.setTarget(code.iload().setParam(2));
            code.ifeq().setTarget(nullTarget);
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.