Guest User

Untitled

a guest
May 2nd, 2025
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.83 KB | None | 0 0
  1. #!/emsdk/node/20.18.0_64bit/bin/node
  2. // include: shell.js
  3. // The Module object: Our interface to the outside world. We import
  4. // and export values on it. There are various ways Module can be used:
  5. // 1. Not defined. We create it here
  6. // 2. A function parameter, function(moduleArg) => Promise<Module>
  7. // 3. pre-run appended it, var Module = {}; ..generated code..
  8. // 4. External script tag defines var Module.
  9. // We need to check if Module already exists (e.g. case 3 above).
  10. // Substitution will be replaced with actual code on later stage of the build,
  11. // this way Closure Compiler will not mangle it (e.g. case 4. above).
  12. // Note that if you want to run closure, and also to use Module
  13. // after the generated code, you will need to define var Module = {};
  14. // before the code. Then that object will be used in the code, and you
  15. // can continue to use Module afterwards as well.
  16. var Module = typeof Module != 'undefined' ? Module : {};
  17.  
  18. // Determine the runtime environment we are in. You can customize this by
  19. // setting the ENVIRONMENT setting at compile time (see settings.js).
  20.  
  21. // Attempt to auto-detect the environment
  22. var ENVIRONMENT_IS_WEB = typeof window == 'object';
  23. var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != 'undefined';
  24. // N.b. Electron.js environment is simultaneously a NODE-environment, but
  25. // also a web environment.
  26. var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string' && process.type != 'renderer';
  27. var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
  28.  
  29. if (ENVIRONMENT_IS_NODE) {
  30.  
  31. }
  32.  
  33. // --pre-jses are emitted after the Module integration code, so that they can
  34. // refer to Module (if they choose; they can also define Module)
  35.  
  36.  
  37. var arguments_ = [];
  38. var thisProgram = './this.program';
  39. var quit_ = (status, toThrow) => {
  40. throw toThrow;
  41. };
  42.  
  43. // In MODULARIZE mode _scriptName needs to be captured already at the very top of the page immediately when the page is parsed, so it is generated there
  44. // before the page load. In non-MODULARIZE modes generate it here.
  45. var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
  46.  
  47. if (typeof __filename != 'undefined') { // Node
  48. _scriptName = __filename;
  49. } else
  50. if (ENVIRONMENT_IS_WORKER) {
  51. _scriptName = self.location.href;
  52. }
  53.  
  54. // `/` should be present at the end if `scriptDirectory` is not empty
  55. var scriptDirectory = '';
  56. function locateFile(path) {
  57. if (Module['locateFile']) {
  58. return Module['locateFile'](path, scriptDirectory);
  59. }
  60. return scriptDirectory + path;
  61. }
  62.  
  63. // Hooks that are implemented differently in different runtime environments.
  64. var readAsync, readBinary;
  65.  
  66. if (ENVIRONMENT_IS_NODE) {
  67. if (typeof process == 'undefined' || !process.release || process.release.name !== 'node') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
  68.  
  69. var nodeVersion = process.versions.node;
  70. var numericVersion = nodeVersion.split('.').slice(0, 3);
  71. numericVersion = (numericVersion[0] * 10000) + (numericVersion[1] * 100) + (numericVersion[2].split('-')[0] * 1);
  72. var minVersion = 160000;
  73. if (numericVersion < 160000) {
  74. throw new Error('This emscripten-generated code requires node v16.0.0 (detected v' + nodeVersion + ')');
  75. }
  76.  
  77. // These modules will usually be used on Node.js. Load them eagerly to avoid
  78. // the complexity of lazy-loading.
  79. var fs = require('fs');
  80. var nodePath = require('path');
  81.  
  82. scriptDirectory = __dirname + '/';
  83.  
  84. // include: node_shell_read.js
  85. readBinary = (filename) => {
  86. // We need to re-wrap `file://` strings to URLs.
  87. filename = isFileURI(filename) ? new URL(filename) : filename;
  88. var ret = fs.readFileSync(filename);
  89. assert(Buffer.isBuffer(ret));
  90. return ret;
  91. };
  92.  
  93. readAsync = async (filename, binary = true) => {
  94. // See the comment in the `readBinary` function.
  95. filename = isFileURI(filename) ? new URL(filename) : filename;
  96. var ret = fs.readFileSync(filename, binary ? undefined : 'utf8');
  97. assert(binary ? Buffer.isBuffer(ret) : typeof ret == 'string');
  98. return ret;
  99. };
  100. // end include: node_shell_read.js
  101. if (process.argv.length > 1) {
  102. thisProgram = process.argv[1].replace(/\\/g, '/');
  103. }
  104.  
  105. arguments_ = process.argv.slice(2);
  106.  
  107. // MODULARIZE will export the module in the proper place outside, we don't need to export here
  108. if (typeof module != 'undefined') {
  109. module['exports'] = Module;
  110. }
  111.  
  112. quit_ = (status, toThrow) => {
  113. process.exitCode = status;
  114. throw toThrow;
  115. };
  116.  
  117. } else
  118. if (ENVIRONMENT_IS_SHELL) {
  119.  
  120. if ((typeof process == 'object' && typeof require === 'function') || typeof window == 'object' || typeof WorkerGlobalScope != 'undefined') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
  121.  
  122. } else
  123.  
  124. // Note that this includes Node.js workers when relevant (pthreads is enabled).
  125. // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
  126. // ENVIRONMENT_IS_NODE.
  127. if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
  128. try {
  129. scriptDirectory = new URL('.', _scriptName).href; // includes trailing slash
  130. } catch {
  131. // Must be a `blob:` or `data:` URL (e.g. `blob:http://site.com/etc/etc`), we cannot
  132. // infer anything from them.
  133. }
  134.  
  135. if (!(typeof window == 'object' || typeof WorkerGlobalScope != 'undefined')) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
  136.  
  137. {
  138. // include: web_or_worker_shell_read.js
  139. if (ENVIRONMENT_IS_WORKER) {
  140. readBinary = (url) => {
  141. var xhr = new XMLHttpRequest();
  142. xhr.open('GET', url, false);
  143. xhr.responseType = 'arraybuffer';
  144. xhr.send(null);
  145. return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
  146. };
  147. }
  148.  
  149. readAsync = async (url) => {
  150. // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
  151. // See https://github.com/github/fetch/pull/92#issuecomment-140665932
  152. // Cordova or Electron apps are typically loaded from a file:// url.
  153. // So use XHR on webview if URL is a file URL.
  154. if (isFileURI(url)) {
  155. return new Promise((resolve, reject) => {
  156. var xhr = new XMLHttpRequest();
  157. xhr.open('GET', url, true);
  158. xhr.responseType = 'arraybuffer';
  159. xhr.onload = () => {
  160. if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
  161. resolve(xhr.response);
  162. return;
  163. }
  164. reject(xhr.status);
  165. };
  166. xhr.onerror = reject;
  167. xhr.send(null);
  168. });
  169. }
  170. var response = await fetch(url, { credentials: 'same-origin' });
  171. if (response.ok) {
  172. return response.arrayBuffer();
  173. }
  174. throw new Error(response.status + ' : ' + response.url);
  175. };
  176. // end include: web_or_worker_shell_read.js
  177. }
  178. } else
  179. {
  180. throw new Error('environment detection error');
  181. }
  182.  
  183. var out = console.log.bind(console);
  184. var err = console.error.bind(console);
  185.  
  186. var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js';
  187. var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js';
  188. var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js';
  189. var FETCHFS = 'FETCHFS is no longer included by default; build with -lfetchfs.js';
  190. var ICASEFS = 'ICASEFS is no longer included by default; build with -licasefs.js';
  191. var JSFILEFS = 'JSFILEFS is no longer included by default; build with -ljsfilefs.js';
  192. var OPFS = 'OPFS is no longer included by default; build with -lopfs.js';
  193.  
  194. // perform assertions in shell.js after we set up out() and err(), as otherwise
  195. // if an assertion fails it cannot print the message
  196.  
  197. assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.');
  198.  
  199. // end include: shell.js
  200.  
  201. // include: preamble.js
  202. // === Preamble library stuff ===
  203.  
  204. // Documentation for the public APIs defined in this file must be updated in:
  205. // site/source/docs/api_reference/preamble.js.rst
  206. // A prebuilt local version of the documentation is available at:
  207. // site/build/text/docs/api_reference/preamble.js.txt
  208. // You can also build docs locally as HTML or other formats in site/
  209. // An online HTML version (which may be of a different version of Emscripten)
  210. // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
  211.  
  212. var wasmBinary;
  213.  
  214. if (typeof WebAssembly != 'object') {
  215. err('no native wasm support detected');
  216. }
  217.  
  218. // Wasm globals
  219.  
  220. var wasmMemory;
  221.  
  222. //========================================
  223. // Runtime essentials
  224. //========================================
  225.  
  226. // whether we are quitting the application. no code should run after this.
  227. // set in exit() and abort()
  228. var ABORT = false;
  229.  
  230. // set by exit() and abort(). Passed to 'onExit' handler.
  231. // NOTE: This is also used as the process return code code in shell environments
  232. // but only when noExitRuntime is false.
  233. var EXITSTATUS;
  234.  
  235. // In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we
  236. // don't define it at all in release modes. This matches the behaviour of
  237. // MINIMAL_RUNTIME.
  238. // TODO(sbc): Make this the default even without STRICT enabled.
  239. /** @type {function(*, string=)} */
  240. function assert(condition, text) {
  241. if (!condition) {
  242. abort('Assertion failed' + (text ? ': ' + text : ''));
  243. }
  244. }
  245.  
  246. // We used to include malloc/free by default in the past. Show a helpful error in
  247. // builds with assertions.
  248. function _malloc() {
  249. abort('malloc() called but not included in the build - add `_malloc` to EXPORTED_FUNCTIONS');
  250. }
  251. function _free() {
  252. // Show a helpful error since we used to include free by default in the past.
  253. abort('free() called but not included in the build - add `_free` to EXPORTED_FUNCTIONS');
  254. }
  255.  
  256. // Memory management
  257.  
  258. var HEAP,
  259. /** @type {!Int8Array} */
  260. HEAP8,
  261. /** @type {!Uint8Array} */
  262. HEAPU8,
  263. /** @type {!Int16Array} */
  264. HEAP16,
  265. /** @type {!Uint16Array} */
  266. HEAPU16,
  267. /** @type {!Int32Array} */
  268. HEAP32,
  269. /** @type {!Uint32Array} */
  270. HEAPU32,
  271. /** @type {!Float32Array} */
  272. HEAPF32,
  273. /* BigInt64Array type is not correctly defined in closure
  274. /** not-@type {!BigInt64Array} */
  275. HEAP64,
  276. /* BigUint64Array type is not correctly defined in closure
  277. /** not-t@type {!BigUint64Array} */
  278. HEAPU64,
  279. /** @type {!Float64Array} */
  280. HEAPF64;
  281.  
  282. var runtimeInitialized = false;
  283.  
  284. var runtimeExited = false;
  285.  
  286. /**
  287. * Indicates whether filename is delivered via file protocol (as opposed to http/https)
  288. * @noinline
  289. */
  290. var isFileURI = (filename) => filename.startsWith('file://');
  291.  
  292. // include: runtime_shared.js
  293. // include: runtime_stack_check.js
  294. // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
  295. function writeStackCookie() {
  296. var max = _emscripten_stack_get_end();
  297. assert((max & 3) == 0);
  298. // If the stack ends at address zero we write our cookies 4 bytes into the
  299. // stack. This prevents interference with SAFE_HEAP and ASAN which also
  300. // monitor writes to address zero.
  301. if (max == 0) {
  302. max += 4;
  303. }
  304. // The stack grow downwards towards _emscripten_stack_get_end.
  305. // We write cookies to the final two words in the stack and detect if they are
  306. // ever overwritten.
  307. HEAPU32[((max)>>2)] = 0x02135467;
  308. HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
  309. // Also test the global address 0 for integrity.
  310. HEAPU32[((0)>>2)] = 1668509029;
  311. }
  312.  
  313. function checkStackCookie() {
  314. if (ABORT) return;
  315. var max = _emscripten_stack_get_end();
  316. // See writeStackCookie().
  317. if (max == 0) {
  318. max += 4;
  319. }
  320. var cookie1 = HEAPU32[((max)>>2)];
  321. var cookie2 = HEAPU32[(((max)+(4))>>2)];
  322. if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) {
  323. abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
  324. }
  325. // Also test the global address 0 for integrity.
  326. if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) {
  327. abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
  328. }
  329. }
  330. // end include: runtime_stack_check.js
  331. // include: runtime_exceptions.js
  332. // end include: runtime_exceptions.js
  333. // include: runtime_debug.js
  334. var runtimeDebug = true; // Switch to false at runtime to disable logging at the right times
  335.  
  336. // Used by XXXXX_DEBUG settings to output debug messages.
  337. function dbg(...args) {
  338. if (!runtimeDebug && typeof runtimeDebug != 'undefined') return;
  339. // TODO(sbc): Make this configurable somehow. Its not always convenient for
  340. // logging to show up as warnings.
  341. console.warn(...args);
  342. }
  343.  
  344. // Endianness check
  345. (() => {
  346. var h16 = new Int16Array(1);
  347. var h8 = new Int8Array(h16.buffer);
  348. h16[0] = 0x6373;
  349. if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)';
  350. })();
  351.  
  352. function consumedModuleProp(prop) {
  353. if (!Object.getOwnPropertyDescriptor(Module, prop)) {
  354. Object.defineProperty(Module, prop, {
  355. configurable: true,
  356. set() {
  357. abort(`Attempt to set \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`);
  358.  
  359. }
  360. });
  361. }
  362. }
  363.  
  364. function ignoredModuleProp(prop) {
  365. if (Object.getOwnPropertyDescriptor(Module, prop)) {
  366. abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
  367. }
  368. }
  369.  
  370. // forcing the filesystem exports a few things by default
  371. function isExportedByForceFilesystem(name) {
  372. return name === 'FS_createPath' ||
  373. name === 'FS_createDataFile' ||
  374. name === 'FS_createPreloadedFile' ||
  375. name === 'FS_unlink' ||
  376. name === 'addRunDependency' ||
  377. // The old FS has some functionality that WasmFS lacks.
  378. name === 'FS_createLazyFile' ||
  379. name === 'FS_createDevice' ||
  380. name === 'removeRunDependency';
  381. }
  382.  
  383. /**
  384. * Intercept access to a global symbol. This enables us to give informative
  385. * warnings/errors when folks attempt to use symbols they did not include in
  386. * their build, or no symbols that no longer exist.
  387. */
  388. function hookGlobalSymbolAccess(sym, func) {
  389. if (typeof globalThis != 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
  390. Object.defineProperty(globalThis, sym, {
  391. configurable: true,
  392. get() {
  393. func();
  394. return undefined;
  395. }
  396. });
  397. }
  398. }
  399.  
  400. function missingGlobal(sym, msg) {
  401. hookGlobalSymbolAccess(sym, () => {
  402. warnOnce(`\`${sym}\` is not longer defined by emscripten. ${msg}`);
  403. });
  404. }
  405.  
  406. missingGlobal('buffer', 'Please use HEAP8.buffer or wasmMemory.buffer');
  407. missingGlobal('asm', 'Please use wasmExports instead');
  408.  
  409. function missingLibrarySymbol(sym) {
  410. hookGlobalSymbolAccess(sym, () => {
  411. // Can't `abort()` here because it would break code that does runtime
  412. // checks. e.g. `if (typeof SDL === 'undefined')`.
  413. var msg = `\`${sym}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`;
  414. // DEFAULT_LIBRARY_FUNCS_TO_INCLUDE requires the name as it appears in
  415. // library.js, which means $name for a JS name with no prefix, or name
  416. // for a JS name like _name.
  417. var librarySymbol = sym;
  418. if (!librarySymbol.startsWith('_')) {
  419. librarySymbol = '$' + sym;
  420. }
  421. msg += ` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${librarySymbol}')`;
  422. if (isExportedByForceFilesystem(sym)) {
  423. msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
  424. }
  425. warnOnce(msg);
  426. });
  427.  
  428. // Any symbol that is not included from the JS library is also (by definition)
  429. // not exported on the Module object.
  430. unexportedRuntimeSymbol(sym);
  431. }
  432.  
  433. function unexportedRuntimeSymbol(sym) {
  434. if (!Object.getOwnPropertyDescriptor(Module, sym)) {
  435. Object.defineProperty(Module, sym, {
  436. configurable: true,
  437. get() {
  438. var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
  439. if (isExportedByForceFilesystem(sym)) {
  440. msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
  441. }
  442. abort(msg);
  443. }
  444. });
  445. }
  446. }
  447.  
  448. // end include: runtime_debug.js
  449. // include: memoryprofiler.js
  450. // end include: memoryprofiler.js
  451.  
  452.  
  453. function updateMemoryViews() {
  454. var b = wasmMemory.buffer;
  455. HEAP8 = new Int8Array(b);
  456. HEAP16 = new Int16Array(b);
  457. HEAPU8 = new Uint8Array(b);
  458. HEAPU16 = new Uint16Array(b);
  459. HEAP32 = new Int32Array(b);
  460. HEAPU32 = new Uint32Array(b);
  461. HEAPF32 = new Float32Array(b);
  462. HEAPF64 = new Float64Array(b);
  463. HEAP64 = new BigInt64Array(b);
  464. HEAPU64 = new BigUint64Array(b);
  465. }
  466.  
  467. // end include: runtime_shared.js
  468. assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined,
  469. 'JS engine does not provide full typed array support');
  470.  
  471. function preRun() {
  472. if (Module['preRun']) {
  473. if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
  474. while (Module['preRun'].length) {
  475. addOnPreRun(Module['preRun'].shift());
  476. }
  477. }
  478. consumedModuleProp('preRun');
  479. // Begin ATPRERUNS hooks
  480. callRuntimeCallbacks(onPreRuns);
  481. // End ATPRERUNS hooks
  482. }
  483.  
  484. function initRuntime() {
  485. assert(!runtimeInitialized);
  486. runtimeInitialized = true;
  487.  
  488. checkStackCookie();
  489.  
  490. // No ATINITS hooks
  491.  
  492. wasmExports['__wasm_call_ctors']();
  493.  
  494. // No ATPOSTCTORS hooks
  495. }
  496.  
  497. function preMain() {
  498. checkStackCookie();
  499. // No ATMAINS hooks
  500. }
  501.  
  502. function exitRuntime() {
  503. assert(!runtimeExited);
  504. checkStackCookie();
  505. // PThreads reuse the runtime from the main thread.
  506. ___funcs_on_exit(); // Native atexit() functions
  507. // Begin ATEXITS hooks
  508. flush_NO_FILESYSTEM()
  509. // End ATEXITS hooks
  510. runtimeExited = true;
  511. }
  512.  
  513. function postRun() {
  514. checkStackCookie();
  515. // PThreads reuse the runtime from the main thread.
  516.  
  517. if (Module['postRun']) {
  518. if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
  519. while (Module['postRun'].length) {
  520. addOnPostRun(Module['postRun'].shift());
  521. }
  522. }
  523. consumedModuleProp('postRun');
  524.  
  525. // Begin ATPOSTRUNS hooks
  526. callRuntimeCallbacks(onPostRuns);
  527. // End ATPOSTRUNS hooks
  528. }
  529.  
  530. // A counter of dependencies for calling run(). If we need to
  531. // do asynchronous work before running, increment this and
  532. // decrement it. Incrementing must happen in a place like
  533. // Module.preRun (used by emcc to add file preloading).
  534. // Note that you can add dependencies in preRun, even though
  535. // it happens right before run - run will be postponed until
  536. // the dependencies are met.
  537. var runDependencies = 0;
  538. var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
  539. var runDependencyTracking = {};
  540. var runDependencyWatcher = null;
  541.  
  542. function getUniqueRunDependency(id) {
  543. var orig = id;
  544. while (1) {
  545. if (!runDependencyTracking[id]) return id;
  546. id = orig + Math.random();
  547. }
  548. }
  549.  
  550. function addRunDependency(id) {
  551. runDependencies++;
  552.  
  553. Module['monitorRunDependencies']?.(runDependencies);
  554.  
  555. if (id) {
  556. assert(!runDependencyTracking[id]);
  557. runDependencyTracking[id] = 1;
  558. if (runDependencyWatcher === null && typeof setInterval != 'undefined') {
  559. // Check for missing dependencies every few seconds
  560. runDependencyWatcher = setInterval(() => {
  561. if (ABORT) {
  562. clearInterval(runDependencyWatcher);
  563. runDependencyWatcher = null;
  564. return;
  565. }
  566. var shown = false;
  567. for (var dep in runDependencyTracking) {
  568. if (!shown) {
  569. shown = true;
  570. err('still waiting on run dependencies:');
  571. }
  572. err(`dependency: ${dep}`);
  573. }
  574. if (shown) {
  575. err('(end of list)');
  576. }
  577. }, 10000);
  578. }
  579. } else {
  580. err('warning: run dependency added without ID');
  581. }
  582. }
  583.  
  584. function removeRunDependency(id) {
  585. runDependencies--;
  586.  
  587. Module['monitorRunDependencies']?.(runDependencies);
  588.  
  589. if (id) {
  590. assert(runDependencyTracking[id]);
  591. delete runDependencyTracking[id];
  592. } else {
  593. err('warning: run dependency removed without ID');
  594. }
  595. if (runDependencies == 0) {
  596. if (runDependencyWatcher !== null) {
  597. clearInterval(runDependencyWatcher);
  598. runDependencyWatcher = null;
  599. }
  600. if (dependenciesFulfilled) {
  601. var callback = dependenciesFulfilled;
  602. dependenciesFulfilled = null;
  603. callback(); // can add another dependenciesFulfilled
  604. }
  605. }
  606. }
  607.  
  608. /** @param {string|number=} what */
  609. function abort(what) {
  610. Module['onAbort']?.(what);
  611.  
  612. what = 'Aborted(' + what + ')';
  613. // TODO(sbc): Should we remove printing and leave it up to whoever
  614. // catches the exception?
  615. err(what);
  616.  
  617. ABORT = true;
  618.  
  619. // Use a wasm runtime error, because a JS error might be seen as a foreign
  620. // exception, which means we'd run destructors on it. We need the error to
  621. // simply make the program stop.
  622. // FIXME This approach does not work in Wasm EH because it currently does not assume
  623. // all RuntimeErrors are from traps; it decides whether a RuntimeError is from
  624. // a trap or not based on a hidden field within the object. So at the moment
  625. // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
  626. // allows this in the wasm spec.
  627.  
  628. // Suppress closure compiler warning here. Closure compiler's builtin extern
  629. // definition for WebAssembly.RuntimeError claims it takes no arguments even
  630. // though it can.
  631. // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
  632. /** @suppress {checkTypes} */
  633. var e = new WebAssembly.RuntimeError(what);
  634.  
  635. // Throw the error whether or not MODULARIZE is set because abort is used
  636. // in code paths apart from instantiation where an exception is expected
  637. // to be thrown when abort is called.
  638. throw e;
  639. }
  640.  
  641. // show errors on likely calls to FS when it was not included
  642. var FS = {
  643. error() {
  644. abort('Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM');
  645. },
  646. init() { FS.error() },
  647. createDataFile() { FS.error() },
  648. createPreloadedFile() { FS.error() },
  649. createLazyFile() { FS.error() },
  650. open() { FS.error() },
  651. mkdev() { FS.error() },
  652. registerDevice() { FS.error() },
  653. analyzePath() { FS.error() },
  654.  
  655. ErrnoError() { FS.error() },
  656. };
  657.  
  658.  
  659. function createExportWrapper(name, nargs) {
  660. return (...args) => {
  661. assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
  662. assert(!runtimeExited, `native function \`${name}\` called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)`);
  663. var f = wasmExports[name];
  664. assert(f, `exported native function \`${name}\` not found`);
  665. // Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled.
  666. assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`);
  667. return f(...args);
  668. };
  669. }
  670.  
  671. var wasmBinaryFile;
  672.  
  673. function findWasmBinary() {
  674. return locateFile('conftest.wasm');
  675. }
  676.  
  677. function getBinarySync(file) {
  678. if (file == wasmBinaryFile && wasmBinary) {
  679. return new Uint8Array(wasmBinary);
  680. }
  681. if (readBinary) {
  682. return readBinary(file);
  683. }
  684. throw 'both async and sync fetching of the wasm failed';
  685. }
  686.  
  687. async function getWasmBinary(binaryFile) {
  688. // If we don't have the binary yet, load it asynchronously using readAsync.
  689. if (!wasmBinary) {
  690. // Fetch the binary using readAsync
  691. try {
  692. var response = await readAsync(binaryFile);
  693. return new Uint8Array(response);
  694. } catch {
  695. // Fall back to getBinarySync below;
  696. }
  697. }
  698.  
  699. // Otherwise, getBinarySync should be able to get it synchronously
  700. return getBinarySync(binaryFile);
  701. }
  702.  
  703. async function instantiateArrayBuffer(binaryFile, imports) {
  704. try {
  705. var binary = await getWasmBinary(binaryFile);
  706. var instance = await WebAssembly.instantiate(binary, imports);
  707. return instance;
  708. } catch (reason) {
  709. err(`failed to asynchronously prepare wasm: ${reason}`);
  710.  
  711. // Warn on some common problems.
  712. if (isFileURI(wasmBinaryFile)) {
  713. err(`warning: Loading from a file URI (${wasmBinaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`);
  714. }
  715. abort(reason);
  716. }
  717. }
  718.  
  719. async function instantiateAsync(binary, binaryFile, imports) {
  720. if (!binary && typeof WebAssembly.instantiateStreaming == 'function'
  721. // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
  722. && !isFileURI(binaryFile)
  723. // Avoid instantiateStreaming() on Node.js environment for now, as while
  724. // Node.js v18.1.0 implements it, it does not have a full fetch()
  725. // implementation yet.
  726. //
  727. // Reference:
  728. // https://github.com/emscripten-core/emscripten/pull/16917
  729. && !ENVIRONMENT_IS_NODE
  730. ) {
  731. try {
  732. var response = fetch(binaryFile, { credentials: 'same-origin' });
  733. var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
  734. return instantiationResult;
  735. } catch (reason) {
  736. // We expect the most common failure cause to be a bad MIME type for the binary,
  737. // in which case falling back to ArrayBuffer instantiation should work.
  738. err(`wasm streaming compile failed: ${reason}`);
  739. err('falling back to ArrayBuffer instantiation');
  740. // fall back of instantiateArrayBuffer below
  741. };
  742. }
  743. return instantiateArrayBuffer(binaryFile, imports);
  744. }
  745.  
  746. function getWasmImports() {
  747. // prepare imports
  748. return {
  749. 'env': wasmImports,
  750. 'wasi_snapshot_preview1': wasmImports,
  751. }
  752. }
  753.  
  754. // Create the wasm instance.
  755. // Receives the wasm imports, returns the exports.
  756. async function createWasm() {
  757. // Load the wasm module and create an instance of using native support in the JS engine.
  758. // handle a generated wasm instance, receiving its exports and
  759. // performing other necessary setup
  760. /** @param {WebAssembly.Module=} module*/
  761. function receiveInstance(instance, module) {
  762. wasmExports = instance.exports;
  763.  
  764.  
  765.  
  766. wasmMemory = wasmExports['memory'];
  767.  
  768. assert(wasmMemory, 'memory not found in wasm exports');
  769. updateMemoryViews();
  770.  
  771. removeRunDependency('wasm-instantiate');
  772. return wasmExports;
  773. }
  774. // wait for the pthread pool (if any)
  775. addRunDependency('wasm-instantiate');
  776.  
  777. // Prefer streaming instantiation if available.
  778. // Async compilation can be confusing when an error on the page overwrites Module
  779. // (for example, if the order of elements is wrong, and the one defining Module is
  780. // later), so we save Module and check it later.
  781. var trueModule = Module;
  782. function receiveInstantiationResult(result) {
  783. // 'result' is a ResultObject object which has both the module and instance.
  784. // receiveInstance() will swap in the exports (to Module.asm) so they can be called
  785. assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
  786. trueModule = null;
  787. // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line.
  788. // When the regression is fixed, can restore the above PTHREADS-enabled path.
  789. return receiveInstance(result['instance']);
  790. }
  791.  
  792. var info = getWasmImports();
  793.  
  794. // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
  795. // to manually instantiate the Wasm module themselves. This allows pages to
  796. // run the instantiation parallel to any other async startup actions they are
  797. // performing.
  798. // Also pthreads and wasm workers initialize the wasm instance through this
  799. // path.
  800. if (Module['instantiateWasm']) {
  801. return new Promise((resolve, reject) => {
  802. try {
  803. Module['instantiateWasm'](info, (mod, inst) => {
  804. resolve(receiveInstance(mod, inst));
  805. });
  806. } catch(e) {
  807. err(`Module.instantiateWasm callback failed with error: ${e}`);
  808. reject(e);
  809. }
  810. });
  811. }
  812.  
  813. wasmBinaryFile ??= findWasmBinary();
  814. var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
  815. var exports = receiveInstantiationResult(result);
  816. return exports;
  817. }
  818.  
  819. // end include: preamble.js
  820.  
  821. // Begin JS library code
  822.  
  823.  
  824. class ExitStatus {
  825. name = 'ExitStatus';
  826. constructor(status) {
  827. this.message = `Program terminated with exit(${status})`;
  828. this.status = status;
  829. }
  830. }
  831.  
  832. var callRuntimeCallbacks = (callbacks) => {
  833. while (callbacks.length > 0) {
  834. // Pass the module as the first argument.
  835. callbacks.shift()(Module);
  836. }
  837. };
  838. var onPostRuns = [];
  839. var addOnPostRun = (cb) => onPostRuns.push(cb);
  840.  
  841. var onPreRuns = [];
  842. var addOnPreRun = (cb) => onPreRuns.push(cb);
  843.  
  844.  
  845.  
  846. /**
  847. * @param {number} ptr
  848. * @param {string} type
  849. */
  850. function getValue(ptr, type = 'i8') {
  851. if (type.endsWith('*')) type = '*';
  852. switch (type) {
  853. case 'i1': return HEAP8[ptr];
  854. case 'i8': return HEAP8[ptr];
  855. case 'i16': return HEAP16[((ptr)>>1)];
  856. case 'i32': return HEAP32[((ptr)>>2)];
  857. case 'i64': return HEAP64[((ptr)>>3)];
  858. case 'float': return HEAPF32[((ptr)>>2)];
  859. case 'double': return HEAPF64[((ptr)>>3)];
  860. case '*': return HEAPU32[((ptr)>>2)];
  861. default: abort(`invalid type for getValue: ${type}`);
  862. }
  863. }
  864.  
  865. var noExitRuntime = false;
  866.  
  867. var ptrToString = (ptr) => {
  868. assert(typeof ptr === 'number');
  869. // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
  870. ptr >>>= 0;
  871. return '0x' + ptr.toString(16).padStart(8, '0');
  872. };
  873.  
  874.  
  875. /**
  876. * @param {number} ptr
  877. * @param {number} value
  878. * @param {string} type
  879. */
  880. function setValue(ptr, value, type = 'i8') {
  881. if (type.endsWith('*')) type = '*';
  882. switch (type) {
  883. case 'i1': HEAP8[ptr] = value; break;
  884. case 'i8': HEAP8[ptr] = value; break;
  885. case 'i16': HEAP16[((ptr)>>1)] = value; break;
  886. case 'i32': HEAP32[((ptr)>>2)] = value; break;
  887. case 'i64': HEAP64[((ptr)>>3)] = BigInt(value); break;
  888. case 'float': HEAPF32[((ptr)>>2)] = value; break;
  889. case 'double': HEAPF64[((ptr)>>3)] = value; break;
  890. case '*': HEAPU32[((ptr)>>2)] = value; break;
  891. default: abort(`invalid type for setValue: ${type}`);
  892. }
  893. }
  894.  
  895. var stackRestore = (val) => __emscripten_stack_restore(val);
  896.  
  897. var stackSave = () => _emscripten_stack_get_current();
  898.  
  899. var warnOnce = (text) => {
  900. warnOnce.shown ||= {};
  901. if (!warnOnce.shown[text]) {
  902. warnOnce.shown[text] = 1;
  903. if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text;
  904. err(text);
  905. }
  906. };
  907.  
  908. var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder() : undefined;
  909.  
  910. /**
  911. * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
  912. * array that contains uint8 values, returns a copy of that string as a
  913. * Javascript String object.
  914. * heapOrArray is either a regular array, or a JavaScript typed array view.
  915. * @param {number=} idx
  916. * @param {number=} maxBytesToRead
  917. * @return {string}
  918. */
  919. var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead = NaN) => {
  920. var endIdx = idx + maxBytesToRead;
  921. var endPtr = idx;
  922. // TextDecoder needs to know the byte length in advance, it doesn't stop on
  923. // null terminator by itself. Also, use the length info to avoid running tiny
  924. // strings through TextDecoder, since .subarray() allocates garbage.
  925. // (As a tiny code save trick, compare endPtr against endIdx using a negation,
  926. // so that undefined/NaN means Infinity)
  927. while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
  928.  
  929. if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
  930. return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
  931. }
  932. var str = '';
  933. // If building with TextDecoder, we have already computed the string length
  934. // above, so test loop end condition against that
  935. while (idx < endPtr) {
  936. // For UTF8 byte structure, see:
  937. // http://en.wikipedia.org/wiki/UTF-8#Description
  938. // https://www.ietf.org/rfc/rfc2279.txt
  939. // https://tools.ietf.org/html/rfc3629
  940. var u0 = heapOrArray[idx++];
  941. if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
  942. var u1 = heapOrArray[idx++] & 63;
  943. if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
  944. var u2 = heapOrArray[idx++] & 63;
  945. if ((u0 & 0xF0) == 0xE0) {
  946. u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
  947. } else {
  948. if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte ' + ptrToString(u0) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!');
  949. u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
  950. }
  951.  
  952. if (u0 < 0x10000) {
  953. str += String.fromCharCode(u0);
  954. } else {
  955. var ch = u0 - 0x10000;
  956. str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
  957. }
  958. }
  959. return str;
  960. };
  961.  
  962. /**
  963. * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
  964. * emscripten HEAP, returns a copy of that string as a Javascript String object.
  965. *
  966. * @param {number} ptr
  967. * @param {number=} maxBytesToRead - An optional length that specifies the
  968. * maximum number of bytes to read. You can omit this parameter to scan the
  969. * string until the first 0 byte. If maxBytesToRead is passed, and the string
  970. * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
  971. * string will cut short at that byte index (i.e. maxBytesToRead will not
  972. * produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
  973. * frequent uses of UTF8ToString() with and without maxBytesToRead may throw
  974. * JS JIT optimizations off, so it is worth to consider consistently using one
  975. * @return {string}
  976. */
  977. var UTF8ToString = (ptr, maxBytesToRead) => {
  978. assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
  979. return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
  980. };
  981. var SYSCALLS = {
  982. varargs:undefined,
  983. getStr(ptr) {
  984. var ret = UTF8ToString(ptr);
  985. return ret;
  986. },
  987. };
  988. var _fd_close = (fd) => {
  989. abort('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM');
  990. };
  991.  
  992. var INT53_MAX = 9007199254740992;
  993.  
  994. var INT53_MIN = -9007199254740992;
  995. var bigintToI53Checked = (num) => (num < INT53_MIN || num > INT53_MAX) ? NaN : Number(num);
  996. function _fd_seek(fd, offset, whence, newOffset) {
  997. offset = bigintToI53Checked(offset);
  998.  
  999.  
  1000. return 70;
  1001. ;
  1002. }
  1003.  
  1004. var printCharBuffers = [null,[],[]];
  1005.  
  1006. var printChar = (stream, curr) => {
  1007. var buffer = printCharBuffers[stream];
  1008. assert(buffer);
  1009. if (curr === 0 || curr === 10) {
  1010. (stream === 1 ? out : err)(UTF8ArrayToString(buffer));
  1011. buffer.length = 0;
  1012. } else {
  1013. buffer.push(curr);
  1014. }
  1015. };
  1016.  
  1017. var flush_NO_FILESYSTEM = () => {
  1018. // flush anything remaining in the buffers during shutdown
  1019. _fflush(0);
  1020. if (printCharBuffers[1].length) printChar(1, 10);
  1021. if (printCharBuffers[2].length) printChar(2, 10);
  1022. };
  1023.  
  1024.  
  1025. var _fd_write = (fd, iov, iovcnt, pnum) => {
  1026. // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
  1027. var num = 0;
  1028. for (var i = 0; i < iovcnt; i++) {
  1029. var ptr = HEAPU32[((iov)>>2)];
  1030. var len = HEAPU32[(((iov)+(4))>>2)];
  1031. iov += 8;
  1032. for (var j = 0; j < len; j++) {
  1033. printChar(fd, HEAPU8[ptr+j]);
  1034. }
  1035. num += len;
  1036. }
  1037. HEAPU32[((pnum)>>2)] = num;
  1038. return 0;
  1039. };
  1040.  
  1041.  
  1042. var runtimeKeepaliveCounter = 0;
  1043. var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
  1044. var _proc_exit = (code) => {
  1045. EXITSTATUS = code;
  1046. if (!keepRuntimeAlive()) {
  1047. Module['onExit']?.(code);
  1048. ABORT = true;
  1049. }
  1050. quit_(code, new ExitStatus(code));
  1051. };
  1052.  
  1053.  
  1054. /** @param {boolean|number=} implicit */
  1055. var exitJS = (status, implicit) => {
  1056. EXITSTATUS = status;
  1057.  
  1058. if (!keepRuntimeAlive()) {
  1059. exitRuntime();
  1060. }
  1061.  
  1062. // if exit() was called explicitly, warn the user if the runtime isn't actually being shut down
  1063. if (keepRuntimeAlive() && !implicit) {
  1064. var msg = `program exited (with status: ${status}), but keepRuntimeAlive() is set (counter=${runtimeKeepaliveCounter}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;
  1065. err(msg);
  1066. }
  1067.  
  1068. _proc_exit(status);
  1069. };
  1070.  
  1071. var handleException = (e) => {
  1072. // Certain exception types we do not treat as errors since they are used for
  1073. // internal control flow.
  1074. // 1. ExitStatus, which is thrown by exit()
  1075. // 2. "unwind", which is thrown by emscripten_unwind_to_js_event_loop() and others
  1076. // that wish to return to JS event loop.
  1077. if (e instanceof ExitStatus || e == 'unwind') {
  1078. return EXITSTATUS;
  1079. }
  1080. checkStackCookie();
  1081. if (e instanceof WebAssembly.RuntimeError) {
  1082. if (_emscripten_stack_get_current() <= 0) {
  1083. err('Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 65536)');
  1084. }
  1085. }
  1086. quit_(1, e);
  1087. };
  1088. // End JS library code
  1089.  
  1090. // include: postlibrary.js
  1091. // This file is included after the automatically-generated JS library code
  1092. // but before the wasm module is created.
  1093.  
  1094. {
  1095.  
  1096. // Begin ATMODULES hooks
  1097. if (Module['noExitRuntime']) noExitRuntime = Module['noExitRuntime'];
  1098. if (Module['print']) out = Module['print'];
  1099. if (Module['printErr']) err = Module['printErr'];
  1100. if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
  1101.  
  1102. Module['FS_createDataFile'] = FS.createDataFile;
  1103. Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
  1104.  
  1105. // End ATMODULES hooks
  1106.  
  1107. checkIncomingModuleAPI();
  1108.  
  1109. if (Module['arguments']) arguments_ = Module['arguments'];
  1110. if (Module['thisProgram']) thisProgram = Module['thisProgram'];
  1111.  
  1112. // Assertions on removed incoming Module JS APIs.
  1113. assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
  1114. assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
  1115. assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
  1116. assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
  1117. assert(typeof Module['read'] == 'undefined', 'Module.read option was removed');
  1118. assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
  1119. assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
  1120. assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)');
  1121. assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
  1122. assert(typeof Module['ENVIRONMENT'] == 'undefined', 'Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');
  1123. assert(typeof Module['STACK_SIZE'] == 'undefined', 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
  1124. // If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY
  1125. assert(typeof Module['wasmMemory'] == 'undefined', 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally');
  1126. assert(typeof Module['INITIAL_MEMORY'] == 'undefined', 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically');
  1127.  
  1128. }
  1129.  
  1130. // Begin runtime exports
  1131. var missingLibrarySymbols = [
  1132. 'writeI53ToI64',
  1133. 'writeI53ToI64Clamped',
  1134. 'writeI53ToI64Signaling',
  1135. 'writeI53ToU64Clamped',
  1136. 'writeI53ToU64Signaling',
  1137. 'readI53FromI64',
  1138. 'readI53FromU64',
  1139. 'convertI32PairToI53',
  1140. 'convertI32PairToI53Checked',
  1141. 'convertU32PairToI53',
  1142. 'stackAlloc',
  1143. 'getTempRet0',
  1144. 'setTempRet0',
  1145. 'zeroMemory',
  1146. 'getHeapMax',
  1147. 'abortOnCannotGrowMemory',
  1148. 'growMemory',
  1149. 'strError',
  1150. 'inetPton4',
  1151. 'inetNtop4',
  1152. 'inetPton6',
  1153. 'inetNtop6',
  1154. 'readSockaddr',
  1155. 'writeSockaddr',
  1156. 'emscriptenLog',
  1157. 'readEmAsmArgs',
  1158. 'jstoi_q',
  1159. 'getExecutableName',
  1160. 'listenOnce',
  1161. 'autoResumeAudioContext',
  1162. 'getDynCaller',
  1163. 'dynCall',
  1164. 'runtimeKeepalivePush',
  1165. 'runtimeKeepalivePop',
  1166. 'callUserCallback',
  1167. 'maybeExit',
  1168. 'asmjsMangle',
  1169. 'asyncLoad',
  1170. 'alignMemory',
  1171. 'mmapAlloc',
  1172. 'HandleAllocator',
  1173. 'getNativeTypeSize',
  1174. 'addOnInit',
  1175. 'addOnPostCtor',
  1176. 'addOnPreMain',
  1177. 'addOnExit',
  1178. 'STACK_SIZE',
  1179. 'STACK_ALIGN',
  1180. 'POINTER_SIZE',
  1181. 'ASSERTIONS',
  1182. 'getCFunc',
  1183. 'ccall',
  1184. 'cwrap',
  1185. 'uleb128Encode',
  1186. 'sigToWasmTypes',
  1187. 'generateFuncType',
  1188. 'convertJsFunctionToWasm',
  1189. 'getEmptyTableSlot',
  1190. 'updateTableMap',
  1191. 'getFunctionAddress',
  1192. 'addFunction',
  1193. 'removeFunction',
  1194. 'reallyNegative',
  1195. 'unSign',
  1196. 'strLen',
  1197. 'reSign',
  1198. 'formatString',
  1199. 'stringToUTF8Array',
  1200. 'stringToUTF8',
  1201. 'lengthBytesUTF8',
  1202. 'intArrayFromString',
  1203. 'intArrayToString',
  1204. 'AsciiToString',
  1205. 'stringToAscii',
  1206. 'UTF16ToString',
  1207. 'stringToUTF16',
  1208. 'lengthBytesUTF16',
  1209. 'UTF32ToString',
  1210. 'stringToUTF32',
  1211. 'lengthBytesUTF32',
  1212. 'stringToNewUTF8',
  1213. 'stringToUTF8OnStack',
  1214. 'writeArrayToMemory',
  1215. 'registerKeyEventCallback',
  1216. 'maybeCStringToJsString',
  1217. 'findEventTarget',
  1218. 'getBoundingClientRect',
  1219. 'fillMouseEventData',
  1220. 'registerMouseEventCallback',
  1221. 'registerWheelEventCallback',
  1222. 'registerUiEventCallback',
  1223. 'registerFocusEventCallback',
  1224. 'fillDeviceOrientationEventData',
  1225. 'registerDeviceOrientationEventCallback',
  1226. 'fillDeviceMotionEventData',
  1227. 'registerDeviceMotionEventCallback',
  1228. 'screenOrientation',
  1229. 'fillOrientationChangeEventData',
  1230. 'registerOrientationChangeEventCallback',
  1231. 'fillFullscreenChangeEventData',
  1232. 'registerFullscreenChangeEventCallback',
  1233. 'JSEvents_requestFullscreen',
  1234. 'JSEvents_resizeCanvasForFullscreen',
  1235. 'registerRestoreOldStyle',
  1236. 'hideEverythingExceptGivenElement',
  1237. 'restoreHiddenElements',
  1238. 'setLetterbox',
  1239. 'softFullscreenResizeWebGLRenderTarget',
  1240. 'doRequestFullscreen',
  1241. 'fillPointerlockChangeEventData',
  1242. 'registerPointerlockChangeEventCallback',
  1243. 'registerPointerlockErrorEventCallback',
  1244. 'requestPointerLock',
  1245. 'fillVisibilityChangeEventData',
  1246. 'registerVisibilityChangeEventCallback',
  1247. 'registerTouchEventCallback',
  1248. 'fillGamepadEventData',
  1249. 'registerGamepadEventCallback',
  1250. 'registerBeforeUnloadEventCallback',
  1251. 'fillBatteryEventData',
  1252. 'battery',
  1253. 'registerBatteryEventCallback',
  1254. 'setCanvasElementSize',
  1255. 'getCanvasElementSize',
  1256. 'jsStackTrace',
  1257. 'getCallstack',
  1258. 'convertPCtoSourceLocation',
  1259. 'getEnvStrings',
  1260. 'checkWasiClock',
  1261. 'wasiRightsToMuslOFlags',
  1262. 'wasiOFlagsToMuslOFlags',
  1263. 'initRandomFill',
  1264. 'randomFill',
  1265. 'safeSetTimeout',
  1266. 'setImmediateWrapped',
  1267. 'safeRequestAnimationFrame',
  1268. 'clearImmediateWrapped',
  1269. 'registerPostMainLoop',
  1270. 'registerPreMainLoop',
  1271. 'getPromise',
  1272. 'makePromise',
  1273. 'idsToPromises',
  1274. 'makePromiseCallback',
  1275. 'ExceptionInfo',
  1276. 'findMatchingCatch',
  1277. 'Browser_asyncPrepareDataCounter',
  1278. 'isLeapYear',
  1279. 'ydayFromDate',
  1280. 'arraySum',
  1281. 'addDays',
  1282. 'getSocketFromFD',
  1283. 'getSocketAddress',
  1284. 'FS_createPreloadedFile',
  1285. 'FS_modeStringToFlags',
  1286. 'FS_getMode',
  1287. 'FS_stdin_getChar',
  1288. 'FS_mkdirTree',
  1289. '_setNetworkCallback',
  1290. 'heapObjectForWebGLType',
  1291. 'toTypedArrayIndex',
  1292. 'webgl_enable_ANGLE_instanced_arrays',
  1293. 'webgl_enable_OES_vertex_array_object',
  1294. 'webgl_enable_WEBGL_draw_buffers',
  1295. 'webgl_enable_WEBGL_multi_draw',
  1296. 'webgl_enable_EXT_polygon_offset_clamp',
  1297. 'webgl_enable_EXT_clip_control',
  1298. 'webgl_enable_WEBGL_polygon_mode',
  1299. 'emscriptenWebGLGet',
  1300. 'computeUnpackAlignedImageSize',
  1301. 'colorChannelsInGlTextureFormat',
  1302. 'emscriptenWebGLGetTexPixelData',
  1303. 'emscriptenWebGLGetUniform',
  1304. 'webglGetUniformLocation',
  1305. 'webglPrepareUniformLocationsBeforeFirstUse',
  1306. 'webglGetLeftBracePos',
  1307. 'emscriptenWebGLGetVertexAttrib',
  1308. '__glGetActiveAttribOrUniform',
  1309. 'writeGLArray',
  1310. 'registerWebGlEventCallback',
  1311. 'runAndAbortIfError',
  1312. 'ALLOC_NORMAL',
  1313. 'ALLOC_STACK',
  1314. 'allocate',
  1315. 'writeStringToMemory',
  1316. 'writeAsciiToMemory',
  1317. 'demangle',
  1318. 'stackTrace',
  1319. ];
  1320. missingLibrarySymbols.forEach(missingLibrarySymbol)
  1321.  
  1322. var unexportedSymbols = [
  1323. 'run',
  1324. 'addRunDependency',
  1325. 'removeRunDependency',
  1326. 'out',
  1327. 'err',
  1328. 'callMain',
  1329. 'abort',
  1330. 'wasmMemory',
  1331. 'wasmExports',
  1332. 'HEAPF32',
  1333. 'HEAPF64',
  1334. 'HEAP8',
  1335. 'HEAPU8',
  1336. 'HEAP16',
  1337. 'HEAPU16',
  1338. 'HEAP32',
  1339. 'HEAPU32',
  1340. 'HEAP64',
  1341. 'HEAPU64',
  1342. 'writeStackCookie',
  1343. 'checkStackCookie',
  1344. 'INT53_MAX',
  1345. 'INT53_MIN',
  1346. 'bigintToI53Checked',
  1347. 'stackSave',
  1348. 'stackRestore',
  1349. 'ptrToString',
  1350. 'exitJS',
  1351. 'ENV',
  1352. 'ERRNO_CODES',
  1353. 'DNS',
  1354. 'Protocols',
  1355. 'Sockets',
  1356. 'timers',
  1357. 'warnOnce',
  1358. 'readEmAsmArgsArray',
  1359. 'handleException',
  1360. 'keepRuntimeAlive',
  1361. 'wasmTable',
  1362. 'noExitRuntime',
  1363. 'addOnPreRun',
  1364. 'addOnPostRun',
  1365. 'freeTableIndexes',
  1366. 'functionsInTableMap',
  1367. 'setValue',
  1368. 'getValue',
  1369. 'PATH',
  1370. 'PATH_FS',
  1371. 'UTF8Decoder',
  1372. 'UTF8ArrayToString',
  1373. 'UTF8ToString',
  1374. 'UTF16Decoder',
  1375. 'JSEvents',
  1376. 'specialHTMLTargets',
  1377. 'findCanvasEventTarget',
  1378. 'currentFullscreenStrategy',
  1379. 'restoreOldWindowedStyle',
  1380. 'UNWIND_CACHE',
  1381. 'ExitStatus',
  1382. 'flush_NO_FILESYSTEM',
  1383. 'emSetImmediate',
  1384. 'emClearImmediate_deps',
  1385. 'emClearImmediate',
  1386. 'promiseMap',
  1387. 'uncaughtExceptionCount',
  1388. 'exceptionLast',
  1389. 'exceptionCaught',
  1390. 'Browser',
  1391. 'getPreloadedImageData__data',
  1392. 'wget',
  1393. 'MONTH_DAYS_REGULAR',
  1394. 'MONTH_DAYS_LEAP',
  1395. 'MONTH_DAYS_REGULAR_CUMULATIVE',
  1396. 'MONTH_DAYS_LEAP_CUMULATIVE',
  1397. 'SYSCALLS',
  1398. 'preloadPlugins',
  1399. 'FS_stdin_getChar_buffer',
  1400. 'FS_unlink',
  1401. 'FS_createPath',
  1402. 'FS_createDevice',
  1403. 'FS_readFile',
  1404. 'FS',
  1405. 'FS_root',
  1406. 'FS_mounts',
  1407. 'FS_devices',
  1408. 'FS_streams',
  1409. 'FS_nextInode',
  1410. 'FS_nameTable',
  1411. 'FS_currentPath',
  1412. 'FS_initialized',
  1413. 'FS_ignorePermissions',
  1414. 'FS_filesystems',
  1415. 'FS_syncFSRequests',
  1416. 'FS_readFiles',
  1417. 'FS_lookupPath',
  1418. 'FS_getPath',
  1419. 'FS_hashName',
  1420. 'FS_hashAddNode',
  1421. 'FS_hashRemoveNode',
  1422. 'FS_lookupNode',
  1423. 'FS_createNode',
  1424. 'FS_destroyNode',
  1425. 'FS_isRoot',
  1426. 'FS_isMountpoint',
  1427. 'FS_isFile',
  1428. 'FS_isDir',
  1429. 'FS_isLink',
  1430. 'FS_isChrdev',
  1431. 'FS_isBlkdev',
  1432. 'FS_isFIFO',
  1433. 'FS_isSocket',
  1434. 'FS_flagsToPermissionString',
  1435. 'FS_nodePermissions',
  1436. 'FS_mayLookup',
  1437. 'FS_mayCreate',
  1438. 'FS_mayDelete',
  1439. 'FS_mayOpen',
  1440. 'FS_checkOpExists',
  1441. 'FS_nextfd',
  1442. 'FS_getStreamChecked',
  1443. 'FS_getStream',
  1444. 'FS_createStream',
  1445. 'FS_closeStream',
  1446. 'FS_dupStream',
  1447. 'FS_doSetAttr',
  1448. 'FS_chrdev_stream_ops',
  1449. 'FS_major',
  1450. 'FS_minor',
  1451. 'FS_makedev',
  1452. 'FS_registerDevice',
  1453. 'FS_getDevice',
  1454. 'FS_getMounts',
  1455. 'FS_syncfs',
  1456. 'FS_mount',
  1457. 'FS_unmount',
  1458. 'FS_lookup',
  1459. 'FS_mknod',
  1460. 'FS_statfs',
  1461. 'FS_statfsStream',
  1462. 'FS_statfsNode',
  1463. 'FS_create',
  1464. 'FS_mkdir',
  1465. 'FS_mkdev',
  1466. 'FS_symlink',
  1467. 'FS_rename',
  1468. 'FS_rmdir',
  1469. 'FS_readdir',
  1470. 'FS_readlink',
  1471. 'FS_stat',
  1472. 'FS_fstat',
  1473. 'FS_lstat',
  1474. 'FS_doChmod',
  1475. 'FS_chmod',
  1476. 'FS_lchmod',
  1477. 'FS_fchmod',
  1478. 'FS_doChown',
  1479. 'FS_chown',
  1480. 'FS_lchown',
  1481. 'FS_fchown',
  1482. 'FS_doTruncate',
  1483. 'FS_truncate',
  1484. 'FS_ftruncate',
  1485. 'FS_utime',
  1486. 'FS_open',
  1487. 'FS_close',
  1488. 'FS_isClosed',
  1489. 'FS_llseek',
  1490. 'FS_read',
  1491. 'FS_write',
  1492. 'FS_mmap',
  1493. 'FS_msync',
  1494. 'FS_ioctl',
  1495. 'FS_writeFile',
  1496. 'FS_cwd',
  1497. 'FS_chdir',
  1498. 'FS_createDefaultDirectories',
  1499. 'FS_createDefaultDevices',
  1500. 'FS_createSpecialDirectories',
  1501. 'FS_createStandardStreams',
  1502. 'FS_staticInit',
  1503. 'FS_init',
  1504. 'FS_quit',
  1505. 'FS_findObject',
  1506. 'FS_analyzePath',
  1507. 'FS_createFile',
  1508. 'FS_createDataFile',
  1509. 'FS_forceLoadFile',
  1510. 'FS_createLazyFile',
  1511. 'FS_absolutePath',
  1512. 'FS_createFolder',
  1513. 'FS_createLink',
  1514. 'FS_joinPath',
  1515. 'FS_mmapAlloc',
  1516. 'FS_standardizePath',
  1517. 'MEMFS',
  1518. 'TTY',
  1519. 'PIPEFS',
  1520. 'SOCKFS',
  1521. 'NODEFS',
  1522. 'NODERAWFS',
  1523. 'tempFixedLengthArray',
  1524. 'miniTempWebGLFloatBuffers',
  1525. 'miniTempWebGLIntBuffers',
  1526. 'GL',
  1527. 'AL',
  1528. 'GLUT',
  1529. 'EGL',
  1530. 'GLEW',
  1531. 'IDBStore',
  1532. 'SDL',
  1533. 'SDL_gfx',
  1534. 'allocateUTF8',
  1535. 'allocateUTF8OnStack',
  1536. 'print',
  1537. 'printErr',
  1538. 'jstoi_s',
  1539. ];
  1540. unexportedSymbols.forEach(unexportedRuntimeSymbol);
  1541.  
  1542. // End runtime exports
  1543. // Begin JS library exports
  1544. // End JS library exports
  1545.  
  1546. // end include: postlibrary.js
  1547.  
  1548. function checkIncomingModuleAPI() {
  1549. ignoredModuleProp('fetchSettings');
  1550. }
  1551. var wasmImports = {
  1552. /** @export */
  1553. fd_close: _fd_close,
  1554. /** @export */
  1555. fd_seek: _fd_seek,
  1556. /** @export */
  1557. fd_write: _fd_write
  1558. };
  1559. var wasmExports;
  1560. createWasm();
  1561. var ___wasm_call_ctors = createExportWrapper('__wasm_call_ctors', 0);
  1562. var _main = Module['_main'] = createExportWrapper('main', 2);
  1563. var ___funcs_on_exit = createExportWrapper('__funcs_on_exit', 0);
  1564. var _fflush = createExportWrapper('fflush', 1);
  1565. var _strerror = createExportWrapper('strerror', 1);
  1566. var _emscripten_stack_init = () => (_emscripten_stack_init = wasmExports['emscripten_stack_init'])();
  1567. var _emscripten_stack_get_free = () => (_emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'])();
  1568. var _emscripten_stack_get_base = () => (_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'])();
  1569. var _emscripten_stack_get_end = () => (_emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'])();
  1570. var __emscripten_stack_restore = (a0) => (__emscripten_stack_restore = wasmExports['_emscripten_stack_restore'])(a0);
  1571. var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'])(a0);
  1572. var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
  1573.  
  1574.  
  1575. // include: postamble.js
  1576. // === Auto-generated postamble setup entry stuff ===
  1577.  
  1578. var calledRun;
  1579.  
  1580. function callMain() {
  1581. assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])');
  1582. assert(typeof onPreRuns === 'undefined' || onPreRuns.length == 0, 'cannot call main when preRun functions remain to be called');
  1583.  
  1584. var entryFunction = _main;
  1585.  
  1586. var argc = 0;
  1587. var argv = 0;
  1588.  
  1589. try {
  1590.  
  1591. var ret = entryFunction(argc, argv);
  1592.  
  1593. // if we're not running an evented main loop, it's time to exit
  1594. exitJS(ret, /* implicit = */ true);
  1595. return ret;
  1596. } catch (e) {
  1597. return handleException(e);
  1598. }
  1599. }
  1600.  
  1601. function stackCheckInit() {
  1602. // This is normally called automatically during __wasm_call_ctors but need to
  1603. // get these values before even running any of the ctors so we call it redundantly
  1604. // here.
  1605. _emscripten_stack_init();
  1606. // TODO(sbc): Move writeStackCookie to native to to avoid this.
  1607. writeStackCookie();
  1608. }
  1609.  
  1610. function run() {
  1611.  
  1612. if (runDependencies > 0) {
  1613. dependenciesFulfilled = run;
  1614. return;
  1615. }
  1616.  
  1617. stackCheckInit();
  1618.  
  1619. preRun();
  1620.  
  1621. // a preRun added a dependency, run will be called later
  1622. if (runDependencies > 0) {
  1623. dependenciesFulfilled = run;
  1624. return;
  1625. }
  1626.  
  1627. function doRun() {
  1628. // run may have just been called through dependencies being fulfilled just in this very frame,
  1629. // or while the async setStatus time below was happening
  1630. assert(!calledRun);
  1631. calledRun = true;
  1632. Module['calledRun'] = true;
  1633.  
  1634. if (ABORT) return;
  1635.  
  1636. initRuntime();
  1637.  
  1638. preMain();
  1639.  
  1640. Module['onRuntimeInitialized']?.();
  1641. consumedModuleProp('onRuntimeInitialized');
  1642.  
  1643. var noInitialRun = Module['noInitialRun'] || false;
  1644. if (!noInitialRun) callMain();
  1645.  
  1646. postRun();
  1647. }
  1648.  
  1649. if (Module['setStatus']) {
  1650. Module['setStatus']('Running...');
  1651. setTimeout(() => {
  1652. setTimeout(() => Module['setStatus'](''), 1);
  1653. doRun();
  1654. }, 1);
  1655. } else
  1656. {
  1657. doRun();
  1658. }
  1659. checkStackCookie();
  1660. }
  1661.  
  1662. function preInit() {
  1663. if (Module['preInit']) {
  1664. if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
  1665. while (Module['preInit'].length > 0) {
  1666. Module['preInit'].shift()();
  1667. }
  1668. }
  1669. consumedModuleProp('preInit');
  1670. }
  1671.  
  1672. preInit();
  1673. run();
  1674.  
  1675. // end include: postamble.js
  1676.  
  1677.  
Advertisement
Add Comment
Please, Sign In to add comment