Package org.jruby.runtime

Examples of org.jruby.runtime.Block


        if (beBlocks == null) return;

        for (IRClosure b: beBlocks) {
            // SSS FIXME: Should I piggyback on WrappedIRClosure.retrieve or just copy that code here?
            b.prepareForInterpretation(false);
            Block blk = (Block)(new WrappedIRClosure(b)).retrieve(context, self, context.getCurrentScope(), temp);
            blk.yield(context, null);
        }
    }
View Full Code Here


                    return runtime.getNil();
                }
            };
        }
        final RubyModule signalModule = runtime.getModule("Signal");
        Block block = CallBlock.newCallClosure(signalModule, signalModule, Arity.noArguments(),
                callback, runtime.getCurrentContext());
        return RubyProc.newProc(runtime, block, block.type);
    }
View Full Code Here

    public static IRubyObject runBeginBlock(ThreadContext context, IRubyObject self, String scopeString, CompiledBlockCallback callback) {
        StaticScope staticScope = decodeScope(context, context.getCurrentStaticScope(), scopeString);
       
        context.preScopedBody(DynamicScope.newDynamicScope(staticScope, context.getCurrentScope()));
       
        Block block = CompiledBlock.newCompiledClosure(context, self, Arity.createArity(0), staticScope, callback, false, BlockBody.ZERO_ARGS);
       
        try {
            block.yield(context, null);
        } finally {
            context.postScopedBody();
        }

        return context.runtime.getNil();
View Full Code Here

    }

    @Override
    public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
        IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currScope, currDynScope, temp);
        Block block = prepareBlock(context, self, currScope, currDynScope, temp);
        RubyModule definingModule = ((RubyModule) getDefiningModule().retrieve(context, self, currScope, currDynScope, temp)).getMethodLocation();
        String methodName = methAddr.getName();
        return IRRuntimeHelpers.instanceSuper(context, self, methodName, definingModule, args, block);
    }
View Full Code Here

            } else {
                retVals[0] = runtime.newString("DEFAULT");
            }
        } else {
            final RubyModule signalModule = runtime.getModule("Signal");
            Block block = CallBlock.newCallClosure(signalModule, signalModule, Arity.noArguments(),
                    callback, runtime.getCurrentContext());
            retVals[0] = RubyProc.newProc(runtime, block, block.type);
        }

        return runtime.newArray(retVals);
View Full Code Here

            public int getLine() {
                return RubyMethod.this.getLine();
            }
        };
        BlockBody body = CompiledBlockLight19.newCompiledBlockLight(method.getArity(), runtime.getStaticScopeFactory().getDummyScope(), callback, false, 0, JRubyLibrary.MethodExtensions.methodParameters(runtime, method));
        Block b = new Block(body, context.currentBinding(receiver, Visibility.PUBLIC));
       
        return RubyProc.newProc(runtime, b, Block.Type.LAMBDA);
    }
View Full Code Here

                return -1;
            }
        };

        return RubyProc.newProc(context.runtime,
                                new Block(body, context.currentBinding()),
                                Block.Type.PROC);
    }
View Full Code Here

        ((WrappedIRClosure) getLambdaBody()).getClosure().getStaticScope().determineModule();

        // CON: This must not be happening, because nil would never cast to Block
//        IRClosure body = getLambdaBody().getClosure();
//        Block block = (Block) (body == null ? context.runtime.getIRManager().getNil() : getLambdaBody()).retrieve(context, self, currScope, currDynScope, temp);
        Block block = (Block)getLambdaBody().retrieve(context, self, currScope, currDynScope, temp);
        // ENEBO: Now can live nil be passed as block reference?
        // SSS FIXME: Should we do the same %self retrieval as in the case of WrappedIRClosure? Or are lambdas special??
        return RubyProc.newProc(context.runtime,
                block,
                Block.Type.LAMBDA,
View Full Code Here

    }

    @Override
    public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
        IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currScope, currDynScope, temp);
        Block block = prepareBlock(context, self, currScope, currDynScope, temp);
        if (block == null || !block.isGiven()) block = context.getFrameBlock();
        return IRRuntimeHelpers.unresolvedSuper(context, self, args, block);
    }
View Full Code Here

    }

    @Override
    public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
        IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currScope, currDynScope, temp);
        Block block = prepareBlock(context, self, currScope, currDynScope, temp);
        return IRRuntimeHelpers.unresolvedSuper(context, self, args, block);
    }
View Full Code Here

TOP

Related Classes of org.jruby.runtime.Block

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.