Examples of SkinnyMethodAdapter


Examples of org.jruby.compiler.impl.SkinnyMethodAdapter

        synchronized (classLoader) {
            Class c = tryClass(mname);
            try {
                if (c == null) {
                    ClassWriter cw = createBlockCtor(mnamePath, typeClass);
                    SkinnyMethodAdapter mv = startBlockCall(cw);
                    mv.aload(0);
                    mv.getfield(mnamePath, "$scriptObject", ci(typeClass));
                    mv.aload(1);
                    mv.aload(2);
                    mv.aload(3);
                    mv.invokestatic(typePathString, method, sig(
                            RubyKernel.IRUBY_OBJECT, "L" + typePathString + ";", ThreadContext.class,
                                    RubyKernel.IRUBY_OBJECT, IRubyObject.class));
                    mv.areturn();
                   
                    mv.visitMaxs(2, 3);
                    c = endCall(cw, mv, mname);
                }
                CompiledBlockCallback ic = (CompiledBlockCallback) c.getConstructor(Object.class).newInstance(scriptObject);
                return ic;
            } catch (IllegalArgumentException e) {
View Full Code Here

Examples of org.jruby.compiler.impl.SkinnyMethodAdapter

        synchronized (classLoader) {
            Class c = tryClass(mname);
            try {
                if (c == null) {
                    ClassWriter cw = createBlockCtor19(mnamePath, typeClass);
                    SkinnyMethodAdapter mv = startBlockCall19(cw);
                    mv.aload(0);
                    mv.getfield(mnamePath, "$scriptObject", ci(typeClass));
                    mv.aload(1);
                    mv.aload(2);
                    mv.aload(3);
                    mv.aload(4);
                    mv.invokestatic(typePathString, method, sig(
                            IRubyObject.class, "L" + typePathString + ";", ThreadContext.class,
                                    IRubyObject.class, IRubyObject[].class, Block.class));
                    mv.areturn();

                    mv.visitMaxs(2, 3);
                    c = endCall(cw, mv, mname);
                }
                CompiledBlockCallback19 ic = (CompiledBlockCallback19) c.getConstructor(Object.class).newInstance(scriptObject);
                return ic;
            } catch (IllegalArgumentException e) {
View Full Code Here

Examples of org.jruby.compiler.impl.SkinnyMethodAdapter

        site.setTarget(myFallback);
        return site;
    }
   
    public static void installBytecode(MethodVisitor method, String classname) {
        SkinnyMethodAdapter mv = new SkinnyMethodAdapter(method);
        mv.ldc(c(classname));
        mv.invokestatic(p(Class.class), "forName", sig(Class.class, params(String.class)));
        mv.getstatic(p(InvokeDynamicSupport.class), "BOOTSTRAP", ci(MethodHandle.class));
        mv.invokestatic(p(java.dyn.Linkage.class), "registerBootstrapMethod", sig(void.class, Class.class, MethodHandle.class));
    }
View Full Code Here

Examples of org.jruby.compiler.impl.SkinnyMethodAdapter

       
        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
        cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, classname, null, p(Object.class), new String[] {p(Unsafe.class)});
        cw.visitSource("<generated>", null);
       
        SkinnyMethodAdapter method = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "<init>", sig(void.class), null, null);
        method.start();
        method.line(0);
        method.aload(0);
        method.invokespecial(p(Object.class), "<init>", sig(void.class));
        method.voidreturn();
        method.end();
       
        method = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "throwException", sig(void.class, Throwable.class), null, null);
        method.line(0);
        method.start();
        method.aload(1);
        method.athrow();
        method.end();
       
        cw.visitEnd();
       
        byte[] bytecode = cw.toByteArray();
       
View Full Code Here

