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

@ -783,6 +783,14 @@ impl<'a> Context<'a> {
))
})?;
self.bind("__wbindgen_function_table", &|me| {
me.function_table_needed = true;
Ok(format!(
"function() {{ return {}; }}",
me.add_heap_object("wasm.__wbg_function_table")
))
})?;
self.bind("__wbindgen_rethrow", &|me| {
Ok(format!(
"function(idx) {{ throw {}; }}",