diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2019-11-14 05:31:39 -0800 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-11-14 08:31:39 -0500 |
commit | 4189cc1ab5493ab0aef48c06416c4d16f6806245 (patch) | |
tree | dad82896518ed93548a8d11b7bf68ad6a0eaa4f0 /cli/compilers/wasm_wrap.js | |
parent | fdf0ede2acd110ba04857d5674db19c908b3ff32 (diff) |
Loader: support .wasm imports (#3328)
* loader: support .wasm imports
* http_server: true
* Support named exports
* Clippy
Diffstat (limited to 'cli/compilers/wasm_wrap.js')
-rw-r--r-- | cli/compilers/wasm_wrap.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/compilers/wasm_wrap.js b/cli/compilers/wasm_wrap.js new file mode 100644 index 000000000..c90bd5540 --- /dev/null +++ b/cli/compilers/wasm_wrap.js @@ -0,0 +1,19 @@ +const importObject = Object.create(null); +//IMPORTS + +function base64ToUint8Array(data) { + const binString = window.atob(data); + const size = binString.length; + const bytes = new Uint8Array(size); + for (let i = 0; i < size; i++) { + bytes[i] = binString.charCodeAt(i); + } + return bytes; +} + +const buffer = base64ToUint8Array("BASE64_DATA"); +const compiled = await WebAssembly.compile(buffer); + +const instance = new WebAssembly.Instance(compiled, importObject); + +//EXPORTS |