Add an accessor for the function table

This commit adds an intrinsics to the `wasm_bindgen` crate which
accesses the `WebAssembly.Table` which is the function table of the
module. Eventually the thinking is that a module would import its own
function table via native wasm functionality (via `anyref` and such),
but until that's implemented let's add a binding for it ourselves!

Closes #1427
This commit is contained in:
Alex Crichton
2019-04-08 07:43:38 -07:00
parent a9a23020c4
commit 7e5e401076
4 changed files with 33 additions and 0 deletions

View File

@ -55,3 +55,9 @@ exports.debug_values = () => ([
() => (null),
new Set(),
]);
exports.assert_function_table = (x, i) => {
const rawWasm = require('wasm-bindgen-test_bg.js');
assert.ok(x instanceof WebAssembly.Table);
assert.strictEqual(x.get(i), rawWasm.function_table_lookup);
};