git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 2417016a904e9be97c5043e4fc9b1d5357aa1635

fix a bug with calling findSections on the same json

Norton Wang committed on 3/6/2018, 10:27:33 PM
Parent: 888b8752d6766cfe61cb86689a349d3d493661c6

Files changed

injectGlobals.jschanged
injectGlobals.jsView
@@ -1,21 +1,21 @@
11 const {findSections} = require('wasm-json-toolkit')
2-const wantedSections = ['type', 'import', 'function', 'export', 'code']
32
43 module.exports = function injectGlobals (json, globals) {
4+ const wantedSections = ['type', 'import', 'function', 'export', 'code']
55 const iter = findSections(json, wantedSections)
6- const {value: type} = iter.next()
6+ const {value: type = {entries: []}} = iter.next()
77 const getterType = type.entries.push(typeEntry()) - 1
88 const setterType = type.entries.push(typeEntry(Array(globals.length).fill('i32'))) - 1
99
1010 const {value: imports = {entries: []}} = iter.next()
11- const {value: func} = iter.next()
11+ const {value: func = {entries: []}} = iter.next()
1212 const getterIndex = func.entries.push(getterType) - 1 + imports.entries.length
1313 const setterIndex = func.entries.push(setterType) - 1 + imports.entries.length
14- const {value: exports} = iter.next()
14+ const {value: exports = {entries: []}} = iter.next()
1515 exports.entries.push(exportEntry('getter_globals', getterIndex))
1616 exports.entries.push(exportEntry('setter_globals', setterIndex))
17- const {value: code} = iter.next()
17+ const {value: code = {entries: []}} = iter.next()
1818 const getterCode = []
1919 const setterCode = []
2020 globals.forEach((global, index) => {
2121 const globalIndex = global.index

Built with git-ssb-web