From 5e2fd183ff1fe240ddbd864dbf1e6a0941fb4582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 21 Jan 2020 15:53:29 +0100 Subject: refactor: Rename JS entry functions (#3732) --- cli/js/os.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'cli/js/os.ts') diff --git a/cli/js/os.ts b/cli/js/os.ts index 2a3a51de7..cf522f857 100644 --- a/cli/js/os.ts +++ b/cli/js/os.ts @@ -84,13 +84,10 @@ interface Start { arch: Arch; } -// This function bootstraps an environment within Deno, it is shared both by -// the runtime and the compiler environments. -// @internal -export function start(preserveDenoNamespace = true, source?: string): Start { +// TODO(bartlomieju): temporary solution, must be fixed when moving +// dispatches to separate crates +export function initOps(): void { const ops = core.ops(); - // TODO(bartlomieju): this is a prototype, we should come up with - // something a bit more sophisticated for (const [name, opId] of Object.entries(ops)) { const opName = `OP_${name.toUpperCase()}`; // Assign op ids to actual variables @@ -98,6 +95,13 @@ export function start(preserveDenoNamespace = true, source?: string): Start { ((dispatch as unknown) as { [key: string]: number })[opName] = opId; core.setAsyncHandler(opId, dispatch.getAsyncHandler(opName)); } +} + +// This function bootstraps an environment within Deno, it is shared both by +// the runtime and the compiler environments. +// @internal +export function start(preserveDenoNamespace = true, source?: string): Start { + initOps(); // 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. -- cgit v1.2.3