summaryrefslogtreecommitdiff
path: root/cli/js/runtime.ts
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2020-02-25 09:14:27 -0500
committerGitHub <noreply@github.com>2020-02-25 09:14:27 -0500
commit91b606aaae23bcb790b55adc5fe70a182a37d564 (patch)
tree16b56a21ffcb3991569eda984fbd14073bdbd3ae /cli/js/runtime.ts
parent805992b14a65a6dbfb857dea6d9b657477de043d (diff)
Clean up how we use opIds (#4118)
Diffstat (limited to 'cli/js/runtime.ts')
-rw-r--r--cli/js/runtime.ts14
1 files changed, 6 insertions, 8 deletions
diff --git a/cli/js/runtime.ts b/cli/js/runtime.ts
index 53ce5fcee..8149c065c 100644
--- a/cli/js/runtime.ts
+++ b/cli/js/runtime.ts
@@ -28,16 +28,14 @@ interface Start {
arch: Arch;
}
+export let OPS_CACHE: { [name: string]: number };
+
// TODO(bartlomieju): temporary solution, must be fixed when moving
// dispatches to separate crates
export function initOps(): void {
- const ops = core.ops();
- for (const [name, opId] of Object.entries(ops)) {
- const opName = `OP_${name.toUpperCase()}`;
- // Assign op ids to actual variables
- // TODO(ry) This type casting is gross and should be fixed.
- ((dispatch as unknown) as { [key: string]: number })[opName] = opId;
- core.setAsyncHandler(opId, dispatch.getAsyncHandler(opName));
+ OPS_CACHE = core.ops();
+ for (const [name, opId] of Object.entries(OPS_CACHE)) {
+ core.setAsyncHandler(opId, dispatch.getAsyncHandler(name));
}
}
@@ -51,7 +49,7 @@ export function start(preserveDenoNamespace = true, source?: string): Start {
// 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 s = sendSync(dispatch.OP_START);
+ const s = sendSync("op_start");
setVersions(s.denoVersion, s.v8Version, s.tsVersion);
setBuildInfo(s.os, s.arch);