git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 643fe1d2f37714b0ada02a671a4c74924ce8437e

updated shim to work with new JS api

wanderer committed on 9/13/2016, 4:00:14 AM
Parent: 93aaefe3bbdce6e21ef81eb50b106062b13f5b9f

Files changed

index.jschanged
interface.jschanged
index.jsView
@@ -44,9 +44,9 @@
4444 // otherwise execution succeeded
4545 codeHandler (code, ethInterface = new Interface(new Environment())) {
4646 const debugInterface = new DebugInterface(ethInterface.environment)
4747 const module = WebAssembly.Module(code)
48- const instance = WebAssembly.Instance(module, {
48+ const imports = {
4949 'ethereum': ethInterface.exportTable,
5050 'debug': debugInterface.exportTable,
5151
5252 // export this for Rust
@@ -55,9 +55,12 @@
5555
5656 // export this for Binaryen
5757 // FIXME: remove once C has proper imports, see https://github.com/ethereum/evm2.0-design/issues/16
5858 'env': ethInterface.exportTable
59- })
59+ }
60+ // add shims
61+ imports.ethereum.useGas = ethInterface.shims.exports.useGas
62+ const instance = WebAssembly.Instance(module, imports)
6063
6164 ethInterface.setModule(instance)
6265 debugInterface.setModule(instance)
6366
interface.jsView
@@ -16,21 +16,19 @@
1616 constructor (environment) {
1717 this.environment = environment
1818 const shimBin = fs.readFileSync(path.join(__dirname, '/wasm/interface.wasm'))
1919 const shimMod = WebAssembly.Module(shimBin)
20- const shim = WebAssembly.Instance(shimMod, {
20+ const shims = WebAssembly.Instance(shimMod, {
2121 'interface': {
2222 'useGas': this._useGas.bind(this)
2323 }
2424 })
25- this.useGas = shim.exports.useGas
26- // this.useGas = this._useGas
25+ this.shims = shims
2726 }
2827
2928 get exportTable () {
3029 let exportMethods = [
3130 // include all the public methods according to the Ethereum Environment Interface (EEI) r1
32- 'useGas',
3331 'getGasLeft',
3432 'getAddress',
3533 'getBalance',
3634 'getTxOrigin',

Built with git-ssb-web