git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit fc3efb6d1a8e5ef2e4cbd0017fa9649b221b8793

added system objects

Signed-off-by: wanderer <mjbecze@gmail.com>
wanderer committed on 2/28/2018, 9:04:23 PM
Parent: 7c6e94b073aaac86243093e7d533ecd1cbdb587d

Files changed

wasmContainer.jschanged
systemObjects.jsadded
wasmContainer.jsView
@@ -4,27 +4,10 @@
44 const Message = require('./message.js')
55 const customTypes = require('./customTypes.js')
66 const injectGlobals = require('./injectGlobals.js')
77 const typeCheckWrapper = require('./typeCheckWrapper.js')
8-const {FunctionRef} = require('./systemObjects.js')
9-const cbor = require('borc')
8+const {FunctionRef, ModuleRef, DEFAULTS} = require('./systemObjects.js')
109
11-const TAGS = {
12- link: 42,
13- id: 43,
14- func: 43,
15- mod: 44
16-}
17-
18-const DEFAULTS = {
19- elem: [],
20- buf: Buffer.from([]),
21- id: new cbor.Tagged(TAGS.id, 0),
22- mod: new cbor.Tagged(TAGS.mod, [{}, new cbor.Tagged(TAGS.id, 0)]),
23- link: {'/': null},
24- func: new cbor.Tagged(TAGS.func, 0)
25-}
26-
2710 const nativeTypes = new Set(['i32', 'i64', 'f32', 'f64'])
2811 const LANGUAGE_TYPES = {
2912 'actor': 0x0,
3013 'buf': 0x1,
@@ -82,34 +65,8 @@
8265 wrapper.exports.check.object = funcRef
8366 return wrapper
8467 }
8568
86-class ModuleRef {
87- constructor (ex, id) {
88- this.exports = ex
89- this.id = id
90- }
91-
92- getFuncRef (name) {
93- return new FunctionRef(false, name, this.exports[name], this.id)
94- }
95-
96- encodeCBOR (gen) {
97- return gen.write(new cbor.Tagged(TAGS.mod, [this.exports, new cbor.Tagged(TAGS.id, this.id)]))
98- }
99-
100- static fromMetaJSON (json, id) {
101- const exports = {}
102- for (const ex in json.exports) {
103- const type = json.types[json.indexes[json.exports[ex].toString()]].params
104- exports[ex] = type
105- }
106- return new ModuleRef(exports, id)
107- }
108-
109- static deserialize (serialized) {}
110-}
111-
11269 module.exports = class WasmContainer {
11370 constructor (actor) {
11471 this.actor = actor
11572 this.refs = new ReferanceMap()
systemObjects.jsView
@@ -1,0 +1,82 @@
1+const cbor = require('borc')
2+
3+const TAGS = {
4+ link: 42,
5+ id: 43,
6+ func: 43,
7+ mod: 44
8+}
9+
10+const DEFAULTS = {
11+ elem: [],
12+ buf: Buffer.from([]),
13+ id: new cbor.Tagged(TAGS.id, 0),
14+ mod: new cbor.Tagged(TAGS.mod, [{}, new cbor.Tagged(TAGS.id, 0)]),
15+ link: {'/': null},
16+ func: new cbor.Tagged(TAGS.func, 0)
17+}
18+
19+class FunctionRef {
20+ constructor (privateFunc, identifier, params, id) {
21+ this.private = privateFunc
22+ this.identifier = identifier
23+ this.destId = id
24+ this.params = params
25+ }
26+
27+ encodeCBOR (gen) {
28+ return gen.write(new cbor.Tagged(TAGS.func, [
29+ this.private,
30+ this.identifier,
31+ this.destId,
32+ this.params
33+ ]))
34+ }
35+
36+ set container (container) {
37+ this._container = container
38+ }
39+}
40+
41+class ModuleRef {
42+ constructor (ex, id) {
43+ this.exports = ex
44+ this.id = id
45+ }
46+
47+ getFuncRef (name) {
48+ return new FunctionRef(false, name, this.exports[name], this.id)
49+ }
50+
51+ encodeCBOR (gen) {
52+ return gen.write(new cbor.Tagged(TAGS.mod, [this.exports, this.id]))
53+ }
54+
55+ static fromMetaJSON (json, id) {
56+ const exports = {}
57+ for (const ex in json.exports) {
58+ const type = json.types[json.indexes[json.exports[ex].toString()]].params
59+ exports[ex] = type
60+ }
61+ return new ModuleRef(exports, id)
62+ }
63+
64+ static deserialize (serialized) {}
65+}
66+
67+class ID {
68+ constructor (id) {
69+ this.id = id
70+ }
71+
72+ encodeCBOR (gen) {
73+ return gen.write(cbor.Tagged(TAGS.id, this.id))
74+ }
75+}
76+
77+module.exports = {
78+ ID,
79+ FunctionRef,
80+ ModuleRef,
81+ DEFAULTS
82+}

Built with git-ssb-web