public Signature getSignature() { return body.getSignature(); }
public Signature getSignature() { return body.getSignature(); }
/** * For Type.LAMBDA, ensures that the args have the correct arity. * * For others, transforms the given arguments appropriately for the given arity (i.e. trimming to one arg for fixed * arity of one, etc.) */ public static IRubyObject[] prepareArgs(ThreadContext context, Block.Type type, BlockBody blockBody, IRubyObject[] args) { if (type == Block.Type.LAMBDA) { blockBody.getSignature().checkArity(context.runtime, args); return args; } // FIXME: weirdly nearly identical logic exists in prepareBlockArgsInternal but only for lambdas. // for procs and blocks, single array passed to multi-arg must be spread int arityValue = blockBody.getSignature().arityValue(); if (args.length == 1 && (arityValue < -1 || arityValue > 1)) args = IRRuntimeHelpers.toAry(context, args); return args; }
/** * For Type.LAMBDA, ensures that the args have the correct arity. * * For others, transforms the given arguments appropriately for the given arity (i.e. trimming to one arg for fixed * arity of one, etc.) */ public static IRubyObject[] prepareArgs(ThreadContext context, Block.Type type, BlockBody blockBody, IRubyObject[] args) { if (type == Block.Type.LAMBDA) { blockBody.getSignature().checkArity(context.runtime, args); return args; } // FIXME: weirdly nearly identical logic exists in prepareBlockArgsInternal but only for lambdas. // for procs and blocks, single array passed to multi-arg must be spread int arityValue = blockBody.getSignature().arityValue(); if (args.length == 1 && (arityValue < -1 || arityValue > 1)) args = IRRuntimeHelpers.toAry(context, args); return args; }
private static IRubyObject[] prepareProcArgs(ThreadContext context, Block b, IRubyObject[] args) { if (args.length != 1) return args; // Potentially expand single value if it is an array depending on what we are calling. return IRRuntimeHelpers.convertValueIntoArgArray(context, args[0], b.getBody().getSignature(), b.type == Block.Type.NORMAL && args[0] instanceof RubyArray); }
private static IRubyObject[] prepareProcArgs(ThreadContext context, Block b, IRubyObject[] args) { if (args.length != 1) return args; // Potentially expand single value if it is an array depending on what we are calling. return IRRuntimeHelpers.convertValueIntoArgArray(context, args[0], b.getBody().getSignature(), b.type == Block.Type.NORMAL && args[0] instanceof RubyArray); }
@Override public Signature getSignature() { return proc.getBlock().getBody().getSignature(); }
@Override public Signature getSignature() { return proc.getBlock().getBody().getSignature(); }
public IRubyObject[] prepareArgumentsForCall(ThreadContext context, IRubyObject[] args, Block.Type type) { if (type == Block.Type.LAMBDA) { signature.checkArity(context.runtime, args); } else { // SSS FIXME: How is it even possible to "call" a NORMAL block? // I thought only procs & lambdas can be called, and blocks are yielded to. if (args.length == 1) { // Convert value to arg-array, unwrapping where necessary args = IRRuntimeHelpers.convertValueIntoArgArray(context, args[0], signature, type == Block.Type.NORMAL && args[0] instanceof RubyArray); } else if (getSignature().arityValue() == 1 && !getSignature().restKwargs()) { // discard excess arguments args = args.length == 0 ? context.runtime.getSingleNilArray() : new IRubyObject[] { args[0] }; } } return args; }
public IRubyObject[] prepareArgumentsForCall(ThreadContext context, IRubyObject[] args, Block.Type type) { if (type == Block.Type.LAMBDA) { signature.checkArity(context.runtime, args); } else { // SSS FIXME: How is it even possible to "call" a NORMAL block? // I thought only procs & lambdas can be called, and blocks are yielded to. if (args.length == 1) { // Convert value to arg-array, unwrapping where necessary args = IRRuntimeHelpers.convertValueIntoArgArray(context, args[0], signature, type == Block.Type.NORMAL && args[0] instanceof RubyArray); } else if (getSignature().arityValue() == 1 && !getSignature().restKwargs()) { // discard excess arguments args = args.length == 0 ? context.runtime.getSingleNilArray() : new IRubyObject[] { args[0] }; } } return args; }
@Interp @JIT public static IRubyObject[] prepareBlockArgs(ThreadContext context, Block block, IRubyObject[] args, boolean usesKwArgs) { args = prepareBlockArgsInternal(context, block, args); if (usesKwArgs) { args = frobnicateKwargsArgument(context, args, block.getBody().getSignature().required()); } return args; }
@Interp @JIT public static IRubyObject[] prepareBlockArgs(ThreadContext context, Block block, IRubyObject[] args, boolean usesKwArgs) { args = prepareBlockArgsInternal(context, block, args); if (usesKwArgs) { args = frobnicateKwargsArgument(context, args, block.getBody().getSignature().required()); } return args; }
@Interp @JIT public static IRubyObject[] prepareFixedBlockArgs(ThreadContext context, Block block, IRubyObject[] args) { if (args == null) args = IRubyObject.NULL_ARRAY; switch (block.type) { case LAMBDA: block.getBody().getSignature().checkArity(context.runtime, args); return args; case PROC: return prepareProcArgs(context, block, args); default: // If we need more than 1 reqd arg, convert a single value to an array if possible. // If there are insufficient args, ReceivePreReqdInstr will return nil return toAry(context, args); } }
@Interp @JIT public static IRubyObject[] prepareFixedBlockArgs(ThreadContext context, Block block, IRubyObject[] args) { if (args == null) args = IRubyObject.NULL_ARRAY; switch (block.type) { case LAMBDA: block.getBody().getSignature().checkArity(context.runtime, args); return args; case PROC: return prepareProcArgs(context, block, args); default: // If we need more than 1 reqd arg, convert a single value to an array if possible. // If there are insufficient args, ReceivePreReqdInstr will return nil return toAry(context, args); } }
@Interp @JIT public static IRubyObject[] prepareSingleBlockArgs(ThreadContext context, Block block, IRubyObject[] args) { if (args == null) args = IRubyObject.NULL_ARRAY; switch (block.type) { case LAMBDA: block.getBody().getSignature().checkArity(context.runtime, args); return args; case PROC: if (args.length == 0) { args = context.runtime.getSingleNilArray(); } else if (args.length == 1) { args = prepareProcArgs(context, block, args); } else { args = new IRubyObject[] { args[0] }; } } // If there are insufficient args, ReceivePreReqdInstr will return nil return args; }
@Interp @JIT public static IRubyObject[] prepareSingleBlockArgs(ThreadContext context, Block block, IRubyObject[] args) { if (args == null) args = IRubyObject.NULL_ARRAY; switch (block.type) { case LAMBDA: block.getBody().getSignature().checkArity(context.runtime, args); return args; case PROC: if (args.length == 0) { args = context.runtime.getSingleNilArray(); } else if (args.length == 1) { args = prepareProcArgs(context, block, args); } else { args = new IRubyObject[] { args[0] }; } } // If there are insufficient args, ReceivePreReqdInstr will return nil return args; }
org.jruby.runtime.Signature sig = block.getBody().getSignature(); if (sig.arityValue() != -1 && sig.required() != 1) { args = toAry(context, args); org.jruby.runtime.Signature sig = block.getBody().getSignature(); int arityValue = sig.arityValue(); if (!sig.hasKwargs() && arityValue >= -1 && arityValue <= 1) {
org.jruby.runtime.Signature sig = block.getBody().getSignature(); if (sig.arityValue() != -1 && sig.required() != 1) { args = toAry(context, args); org.jruby.runtime.Signature sig = block.getBody().getSignature(); int arityValue = sig.arityValue(); if (!sig.hasKwargs() && arityValue >= -1 && arityValue <= 1) {
ii.setupYieldArgsAndYieldResult(yield, beforeInlineBB, cl.getBlockBody().getSignature().arityValue());
ii.setupYieldArgsAndYieldResult(yield, beforeInlineBB, cl.getBlockBody().getSignature().arityValue());