public Block prepareBlock( ThreadContext context, IRubyObject self, StaticScope currScope, DynamicScope currDynScope, Object[] temp) { if (closure == null) return Block.NULL_BLOCK; return IRRuntimeHelpers.getBlockFromObject( context, closure.retrieve(context, self, currScope, currDynScope, temp)); }
@Override public Object interpret( ThreadContext context, StaticScope currScope, DynamicScope dynamicScope, IRubyObject self, Object[] temp) { IRubyObject object = (IRubyObject) receiver.retrieve(context, self, currScope, dynamicScope, temp); IRubyObject[] values = prepareArguments(context, self, arguments, currScope, dynamicScope, temp); Block preparedBlock = prepareBlock(context, self, currScope, dynamicScope, temp); return callSite.call(context, self, object, values, preparedBlock); }
protected IRubyObject[] prepareArgumentsComplex( ThreadContext context, IRubyObject self, Operand[] args, StaticScope currScope, DynamicScope currDynScope, Object[] temp) { // SSS: For regular calls, IR builder never introduces splats except as the first argument // But when zsuper is converted to SuperInstr with known args, splats can appear anywhere // in the list. So, this looping handles both these scenarios, although if we wanted to // optimize for CallInstr which has splats only in the first position, we could do that. List<IRubyObject> argList = new ArrayList<IRubyObject>(); for (Operand arg : args) { IRubyObject rArg = (IRubyObject) arg.retrieve(context, self, currScope, currDynScope, temp); if (arg instanceof Splat) { argList.addAll(Arrays.asList(((RubyArray) rArg).toJavaArray())); } else { argList.add(rArg); } } return argList.toArray(new IRubyObject[argList.size()]); }