git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 1ffd915b15f2f2a528bc6e5329be0be2c9cab33b

added types to persitant globals

wanderer committed on 2/21/2018, 2:25:46 AM
Parent: cd5644a350c66679340731cc00c9fcf16834bdb9

Files changed

customTypes.jschanged
injectGlobals.jschanged
customTypes.jsView
@@ -52,9 +52,10 @@
5252
5353 function encodeGlobals (json, stream) {
5454 leb.unsigned.write(json.length, stream)
5555 for (const entry of json) {
56- leb.unsigned.write(entry, stream)
56+ leb.unsigned.write(entry.index, stream)
57+ leb.unsigned.write(LANGUAGE_TYPES[entry.type], stream)
5758 }
5859 return stream
5960 }
6061
@@ -62,9 +63,12 @@
6263 const stream = new Stream(Buffer.from(buf))
6364 let numOfEntries = leb.unsigned.read(stream)
6465 const json = []
6566 while (numOfEntries--) {
66- json.push(leb.unsigned.readBn(stream).toNumber())
67+ json.push({
68+ index: leb.unsigned.readBn(stream).toNumber(),
69+ type: LANGUAGE_TYPES[leb.unsigned.readBn(stream).toNumber()]
70+ })
6771 }
6872 return json
6973 }
7074
injectGlobals.jsView
@@ -16,9 +16,10 @@
1616 exports.entries.push(exportEntry('setter_globals', setterIndex))
1717 const {value: code} = iter.next()
1818 const getterCode = []
1919 const setterCode = []
20- globals.forEach((globalIndex, index) => {
20+ globals.forEach((global, index) => {
21+ const globalIndex = global.index
2122 // getter
2223 getterCode.push(i32_const(index * 4))
2324 getterCode.push(get_global(globalIndex))
2425 getterCode.push(i32_store())

Built with git-ssb-web