sclass Operation { S function; int[] registers; int outRegister = -1; *(S *function, int... regs) { registers = subArray(regs, 0, l(regs)-1); outRegister = last(regs); } } sclass Machine { O[] registers = new O[10]; new TreeMap<S, O> functions; void function(S name, O implementation) { functions.put(name, implementation); } void set(int register, O value) { if (register >= l(registers)) registers = resizeArray(registers, register+1); registers[register] = value; } O get(int register) { ret _get(registers, register); } void run(Operation op) { O f = functions.get(op.function); if (f == null) fail("Unknown operation: " + op.function); int n = l(op.registers); O[] arguments = new O[n]; for i to n: arguments[i] = get(op.registers[i]); O result = callF(f, arguments); if (op.outRegister >= 0) set(op.outRegister, result); } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006737 |
Snippet name: | AI Assembler [Include] - Machine + Operation |
Eternal ID of this version: | #1006737/2 |
Text MD5: | 01c260a54f53b2bb3fc27535b7cbf2ec |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-02-03 04:32:16 |
Source code size: | 979 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 531 / 490 |
Version history: | 1 change(s) |
Referenced in: | [show references] |