Simplifying the error handling code

This commit is contained in:
Pauan
2019-02-04 02:08:08 +01:00
parent 9f00664d81
commit e4294babeb
2 changed files with 20 additions and 10 deletions

View File

@ -1546,6 +1546,23 @@ impl<'a> Context<'a> {
));
}
fn expose_handle_error(&mut self) {
if !self.should_write_global("handle_error") {
return;
}
self.expose_uint32_memory();
self.expose_add_heap_object();
self.global(
"
function handleError(exnptr, e) {
const view = getUint32Memory();
view[exnptr / 4] = 1;
view[exnptr / 4 + 1] = addHeapObject(e);
}
",
);
}
fn wasm_import_needed(&self, name: &str) -> bool {
let imports = match self.module.import_section() {
Some(s) => s,