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).

!7

cmodule VirtualObjectsSpike > DynPrintLog {
  start-thread {
    new VirtualObject vo;
    print("VO made");
    vo.setInt(5, 13);
    assertEqualsVerbose(13, vo.getIntAt(5));
    assertEqualsVerbose(0, vo.getIntAt(3));
  }
}

sclass VirtualObject {
  byte[] byteData;
  O[] pointerData;
  
  int getIntAt(int byteIdx) {
    ret intFromBytes(byteData, byteIdx);
  }
  
  void setInt(int byteIdx, int i) {
    setByte(byteIdx+3, 0);
    intToBytes_inArray(i, byteData, byteIdx);
  }
  
  byte getByteAt(int byteIdx) {
    ret byteData[byteIdx];
  }
  
  void setByte(int byteIdx, int b) {
    byteData = byteArraySetWithExponentialGrowth(byteData, byteIdx, (byte) b);
  }
  
  O getPointerAt(int pointerIdx) {
    ret pointerData[pointerIdx];
  }
  
  void setPointer(int pointerIdx, O o) {
    pointerData = arraySetWithExponentialGrowth(pointerData, pointerIdx, o);
  }
}

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: 295 / 485
Version history: 10 change(s)
Referenced in: