git ssb

0+

wanderer🌟 / js-primea-hypervisor



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.jschanged
package-lock.jsonchanged
package.jsonchanged
tests/index.jschanged
tests/wasm/addTwo.wasmadded
tests/wasmContainer.jsadded
tests/wast/addTwo.wastadded
typeEncoding.mdadded
index.jsView
@@ -67,20 +67,19 @@
6767 * @param {Object} message - an intial [message](https://github.com/primea/js-primea-message) to send newly created actor
6868 * @param {Object} id - the id for the actor
6969 */
7070 async createActor (type, code, id = {nonce: this.nonce++, parent: null}) {
71+ const Container = this._containerTypes[type]
72+ await Container.validate(code)
7173 const encoded = encodedID(id)
7274 const idHash = await this._getHashFromObj(encoded)
7375 const metaData = Actor.serializeMetaData(type)
7476
7577 // save the container in the state
7678 this.tree.set(idHash, metaData)
77- const Container = this._containerTypes[type]
78- await Container.validate(code)
79- const module = await Container.compile(code)
8079 return {
8180 id: idHash,
82- exports: Container.exports(module, idHash)
81+ exports: Container.exports(code, idHash)
8382 }
8483 }
8584
8685 // get a hash from a POJO
package-lock.jsonView
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.jsonView
@@ -36,9 +36,10 @@
3636 "events": "^1.1.1",
3737 "leb128": "0.0.4",
3838 "safe-buffer": "^5.1.1",
3939 "sortedmap": "0.0.1",
40- "typedarray-addition": "0.0.1"
40+ "typedarray-addition": "0.0.1",
41+ "wasm-json-toolkit": "^0.2.0"
4142 },
4243 "devDependencies": {
4344 "coveralls": "^3.0.0",
4445 "dfinity-radix-tree": "0.0.9",
tests/index.jsView
@@ -7,9 +7,8 @@
77 const db = level('./testdb')
88
99 class BaseContainer {
1010 static validate () {}
11- static compile () {}
1211 static get typeId () {
1312 return 9
1413 }
1514
tests/wasm/addTwo.wasmView
@@ -1,0 +1,4 @@
1+asm`
2+addTwo
3+
4+ j
tests/wasmContainer.jsView
@@ -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+})
tests/wast/addTwo.wastView
@@ -1,0 +1,8 @@
1+(module
2+ (func $addTwo (param i32 i32)
3+ get_local 0
4+ get_local 1
5+ i32.add
6+ drop
7+ )
8+ (export "addTwo" (func $addTwo)))
typeEncoding.mdView
@@ -1,0 +1,5 @@
1+func = 0
2+buf = 1
3+actor = 1
4+
5+customTypeToFunc = count: i32, [funcIndex, CustomtypeIndex]

Built with git-ssb-web