-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo.mjs
47 lines (33 loc) · 901 Bytes
/
go.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import * as C from "./control.js";
import Machine from "./machine.js";
import Heap from "./heap.js";
import Stack from "./stack.js";
import Env from "./env.js";
import * as M from "./machine.js";
import compile from "./compile.js";
import flatten from "./flatten.js";
import emit from "./emit.js";
import jit from "./jit.js";
import exec from "./exec.js";
const h1 = C.elm("h1");
const heading = h1([
C.txt("Hello"),
C.vr("x").to("y",
C.vr("y").map(x => C.txt("world " + x)))
]);
const e = Env.create(Object.entries({
x: "Molo",
}));
const s = Heap.create([]);
const k = Stack.create([]);
console.log(heading);
const code = compile(heading);
console.log(code);
const state = flatten(code);
console.log(state);
const bit = emit(state);
console.log(bit);
const j = jit(bit);
console.log(j);
const result = exec(j, new Machine(e, s, k));
console.log(result.v);