Commit b9cefb81b38fc031f3179fbfff55dfd7fa8596a6
move find iterator to toolkit
wanderer committed on 2/16/2018, 1:07:19 AMParent: c1baf026f5fba05cb5619603b350445d6e40a0d5
Files changed
customTypes.js | changed |
package-lock.json | changed |
package.json | changed |
tools/testTypeInfo.json | changed |
typeCheckWrapper.js | changed |
wasmContainer.js | changed |
customTypes.js | ||
---|---|---|
@@ -1,6 +1,7 @@ | ||
1 | 1 | const Stream = require('buffer-pipe') |
2 | 2 | const leb = require('leb128') |
3 | +const {findSections} = require('wasm-json-toolkit') | |
3 | 4 | |
4 | 5 | const LANGUAGE_TYPES = { |
5 | 6 | 'actor': 0x0, |
6 | 7 | 'buf': 0x1, |
@@ -137,12 +138,13 @@ | ||
137 | 138 | types: [], |
138 | 139 | indexes: {}, |
139 | 140 | exports: {} |
140 | 141 | } |
141 | - const iterator = findSections(json) | |
142 | + | |
143 | + const wantedSections = ['custom', 'custom', 'type', 'import', 'function', 'export'] | |
144 | + const iterator = findSections(json, wantedSections) | |
142 | 145 | const mappedFuncs = new Map() |
143 | 146 | const mappedTypes = new Map() |
144 | - iterator.next() | |
145 | 147 | const {value: customType} = iterator.next('custom') |
146 | 148 | if (customType) { |
147 | 149 | const type = decodeType(customType.payload) |
148 | 150 | result.types = type |
@@ -175,31 +177,8 @@ | ||
175 | 177 | }) |
176 | 178 | return result |
177 | 179 | } |
178 | 180 | |
179 | -const wantedSections = new Set(['custom', 'type', 'function', 'export', 'import']) | |
180 | - | |
181 | -function * findSections (array) { | |
182 | - let section = array[0] | |
183 | - let index = 0 | |
184 | - let nextSection = yield null | |
185 | - | |
186 | - while (section) { | |
187 | - if (!wantedSections.has(section.name)) { | |
188 | - index++ | |
189 | - section = array[index] | |
190 | - } else { | |
191 | - if (section.name === nextSection) { | |
192 | - nextSection = yield section | |
193 | - index++ | |
194 | - section = array[index] | |
195 | - } else { | |
196 | - nextSection = yield null | |
197 | - } | |
198 | - } | |
199 | - } | |
200 | -} | |
201 | - | |
202 | 181 | module.exports = { |
203 | 182 | injectCustomSection, |
204 | 183 | inject, |
205 | 184 | decodeType, |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 344343 bytes New file size: 344343 bytes |
package.json | ||
---|---|---|
@@ -36,16 +36,15 @@ | ||
36 | 36 | "leb128": "0.0.4", |
37 | 37 | "levelup": "^2.0.1", |
38 | 38 | "reference-map": "^1.2.1", |
39 | 39 | "safe-buffer": "^5.1.1", |
40 | - "wasm-json-toolkit": "^0.2.0", | |
40 | + "wasm-json-toolkit": "^0.2.1", | |
41 | 41 | "wasm-metering": "^0.1.1" |
42 | 42 | }, |
43 | 43 | "devDependencies": { |
44 | 44 | "coveralls": "^3.0.0", |
45 | 45 | "dfinity-radix-tree": "0.0.9", |
46 | 46 | "documentation": "^5.3.5", |
47 | - "js-yaml": "^3.10.0", | |
48 | 47 | "level-browserify": "^1.1.1", |
49 | 48 | "nyc": "^11.4.1", |
50 | 49 | "primea-abstract-container": "0.0.6", |
51 | 50 | "standard": "10.0.3", |
tools/testTypeInfo.json | ||
---|---|---|
@@ -1,5 +1,6 @@ | ||
1 | 1 | { |
2 | + "globals": [3, 5, 6], | |
2 | 3 | "type": [{ |
3 | 4 | "form": "func", |
4 | 5 | "params": [ |
5 | 6 | "i32", |
typeCheckWrapper.js | ||
---|---|---|
@@ -1,7 +1,9 @@ | ||
1 | 1 | const LANGUAGE_TYPES = { |
2 | - 'actor': 0x0, | |
2 | + 'mod': 0x0, | |
3 | 3 | 'buf': 0x1, |
4 | + 'elem': 0x2, | |
5 | + 'link': 0x3, | |
4 | 6 | 'i32': 0x7f, |
5 | 7 | 'i64': 0x7e, |
6 | 8 | 'f32': 0x7d, |
7 | 9 | 'f64': 0x7c, |
@@ -9,9 +11,9 @@ | ||
9 | 11 | 'func': 0x60, |
10 | 12 | 'block_type': 0x40 |
11 | 13 | } |
12 | 14 | |
13 | -module.exports = function generateWrapper (type) { | |
15 | +module.exports = function (type) { | |
14 | 16 | const module = [{ |
15 | 17 | 'name': 'preramble', |
16 | 18 | 'magic': [ |
17 | 19 | 0, |
@@ -98,8 +100,9 @@ | ||
98 | 100 | 'locals': [], |
99 | 101 | 'code': [] |
100 | 102 | }] |
101 | 103 | }] |
104 | + | |
102 | 105 | const definedTypes = new Set(['actor', 'func', 'buf']) |
103 | 106 | const setGlobals = [] |
104 | 107 | const importType = module[1].entries[0].params |
105 | 108 | const checkType = module[1].entries[1].params |
wasmContainer.js | ||
---|---|---|
@@ -1,11 +1,11 @@ | ||
1 | 1 | const {wasm2json, json2wasm} = require('wasm-json-toolkit') |
2 | +const wasmMetering = require('wasm-metering') | |
3 | +const ReferanceMap = require('reference-map') | |
4 | +const leb128 = require('leb128') | |
2 | 5 | const Message = require('./message.js') |
3 | -const wasmMetering = require('wasm-metering') | |
4 | 6 | const customTypes = require('./customTypes.js') |
5 | 7 | const typeCheckWrapper = require('./typeCheckWrapper.js') |
6 | -const ReferanceMap = require('reference-map') | |
7 | -const leb128 = require('leb128') | |
8 | 8 | |
9 | 9 | const nativeTypes = new Set(['i32', 'i64', 'f32', 'f64']) |
10 | 10 | const LANGUAGE_TYPES = { |
11 | 11 | 'actor': 0x0, |
@@ -177,9 +177,9 @@ | ||
177 | 177 | const object = func.object |
178 | 178 | if (object) { |
179 | 179 | return self.refs.add(object) |
180 | 180 | } else { |
181 | - const ref = new FunctionRef(false, object.tableIndex, self.json, self.actor.id) | |
181 | + const ref = new FunctionRef('table', object.tableIndex, self.json, self.actor.id) | |
182 | 182 | return self.refs.add(ref) |
183 | 183 | } |
184 | 184 | }, |
185 | 185 | internalize: (ref, index) => { |
Built with git-ssb-web