git ssb

0+

wanderer🌟 / js-primea-wasm-container



Tree: 172b9d65cd4d2fbc210b0cee09b451dfdccabf34

Files: 172b9d65cd4d2fbc210b0cee09b451dfdccabf34 / 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