summaryrefslogtreecommitdiff
path: root/main.ts
blob: 4b64650f963b03ffce2761e60c56c6b8af5ffcb3 (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
import { main as pb } from "./msg.pb";
import "./util";
import * as runtime from "./runtime";
import * as path from "path";

function start(cwd: string, argv: string[]): void {
  // TODO parse arguments.
  const inputFn = argv[1];
  const fn = path.resolve(cwd, inputFn);
  const m = runtime.FileModule.load(fn);
  m.compileAndRun();
}

V8Worker2.recv((ab: ArrayBuffer) => {
  const msg = pb.Msg.decode(new Uint8Array(ab));
  switch (msg.kind) {
    case pb.Msg.MsgKind.START:
      start(msg.start.cwd, msg.start.argv);
      break;
    default:
      console.log("Unknown message", msg);
      break;
  }
});