Package org.jruby.runtime

Examples of org.jruby.runtime.Block


            throw context.getRuntime().newArgumentError("wrong number of arguments (" + args.length + " for 2)");
        }
    }
   
    private DynamicMethod createProcMethod(String name, Visibility visibility, RubyProc proc) {
        Block block = proc.getBlock();
        block.getBinding().getFrame().setKlazz(this);
        block.getBinding().getFrame().setName(name);
        block.getBinding().setMethod(name);
       
        StaticScope scope = block.getBody().getStaticScope();

        // for zsupers in define_method (blech!) we tell the proc scope to act as the "argument" scope
        scope.makeArgumentScope();

        Arity arity = block.arity();
        // just using required is broken...but no more broken than before zsuper refactoring
        scope.setRequiredArgs(arity.required());

        if(!arity.isFixed()) {
            scope.setRestArg(arity.required());
View Full Code Here


                return RuntimeHelpers.invoke(context, receiver, symbol, array.toJavaArray());
            }

            @Override
            public Block cloneBlock(Binding binding) {
                return new Block(this, binding);
            }

            @Override
            public Arity arity() {
                return Arity.OPTIONAL;
            }

            public String getFile() {
                return symbol;
            }

            public int getLine() {
                return -1;
            }
        };
        Block block = new Block(body, context.currentBinding());
        return RubyProc.newProc(context.getRuntime(),
                                block,
                                Block.Type.PROC);
    }
View Full Code Here

            @Override
            public IRubyObject callback(IRubyObject value, IRubyObject method, IRubyObject self, Block block) {
                return bmcall(value, method, self, block);
            }
        };
        Block block = MethodBlock.createMethodBlock(context, runtime.getTopSelf(), context.getCurrentScope(), mb);
       
        while (true) {
            try {
                // FIXME: We should not be regenerating this over and over
                return mproc(context, block);
View Full Code Here

    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

                    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.NORMAL);
    }
View Full Code Here

        StaticScope staticScope = decodeBlockScope(context, scopeString);
        staticScope.determineModule();
       
        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.getRuntime().getNil();
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[] args = ((ArrayNode) getArgsNode()).interpretPrimitive(runtime, context, self, aBlock);
        Block block = RuntimeHelpers.getBlock(runtime, context, self, iterNode, aBlock);
       
        return callAdapter.call(context, self, receiver, args, block);
    }
View Full Code Here

        // Each root node has a top-level scope that we need to push
        context.preScopedBody(scope);

        // FIXME: I use a for block to implement END node because we need a proc which captures
        // its enclosing scope.   ForBlock now represents these node and should be renamed.
        Block block = InterpretedBlock.newInterpretedClosure(context, this, self);

        try {
            block.yield(context, null);
        } finally {
            context.postScopedBody();
        }

        return runtime.getNil();
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(context, self, iterNode);
       
        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[] args = ((ArrayNode) getArgsNode()).interpretPrimitive(runtime, context, self, aBlock);
        Block block = RuntimeHelpers.getBlock(context, self, iterNode);

        return callAdapter.callIter(context, self, 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.