| | @@ -1,18 +1,17 @@ |
| 1 | 1 | |
| 2 | 2 | var initPikchrModule = (() => { |
| 3 | 3 | var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; |
| 4 | 4 | |
| 5 | 5 | return ( |
| 6 | | -function(initPikchrModule) { |
| 7 | | - initPikchrModule = initPikchrModule || {}; |
| 6 | +function(initPikchrModule = {}) { |
| 8 | 7 | |
| 9 | 8 | var Module = typeof initPikchrModule != "undefined" ? initPikchrModule : {}; |
| 10 | 9 | |
| 11 | 10 | var readyPromiseResolve, readyPromiseReject; |
| 12 | 11 | |
| 13 | | -Module["ready"] = new Promise(function(resolve, reject) { |
| 12 | +Module["ready"] = new Promise((resolve, reject) => { |
| 14 | 13 | readyPromiseResolve = resolve; |
| 15 | 14 | readyPromiseReject = reject; |
| 16 | 15 | }); |
| 17 | 16 | |
| 18 | 17 | var moduleOverrides = Object.assign({}, Module); |
| | @@ -116,104 +115,23 @@ |
| 116 | 115 | |
| 117 | 116 | var ABORT = false; |
| 118 | 117 | |
| 119 | 118 | var EXITSTATUS; |
| 120 | 119 | |
| 121 | | -var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : undefined; |
| 122 | | - |
| 123 | | -function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) { |
| 124 | | - var endIdx = idx + maxBytesToRead; |
| 125 | | - var endPtr = idx; |
| 126 | | - while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr; |
| 127 | | - if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) { |
| 128 | | - return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr)); |
| 129 | | - } |
| 130 | | - var str = ""; |
| 131 | | - while (idx < endPtr) { |
| 132 | | - var u0 = heapOrArray[idx++]; |
| 133 | | - if (!(u0 & 128)) { |
| 134 | | - str += String.fromCharCode(u0); |
| 135 | | - continue; |
| 136 | | - } |
| 137 | | - var u1 = heapOrArray[idx++] & 63; |
| 138 | | - if ((u0 & 224) == 192) { |
| 139 | | - str += String.fromCharCode((u0 & 31) << 6 | u1); |
| 140 | | - continue; |
| 141 | | - } |
| 142 | | - var u2 = heapOrArray[idx++] & 63; |
| 143 | | - if ((u0 & 240) == 224) { |
| 144 | | - u0 = (u0 & 15) << 12 | u1 << 6 | u2; |
| 145 | | - } else { |
| 146 | | - u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63; |
| 147 | | - } |
| 148 | | - if (u0 < 65536) { |
| 149 | | - str += String.fromCharCode(u0); |
| 150 | | - } else { |
| 151 | | - var ch = u0 - 65536; |
| 152 | | - str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023); |
| 153 | | - } |
| 154 | | - } |
| 155 | | - return str; |
| 156 | | -} |
| 157 | | - |
| 158 | | -function UTF8ToString(ptr, maxBytesToRead) { |
| 159 | | - return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : ""; |
| 160 | | -} |
| 161 | | - |
| 162 | | -function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { |
| 163 | | - if (!(maxBytesToWrite > 0)) return 0; |
| 164 | | - var startIdx = outIdx; |
| 165 | | - var endIdx = outIdx + maxBytesToWrite - 1; |
| 166 | | - for (var i = 0; i < str.length; ++i) { |
| 167 | | - var u = str.charCodeAt(i); |
| 168 | | - if (u >= 55296 && u <= 57343) { |
| 169 | | - var u1 = str.charCodeAt(++i); |
| 170 | | - u = 65536 + ((u & 1023) << 10) | u1 & 1023; |
| 171 | | - } |
| 172 | | - if (u <= 127) { |
| 173 | | - if (outIdx >= endIdx) break; |
| 174 | | - heap[outIdx++] = u; |
| 175 | | - } else if (u <= 2047) { |
| 176 | | - if (outIdx + 1 >= endIdx) break; |
| 177 | | - heap[outIdx++] = 192 | u >> 6; |
| 178 | | - heap[outIdx++] = 128 | u & 63; |
| 179 | | - } else if (u <= 65535) { |
| 180 | | - if (outIdx + 2 >= endIdx) break; |
| 181 | | - heap[outIdx++] = 224 | u >> 12; |
| 182 | | - heap[outIdx++] = 128 | u >> 6 & 63; |
| 183 | | - heap[outIdx++] = 128 | u & 63; |
| 184 | | - } else { |
| 185 | | - if (outIdx + 3 >= endIdx) break; |
| 186 | | - heap[outIdx++] = 240 | u >> 18; |
| 187 | | - heap[outIdx++] = 128 | u >> 12 & 63; |
| 188 | | - heap[outIdx++] = 128 | u >> 6 & 63; |
| 189 | | - heap[outIdx++] = 128 | u & 63; |
| 190 | | - } |
| 191 | | - } |
| 192 | | - heap[outIdx] = 0; |
| 193 | | - return outIdx - startIdx; |
| 194 | | -} |
| 195 | | - |
| 196 | | -function stringToUTF8(str, outPtr, maxBytesToWrite) { |
| 197 | | - return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite); |
| 198 | | -} |
| 199 | | - |
| 200 | | -var buffer, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64; |
| 201 | | - |
| 202 | | -function updateGlobalBufferAndViews(buf) { |
| 203 | | - buffer = buf; |
| 204 | | - Module["HEAP8"] = HEAP8 = new Int8Array(buf); |
| 205 | | - Module["HEAP16"] = HEAP16 = new Int16Array(buf); |
| 206 | | - Module["HEAP32"] = HEAP32 = new Int32Array(buf); |
| 207 | | - Module["HEAPU8"] = HEAPU8 = new Uint8Array(buf); |
| 208 | | - Module["HEAPU16"] = HEAPU16 = new Uint16Array(buf); |
| 209 | | - Module["HEAPU32"] = HEAPU32 = new Uint32Array(buf); |
| 210 | | - Module["HEAPF32"] = HEAPF32 = new Float32Array(buf); |
| 211 | | - Module["HEAPF64"] = HEAPF64 = new Float64Array(buf); |
| 212 | | -} |
| 213 | | - |
| 214 | | -var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 16777216; |
| 120 | +var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64; |
| 121 | + |
| 122 | +function updateMemoryViews() { |
| 123 | + var b = wasmMemory.buffer; |
| 124 | + Module["HEAP8"] = HEAP8 = new Int8Array(b); |
| 125 | + Module["HEAP16"] = HEAP16 = new Int16Array(b); |
| 126 | + Module["HEAP32"] = HEAP32 = new Int32Array(b); |
| 127 | + Module["HEAPU8"] = HEAPU8 = new Uint8Array(b); |
| 128 | + Module["HEAPU16"] = HEAPU16 = new Uint16Array(b); |
| 129 | + Module["HEAPU32"] = HEAPU32 = new Uint32Array(b); |
| 130 | + Module["HEAPF32"] = HEAPF32 = new Float32Array(b); |
| 131 | + Module["HEAPF64"] = HEAPF64 = new Float64Array(b); |
| 132 | +} |
| 215 | 133 | |
| 216 | 134 | var wasmTable; |
| 217 | 135 | |
| 218 | 136 | var __ATPRERUN__ = []; |
| 219 | 137 | |
| | @@ -221,12 +139,14 @@ |
| 221 | 139 | |
| 222 | 140 | var __ATPOSTRUN__ = []; |
| 223 | 141 | |
| 224 | 142 | var runtimeInitialized = false; |
| 225 | 143 | |
| 144 | +var runtimeKeepaliveCounter = 0; |
| 145 | + |
| 226 | 146 | function keepRuntimeAlive() { |
| 227 | | - return noExitRuntime; |
| 147 | + return noExitRuntime || runtimeKeepaliveCounter > 0; |
| 228 | 148 | } |
| 229 | 149 | |
| 230 | 150 | function preRun() { |
| 231 | 151 | if (Module["preRun"]) { |
| 232 | 152 | if (typeof Module["preRun"] == "function") Module["preRun"] = [ Module["preRun"] ]; |
| | @@ -335,83 +255,81 @@ |
| 335 | 255 | } catch (err) { |
| 336 | 256 | abort(err); |
| 337 | 257 | } |
| 338 | 258 | } |
| 339 | 259 | |
| 340 | | -function getBinaryPromise() { |
| 260 | +function getBinaryPromise(binaryFile) { |
| 341 | 261 | if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { |
| 342 | 262 | if (typeof fetch == "function") { |
| 343 | | - return fetch(wasmBinaryFile, { |
| 263 | + return fetch(binaryFile, { |
| 344 | 264 | credentials: "same-origin" |
| 345 | | - }).then(function(response) { |
| 265 | + }).then(response => { |
| 346 | 266 | if (!response["ok"]) { |
| 347 | | - throw "failed to load wasm binary file at '" + wasmBinaryFile + "'"; |
| 267 | + throw "failed to load wasm binary file at '" + binaryFile + "'"; |
| 348 | 268 | } |
| 349 | 269 | return response["arrayBuffer"](); |
| 350 | | - }).catch(function() { |
| 351 | | - return getBinary(wasmBinaryFile); |
| 352 | | - }); |
| 353 | | - } |
| 354 | | - } |
| 355 | | - return Promise.resolve().then(function() { |
| 356 | | - return getBinary(wasmBinaryFile); |
| 357 | | - }); |
| 270 | + }).catch(() => getBinary(binaryFile)); |
| 271 | + } |
| 272 | + } |
| 273 | + return Promise.resolve().then(() => getBinary(binaryFile)); |
| 274 | +} |
| 275 | + |
| 276 | +function instantiateArrayBuffer(binaryFile, imports, receiver) { |
| 277 | + return getBinaryPromise(binaryFile).then(binary => { |
| 278 | + return WebAssembly.instantiate(binary, imports); |
| 279 | + }).then(instance => { |
| 280 | + return instance; |
| 281 | + }).then(receiver, reason => { |
| 282 | + err("failed to asynchronously prepare wasm: " + reason); |
| 283 | + abort(reason); |
| 284 | + }); |
| 285 | +} |
| 286 | + |
| 287 | +function instantiateAsync(binary, binaryFile, imports, callback) { |
| 288 | + if (!binary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(binaryFile) && typeof fetch == "function") { |
| 289 | + return fetch(binaryFile, { |
| 290 | + credentials: "same-origin" |
| 291 | + }).then(response => { |
| 292 | + var result = WebAssembly.instantiateStreaming(response, imports); |
| 293 | + return result.then(callback, function(reason) { |
| 294 | + err("wasm streaming compile failed: " + reason); |
| 295 | + err("falling back to ArrayBuffer instantiation"); |
| 296 | + return instantiateArrayBuffer(binaryFile, imports, callback); |
| 297 | + }); |
| 298 | + }); |
| 299 | + } else { |
| 300 | + return instantiateArrayBuffer(binaryFile, imports, callback); |
| 301 | + } |
| 358 | 302 | } |
| 359 | 303 | |
| 360 | 304 | function createWasm() { |
| 361 | 305 | var info = { |
| 362 | | - "a": asmLibraryArg |
| 306 | + "a": wasmImports |
| 363 | 307 | }; |
| 364 | 308 | function receiveInstance(instance, module) { |
| 365 | 309 | var exports = instance.exports; |
| 366 | 310 | Module["asm"] = exports; |
| 367 | 311 | wasmMemory = Module["asm"]["d"]; |
| 368 | | - updateGlobalBufferAndViews(wasmMemory.buffer); |
| 312 | + updateMemoryViews(); |
| 369 | 313 | wasmTable = Module["asm"]["g"]; |
| 370 | 314 | addOnInit(Module["asm"]["e"]); |
| 371 | 315 | removeRunDependency("wasm-instantiate"); |
| 316 | + return exports; |
| 372 | 317 | } |
| 373 | 318 | addRunDependency("wasm-instantiate"); |
| 374 | 319 | function receiveInstantiationResult(result) { |
| 375 | 320 | receiveInstance(result["instance"]); |
| 376 | 321 | } |
| 377 | | - function instantiateArrayBuffer(receiver) { |
| 378 | | - return getBinaryPromise().then(function(binary) { |
| 379 | | - return WebAssembly.instantiate(binary, info); |
| 380 | | - }).then(function(instance) { |
| 381 | | - return instance; |
| 382 | | - }).then(receiver, function(reason) { |
| 383 | | - err("failed to asynchronously prepare wasm: " + reason); |
| 384 | | - abort(reason); |
| 385 | | - }); |
| 386 | | - } |
| 387 | | - function instantiateAsync() { |
| 388 | | - if (!wasmBinary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(wasmBinaryFile) && typeof fetch == "function") { |
| 389 | | - return fetch(wasmBinaryFile, { |
| 390 | | - credentials: "same-origin" |
| 391 | | - }).then(function(response) { |
| 392 | | - var result = WebAssembly.instantiateStreaming(response, info); |
| 393 | | - return result.then(receiveInstantiationResult, function(reason) { |
| 394 | | - err("wasm streaming compile failed: " + reason); |
| 395 | | - err("falling back to ArrayBuffer instantiation"); |
| 396 | | - return instantiateArrayBuffer(receiveInstantiationResult); |
| 397 | | - }); |
| 398 | | - }); |
| 399 | | - } else { |
| 400 | | - return instantiateArrayBuffer(receiveInstantiationResult); |
| 401 | | - } |
| 402 | | - } |
| 403 | 322 | if (Module["instantiateWasm"]) { |
| 404 | 323 | try { |
| 405 | | - var exports = Module["instantiateWasm"](info, receiveInstance); |
| 406 | | - return exports; |
| 324 | + return Module["instantiateWasm"](info, receiveInstance); |
| 407 | 325 | } catch (e) { |
| 408 | 326 | err("Module.instantiateWasm callback failed with error: " + e); |
| 409 | 327 | readyPromiseReject(e); |
| 410 | 328 | } |
| 411 | 329 | } |
| 412 | | - instantiateAsync().catch(readyPromiseReject); |
| 330 | + instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject); |
| 413 | 331 | return {}; |
| 414 | 332 | } |
| 415 | 333 | |
| 416 | 334 | var tempDouble; |
| 417 | 335 | |
| | @@ -457,11 +375,10 @@ |
| 457 | 375 | return HEAPU32[ptr >> 2]; |
| 458 | 376 | |
| 459 | 377 | default: |
| 460 | 378 | abort("invalid type for getValue: " + type); |
| 461 | 379 | } |
| 462 | | - return null; |
| 463 | 380 | } |
| 464 | 381 | |
| 465 | 382 | function setValue(ptr, value, type = "i8") { |
| 466 | 383 | if (type.endsWith("*")) type = "*"; |
| 467 | 384 | switch (type) { |
| | @@ -480,11 +397,11 @@ |
| 480 | 397 | case "i32": |
| 481 | 398 | HEAP32[ptr >> 2] = value; |
| 482 | 399 | break; |
| 483 | 400 | |
| 484 | 401 | case "i64": |
| 485 | | - tempI64 = [ value >>> 0, (tempDouble = value, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0) ], |
| 402 | + tempI64 = [ value >>> 0, (tempDouble = value, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? +Math.floor(tempDouble / 4294967296) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0) ], |
| 486 | 403 | HEAP32[ptr >> 2] = tempI64[0], HEAP32[ptr + 4 >> 2] = tempI64[1]; |
| 487 | 404 | break; |
| 488 | 405 | |
| 489 | 406 | case "float": |
| 490 | 407 | HEAPF32[ptr >> 2] = value; |
| | @@ -500,10 +417,51 @@ |
| 500 | 417 | |
| 501 | 418 | default: |
| 502 | 419 | abort("invalid type for setValue: " + type); |
| 503 | 420 | } |
| 504 | 421 | } |
| 422 | + |
| 423 | +var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : undefined; |
| 424 | + |
| 425 | +function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) { |
| 426 | + var endIdx = idx + maxBytesToRead; |
| 427 | + var endPtr = idx; |
| 428 | + while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr; |
| 429 | + if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) { |
| 430 | + return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr)); |
| 431 | + } |
| 432 | + var str = ""; |
| 433 | + while (idx < endPtr) { |
| 434 | + var u0 = heapOrArray[idx++]; |
| 435 | + if (!(u0 & 128)) { |
| 436 | + str += String.fromCharCode(u0); |
| 437 | + continue; |
| 438 | + } |
| 439 | + var u1 = heapOrArray[idx++] & 63; |
| 440 | + if ((u0 & 224) == 192) { |
| 441 | + str += String.fromCharCode((u0 & 31) << 6 | u1); |
| 442 | + continue; |
| 443 | + } |
| 444 | + var u2 = heapOrArray[idx++] & 63; |
| 445 | + if ((u0 & 240) == 224) { |
| 446 | + u0 = (u0 & 15) << 12 | u1 << 6 | u2; |
| 447 | + } else { |
| 448 | + u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63; |
| 449 | + } |
| 450 | + if (u0 < 65536) { |
| 451 | + str += String.fromCharCode(u0); |
| 452 | + } else { |
| 453 | + var ch = u0 - 65536; |
| 454 | + str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023); |
| 455 | + } |
| 456 | + } |
| 457 | + return str; |
| 458 | +} |
| 459 | + |
| 460 | +function UTF8ToString(ptr, maxBytesToRead) { |
| 461 | + return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : ""; |
| 462 | +} |
| 505 | 463 | |
| 506 | 464 | function ___assert_fail(condition, filename, line, func) { |
| 507 | 465 | abort("Assertion failed: " + UTF8ToString(condition) + ", at: " + [ filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function" ]); |
| 508 | 466 | } |
| 509 | 467 | |
| | @@ -552,19 +510,80 @@ |
| 552 | 510 | } |
| 553 | 511 | |
| 554 | 512 | function writeArrayToMemory(array, buffer) { |
| 555 | 513 | HEAP8.set(array, buffer); |
| 556 | 514 | } |
| 515 | + |
| 516 | +function lengthBytesUTF8(str) { |
| 517 | + var len = 0; |
| 518 | + for (var i = 0; i < str.length; ++i) { |
| 519 | + var c = str.charCodeAt(i); |
| 520 | + if (c <= 127) { |
| 521 | + len++; |
| 522 | + } else if (c <= 2047) { |
| 523 | + len += 2; |
| 524 | + } else if (c >= 55296 && c <= 57343) { |
| 525 | + len += 4; |
| 526 | + ++i; |
| 527 | + } else { |
| 528 | + len += 3; |
| 529 | + } |
| 530 | + } |
| 531 | + return len; |
| 532 | +} |
| 533 | + |
| 534 | +function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { |
| 535 | + if (!(maxBytesToWrite > 0)) return 0; |
| 536 | + var startIdx = outIdx; |
| 537 | + var endIdx = outIdx + maxBytesToWrite - 1; |
| 538 | + for (var i = 0; i < str.length; ++i) { |
| 539 | + var u = str.charCodeAt(i); |
| 540 | + if (u >= 55296 && u <= 57343) { |
| 541 | + var u1 = str.charCodeAt(++i); |
| 542 | + u = 65536 + ((u & 1023) << 10) | u1 & 1023; |
| 543 | + } |
| 544 | + if (u <= 127) { |
| 545 | + if (outIdx >= endIdx) break; |
| 546 | + heap[outIdx++] = u; |
| 547 | + } else if (u <= 2047) { |
| 548 | + if (outIdx + 1 >= endIdx) break; |
| 549 | + heap[outIdx++] = 192 | u >> 6; |
| 550 | + heap[outIdx++] = 128 | u & 63; |
| 551 | + } else if (u <= 65535) { |
| 552 | + if (outIdx + 2 >= endIdx) break; |
| 553 | + heap[outIdx++] = 224 | u >> 12; |
| 554 | + heap[outIdx++] = 128 | u >> 6 & 63; |
| 555 | + heap[outIdx++] = 128 | u & 63; |
| 556 | + } else { |
| 557 | + if (outIdx + 3 >= endIdx) break; |
| 558 | + heap[outIdx++] = 240 | u >> 18; |
| 559 | + heap[outIdx++] = 128 | u >> 12 & 63; |
| 560 | + heap[outIdx++] = 128 | u >> 6 & 63; |
| 561 | + heap[outIdx++] = 128 | u & 63; |
| 562 | + } |
| 563 | + } |
| 564 | + heap[outIdx] = 0; |
| 565 | + return outIdx - startIdx; |
| 566 | +} |
| 567 | + |
| 568 | +function stringToUTF8(str, outPtr, maxBytesToWrite) { |
| 569 | + return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite); |
| 570 | +} |
| 571 | + |
| 572 | +function stringToUTF8OnStack(str) { |
| 573 | + var size = lengthBytesUTF8(str) + 1; |
| 574 | + var ret = stackAlloc(size); |
| 575 | + stringToUTF8(str, ret, size); |
| 576 | + return ret; |
| 577 | +} |
| 557 | 578 | |
| 558 | 579 | function ccall(ident, returnType, argTypes, args, opts) { |
| 559 | 580 | var toC = { |
| 560 | 581 | "string": str => { |
| 561 | 582 | var ret = 0; |
| 562 | 583 | if (str !== null && str !== undefined && str !== 0) { |
| 563 | | - var len = (str.length << 2) + 1; |
| 564 | | - ret = stackAlloc(len); |
| 565 | | - stringToUTF8(str, ret, len); |
| 584 | + ret = stringToUTF8OnStack(str); |
| 566 | 585 | } |
| 567 | 586 | return ret; |
| 568 | 587 | }, |
| 569 | 588 | "array": arr => { |
| 570 | 589 | var ret = stackAlloc(arr.length); |
| | @@ -601,48 +620,53 @@ |
| 601 | 620 | ret = onDone(ret); |
| 602 | 621 | return ret; |
| 603 | 622 | } |
| 604 | 623 | |
| 605 | 624 | function cwrap(ident, returnType, argTypes, opts) { |
| 606 | | - argTypes = argTypes || []; |
| 607 | | - var numericArgs = argTypes.every(type => type === "number" || type === "boolean"); |
| 625 | + var numericArgs = !argTypes || argTypes.every(type => type === "number" || type === "boolean"); |
| 608 | 626 | var numericRet = returnType !== "string"; |
| 609 | 627 | if (numericRet && numericArgs && !opts) { |
| 610 | 628 | return getCFunc(ident); |
| 611 | 629 | } |
| 612 | 630 | return function() { |
| 613 | 631 | return ccall(ident, returnType, argTypes, arguments, opts); |
| 614 | 632 | }; |
| 615 | 633 | } |
| 616 | 634 | |
| 617 | | -var asmLibraryArg = { |
| 635 | +var wasmImports = { |
| 618 | 636 | "a": ___assert_fail, |
| 619 | 637 | "b": _emscripten_resize_heap, |
| 620 | 638 | "c": _exit |
| 621 | 639 | }; |
| 622 | 640 | |
| 623 | 641 | var asm = createWasm(); |
| 624 | 642 | |
| 625 | | -var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function() { |
| 626 | | - return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["e"]).apply(null, arguments); |
| 643 | +var ___wasm_call_ctors = function() { |
| 644 | + return (___wasm_call_ctors = Module["asm"]["e"]).apply(null, arguments); |
| 627 | 645 | }; |
| 628 | 646 | |
| 629 | 647 | var _pikchr = Module["_pikchr"] = function() { |
| 630 | 648 | return (_pikchr = Module["_pikchr"] = Module["asm"]["f"]).apply(null, arguments); |
| 631 | 649 | }; |
| 632 | 650 | |
| 633 | | -var stackSave = Module["stackSave"] = function() { |
| 634 | | - return (stackSave = Module["stackSave"] = Module["asm"]["h"]).apply(null, arguments); |
| 651 | +var ___errno_location = function() { |
| 652 | + return (___errno_location = Module["asm"]["__errno_location"]).apply(null, arguments); |
| 653 | +}; |
| 654 | + |
| 655 | +var stackSave = function() { |
| 656 | + return (stackSave = Module["asm"]["h"]).apply(null, arguments); |
| 657 | +}; |
| 658 | + |
| 659 | +var stackRestore = function() { |
| 660 | + return (stackRestore = Module["asm"]["i"]).apply(null, arguments); |
| 635 | 661 | }; |
| 636 | 662 | |
| 637 | | -var stackRestore = Module["stackRestore"] = function() { |
| 638 | | - return (stackRestore = Module["stackRestore"] = Module["asm"]["i"]).apply(null, arguments); |
| 663 | +var stackAlloc = function() { |
| 664 | + return (stackAlloc = Module["asm"]["j"]).apply(null, arguments); |
| 639 | 665 | }; |
| 640 | 666 | |
| 641 | | -var stackAlloc = Module["stackAlloc"] = function() { |
| 642 | | - return (stackAlloc = Module["stackAlloc"] = Module["asm"]["j"]).apply(null, arguments); |
| 643 | | -}; |
| 667 | +Module["stackAlloc"] = stackAlloc; |
| 644 | 668 | |
| 645 | 669 | Module["stackSave"] = stackSave; |
| 646 | 670 | |
| 647 | 671 | Module["stackRestore"] = stackRestore; |
| 648 | 672 | |
| | @@ -657,12 +681,11 @@ |
| 657 | 681 | dependenciesFulfilled = function runCaller() { |
| 658 | 682 | if (!calledRun) run(); |
| 659 | 683 | if (!calledRun) dependenciesFulfilled = runCaller; |
| 660 | 684 | }; |
| 661 | 685 | |
| 662 | | -function run(args) { |
| 663 | | - args = args || arguments_; |
| 686 | +function run() { |
| 664 | 687 | if (runDependencies > 0) { |
| 665 | 688 | return; |
| 666 | 689 | } |
| 667 | 690 | preRun(); |
| 668 | 691 | if (runDependencies > 0) { |
| | @@ -701,13 +724,14 @@ |
| 701 | 724 | run(); |
| 702 | 725 | |
| 703 | 726 | |
| 704 | 727 | return initPikchrModule.ready |
| 705 | 728 | } |
| 729 | + |
| 706 | 730 | ); |
| 707 | 731 | })(); |
| 708 | 732 | if (typeof exports === 'object' && typeof module === 'object') |
| 709 | 733 | module.exports = initPikchrModule; |
| 710 | 734 | else if (typeof define === 'function' && define['amd']) |
| 711 | 735 | define([], function() { return initPikchrModule; }); |
| 712 | 736 | else if (typeof exports === 'object') |
| 713 | 737 | exports["initPikchrModule"] = initPikchrModule; |
| 714 | 738 | |