git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit b9cefb81b38fc031f3179fbfff55dfd7fa8596a6

move find iterator to toolkit

wanderer committed on 2/16/2018, 1:07:19 AM
Parent: c1baf026f5fba05cb5619603b350445d6e40a0d5

Files changed

customTypes.jschanged
package-lock.jsonchanged
package.jsonchanged
tools/testTypeInfo.jsonchanged
typeCheckWrapper.jschanged
wasmContainer.jschanged
customTypes.jsView
@@ -1,6 +1,7 @@
11 const Stream = require('buffer-pipe')
22 const leb = require('leb128')
3+const {findSections} = require('wasm-json-toolkit')
34
45 const LANGUAGE_TYPES = {
56 'actor': 0x0,
67 'buf': 0x1,
@@ -137,12 +138,13 @@
137138 types: [],
138139 indexes: {},
139140 exports: {}
140141 }
141- const iterator = findSections(json)
142+
143+ const wantedSections = ['custom', 'custom', 'type', 'import', 'function', 'export']
144+ const iterator = findSections(json, wantedSections)
142145 const mappedFuncs = new Map()
143146 const mappedTypes = new Map()
144- iterator.next()
145147 const {value: customType} = iterator.next('custom')
146148 if (customType) {
147149 const type = decodeType(customType.payload)
148150 result.types = type
@@ -175,31 +177,8 @@
175177 })
176178 return result
177179 }
178180
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-
202181 module.exports = {
203182 injectCustomSection,
204183 inject,
205184 decodeType,
package-lock.jsonView
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.jsonView
@@ -36,16 +36,15 @@
3636 "leb128": "0.0.4",
3737 "levelup": "^2.0.1",
3838 "reference-map": "^1.2.1",
3939 "safe-buffer": "^5.1.1",
40- "wasm-json-toolkit": "^0.2.0",
40+ "wasm-json-toolkit": "^0.2.1",
4141 "wasm-metering": "^0.1.1"
4242 },
4343 "devDependencies": {
4444 "coveralls": "^3.0.0",
4545 "dfinity-radix-tree": "0.0.9",
4646 "documentation": "^5.3.5",
47- "js-yaml": "^3.10.0",
4847 "level-browserify": "^1.1.1",
4948 "nyc": "^11.4.1",
5049 "primea-abstract-container": "0.0.6",
5150 "standard": "10.0.3",
tools/testTypeInfo.jsonView
@@ -1,5 +1,6 @@
11 {
2+ "globals": [3, 5, 6],
23 "type": [{
34 "form": "func",
45 "params": [
56 "i32",
typeCheckWrapper.jsView
@@ -1,7 +1,9 @@
11 const LANGUAGE_TYPES = {
2- 'actor': 0x0,
2+ 'mod': 0x0,
33 'buf': 0x1,
4+ 'elem': 0x2,
5+ 'link': 0x3,
46 'i32': 0x7f,
57 'i64': 0x7e,
68 'f32': 0x7d,
79 'f64': 0x7c,
@@ -9,9 +11,9 @@
911 'func': 0x60,
1012 'block_type': 0x40
1113 }
1214
13-module.exports = function generateWrapper (type) {
15+module.exports = function (type) {
1416 const module = [{
1517 'name': 'preramble',
1618 'magic': [
1719 0,
@@ -98,8 +100,9 @@
98100 'locals': [],
99101 'code': []
100102 }]
101103 }]
104+
102105 const definedTypes = new Set(['actor', 'func', 'buf'])
103106 const setGlobals = []
104107 const importType = module[1].entries[0].params
105108 const checkType = module[1].entries[1].params
wasmContainer.jsView
@@ -1,11 +1,11 @@
11 const {wasm2json, json2wasm} = require('wasm-json-toolkit')
2+const wasmMetering = require('wasm-metering')
3+const ReferanceMap = require('reference-map')
4+const leb128 = require('leb128')
25 const Message = require('./message.js')
3-const wasmMetering = require('wasm-metering')
46 const customTypes = require('./customTypes.js')
57 const typeCheckWrapper = require('./typeCheckWrapper.js')
6-const ReferanceMap = require('reference-map')
7-const leb128 = require('leb128')
88
99 const nativeTypes = new Set(['i32', 'i64', 'f32', 'f64'])
1010 const LANGUAGE_TYPES = {
1111 'actor': 0x0,
@@ -177,9 +177,9 @@
177177 const object = func.object
178178 if (object) {
179179 return self.refs.add(object)
180180 } 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)
182182 return self.refs.add(ref)
183183 }
184184 },
185185 internalize: (ref, index) => {

Built with git-ssb-web