You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1762 lines
60 KiB

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