Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.VarInsnNode


        // move the arguments onto the scratchpad
        int ltmp = 0;
        if ((access & Opcodes.ACC_STATIC) == 0) ltmp += saveArg(instructions, ltmp, Type.getType(Object.class));
        for (Type at : Type.getArgumentTypes(desc)) ltmp += saveArg(instructions, ltmp, at);

        instructions.add(new VarInsnNode(Opcodes.ASTORE, 0));
        instructions.add(intNode(0));
        instructions.add(new VarInsnNode(Opcodes.ISTORE, 1));

        LabelNode loop = new LabelNode();
        instructions.add(loop);

        for (int i = firstJump.size() - 1; i >= 0; i--) {
            LabelNode not_my_problem = new LabelNode();
            instructions.add(new VarInsnNode(Opcodes.ILOAD, 1));
            instructions.add(intNode(firstJump.get(i)));
            instructions.add(new JumpInsnNode(Opcodes.IF_ICMPLT, not_my_problem));
            instructions.add(new VarInsnNode(Opcodes.ILOAD, 1));
            instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
            instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, tgtype, name + "$f" + i, "(I[Ljava/lang/Object;)I"));
            instructions.add(new VarInsnNode(Opcodes.ISTORE, 1));
            instructions.add(new JumpInsnNode(Opcodes.GOTO, loop));
            instructions.add(not_my_problem);
        }

        // time for return
        String rty = null, unboxName = null, unboxDesc = null;
        int retinst;
        Type rtyty = Type.getReturnType(desc);
        switch (rtyty.getSort()) {
            case Type.VOID:
                retinst = Opcodes.RETURN; break;
            case Type.BOOLEAN:
            case Type.CHAR:
            case Type.INT:
            case Type.SHORT:
            case Type.BYTE:
                retinst = Opcodes.IRETURN; rty = "java/lang/Integer"; unboxName = "intValue"; unboxDesc = "()I"; break;
            case Type.LONG:
                retinst = Opcodes.LRETURN; rty = "java/lang/Long"; unboxName = "longValue"; unboxDesc = "()J"; break;
            case Type.FLOAT:
                retinst = Opcodes.FRETURN; rty = "java/lang/Float"; unboxName = "floatValue"; unboxDesc = "()F"; break;
            case Type.DOUBLE:
                retinst = Opcodes.DRETURN; rty = "java/lang/Double"; unboxName = "doubleValue"; unboxDesc = "()D"; break;
            default:
                retinst = Opcodes.ARETURN; rty = rtyty.getInternalName(); break;
        }

        if (rty != null) {
            instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
            instructions.add(new InsnNode(Opcodes.ICONST_0));
            instructions.add(new InsnNode(Opcodes.AALOAD));
            instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, rty));
            if (unboxName != null)
                instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, rty, unboxName, unboxDesc));
View Full Code Here


        if (ty != null) {
            il.add(new TypeInsnNode(Opcodes.NEW, ty));
            il.add(new InsnNode(Opcodes.DUP));
        }
        il.add(new VarInsnNode(opc, ltmp));
        if (ty != null) il.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, ty, "<init>", desc));
        il.add(new InsnNode(Opcodes.AASTORE));
        return at.getSize();
    }
View Full Code Here

      case 1:
        IntInsnNode iinsn = (IntInsnNode) insn;
        visitIntInsn(iinsn.getOpcode(), iinsn.operand);
        break;
      case 2:
        VarInsnNode vinsn = (VarInsnNode) insn;
        visitVarInsn(vinsn.getOpcode(), vinsn.var);
        break;
      case 3:
        TypeInsnNode tinsn = (TypeInsnNode) insn;
        visitTypeInsn(tinsn.getOpcode(), tinsn.desc);
        break;
View Full Code Here

       
        /** Initialize def, use, and alloc sets based on the instruction corresponding to this node. */
        public final void initInfoSets(AbstractInsnNode insn) {
            if (AbstractInsnNode.VAR_INSN == insn.getType()) {
                // Detect reads and writes to local object references.
                VarInsnNode var = (VarInsnNode)insn;
   
                // We care only about object references and return addresses. (The latter only
                // because it uses the astore instruction.)
                // Read opcodes:
                //   aload, aload_n (for 0 <= n <= 3), ret (for return addresses)
                // Write opcodes:
                //   astore, astore_n (for 0 <= n <= 3)
                // ASM handles the *_n forms automatically.
                switch (var.getOpcode()) {
                case Opcodes.ALOAD:
                case Opcodes.RET:
                    use.set(var.var);
                    break;
                case Opcodes.ASTORE:
View Full Code Here

         * The 'def' set is updated for use by later analyses.
         */
        public final void removeDeadAssignments(InsnList instructions, AbstractInsnNode insn) {
            if (insn.getOpcode() != Opcodes.ASTORE) return;
           
            VarInsnNode varInsn = (VarInsnNode)insn;
           
            Value topValue = getStack(getStackSize() - 1);
            if (!liveOut.get(varInsn.var) && topValue != IsNullInterpreter.NULL) {
                InsnNode pop = new InsnNode(Opcodes.POP);
                instructions.insert(insn, pop);
View Full Code Here

                // Construct the nulling instructions.
                InsnList nullingInsns = new InsnList();
                for (int i = 0; i < toNull.length(); i++) {
                    if (toNull.get(i)) {
                        AbstractInsnNode pushNull = new InsnNode(Opcodes.ACONST_NULL);
                        AbstractInsnNode store = new VarInsnNode(Opcodes.ASTORE, i);
                        nullingInsns.add(pushNull);
                        nullingInsns.add(store);
                    }
                }
               
View Full Code Here

        return this;
    }

    public MethodDefinition loadObject(int slot)
    {
        instructionList.add(new VarInsnNode(ALOAD, slot));
        return this;
    }
View Full Code Here

        }
        else {
            instructionList.add(new InsnNode(ACONST_NULL));
        }

        instructionList.add(new VarInsnNode(Type.getType(type.getType()).getOpcode(ISTORE), variable.getSlot()));

        return this;
    }
View Full Code Here

    }

    public MethodDefinition loadVariable(LocalVariableDefinition variable)
    {
        ParameterizedType type = variable.getType();
        instructionList.add(new VarInsnNode(Type.getType(type.getType()).getOpcode(ILOAD), variable.getSlot()));
        return this;
    }
View Full Code Here

    }

    public MethodDefinition storeVariable(LocalVariableDefinition variable)
    {
        ParameterizedType type = variable.getType();
        instructionList.add(new VarInsnNode(Type.getType(type.getType()).getOpcode(ISTORE), variable.getSlot()));
        return this;
    }
View Full Code Here

TOP

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

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.