Created
May 5, 2020 12:53
-
-
Save bnjbvr/b17faedfd384b240fabc2277709c7eee to your computer and use it in GitHub Desktop.
Run a wasm binary in Spidermonkey's shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (scriptArgs.length < 1) { | |
console.log('path to a wasm binary is required'); | |
quit(-1); | |
} | |
let binary = os.file.readFile(scriptArgs[0], 'binary'); | |
// If the wasm instance expects imported functions from js, put them in here. | |
// let maybeImports = { std: { f: function() { }} }; | |
let maybeImports; | |
let { exports } = new WebAssembly.Instance( | |
new WebAssembly.Module(binary), maybeImports | |
); | |
// If the wasm module exports a function f. | |
exports.f(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment