runtime.ts refactor into compiler.ts (#564)

Adds compiler_test.ts
This commit is contained in:
Ryan Dahl 2018-08-22 17:17:26 -04:00 committed by GitHub
parent c5bb412933
commit e7cab71574
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1154 additions and 396 deletions

View file

@ -1,10 +1,9 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { flatbuffers } from "flatbuffers";
import { deno as fbs } from "gen/msg_generated";
import { assert, log, assignCmdId } from "./util";
import * as util from "./util";
import { assert, assignCmdId, log, setLogDebug } from "./util";
import * as os from "./os";
import * as runtime from "./runtime";
import { DenoCompiler } from "./compiler";
import { libdeno } from "./globals";
import * as timers from "./timers";
import { onFetchRes } from "./fetch";
@ -47,7 +46,7 @@ function onMessage(ui8: Uint8Array) {
/* tslint:disable-next-line:no-default-export */
export default function denoMain() {
libdeno.recv(onMessage);
runtime.setup();
const compiler = DenoCompiler.instance();
// First we send an empty "Start" message to let the privlaged side know we
// are ready. The response should be a "StartRes" message containing the CLI
@ -69,7 +68,7 @@ export default function denoMain() {
const startResMsg = new fbs.StartRes();
assert(base.msg(startResMsg) != null);
util.setLogDebug(startResMsg.debugFlag());
setLogDebug(startResMsg.debugFlag());
const cwd = startResMsg.cwd();
log("cwd", cwd);
@ -86,8 +85,5 @@ export default function denoMain() {
os.exit(1);
}
const mod = runtime.resolveModule(inputFn, `${cwd}/`);
assert(mod != null);
// TypeScript does not track assert, therefore not null assertion
mod!.compileAndRun();
compiler.run(inputFn, `${cwd}/`);
}