Examples of org.jruby.compiler.impl.SkinnyMethodAdapter

            String method, String className, String invokerPath, Arity arity,
            StaticScope scope, CallConfiguration callConfig, String filename, int line) {
        String sup = COMPILED_SUPER_CLASS;
        ClassWriter cw;
        cw = createCompiledCtor(invokerPath, invokerPath, sup);
        SkinnyMethodAdapter mv = null;
        String signature = null;
        boolean specificArity = false;

        // if trace, need to at least populate a backtrace frame
        if (RubyInstanceConfig.FULL_TRACE_ENABLED) {
            switch (callConfig) {
            case FrameNoneScopeDummy:
                callConfig = CallConfiguration.FrameBacktraceScopeDummy;
                break;
            case FrameNoneScopeFull:
                callConfig = CallConfiguration.FrameBacktraceScopeFull;
                break;
            case FrameNoneScopeNone:
                callConfig = CallConfiguration.FrameBacktraceScopeNone;
                break;
            }
        }

        if (scope.getRestArg() >= 0 || scope.getOptionalArgs() > 0 || scope.getRequiredArgs() > 3) {
            signature = COMPILED_CALL_SIG_BLOCK;
            mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "call", signature, null, null);
        } else {
            specificArity = true;

            mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "call", COMPILED_CALL_SIG_BLOCK, null, null);
            mv.start();
            mv.line(-1);

            // check arity
            mv.aloadMany(0, 1, 4, 5); // method, context, name, args, required
            mv.pushInt(scope.getRequiredArgs());
            mv.invokestatic(p(JavaMethod.class), "checkArgumentCount", sig(void.class, JavaMethod.class, ThreadContext.class, String.class, IRubyObject[].class, int.class));

            mv.aloadMany(0, 1, 2, 3, 4);
            for (int i = 0; i < scope.getRequiredArgs(); i++) {
                mv.aload(5);
                mv.ldc(i);
                mv.arrayload();
            }
            mv.aload(6);

            switch (scope.getRequiredArgs()) {
            case 0:
                signature = COMPILED_CALL_SIG_ZERO_BLOCK;
                break;
            case 1:
                signature = COMPILED_CALL_SIG_ONE_BLOCK;
                break;
            case 2:
                signature = COMPILED_CALL_SIG_TWO_BLOCK;
                break;
            case 3:
                signature = COMPILED_CALL_SIG_THREE_BLOCK;
                break;
            }

            mv.invokevirtual(invokerPath, "call", signature);
            mv.areturn();
            mv.end();

            // Define a second version that doesn't take a block, so we have unique code paths for both cases.
            switch (scope.getRequiredArgs()) {
            case 0:
                signature = COMPILED_CALL_SIG_ZERO;
                break;
            case 1:
                signature = COMPILED_CALL_SIG_ONE;
                break;
            case 2:
                signature = COMPILED_CALL_SIG_TWO;
                break;
            case 3:
                signature = COMPILED_CALL_SIG_THREE;
                break;
            }
            mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "call", signature, null, null);
            mv.start();
            mv.line(-1);

            mv.aloadMany(0, 1, 2, 3, 4);
            for (int i = 1; i <= scope.getRequiredArgs(); i++) {
                mv.aload(4 + i);
            }
            mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class));

            switch (scope.getRequiredArgs()) {
            case 0:
                signature = COMPILED_CALL_SIG_ZERO_BLOCK;
                break;
            case 1:
                signature = COMPILED_CALL_SIG_ONE_BLOCK;
                break;
            case 2:
                signature = COMPILED_CALL_SIG_TWO_BLOCK;
                break;
            case 3:
                signature = COMPILED_CALL_SIG_THREE_BLOCK;
                break;
            }

            mv.invokevirtual(invokerPath, "call", signature);
            mv.areturn();
            mv.end();

            mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "call", signature, null, null);
        }

        mv.visitCode();
        mv.line(-1);

        // save off callNumber
        mv.aload(1);
        mv.getfield(p(ThreadContext.class), "callNumber", ci(int.class));
        int callNumberIndex = -1;
        if (specificArity) {
            switch (scope.getRequiredArgs()) {
            case -1:
                callNumberIndex = ARGS_INDEX + 1/*args*/ + 1/*block*/ + 1;
                break;
            case 0:
                callNumberIndex = ARGS_INDEX + 1/*block*/ + 1;
                break;
            default:
                callNumberIndex = ARGS_INDEX + scope.getRequiredArgs() + 1/*block*/ + 1;
            }
        } else {
            callNumberIndex = ARGS_INDEX + 1/*block*/ + 1;
        }
        mv.istore(callNumberIndex);

        // invoke pre method stuff
        if (!callConfig.isNoop() || RubyInstanceConfig.FULL_TRACE_ENABLED) {
            if (specificArity) {
                invokeCallConfigPre(mv, COMPILED_SUPER_CLASS, scope.getRequiredArgs(), true, callConfig);
            } else {
                invokeCallConfigPre(mv, COMPILED_SUPER_CLASS, -1, true, callConfig);
            }
        }

        // pre-call trace
        int traceBoolIndex = -1;
        if (RubyInstanceConfig.FULL_TRACE_ENABLED) {
            // load and store trace enabled flag
            if (specificArity) {
                switch (scope.getRequiredArgs()) {
                case -1:
                    traceBoolIndex = ARGS_INDEX + 1/*args*/ + 1/*block*/ + 2;
                    break;
                case 0:
                    traceBoolIndex = ARGS_INDEX + 1/*block*/ + 2;
                    break;
                default:
                    traceBoolIndex = ARGS_INDEX + scope.getRequiredArgs() + 1/*block*/ + 2;
                }
            } else {
                traceBoolIndex = ARGS_INDEX + 1/*block*/ + 2;
            }

            mv.aload(1);
            mv.invokevirtual(p(ThreadContext.class), "getRuntime", sig(Ruby.class));
            mv.invokevirtual(p(Ruby.class), "hasEventHooks", sig(boolean.class));
            mv.istore(traceBoolIndex);
            // tracing pre
            invokeTraceCompiledPre(mv, COMPILED_SUPER_CLASS, traceBoolIndex, filename, line);
        }

        Label tryBegin = new Label();
        Label tryEnd = new Label();
        Label doFinally = new Label();
        Label doReturnFinally = new Label();
        Label doRedoFinally = new Label();
        Label catchReturnJump = new Label();
        Label catchRedoJump = new Label();

        boolean heapScoped = callConfig.scoping() != Scoping.None;
        boolean framed = callConfig.framing() != Framing.None;

        if (framed || heapScoped)   mv.trycatch(tryBegin, tryEnd, catchReturnJump, p(JumpException.ReturnJump.class));
        if (framed)                 mv.trycatch(tryBegin, tryEnd, catchRedoJump, p(JumpException.RedoJump.class));
        if (framed || heapScoped)   mv.trycatch(tryBegin, tryEnd, doFinally, null);
        if (framed || heapScoped)   mv.trycatch(catchReturnJump, doReturnFinally, doFinally, null);
        if (framed)                 mv.trycatch(catchRedoJump, doRedoFinally, doFinally, null);
        if (framed || heapScoped)   mv.label(tryBegin);

        // main body
        {
            mv.aload(0);
            // FIXME we want to eliminate these type casts when possible
            mv.getfield(invokerPath, "$scriptObject", ci(Object.class));
            mv.checkcast(className);
            mv.aloadMany(THREADCONTEXT_INDEX, RECEIVER_INDEX);
            if (specificArity) {
                for (int i = 0; i < scope.getRequiredArgs(); i++) {
                    mv.aload(ARGS_INDEX + i);
                }
                mv.aload(ARGS_INDEX + scope.getRequiredArgs());
                mv.invokestatic(className, method, StandardASMCompiler.getStaticMethodSignature(className, scope.getRequiredArgs()));
            } else {
                mv.aloadMany(ARGS_INDEX, BLOCK_INDEX);
                mv.invokestatic(className, method, StandardASMCompiler.getStaticMethodSignature(className, 4));
            }
        }
        if (framed || heapScoped) {
            mv.label(tryEnd);
        }

        // normal exit, perform finally and return
        {
            if (RubyInstanceConfig.FULL_TRACE_ENABLED) {
                invokeTraceCompiledPost(mv, COMPILED_SUPER_CLASS, traceBoolIndex);
            }
            if (!callConfig.isNoop()) {
                invokeCallConfigPost(mv, COMPILED_SUPER_CLASS, callConfig);
            }
            mv.visitInsn(ARETURN);
        }

        // return jump handling
        if (framed || heapScoped) {
            mv.label(catchReturnJump);
            {
                mv.aload(0);
                mv.swap();
                mv.aload(1);
                mv.swap();
                mv.iload(callNumberIndex);
                mv.invokevirtual(COMPILED_SUPER_CLASS, "handleReturn", sig(IRubyObject.class, ThreadContext.class, JumpException.ReturnJump.class, int.class));
                mv.label(doReturnFinally);

                // finally
                if (RubyInstanceConfig.FULL_TRACE_ENABLED) {
                    invokeTraceCompiledPost(mv, COMPILED_SUPER_CLASS, traceBoolIndex);
                }
                if (!callConfig.isNoop()) {
                    invokeCallConfigPost(mv, COMPILED_SUPER_CLASS, callConfig);
                }

                // return result if we're still good
                mv.areturn();
            }
        }

        if (framed) {
            // redo jump handling
            mv.label(catchRedoJump);
            {
                // clear the redo
                mv.pop();

                // get runtime, create jump error, and throw it
                mv.aload(1);
                mv.invokevirtual(p(ThreadContext.class), "getRuntime", sig(Ruby.class));
                mv.invokevirtual(p(Ruby.class), "newRedoLocalJumpError", sig(RaiseException.class));
                mv.label(doRedoFinally);

                // finally
                if (RubyInstanceConfig.FULL_TRACE_ENABLED) {
                    invokeTraceCompiledPost(mv, COMPILED_SUPER_CLASS, traceBoolIndex);
                }
                if (!callConfig.isNoop()) {
                    invokeCallConfigPost(mv, COMPILED_SUPER_CLASS, callConfig);
                }

                // throw redo error if we're still good
                mv.athrow();
            }
        }

        // finally handling for abnormal exit
        if (framed || heapScoped) {
            mv.label(doFinally);

            //call post method stuff (exception raised)
            if (RubyInstanceConfig.FULL_TRACE_ENABLED) {
                invokeTraceCompiledPost(mv, COMPILED_SUPER_CLASS, traceBoolIndex);
            }
            if (!callConfig.isNoop()) {
                invokeCallConfigPost(mv, COMPILED_SUPER_CLASS, callConfig);
            }

            // rethrow exception
            mv.athrow(); // rethrow it
        }
        mv.end();

        return endCallOffline(cw);
    }
