Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.AbstractInsnNode


        ASMBlock block = new ASMBlock(list2);

        HashMap<LabelNode, LabelNode> labelMap = new HashMap<LabelNode, LabelNode>();

        for(int i = 0, k = 0; i < list.size() && k < list2.size(); ) {
            AbstractInsnNode insn1 = list.get(i);
            if(!InsnComparator.insnImportant(insn1, cFlowLabels1)) {
                i++;
                continue;
            }

            AbstractInsnNode insn2 = list2.get(k);
            if(!InsnComparator.insnImportant(insn2, cFlowLabels2)) {
                k++;
                continue;
            }

            if(insn1.getOpcode() != insn2.getOpcode())
                throw new IllegalArgumentException("Lists do not match:\n"+list+"\n\n"+list2);

            switch(insn1.getType()) {
                case LABEL:
                    labelMap.put((LabelNode) insn1, (LabelNode) insn2);
View Full Code Here


    public void replaceLabels(Map<LabelNode, LabelNode> labelMap, Set<LabelNode> usedLabels) {
        for (AbstractInsnNode insn : list)
            switch (insn.getType()) {
                case LABEL:
                    AbstractInsnNode insn2 = insn.clone(labelMap);
                    if (insn2 == insn)//identity mapping
                        continue;
                    if (usedLabels.contains(insn2))
                        throw new IllegalStateException("LabelNode cannot be a part of two InsnLists");
                    list.replace(insn, insn2);
View Full Code Here

        ASMBlock block = new ASMBlock(list2);

        HashMap<LabelNode, LabelNode> labelMap = new HashMap<LabelNode, LabelNode>();

        for(int i = 0, k = 0; i < list.size() && k < list2.size(); ) {
            AbstractInsnNode insn1 = list.get(i);
            if(!InsnComparator.insnImportant(insn1, cFlowLabels1)) {
                i++;
                continue;
            }

            AbstractInsnNode insn2 = list2.get(k);
            if(!InsnComparator.insnImportant(insn2, cFlowLabels2)) {
                k++;
                continue;
            }

            if(insn1.getOpcode() != insn2.getOpcode())
                throw new IllegalArgumentException("Lists do not match:\n"+list+"\n\n"+list2);

            switch(insn1.getType()) {
                case LABEL:
                    labelMap.put((LabelNode) insn1, (LabelNode) insn2);
View Full Code Here

                    block = new ASMBlock();
                    continue;
                }

                try {
                    AbstractInsnNode insn = null;
                    String[] split = line.replace(" : ", ":").split(" ");
                    Integer i_opcode = opCodes.get(split[0]);
                    if (i_opcode == null) {
                        if (split[0].equals("LINENUMBER"))
                            insn = new LineNumberNode(Integer.parseInt(split[1]), block.getOrAdd(split[2]));
View Full Code Here

    }

    public static InsnListSection matches(InsnListSection haystack, InsnListSection needle, Set<LabelNode> controlFlowLabels) {
        int h = 0, n = 0;
        for (; h < haystack.size() && n < needle.size(); h++) {
            AbstractInsnNode insn = haystack.get(h);
            if(!insnImportant(insn, controlFlowLabels))
                continue;

            if (!insnEqual(haystack.get(h), needle.get(n)))
                return null;
View Full Code Here

            int insn = queue[--top];
            Frame f = frames[insn];
            Subroutine subroutine = subroutines[insn];
            queued[insn] = false;

            AbstractInsnNode insnNode = null;
            try {
                insnNode = m.instructions.get(insn);
                int insnOpcode = insnNode.getOpcode();
                int insnType = insnNode.getType();

                if (insnType == AbstractInsnNode.LABEL
                        || insnType == AbstractInsnNode.LINE
                        || insnType == AbstractInsnNode.FRAME)
                {
View Full Code Here

            }
            if (subroutines[insn] != null) {
                return;
            }
            subroutines[insn] = sub.copy();
            AbstractInsnNode node = insns.get(insn);

            // calls findSubroutine recursively on normal successors
            if (node instanceof JumpInsnNode) {
                if (node.getOpcode() == JSR) {
                    // do not follow a JSR, it leads to another subroutine!
                    calls.add(node);
                } else {
                    JumpInsnNode jnode = (JumpInsnNode) node;
                    findSubroutine(insns.indexOf(jnode.label), sub, calls);
                }
            } else if (node instanceof TableSwitchInsnNode) {
                TableSwitchInsnNode tsnode = (TableSwitchInsnNode) node;
                findSubroutine(insns.indexOf(tsnode.dflt), sub, calls);
                for (int i = tsnode.labels.size() - 1; i >= 0; --i) {
                    LabelNode l = (LabelNode) tsnode.labels.get(i);
                    findSubroutine(insns.indexOf(l), sub, calls);
                }
            } else if (node instanceof LookupSwitchInsnNode) {
                LookupSwitchInsnNode lsnode = (LookupSwitchInsnNode) node;
                findSubroutine(insns.indexOf(lsnode.dflt), sub, calls);
                for (int i = lsnode.labels.size() - 1; i >= 0; --i) {
                    LabelNode l = (LabelNode) lsnode.labels.get(i);
                    findSubroutine(insns.indexOf(l), sub, calls);
                }
            }

            // calls findSubroutine recursively on exception handler successors
            List insnHandlers = handlers[insn];
            if (insnHandlers != null) {
                for (int i = 0; i < insnHandlers.size(); ++i) {
                    TryCatchBlockNode tcb = (TryCatchBlockNode) insnHandlers.get(i);
                    findSubroutine(insns.indexOf(tcb.handler), sub, calls);
                }
            }

            // if insn does not falls through to the next instruction, return.
            switch (node.getOpcode()) {
                case GOTO:
                case RET:
                case TABLESWITCH:
                case LOOKUPSWITCH:
                case IRETURN:
View Full Code Here

        }

        // Initializations of fields end up placed in generated methods (<init>
        // for members and <clinit> for static fields).
        if (instruction != null && method.name.charAt(0) == '<') {
            AbstractInsnNode next = LintUtils.getNextInstruction(instruction);
            if (next != null && next.getType() == AbstractInsnNode.FIELD_INSN) {
                FieldInsnNode fieldRef = (FieldInsnNode) next;
                FieldNode field = findField(classNode, fieldRef.owner, fieldRef.name);
                if (field != null && isSuppressed(issue, field)) {
                    return true;
                }
View Full Code Here

    private static MethodInsnNode findConstructorInvocation(
            @NonNull MethodNode method,
            @NonNull String className) {
        InsnList nodes = ((MethodNode) method).instructions;
        for (int i = 0, n = nodes.size(); i < n; i++) {
            AbstractInsnNode instruction = nodes.get(i);
            if (instruction.getOpcode() == Opcodes.INVOKESPECIAL) {
                MethodInsnNode call = (MethodInsnNode) instruction;
                if (className.equals(call.owner)) {
                    return call;
                }
            }
View Full Code Here

        }

        // Initializations of fields end up placed in generated methods (<init>
        // for members and <clinit> for static fields).
        if (instruction != null && method.name.charAt(0) == '<') {
            AbstractInsnNode next = LintUtils.getNextInstruction(instruction);
            if (next != null && next.getType() == AbstractInsnNode.FIELD_INSN) {
                FieldInsnNode fieldRef = (FieldInsnNode) next;
                FieldNode field = findField(classNode, fieldRef.owner, fieldRef.name);
                if (field != null && isSuppressed(issue, field)) {
                    return true;
                }
View Full Code Here

TOP

Related Classes of org.objectweb.asm.tree.AbstractInsnNode

Copyright © 2018 www.massapicom. 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.