-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathWhyOS.hx
30 lines (28 loc) · 917 Bytes
/
WhyOS.hx
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
// with console.log in the cwd
// $ haxe --run WhyOS
// but for performance reasons maybe compile to C++ first:
// $ haxe -main WhyOS -cpp whyos
// $ whyos/WhyOS
import sys.io.*;
class WhyOS {
public static function main():Void {
var f = File.read("console.log");
var progs = new Map<String, FileOutput>();
var lastProg = null;
while (true) {
var line = (try f.readLine() catch (e:Dynamic) break);
var msgType = line.substr(0, 7);
if (msgType == "default" || msgType == "error " || msgType == "fault ") {
var endProg = line.indexOf(" ", 32);
if (endProg == -1) endProg = line.length;
var prog = line.substr(32, endProg - 32);
if (!progs.exists(prog)) {
progs[prog] = File.write('console-$prog.log');
}
lastProg = progs[prog];
}
lastProg.writeString(line + "\n");
}
for (p in progs) p.close();
}
}