blob: 526b79a351bba4adfa42b79b869a8006ef189727 (
plain)
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
48
49
50
51
52
|
import std.stdio;
import std.string;
import parser;
import dbg;
import chunk;
import compiler;
import vm;
/*
import compiler;
import obj;
import dbg;
import chunk;
import vm;
*/
void repl() {
while(true) {
write("> ");
string input = strip(stdin.readln());
if (input.length == 0) {
continue;
}
Parser parser = new Parser(input);
Compiler compiler = new Compiler(FunctionType.SCRIPT, &parser);
Function func = compiler.compile();
int cnt = 0;
writeln("== disassembly ==");
while(true) {
if (cnt >= func.chunk.code.length) {
break;
}
cnt = disassemble(func.chunk, cnt);
}
VM vm = new VM(func);
vm.run();
}
}
void main() {
repl();
}
|