Commit 7feb7c9fd152c9b122c6ee9ec57387c444a89541
wasm container stub
Signed-off-by: wanderer <mjbecze@gmail.com>wanderer committed on 1/20/2018, 1:39:10 AM
Parent: 4c6125763fffeac43ae5302bb5541ac7f124c0a3
Files changed
index.js | changed |
package-lock.json | changed |
package.json | changed |
tests/index.js | changed |
tests/wasm/addTwo.wasm | added |
tests/wasmContainer.js | added |
tests/wast/addTwo.wast | added |
typeEncoding.md | added |
index.js | ||
---|---|---|
@@ -67,20 +67,19 @@ | ||
67 | 67 | * @param {Object} message - an intial [message](https://github.com/primea/js-primea-message) to send newly created actor |
68 | 68 | * @param {Object} id - the id for the actor |
69 | 69 | */ |
70 | 70 | async createActor (type, code, id = {nonce: this.nonce++, parent: null}) { |
71 | + const Container = this._containerTypes[type] | |
72 | + await Container.validate(code) | |
71 | 73 | const encoded = encodedID(id) |
72 | 74 | const idHash = await this._getHashFromObj(encoded) |
73 | 75 | const metaData = Actor.serializeMetaData(type) |
74 | 76 | |
75 | 77 | // save the container in the state |
76 | 78 | this.tree.set(idHash, metaData) |
77 | - const Container = this._containerTypes[type] | |
78 | - await Container.validate(code) | |
79 | - const module = await Container.compile(code) | |
80 | 79 | return { |
81 | 80 | id: idHash, |
82 | - exports: Container.exports(module, idHash) | |
81 | + exports: Container.exports(code, idHash) | |
83 | 82 | } |
84 | 83 | } |
85 | 84 | |
86 | 85 | // get a hash from a POJO |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 341239 bytes New file size: 341658 bytes |
package.json | ||
---|---|---|
@@ -36,9 +36,10 @@ | ||
36 | 36 | "events": "^1.1.1", |
37 | 37 | "leb128": "0.0.4", |
38 | 38 | "safe-buffer": "^5.1.1", |
39 | 39 | "sortedmap": "0.0.1", |
40 | - "typedarray-addition": "0.0.1" | |
40 | + "typedarray-addition": "0.0.1", | |
41 | + "wasm-json-toolkit": "^0.2.0" | |
41 | 42 | }, |
42 | 43 | "devDependencies": { |
43 | 44 | "coveralls": "^3.0.0", |
44 | 45 | "dfinity-radix-tree": "0.0.9", |
tests/index.js | ||
---|---|---|
@@ -7,9 +7,8 @@ | ||
7 | 7 | const db = level('./testdb') |
8 | 8 | |
9 | 9 | class BaseContainer { |
10 | 10 | static validate () {} |
11 | - static compile () {} | |
12 | 11 | static get typeId () { |
13 | 12 | return 9 |
14 | 13 | } |
15 | 14 |
tests/wasmContainer.js | ||
---|---|---|
@@ -1,0 +1,15 @@ | ||
1 | +const fs = require('fs') | |
2 | +const tape = require('tape') | |
3 | +const WasmContainer = require('../wasmContainer.js') | |
4 | +// const Message = require('../message.js') | |
5 | +// const Hypervisor = require('../') | |
6 | + | |
7 | +// const level = require('level-browserify') | |
8 | +// const RadixTree = require('dfinity-radix-tree') | |
9 | +// const db = level('./testdb') | |
10 | +tape('basic', async t => { | |
11 | + const addTwoBin = fs.readFileSync(`${__dirname}/wasm/addTwo.wasm`) | |
12 | + const exports = WasmContainer.actorRef(addTwoBin, 'test') | |
13 | + console.log(exports) | |
14 | + t.end() | |
15 | +}) |
Built with git-ssb-web