cassette.js 66 KB

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