@Override public Instr cloneForInlining(InlinerInfo ii) { return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), array.cloneForInlining(ii), preArgsCount, postArgsCount, index); }
@Override public void encode(IRWriterEncoder e) { super.encode(e); e.encode(getArray()); e.encode(getPreArgsCount()); e.encode(getPostArgsCount()); e.encode(getIndex()); }
@Override public void ReqdArgMultipleAsgnInstr(ReqdArgMultipleAsgnInstr reqdargmultipleasgninstr) { jvm.method().loadContext(); visit(reqdargmultipleasgninstr.getArrayArg()); jvm.method().adapter.checkcast("org/jruby/RubyArray"); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getPreArgsCount()); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getIndex()); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getPostArgsCount()); jvm.method().invokeHelper("irReqdArgMultipleAsgn", IRubyObject.class, ThreadContext.class, RubyArray.class, int.class, int.class, int.class); jvmStoreLocal(reqdargmultipleasgninstr.getResult()); }
@Override public Instr clone(CloneInfo ii) { return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), getArray().cloneForInlining(ii), preArgsCount, postArgsCount, index); }
@Override public Operand simplifyAndGetResult(IRScope scope, Map<Operand, Operand> valueMap) { simplifyOperands(valueMap, false); Operand val = getArray().getValue(valueMap); if (val instanceof Array) { Array a = (Array)val; int n = a.size(); int i = IRRuntimeHelpers.irReqdArgMultipleAsgnIndex(n, preArgsCount, index, postArgsCount); return i == -1 ? scope.getManager().getNil() : a.get(i); } else { return null; } }
@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.irReqdArgMultipleAsgn(context, rubyArray, preArgsCount, index, postArgsCount); }
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); case MATCH: return MatchInstr.decode(this);
@Override public Instr clone(CloneInfo ii) { return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), getArray().cloneForInlining(ii), preArgsCount, postArgsCount, index); }
@Override public Operand simplifyAndGetResult(IRScope scope, Map<Operand, Operand> valueMap) { simplifyOperands(valueMap, false); Operand val = getArray().getValue(valueMap); if (val instanceof Array) { Array a = (Array)val; int n = a.size(); int i = IRRuntimeHelpers.irReqdArgMultipleAsgnIndex(n, preArgsCount, index, postArgsCount); return i == -1 ? scope.getManager().getNil() : a.get(i); } else { return null; } }
@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.irReqdArgMultipleAsgn(context, rubyArray, preArgsCount, index, postArgsCount); }
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); case MATCH: return MatchInstr.decode(this);
@Override public void encode(IRWriterEncoder e) { super.encode(e); e.encode(getArray()); e.encode(getPreArgsCount()); e.encode(getPostArgsCount()); e.encode(getIndex()); }
@Override public void ReqdArgMultipleAsgnInstr(ReqdArgMultipleAsgnInstr reqdargmultipleasgninstr) { jvm.method().loadContext(); visit(reqdargmultipleasgninstr.getArrayArg()); jvm.method().adapter.checkcast("org/jruby/RubyArray"); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getPreArgsCount()); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getIndex()); jvm.method().adapter.pushInt(reqdargmultipleasgninstr.getPostArgsCount()); jvm.method().invokeHelper("irReqdArgMultipleAsgn", IRubyObject.class, ThreadContext.class, RubyArray.class, int.class, int.class, int.class); jvmStoreLocal(reqdargmultipleasgninstr.getResult()); }
@Override public Instr cloneForInlining(InlinerInfo ii) { return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), array.cloneForInlining(ii), preArgsCount, postArgsCount, index); }
@Override public void ReqdArgMultipleAsgnInstr(ReqdArgMultipleAsgnInstr reqdargmultipleasgninstr) { jvmMethod().loadContext(); visit(reqdargmultipleasgninstr.getArray()); jvmAdapter().checkcast(p(RubyArray.class)); jvmAdapter().pushInt(reqdargmultipleasgninstr.getPreArgsCount()); jvmAdapter().pushInt(reqdargmultipleasgninstr.getIndex()); jvmAdapter().pushInt(reqdargmultipleasgninstr.getPostArgsCount()); jvmMethod().invokeIRHelper("irReqdArgMultipleAsgn", sig(IRubyObject.class, ThreadContext.class, RubyArray.class, int.class, int.class, int.class)); jvmStoreLocal(reqdargmultipleasgninstr.getResult()); }
public static ReqdArgMultipleAsgnInstr decode(IRReaderDecoder d) { return new ReqdArgMultipleAsgnInstr(d.decodeVariable(), d.decodeOperand(), d.decodeInt(), d.decodeInt(), d.decodeInt()); }
@Override public void ReqdArgMultipleAsgnInstr(ReqdArgMultipleAsgnInstr reqdargmultipleasgninstr) { jvmMethod().loadContext(); visit(reqdargmultipleasgninstr.getArray()); jvmAdapter().checkcast(p(RubyArray.class)); jvmAdapter().pushInt(reqdargmultipleasgninstr.getPreArgsCount()); jvmAdapter().pushInt(reqdargmultipleasgninstr.getIndex()); jvmAdapter().pushInt(reqdargmultipleasgninstr.getPostArgsCount()); jvmMethod().invokeIRHelper("irReqdArgMultipleAsgn", sig(IRubyObject.class, ThreadContext.class, RubyArray.class, int.class, int.class, int.class)); jvmStoreLocal(reqdargmultipleasgninstr.getResult()); }
public static ReqdArgMultipleAsgnInstr decode(IRReaderDecoder d) { return new ReqdArgMultipleAsgnInstr(d.decodeVariable(), d.decodeOperand(), d.decodeInt(), d.decodeInt(), d.decodeInt()); }
protected void receiveBlockArg(Variable v, Operand argsArray, int argIndex, boolean isSplat) { if (argsArray != null) { // We are in a nested receive situation -- when we are not at the root of a masgn tree // Ex: We are trying to receive (b,c) in this example: "|a, (b,c), d| = ..." if (isSplat) addInstr(new RestArgMultipleAsgnInstr(v, argsArray, argIndex)); else addInstr(new ReqdArgMultipleAsgnInstr(v, argsArray, argIndex)); } else { // argsArray can be null when the first node in the args-node-ast is a multiple-assignment // For example, for-nodes addInstr(isSplat ? new ReceiveRestArgInstr(v, argIndex, argIndex) : new ReceivePreReqdArgInstr(v, argIndex)); } }
@Override public Instr cloneForInlinedScope(InlinerInfo ii) { if (ii.canMapArgsStatically()) { return new CopyInstr(ii.getRenamedVariable(result), ii.getArg(argIndex)); } else { return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), -1, -1, argIndex); } }