@Override public Instr clone(CloneInfo ii) { return new SearchConstInstr(ii.getRenamedVariable(result), constantName, getStartingScope().cloneForInlining(ii), noPrivateConsts); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Object constant = cachedConstant; // Store to temp so it does null out on us mid-stream if (!isCached(context, constant)) constant = cache(context, currDynScope, self, temp); return constant; }
@Override public void SearchConstInstr(SearchConstInstr searchconstinstr) { jvmMethod().loadContext(); visit(searchconstinstr.getStartingScope()); jvmMethod().searchConst(searchconstinstr.getId(), searchconstinstr.isNoPrivateConsts()); jvmStoreLocal(searchconstinstr.getResult()); }
@Override public void encode(IRWriterEncoder e) { super.encode(e); e.encode(getName()); e.encode(getStartingScope()); e.encode(isNoPrivateConsts()); }
ConstantCache cache = sci.getConstantCache(); Object result = !ConstantCache.isCached(cache) ? sci.cache(context, currScope, currDynScope, self, temp) : cache.value; setResult(temp, currDynScope, sci.getResult(), result); break;
result = sci.getCachedConst(); if (!sci.isCached(context, result)) result = sci.cache(context, currDynScope, self, temp); setResult(temp, currDynScope, sci.getResult(), result); break;
@Override public void SearchConstInstr(SearchConstInstr searchconstinstr) { // TODO: private consts jvm.method().loadLocal(0); visit(searchconstinstr.getStartingScope()); jvm.method().searchConst(searchconstinstr.getConstName()); jvmStoreLocal(searchconstinstr.getResult()); }
public Instr cloneForInlining(InlinerInfo ii) { return new SearchConstInstr(ii.getRenamedVariable(result), constName, startingScope.cloneForInlining(ii), noPrivateConsts); }
public Object cache(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { // Lexical lookup Ruby runtime = context.getRuntime(); RubyModule object = runtime.getObject(); String id = getId(); StaticScope staticScope = (StaticScope) getStartingScope().retrieve(context, self, currScope, currDynScope, temp); Object constant = (staticScope == null) ? object.getConstant(id) : staticScope.getConstantInner(id); // Inheritance lookup RubyModule module = null; if (constant == null) { // SSS FIXME: Is this null check case correct? module = staticScope == null ? object : staticScope.getModule(); constant = noPrivateConsts ? module.getConstantFromNoConstMissing(id, false) : module.getConstantNoConstMissing(id); } // Call const_missing or cache if (constant == null) { constant = module.callMethod(context, "const_missing", runtime.fastNewSymbol(id)); } else { // recache Invalidator invalidator = runtime.getConstantInvalidator(id); cache = new ConstantCache((IRubyObject)constant, invalidator.getData(), invalidator); } return constant; }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { ConstantCache cache = this.cache; if (!ConstantCache.isCached(cache)) return cache(context, currScope, currDynScope, self, temp); return cache.value; }
@Override public String[] toStringNonOperandArgs() { return new String[] {"name: " + getName(), "no_priv: " + noPrivateConsts}; }
case RETURN_OR_RETHROW_SAVED_EXC: return ReturnOrRethrowSavedExcInstr.decode(this); case RUNTIME_HELPER: return RuntimeHelperCall.decode(this); case SEARCH_CONST: return SearchConstInstr.decode(this); case SEARCH_MODULE_FOR_CONST: return SearchModuleForConstInstr.decode(this); case SET_CAPTURED_VAR: return SetCapturedVarInstr.decode(this);
ConstantCache cache = sci.getConstantCache(); Object result = !ConstantCache.isCached(cache) ? sci.cache(context, currScope, currDynScope, self, temp) : cache.value; setResult(temp, currDynScope, sci.getResult(), result); break;
result = sci.getCachedConst(); if (!sci.isCached(context, result)) result = sci.cache(context, currDynScope, self, temp); setResult(temp, currDynScope, sci.getResult(), result); break;
@Override public void SearchConstInstr(SearchConstInstr searchconstinstr) { // TODO: private consts jvm.method().loadLocal(0); visit(searchconstinstr.getStartingScope()); jvm.method().searchConst(searchconstinstr.getConstName()); jvmStoreLocal(searchconstinstr.getResult()); }
public Instr cloneForInlining(InlinerInfo ii) { return new SearchConstInstr(ii.getRenamedVariable(result), constName, startingScope.cloneForInlining(ii), noPrivateConsts); }
@Override public void encode(IRWriterEncoder e) { super.encode(e); e.encode(getName()); e.encode(getStartingScope()); e.encode(isNoPrivateConsts()); }
public Object cache(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { // Lexical lookup Ruby runtime = context.getRuntime(); RubyModule object = runtime.getObject(); String id = getId(); StaticScope staticScope = (StaticScope) getStartingScope().retrieve(context, self, currScope, currDynScope, temp); Object constant = (staticScope == null) ? object.getConstant(id) : staticScope.getConstantInner(id); // Inheritance lookup RubyModule module = null; if (constant == null) { // SSS FIXME: Is this null check case correct? module = staticScope == null ? object : staticScope.getModule(); constant = noPrivateConsts ? module.getConstantFromNoConstMissing(id, false) : module.getConstantNoConstMissing(id); } // Call const_missing or cache if (constant == null) { constant = module.callMethod(context, "const_missing", runtime.fastNewSymbol(id)); } else { // recache Invalidator invalidator = runtime.getConstantInvalidator(id); cache = new ConstantCache((IRubyObject)constant, invalidator.getData(), invalidator); } return constant; }
@Override public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { ConstantCache cache = this.cache; if (!ConstantCache.isCached(cache)) return cache(context, currScope, currDynScope, self, temp); return cache.value; }
@Override public String[] toStringNonOperandArgs() { return new String[] {"name: " + getName(), "no_priv: " + noPrivateConsts}; }