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

1  
!747
2  
3  
abstract class Pred {
4  
  boolean eval(Map<S, S> s);
5  
}
6  
7  
m {
8  
  static int nextMCellID;
9  
  static new Map<S, MCell> memoryCells;
10  
  
11  
  // a memory cell
12  
  static class MCell {
13  
    S id;
14  
    O value;
15  
    long lastAccess;
16  
    
17  
    *(S *id) {
18  
      lastAccess = now();
19  
    }
20  
    
21  
    O get() {
22  
      lastAccess = now();
23  
      return value;
24  
    }
25  
    
26  
    void set(O value) {
27  
      lastAccess = now();
28  
      this.value = value;
29  
    }
30  
  }
31  
  
32  
  static MCell newMCell() {
33  
    S id = "m" + ++nextMCellID;
34  
    MCell cell = new MCell(id);
35  
    memoryCells.put(id, cell);
36  
    return cell;
37  
  }
38  
  
39  
  static MCell getMCell(S id) {
40  
    return memoryCells.get(id);
41  
  }
42  
  
43  
  p {
44  
    defineVerification("<memory cell> is occupied.",
45  
      new Pred() {
46  
        boolean eval(Map<S, S> s) {
47  
          S cell = s.get("memory cell");
48  
          return memoryCells.get(cell).get() != null;
49  
        }
50  
      });
51  
    verify("m1 is occupied.");
52  
  }
53  
  
54  
  static void defineVerification(S sentence, Pred p) {
55  
  }
56  
}

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: 637 / 649
Referenced in: [show references]