Libraryless. Click here for Pure Java version (3148L/19K).
1 | // all addresses in this system are IndirectAddr, |
2 | // or: obj id (int) + offset in object (int) |
3 | sinterface IIntMemory_indirect { |
4 | // versions using two ints (obj+ofs) |
5 | int get(int obj, int ofs); // read offset ofs in object obj |
6 | default int read(int obj, int ofs) { ret get(obj, ofs); } |
7 | void set(int obj, int ofs, int val); |
8 | |
9 | // versions using IndirectAddr |
10 | default int get(IndirectAddr addr) { ret get(addr.obj, addr.ofs); } |
11 | default int read(IndirectAddr addr) { ret get(addr); } |
12 | default void set(IndirectAddr addr, int val) { set(addr.obj, addr.ofs, val); } |
13 | |
14 | default int[] readArray(int obj, int start, int len) { |
15 | int[] a = new[len]; |
16 | for i to len: |
17 | a[i] = get(obj, start+i); |
18 | ret a; |
19 | } |
20 | |
21 | |
22 | default long getLong(int obj, int ofs) { |
23 | ret twoIntsToLong(get(obj, ofs), get(obj, ofs+1)); |
24 | } |
25 | |
26 | default void setLong(int obj, int ofs, long val) { |
27 | set(obj, ofs, firstIntFromLong(val)); |
28 | set(obj, ofs+1, secondIntFromLong(val)); |
29 | } |
30 | } |
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: | 175 / 337 |
Version history: | 1 change(s) |
Referenced in: | [show references] |