diff options
| author | Ryan Dahl <ry@tinyclouds.org> | 2018-05-14 13:02:47 -0400 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2018-05-14 13:06:44 -0400 |
| commit | 50105d7855f69190f235ebd50e261863905ef173 (patch) | |
| tree | 650688610cfc1682e5cf580aa0a517b6bd60d127 /main.ts | |
| parent | 2da9893da33f05fd9122b6052c67eabcd570b0d5 (diff) | |
Use typescript
Diffstat (limited to 'main.ts')
| -rw-r--r-- | main.ts | 28 |
1 files changed, 6 insertions, 22 deletions
@@ -1,35 +1,19 @@ -//import * as ts from "typescript"; import { main as pb } from "./msg.pb"; import "./util"; -import { TextDecoder } from "text-encoding"; +import { compile } from "./compiler"; -function readFileSync(filename: string): string { - const msg = pb.Msg.fromObject({ - kind: pb.Msg.MsgKind.READ_FILE_SYNC, - path: filename - }); - const ui8 = pb.Msg.encode(msg).finish(); - const ab = ui8.buffer.slice(ui8.byteOffset, ui8.byteOffset + ui8.byteLength); - const resBuf = V8Worker2.send(ab as ArrayBuffer); - const res = pb.Msg.decode(new Uint8Array(resBuf)); - if (res.error != null && res.error.length > 0) { - throw Error(res.error); - } - const decoder = new TextDecoder("utf8"); - return decoder.decode(res.data); -} -function load(argv: string[]): void { +function start(cwd: string, argv: string[]): void { + // TODO parse arguments. const inputFn = argv[1]; - const source = readFileSync(inputFn); - console.log("source", source); + compile(cwd, inputFn); } V8Worker2.recv((ab: ArrayBuffer) => { const msg = pb.Msg.decode(new Uint8Array(ab)); switch (msg.kind) { - case pb.Msg.MsgKind.LOAD: - load(msg.argv); + case pb.Msg.MsgKind.START: + start(msg.cwd, msg.argv); break; default: console.log("Unknown message", msg); |
