Package org.jruby.runtime

Examples of org.jruby.runtime.BlockBody


    }

    @JRubyMethod(name = "parameters", compat = RUBY1_9)
    public IRubyObject parameters(ThreadContext context) {
        Ruby runtime = context.getRuntime();
        BlockBody body = this.getBlock().getBody();

        if (body instanceof MethodBlock) {
            MethodBlock methodBlock = (MethodBlock)body;
            return methodBlock.getMethod().parameters(context);
        }

        return RuntimeHelpers.parameterListToParameters(runtime, body.getParameterList(), isLambda());
    }
View Full Code Here


   
    @JRubyMethod
    public IRubyObject to_proc(ThreadContext context) {
        StaticScope scope = new LocalStaticScope(null);
       
        BlockBody body = new ContextAwareBlockBody(scope, Arity.OPTIONAL, BlockBody.SINGLE_RESTARG) {
            @Override
            public IRubyObject yield(ThreadContext context, IRubyObject value, Binding binding, Type type) {
                RubyArray array = ArgsUtil.convertToRubyArray(context.getRuntime(), value, false);
                if (array.isEmpty()) {
                    throw context.getRuntime().newArgumentError("no receiver given");
View Full Code Here

        return true;
    }

    @Override
    public Object retrieve(InterpreterContext interp) {
        BlockBody body = ((IRClosure) scope).getBlockBody();
        scope.getStaticScope().determineModule();
        Binding binding = interp.getContext().currentBinding((IRubyObject) interp.getSelf(), interp.getSharedBindingScope());

        return new Block(body, binding);
    }
View Full Code Here

     * @param index
     * @param descriptor
     * @return
     */
    public final BlockBody getBlockBody(Object scriptObject, ThreadContext context, int index, String descriptor) {
        BlockBody body = blockBodies[index];
        if (body == null) {
            return createBlockBody(scriptObject, context, index, descriptor);
        }
        return body;
    }
View Full Code Here

     * @param index
     * @param descriptor
     * @return
     */
    public final BlockBody getBlockBody19(Object scriptObject, ThreadContext context, int index, String descriptor) {
        BlockBody body = blockBodies[index];
        if (body == null) {
            return createBlockBody19(scriptObject, context, index, descriptor);
        }
        return body;
    }
View Full Code Here

        }
        return value;
    }

    private BlockBody createBlockBody(Object scriptObject, ThreadContext context, int index, String descriptor) throws NumberFormatException {
        BlockBody body = RuntimeHelpers.createCompiledBlockBody(context, scriptObject, descriptor);
        return blockBodies[index] = body;
    }
View Full Code Here

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

    private BlockBody createBlockBody19(Object scriptObject, ThreadContext context, int index, String descriptor) throws NumberFormatException {
        BlockBody body = RuntimeHelpers.createCompiledBlockBody19(context, scriptObject, descriptor);
        return blockBodies[index] = body;
    }
View Full Code Here

        site.setTarget(dropArguments(constant(RubyEncoding.class, rubyEncoding), 0, ThreadContext.class));
        return rubyEncoding;
    }
   
    public static BlockBody initBlockBody(MutableCallSite site, Object scriptObject, ThreadContext context, StaticScope scope, String descriptor) {
        BlockBody body = RuntimeHelpers.createCompiledBlockBody(context, scriptObject, scope, descriptor);
        site.setTarget(dropArguments(constant(BlockBody.class, body), 0, Object.class, ThreadContext.class, StaticScope.class));
        return body;
    }
View Full Code Here

        site.setTarget(dropArguments(constant(BlockBody.class, body), 0, Object.class, ThreadContext.class, StaticScope.class));
        return body;
    }
   
    public static BlockBody initBlockBody19(MutableCallSite site, Object scriptObject, ThreadContext context, StaticScope scope, String descriptor) {
        BlockBody body = RuntimeHelpers.createCompiledBlockBody19(context, scriptObject, scope, descriptor);
        site.setTarget(dropArguments(constant(BlockBody.class, body), 0, Object.class, ThreadContext.class, StaticScope.class));
        return body;
    }
View Full Code Here

        return runtime.getNil();
    }

    @JRubyMethod(name = "parameters", compat = RUBY1_9)
    public IRubyObject parameters(ThreadContext context) {
        BlockBody body = this.getBlock().getBody();

        if (body instanceof MethodBlock) return ((MethodBlock) body).getMethod().parameters(context);

        return RuntimeHelpers.parameterListToParameters(context.runtime,
                body.getParameterList(), isLambda());
    }
View Full Code Here

TOP

Related Classes of org.jruby.runtime.BlockBody

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.