Files: 46e04c98fc3dc5aa69dc36fe9176ddc702784118 / tests / injectGlobals.js
641 bytesRaw
1 | const fs = require('fs') |
2 | const {wasm2json, json2wasm} = require('wasm-json-toolkit') |
3 | const injectGlobals = require('../injectGlobals.js') |
4 | const customTypes = require('../customTypes') |
5 | |
6 | const testWasm = fs.readFileSync('./wasm/globals.wasm') |
7 | const json = wasm2json(testWasm) |
8 | const globals = customTypes.decodeGlobals(json[1].payload) |
9 | console.log(globals) |
10 | |
11 | const r = injectGlobals(json, globals) |
12 | const rWasm = json2wasm(r) |
13 | const mod = WebAssembly.Module(rWasm) |
14 | const inst = WebAssembly.Instance(mod) |
15 | inst.exports.setter_globals(5, 6) |
16 | inst.exports.getter_globals() |
17 | |
18 | const mem = new Uint8Array(inst.exports.memory.buffer, 0, 8) |
19 | console.log(mem) |
20 |
Built with git-ssb-web