Package org.jruby.runtime

Examples of org.jruby.runtime.CompiledBlockCallback


    }
   
    public CompiledBlockCallback getBlockCallback(String method, final Object scriptObject) {
        try {
            final Method blockMethod = scriptObject.getClass().getMethod(method, new Class[]{ThreadContext.class, IRubyObject.class, IRubyObject.class});
            return new CompiledBlockCallback() {
                public IRubyObject call(ThreadContext context, IRubyObject self, IRubyObject args) {
                    try {
                        return (IRubyObject)blockMethod.invoke(scriptObject, new Object[]{context, self, args});
                    } catch (IllegalAccessException ex) {
                        throw new RuntimeException(ex);
View Full Code Here


                    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) {
                throw e;
            } catch (Exception e) {
                e.printStackTrace();
View Full Code Here

                    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) {
                throw e;
            } catch (Exception e) {
                e.printStackTrace();
View Full Code Here

    @Deprecated
    public CompiledBlockCallback getBlockCallback(String method, final Object scriptObject) {
        try {
            final Method blockMethod = scriptObject.getClass().getMethod(method, new Class[]{ThreadContext.class, IRubyObject.class, IRubyObject.class});
            return new CompiledBlockCallback() {
                public IRubyObject call(ThreadContext context, IRubyObject self, IRubyObject args, Block block) {
                    try {
                        return (IRubyObject)blockMethod.invoke(scriptObject, new Object[]{context, self, args, block});
                    } catch (IllegalAccessException ex) {
                        throw new RuntimeException(ex);
View Full Code Here

        }
        return body;
    }

    public final CompiledBlockCallback getBlockCallback(Object scriptObject, Ruby runtime, int index, String method) {
        CompiledBlockCallback callback = blockCallbacks[index];
        if (callback == null) {
            return createCompiledBlockCallback(scriptObject, runtime, index, method);
        }
        return callback;
    }
View Full Code Here

        BlockBody body = RuntimeHelpers.createCompiledBlockBody19(context, scriptObject, descriptor);
        return blockBodies[index] = body;
    }

    private CompiledBlockCallback createCompiledBlockCallback(Object scriptObject, Ruby runtime, int index, String method) {
        CompiledBlockCallback callback = RuntimeHelpers.createBlockCallback(runtime, scriptObject, method, "(internal)", -1);
        return blockCallbacks[index] = callback;
    }
View Full Code Here

    public CompiledBlockCallback getBlockCallback(String method, final String file, final int line, final Object scriptObject) {
        try {
            Class scriptClass = scriptObject.getClass();
            final Method blockMethod = scriptClass.getMethod(method, scriptClass, ThreadContext.class, IRubyObject.class, IRubyObject.class, Block.class);
            return new CompiledBlockCallback() {
                public IRubyObject call(ThreadContext context, IRubyObject self, IRubyObject args, Block block) {
                    try {
                        return (IRubyObject)blockMethod.invoke(null, scriptObject, context, self, args, block);
                    } catch (IllegalAccessException ex) {
                        throw new RuntimeException(ex);
View Full Code Here

                        }
                    }
                }
            }
               
            CompiledBlockCallback ic = (CompiledBlockCallback) c.getConstructor(Object.class).newInstance(scriptObject);
            return ic;
        } catch (IllegalArgumentException e) {
            throw e;
        } catch (Exception e) {
            throw new IllegalArgumentException(e.getMessage());
View Full Code Here

        }
        return body;
    }

    public final CompiledBlockCallback getBlockCallback(Object scriptObject, int index, String method) {
        CompiledBlockCallback callback = blockCallbacks[index];
        if (callback == null) {
            return createCompiledBlockCallback(scriptObject, index, method);
        }
        return callback;
    }
View Full Code Here

        BlockBody body = RuntimeHelpers.createCompiledBlockBody19(context, scriptObject, scope, descriptor);
        return blockBodies[index] = body;
    }

    private CompiledBlockCallback createCompiledBlockCallback(Object scriptObject, int index, String method) {
        CompiledBlockCallback callback = RuntimeHelpers.createBlockCallback(scriptObject, method, "(internal)", -1);
        return blockCallbacks[index] = callback;
    }
View Full Code Here

TOP

Related Classes of org.jruby.runtime.CompiledBlockCallback

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.