public IRubyObject call(ThreadContext context) { return body.call(context, this); } public IRubyObject call(ThreadContext context, Block blockArg) {
public IRubyObject call(ThreadContext context, Block block, IRubyObject arg0) { IRubyObject[] args = new IRubyObject[] {arg0}; if (canCallDirect()) { return callDirect(context, block, args, Block.NULL_BLOCK); } else { return yield(context, block, prepareArgumentsForCall(context, args, block.type), null); } } public IRubyObject call(ThreadContext context, Block block, IRubyObject arg0, Block unusedBlock) {
public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0) { return body.yieldSpecific(context, this, arg0); } public IRubyObject call(ThreadContext context, IRubyObject arg0, IRubyObject arg1) {
public IRubyObject yieldSpecific(ThreadContext context, Block block, IRubyObject arg0) { if (canCallDirect()) { return yieldDirect(context, block, new IRubyObject[] { arg0 }, null); } else { return yield(context, block, arg0); } } public IRubyObject call(ThreadContext context, Block block, IRubyObject arg0, IRubyObject arg1) {
public final int getArgumentType() { return BlockBody.asArgumentType(BlockBody.getArgumentTypeWackyHack(this)); }
StaticScope oldScope = block.getBody().getStaticScope(); StaticScope newScope = oldScope.duplicate(); block.getBody().setStaticScope(newScope); } else { block.getBinding().setFile(block.getBody().getFile()); block.getBinding().setLine(block.getBody().getLine()); block.getBinding().getDummyScope(block.getBody().getStaticScope());
public IRubyObject call(ThreadContext context, Binding binding, Block.Type type) { IRubyObject[] args = IRubyObject.NULL_ARRAY; args = prepareArgumentsForCall(context, args, type); return yield(context, RubyArray.newArrayNoCopy(context.runtime, args), null, null, true, binding, type); } public IRubyObject call(ThreadContext context, Binding binding,
@JRubyMethod(name = "to_s", compat = RUBY1_9) public IRubyObject to_s19() { StringBuilder sb = new StringBuilder("#<Proc:0x" + Integer.toString(block.hashCode(), 16) + "@" + block.getBody().getFile() + ":" + (block.getBody().getLine() + 1)); if (isLambda()) sb.append(" (lambda)"); sb.append(">"); return RubyString.newString(getRuntime(), sb.toString()); }
public DynamicScope allocScope(DynamicScope parentScope) { // SSS: Important! Use getStaticScope() to use a copy of the static-scope stored in the block-body. // Do not use 'closure.getStaticScope()' -- that returns the original copy of the static scope. // This matters because blocks created for Thread bodies modify the static-scope field of the block-body // that records additional state about the block body. // // FIXME: Rather than modify static-scope, it seems we ought to set a field in block-body which is then // used to tell dynamic-scope that it is a dynamic scope for a thread body. Anyway, to be revisited later! DynamicScope newScope = DynamicScope.newDynamicScope(body.getStaticScope(), parentScope, body.getEvalType()); if (type == Block.Type.LAMBDA) newScope.setLambda(true); return newScope; }
private DynamicMethod createProcMethod(Ruby runtime, String name, Visibility visibility, Block block) { block = block.cloneBlockAndFrame(); block.getBinding().getFrame().setKlazz(this); block.getBinding().getFrame().setName(name); block.getBinding().setMethod(name); // a normal block passed to define_method changes to do arity checking; make it a lambda RubyProc proc = runtime.newProc(Block.Type.LAMBDA, block); // various instructions can tell this scope is not an ordinary block but a block representing // a method definition. block.getBody().getStaticScope().makeArgumentScope(); return new ProcMethod(this, proc, visibility, name); }
public String getFile() { return proc.getBlock().getBody().getFile(); }
public int getLine() { return proc.getBlock().getBody().getLine(); }
/** Used by cloning code */ private IRClosure(IRClosure c, IRScope lexicalParent) { super(c, lexicalParent); this.closureId = lexicalParent.getNextClosureId(); setName("_CLOSURE_CLONE_" + closureId); this.startLabel = getNewLabel(getName() + "_START"); this.endLabel = getNewLabel(getName() + "_END"); this.body = (c.body instanceof InterpretedIRBlockBody19) ? new InterpretedIRBlockBody19(this, c.body.arity(), c.body.getArgumentType()) : new InterpretedIRBlockBody(this, c.body.arity(), c.body.getArgumentType()); this.addedGEBForUncaughtBreaks = false; }
/** * What is the arity of this block? * * @return the arity */ public Arity arity() { return body.arity(); }
public static String buildBlockDescriptor( String closureMethod, int arity, String file, int line, boolean hasMultipleArgsHead, NodeType argsNodeId, ASTInspector inspector) { // We use : to delimit since mangleMethodName mangles it (i.e. it will // never appear in the resulting mangled string) String descriptor = JavaNameMangler.mangleMethodName(closureMethod) + ':' + arity + ':' + hasMultipleArgsHead + ':' + BlockBody.asArgumentType(argsNodeId) + ':' + JavaNameMangler.mangleMethodName(file) + ':' + line + ':' + !(inspector.hasClosure() || inspector.hasScopeAwareMethods()); return descriptor; }
StaticScope oldScope = block.getBody().getStaticScope(); StaticScope newScope = oldScope.duplicate(); block.getBody().setStaticScope(newScope); } else { block.getBinding().setFile(block.getBody().getFile()); block.getBinding().setLine(block.getBody().getLine()); block.getBinding().getDummyScope(block.getBody().getStaticScope());
public IRubyObject call(ThreadContext context, IRubyObject[] args, Binding binding, Block.Type type, Block block) { args = prepareArgumentsForCall(context, args, type); return yield(context, RubyArray.newArrayNoCopy(context.runtime, args), null, null, true, binding, type, block); }
@JRubyMethod(name = "to_s", compat = RUBY1_9) public IRubyObject to_s19() { StringBuilder sb = new StringBuilder("#<Proc:0x" + Integer.toString(block.hashCode(), 16) + "@" + block.getBody().getFile() + ":" + (block.getBody().getLine() + 1)); if (isLambda()) sb.append(" (lambda)"); sb.append(">"); return RubyString.newString(getRuntime(), sb.toString()); }
public IRubyObject yieldSpecific(ThreadContext context, Block block, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { if (canCallDirect()) { return yieldDirect(context, block, new IRubyObject[] { arg0, arg1, arg2 }, null); } else { return yield(context, block, new IRubyObject[] { arg0, arg1, arg2 }, null); } }
public final int getArgumentType() { return BlockBody.asArgumentType(BlockBody.getArgumentTypeWackyHack(this)); }