Improving the code generation for catch (#2098)

* Improving the code generation for catch

* Fixing newlines

* Running rustfmt

* Updating unit tests

* Fixing build error
This commit is contained in:
Pauan
2020-04-22 16:14:00 +02:00
committed by GitHub
parent a93b778b5c
commit 7bc9147258
4 changed files with 84 additions and 40 deletions

View File

@@ -24,9 +24,16 @@ function addToAnyrefTable0(obj) {
return idx;
}
function handleError(e) {
const idx = addToAnyrefTable0(e);
wasm.__wbindgen_exn_store(idx);
function handleError(f) {
return function () {
try {
return f.apply(this, arguments);
} catch (e) {
const idx = addToAnyrefTable0(e);
wasm.__wbindgen_exn_store(idx);
}
};
}
/**
*/
@@ -34,13 +41,9 @@ export function exported() {
wasm.exported();
}
export const __wbg_foo_8d66ddef0ff279d6 = function() {
try {
foo();
} catch (e) {
handleError(e)
}
};
export const __wbg_foo_8d66ddef0ff279d6 = handleError(function() {
foo();
});
export const __wbindgen_throw = function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));

View File

@@ -29,8 +29,15 @@ function addHeapObject(obj) {
return idx;
}
function handleError(e) {
wasm.__wbindgen_exn_store(addHeapObject(e));
function handleError(f) {
return function () {
try {
return f.apply(this, arguments);
} catch (e) {
wasm.__wbindgen_exn_store(addHeapObject(e));
}
};
}
/**
*/
@@ -42,13 +49,9 @@ export const __wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
export const __wbg_foo_8d66ddef0ff279d6 = function() {
try {
foo();
} catch (e) {
handleError(e)
}
};
export const __wbg_foo_8d66ddef0ff279d6 = handleError(function() {
foo();
});
export const __wbindgen_rethrow = function(arg0) {
throw takeObject(arg0);