Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.TypeInsnNode


                    stack[sp++] = s;
                return;
            }

            VarInsnNode vi = null;
            TypeInsnNode ti = null;
            FieldInsnNode fi = null;
            String tidesc = null;
            MethodInsnNode mi = null;
            Type midesc = null;
View Full Code Here


        localVariables = null;
        instructions.clear();

        // allocate the scratchpad
        instructions.add(intNode(maxStack));
        instructions.add(new TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/Object"));
        // 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));
        }
        instructions.add(new InsnNode(retinst));
    }
View Full Code Here

            default:
                opc = Opcodes.ALOAD; break;
        }

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

      case 2:
        VarInsnNode vinsn = (VarInsnNode) insn;
        visitVarInsn(vinsn.getOpcode(), vinsn.var);
        break;
      case 3:
        TypeInsnNode tinsn = (TypeInsnNode) insn;
        visitTypeInsn(tinsn.getOpcode(), tinsn.desc);
        break;
      case 4:
        FieldInsnNode finsn = (FieldInsnNode) insn;
        visitFieldInsn(finsn.getOpcode(), finsn.owner, finsn.name, finsn.desc);
        break;
View Full Code Here

  }

  public AbstractInsnNode toInsn(int opcode)
  {
    if (isClass())
      return new TypeInsnNode(opcode, s_owner);
    else if (isMethod())
      return new MethodInsnNode(opcode, s_owner, s_name, s_desc);
    else
      return new FieldInsnNode(opcode, s_owner, s_name, s_desc);
  }
View Full Code Here

               throw new AnalyzerException(insn, "Unhandled bytecode instruction");
         }
         case NEW:
         {
            assert(insn instanceof TypeInsnNode);
            TypeInsnNode typeInsn = (TypeInsnNode)insn;
            String className = typeInsn.desc;
            return new TypedValue.NewValue(className);
         }
         case BIPUSH:
         case SIPUSH:
View Full Code Here

         case IFNULL:
         case IFNONNULL:
            return ifOperation(insn, value, new ConstantValue.NullConstant());
         case CHECKCAST:
         {
            TypeInsnNode typeInsn = (TypeInsnNode)insn;
            return new TypedValue.CastValue(Type.getObjectType(typeInsn.desc), (TypedValue)value);
         }
         case GETFIELD:  // this should normally failed, but a subclass can handle it
         case INEG:
         case LNEG:
View Full Code Here

        return this;
    }

    public MethodDefinition checkCast(ParameterizedType type)
    {
        instructionList.add(new TypeInsnNode(CHECKCAST, type.getClassName()));
        return this;
    }
View Full Code Here

        return this;
    }

    public MethodDefinition newObject(Class<?> type)
    {
        instructionList.add(new TypeInsnNode(NEW, type(type).getClassName()));
        return this;
    }
View Full Code Here

        return this;
    }

    public MethodDefinition newObject(ParameterizedType type)
    {
        instructionList.add(new TypeInsnNode(NEW, type.getClassName()));
        return this;
    }
View Full Code Here

TOP

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

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.