git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 2d5edf066ff154d5fc07115a7b1b66bcc2899f57

remove unused send messgae

wanderer committed on 1/23/2017, 8:18:15 PM
Parent: fe2d3d73d28c55f28860b137e3990bae31fbd26b

Files changed

index.jschanged
message.jschanged
vm.jschanged
index.jsView
@@ -42,9 +42,9 @@
4242 * to by the VM to retrive infromation from the Environment.
4343 */
4444 async run (message, imports = this.imports) {
4545 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)
4747 if (!result.execption) {
4848 // update the state
4949 this.state.set([], state)
5050 }
@@ -78,21 +78,21 @@
7878 const dest = await this.getPort(port)
7979 return dest.recieve(message)
8080 }
8181
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)
8585 } else {
8686 const destState = await (
87- port === this.PARENT
87+ name === this.PARENT
8888 ? this.state.getParent()
89- : this.state.get([port]))
89+ : this.state.get([name]))
9090
9191 const kernel = new Kernel({
9292 state: destState
9393 })
94- this._instanceCache.set(port, kernel)
94+ this._instanceCache.set(name, kernel)
9595 return kernel
9696 }
9797 }
9898 }
message.jsView
@@ -12,32 +12,31 @@
1212 gas: new U256(0),
1313 gasPrices: new U256(0)
1414 }
1515 Object.assign(this, defaults, opts)
16- this._index = 0
17- this._parentProcesses = []
16+ this.hops = 0
17+ this._vistedAgents = []
1818 }
1919
2020 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++
2423 return this.toPort
2524 }
2625
2726 finished () {
2827 if (this.sync) {
29- this._parentProcesses.pop()
28+ this._vistedAgents.pop()
3029 }
3130 }
3231
3332 sending (kernel, parentMessage) {
3433 if (this.sync && parentMessage) {
35- this._parentProcesses = parentMessage._parentProcesses
36- this._parentProcesses.push(kernel)
34+ this._vistedAgents = parentMessage._vistedAgents
35+ this._vistedAgents.push(kernel)
3736 }
3837 }
3938
4039 isCyclic (kernel) {
41- return this.sync && this._parentProcesses.some(process => process === kernel)
40+ return this.sync && this._vistedAgents.some(process => process === kernel)
4241 }
4342 }
vm.jsView
@@ -8,27 +8,27 @@
88 }
99 /**
1010 * Runs the core VM with a given environment and imports
1111 */
12- async run (message, kernel, imports) {
12+ async run (message, kernel, imports, state) {
1313 const responses = {}
1414 /**
1515 * Builds a import map with an array of given interfaces
1616 */
1717 async function buildImports (kernelApi, kernel, imports) {
18- const result = {}
18+ const importMap = {}
1919 for (const Import of imports) {
2020 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
2323 // initailize the import
2424 await newIterface.initialize()
2525 }
26- return result
26+ return importMap
2727 }
2828
2929 let instance
30- const kernelApi = {
30+ const interfaceApi = {
3131 /**
3232 * adds an aync operation to the operations queue
3333 */
3434 pushOpsQueue: (promise, callbackIndex, intefaceCallback) => {
@@ -42,9 +42,9 @@
4242 },
4343 kernel: kernel
4444 }
4545
46- const initializedImports = await buildImports(kernelApi, kernel, imports)
46+ const initializedImports = await buildImports(interfaceApi, kernel, imports)
4747 instance = WebAssembly.Instance(this._module, initializedImports)
4848
4949 if (instance.exports.main) {
5050 instance.exports.main()
@@ -62,8 +62,5 @@
6262 prevOps = this._opsQueue
6363 await this._opsQueue
6464 }
6565 }
66-
67- sendMessage (message) {
68- }
6966 }

Built with git-ssb-web