View Full Code Here

Examples of org.jruby.compiler.impl.SkinnyMethodAdapter

        // fields to hold Ruby and RubyClass references
        cw.visitField(ACC_STATIC | ACC_PRIVATE, "ruby", ci(Ruby.class), null, null);
        cw.visitField(ACC_STATIC | ACC_PRIVATE, "rubyClass", ci(RubyClass.class), null, null);

        // static initializing method
        SkinnyMethodAdapter m = new SkinnyMethodAdapter(cw, ACC_PUBLIC | ACC_STATIC, "clinit", sig(void.class, Ruby.class, RubyClass.class), null, null);
        m.start();
        m.aload(0);
        m.putstatic(javaPath, "ruby", ci(Ruby.class));
        m.aload(1);
        m.putstatic(javaPath, "rubyClass", ci(RubyClass.class));
        m.voidreturn();
        m.end();

        // standard constructor that accepts Ruby, RubyClass
        m = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "<init>", sig(void.class, Ruby.class, RubyClass.class), null, null);
        m.aload(0);
        m.aload(1);
        m.aload(2);
        m.invokespecial(p(reifiedParent), "<init>", sig(void.class, Ruby.class, RubyClass.class));
        m.voidreturn();
        m.end();

        // no-arg constructor using static references to Ruby and RubyClass
        m = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "<init>", CodegenUtils.sig(void.class), null, null);
        m.aload(0);
        m.getstatic(javaPath, "ruby", ci(Ruby.class));
        m.getstatic(javaPath, "rubyClass", ci(RubyClass.class));
        m.invokespecial(p(reifiedParent), "<init>", sig(void.class, Ruby.class, RubyClass.class));
        m.voidreturn();
        m.end();

        // gather a list of instance methods, so we don't accidentally make static ones that conflict
        Set<String> instanceMethods = new HashSet<String>();

        // define instance methods
        for (Map.Entry<String,DynamicMethod> methodEntry : getMethods().entrySet()) {
            String methodName = methodEntry.getKey();
            String javaMethodName = JavaNameMangler.mangleStringForCleanJavaIdentifier(methodName);
            Map<Class,Map<String,Object>> methodAnnos = getMethodAnnotations().get(methodName);
            List<Map<Class,Map<String,Object>>> parameterAnnos = getParameterAnnotations().get(methodName);
            Class[] methodSignature = getMethodSignatures().get(methodName);

            String signature;
            if (methodSignature == null) {
                // non-signature signature with just IRubyObject
                switch (methodEntry.getValue().getArity().getValue()) {
                case 0:
                    signature = sig(IRubyObject.class);
                    m = new SkinnyMethodAdapter(cw, ACC_PUBLIC | ACC_VARARGS, javaMethodName, signature, null, null);
                    generateMethodAnnotations(methodAnnos, m, parameterAnnos);

                    m.aload(0);
                    m.ldc(methodName);
                    m.invokevirtual(javaPath, "callMethod", sig(IRubyObject.class, String.class));
                    break;
                default:
                    signature = sig(IRubyObject.class, IRubyObject[].class);
                    m = new SkinnyMethodAdapter(cw, ACC_PUBLIC | ACC_VARARGS, javaMethodName, signature, null, null);
                    generateMethodAnnotations(methodAnnos, m, parameterAnnos);

                    m.aload(0);
                    m.ldc(methodName);
                    m.aload(1);
                    m.invokevirtual(javaPath, "callMethod", sig(IRubyObject.class, String.class, IRubyObject[].class));
                }
                m.areturn();
            } else {
                // generate a real method signature for the method, with to/from coercions

                // indices for temp values
                Class[] params = new Class[methodSignature.length - 1];
                System.arraycopy(methodSignature, 1, params, 0, params.length);
                int baseIndex = 1;
                for (Class paramType : params) {
                    if (paramType == double.class || paramType == long.class) {
                        baseIndex += 2;
                    } else {
                        baseIndex += 1;
                    }
                }
                int rubyIndex = baseIndex;

                signature = sig(methodSignature[0], params);
                m = new SkinnyMethodAdapter(cw, ACC_PUBLIC | ACC_VARARGS, javaMethodName, signature, null, null);
                generateMethodAnnotations(methodAnnos, m, parameterAnnos);

                m.getstatic(javaPath, "ruby", ci(Ruby.class));
                m.astore(rubyIndex);

                m.aload(0); // self
                m.ldc(methodName); // method name
                RealClassGenerator.coerceArgumentsToRuby(m, params, rubyIndex);
                m.invokevirtual(javaPath, "callMethod", sig(IRubyObject.class, String.class, IRubyObject[].class));

                RealClassGenerator.coerceResultAndReturn(m, methodSignature[0]);
            }

            if (DEBUG_REIFY) System.out.println("defining " + getName() + "#" + methodName + " as " + javaName + "#" + javaMethodName + signature);

            instanceMethods.add(javaMethodName + signature);

            m.end();
        }

        // define class/static methods
        for (Map.Entry<String,DynamicMethod> methodEntry : getMetaClass().getMethods().entrySet()) {
            String methodName = methodEntry.getKey();
            String javaMethodName = JavaNameMangler.mangleStringForCleanJavaIdentifier(methodName);
            Map<Class,Map<String,Object>> methodAnnos = getMetaClass().getMethodAnnotations().get(methodName);
            List<Map<Class,Map<String,Object>>> parameterAnnos = getMetaClass().getParameterAnnotations().get(methodName);
            Class[] methodSignature = getMetaClass().getMethodSignatures().get(methodName);

            String signature;
            if (methodSignature == null) {
                // non-signature signature with just IRubyObject
                switch (methodEntry.getValue().getArity().getValue()) {
                case 0:
                    signature = sig(IRubyObject.class);
                    if (instanceMethods.contains(javaMethodName + signature)) continue;
                    m = new SkinnyMethodAdapter(cw, ACC_PUBLIC | ACC_VARARGS | ACC_STATIC, javaMethodName, signature, null, null);
                    generateMethodAnnotations(methodAnnos, m, parameterAnnos);

                    m.getstatic(javaPath, "rubyClass", ci(RubyClass.class));
                    //m.invokevirtual("org/jruby/RubyClass", "getMetaClass", sig(RubyClass.class) );
                    m.ldc(methodName); // Method name
                    m.invokevirtual("org/jruby/RubyClass", "callMethod", sig(IRubyObject.class, String.class) );
                    break;
                default:
                    signature = sig(IRubyObject.class, IRubyObject[].class);
                    if (instanceMethods.contains(javaMethodName + signature)) continue;
                    m = new SkinnyMethodAdapter(cw, ACC_PUBLIC | ACC_VARARGS | ACC_STATIC, javaMethodName, signature, null, null);
                    generateMethodAnnotations(methodAnnos, m, parameterAnnos);

                    m.getstatic(javaPath, "rubyClass", ci(RubyClass.class));
                    m.ldc(methodName); // Method name
                    m.aload(0);
                    m.invokevirtual("org/jruby/RubyClass", "callMethod", sig(IRubyObject.class, String.class, IRubyObject[].class) );
                }
                m.areturn();
            } else {
                // generate a real method signature for the method, with to/from coercions

                // indices for temp values
                Class[] params = new Class[methodSignature.length - 1];
                System.arraycopy(methodSignature, 1, params, 0, params.length);
                int baseIndex = 0;
                for (Class paramType : params) {
                    if (paramType == double.class || paramType == long.class) {
                        baseIndex += 2;
                    } else {
                        baseIndex += 1;
                    }
                }
                int rubyIndex = baseIndex;

                signature = sig(methodSignature[0], params);
                if (instanceMethods.contains(javaMethodName + signature)) continue;
                m = new SkinnyMethodAdapter(cw, ACC_PUBLIC | ACC_VARARGS | ACC_STATIC, javaMethodName, signature, null, null);
                generateMethodAnnotations(methodAnnos, m, parameterAnnos);

                m.getstatic(javaPath, "ruby", ci(Ruby.class));
                m.astore(rubyIndex);

                m.getstatic(javaPath, "rubyClass", ci(RubyClass.class));
               
                m.ldc(methodName); // method name
                RealClassGenerator.coerceArgumentsToRuby(m, params, rubyIndex);
                m.invokevirtual("org/jruby/RubyClass", "callMethod", sig(IRubyObject.class, String.class, IRubyObject[].class));

                RealClassGenerator.coerceResultAndReturn(m, methodSignature[0]);
            }

            if (DEBUG_REIFY) System.out.println("defining " + getName() + "." + methodName + " as " + javaName + "." + javaMethodName + signature);

            m.end();
        }


        cw.visitEnd();
        byte[] classBytes = cw.toByteArray();
