Beispiel #1
0
 public IRubyObject reCacheFrom(RubyModule target, ThreadContext context, String name, int index) {
   int newGeneration = context.getRuntime().getConstantGeneration();
   IRubyObject value = target.fastGetConstantFromNoConstMissing(name);
   constants[index] = value;
   if (value != null) {
     constantGenerations[index] = newGeneration;
     constantTargetHashes[index] = target.hashCode();
   }
   return value;
 }
  public IRubyObject reCache(ThreadContext context, RubyModule target) {
    Object newGeneration = invalidator(context).getData();
    IRubyObject value = target.getConstantFromNoConstMissing(name, false);

    cachedValue = value;

    if (value != null) {
      generation = newGeneration;
      hash = target.hashCode();
    }

    return value;
  }
 private Object cache(Ruby runtime, RubyModule module) {
   Object constant =
       noPrivateConsts
           ? module.getConstantFromNoConstMissing(constName, false)
           : module.getConstantNoConstMissing(constName);
   if (constant == null) {
     constant = UndefinedValue.UNDEFINED;
   } else {
     // recache
     generation = runtime.getConstantInvalidator(constName).getData();
     hash = module.hashCode();
     cachedConstant = constant;
   }
   return constant;
 }
Beispiel #4
0
 private boolean isCachedFrom(
     RubyModule target, ThreadContext context, IRubyObject value, int index) {
   return value != null
       && constantGenerations[index] == context.getRuntime().getConstantGeneration()
       && constantTargetHashes[index] == target.hashCode();
 }
 private boolean isCached(Ruby runtime, RubyModule target, Object value) {
   return value != null
       && generation == invalidator(runtime).getData()
       && hash == target.hashCode();
 }
 private boolean isCached(ThreadContext context, RubyModule target, IRubyObject value) {
   // We could probably also detect if LHS value came out of cache and avoid some of this
   return value != null
       && generation == invalidator(context).getData()
       && hash == target.hashCode();
 }