|
| 1 | +import wasm_path from 'file-loader!./gecko_profiler_demangle_bg.wasmpleaseignoremewebpack'; |
| 2 | + |
| 3 | +// The code below was generated using `wasm-bindgen --no-modules`, except for |
| 4 | +// the export statement at the very end which I added manually, and except for |
| 5 | +// the fact that the init() function now no longer takes a parameter and instead |
| 6 | +// uses the wasm_path variable that I'm declaring at the top. |
| 7 | + |
| 8 | +(function() { |
| 9 | + var wasm; |
| 10 | + const __exports = {}; |
| 11 | + |
| 12 | + |
| 13 | + let cachedEncoder = new TextEncoder('utf-8'); |
| 14 | + |
| 15 | + let cachegetUint8Memory = null; |
| 16 | + function getUint8Memory() { |
| 17 | + if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) { |
| 18 | + cachegetUint8Memory = new Uint8Array(wasm.memory.buffer); |
| 19 | + } |
| 20 | + return cachegetUint8Memory; |
| 21 | + } |
| 22 | + |
| 23 | + function passStringToWasm(arg) { |
| 24 | + |
| 25 | + const buf = cachedEncoder.encode(arg); |
| 26 | + const ptr = wasm.__wbindgen_malloc(buf.length); |
| 27 | + getUint8Memory().set(buf, ptr); |
| 28 | + return [ptr, buf.length]; |
| 29 | + } |
| 30 | + |
| 31 | + let cachedDecoder = new TextDecoder('utf-8'); |
| 32 | + |
| 33 | + function getStringFromWasm(ptr, len) { |
| 34 | + return cachedDecoder.decode(getUint8Memory().subarray(ptr, ptr + len)); |
| 35 | + } |
| 36 | + |
| 37 | + let cachedGlobalArgumentPtr = null; |
| 38 | + function globalArgumentPtr() { |
| 39 | + if (cachedGlobalArgumentPtr === null) { |
| 40 | + cachedGlobalArgumentPtr = wasm.__wbindgen_global_argument_ptr(); |
| 41 | + } |
| 42 | + return cachedGlobalArgumentPtr; |
| 43 | + } |
| 44 | + |
| 45 | + let cachegetUint32Memory = null; |
| 46 | + function getUint32Memory() { |
| 47 | + if (cachegetUint32Memory === null || cachegetUint32Memory.buffer !== wasm.memory.buffer) { |
| 48 | + cachegetUint32Memory = new Uint32Array(wasm.memory.buffer); |
| 49 | + } |
| 50 | + return cachegetUint32Memory; |
| 51 | + } |
| 52 | + /** |
| 53 | + * Takes an input string and runs it through a sequence of demanglers. Returns |
| 54 | + * the demangled string if a match was found, or the original string if not. |
| 55 | + * @param {string} arg0 |
| 56 | + * @returns {string} |
| 57 | + */ |
| 58 | + __exports.demangle_any = function(arg0) { |
| 59 | + const [ptr0, len0] = passStringToWasm(arg0); |
| 60 | + const retptr = globalArgumentPtr(); |
| 61 | + try { |
| 62 | + wasm.demangle_any(retptr, ptr0, len0); |
| 63 | + const mem = getUint32Memory(); |
| 64 | + const rustptr = mem[retptr / 4]; |
| 65 | + const rustlen = mem[retptr / 4 + 1]; |
| 66 | + |
| 67 | + const realRet = getStringFromWasm(rustptr, rustlen).slice(); |
| 68 | + wasm.__wbindgen_free(rustptr, rustlen * 1); |
| 69 | + return realRet; |
| 70 | + |
| 71 | + |
| 72 | + } finally { |
| 73 | + wasm.__wbindgen_free(ptr0, len0 * 1); |
| 74 | + |
| 75 | + } |
| 76 | + |
| 77 | + }; |
| 78 | + |
| 79 | + __exports.__wbindgen_throw = function(ptr, len) { |
| 80 | + throw new Error(getStringFromWasm(ptr, len)); |
| 81 | + }; |
| 82 | + |
| 83 | + function init() { |
| 84 | + const fetchPromise = fetch(wasm_path); |
| 85 | + let resultPromise; |
| 86 | + if (typeof WebAssembly.instantiateStreaming === 'function') { |
| 87 | + resultPromise = WebAssembly.instantiateStreaming(fetchPromise, { './gecko_profiler_demangle': __exports }); |
| 88 | + } else { |
| 89 | + resultPromise = fetchPromise |
| 90 | + .then(response => response.arrayBuffer()) |
| 91 | + .then(buffer => WebAssembly.instantiate(buffer, { './gecko_profiler_demangle': __exports })); |
| 92 | + } |
| 93 | + return resultPromise.then(({instance}) => { |
| 94 | + wasm = init.wasm = instance.exports; |
| 95 | + return; |
| 96 | + }); |
| 97 | + }; |
| 98 | + self.wasm_bindgen = Object.assign(init, __exports); |
| 99 | +})(); |
| 100 | + |
| 101 | +export default wasm_bindgen; |
0 commit comments