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

56
LINES

< > BotCompany Repo | #1001053 // Memory cells (developing)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Compilation Failed (133L/1K).

!747

abstract class Pred {
  boolean eval(Map<S, S> s);
}

m {
  static int nextMCellID;
  static new Map<S, MCell> memoryCells;
  
  // a memory cell
  static class MCell {
    S id;
    O value;
    long lastAccess;
    
    *(S *id) {
      lastAccess = now();
    }
    
    O get() {
      lastAccess = now();
      return value;
    }
    
    void set(O value) {
      lastAccess = now();
      this.value = value;
    }
  }
  
  static MCell newMCell() {
    S id = "m" + ++nextMCellID;
    MCell cell = new MCell(id);
    memoryCells.put(id, cell);
    return cell;
  }
  
  static MCell getMCell(S id) {
    return memoryCells.get(id);
  }
  
  p {
    defineVerification("<memory cell> is occupied.",
      new Pred() {
        boolean eval(Map<S, S> s) {
          S cell = s.get("memory cell");
          return memoryCells.get(cell).get() != null;
        }
      });
    verify("m1 is occupied.");
  }
  
  static void defineVerification(S sentence, Pred p) {
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001053
Snippet name: Memory cells (developing)
Eternal ID of this version: #1001053/1
Text MD5: e5384029198e86f79f4d8c8f93a921a5
Transpilation MD5: b5cba06fbb3e6ade6f2c6c869ad5e271
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-18 18:53:09
Source code size: 1036 bytes / 56 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 636 / 648
Referenced in: #3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)