wasmContainer.jsView |
---|
66 | 66 | meterType: 'i32' |
67 | 67 | }) |
68 | 68 | |
69 | 69 | |
70 | | - let numOfGlobals = json.persist.length |
71 | | - if (numOfGlobals) { |
| 70 | + if (json.persist.length) { |
72 | 71 | moduleJSON = injectGlobals(moduleJSON, json.persist) |
73 | 72 | } |
74 | 73 | |
75 | 74 | wasm = json2wasm(moduleJSON) |
193 | 192 | }, |
194 | 193 | metering: { |
195 | 194 | usegas: amount => { |
196 | 195 | this.actor.incrementTicks(amount) |
197 | | - |
| 196 | + funcRef.gas -= amount |
198 | 197 | if (funcRef.gas < 0) { |
199 | 198 | throw new Error('out of gas! :(') |
200 | 199 | } |
201 | 200 | } |
249 | 248 | |
250 | 249 | |
251 | 250 | numOfGlobals = this.json.persist.length |
252 | 251 | if (numOfGlobals) { |
253 | | - this.actor.storage = [] |
| 252 | + const storage = [] |
254 | 253 | this.instance.exports.getter_globals() |
255 | 254 | const mem = this.get32Memory(0, numOfGlobals) |
256 | 255 | while (numOfGlobals--) { |
257 | 256 | const ref = mem[numOfGlobals] |
258 | | - this.actor.storage.push(this.refs.get(ref, this.json.persist[numOfGlobals].type)) |
| 257 | + storage.push(this.refs.get(ref, this.json.persist[numOfGlobals].type)) |
259 | 258 | } |
| 259 | + this.actor.storage = storage |
260 | 260 | } |
261 | 261 | |
262 | 262 | this.refs.clear() |
263 | 263 | } |