public boolean isConstantDefined(String internedName) { return getConstant(internedName) != null; }
public boolean isConstantDefined(String internedName) { return getConstant(internedName) != null; }
/** * Used by the evaluator and the compiler to look up a constant by name */ @Deprecated public IRubyObject getConstant(String internedName) { return getCurrentStaticScope().getConstant(internedName); }
/** * Used by the evaluator and the compiler to look up a constant by name */ @Deprecated public IRubyObject getConstant(String internedName) { return getCurrentStaticScope().getConstant(internedName); }
/** * Used by the evaluator and the compiler to look up a constant by name */ @Deprecated public IRubyObject getConstant(String internedName) { return getCurrentStaticScope().getConstant(internedName); }
/** * Used by the evaluator and the compiler to look up a constant by name */ @Deprecated public IRubyObject getConstant(String internedName) { return getCurrentStaticScope().getConstant(internedName); }
public IRubyObject reCache(ThreadContext context, StaticScope scope, String name, int index) { Invalidator invalidator = context.runtime.getConstantInvalidator(name); Object newGeneration = invalidator.getData(); IRubyObject value = scope.getConstant(name); if (value != null) { constants[index] = new ConstantCache(value, newGeneration, invalidator); } else { constants[index] = null; } return value; }
public IRubyObject reCache(ThreadContext context, StaticScope scope, String name, int index) { Invalidator invalidator = context.runtime.getConstantInvalidator(name); Object newGeneration = invalidator.getData(); IRubyObject value = scope.getConstant(name); if (value != null) { constants[index] = new ConstantCache(value, newGeneration, invalidator); } else { constants[index] = null; } return value; }
public IRubyObject reCache(ThreadContext context, StaticScope scope, String name, int index) { Invalidator invalidator = context.runtime.getConstantInvalidator(name); Object newGeneration = invalidator.getData(); IRubyObject value = scope.getConstant(name); if (value != null) { constants[index] = new ConstantCache(value, newGeneration, invalidator); } else { constants[index] = null; } return value; }
public IRubyObject reCache(ThreadContext context, StaticScope scope, String name, int index) { Invalidator invalidator = context.runtime.getConstantInvalidator(name); Object newGeneration = invalidator.getData(); IRubyObject value = scope.getConstant(name); if (value != null) { constants[index] = new ConstantCache(value, newGeneration, invalidator); } else { constants[index] = null; } return value; }
public IRubyObject reCache(ThreadContext context, String name) { Invalidator invalidator = context.runtime.getConstantInvalidator(name); Object newGeneration = invalidator.getData(); IRubyObject value = context.getCurrentStaticScope().getConstant(name); this.name = name; if (value != null) { cache = new ConstantCache(value, newGeneration, invalidator); } else { cache = null; } return value; } }
public IRubyObject reCache(ThreadContext context, String name) { Invalidator invalidator = context.runtime.getConstantInvalidator(name); Object newGeneration = invalidator.getData(); IRubyObject value = context.getCurrentStaticScope().getConstant(name); this.name = name; if (value != null) { cache = new ConstantCache(value, newGeneration, invalidator); } else { cache = null; } return value; } }
public static IRubyObject searchConst(MutableCallSite site, String constName, ThreadContext context, StaticScope staticScope) throws Throwable { Ruby runtime = context.runtime; SwitchPoint switchPoint = (SwitchPoint)runtime.getConstantInvalidator(constName).getData(); IRubyObject value = staticScope.getConstant(constName); if (value == null) { return staticScope.getModule().callMethod(context, "const_missing", runtime.fastNewSymbol(constName)); } // bind constant until invalidated MethodHandle target = Binder.from(site.type()) .drop(0, 2) .constant(value); MethodHandle fallback = Binder.from(site.type()) .insert(0, site, constName) .invokeStatic(MethodHandles.lookup(), Bootstrap.class, "searchConst"); site.setTarget(switchPoint.guardWithTest(target, fallback)); return value; }
public static IRubyObject searchConst(MutableCallSite site, String constName, ThreadContext context, StaticScope staticScope) throws Throwable { Ruby runtime = context.runtime; SwitchPoint switchPoint = (SwitchPoint)runtime.getConstantInvalidator(constName).getData(); IRubyObject value = staticScope.getConstant(constName); if (value == null) { return staticScope.getModule().callMethod(context, "const_missing", runtime.fastNewSymbol(constName)); } // bind constant until invalidated MethodHandle target = Binder.from(site.type()) .drop(0, 2) .constant(value); MethodHandle fallback = Binder.from(site.type()) .insert(0, site, constName) .invokeStatic(MethodHandles.lookup(), Bootstrap.class, "searchConst"); site.setTarget(switchPoint.guardWithTest(target, fallback)); return value; }
public static IRubyObject constantFallback(RubyConstantCallSite site, AbstractScript script, ThreadContext context, int scopeIndex) { SwitchPoint switchPoint = (SwitchPoint)context.runtime.getConstantInvalidator(site.name()).getData(); StaticScope scope = script.getScope(scopeIndex); IRubyObject value = scope.getConstant(site.name()); if (value != null) { if (RubyInstanceConfig.LOG_INDY_CONSTANTS) LOG.info("constant " + site.name() + " bound directly"); MethodHandle valueHandle = constant(IRubyObject.class, value); valueHandle = dropArguments(valueHandle, 0, AbstractScript.class, ThreadContext.class); MethodHandle fallback = insertArguments( findStatic(InvokeDynamicSupport.class, "constantFallback", methodType(IRubyObject.class, RubyConstantCallSite.class, AbstractScript.class, ThreadContext.class, int.class)), 0, site); fallback = insertArguments(fallback, 2, scopeIndex); MethodHandle gwt = switchPoint.guardWithTest(valueHandle, fallback); site.setTarget(gwt); } else { value = scope.getModule() .callMethod(context, "const_missing", context.runtime.newSymbol(site.name())); } return value; }
public static IRubyObject constantFallback(RubyConstantCallSite site, AbstractScript script, ThreadContext context, int scopeIndex) { SwitchPoint switchPoint = (SwitchPoint)context.runtime.getConstantInvalidator(site.name()).getData(); StaticScope scope = script.getScope(scopeIndex); IRubyObject value = scope.getConstant(site.name()); if (value != null) { if (RubyInstanceConfig.LOG_INDY_CONSTANTS) LOG.info("constant " + site.name() + " bound directly"); MethodHandle valueHandle = constant(IRubyObject.class, value); valueHandle = dropArguments(valueHandle, 0, AbstractScript.class, ThreadContext.class); MethodHandle fallback = insertArguments( findStatic(InvokeDynamicSupport.class, "constantFallback", methodType(IRubyObject.class, RubyConstantCallSite.class, AbstractScript.class, ThreadContext.class, int.class)), 0, site); fallback = insertArguments(fallback, 2, scopeIndex); MethodHandle gwt = switchPoint.guardWithTest(valueHandle, fallback); site.setTarget(gwt); } else { value = scope.getModule() .callMethod(context, "const_missing", context.runtime.newSymbol(site.name())); } return value; }
public static boolean constantBooleanFallback(RubyConstantCallSite site, AbstractScript script, ThreadContext context, int scopeIndex) { SwitchPoint switchPoint = (SwitchPoint)context.runtime.getConstantInvalidator(site.name()).getData(); StaticScope scope = script.getScope(scopeIndex); IRubyObject value = scope.getConstant(site.name()); if (value != null) { if (RubyInstanceConfig.LOG_INDY_CONSTANTS) LOG.info("constant " + site.name() + " bound directly"); MethodHandle valueHandle = constant(boolean.class, value.isTrue()); valueHandle = dropArguments(valueHandle, 0, AbstractScript.class, ThreadContext.class); MethodHandle fallback = insertArguments( findStatic(InvokeDynamicSupport.class, "constantBooleanFallback", methodType(boolean.class, RubyConstantCallSite.class, AbstractScript.class, ThreadContext.class, int.class)), 0, site); fallback = insertArguments(fallback, 2, scopeIndex); MethodHandle gwt = switchPoint.guardWithTest(valueHandle, fallback); site.setTarget(gwt); } else { value = scope.getModule() .callMethod(context, "const_missing", context.runtime.newSymbol(site.name())); } boolean booleanValue = value.isTrue(); return booleanValue; }
public static boolean constantBooleanFallback(RubyConstantCallSite site, AbstractScript script, ThreadContext context, int scopeIndex) { SwitchPoint switchPoint = (SwitchPoint)context.runtime.getConstantInvalidator(site.name()).getData(); StaticScope scope = script.getScope(scopeIndex); IRubyObject value = scope.getConstant(site.name()); if (value != null) { if (RubyInstanceConfig.LOG_INDY_CONSTANTS) LOG.info("constant " + site.name() + " bound directly"); MethodHandle valueHandle = constant(boolean.class, value.isTrue()); valueHandle = dropArguments(valueHandle, 0, AbstractScript.class, ThreadContext.class); MethodHandle fallback = insertArguments( findStatic(InvokeDynamicSupport.class, "constantBooleanFallback", methodType(boolean.class, RubyConstantCallSite.class, AbstractScript.class, ThreadContext.class, int.class)), 0, site); fallback = insertArguments(fallback, 2, scopeIndex); MethodHandle gwt = switchPoint.guardWithTest(valueHandle, fallback); site.setTarget(gwt); } else { value = scope.getModule() .callMethod(context, "const_missing", context.runtime.newSymbol(site.name())); } boolean booleanValue = value.isTrue(); return booleanValue; }