Esempio n. 1
0
    public IRubyObject get(
        ThreadContext context, StructLayout.Storage cache, Member m, IRubyObject ptr) {
      DirectMemoryIO memory = ((AbstractMemory) ptr).getMemoryIO().getMemoryIO(m.getOffset(ptr));
      IRubyObject old = cache.getCachedValue(m);
      if (old instanceof Pointer) {
        MemoryIO oldMemory = ((Pointer) old).getMemoryIO();
        if (memory.equals(oldMemory)) {
          return old;
        }
      }
      Pointer retval = new Pointer(context.getRuntime(), memory);
      cache.putCachedValue(m, retval);

      return retval;
    }
Esempio n. 2
0
 protected Pointer getPointer(Ruby runtime, long offset) {
   DirectMemoryIO ptr = (DirectMemoryIO) getMemoryIO().getMemoryIO(offset);
   return new BasePointer(runtime, ptr != null && !ptr.isNull() ? ptr : new NullMemoryIO(runtime));
 }