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