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

41
LINES

< > BotCompany Repo | #1023054 // "Virtual" Objects Spike - custom compact object representations v1 [OK]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (1684L/10K).

1  
!7
2  
3  
cmodule VirtualObjectsSpike > DynPrintLog {
4  
  start-thread {
5  
    new VirtualObject vo;
6  
    print("VO made");
7  
    vo.setInt(5, 13);
8  
    assertEqualsVerbose(13, vo.getIntAt(5));
9  
    assertEqualsVerbose(0, vo.getIntAt(3));
10  
  }
11  
}
12  
13  
sclass VirtualObject {
14  
  byte[] byteData;
15  
  O[] pointerData;
16  
  
17  
  int getIntAt(int byteIdx) {
18  
    ret intFromBytes(byteData, byteIdx);
19  
  }
20  
  
21  
  void setInt(int byteIdx, int i) {
22  
    setByte(byteIdx+3, 0);
23  
    intToBytes_inArray(i, byteData, byteIdx);
24  
  }
25  
  
26  
  byte getByteAt(int byteIdx) {
27  
    ret byteData[byteIdx];
28  
  }
29  
  
30  
  void setByte(int byteIdx, int b) {
31  
    byteData = byteArraySetWithExponentialGrowth(byteData, byteIdx, (byte) b);
32  
  }
33  
  
34  
  O getPointerAt(int pointerIdx) {
35  
    ret pointerData[pointerIdx];
36  
  }
37  
  
38  
  void setPointer(int pointerIdx, O o) {
39  
    pointerData = arraySetWithExponentialGrowth(pointerData, pointerIdx, o);
40  
  }
41  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023054
Snippet name: "Virtual" Objects Spike - custom compact object representations v1 [OK]
Eternal ID of this version: #1023054/11
Text MD5: 7df5ce2a7d3fc8f6667412b66ca3cb23
Transpilation MD5: 5756d8f053bd753ed757f2e9b8633917
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-29 23:25:01
Source code size: 916 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 296 / 487
Version history: 10 change(s)
Referenced in: [show references]