예제 #1
0
  @Override
  @ForceInline
  public byte readByte(long offset) {
    if (Jvm.isDebug()) checkReleased();

    return memory.readByte(address + translate(offset));
  }
예제 #2
0
 public long readIncompleteLong(long offset) {
   int remaining = (int) Math.min(8, readRemaining() - offset);
   long l = 0;
   for (int i = 0; i < remaining; i++) {
     byte b = memory.readByte(address + offset + i);
     l |= (long) (b & 0xFF) << (i * 8);
   }
   return l;
 }
 public int byteCheckSum() throws IORuntimeException {
   if (readLimit() >= Integer.MAX_VALUE || start() != 0) throw new AssertionError();
   byte b = 0;
   NativeBytesStore bytesStore = (NativeBytesStore) bytesStore();
   Memory memory = bytesStore.memory;
   assert memory != null;
   for (int i = (int) readPosition(), lim = (int) readLimit(); i < lim; i++) {
     b += memory.readByte(bytesStore.address + i);
   }
   return b & 0xFF;
 }
예제 #4
0
 @Override
 public boolean isEqual(String s) {
   if (s == null || s.length() != readRemaining()) return false;
   char[] chars = StringUtils.extractChars(s);
   if (bytesStore instanceof NativeBytesStore) {
     NativeBytesStore bs = (NativeBytesStore) this.bytesStore;
     long address = bs.address + bs.translate(readPosition);
     Memory memory = bs.memory;
     for (int i = 0; i < chars.length; i++) {
       int b = memory.readByte(address + i) & 0xFF;
       if (b != chars[i]) return false;
     }
   } else {
     try {
       for (int i = 0; i < chars.length; i++) {
         int b = bytesStore.readByte(readPosition + i) & 0xFF;
         if (b != chars[i]) return false;
       }
     } catch (IORuntimeException e) {
       throw new AssertionError(e);
     }
   }
   return true;
 }
예제 #5
0
 void read8bit(long position, char[] chars, int length) {
   long addr = address + translate(position);
   Memory memory = OS.memory();
   for (int i = 0; i < length; i++) chars[i] = (char) (memory.readByte(addr + i) & 0xFF);
 }