aplm8000sdk.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723
  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 e.g. in memoryInitializerRequest, which is a large typed array.
  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. abort('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. function updateMemoryViews() {
  341. var b = wasmMemory.buffer;
  342. Module['HEAP8'] = HEAP8 = new Int8Array(b);
  343. Module['HEAP16'] = HEAP16 = new Int16Array(b);
  344. Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
  345. Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
  346. Module['HEAP32'] = HEAP32 = new Int32Array(b);
  347. Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
  348. Module['HEAPF32'] = HEAPF32 = new Float32Array(b);
  349. Module['HEAPF64'] = HEAPF64 = new Float64Array(b);
  350. }
  351. assert(!Module['STACK_SIZE'], 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
  352. assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined,
  353. 'JS engine does not provide full typed array support');
  354. // If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY
  355. assert(!Module['wasmMemory'], 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally');
  356. assert(!Module['INITIAL_MEMORY'], 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically');
  357. // include: runtime_stack_check.js
  358. // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
  359. function writeStackCookie() {
  360. var max = _emscripten_stack_get_end();
  361. assert((max & 3) == 0);
  362. // If the stack ends at address zero we write our cookies 4 bytes into the
  363. // stack. This prevents interference with SAFE_HEAP and ASAN which also
  364. // monitor writes to address zero.
  365. if (max == 0) {
  366. max += 4;
  367. }
  368. // The stack grow downwards towards _emscripten_stack_get_end.
  369. // We write cookies to the final two words in the stack and detect if they are
  370. // ever overwritten.
  371. HEAPU32[((max)>>2)] = 0x02135467;
  372. HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
  373. // Also test the global address 0 for integrity.
  374. HEAPU32[((0)>>2)] = 1668509029;
  375. }
  376. function checkStackCookie() {
  377. if (ABORT) return;
  378. var max = _emscripten_stack_get_end();
  379. // See writeStackCookie().
  380. if (max == 0) {
  381. max += 4;
  382. }
  383. var cookie1 = HEAPU32[((max)>>2)];
  384. var cookie2 = HEAPU32[(((max)+(4))>>2)];
  385. if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) {
  386. abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
  387. }
  388. // Also test the global address 0 for integrity.
  389. if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) {
  390. abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
  391. }
  392. }
  393. // end include: runtime_stack_check.js
  394. // include: runtime_assertions.js
  395. // Endianness check
  396. (function() {
  397. var h16 = new Int16Array(1);
  398. var h8 = new Int8Array(h16.buffer);
  399. h16[0] = 0x6373;
  400. if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)';
  401. })();
  402. // end include: runtime_assertions.js
  403. var __ATPRERUN__ = []; // functions called before the runtime is initialized
  404. var __ATINIT__ = []; // functions called during startup
  405. var __ATMAIN__ = []; // functions called when main() is to be run
  406. var __ATEXIT__ = []; // functions called during shutdown
  407. var __ATPOSTRUN__ = []; // functions called after the main() is called
  408. var runtimeInitialized = false;
  409. function preRun() {
  410. if (Module['preRun']) {
  411. if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
  412. while (Module['preRun'].length) {
  413. addOnPreRun(Module['preRun'].shift());
  414. }
  415. }
  416. callRuntimeCallbacks(__ATPRERUN__);
  417. }
  418. function initRuntime() {
  419. assert(!runtimeInitialized);
  420. runtimeInitialized = true;
  421. checkStackCookie();
  422. callRuntimeCallbacks(__ATINIT__);
  423. }
  424. function preMain() {
  425. checkStackCookie();
  426. callRuntimeCallbacks(__ATMAIN__);
  427. }
  428. function postRun() {
  429. checkStackCookie();
  430. if (Module['postRun']) {
  431. if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
  432. while (Module['postRun'].length) {
  433. addOnPostRun(Module['postRun'].shift());
  434. }
  435. }
  436. callRuntimeCallbacks(__ATPOSTRUN__);
  437. }
  438. function addOnPreRun(cb) {
  439. __ATPRERUN__.unshift(cb);
  440. }
  441. function addOnInit(cb) {
  442. __ATINIT__.unshift(cb);
  443. }
  444. function addOnPreMain(cb) {
  445. __ATMAIN__.unshift(cb);
  446. }
  447. function addOnExit(cb) {
  448. }
  449. function addOnPostRun(cb) {
  450. __ATPOSTRUN__.unshift(cb);
  451. }
  452. // include: runtime_math.js
  453. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
  454. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
  455. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
  456. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
  457. 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');
  458. 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');
  459. 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');
  460. 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');
  461. // end include: runtime_math.js
  462. // A counter of dependencies for calling run(). If we need to
  463. // do asynchronous work before running, increment this and
  464. // decrement it. Incrementing must happen in a place like
  465. // Module.preRun (used by emcc to add file preloading).
  466. // Note that you can add dependencies in preRun, even though
  467. // it happens right before run - run will be postponed until
  468. // the dependencies are met.
  469. var runDependencies = 0;
  470. var runDependencyWatcher = null;
  471. var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
  472. var runDependencyTracking = {};
  473. function getUniqueRunDependency(id) {
  474. var orig = id;
  475. while (1) {
  476. if (!runDependencyTracking[id]) return id;
  477. id = orig + Math.random();
  478. }
  479. }
  480. function addRunDependency(id) {
  481. runDependencies++;
  482. Module['monitorRunDependencies']?.(runDependencies);
  483. if (id) {
  484. assert(!runDependencyTracking[id]);
  485. runDependencyTracking[id] = 1;
  486. if (runDependencyWatcher === null && typeof setInterval != 'undefined') {
  487. // Check for missing dependencies every few seconds
  488. runDependencyWatcher = setInterval(() => {
  489. if (ABORT) {
  490. clearInterval(runDependencyWatcher);
  491. runDependencyWatcher = null;
  492. return;
  493. }
  494. var shown = false;
  495. for (var dep in runDependencyTracking) {
  496. if (!shown) {
  497. shown = true;
  498. err('still waiting on run dependencies:');
  499. }
  500. err(`dependency: ${dep}`);
  501. }
  502. if (shown) {
  503. err('(end of list)');
  504. }
  505. }, 10000);
  506. }
  507. } else {
  508. err('warning: run dependency added without ID');
  509. }
  510. }
  511. function removeRunDependency(id) {
  512. runDependencies--;
  513. Module['monitorRunDependencies']?.(runDependencies);
  514. if (id) {
  515. assert(runDependencyTracking[id]);
  516. delete runDependencyTracking[id];
  517. } else {
  518. err('warning: run dependency removed without ID');
  519. }
  520. if (runDependencies == 0) {
  521. if (runDependencyWatcher !== null) {
  522. clearInterval(runDependencyWatcher);
  523. runDependencyWatcher = null;
  524. }
  525. if (dependenciesFulfilled) {
  526. var callback = dependenciesFulfilled;
  527. dependenciesFulfilled = null;
  528. callback(); // can add another dependenciesFulfilled
  529. }
  530. }
  531. }
  532. /** @param {string|number=} what */
  533. function abort(what) {
  534. Module['onAbort']?.(what);
  535. what = 'Aborted(' + what + ')';
  536. // TODO(sbc): Should we remove printing and leave it up to whoever
  537. // catches the exception?
  538. err(what);
  539. ABORT = true;
  540. EXITSTATUS = 1;
  541. // Use a wasm runtime error, because a JS error might be seen as a foreign
  542. // exception, which means we'd run destructors on it. We need the error to
  543. // simply make the program stop.
  544. // FIXME This approach does not work in Wasm EH because it currently does not assume
  545. // all RuntimeErrors are from traps; it decides whether a RuntimeError is from
  546. // a trap or not based on a hidden field within the object. So at the moment
  547. // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
  548. // allows this in the wasm spec.
  549. // Suppress closure compiler warning here. Closure compiler's builtin extern
  550. // defintion for WebAssembly.RuntimeError claims it takes no arguments even
  551. // though it can.
  552. // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
  553. /** @suppress {checkTypes} */
  554. var e = new WebAssembly.RuntimeError(what);
  555. // Throw the error whether or not MODULARIZE is set because abort is used
  556. // in code paths apart from instantiation where an exception is expected
  557. // to be thrown when abort is called.
  558. throw e;
  559. }
  560. // include: memoryprofiler.js
  561. // end include: memoryprofiler.js
  562. // show errors on likely calls to FS when it was not included
  563. var FS = {
  564. error() {
  565. 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');
  566. },
  567. init() { FS.error() },
  568. createDataFile() { FS.error() },
  569. createPreloadedFile() { FS.error() },
  570. createLazyFile() { FS.error() },
  571. open() { FS.error() },
  572. mkdev() { FS.error() },
  573. registerDevice() { FS.error() },
  574. analyzePath() { FS.error() },
  575. ErrnoError() { FS.error() },
  576. };
  577. Module['FS_createDataFile'] = FS.createDataFile;
  578. Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
  579. // include: URIUtils.js
  580. // Prefix of data URIs emitted by SINGLE_FILE and related options.
  581. var dataURIPrefix = 'data:application/octet-stream;base64,';
  582. /**
  583. * Indicates whether filename is a base64 data URI.
  584. * @noinline
  585. */
  586. var isDataURI = (filename) => filename.startsWith(dataURIPrefix);
  587. /**
  588. * Indicates whether filename is delivered via file protocol (as opposed to http/https)
  589. * @noinline
  590. */
  591. var isFileURI = (filename) => filename.startsWith('file://');
  592. // end include: URIUtils.js
  593. function createExportWrapper(name) {
  594. return (...args) => {
  595. assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
  596. var f = wasmExports[name];
  597. assert(f, `exported native function \`${name}\` not found`);
  598. return f(...args);
  599. };
  600. }
  601. // include: runtime_exceptions.js
  602. // end include: runtime_exceptions.js
  603. var wasmBinaryFile;
  604. wasmBinaryFile = 'aplm8000sdk.wasm';
  605. if (!isDataURI(wasmBinaryFile)) {
  606. wasmBinaryFile = locateFile(wasmBinaryFile);
  607. }
  608. function getBinarySync(file) {
  609. if (file == wasmBinaryFile && wasmBinary) {
  610. return new Uint8Array(wasmBinary);
  611. }
  612. if (readBinary) {
  613. return readBinary(file);
  614. }
  615. throw 'both async and sync fetching of the wasm failed';
  616. }
  617. function getBinaryPromise(binaryFile) {
  618. // If we don't have the binary yet, try to load it asynchronously.
  619. // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
  620. // See https://github.com/github/fetch/pull/92#issuecomment-140665932
  621. // Cordova or Electron apps are typically loaded from a file:// url.
  622. // So use fetch if it is available and the url is not a file, otherwise fall back to XHR.
  623. if (!wasmBinary
  624. && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
  625. if (typeof fetch == 'function'
  626. && !isFileURI(binaryFile)
  627. ) {
  628. return fetch(binaryFile, { credentials: 'same-origin' }).then((response) => {
  629. if (!response['ok']) {
  630. throw `failed to load wasm binary file at '${binaryFile}'`;
  631. }
  632. return response['arrayBuffer']();
  633. }).catch(() => getBinarySync(binaryFile));
  634. }
  635. else if (readAsync) {
  636. // fetch is not available or url is file => try XHR (readAsync uses XHR internally)
  637. return new Promise((resolve, reject) => {
  638. readAsync(binaryFile, (response) => resolve(new Uint8Array(/** @type{!ArrayBuffer} */(response))), reject)
  639. });
  640. }
  641. }
  642. // Otherwise, getBinarySync should be able to get it synchronously
  643. return Promise.resolve().then(() => getBinarySync(binaryFile));
  644. }
  645. function instantiateArrayBuffer(binaryFile, imports, receiver) {
  646. return getBinaryPromise(binaryFile).then((binary) => {
  647. return WebAssembly.instantiate(binary, imports);
  648. }).then(receiver, (reason) => {
  649. err(`failed to asynchronously prepare wasm: ${reason}`);
  650. // Warn on some common problems.
  651. if (isFileURI(wasmBinaryFile)) {
  652. 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`);
  653. }
  654. abort(reason);
  655. });
  656. }
  657. function instantiateAsync(binary, binaryFile, imports, callback) {
  658. if (!binary &&
  659. typeof WebAssembly.instantiateStreaming == 'function' &&
  660. !isDataURI(binaryFile) &&
  661. // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
  662. !isFileURI(binaryFile) &&
  663. // Avoid instantiateStreaming() on Node.js environment for now, as while
  664. // Node.js v18.1.0 implements it, it does not have a full fetch()
  665. // implementation yet.
  666. //
  667. // Reference:
  668. // https://github.com/emscripten-core/emscripten/pull/16917
  669. !ENVIRONMENT_IS_NODE &&
  670. typeof fetch == 'function') {
  671. return fetch(binaryFile, { credentials: 'same-origin' }).then((response) => {
  672. // Suppress closure warning here since the upstream definition for
  673. // instantiateStreaming only allows Promise<Repsponse> rather than
  674. // an actual Response.
  675. // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed.
  676. /** @suppress {checkTypes} */
  677. var result = WebAssembly.instantiateStreaming(response, imports);
  678. return result.then(
  679. callback,
  680. function(reason) {
  681. // We expect the most common failure cause to be a bad MIME type for the binary,
  682. // in which case falling back to ArrayBuffer instantiation should work.
  683. err(`wasm streaming compile failed: ${reason}`);
  684. err('falling back to ArrayBuffer instantiation');
  685. return instantiateArrayBuffer(binaryFile, imports, callback);
  686. });
  687. });
  688. }
  689. return instantiateArrayBuffer(binaryFile, imports, callback);
  690. }
  691. // Create the wasm instance.
  692. // Receives the wasm imports, returns the exports.
  693. function createWasm() {
  694. // prepare imports
  695. var info = {
  696. 'env': wasmImports,
  697. 'wasi_snapshot_preview1': wasmImports,
  698. };
  699. // Load the wasm module and create an instance of using native support in the JS engine.
  700. // handle a generated wasm instance, receiving its exports and
  701. // performing other necessary setup
  702. /** @param {WebAssembly.Module=} module*/
  703. function receiveInstance(instance, module) {
  704. wasmExports = instance.exports;
  705. wasmMemory = wasmExports['memory'];
  706. assert(wasmMemory, 'memory not found in wasm exports');
  707. // This assertion doesn't hold when emscripten is run in --post-link
  708. // mode.
  709. // TODO(sbc): Read INITIAL_MEMORY out of the wasm file in post-link mode.
  710. //assert(wasmMemory.buffer.byteLength === 1073741824);
  711. updateMemoryViews();
  712. addOnInit(wasmExports['__wasm_call_ctors']);
  713. removeRunDependency('wasm-instantiate');
  714. return wasmExports;
  715. }
  716. // wait for the pthread pool (if any)
  717. addRunDependency('wasm-instantiate');
  718. // Prefer streaming instantiation if available.
  719. // Async compilation can be confusing when an error on the page overwrites Module
  720. // (for example, if the order of elements is wrong, and the one defining Module is
  721. // later), so we save Module and check it later.
  722. var trueModule = Module;
  723. function receiveInstantiationResult(result) {
  724. // 'result' is a ResultObject object which has both the module and instance.
  725. // receiveInstance() will swap in the exports (to Module.asm) so they can be called
  726. assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
  727. trueModule = null;
  728. // 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.
  729. // When the regression is fixed, can restore the above PTHREADS-enabled path.
  730. receiveInstance(result['instance']);
  731. }
  732. // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
  733. // to manually instantiate the Wasm module themselves. This allows pages to
  734. // run the instantiation parallel to any other async startup actions they are
  735. // performing.
  736. // Also pthreads and wasm workers initialize the wasm instance through this
  737. // path.
  738. if (Module['instantiateWasm']) {
  739. try {
  740. return Module['instantiateWasm'](info, receiveInstance);
  741. } catch(e) {
  742. err(`Module.instantiateWasm callback failed with error: ${e}`);
  743. return false;
  744. }
  745. }
  746. instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult);
  747. return {}; // no exports yet; we'll fill them in later
  748. }
  749. // Globals used by JS i64 conversions (see makeSetValue)
  750. var tempDouble;
  751. var tempI64;
  752. // include: runtime_debug.js
  753. function legacyModuleProp(prop, newName, incomming=true) {
  754. if (!Object.getOwnPropertyDescriptor(Module, prop)) {
  755. Object.defineProperty(Module, prop, {
  756. configurable: true,
  757. get() {
  758. let extra = incomming ? ' (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)' : '';
  759. abort(`\`Module.${prop}\` has been replaced by \`${newName}\`` + extra);
  760. }
  761. });
  762. }
  763. }
  764. function ignoredModuleProp(prop) {
  765. if (Object.getOwnPropertyDescriptor(Module, prop)) {
  766. abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
  767. }
  768. }
  769. // forcing the filesystem exports a few things by default
  770. function isExportedByForceFilesystem(name) {
  771. return name === 'FS_createPath' ||
  772. name === 'FS_createDataFile' ||
  773. name === 'FS_createPreloadedFile' ||
  774. name === 'FS_unlink' ||
  775. name === 'addRunDependency' ||
  776. // The old FS has some functionality that WasmFS lacks.
  777. name === 'FS_createLazyFile' ||
  778. name === 'FS_createDevice' ||
  779. name === 'removeRunDependency';
  780. }
  781. function missingGlobal(sym, msg) {
  782. if (typeof globalThis !== 'undefined') {
  783. Object.defineProperty(globalThis, sym, {
  784. configurable: true,
  785. get() {
  786. warnOnce(`\`${sym}\` is not longer defined by emscripten. ${msg}`);
  787. return undefined;
  788. }
  789. });
  790. }
  791. }
  792. missingGlobal('buffer', 'Please use HEAP8.buffer or wasmMemory.buffer');
  793. missingGlobal('asm', 'Please use wasmExports instead');
  794. function missingLibrarySymbol(sym) {
  795. if (typeof globalThis !== 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
  796. Object.defineProperty(globalThis, sym, {
  797. configurable: true,
  798. get() {
  799. // Can't `abort()` here because it would break code that does runtime
  800. // checks. e.g. `if (typeof SDL === 'undefined')`.
  801. 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`;
  802. // DEFAULT_LIBRARY_FUNCS_TO_INCLUDE requires the name as it appears in
  803. // library.js, which means $name for a JS name with no prefix, or name
  804. // for a JS name like _name.
  805. var librarySymbol = sym;
  806. if (!librarySymbol.startsWith('_')) {
  807. librarySymbol = '$' + sym;
  808. }
  809. msg += ` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${librarySymbol}')`;
  810. if (isExportedByForceFilesystem(sym)) {
  811. msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
  812. }
  813. warnOnce(msg);
  814. return undefined;
  815. }
  816. });
  817. }
  818. // Any symbol that is not included from the JS libary is also (by definition)
  819. // not exported on the Module object.
  820. unexportedRuntimeSymbol(sym);
  821. }
  822. function unexportedRuntimeSymbol(sym) {
  823. if (!Object.getOwnPropertyDescriptor(Module, sym)) {
  824. Object.defineProperty(Module, sym, {
  825. configurable: true,
  826. get() {
  827. var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
  828. if (isExportedByForceFilesystem(sym)) {
  829. msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
  830. }
  831. abort(msg);
  832. }
  833. });
  834. }
  835. }
  836. // Used by XXXXX_DEBUG settings to output debug messages.
  837. function dbg(...args) {
  838. // TODO(sbc): Make this configurable somehow. Its not always convenient for
  839. // logging to show up as warnings.
  840. console.warn(...args);
  841. }
  842. // end include: runtime_debug.js
  843. // === Body ===
  844. // end include: preamble.js
  845. /** @constructor */
  846. function ExitStatus(status) {
  847. this.name = 'ExitStatus';
  848. this.message = `Program terminated with exit(${status})`;
  849. this.status = status;
  850. }
  851. var callRuntimeCallbacks = (callbacks) => {
  852. while (callbacks.length > 0) {
  853. // Pass the module as the first argument.
  854. callbacks.shift()(Module);
  855. }
  856. };
  857. /**
  858. * @param {number} ptr
  859. * @param {string} type
  860. */
  861. function getValue(ptr, type = 'i8') {
  862. if (type.endsWith('*')) type = '*';
  863. switch (type) {
  864. case 'i1': return HEAP8[ptr];
  865. case 'i8': return HEAP8[ptr];
  866. case 'i16': return HEAP16[((ptr)>>1)];
  867. case 'i32': return HEAP32[((ptr)>>2)];
  868. case 'i64': abort('to do getValue(i64) use WASM_BIGINT');
  869. case 'float': return HEAPF32[((ptr)>>2)];
  870. case 'double': return HEAPF64[((ptr)>>3)];
  871. case '*': return HEAPU32[((ptr)>>2)];
  872. default: abort(`invalid type for getValue: ${type}`);
  873. }
  874. }
  875. var noExitRuntime = Module['noExitRuntime'] || true;
  876. var ptrToString = (ptr) => {
  877. assert(typeof ptr === 'number');
  878. // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
  879. ptr >>>= 0;
  880. return '0x' + ptr.toString(16).padStart(8, '0');
  881. };
  882. /**
  883. * @param {number} ptr
  884. * @param {number} value
  885. * @param {string} type
  886. */
  887. function setValue(ptr, value, type = 'i8') {
  888. if (type.endsWith('*')) type = '*';
  889. switch (type) {
  890. case 'i1': HEAP8[ptr] = value; break;
  891. case 'i8': HEAP8[ptr] = value; break;
  892. case 'i16': HEAP16[((ptr)>>1)] = value; break;
  893. case 'i32': HEAP32[((ptr)>>2)] = value; break;
  894. case 'i64': abort('to do setValue(i64) use WASM_BIGINT');
  895. case 'float': HEAPF32[((ptr)>>2)] = value; break;
  896. case 'double': HEAPF64[((ptr)>>3)] = value; break;
  897. case '*': HEAPU32[((ptr)>>2)] = value; break;
  898. default: abort(`invalid type for setValue: ${type}`);
  899. }
  900. }
  901. var warnOnce = (text) => {
  902. warnOnce.shown ||= {};
  903. if (!warnOnce.shown[text]) {
  904. warnOnce.shown[text] = 1;
  905. if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text;
  906. err(text);
  907. }
  908. };
  909. var _emscripten_date_now = () => Date.now();
  910. var _emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
  911. var getHeapMax = () =>
  912. HEAPU8.length;
  913. var abortOnCannotGrowMemory = (requestedSize) => {
  914. abort(`Cannot enlarge memory arrays to size ${requestedSize} bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value ${HEAP8.length}, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0`);
  915. };
  916. var _emscripten_resize_heap = (requestedSize) => {
  917. var oldSize = HEAPU8.length;
  918. // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
  919. requestedSize >>>= 0;
  920. abortOnCannotGrowMemory(requestedSize);
  921. };
  922. var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf8') : undefined;
  923. /**
  924. * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
  925. * array that contains uint8 values, returns a copy of that string as a
  926. * Javascript String object.
  927. * heapOrArray is either a regular array, or a JavaScript typed array view.
  928. * @param {number} idx
  929. * @param {number=} maxBytesToRead
  930. * @return {string}
  931. */
  932. var UTF8ArrayToString = (heapOrArray, idx, maxBytesToRead) => {
  933. var endIdx = idx + maxBytesToRead;
  934. var endPtr = idx;
  935. // TextDecoder needs to know the byte length in advance, it doesn't stop on
  936. // null terminator by itself. Also, use the length info to avoid running tiny
  937. // strings through TextDecoder, since .subarray() allocates garbage.
  938. // (As a tiny code save trick, compare endPtr against endIdx using a negation,
  939. // so that undefined means Infinity)
  940. while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
  941. if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
  942. return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
  943. }
  944. var str = '';
  945. // If building with TextDecoder, we have already computed the string length
  946. // above, so test loop end condition against that
  947. while (idx < endPtr) {
  948. // For UTF8 byte structure, see:
  949. // http://en.wikipedia.org/wiki/UTF-8#Description
  950. // https://www.ietf.org/rfc/rfc2279.txt
  951. // https://tools.ietf.org/html/rfc3629
  952. var u0 = heapOrArray[idx++];
  953. if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
  954. var u1 = heapOrArray[idx++] & 63;
  955. if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
  956. var u2 = heapOrArray[idx++] & 63;
  957. if ((u0 & 0xF0) == 0xE0) {
  958. u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
  959. } else {
  960. 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!');
  961. u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
  962. }
  963. if (u0 < 0x10000) {
  964. str += String.fromCharCode(u0);
  965. } else {
  966. var ch = u0 - 0x10000;
  967. str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
  968. }
  969. }
  970. return str;
  971. };
  972. /**
  973. * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
  974. * emscripten HEAP, returns a copy of that string as a Javascript String object.
  975. *
  976. * @param {number} ptr
  977. * @param {number=} maxBytesToRead - An optional length that specifies the
  978. * maximum number of bytes to read. You can omit this parameter to scan the
  979. * string until the first 0 byte. If maxBytesToRead is passed, and the string
  980. * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
  981. * string will cut short at that byte index (i.e. maxBytesToRead will not
  982. * produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
  983. * frequent uses of UTF8ToString() with and without maxBytesToRead may throw
  984. * JS JIT optimizations off, so it is worth to consider consistently using one
  985. * @return {string}
  986. */
  987. var UTF8ToString = (ptr, maxBytesToRead) => {
  988. assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
  989. return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
  990. };
  991. var SYSCALLS = {
  992. varargs:undefined,
  993. get() {
  994. assert(SYSCALLS.varargs != undefined);
  995. // the `+` prepended here is necessary to convince the JSCompiler that varargs is indeed a number.
  996. var ret = HEAP32[((+SYSCALLS.varargs)>>2)];
  997. SYSCALLS.varargs += 4;
  998. return ret;
  999. },
  1000. getp() { return SYSCALLS.get() },
  1001. getStr(ptr) {
  1002. var ret = UTF8ToString(ptr);
  1003. return ret;
  1004. },
  1005. };
  1006. var _fd_close = (fd) => {
  1007. abort('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM');
  1008. };
  1009. var convertI32PairToI53Checked = (lo, hi) => {
  1010. assert(lo == (lo >>> 0) || lo == (lo|0)); // lo should either be a i32 or a u32
  1011. assert(hi === (hi|0)); // hi should be a i32
  1012. return ((hi + 0x200000) >>> 0 < 0x400001 - !!lo) ? (lo >>> 0) + hi * 4294967296 : NaN;
  1013. };
  1014. function _fd_seek(fd,offset_low, offset_high,whence,newOffset) {
  1015. var offset = convertI32PairToI53Checked(offset_low, offset_high);;
  1016. return 70;
  1017. ;
  1018. }
  1019. var printCharBuffers = [null,[],[]];
  1020. var printChar = (stream, curr) => {
  1021. var buffer = printCharBuffers[stream];
  1022. assert(buffer);
  1023. if (curr === 0 || curr === 10) {
  1024. (stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0));
  1025. buffer.length = 0;
  1026. } else {
  1027. buffer.push(curr);
  1028. }
  1029. };
  1030. var flush_NO_FILESYSTEM = () => {
  1031. // flush anything remaining in the buffers during shutdown
  1032. _fflush(0);
  1033. if (printCharBuffers[1].length) printChar(1, 10);
  1034. if (printCharBuffers[2].length) printChar(2, 10);
  1035. };
  1036. var _fd_write = (fd, iov, iovcnt, pnum) => {
  1037. // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
  1038. var num = 0;
  1039. for (var i = 0; i < iovcnt; i++) {
  1040. var ptr = HEAPU32[((iov)>>2)];
  1041. var len = HEAPU32[(((iov)+(4))>>2)];
  1042. iov += 8;
  1043. for (var j = 0; j < len; j++) {
  1044. printChar(fd, HEAPU8[ptr+j]);
  1045. }
  1046. num += len;
  1047. }
  1048. HEAPU32[((pnum)>>2)] = num;
  1049. return 0;
  1050. };
  1051. var runtimeKeepaliveCounter = 0;
  1052. var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
  1053. var _proc_exit = (code) => {
  1054. EXITSTATUS = code;
  1055. if (!keepRuntimeAlive()) {
  1056. Module['onExit']?.(code);
  1057. ABORT = true;
  1058. }
  1059. quit_(code, new ExitStatus(code));
  1060. };
  1061. /** @param {boolean|number=} implicit */
  1062. var exitJS = (status, implicit) => {
  1063. EXITSTATUS = status;
  1064. checkUnflushedContent();
  1065. // if exit() was called explicitly, warn the user if the runtime isn't actually being shut down
  1066. if (keepRuntimeAlive() && !implicit) {
  1067. 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)`;
  1068. err(msg);
  1069. }
  1070. _proc_exit(status);
  1071. };
  1072. var handleException = (e) => {
  1073. // Certain exception types we do not treat as errors since they are used for
  1074. // internal control flow.
  1075. // 1. ExitStatus, which is thrown by exit()
  1076. // 2. "unwind", which is thrown by emscripten_unwind_to_js_event_loop() and others
  1077. // that wish to return to JS event loop.
  1078. if (e instanceof ExitStatus || e == 'unwind') {
  1079. return EXITSTATUS;
  1080. }
  1081. checkStackCookie();
  1082. if (e instanceof WebAssembly.RuntimeError) {
  1083. if (_emscripten_stack_get_current() <= 0) {
  1084. err('Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 10485760)');
  1085. }
  1086. }
  1087. quit_(1, e);
  1088. };
  1089. function checkIncomingModuleAPI() {
  1090. ignoredModuleProp('fetchSettings');
  1091. }
  1092. var wasmImports = {
  1093. /** @export */
  1094. emscripten_date_now: _emscripten_date_now,
  1095. /** @export */
  1096. emscripten_memcpy_js: _emscripten_memcpy_js,
  1097. /** @export */
  1098. emscripten_resize_heap: _emscripten_resize_heap,
  1099. /** @export */
  1100. fd_close: _fd_close,
  1101. /** @export */
  1102. fd_seek: _fd_seek,
  1103. /** @export */
  1104. fd_write: _fd_write
  1105. };
  1106. var wasmExports = createWasm();
  1107. var ___wasm_call_ctors = createExportWrapper('__wasm_call_ctors');
  1108. var _main = Module['_main'] = createExportWrapper('main');
  1109. var _exchange_js_get_install_bts_save_address = Module['_exchange_js_get_install_bts_save_address'] = createExportWrapper('exchange_js_get_install_bts_save_address');
  1110. var _exchange_js_get_route_bts_save_address = Module['_exchange_js_get_route_bts_save_address'] = createExportWrapper('exchange_js_get_route_bts_save_address');
  1111. var _exchange_js_get_audio_data_save_address = Module['_exchange_js_get_audio_data_save_address'] = createExportWrapper('exchange_js_get_audio_data_save_address');
  1112. var _exchange_js_notice_wasm_start_work = Module['_exchange_js_notice_wasm_start_work'] = createExportWrapper('exchange_js_notice_wasm_start_work');
  1113. var _exchange_js_get_current_location_coord_save_address = Module['_exchange_js_get_current_location_coord_save_address'] = createExportWrapper('exchange_js_get_current_location_coord_save_address');
  1114. var _exchange_js_get_acc_save_address = Module['_exchange_js_get_acc_save_address'] = createExportWrapper('exchange_js_get_acc_save_address');
  1115. var _exchange_js_notice_wasm_save_acc = Module['_exchange_js_notice_wasm_save_acc'] = createExportWrapper('exchange_js_notice_wasm_save_acc');
  1116. var _exchange_js_get_soft_name_and_version_save_address = Module['_exchange_js_get_soft_name_and_version_save_address'] = createExportWrapper('exchange_js_get_soft_name_and_version_save_address');
  1117. var _exchange_js_notice_wasm_free_memory = Module['_exchange_js_notice_wasm_free_memory'] = createExportWrapper('exchange_js_notice_wasm_free_memory');
  1118. var _exchange_js_notice_wasm_show_route_bts = Module['_exchange_js_notice_wasm_show_route_bts'] = createExportWrapper('exchange_js_notice_wasm_show_route_bts');
  1119. var _exchange_js_notice_wasm_show_install_bts = Module['_exchange_js_notice_wasm_show_install_bts'] = createExportWrapper('exchange_js_notice_wasm_show_install_bts');
  1120. var _fflush = createExportWrapper('fflush');
  1121. var _emscripten_stack_init = () => (_emscripten_stack_init = wasmExports['emscripten_stack_init'])();
  1122. var _emscripten_stack_get_free = () => (_emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'])();
  1123. var _emscripten_stack_get_base = () => (_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'])();
  1124. var _emscripten_stack_get_end = () => (_emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'])();
  1125. var stackSave = createExportWrapper('stackSave');
  1126. var stackRestore = createExportWrapper('stackRestore');
  1127. var stackAlloc = createExportWrapper('stackAlloc');
  1128. var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
  1129. var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji');
  1130. // include: postamble.js
  1131. // === Auto-generated postamble setup entry stuff ===
  1132. var missingLibrarySymbols = [
  1133. 'writeI53ToI64',
  1134. 'writeI53ToI64Clamped',
  1135. 'writeI53ToI64Signaling',
  1136. 'writeI53ToU64Clamped',
  1137. 'writeI53ToU64Signaling',
  1138. 'readI53FromI64',
  1139. 'readI53FromU64',
  1140. 'convertI32PairToI53',
  1141. 'convertU32PairToI53',
  1142. 'zeroMemory',
  1143. 'growMemory',
  1144. 'isLeapYear',
  1145. 'ydayFromDate',
  1146. 'arraySum',
  1147. 'addDays',
  1148. 'inetPton4',
  1149. 'inetNtop4',
  1150. 'inetPton6',
  1151. 'inetNtop6',
  1152. 'readSockaddr',
  1153. 'writeSockaddr',
  1154. 'initRandomFill',
  1155. 'randomFill',
  1156. 'getCallstack',
  1157. 'emscriptenLog',
  1158. 'convertPCtoSourceLocation',
  1159. 'readEmAsmArgs',
  1160. 'jstoi_q',
  1161. 'getExecutableName',
  1162. 'listenOnce',
  1163. 'autoResumeAudioContext',
  1164. 'dynCallLegacy',
  1165. 'getDynCaller',
  1166. 'dynCall',
  1167. 'runtimeKeepalivePush',
  1168. 'runtimeKeepalivePop',
  1169. 'callUserCallback',
  1170. 'maybeExit',
  1171. 'asmjsMangle',
  1172. 'asyncLoad',
  1173. 'alignMemory',
  1174. 'mmapAlloc',
  1175. 'HandleAllocator',
  1176. 'getNativeTypeSize',
  1177. 'STACK_SIZE',
  1178. 'STACK_ALIGN',
  1179. 'POINTER_SIZE',
  1180. 'ASSERTIONS',
  1181. 'getCFunc',
  1182. 'ccall',
  1183. 'cwrap',
  1184. 'uleb128Encode',
  1185. 'sigToWasmTypes',
  1186. 'generateFuncType',
  1187. 'convertJsFunctionToWasm',
  1188. 'getEmptyTableSlot',
  1189. 'updateTableMap',
  1190. 'getFunctionAddress',
  1191. 'addFunction',
  1192. 'removeFunction',
  1193. 'reallyNegative',
  1194. 'unSign',
  1195. 'strLen',
  1196. 'reSign',
  1197. 'formatString',
  1198. 'stringToUTF8Array',
  1199. 'stringToUTF8',
  1200. 'lengthBytesUTF8',
  1201. 'intArrayFromString',
  1202. 'intArrayToString',
  1203. 'AsciiToString',
  1204. 'stringToAscii',
  1205. 'UTF16ToString',
  1206. 'stringToUTF16',
  1207. 'lengthBytesUTF16',
  1208. 'UTF32ToString',
  1209. 'stringToUTF32',
  1210. 'lengthBytesUTF32',
  1211. 'stringToNewUTF8',
  1212. 'stringToUTF8OnStack',
  1213. 'writeArrayToMemory',
  1214. 'registerKeyEventCallback',
  1215. 'maybeCStringToJsString',
  1216. 'findEventTarget',
  1217. 'getBoundingClientRect',
  1218. 'fillMouseEventData',
  1219. 'registerMouseEventCallback',
  1220. 'registerWheelEventCallback',
  1221. 'registerUiEventCallback',
  1222. 'registerFocusEventCallback',
  1223. 'fillDeviceOrientationEventData',
  1224. 'registerDeviceOrientationEventCallback',
  1225. 'fillDeviceMotionEventData',
  1226. 'registerDeviceMotionEventCallback',
  1227. 'screenOrientation',
  1228. 'fillOrientationChangeEventData',
  1229. 'registerOrientationChangeEventCallback',
  1230. 'fillFullscreenChangeEventData',
  1231. 'registerFullscreenChangeEventCallback',
  1232. 'JSEvents_requestFullscreen',
  1233. 'JSEvents_resizeCanvasForFullscreen',
  1234. 'registerRestoreOldStyle',
  1235. 'hideEverythingExceptGivenElement',
  1236. 'restoreHiddenElements',
  1237. 'setLetterbox',
  1238. 'softFullscreenResizeWebGLRenderTarget',
  1239. 'doRequestFullscreen',
  1240. 'fillPointerlockChangeEventData',
  1241. 'registerPointerlockChangeEventCallback',
  1242. 'registerPointerlockErrorEventCallback',
  1243. 'requestPointerLock',
  1244. 'fillVisibilityChangeEventData',
  1245. 'registerVisibilityChangeEventCallback',
  1246. 'registerTouchEventCallback',
  1247. 'fillGamepadEventData',
  1248. 'registerGamepadEventCallback',
  1249. 'registerBeforeUnloadEventCallback',
  1250. 'fillBatteryEventData',
  1251. 'battery',
  1252. 'registerBatteryEventCallback',
  1253. 'setCanvasElementSize',
  1254. 'getCanvasElementSize',
  1255. 'jsStackTrace',
  1256. 'stackTrace',
  1257. 'getEnvStrings',
  1258. 'checkWasiClock',
  1259. 'wasiRightsToMuslOFlags',
  1260. 'wasiOFlagsToMuslOFlags',
  1261. 'createDyncallWrapper',
  1262. 'safeSetTimeout',
  1263. 'setImmediateWrapped',
  1264. 'clearImmediateWrapped',
  1265. 'polyfillSetImmediate',
  1266. 'getPromise',
  1267. 'makePromise',
  1268. 'idsToPromises',
  1269. 'makePromiseCallback',
  1270. 'ExceptionInfo',
  1271. 'findMatchingCatch',
  1272. 'Browser_asyncPrepareDataCounter',
  1273. 'setMainLoop',
  1274. 'getSocketFromFD',
  1275. 'getSocketAddress',
  1276. 'FS_createPreloadedFile',
  1277. 'FS_modeStringToFlags',
  1278. 'FS_getMode',
  1279. 'FS_stdin_getChar',
  1280. 'FS_createDataFile',
  1281. 'FS_unlink',
  1282. 'FS_mkdirTree',
  1283. '_setNetworkCallback',
  1284. 'heapObjectForWebGLType',
  1285. 'toTypedArrayIndex',
  1286. 'webgl_enable_ANGLE_instanced_arrays',
  1287. 'webgl_enable_OES_vertex_array_object',
  1288. 'webgl_enable_WEBGL_draw_buffers',
  1289. 'webgl_enable_WEBGL_multi_draw',
  1290. 'emscriptenWebGLGet',
  1291. 'computeUnpackAlignedImageSize',
  1292. 'colorChannelsInGlTextureFormat',
  1293. 'emscriptenWebGLGetTexPixelData',
  1294. 'emscriptenWebGLGetUniform',
  1295. 'webglGetUniformLocation',
  1296. 'webglPrepareUniformLocationsBeforeFirstUse',
  1297. 'webglGetLeftBracePos',
  1298. 'emscriptenWebGLGetVertexAttrib',
  1299. '__glGetActiveAttribOrUniform',
  1300. 'writeGLArray',
  1301. 'registerWebGlEventCallback',
  1302. 'runAndAbortIfError',
  1303. 'SDL_unicode',
  1304. 'SDL_ttfContext',
  1305. 'SDL_audio',
  1306. 'ALLOC_NORMAL',
  1307. 'ALLOC_STACK',
  1308. 'allocate',
  1309. 'writeStringToMemory',
  1310. 'writeAsciiToMemory',
  1311. 'setErrNo',
  1312. 'demangle',
  1313. ];
  1314. missingLibrarySymbols.forEach(missingLibrarySymbol)
  1315. var unexportedSymbols = [
  1316. 'run',
  1317. 'addOnPreRun',
  1318. 'addOnInit',
  1319. 'addOnPreMain',
  1320. 'addOnExit',
  1321. 'addOnPostRun',
  1322. 'addRunDependency',
  1323. 'removeRunDependency',
  1324. 'FS_createFolder',
  1325. 'FS_createPath',
  1326. 'FS_createLazyFile',
  1327. 'FS_createLink',
  1328. 'FS_createDevice',
  1329. 'FS_readFile',
  1330. 'out',
  1331. 'err',
  1332. 'callMain',
  1333. 'abort',
  1334. 'wasmMemory',
  1335. 'wasmExports',
  1336. 'stackAlloc',
  1337. 'stackSave',
  1338. 'stackRestore',
  1339. 'getTempRet0',
  1340. 'setTempRet0',
  1341. 'writeStackCookie',
  1342. 'checkStackCookie',
  1343. 'convertI32PairToI53Checked',
  1344. 'ptrToString',
  1345. 'exitJS',
  1346. 'getHeapMax',
  1347. 'abortOnCannotGrowMemory',
  1348. 'ENV',
  1349. 'MONTH_DAYS_REGULAR',
  1350. 'MONTH_DAYS_LEAP',
  1351. 'MONTH_DAYS_REGULAR_CUMULATIVE',
  1352. 'MONTH_DAYS_LEAP_CUMULATIVE',
  1353. 'ERRNO_CODES',
  1354. 'ERRNO_MESSAGES',
  1355. 'DNS',
  1356. 'Protocols',
  1357. 'Sockets',
  1358. 'timers',
  1359. 'warnOnce',
  1360. 'UNWIND_CACHE',
  1361. 'readEmAsmArgsArray',
  1362. 'jstoi_s',
  1363. 'handleException',
  1364. 'keepRuntimeAlive',
  1365. 'wasmTable',
  1366. 'noExitRuntime',
  1367. 'freeTableIndexes',
  1368. 'functionsInTableMap',
  1369. 'setValue',
  1370. 'getValue',
  1371. 'PATH',
  1372. 'PATH_FS',
  1373. 'UTF8Decoder',
  1374. 'UTF8ArrayToString',
  1375. 'UTF8ToString',
  1376. 'UTF16Decoder',
  1377. 'JSEvents',
  1378. 'specialHTMLTargets',
  1379. 'findCanvasEventTarget',
  1380. 'currentFullscreenStrategy',
  1381. 'restoreOldWindowedStyle',
  1382. 'ExitStatus',
  1383. 'flush_NO_FILESYSTEM',
  1384. 'promiseMap',
  1385. 'uncaughtExceptionCount',
  1386. 'exceptionLast',
  1387. 'exceptionCaught',
  1388. 'Browser',
  1389. 'getPreloadedImageData__data',
  1390. 'wget',
  1391. 'SYSCALLS',
  1392. 'preloadPlugins',
  1393. 'FS_stdin_getChar_buffer',
  1394. 'FS',
  1395. 'MEMFS',
  1396. 'TTY',
  1397. 'PIPEFS',
  1398. 'SOCKFS',
  1399. 'tempFixedLengthArray',
  1400. 'miniTempWebGLFloatBuffers',
  1401. 'miniTempWebGLIntBuffers',
  1402. 'GL',
  1403. 'AL',
  1404. 'GLUT',
  1405. 'EGL',
  1406. 'GLEW',
  1407. 'IDBStore',
  1408. 'SDL',
  1409. 'SDL_gfx',
  1410. 'allocateUTF8',
  1411. 'allocateUTF8OnStack',
  1412. ];
  1413. unexportedSymbols.forEach(unexportedRuntimeSymbol);
  1414. var calledRun;
  1415. dependenciesFulfilled = function runCaller() {
  1416. // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
  1417. if (!calledRun) run();
  1418. if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
  1419. };
  1420. function callMain() {
  1421. assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])');
  1422. assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
  1423. var entryFunction = _main;
  1424. var argc = 0;
  1425. var argv = 0;
  1426. try {
  1427. var ret = entryFunction(argc, argv);
  1428. // if we're not running an evented main loop, it's time to exit
  1429. exitJS(ret, /* implicit = */ true);
  1430. return ret;
  1431. }
  1432. catch (e) {
  1433. return handleException(e);
  1434. }
  1435. }
  1436. function stackCheckInit() {
  1437. // This is normally called automatically during __wasm_call_ctors but need to
  1438. // get these values before even running any of the ctors so we call it redundantly
  1439. // here.
  1440. _emscripten_stack_init();
  1441. // TODO(sbc): Move writeStackCookie to native to to avoid this.
  1442. writeStackCookie();
  1443. }
  1444. function run() {
  1445. if (runDependencies > 0) {
  1446. return;
  1447. }
  1448. stackCheckInit();
  1449. preRun();
  1450. // a preRun added a dependency, run will be called later
  1451. if (runDependencies > 0) {
  1452. return;
  1453. }
  1454. function doRun() {
  1455. // run may have just been called through dependencies being fulfilled just in this very frame,
  1456. // or while the async setStatus time below was happening
  1457. if (calledRun) return;
  1458. calledRun = true;
  1459. Module['calledRun'] = true;
  1460. if (ABORT) return;
  1461. initRuntime();
  1462. preMain();
  1463. if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();
  1464. if (shouldRunNow) callMain();
  1465. postRun();
  1466. }
  1467. if (Module['setStatus']) {
  1468. Module['setStatus']('Running...');
  1469. setTimeout(function() {
  1470. setTimeout(function() {
  1471. Module['setStatus']('');
  1472. }, 1);
  1473. doRun();
  1474. }, 1);
  1475. } else
  1476. {
  1477. doRun();
  1478. }
  1479. checkStackCookie();
  1480. }
  1481. function checkUnflushedContent() {
  1482. // Compiler settings do not allow exiting the runtime, so flushing
  1483. // the streams is not possible. but in ASSERTIONS mode we check
  1484. // if there was something to flush, and if so tell the user they
  1485. // should request that the runtime be exitable.
  1486. // Normally we would not even include flush() at all, but in ASSERTIONS
  1487. // builds we do so just for this check, and here we see if there is any
  1488. // content to flush, that is, we check if there would have been
  1489. // something a non-ASSERTIONS build would have not seen.
  1490. // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0
  1491. // mode (which has its own special function for this; otherwise, all
  1492. // the code is inside libc)
  1493. var oldOut = out;
  1494. var oldErr = err;
  1495. var has = false;
  1496. out = err = (x) => {
  1497. has = true;
  1498. }
  1499. try { // it doesn't matter if it fails
  1500. flush_NO_FILESYSTEM();
  1501. } catch(e) {}
  1502. out = oldOut;
  1503. err = oldErr;
  1504. if (has) {
  1505. 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.');
  1506. warnOnce('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)');
  1507. }
  1508. }
  1509. if (Module['preInit']) {
  1510. if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
  1511. while (Module['preInit'].length > 0) {
  1512. Module['preInit'].pop()();
  1513. }
  1514. }
  1515. // shouldRunNow refers to calling main(), not run().
  1516. var shouldRunNow = true;
  1517. if (Module['noInitialRun']) shouldRunNow = false;
  1518. run();
  1519. // end include: postamble.js