diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-01-09 20:52:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-09 20:52:13 -0500 |
commit | cca3a9562bc41744a8fdb4fd8b185505ca9af1c3 (patch) | |
tree | 3c6cdd754f04f003141b7855101404cd271e6b1b | |
parent | 26bc251c58186b43cbc85c454a602d2f427b7dc3 (diff) |
Re-enable --recompile (#1492)
-rw-r--r-- | js/main.ts | 26 | ||||
-rw-r--r-- | src/isolate.rs | 11 |
2 files changed, 21 insertions, 16 deletions
diff --git a/js/main.ts b/js/main.ts index 08e3bea89..910edef49 100644 --- a/js/main.ts +++ b/js/main.ts @@ -11,31 +11,35 @@ import { args } from "./deno"; import { sendSync, handleAsyncMsgFromRust } from "./dispatch"; import { replLoop } from "./repl"; import { version } from "typescript"; +import { postMessage } from "./workers"; +import { TextDecoder, TextEncoder } from "./text_encoding"; +import { ModuleSpecifier, ContainingFile } from "./compiler"; // builtin modules import * as deno from "./deno"; -function sendStart(): msg.StartRes { +type CompilerLookup = { specifier: ModuleSpecifier; referrer: ContainingFile }; + +// Global reference to StartRes so it can be shared between compilerMain and +// denoMain. +let startResMsg: msg.StartRes; + +function sendStart(): void { const builder = flatbuffers.createBuilder(); msg.Start.startStart(builder); const startOffset = msg.Start.endStart(builder); const baseRes = sendSync(builder, msg.Any.Start, startOffset); assert(baseRes != null); assert(msg.Any.StartRes === baseRes!.innerType()); - const startRes = new msg.StartRes(); - assert(baseRes!.inner(startRes) != null); - return startRes; + startResMsg = new msg.StartRes(); + assert(baseRes!.inner(startResMsg) != null); } -import { postMessage } from "./workers"; -import { TextDecoder, TextEncoder } from "./text_encoding"; -import { ModuleSpecifier, ContainingFile } from "./compiler"; -type CompilerLookup = { specifier: ModuleSpecifier; referrer: ContainingFile }; - function compilerMain() { // workerMain should have already been called since a compiler is a worker. const compiler = DenoCompiler.instance(); - // compiler.recompile = startResMsg.recompileFlag(); + compiler.recompile = startResMsg.recompileFlag(); + log(`recompile ${compiler.recompile}`); window.onmessage = (e: { data: Uint8Array }) => { const json = new TextDecoder().decode(e.data); const lookup = JSON.parse(json) as CompilerLookup; @@ -61,7 +65,7 @@ export default function denoMain() { // First we send an empty "Start" message to let the privileged side know we // are ready. The response should be a "StartRes" message containing the CLI // args and other info. - const startResMsg = sendStart(); + sendStart(); setLogDebug(startResMsg.debugFlag()); diff --git a/src/isolate.rs b/src/isolate.rs index fcd07d23e..03b73075e 100644 --- a/src/isolate.rs +++ b/src/isolate.rs @@ -3,12 +3,15 @@ // TODO Currently this module uses Tokio, but it would be nice if they were // decoupled. +use compiler::compile_sync; +use compiler::CodeFetchOutput; use deno_dir; use errors::DenoError; use errors::DenoResult; use flags; use js_errors::JSError; use libdeno; +use msg; use permissions::DenoPermissions; use futures::sync::mpsc as async_mpsc; @@ -364,17 +367,15 @@ impl Drop for Isolate { } } -use compiler::compile_sync; -use compiler::CodeFetchOutput; -use msg; fn code_fetch_and_maybe_compile( state: &Arc<IsolateState>, specifier: &str, referrer: &str, ) -> Result<CodeFetchOutput, DenoError> { let mut out = state.dir.code_fetch(specifier, referrer)?; - if out.media_type == msg::MediaType::TypeScript - && out.maybe_output_code.is_none() + if (out.media_type == msg::MediaType::TypeScript + && out.maybe_output_code.is_none()) + || state.flags.recompile { debug!(">>>>> compile_sync START"); out = compile_sync(state, specifier, &referrer).unwrap(); |