Пример #1
0
 private VariableAccessor verifyAccessor(RubyClass cls) {
   VariableAccessor localAccessor = accessor;
   if (localAccessor.getClassId() != cls.hashCode()) {
     localAccessor = cls.getVariableAccessorForWrite(name);
     accessor = localAccessor;
   }
   return localAccessor;
 }
Пример #2
0
 public final IRubyObject setVariable(
     Ruby runtime, int index, String name, IRubyObject object, IRubyObject value) {
   VariableAccessor variableAccessor = variableWriters[index];
   RubyClass cls = object.getMetaClass().getRealClass();
   if (variableAccessor.getClassId() != cls.hashCode()) {
     variableWriters[index] = variableAccessor = cls.getVariableAccessorForWrite(name);
   }
   variableAccessor.set(object, value);
   return value;
 }
Пример #3
0
 public final IRubyObject getVariable(Ruby runtime, int index, String name, IRubyObject object) {
   VariableAccessor variableAccessor = variableReaders[index];
   RubyClass cls = object.getMetaClass().getRealClass();
   if (variableAccessor.getClassId() != cls.hashCode()) {
     variableReaders[index] = variableAccessor = cls.getVariableAccessorForRead(name);
   }
   IRubyObject value = (IRubyObject) variableAccessor.get(object);
   if (value != null) {
     return value;
   }
   if (runtime.isVerbose()) {
     warnAboutUninitializedIvar(runtime, name);
   }
   return runtime.getNil();
 }