@Override public Object retrieve(ThreadContext context, IRubyObject self, StaticScope currScope, DynamicScope currDynScope, Object[] temp) { switch (elts.length) { case 0: return context.runtime.newEmptyArray(); case 1: return context.runtime.newArray((IRubyObject) elts[0].retrieve(context, self, currScope, currDynScope, temp)); case 2: return context.runtime.newArray((IRubyObject) elts[0].retrieve(context, self, currScope, currDynScope, temp), (IRubyObject) elts[1].retrieve(context, self, currScope, currDynScope, temp)); default: return RubyArray.newArrayMayCopy(context.runtime, retrieveArrayElts(context, self, currScope, currDynScope, temp)); } }
@Override public Object retrieve(ThreadContext context, IRubyObject self, StaticScope currScope, DynamicScope currDynScope, Object[] temp) { switch (elts.length) { case 0: return context.runtime.newEmptyArray(); case 1: return context.runtime.newArray((IRubyObject) elts[0].retrieve(context, self, currScope, currDynScope, temp)); case 2: return context.runtime.newArray((IRubyObject) elts[0].retrieve(context, self, currScope, currDynScope, temp), (IRubyObject) elts[1].retrieve(context, self, currScope, currDynScope, temp)); default: return RubyArray.newArrayMayCopy(context.runtime, retrieveArrayElts(context, self, currScope, currDynScope, temp)); } }
@Interp @Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { Block blk = (Block)getBlockArg().retrieve(context, self, currScope, currDynScope, temp); if (getYieldArg() == UndefinedValue.UNDEFINED) { return IRRuntimeHelpers.yieldSpecific(context, blk); } else { Operand yieldOp = getYieldArg(); if (unwrapArray && yieldOp instanceof Array && ((Array)yieldOp).size() > 1) { // Special case this path! // Don't build a RubyArray. return blk.yieldValues(context, ((Array)yieldOp).retrieveArrayElts(context, self, currScope, currDynScope, temp)); } else { IRubyObject yieldVal = (IRubyObject) yieldOp.retrieve(context, self, currScope, currDynScope, temp); return IRRuntimeHelpers.yield(context, blk, yieldVal, unwrapArray); } } }
@Interp @Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { Block blk = (Block)getBlockArg().retrieve(context, self, currScope, currDynScope, temp); if (getYieldArg() == UndefinedValue.UNDEFINED) { return IRRuntimeHelpers.yieldSpecific(context, blk); } else { Operand yieldOp = getYieldArg(); if (unwrapArray && yieldOp instanceof Array && ((Array)yieldOp).size() > 1) { // Special case this path! // Don't build a RubyArray. return blk.yieldValues(context, ((Array)yieldOp).retrieveArrayElts(context, self, currScope, currDynScope, temp)); } else { IRubyObject yieldVal = (IRubyObject) yieldOp.retrieve(context, self, currScope, currDynScope, temp); return IRRuntimeHelpers.yield(context, blk, yieldVal, unwrapArray); } } }