-
Notifications
You must be signed in to change notification settings - Fork 1k
/
import-catch.js
59 lines (45 loc) · 1.1 KB
/
import-catch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import * as wasm from './reference_test_bg.wasm';
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
function handleError(f) {
return function () {
try {
return f.apply(this, arguments);
} catch (e) {
wasm.__wbindgen_exn_store(addHeapObject(e));
}
};
}
/**
*/
export function exported() {
wasm.exported();
}
export const __wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
export const __wbg_foo_8d66ddef0ff279d6 = handleError(function() {
foo();
});
export const __wbindgen_rethrow = function(arg0) {
throw takeObject(arg0);
};