Commit 643fe1d2f37714b0ada02a671a4c74924ce8437e
updated shim to work with new JS api
wanderer committed on 9/13/2016, 4:00:14 AMParent: 93aaefe3bbdce6e21ef81eb50b106062b13f5b9f
Files changed
index.js | changed |
interface.js | changed |
index.js | ||
---|---|---|
@@ -44,9 +44,9 @@ | ||
44 | 44 | // otherwise execution succeeded |
45 | 45 | codeHandler (code, ethInterface = new Interface(new Environment())) { |
46 | 46 | const debugInterface = new DebugInterface(ethInterface.environment) |
47 | 47 | const module = WebAssembly.Module(code) |
48 | - const instance = WebAssembly.Instance(module, { | |
48 | + const imports = { | |
49 | 49 | 'ethereum': ethInterface.exportTable, |
50 | 50 | 'debug': debugInterface.exportTable, |
51 | 51 | |
52 | 52 | // export this for Rust |
@@ -55,9 +55,12 @@ | ||
55 | 55 | |
56 | 56 | // export this for Binaryen |
57 | 57 | // FIXME: remove once C has proper imports, see https://github.com/ethereum/evm2.0-design/issues/16 |
58 | 58 | 'env': ethInterface.exportTable |
59 | - }) | |
59 | + } | |
60 | + // add shims | |
61 | + imports.ethereum.useGas = ethInterface.shims.exports.useGas | |
62 | + const instance = WebAssembly.Instance(module, imports) | |
60 | 63 | |
61 | 64 | ethInterface.setModule(instance) |
62 | 65 | debugInterface.setModule(instance) |
63 | 66 |
interface.js | ||
---|---|---|
@@ -16,21 +16,19 @@ | ||
16 | 16 | constructor (environment) { |
17 | 17 | this.environment = environment |
18 | 18 | const shimBin = fs.readFileSync(path.join(__dirname, '/wasm/interface.wasm')) |
19 | 19 | const shimMod = WebAssembly.Module(shimBin) |
20 | - const shim = WebAssembly.Instance(shimMod, { | |
20 | + const shims = WebAssembly.Instance(shimMod, { | |
21 | 21 | 'interface': { |
22 | 22 | 'useGas': this._useGas.bind(this) |
23 | 23 | } |
24 | 24 | }) |
25 | - this.useGas = shim.exports.useGas | |
26 | - // this.useGas = this._useGas | |
25 | + this.shims = shims | |
27 | 26 | } |
28 | 27 | |
29 | 28 | get exportTable () { |
30 | 29 | let exportMethods = [ |
31 | 30 | // include all the public methods according to the Ethereum Environment Interface (EEI) r1 |
32 | - 'useGas', | |
33 | 31 | 'getGasLeft', |
34 | 32 | 'getAddress', |
35 | 33 | 'getBalance', |
36 | 34 | 'getTxOrigin', |
Built with git-ssb-web