@Override public Instr cloneForInlining(InlinerInfo ii) { return new OptArgMultipleAsgnInstr(ii.getRenamedVariable(result), array.cloneForInlining(ii), index, minArgsLength); }
@Override public void OptArgMultipleAsgnInstr(OptArgMultipleAsgnInstr optargmultipleasgninstr) { visit(optargmultipleasgninstr.getArray()); jvmAdapter().checkcast(p(RubyArray.class)); jvmAdapter().ldc(optargmultipleasgninstr.getMinArgsLength()); jvmAdapter().ldc(optargmultipleasgninstr.getIndex()); jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "extractOptionalArgument", sig(IRubyObject.class, RubyArray.class, int.class, int.class)); jvmStoreLocal(optargmultipleasgninstr.getResult()); }
@Override public Instr clone(CloneInfo ii) { return new OptArgMultipleAsgnInstr(ii.getRenamedVariable(result), getArray().cloneForInlining(ii), index, minArgsLength); }
@Override public void encode(IRWriterEncoder e) { super.encode(e); e.encode(getArray()); e.encode(getIndex()); e.encode(getMinArgsLength()); }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { // ENEBO: Can I assume since IR figured this is an internal array it will be RubyArray like this? RubyArray rubyArray = (RubyArray) getArray().retrieve(context, self, currScope, currDynScope, temp); return IRRuntimeHelpers.extractOptionalArgument(rubyArray, minArgsLength, index); }
case LOAD_IMPLICIT_CLOSURE: return LoadImplicitClosureInstr.decode(this); case LINE_NUM: return LineNumberInstr.decode(this); case MASGN_OPT: return OptArgMultipleAsgnInstr.decode(this); case MASGN_REQD: return ReqdArgMultipleAsgnInstr.decode(this); case MASGN_REST: return RestArgMultipleAsgnInstr.decode(this);
@Override public void encode(IRWriterEncoder e) { super.encode(e); e.encode(getArray()); e.encode(getIndex()); e.encode(getMinArgsLength()); }
@Override public Instr clone(CloneInfo ii) { return new OptArgMultipleAsgnInstr(ii.getRenamedVariable(result), getArray().cloneForInlining(ii), index, minArgsLength); }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { // ENEBO: Can I assume since IR figured this is an internal array it will be RubyArray like this? RubyArray rubyArray = (RubyArray) getArray().retrieve(context, self, currScope, currDynScope, temp); return IRRuntimeHelpers.extractOptionalArgument(rubyArray, minArgsLength, index); }
case LOAD_IMPLICIT_CLOSURE: return LoadImplicitClosureInstr.decode(this); case LINE_NUM: return LineNumberInstr.decode(this); case MASGN_OPT: return OptArgMultipleAsgnInstr.decode(this); case MASGN_REQD: return ReqdArgMultipleAsgnInstr.decode(this); case MASGN_REST: return RestArgMultipleAsgnInstr.decode(this);
@Override public void OptArgMultipleAsgnInstr(OptArgMultipleAsgnInstr optargmultipleasgninstr) { visit(optargmultipleasgninstr.getArray()); jvmAdapter().checkcast(p(RubyArray.class)); jvmAdapter().ldc(optargmultipleasgninstr.getMinArgsLength()); jvmAdapter().ldc(optargmultipleasgninstr.getIndex()); jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "extractOptionalArgument", sig(IRubyObject.class, RubyArray.class, int.class, int.class)); jvmStoreLocal(optargmultipleasgninstr.getResult()); }
@Override public Instr cloneForInlining(InlinerInfo ii) { return new OptArgMultipleAsgnInstr(ii.getRenamedVariable(result), array.cloneForInlining(ii), index, minArgsLength); }
public static OptArgMultipleAsgnInstr decode(IRReaderDecoder d) { return new OptArgMultipleAsgnInstr(d.decodeVariable(), d.decodeOperand(), d.decodeInt(), d.decodeInt()); }
public static OptArgMultipleAsgnInstr decode(IRReaderDecoder d) { return new OptArgMultipleAsgnInstr(d.decodeVariable(), d.decodeOperand(), d.decodeInt(), d.decodeInt()); }
@Override public Instr cloneForInlining(InlinerInfo ii) { // SSS FIXME: Need to add kwArgLoss information in InlinerInfo // Added this copy for code clarity // argIndex is relative to start of opt args and not the start of arg array int optArgIndex = this.argIndex; int minReqdArgs = optArgIndex + numUsedArgs; if (ii.canMapArgsStatically()) { int n = ii.getArgsCount(); return new CopyInstr(ii.getRenamedVariable(result), minReqdArgs < n ? ii.getArg(argOffset + optArgIndex) : UndefinedValue.UNDEFINED); } else { return new OptArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), argOffset + optArgIndex, minReqdArgs); } }
@Override public Instr cloneForInlining(InlinerInfo ii) { // SSS FIXME: Need to add kwArgLoss information in InlinerInfo // Added this copy for code clarity // argIndex is relative to start of opt args and not the start of arg array int optArgIndex = this.argIndex; int minReqdArgs = optArgIndex + numUsedArgs; if (ii.canMapArgsStatically()) { int n = ii.getArgsCount(); return new CopyInstr(ii.getRenamedVariable(result), minReqdArgs < n ? ii.getArg(argOffset + optArgIndex) : UndefinedValue.UNDEFINED); } else { return new OptArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), argOffset + optArgIndex, minReqdArgs); } }
@Override public Instr clone(CloneInfo info) { int optArgIndex = this.argIndex; if (info instanceof SimpleCloneInfo) return new ReceiveOptArgInstr(info.getRenamedVariable(result), requiredArgs, preArgs, optArgIndex); InlineCloneInfo ii = (InlineCloneInfo) info; // SSS FIXME: Need to add kwArgLoss information in InlinerInfo // Added this copy for code clarity // argIndex is relative to start of opt args and not the start of arg array int minReqdArgs = optArgIndex + requiredArgs; if (ii.canMapArgsStatically()) { int n = ii.getArgsCount(); return new CopyInstr(ii.getRenamedVariable(result), minReqdArgs < n ? ii.getArg(preArgs + optArgIndex) : UndefinedValue.UNDEFINED); } return new OptArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), preArgs + optArgIndex, minReqdArgs); }
@Override public Instr clone(CloneInfo info) { int optArgIndex = this.argIndex; if (info instanceof SimpleCloneInfo) return new ReceiveOptArgInstr(info.getRenamedVariable(result), requiredArgs, preArgs, optArgIndex); InlineCloneInfo ii = (InlineCloneInfo) info; // SSS FIXME: Need to add kwArgLoss information in InlinerInfo // Added this copy for code clarity // argIndex is relative to start of opt args and not the start of arg array int minReqdArgs = optArgIndex + requiredArgs; if (ii.canMapArgsStatically()) { int n = ii.getArgsCount(); return new CopyInstr(ii.getRenamedVariable(result), minReqdArgs < n ? ii.getArg(preArgs + optArgIndex) : UndefinedValue.UNDEFINED); } return new OptArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), preArgs + optArgIndex, minReqdArgs); }