Commit 53fa2cb6dbb5833d412e128716f96fe637b40738
use lang defs from annotation module
wanderer committed on 3/21/2018, 7:45:27 PMParent: 891456b4ce75b2fdc83622388dc0ebf2837835cc
Files changed
package-lock.json | changed |
package.json | changed |
tests/wasm/caller.wasm | changed |
tests/wasm/funcRef_caller.wasm | changed |
tests/wasm/funcRef_reciever.wasm | changed |
tests/wasm/globals.wasm | changed |
tests/wasm/private_caller.wasm | changed |
typeCheckWrapper.js | changed |
wasmContainer.js | changed |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 369684 bytes New file size: 369221 bytes |
package.json | ||
---|---|---|
@@ -32,9 +32,9 @@ | ||
32 | 32 | "dependencies": { |
33 | 33 | "binary-search-insert": "^1.0.3", |
34 | 34 | "borc": "^2.0.2", |
35 | 35 | "events": "^2.0.0", |
36 | - "primea-annotations": "0.0.0", | |
36 | + "primea-annotations": "0.0.1", | |
37 | 37 | "reference-map": "^1.2.3", |
38 | 38 | "safe-buffer": "^5.1.1", |
39 | 39 | "wasm-json-toolkit": "^0.2.3", |
40 | 40 | "wasm-metering": "^0.1.1" |
tests/wasm/caller.wasm | ||
---|---|---|
@@ -1,3 +1,3 @@ | ||
1 | - asm types`` typeMap | |
1 | + asm types`n typeMap | |
2 | 2 | ` ` funcinternalize ptable call |
3 | 3 | A A A |
tests/wasm/funcRef_caller.wasm | ||
---|---|---|
@@ -1,2 +1,2 @@ | ||
1 | - asm types`` typeMap ` ` `` Tfuncinternalize testcheck moduleself moduleexport memoryexternalize p $memory table call callback | |
1 | + asm types`n typeMap ` ` `` Tfuncinternalize testcheck moduleself moduleexport memoryexternalize p $memory table call callback | |
2 | 2 | " A AA A A A callback |
tests/wasm/funcRef_reciever.wasm | ||
---|---|---|
@@ -1,3 +1,3 @@ | ||
1 | - asm types`` typeMap | |
1 | + asm types`n typeMap | |
2 | 2 | ` ` *funcinternalize funcset_gas_budget ptable receive |
3 | 3 | A�� A AA |
tests/wasm/globals.wasm | ||
---|---|---|
@@ -1,4 +1,4 @@ | ||
1 | - asm persist n`` ` +memoryexternalize memoryinternalize A~A~memory load store | |
1 | + asm persist m`` ` +memoryexternalize memoryinternalize A~A~memory load store | |
2 | 2 | |
3 | 3 | A A $ # A AA |
4 | 4 | A test |
tests/wasm/private_caller.wasm | ||
---|---|---|
@@ -1,2 +1,2 @@ | ||
1 | - asm types`` typeMap ` `` 4funcinternalize funcexternalize testcheck p memory table call A | |
1 | + asm types`n typeMap ` `` 4funcinternalize funcexternalize testcheck p memory table call A | |
2 | 2 | A A A A |
typeCheckWrapper.js | ||
---|---|---|
@@ -1,17 +1,5 @@ | ||
1 | -const LANGUAGE_TYPES = { | |
2 | - 'mod': 0x0, | |
3 | - 'buf': 0x1, | |
4 | - 'elem': 0x2, | |
5 | - 'link': 0x3, | |
6 | - 'i32': 0x7f, | |
7 | - 'i64': 0x7e, | |
8 | - 'f32': 0x7d, | |
9 | - 'f64': 0x7c, | |
10 | - 'anyFunc': 0x70, | |
11 | - 'func': 0x60, | |
12 | - 'block_type': 0x40 | |
13 | -} | |
1 | +const {LANGUAGE_TYPES_STRG} = require('primea-annotations') | |
14 | 2 | |
15 | 3 | module.exports = function (params) { |
16 | 4 | const module = [{ |
17 | 5 | 'name': 'preramble', |
@@ -112,9 +100,9 @@ | ||
112 | 100 | const invokeCode = module[7].entries[1].code |
113 | 101 | |
114 | 102 | params.forEach((param, index) => { |
115 | 103 | let baseType = param |
116 | - const typeCode = LANGUAGE_TYPES[param] | |
104 | + const typeCode = LANGUAGE_TYPES_STRG[param] | |
117 | 105 | // import type |
118 | 106 | if (definedTypes.has(param)) { |
119 | 107 | baseType = 'i32' |
120 | 108 | } else { |
wasmContainer.js | ||
---|---|---|
@@ -2,28 +2,13 @@ | ||
2 | 2 | const annotations = require('primea-annotations') |
3 | 3 | const wasmMetering = require('wasm-metering') |
4 | 4 | const ReferanceMap = require('reference-map') |
5 | 5 | const Message = require('./message.js') |
6 | -// const customTypes = require('./customTypes.js') | |
7 | 6 | const injectGlobals = require('./injectGlobals.js') |
8 | 7 | const typeCheckWrapper = require('./typeCheckWrapper.js') |
9 | 8 | const {FunctionRef, ModuleRef, DEFAULTS} = require('./systemObjects.js') |
10 | 9 | |
11 | 10 | const nativeTypes = new Set(['i32', 'i64', 'f32', 'f64']) |
12 | -const LANGUAGE_TYPES = { | |
13 | - 0x0: 'actor', | |
14 | - 0x1: 'data', | |
15 | - 0x02: 'elem', | |
16 | - 0x03: 'link', | |
17 | - 0x04: 'id', | |
18 | - 0x7f: 'i32', | |
19 | - 0x7e: 'i64', | |
20 | - 0x7d: 'f32', | |
21 | - 0x7c: 'f64', | |
22 | - 0x70: 'anyFunc', | |
23 | - 0x60: 'func', | |
24 | - 0x40: 'block_type' | |
25 | -} | |
26 | 11 | const FUNC_INDEX_OFFSET = 1 |
27 | 12 | |
28 | 13 | function generateWrapper (funcRef, container) { |
29 | 14 | let wrapper = typeCheckWrapper(funcRef.params) |
@@ -35,9 +20,9 @@ | ||
35 | 20 | 'checkTypes': function () { |
36 | 21 | const args = [...arguments] |
37 | 22 | const checkedArgs = [] |
38 | 23 | while (args.length) { |
39 | - const type = LANGUAGE_TYPES[args.shift()] | |
24 | + const type = annotations.LANGUAGE_TYPES_BIN[args.shift()] | |
40 | 25 | let arg = args.shift() |
41 | 26 | if (!nativeTypes.has(type)) { |
42 | 27 | arg = container.refs.get(arg, type) |
43 | 28 | } |
Built with git-ssb-web