Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

30
LINES

< > BotCompany Repo | #1031718 // IIntMemory_indirect - with indirect object pointers

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3148L/19K).

// all addresses in this system are IndirectAddr,
// or: obj id (int) + offset in object (int)
sinterface IIntMemory_indirect {
  // versions using two ints (obj+ofs)
  int get(int obj, int ofs); // read offset ofs in object obj
  default int read(int obj, int ofs) { ret get(obj, ofs); }
  void set(int obj, int ofs, int val);
  
  // versions using IndirectAddr
  default int get(IndirectAddr addr) { ret get(addr.obj, addr.ofs); }
  default int read(IndirectAddr addr) { ret get(addr); }
  default void set(IndirectAddr addr, int val) { set(addr.obj, addr.ofs, val); }
  
  default int[] readArray(int obj, int start, int len) {
    int[] a = new[len];
    for i to len:
      a[i] = get(obj, start+i);
    ret a;
  }
  
  
  default long getLong(int obj, int ofs) {
    ret twoIntsToLong(get(obj, ofs), get(obj, ofs+1));
  }
  
  default void setLong(int obj, int ofs, long val) {
    set(obj, ofs, firstIntFromLong(val));
    set(obj, ofs+1, secondIntFromLong(val));
  }
}

Author comment

Began life as a copy of #1029248

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031718
Snippet name: IIntMemory_indirect - with indirect object pointers
Eternal ID of this version: #1031718/2
Text MD5: a9b8304325ca2bd7187eaaecd45f262d
Transpilation MD5: 646f27a4f1158dcdc44d38ec7b215cd2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-28 21:19:06
Source code size: 1006 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 174 / 336
Version history: 1 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)