Package org.jruby.runtime

Examples of org.jruby.runtime.Block


    }

    public IRubyObject call(ThreadContext context, IRubyObject[] args, IRubyObject self, Block passedBlock) {
        assert args != null;
       
        Block newBlock = block.cloneBlock();
        int jumpTarget = newBlock.getBinding().getFrame().getJumpTarget();
       
        try {
            if (self != null) newBlock.getBinding().setSelf(self);
           
            return newBlock.call(context, args, passedBlock);
        } catch (JumpException.BreakJump bj) {
            return handleBreakJump(getRuntime(), newBlock, bj, jumpTarget);
        } catch (JumpException.ReturnJump rj) {
            return handleReturnJump(context, rj, jumpTarget);
        } catch (JumpException.RetryJump rj) {
View Full Code Here


            IRubyObject tmp = begin.checkStringType();
            if (!tmp.isNil()) {
                if (unit == 0) throw runtime.newArgumentError("step can't be 0");
                // rb_iterate((VALUE(*)_((VALUE)))str_step, (VALUE)args, step_i, (VALUE)iter);
                StepBlockCallBack callback = new StepBlockCallBack(block, RubyFixnum.one(runtime), step);
                Block blockCallback = CallBlock.newCallClosure(this, runtime.getRange(), Arity.singleArgument(), callback, context);
                ((RubyString)tmp).uptoCommon18(context, end, isExclusive, blockCallback);
            } else if (begin instanceof RubyNumeric) {
                if (equalInternal(context, step, RubyFixnum.zero(runtime))) throw runtime.newArgumentError("step can't be 0");
                numericStep(context, runtime, step, block);
            } else {
View Full Code Here

            numericStep19(context, runtime, step, block);
        } else {
            IRubyObject tmp = begin.checkStringType();
            if (!tmp.isNil()) {
                StepBlockCallBack callback = new StepBlockCallBack(block, RubyFixnum.one(runtime), step);
                Block blockCallback = CallBlock.newCallClosure(this, runtime.getRange(), Arity.singleArgument(), callback, context);
                ((RubyString)tmp).uptoCommon19(context, end, isExclusive, blockCallback);
            } else {
                if (!begin.respondsTo("succ")) throw runtime.newTypeError("can't iterate from " + begin.getMetaClass().getName());
                // range_each_func(range, step_i, b, e, args);
                rangeEach(context, new StepBlockCallBack(block, RubyFixnum.one(runtime), step));
View Full Code Here

        arg1 = args.get(0);
    }
   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        Block block = RuntimeHelpers.getBlock(context, self, iterNode);
       
        return callAdapter.callIter(context, self, self, arg1.interpret(runtime, context, self, aBlock), block);
    }
View Full Code Here

       
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        IRubyObject receiver = getReceiverNode().interpret(runtime, context, self, aBlock);
        IRubyObject arg = getArgsNode().interpret(runtime, context, self, aBlock);
        Block block = RuntimeHelpers.getBlock(runtime, context, self, iterNode, aBlock);

        if (arg instanceof RubyArray) {
            RubyArray nodes = (RubyArray) arg;

            switch (nodes.size()) {
View Full Code Here

    }

    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        IRubyObject arg = getArgsNode().interpret(runtime, context, self, aBlock);
        Block block = RuntimeHelpers.getBlock(runtime, context, self, iterNode, aBlock);
       
        if (arg instanceof RubyArray) {
            RubyArray nodes = (RubyArray) arg;
           
            switch (nodes.size()) {
View Full Code Here

        return iVisitor.visitPostExeNode(this);
    }
   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        Block block = SharedScopeBlock.newInterpretedSharedScopeClosure(context, this, context.getCurrentScope(), self);
       
        runtime.pushExitBlock(runtime.newProc(Block.Type.LAMBDA, block));
       
        return runtime.getNil();
    }
View Full Code Here

        return this;
    }
   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        Block block = ASTInterpreter.getBlock(runtime, context, self, aBlock, iterNode);
        if (block == null || !block.isGiven()) block = context.getFrameBlock();

        // dispatch as varargs, so incoming args are used to decide arity path
        return callSite.callVarargs(context, self, self, context.getCurrentScope().getArgValues(), block);
    }
View Full Code Here

    }

    public static long instanceEval(IRubyObject self, IRubyObject[] args) {
        Ruby runtime = self.getRuntime();
        ThreadContext ctxt = runtime.getCurrentContext();
        Block block = ctxt.getFrameBlock();
        IRubyObject retval = self.callMethod(ctxt, "instance_eval", args, block);
        return Handle.nativeHandle(retval);
    }
View Full Code Here

        return runtime.getCurrentContext().getFrameBlock().isGiven() ? 1 : 0;
    }

    /** rb_block_proc */
    public static RubyProc getBlockProc(Ruby runtime) {
        Block block = runtime.getCurrentContext().getFrameBlock();
        RubyProc p = RubyProc.newProc(runtime, block, block.type);
        return p;
    }
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.