Add an accessor for wasm's own memory as a JS object

In addition to closing #495 this'll be useful eventually when instantiating
multiple wasm modules from Rust as you'd now be able to acquire a reference to
the current module in Rust itself.
This commit is contained in:
Alex Crichton
2018-08-21 10:42:52 -07:00
parent 85fd49f90a
commit e1474110d4
5 changed files with 40 additions and 1 deletions

View File

@ -380,6 +380,18 @@ impl<'a> Context<'a> {
))
})?;
self.bind("__wbindgen_memory", &|me| {
me.expose_add_heap_object();
let mem = me.memory();
Ok(format!(
"
function() {{
return addHeapObject({});
}}
", mem
))
})?;
self.create_memory_export();
self.unexport_unused_internal_exports();
self.gc()?;