git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 277b81fa0326007d061917f6ea1efa15f8ad5392

docs

wanderer committed on 11/5/2016, 11:07:58 AM
Parent: 4deaaf0620b832ca0e463a1327d1d7d0ee6c8d6e

Files changed

index.jschanged
index.jsView
@@ -1,25 +1,10 @@
1-/**
2- * This implements the Kernel
3- * Kernels must implement two methods `codeHandler` and `callHandler` (and `linkHandler` for sharding)
4- * The Kernel Contract handles the following
5- * - Interprocess communications
6- * - Intializing the VM and exposes ROM to it (codeHandler)
7- * - Expose namespace which VM instance exists and Intializes the Environment (callHandler)
8- * - Provides some built in contract (runTx, runBlock)
9- * - Provides resource sharing and limiting via gas
10- *
11- * All State should be stored in the Environment.
12- */
13-
141 const Vertex = require('./deps/kernelVertex')
152 // The Kernel Exposes this Interface to VM instances it makes
163 const Interface = require('./interface.js')
174 const InterfaceAPI = require('./interfaceAPI.js')
5+const Environment = require('./environment.js')
186
19-// The Kernel Stores all of its state in the Environment. The Interface is used
20-// to by the VM to retrive infromation from the Environment.
21-const Environment = require('./environment.js')
227 module.exports = class Kernel {
238 constructor (opts = {}) {
249 this.state = opts.state || new Vertex()
2510 this.parent = opts.parent
@@ -29,16 +14,23 @@
2914 }
3015 this.imports = this.buildImports(opts.interfaces)
3116 }
3217
18+ /**
19+ * Builds a import map with an array of given interfaces
20+ */
3321 buildImports (interfaces = [Interface]) {
3422 return interfaces.reduce((obj, Interface) => {
3523 obj[Interface.name] = new Interface(this.interfaceAPI).exports
3624 return obj
3725 }, {})
3826 }
3927
40- // run the kernels code with a given enviroment
28+ /**
29+ * run the kernels code with a given enviroment
30+ * The Kernel Stores all of its state in the Environment. The Interface is used
31+ * to by the VM to retrive infromation from the Environment.
32+ */
4133 async run (environment = new Environment({state: this.state}), imports = this.imports) {
4234 await this.interfaceAPI.run(environment, imports)
4335 return environment
4436 }

Built with git-ssb-web