View Full Code Here

Examples of org.jruby.compiler.impl.SkinnyMethodAdapter

    @Override
    public byte[] getBlockCallbackOffline(String method, String file, int line, String classname) {
        String mname = getBlockCallbackName(classname, method);
        ClassWriter cw = createBlockCtor(mname, classname);
        SkinnyMethodAdapter mv = startBlockCall(cw);
        mv.line(-1);
        mv.aload(0);
        mv.getfield(mname, "$scriptObject", "L" + classname + ";");
        mv.aloadMany(1, 2, 3, 4);
        mv.invokestatic(classname, method, sig(
                IRubyObject.class, "L" + classname + ";", ThreadContext.class,
                        IRubyObject.class, IRubyObject.class, Block.class));
        mv.areturn();
        mv.end();

        mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "getFile", sig(String.class), null, null);
        mv.start();
        mv.ldc(file);
        mv.areturn();
        mv.end();

        mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "getLine", sig(int.class), null, null);
        mv.start();
        mv.ldc(line);
        mv.ireturn();
        mv.end();

        return endCallOffline(cw);
    }
View Full Code Here

Examples of org.jruby.compiler.impl.SkinnyMethodAdapter

    @Override
    public byte[] getBlockCallback19Offline(String method, String file, int line, String classname) {
        String mnamePath = getBlockCallbackName(classname, method);
        ClassWriter cw = createBlockCtor19(mnamePath, classname);
        SkinnyMethodAdapter mv = startBlockCall19(cw);
        mv.line(-1);
        mv.aload(0);
        mv.getfield(mnamePath, "$scriptObject", "L" + classname + ";");
        mv.aloadMany(1, 2, 3, 4);
        mv.invokestatic(classname, method, sig(
                IRubyObject.class, "L" + classname + ";", ThreadContext.class,
                        IRubyObject.class, IRubyObject[].class, Block.class));
        mv.areturn();
        mv.end();

        mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "getFile", sig(String.class), null, null);
        mv.start();
        mv.ldc(file);
        mv.areturn();
        mv.end();

        mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "getLine", sig(int.class), null, null);
        mv.start();
        mv.ldc(line);
        mv.ireturn();
        mv.end();
       
        return endCallOffline(cw);
    }
View Full Code Here

Examples of org.jruby.compiler.impl.SkinnyMethodAdapter

       
        return endCallOffline(cw);
    }

    private SkinnyMethodAdapter startBlockCall(ClassWriter cw) {
        SkinnyMethodAdapter mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC | ACC_SYNTHETIC | ACC_FINAL, "call", BLOCK_CALL_SIG, null, null);

        mv.visitCode();
        Label line = new Label();
        mv.visitLineNumber(0, line);
        return mv;
    }
View Full Code Here

Examples of org.jruby.compiler.impl.SkinnyMethodAdapter

        mv.visitLineNumber(0, line);
        return mv;
    }

    private SkinnyMethodAdapter startBlockCall19(ClassWriter cw) {
        SkinnyMethodAdapter mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC | ACC_SYNTHETIC | ACC_FINAL, "call", BLOCK_CALL_SIG19, null, null);

        mv.visitCode();
        Label line = new Label();
        mv.visitLineNumber(0, line);
        return mv;
    }
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.