Commit 2d5edf066ff154d5fc07115a7b1b66bcc2899f57
remove unused send messgae
wanderer committed on 1/23/2017, 8:18:15 PMParent: fe2d3d73d28c55f28860b137e3990bae31fbd26b
Files changed
index.js | changed |
message.js | changed |
vm.js | changed |
index.js | ||
---|---|---|
@@ -42,9 +42,9 @@ | ||
42 | 42 | * to by the VM to retrive infromation from the Environment. |
43 | 43 | */ |
44 | 44 | async run (message, imports = this.imports) { |
45 | 45 | const state = this.state.copy() |
46 | - const result = await this._vm.run(message, this, imports) | |
46 | + const result = await this._vm.run(message, this, imports, state) | |
47 | 47 | if (!result.execption) { |
48 | 48 | // update the state |
49 | 49 | this.state.set([], state) |
50 | 50 | } |
@@ -78,21 +78,21 @@ | ||
78 | 78 | const dest = await this.getPort(port) |
79 | 79 | return dest.recieve(message) |
80 | 80 | } |
81 | 81 | |
82 | - async getPort (port) { | |
83 | - if (this._instanceCache.has(port)) { | |
84 | - return this._instanceCache.get(port) | |
82 | + async getPort (name) { | |
83 | + if (this._instanceCache.has(name)) { | |
84 | + return this._instanceCache.get(name) | |
85 | 85 | } else { |
86 | 86 | const destState = await ( |
87 | - port === this.PARENT | |
87 | + name === this.PARENT | |
88 | 88 | ? this.state.getParent() |
89 | - : this.state.get([port])) | |
89 | + : this.state.get([name])) | |
90 | 90 | |
91 | 91 | const kernel = new Kernel({ |
92 | 92 | state: destState |
93 | 93 | }) |
94 | - this._instanceCache.set(port, kernel) | |
94 | + this._instanceCache.set(name, kernel) | |
95 | 95 | return kernel |
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
message.js | ||
---|---|---|
@@ -12,32 +12,31 @@ | ||
12 | 12 | gas: new U256(0), |
13 | 13 | gasPrices: new U256(0) |
14 | 14 | } |
15 | 15 | Object.assign(this, defaults, opts) |
16 | - this._index = 0 | |
17 | - this._parentProcesses = [] | |
16 | + this.hops = 0 | |
17 | + this._vistedAgents = [] | |
18 | 18 | } |
19 | 19 | |
20 | 20 | nextPort () { |
21 | - // this.from.push(message.toPort) | |
22 | - this.toPort = this.to[this._index] | |
23 | - this._index++ | |
21 | + this.toPort = this.to[this.hops] | |
22 | + this.hops++ | |
24 | 23 | return this.toPort |
25 | 24 | } |
26 | 25 | |
27 | 26 | finished () { |
28 | 27 | if (this.sync) { |
29 | - this._parentProcesses.pop() | |
28 | + this._vistedAgents.pop() | |
30 | 29 | } |
31 | 30 | } |
32 | 31 | |
33 | 32 | sending (kernel, parentMessage) { |
34 | 33 | if (this.sync && parentMessage) { |
35 | - this._parentProcesses = parentMessage._parentProcesses | |
36 | - this._parentProcesses.push(kernel) | |
34 | + this._vistedAgents = parentMessage._vistedAgents | |
35 | + this._vistedAgents.push(kernel) | |
37 | 36 | } |
38 | 37 | } |
39 | 38 | |
40 | 39 | isCyclic (kernel) { |
41 | - return this.sync && this._parentProcesses.some(process => process === kernel) | |
40 | + return this.sync && this._vistedAgents.some(process => process === kernel) | |
42 | 41 | } |
43 | 42 | } |
vm.js | ||
---|---|---|
@@ -8,27 +8,27 @@ | ||
8 | 8 | } |
9 | 9 | /** |
10 | 10 | * Runs the core VM with a given environment and imports |
11 | 11 | */ |
12 | - async run (message, kernel, imports) { | |
12 | + async run (message, kernel, imports, state) { | |
13 | 13 | const responses = {} |
14 | 14 | /** |
15 | 15 | * Builds a import map with an array of given interfaces |
16 | 16 | */ |
17 | 17 | async function buildImports (kernelApi, kernel, imports) { |
18 | - const result = {} | |
18 | + const importMap = {} | |
19 | 19 | for (const Import of imports) { |
20 | 20 | const response = responses[Import.name] = {} |
21 | - const newIterface = new Import(kernelApi, message, response) | |
22 | - result[Import.name] = newIterface.exports | |
21 | + const newIterface = new Import(kernelApi, message, response, state) | |
22 | + importMap[Import.name] = newIterface.exports | |
23 | 23 | // initailize the import |
24 | 24 | await newIterface.initialize() |
25 | 25 | } |
26 | - return result | |
26 | + return importMap | |
27 | 27 | } |
28 | 28 | |
29 | 29 | let instance |
30 | - const kernelApi = { | |
30 | + const interfaceApi = { | |
31 | 31 | /** |
32 | 32 | * adds an aync operation to the operations queue |
33 | 33 | */ |
34 | 34 | pushOpsQueue: (promise, callbackIndex, intefaceCallback) => { |
@@ -42,9 +42,9 @@ | ||
42 | 42 | }, |
43 | 43 | kernel: kernel |
44 | 44 | } |
45 | 45 | |
46 | - const initializedImports = await buildImports(kernelApi, kernel, imports) | |
46 | + const initializedImports = await buildImports(interfaceApi, kernel, imports) | |
47 | 47 | instance = WebAssembly.Instance(this._module, initializedImports) |
48 | 48 | |
49 | 49 | if (instance.exports.main) { |
50 | 50 | instance.exports.main() |
@@ -62,8 +62,5 @@ | ||
62 | 62 | prevOps = this._opsQueue |
63 | 63 | await this._opsQueue |
64 | 64 | } |
65 | 65 | } |
66 | - | |
67 | - sendMessage (message) { | |
68 | - } | |
69 | 66 | } |
Built with git-ssb-web