Package org.objectweb.asm

Examples of org.objectweb.asm.MethodVisitor.visitInsn()


        statement.getExpression().visit(controller.getAcg());

        // we should infer the type of the exception from the expression
        mv.visitTypeInsn(CHECKCAST, "java/lang/Throwable");
        mv.visitInsn(ATHROW);
       
        controller.getOperandStack().remove(1);
    }

    public void writeReturn(ReturnStatement statement) {
View Full Code Here


            if (!(statement.isReturningNullOrVoid())) {
                //TODO: move to Verifier
                controller.getAcg().throwException("Cannot use return statement with an expression on a method that returns void");
            }
            controller.getCompileStack().applyBlockRecorder();
            mv.visitInsn(RETURN);
            return;
        }

        Expression expression = statement.getExpression();
        expression.visit(controller.getAcg());
View Full Code Here

        String desc = BytecodeHelper.getMethodDescriptor(target.getReturnType(), target.getParameters());
        mv.visitMethodInsn(opcode, owner, methodName, desc);
        ClassNode ret = target.getReturnType().redirect();
        if (ret==ClassHelper.VOID_TYPE) {
            ret = ClassHelper.OBJECT_TYPE;
            mv.visitInsn(ACONST_NULL);
        }
        argumentsToRemove += args.getExpressions().size();
        controller.getOperandStack().remove(argumentsToRemove);
        controller.getOperandStack().push(ret);
        return true;
View Full Code Here

        for (int i = 0; i < size; i++) {
            if (useArray) {
                // unpack argument from Object[]
                mv.visitVarInsn(Opcodes.ALOAD, 2);
                BytecodeHelper.pushConstant(mv, i);
                mv.visitInsn(Opcodes.AALOAD);
            } else {
                mv.visitVarInsn(Opcodes.ALOAD, i+2);
            }

            // cast argument to parameter class, inclusive unboxing
View Full Code Here

        mv.visitMethodInsn(invokeMethodCode, type, cachedMethod.getName(), descriptor);

        // produce result
        BytecodeHelper.box(mv, cachedMethod.getReturnType());
        if (cachedMethod.getReturnType() == void.class) {
            mv.visitInsn(Opcodes.ACONST_NULL);
        }

        // return
        mv.visitInsn(Opcodes.ARETURN);
       
View Full Code Here

        if (cachedMethod.getReturnType() == void.class) {
            mv.visitInsn(Opcodes.ACONST_NULL);
        }

        // return
        mv.visitInsn(Opcodes.ARETURN);
       
        // fall back after method change
        mv.visitLabel(l0);
        for (int i = 0; i < argumentCount; ++i) mv.visitVarInsn(Opcodes.ALOAD, i);
        if (!useArray) {
View Full Code Here

        for (int i = 0; i < argumentCount; ++i) mv.visitVarInsn(Opcodes.ALOAD, i);
        if (!useArray) {
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, "org/codehaus/groovy/runtime/ArrayUtil", "createArray", "(" + parameterDescription + ")[Ljava/lang/Object;");
        }
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "org/codehaus/groovy/runtime/callsite/CallSiteArray", "defaultCall" + name, "(Lorg/codehaus/groovy/runtime/callsite/CallSite;L" + receiverType + ";[Ljava/lang/Object;)Ljava/lang/Object;");
        mv.visitInsn(Opcodes.ARETURN);
       
        // exception unwrapping for stackless exceptions
        final Label tryEnd = new Label();
        mv.visitLabel(tryEnd);
        final Label catchStart = new Label();
View Full Code Here

        final Label tryEnd = new Label();
        mv.visitLabel(tryEnd);
        final Label catchStart = new Label();
        mv.visitLabel(catchStart);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "org/codehaus/groovy/runtime/ScriptBytecodeAdapter", "unwrap", "(Lgroovy/lang/GroovyRuntimeException;)Ljava/lang/Throwable;");
        mv.visitInsn(Opcodes.ATHROW);       
        mv.visitTryCatchBlock(tryStart, tryEnd, catchStart, GRE);
       
        mv.visitMaxs(0, 0);
        mv.visitEnd();
        return mv;
View Full Code Here

        mv.visitMethodInsn(Opcodes.INVOKESPECIAL, superClass, "<init>", "(Lorg/codehaus/groovy/runtime/callsite/CallSite;Lgroovy/lang/MetaClassImpl;Lgroovy/lang/MetaMethod;[Ljava/lang/Class;)V");

        mv.visitVarInsn(Opcodes.ALOAD, 5);
        mv.visitFieldInsn(Opcodes.PUTSTATIC, internalName, "__constructor__", "Ljava/lang/reflect/Constructor;");

        mv.visitInsn(Opcodes.RETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }

    public static byte[] genPogoMetaMethodSite(CachedMethod cachedMethod, ClassWriter cw, String name) {
View Full Code Here

  public void test() {
    TraceMethodVisitor tmv = new TraceMethodVisitor(null);
    MethodVisitor mv = new RemoveAddZeroAdapter(tmv);
    mv.visitCode();
    mv.visitVarInsn(ILOAD, 1);
    mv.visitInsn(ICONST_0);
    mv.visitInsn(IADD);
    mv.visitInsn(IRETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    checkMethod(tmv);
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.