Esempio n. 1
0
 private VariableAccessor verifyAccessor(RubyClass cls) {
   VariableAccessor localAccessor = accessor;
   if (localAccessor.getClassId() != cls.hashCode()) {
     localAccessor = cls.getVariableAccessorForWrite(name);
     accessor = localAccessor;
   }
   return localAccessor;
 }
Esempio n. 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;
 }
Esempio n. 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();
 }