|
| 1 | +(function() { |
| 2 | + const __exports = {}; |
| 3 | + let wasm; |
| 4 | + |
| 5 | + let WASM_VECTOR_LEN = 0; |
| 6 | + |
| 7 | + let cachedTextEncoder = new TextEncoder('utf-8'); |
| 8 | + |
| 9 | + const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' |
| 10 | + ? function (arg, view) { |
| 11 | + return cachedTextEncoder.encodeInto(arg, view); |
| 12 | + } |
| 13 | + : function (arg, view) { |
| 14 | + const buf = cachedTextEncoder.encode(arg); |
| 15 | + view.set(buf); |
| 16 | + return { |
| 17 | + read: arg.length, |
| 18 | + written: buf.length |
| 19 | + }; |
| 20 | + }); |
| 21 | + |
| 22 | + let cachegetUint8Memory = null; |
| 23 | + function getUint8Memory() { |
| 24 | + if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) { |
| 25 | + cachegetUint8Memory = new Uint8Array(wasm.memory.buffer); |
| 26 | + } |
| 27 | + return cachegetUint8Memory; |
| 28 | + } |
| 29 | + |
| 30 | + function passStringToWasm(arg) { |
| 31 | + |
| 32 | + let len = arg.length; |
| 33 | + let ptr = wasm.__wbindgen_malloc(len); |
| 34 | + |
| 35 | + const mem = getUint8Memory(); |
| 36 | + |
| 37 | + let offset = 0; |
| 38 | + |
| 39 | + for (; offset < len; offset++) { |
| 40 | + const code = arg.charCodeAt(offset); |
| 41 | + if (code > 0x7F) break; |
| 42 | + mem[ptr + offset] = code; |
| 43 | + } |
| 44 | + |
| 45 | + if (offset !== len) { |
| 46 | + if (offset !== 0) { |
| 47 | + arg = arg.slice(offset); |
| 48 | + } |
| 49 | + ptr = wasm.__wbindgen_realloc(ptr, len, len = offset + arg.length * 3); |
| 50 | + const view = getUint8Memory().subarray(ptr + offset, ptr + len); |
| 51 | + const ret = encodeString(arg, view); |
| 52 | + |
| 53 | + offset += ret.written; |
| 54 | + } |
| 55 | + |
| 56 | + WASM_VECTOR_LEN = offset; |
| 57 | + return ptr; |
| 58 | + } |
| 59 | + |
| 60 | + function passArray8ToWasm(arg) { |
| 61 | + const ptr = wasm.__wbindgen_malloc(arg.length * 1); |
| 62 | + getUint8Memory().set(arg, ptr / 1); |
| 63 | + WASM_VECTOR_LEN = arg.length; |
| 64 | + return ptr; |
| 65 | + } |
| 66 | + |
| 67 | + const heap = new Array(32); |
| 68 | + |
| 69 | + heap.fill(undefined); |
| 70 | + |
| 71 | + heap.push(undefined, null, true, false); |
| 72 | + |
| 73 | + let stack_pointer = 32; |
| 74 | + |
| 75 | + function addBorrowedObject(obj) { |
| 76 | + if (stack_pointer == 1) throw new Error('out of js stack'); |
| 77 | + heap[--stack_pointer] = obj; |
| 78 | + return stack_pointer; |
| 79 | + } |
| 80 | + |
| 81 | + let cachegetInt32Memory = null; |
| 82 | + function getInt32Memory() { |
| 83 | + if (cachegetInt32Memory === null || cachegetInt32Memory.buffer !== wasm.memory.buffer) { |
| 84 | + cachegetInt32Memory = new Int32Array(wasm.memory.buffer); |
| 85 | + } |
| 86 | + return cachegetInt32Memory; |
| 87 | + } |
| 88 | + |
| 89 | + function getArrayU8FromWasm(ptr, len) { |
| 90 | + return getUint8Memory().subarray(ptr / 1, ptr / 1 + len); |
| 91 | + } |
| 92 | + /** |
| 93 | + * @param {string} name |
| 94 | + * @param {Uint8Array} memory |
| 95 | + * @param {any} symbols |
| 96 | + * @returns {Uint8Array} |
| 97 | + */ |
| 98 | + __exports.gen_elf = function(name, memory, symbols) { |
| 99 | + const retptr = 8; |
| 100 | + try { |
| 101 | + const ret = wasm.gen_elf(retptr, passStringToWasm(name), WASM_VECTOR_LEN, passArray8ToWasm(memory), WASM_VECTOR_LEN, addBorrowedObject(symbols)); |
| 102 | + const memi32 = getInt32Memory(); |
| 103 | + const v0 = getArrayU8FromWasm(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1]).slice(); |
| 104 | + wasm.__wbindgen_free(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1] * 1); |
| 105 | + return v0; |
| 106 | + } finally { |
| 107 | + heap[stack_pointer++] = undefined; |
| 108 | + } |
| 109 | + }; |
| 110 | + |
| 111 | +function getObject(idx) { return heap[idx]; } |
| 112 | + |
| 113 | +let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); |
| 114 | + |
| 115 | +cachedTextDecoder.decode(); |
| 116 | + |
| 117 | +function getStringFromWasm(ptr, len) { |
| 118 | + return cachedTextDecoder.decode(getUint8Memory().subarray(ptr, ptr + len)); |
| 119 | +} |
| 120 | + |
| 121 | +let heap_next = heap.length; |
| 122 | + |
| 123 | +function addHeapObject(obj) { |
| 124 | + if (heap_next === heap.length) heap.push(heap.length + 1); |
| 125 | + const idx = heap_next; |
| 126 | + heap_next = heap[idx]; |
| 127 | + |
| 128 | + heap[idx] = obj; |
| 129 | + return idx; |
| 130 | +} |
| 131 | + |
| 132 | +function dropObject(idx) { |
| 133 | + if (idx < 36) return; |
| 134 | + heap[idx] = heap_next; |
| 135 | + heap_next = idx; |
| 136 | +} |
| 137 | + |
| 138 | +function takeObject(idx) { |
| 139 | + const ret = getObject(idx); |
| 140 | + dropObject(idx); |
| 141 | + return ret; |
| 142 | +} |
| 143 | + |
| 144 | +function init(module) { |
| 145 | + |
| 146 | + let result; |
| 147 | + const imports = {}; |
| 148 | + imports.wbg = {}; |
| 149 | + imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) { |
| 150 | + const obj = getObject(arg1); |
| 151 | + const ret = JSON.stringify(obj === undefined ? null : obj); |
| 152 | + const ret0 = passStringToWasm(ret); |
| 153 | + const ret1 = WASM_VECTOR_LEN; |
| 154 | + getInt32Memory()[arg0 / 4 + 0] = ret0; |
| 155 | + getInt32Memory()[arg0 / 4 + 1] = ret1; |
| 156 | + }; |
| 157 | + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { |
| 158 | + const ret = getStringFromWasm(arg0, arg1); |
| 159 | + return addHeapObject(ret); |
| 160 | + }; |
| 161 | + imports.wbg.__wbindgen_rethrow = function(arg0) { |
| 162 | + throw takeObject(arg0); |
| 163 | + }; |
| 164 | + |
| 165 | + if ((typeof URL === 'function' && module instanceof URL) || typeof module === 'string' || (typeof Request === 'function' && module instanceof Request)) { |
| 166 | + |
| 167 | + const response = fetch(module); |
| 168 | + if (typeof WebAssembly.instantiateStreaming === 'function') { |
| 169 | + result = WebAssembly.instantiateStreaming(response, imports) |
| 170 | + .catch(e => { |
| 171 | + return response |
| 172 | + .then(r => { |
| 173 | + if (r.headers.get('Content-Type') != 'application/wasm') { |
| 174 | + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); |
| 175 | + return r.arrayBuffer(); |
| 176 | + } else { |
| 177 | + throw e; |
| 178 | + } |
| 179 | + }) |
| 180 | + .then(bytes => WebAssembly.instantiate(bytes, imports)); |
| 181 | + }); |
| 182 | + } else { |
| 183 | + result = response |
| 184 | + .then(r => r.arrayBuffer()) |
| 185 | + .then(bytes => WebAssembly.instantiate(bytes, imports)); |
| 186 | + } |
| 187 | + } else { |
| 188 | + |
| 189 | + result = WebAssembly.instantiate(module, imports) |
| 190 | + .then(result => { |
| 191 | + if (result instanceof WebAssembly.Instance) { |
| 192 | + return { instance: result, module }; |
| 193 | + } else { |
| 194 | + return result; |
| 195 | + } |
| 196 | + }); |
| 197 | + } |
| 198 | + return result.then(({instance, module}) => { |
| 199 | + wasm = instance.exports; |
| 200 | + init.__wbindgen_wasm_module = module; |
| 201 | + |
| 202 | + return wasm; |
| 203 | + }); |
| 204 | +} |
| 205 | + |
| 206 | +self.wasm_bindgen = Object.assign(init, __exports); |
| 207 | + |
| 208 | +})(); |
0 commit comments