Commit cbaa5108c37a1044ce3682079c2e0dd7cb939698
Merge pull request #3 from dfinity/small-fixes
more small fixeswanderer authored on 3/7/2018, 10:10:00 PM
GitHub committed on 3/7/2018, 10:10:00 PM
Parent: 888b8752d6766cfe61cb86689a349d3d493661c6
Parent: 3293a87f5f8d4e902258609eb8f0c213b7c38192
Files changed
index.js | changed |
injectGlobals.js | changed |
systemObjects.js | changed |
index.js | ||
---|---|---|
@@ -100,11 +100,15 @@ | ||
100 | 100 | * @returns {Promise} |
101 | 101 | */ |
102 | 102 | createStateRoot () { |
103 | 103 | return new Promise((resolve, reject) => { |
104 | - this.scheduler.on('idle', () => { | |
104 | + if (!this.scheduler._running) { | |
105 | 105 | this.tree.flush().then(resolve) |
106 | - }) | |
106 | + } else { | |
107 | + this.scheduler.on('idle', () => { | |
108 | + this.tree.flush().then(resolve) | |
109 | + }) | |
110 | + } | |
107 | 111 | }) |
108 | 112 | } |
109 | 113 | |
110 | 114 | /** |
injectGlobals.js | ||
---|---|---|
@@ -1,21 +1,21 @@ | ||
1 | 1 | const {findSections} = require('wasm-json-toolkit') |
2 | -const wantedSections = ['type', 'import', 'function', 'export', 'code'] | |
3 | 2 | |
4 | 3 | module.exports = function injectGlobals (json, globals) { |
4 | + const wantedSections = ['type', 'import', 'function', 'export', 'code'] | |
5 | 5 | const iter = findSections(json, wantedSections) |
6 | - const {value: type} = iter.next() | |
6 | + const {value: type = {entries: []}} = iter.next() | |
7 | 7 | const getterType = type.entries.push(typeEntry()) - 1 |
8 | 8 | const setterType = type.entries.push(typeEntry(Array(globals.length).fill('i32'))) - 1 |
9 | 9 | |
10 | 10 | const {value: imports = {entries: []}} = iter.next() |
11 | - const {value: func} = iter.next() | |
11 | + const {value: func = {entries: []}} = iter.next() | |
12 | 12 | const getterIndex = func.entries.push(getterType) - 1 + imports.entries.length |
13 | 13 | const setterIndex = func.entries.push(setterType) - 1 + imports.entries.length |
14 | - const {value: exports} = iter.next() | |
14 | + const {value: exports = {entries: []}} = iter.next() | |
15 | 15 | exports.entries.push(exportEntry('getter_globals', getterIndex)) |
16 | 16 | exports.entries.push(exportEntry('setter_globals', setterIndex)) |
17 | - const {value: code} = iter.next() | |
17 | + const {value: code = {entries: []}} = iter.next() | |
18 | 18 | const getterCode = [] |
19 | 19 | const setterCode = [] |
20 | 20 | globals.forEach((global, index) => { |
21 | 21 | const globalIndex = global.index |
systemObjects.js | ||
---|---|---|
@@ -16,14 +16,14 @@ | ||
16 | 16 | func: new cbor.Tagged(TAGS.func, 0) |
17 | 17 | } |
18 | 18 | |
19 | 19 | class FunctionRef { |
20 | - constructor (privateFunc, identifier, params, id) { | |
20 | + constructor (privateFunc, identifier, params, id, gas=0) { | |
21 | 21 | this.private = privateFunc |
22 | 22 | this.identifier = identifier |
23 | 23 | this.destId = id |
24 | 24 | this.params = params |
25 | - this.gas = 0 | |
25 | + this.gas = gas | |
26 | 26 | } |
27 | 27 | |
28 | 28 | encodeCBOR (gen) { |
29 | 29 | return gen.write(new cbor.Tagged(TAGS.func, [ |
Built with git-ssb-web