public Operand getArg(int index) { // yield 1 -> { |a| } case if (canMapArgsStatically && isClosure && !(yieldArg instanceof Array)) return yieldArg; return index < getArgsCount() ? (isClosure ? ((Array)yieldArg).get(index) : callArgs[index]) : null; }
public Operand getArg(int index) { // yield 1 -> { |a| } case if (canMapArgsStatically && isClosure && !(yieldArg instanceof Array)) return yieldArg; return index < getArgsCount() ? (isClosure ? ((Array)yieldArg).get(index) : callArgs[index]) : null; }
@Override public Instr clone(CloneInfo info) { if (info instanceof SimpleCloneInfo) return new CheckArityInstr(required, opt, rest, receivesKeywords, restKey); InlineCloneInfo ii = (InlineCloneInfo) info; if (ii.canMapArgsStatically()) { // we can error on bad arity or remove check_arity int numArgs = ii.getArgsCount(); if (numArgs < required || (!rest && numArgs > (required + opt))) { return new RaiseArgumentErrorInstr(required, opt, rest, numArgs); } return null; } return new CheckArgsArrayArityInstr(ii.getArgs(), required, opt, rest); }
@Override public Instr clone(CloneInfo info) { if (info instanceof SimpleCloneInfo) return new CheckArityInstr(required, opt, rest, receivesKeywords, restKey); InlineCloneInfo ii = (InlineCloneInfo) info; if (ii.canMapArgsStatically()) { // we can error on bad arity or remove check_arity int numArgs = ii.getArgsCount(); if (numArgs < required || (!rest && numArgs > (required + opt))) { return new RaiseArgumentErrorInstr(required, opt, rest, numArgs); } return null; } return new CheckArgsArrayArityInstr(ii.getArgs(), required, opt, rest); }
@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); }
@Override public Instr clone(CloneInfo info) { if (info instanceof SimpleCloneInfo) { return new ReceivePostReqdArgInstr(info.getRenamedVariable(result), argIndex, preReqdArgsCount, optArgsCount, restArg, postReqdArgsCount); } InlineCloneInfo ii = (InlineCloneInfo) info; if (ii.canMapArgsStatically()) { int n = ii.getArgsCount(); int remaining = n - preReqdArgsCount; Operand argVal; if (remaining <= argIndex) { // SSS: FIXME: Argh! argVal = ii.getHostScope().getManager().getNil(); } else { argVal = (remaining > postReqdArgsCount) ? ii.getArg(n - postReqdArgsCount + argIndex) : ii.getArg(preReqdArgsCount + argIndex); } return new CopyInstr(ii.getRenamedVariable(result), argVal); } return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), preReqdArgsCount, postReqdArgsCount, argIndex); }
@Override public Instr clone(CloneInfo info) { if (info instanceof SimpleCloneInfo) { return new ReceivePostReqdArgInstr(info.getRenamedVariable(result), argIndex, preReqdArgsCount, optArgsCount, restArg, postReqdArgsCount); } InlineCloneInfo ii = (InlineCloneInfo) info; if (ii.canMapArgsStatically()) { int n = ii.getArgsCount(); int remaining = n - preReqdArgsCount; Operand argVal; if (remaining <= argIndex) { // SSS: FIXME: Argh! argVal = ii.getHostScope().getManager().getNil(); } else { argVal = (remaining > postReqdArgsCount) ? ii.getArg(n - postReqdArgsCount + argIndex) : ii.getArg(preReqdArgsCount + argIndex); } return new CopyInstr(ii.getRenamedVariable(result), argVal); } return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), preReqdArgsCount, postReqdArgsCount, argIndex); }