@Override public Instr clone(CloneInfo ii) { return new LexicalSearchConstInstr(ii.getRenamedVariable(result), getDefiningScope().cloneForInlining(ii), constantName); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Ruby runtime = context.runtime; Object constant = cachedConstant; // Store to temp so it does null out on us mid-stream if (!isCached(runtime, constant)) constant = cache(context, currDynScope, self, temp, runtime, constant); return constant; }
@Override public void encode(IRWriterEncoder e) { super.encode(e); e.encode(getDefiningScope()); e.encode(getName()); }
@Override public Instr cloneForInlining(InlinerInfo ii) { return new LexicalSearchConstInstr(ii.getRenamedVariable(result), definingScope.cloneForInlining(ii), constName); }
@Override public void LexicalSearchConstInstr(LexicalSearchConstInstr lexicalsearchconstinstr) { jvmMethod().loadContext(); visit(lexicalsearchconstinstr.getDefiningScope()); jvmMethod().lexicalSearchConst(lexicalsearchconstinstr.getId()); jvmStoreLocal(lexicalsearchconstinstr.getResult()); }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { ConstantCache cache = this.cache; // Store to temp so it does null out on us mid-stream if (!ConstantCache.isCached(cache)) return cache(context, currScope, currDynScope, self, temp); return cache.value; }
private Object cache(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { StaticScope staticScope = (StaticScope) getDefiningScope().retrieve(context, self, currScope, currDynScope, temp); String id = getId(); IRubyObject constant = staticScope.getConstantDefined(id); if (constant == null) { constant = UndefinedValue.UNDEFINED; } else { // recache Invalidator invalidator = context.runtime.getConstantInvalidator(id); cache = new ConstantCache(constant, invalidator.getData(), invalidator); } return constant; }
private boolean isCached(Ruby runtime, Object value) { return value != null && generation == invalidator(runtime).getData(); }
public Operand getDefiningScope() { return getOperand1(); }
case LABEL: return LabelInstr.decode(this); case LAMBDA: return BuildLambdaInstr.decode(this); case LEXICAL_SEARCH_CONST: return LexicalSearchConstInstr.decode(this); case LOAD_FRAME_CLOSURE: return LoadFrameClosureInstr.decode(this); case LOAD_IMPLICIT_CLOSURE: return LoadImplicitClosureInstr.decode(this);
@Override public Instr cloneForInlining(InlinerInfo ii) { return new LexicalSearchConstInstr(ii.getRenamedVariable(result), definingScope.cloneForInlining(ii), constName); }
@Override public void LexicalSearchConstInstr(LexicalSearchConstInstr lexicalsearchconstinstr) { jvmMethod().loadContext(); visit(lexicalsearchconstinstr.getDefiningScope()); jvmMethod().lexicalSearchConst(lexicalsearchconstinstr.getId()); jvmStoreLocal(lexicalsearchconstinstr.getResult()); }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { ConstantCache cache = this.cache; // Store to temp so it does null out on us mid-stream if (!ConstantCache.isCached(cache)) return cache(context, currScope, currDynScope, self, temp); return cache.value; }
private Object cache(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { StaticScope staticScope = (StaticScope) getDefiningScope().retrieve(context, self, currScope, currDynScope, temp); String id = getId(); IRubyObject constant = staticScope.getConstantDefined(id); if (constant == null) { constant = UndefinedValue.UNDEFINED; } else { // recache Invalidator invalidator = context.runtime.getConstantInvalidator(id); cache = new ConstantCache(constant, invalidator.getData(), invalidator); } return constant; }
private boolean isCached(Ruby runtime, Object value) { return value != null && generation == invalidator(runtime).getData(); }
public Operand getDefiningScope() { return getOperand1(); }
case LABEL: return LabelInstr.decode(this); case LAMBDA: return BuildLambdaInstr.decode(this); case LEXICAL_SEARCH_CONST: return LexicalSearchConstInstr.decode(this); case LOAD_FRAME_CLOSURE: return LoadFrameClosureInstr.decode(this); case LOAD_IMPLICIT_CLOSURE: return LoadImplicitClosureInstr.decode(this);
public static LexicalSearchConstInstr decode(IRReaderDecoder d) { return new LexicalSearchConstInstr(d.decodeVariable(), d.decodeOperand(), d.decodeSymbol()); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Ruby runtime = context.runtime; Object constant = cachedConstant; // Store to temp so it does null out on us mid-stream if (!isCached(runtime, constant)) constant = cache(context, currDynScope, self, temp, runtime, constant); return constant; }
@Override public Instr clone(CloneInfo ii) { return new LexicalSearchConstInstr(ii.getRenamedVariable(result), getDefiningScope().cloneForInlining(ii), constantName); }