@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { return Helpers.aryToAry(node.interpret(runtime, context, self, aBlock)); } }
static IRubyObject[] restructureBlockArgs(ThreadContext context, IRubyObject value, Signature signature, Block.Type type, boolean needsSplat) { if (!type.checkArity && signature == Signature.NO_ARGUMENTS) return IRubyObject.NULL_ARRAY; if (value == null) return IRubyObject.NULL_ARRAY; if (needsSplat) { IRubyObject ary = Helpers.aryToAry(context, value); if (ary instanceof RubyArray) return ((RubyArray) ary).toJavaArrayMaybeUnsafe(); } return new IRubyObject[] { value }; }
static IRubyObject[] restructureBlockArgs(ThreadContext context, IRubyObject value, Signature signature, Block.Type type, boolean needsSplat) { if (!type.checkArity && signature == Signature.NO_ARGUMENTS) return IRubyObject.NULL_ARRAY; if (value == null) return IRubyObject.NULL_ARRAY; if (needsSplat) { IRubyObject ary = Helpers.aryToAry(context, value); if (ary instanceof RubyArray) return ((RubyArray) ary).toJavaArrayMaybeUnsafe(); } return new IRubyObject[] { value }; }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { return Helpers.aryToAry(node.interpret(runtime, context, self, aBlock)); } }
public static IRubyObject[] restructureBlockArgs19(IRubyObject value, Arity arity, Block.Type type, boolean needsSplat, boolean alreadyArray) { if (!type.checkArity && arity == Arity.NO_ARGUMENTS) return IRubyObject.NULL_ARRAY; if (value != null && !(value instanceof RubyArray) && needsSplat) value = Helpers.aryToAry(value); IRubyObject[] parameters; if (value == null) { parameters = IRubyObject.NULL_ARRAY; } else if (value instanceof RubyArray && (alreadyArray || needsSplat)) { parameters = ((RubyArray) value).toJavaArray(); } else { parameters = new IRubyObject[] { value }; } return parameters; }
public static IRubyObject[] restructureBlockArgs19(IRubyObject value, Arity arity, Block.Type type, boolean needsSplat, boolean alreadyArray) { if (!type.checkArity && arity == Arity.NO_ARGUMENTS) return IRubyObject.NULL_ARRAY; if (value != null && !(value instanceof RubyArray) && needsSplat) value = Helpers.aryToAry(value); IRubyObject[] parameters; if (value == null) { parameters = IRubyObject.NULL_ARRAY; } else if (value instanceof RubyArray && (alreadyArray || needsSplat)) { parameters = ((RubyArray) value).toJavaArray(); } else { parameters = new IRubyObject[] { value }; } return parameters; }
@Deprecated // not used public static IRubyObject aryToAry(IRubyObject value) { return aryToAry(value.getRuntime().getCurrentContext(), value); }
@Deprecated // not used public static IRubyObject aryToAry(IRubyObject value) { return aryToAry(value.getRuntime().getCurrentContext(), value); }
public static IRubyObject arraySlice1(IRubyObject arrayish) { arrayish = aryToAry(arrayish); RubyArray arrayish2 = ensureMultipleAssignableRubyArray(arrayish, arrayish.getRuntime(), true); return arrayEntryOrNilZero(arrayish2); }
public static IRubyObject arraySlice1(IRubyObject arrayish) { arrayish = aryToAry(arrayish); RubyArray arrayish2 = ensureMultipleAssignableRubyArray(arrayish, arrayish.getRuntime(), true); return arrayEntryOrNilZero(arrayish2); }
private IRubyObject[] toAry(ThreadContext context, IRubyObject value) { final IRubyObject ary = Helpers.aryToAry(context, value); if (ary == context.nil) return new IRubyObject[] { value }; if (ary instanceof RubyArray) return ((RubyArray) ary).toJavaArray(); throw context.runtime.newTypeError(value.getType().getName() + "#to_ary should return Array"); }
private IRubyObject[] toAry(ThreadContext context, IRubyObject value) { final IRubyObject ary = Helpers.aryToAry(context, value); if (ary == context.nil) return new IRubyObject[] { value }; if (ary instanceof RubyArray) return ((RubyArray) ary).toJavaArray(); throw context.runtime.newTypeError(value.getType().getName() + "#to_ary should return Array"); }
public static IRubyObject[] arraySlice1N(IRubyObject arrayish) { arrayish = aryToAry(arrayish); RubyArray arrayish2 = ensureMultipleAssignableRubyArray(arrayish, arrayish.getRuntime(), true); return new IRubyObject[] {arrayEntryOrNilZero(arrayish2), subarrayOrEmpty(arrayish2, arrayish2.getRuntime(), 1)}; }
public static IRubyObject[] arraySlice1N(IRubyObject arrayish) { arrayish = aryToAry(arrayish); RubyArray arrayish2 = ensureMultipleAssignableRubyArray(arrayish, arrayish.getRuntime(), true); return new IRubyObject[] {arrayEntryOrNilZero(arrayish2), subarrayOrEmpty(arrayish2, arrayish2.getRuntime(), 1)}; }
public static IRubyObject irToAry(ThreadContext context, IRubyObject receiver, boolean dontToAryArrays) { if (dontToAryArrays && receiver instanceof RubyArray) { return receiver; } else { IRubyObject ary = Helpers.aryToAry(receiver); if (ary instanceof RubyArray) { return ary; } else { String receiverType = receiver.getType().getName(); throw context.runtime.newTypeError("can't convert " + receiverType + " to Array (" + receiverType + "#to_ary gives " + ary.getType().getName() + ")"); } } }
public static IRubyObject irToAry(ThreadContext context, IRubyObject receiver, boolean dontToAryArrays) { if (dontToAryArrays && receiver instanceof RubyArray) { return receiver; } else { IRubyObject ary = Helpers.aryToAry(receiver); if (ary instanceof RubyArray) { return ary; } else { String receiverType = receiver.getType().getName(); throw context.runtime.newTypeError("can't convert " + receiverType + " to Array (" + receiverType + "#to_ary gives " + ary.getType().getName() + ")"); } } }
protected IRubyObject[] prepareArgumentsForYield(ThreadContext context, IRubyObject[] args, Block.Type type) { // SSS FIXME: Hmm .. yield can yield to blocks other than NORMAL block type as well. int blockArity = arity().getValue(); if (args.length == 1) { IRubyObject soleArg = args[0]; if (soleArg instanceof RubyArray) { if (argumentType == MULTIPLE_ASSIGNMENT) args = ((RubyArray) soleArg).toJavaArray(); } else if (blockArity > 1) { IRubyObject toAryArg = Helpers.aryToAry(soleArg); if (toAryArg instanceof RubyArray) args = ((RubyArray)toAryArg).toJavaArray(); else { throw context.runtime.newTypeError(soleArg.getType().getName() + "#to_ary should return Array"); } } } else if (argumentType == ARRAY) { args = convertToRubyArray(context, args); } return args; }
protected IRubyObject[] prepareArgumentsForYield(ThreadContext context, IRubyObject[] args, Block.Type type) { // SSS FIXME: Hmm .. yield can yield to blocks other than NORMAL block type as well. int blockArity = arity().getValue(); if (args.length == 1) { IRubyObject soleArg = args[0]; if (soleArg instanceof RubyArray) { if (argumentType == MULTIPLE_ASSIGNMENT) args = ((RubyArray) soleArg).toJavaArray(); } else if (blockArity > 1) { IRubyObject toAryArg = Helpers.aryToAry(soleArg); if (toAryArg instanceof RubyArray) args = ((RubyArray)toAryArg).toJavaArray(); else { throw context.runtime.newTypeError(soleArg.getType().getName() + "#to_ary should return Array"); } } } else if (argumentType == ARRAY) { args = convertToRubyArray(context, args); } return args; }
@Override public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, Binding binding, Block.Type type) { IRubyObject[] args; if (type == Block.Type.LAMBDA) { args = arg0 instanceof RubyArray ? ((RubyArray)arg0).toJavaArray() : new IRubyObject[] { arg0 }; arity().checkArity(context.runtime, args); } else if (arg0 instanceof RubyArray) { args = convertValueIntoArgArray(context, arg0, true, true); } else if (arity().getValue() <= 1) { args = new IRubyObject[] { arg0 }; } else { IRubyObject value = Helpers.aryToAry(arg0); if (!(value instanceof RubyArray)) { throw context.runtime.newTypeError(arg0.getType().getName() + "#to_ary should return Array"); } args = ((RubyArray)value).toJavaArray(); } return commonYieldPath(context, args, null, null, binding, type, Block.NULL_BLOCK); }
@Override public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, Binding binding, Block.Type type) { IRubyObject[] args; if (type == Block.Type.LAMBDA) { args = arg0 instanceof RubyArray ? ((RubyArray)arg0).toJavaArray() : new IRubyObject[] { arg0 }; arity().checkArity(context.runtime, args); } else if (arg0 instanceof RubyArray) { args = convertValueIntoArgArray(context, arg0, true, true); } else if (arity().getValue() <= 1) { args = new IRubyObject[] { arg0 }; } else { IRubyObject value = Helpers.aryToAry(arg0); if (!(value instanceof RubyArray)) { throw context.runtime.newTypeError(arg0.getType().getName() + "#to_ary should return Array"); } args = ((RubyArray)value).toJavaArray(); } return commonYieldPath(context, args, null, null, binding, type, Block.NULL_BLOCK); }