Examples of InsnList


Examples of org.objectweb.asm.tree.InsnList

                iin.var = iin.var + 1;
                log("Incremented iinc var to " + iin.var);
            }
        }

        InsnList pre = new InsnList();
        // pre.add(vStart);
        if (isStatic) {
            pre.add(new LdcInsnNode(cn.name));
        } else {
            pre.add(new VarInsnNode(ALOAD, 0)); // "this" is index 0 locvar.
        }

        pre.add(new MethodInsnNode(INVOKESTATIC, classDesc, BEFORE,
                ONE_OBJECT_PARAM + OBJECT_DESC));
        pre.add(new VarInsnNode(ASTORE, purrSecretIndex));
        pre.add(fStart);
        mn.instructions.insert(mStart, pre);

        List<AbstractInsnNode> terminalNodes = new ArrayList<AbstractInsnNode>();
        for (int i = 0; i < mn.instructions.size(); i++) {
            AbstractInsnNode insn = mn.instructions.get(i);
            int opcode = insn.getOpcode();
            if (isReturnOpcode(opcode)) {
                terminalNodes.add(insn);
            }
        }

        LabelNode okReturnLabel = new LabelNode( new Label() );
//        LabelNode throwReturnLabel = new LabelNode( new Label() );
        Integer returnOpcode = null;
        for (AbstractInsnNode ain : terminalNodes) {
//            mn.instructions.insertBefore(ain,
//                    preExitInsns(cn, mn, purrSecretIndex));
//            if (  ain.getOpcode() == ATHROW ) {
//                mn.instructions.insert( ain, new JumpInsnNode( GOTO, throwReturnLabel ));
//            }
//           else {
                mn.instructions.insert( ain, new JumpInsnNode( GOTO, okReturnLabel ));
                if ( returnOpcode == null ) {
                    returnOpcode = ain.getOpcode();                   
                }
                else {
                    if ( returnOpcode.intValue() != ain.getOpcode() ) {
                        throw new RuntimeException( "Multiple return types: " + returnOpcode + " and " + ain.getOpcode() );
                    }
//               }
            }
            mn.instructions.remove( ain );
        }

        InsnList coda = new InsnList();
        coda.add( okReturnLabel );
        coda.add( preExitInsns( cn, mn, purrSecretIndex ));
        coda.add( new InsnNode( returnOpcode ));
        coda.add(fEnd);
//        coda.add( throwReturnLabel );
        coda.add(preExitInsns(cn, mn, purrSecretIndex));
        coda.add(new InsnNode(ATHROW));
        mn.instructions.insertBefore(mEnd, coda);

        for (Object o : mn.tryCatchBlocks) {
            TryCatchBlockNode tcbn = (TryCatchBlockNode) o;
            if (tcbn.start == mStart) {
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

        return name;
    }
       

    InsnList preExitInsns(ClassNode cn, MethodNode mn, int varIndex ) {
        InsnList post = new InsnList();
        if ( (mn.access & ACC_STATIC) != 0 ) {
            post.add( new LdcInsnNode( cn.name ));
        }
        else {
            post.add( new VarInsnNode( ALOAD, 0 ));
        }
        post.add( new VarInsnNode( ALOAD, varIndex ));
        post.add( new MethodInsnNode( INVOKESTATIC, classDesc, "after", TWO_OBJECT_PARAM +"V"));
        return post;
    }
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

        }
    }

    // sort the group instructions according to their method index
    private void sort(InstructionGroup group) {
        final InsnList instructions = method.instructions;
        Collections.sort(group.getNodes(), new Comparator<InstructionGraphNode>() {
            public int compare(InstructionGraphNode a, InstructionGraphNode b) {
                return Integer.valueOf(instructions.indexOf(a.getInstruction()))
                        .compareTo(instructions.indexOf(b.getInstruction()));
            }
        });
    }
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

        }
    }

    // sort the group instructions according to their method index
    private void sort(InstructionGroup group) {
        final InsnList instructions = method.instructions;
        Collections.sort(group.getNodes(), new Comparator<InstructionGraphNode>() {
            public int compare(InstructionGraphNode a, InstructionGraphNode b) {
                return Integer.valueOf(instructions.indexOf(a.getInstruction()))
                        .compareTo(instructions.indexOf(b.getInstruction()));
            }
        });
    }
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

    public boolean appliesTo(@NotNull ParserClassNode classNode, @NotNull RuleMethod method) {
        return method.containsPotentialSuperCalls();
    }

    public void process(@NotNull ParserClassNode classNode, @NotNull RuleMethod method) throws Exception {
        InsnList instructions = method.instructions;
        AbstractInsnNode insn = instructions.getFirst();
        while (insn.getOpcode() != ARETURN) {
            if (insn.getOpcode() == INVOKESPECIAL) {
                process(classNode, method, (MethodInsnNode) insn);
            }
            insn = insn.getNext();
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

    public boolean appliesTo(@NotNull ParserClassNode classNode, @NotNull RuleMethod method) {
        return method.containsPotentialSuperCalls();
    }

    public void process(@NotNull ParserClassNode classNode, @NotNull RuleMethod method) throws Exception {
        InsnList instructions = method.instructions;
        AbstractInsnNode insn = instructions.getFirst();
        while (insn.getOpcode() != ARETURN) {
            if (insn.getOpcode() == INVOKESPECIAL) {
                process(classNode, method, (MethodInsnNode) insn);
            }
            insn = insn.getNext();
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

            throw new RuntimeException("Could not load class '" + className + '\'', e);
        }
    }

    public static InsnList createArgumentLoaders(@NotNull String methodDescriptor) {
        InsnList instructions = new InsnList();
        Type[] types = Type.getArgumentTypes(methodDescriptor);
        for (int i = 0; i < types.length; i++) {
            instructions.add(new VarInsnNode(getLoadingOpcode(types[i]), i + 1));
        }
        return instructions;
    }
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

      pos += t.getSize();
    }
    variableIdx = idx;
    variable = pos;
    inserted = false;
    prolog = new InsnList();
  }
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

        // main routine
        worklist.add(new Instantiation(null, mainSubroutine));

        // Emit instantiations of each subroutine we encounter, including the
        // main subroutine
        InsnList newInstructions = new InsnList();
        List<TryCatchBlockNode> newTryCatchBlocks = new ArrayList<TryCatchBlockNode>();
        List<LocalVariableNode> newLocalVariables = new ArrayList<LocalVariableNode>();
        while (!worklist.isEmpty()) {
            Instantiation inst = worklist.removeFirst();
            emitSubroutine(inst,
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

        // main routine
        worklist.add(new Instantiation(null, mainSubroutine));

        // Emit instantiations of each subroutine we encounter, including the
        // main subroutine
        InsnList newInstructions = new InsnList();
        List newTryCatchBlocks = new ArrayList();
        List newLocalVariables = new ArrayList();
        while (!worklist.isEmpty()) {
            Instantiation inst = (Instantiation) worklist.removeFirst();
            emitSubroutine(inst,
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.