git ssb

0+

wanderer🌟 / js-primea-wasm-container



Tree: aef03b94be635e5d746e19e5f5e3af0a7fa3ec0f

Files: aef03b94be635e5d746e19e5f5e3af0a7fa3ec0f / tests / injectGlobals.js

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

Built with git-ssb-web