From 11ec7cb4e332de467dda35d2cf6984cd493587fa Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Wed, 3 Feb 2021 19:10:38 +0000 Subject: [PATCH] jsc/wasm32/wasm32.jsc: new code, unused --- jsc/wasm32/wasm32.jsc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/jsc/wasm32/wasm32.jsc b/jsc/wasm32/wasm32.jsc index 941a5550..23807ec6 100644 --- a/jsc/wasm32/wasm32.jsc +++ b/jsc/wasm32/wasm32.jsc @@ -431,6 +431,31 @@ Wasm32Symbol.prototype.add_reference = function (reference) this.references.push(reference); }; +function Wasm32Modules() +{ + this.by_path = {}; +} + +Wasm32Modules.prototype.bytes = async function (name) +{ + let path; + if (name[0] === "/") + path = name; + else + path = os.getenv("WASMDIR") + "/wasm/" + name + ".wasm"; + return os.readFile(path, "binary"); +}; + +Wasm32Modules.prototype.module = async function (name) +{ + if (!this.by_path[path]) + this.by_path[path] = new Wasm32Module(await this.bytes(name), name); + + return this.by_path[path]; +}; + +var gWasm32Modules = new Wasm32Modules(); + /* A link-map object. */ function Wasm32LM(vm) {