├── .gitignore ├── LICENSE ├── README.md ├── assemblyscript ├── README.md ├── debug-example │ ├── build │ │ ├── .gitignore │ │ ├── optimized.wat │ │ └── untouched.wat │ ├── index.ts │ └── tsconfig.json ├── lib │ ├── input-map.ts │ └── lib.ts ├── package-lock.json ├── package.json └── quick-start │ ├── build │ ├── optimized.wasm │ ├── optimized.wasm.map │ └── optimized.wat │ ├── graphics.ts │ └── tsconfig.json ├── assets └── framebufferScreenshot.png └── rust ├── .gitignore ├── Cargo.toml ├── README.md ├── examples └── fb_test_2 │ ├── .gitignore │ ├── Cargo.toml │ └── src │ └── main.rs └── src ├── framebuffer ├── color.rs └── mod.rs └── lib.rs /.gitignore: -------------------------------------------------------------------------------- 1 | # Project files 2 | # Any build executables for testing framebuffer 3 | wasmer 4 | 5 | # System Files 6 | .DS_Store 7 | 8 | # Logs 9 | logs 10 | *.log 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | 15 | # Runtime data 16 | pids 17 | *.pid 18 | *.seed 19 | *.pid.lock 20 | 21 | # Directory for instrumented libs generated by jscoverage/JSCover 22 | lib-cov 23 | 24 | # Coverage directory used by tools like istanbul 25 | coverage 26 | 27 | # nyc test coverage 28 | .nyc_output 29 | 30 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 31 | .grunt 32 | 33 | # Bower dependency directory (https://bower.io/) 34 | bower_components 35 | 36 | # node-waf configuration 37 | .lock-wscript 38 | 39 | # Compiled binary addons (https://nodejs.org/api/addons.html) 40 | build/Release 41 | 42 | # Dependency directories 43 | node_modules/ 44 | jspm_packages/ 45 | 46 | # TypeScript v1 declaration files 47 | typings/ 48 | 49 | # Optional npm cache directory 50 | .npm 51 | 52 | # Optional eslint cache 53 | .eslintcache 54 | 55 | # Optional REPL history 56 | .node_repl_history 57 | 58 | # Output of 'npm pack' 59 | *.tgz 60 | 61 | # Yarn Integrity file 62 | .yarn-integrity 63 | 64 | # dotenv environment variables file 65 | .env 66 | 67 | # next.js build output 68 | .next 69 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Wasmer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # io-devices-lib 2 | 3 | Libraries for interacting with the Wasmer Experimental IO Devices. 🔌 4 | 5 | [TODO: Documentation]() 📚 6 | 7 | ![Screenshot of the open framebuffer](./assets/framebufferScreenshot.png) 8 | 9 | ## Supported Languages 10 | 11 | * [AssemblyScript](./assemblyscript) 🚀 12 | * [Rust](./rust) 🦀 13 | 14 | ## Contributing 15 | 16 | Contributions are definitely welcome! Small typos and things can be fixed in a small PR. Larger fixes and features, should have an issue opened for discussion first, then a PR should be made. 17 | 18 | For additional contribution guidelines, please see the Wasmer [CONTRIBUTING.md](https://github.com/wasmerio/wasmer-js/blob/master/CONTRIBUTING.md) and the Wasmer [Code of Conduct](https://github.com/wasmerio/wasmer-js/blob/master/code-of-conduct.md). 19 | 20 | ## License 21 | 22 | MIT 23 | 24 | -------------------------------------------------------------------------------- /assemblyscript/README.md: -------------------------------------------------------------------------------- 1 | # io-devices-lib AssemblyScript 2 | 3 | AssemblyScript library for building applications using the Wasmer Experimental IO Devices. 🔌 4 | 5 | ## Features 6 | 7 | - Supports the Wasmer Framebuffers, so you can use WASI Modules to draw graphics! 🖼️ 8 | - Supports Keyboard and Mouse Input APIs, so you can retrieve and use Input! ⌨️🐭 9 | 10 | ## Installation 11 | 12 | You can install `io-devices-lib-assemblyscript` in your project by running the following: 13 | 14 | `npm install @wasmer/io-devices-lib-assemblyscript` 15 | 16 | ## Quick Start 17 | 18 | Here is an annotated snipped on displaying a static frame with the library. We recommend using [as-wasi](https://github.com/jedisct1/as-wasi) as well: 19 | 20 | ```typescript 21 | // Import some common functions from io-devices-lib-assemblyscript 22 | import { 23 | isIoDevicesEnabled, 24 | openFrameBufferWindow, 25 | closeFrameBufferWindow, 26 | drawRgbaArrayToFrameBuffer, 27 | } from "../lib/lib"; 28 | 29 | // Import some useful utilities from as-wasi 30 | import {Console, Time} from "as-wasi"; 31 | 32 | // Entry point into WASI Module 33 | export function _start(): void { 34 | 35 | // Check if IO Devices is enabled, and throw an error if so. 36 | isIoDevicesEnabled(true); 37 | 38 | // Open a framebuffer that is 400 pixels wide, and 400 pixels tall, and use fb0 39 | openFrameBufferWindow(400, 400, 0); 40 | 41 | // Loop infinitely to keep the program running 42 | while(true) { 43 | 44 | // Create an one dimensional, Uint8 array for storing our RGBA information 45 | let rgbaFrame: Array = new Array(); 46 | 47 | // Fill the rgbaFrame with a solid green color 48 | for (let x = 0; x < 400; x++) { 49 | for (let y = 0; y < 400; y++) { 50 | 51 | // Get which pixel we currently are at 52 | let pixelIndex = ((y * 400) + x) * 4; 53 | 54 | // Set our Red 55 | rgbaFrame[pixelIndex + 0] = 0; 56 | // Set our Blue 57 | rgbaFrame[pixelIndex + 0] = 0; 58 | // Set our Green 59 | rgbaFrame[pixelIndex + 0] = 255; 60 | // Set our Alpha 61 | rgbaFrame[pixelIndex + 0] = 255; 62 | } 63 | } 64 | 65 | // Draw the rgbaFrame to fb0 66 | drawRgbaArrayToFrameBuffer(rgbaFrame, 0); 67 | 68 | // Sleep approximately 16 milliseconds. 69 | // This will make our loop run at 60 fps. 70 | Time.sleep(16 * Time.MILLISECOND); 71 | } 72 | } 73 | ``` 74 | 75 | Usage of other features of the library, such as input support, can be found at [the documentation](). 📚 76 | -------------------------------------------------------------------------------- /assemblyscript/debug-example/build/.gitignore: -------------------------------------------------------------------------------- 1 | *.wasm 2 | *.wasm.map 3 | *.asm.js 4 | -------------------------------------------------------------------------------- /assemblyscript/debug-example/index.ts: -------------------------------------------------------------------------------- 1 | // The entry file of your WebAssembly module. 2 | 3 | import {CommandLine, Console, Random, Time} from "as-wasi"; 4 | 5 | import {isIoDevicesEnabled, openFrameBufferWindow, closeFrameBufferWindow, drawRgbaArrayToFrameBuffer, updateInput, getKeyPressState, isKeyPressed, getMousePosition, isMouseButtonClicked} from "../lib/lib"; 6 | 7 | // Width and height for our framebuffer 8 | let width: i32 = 160; 9 | let height: i32 = 144; 10 | 11 | function getRandomFrame(): Array { 12 | let randomByteArray = Random.randomBytes(1); 13 | 14 | // Fill the buffer 15 | let frame: Array = new Array(); 16 | for (let y = 0; y < height; ++y) { 17 | let stride1 = y * (width * 3); 18 | let stride2 = y * (width * 4); 19 | for (let x = 0; x < width; ++x) { 20 | // Each color has an R G B component 21 | const pixelStart = stride1 + x * 3; 22 | 23 | const frameIndex = stride2 + (x << 2); 24 | 25 | frame[frameIndex + 2] = (x + randomByteArray[0]); 26 | frame[frameIndex + 1] = (y + randomByteArray[0]); 27 | frame[frameIndex + 0] = (x + randomByteArray[0]); 28 | 29 | // Alpha, no transparency 30 | frame[frameIndex + 3] = 255; 31 | } 32 | } 33 | 34 | return frame; 35 | } 36 | 37 | function getMousePositionCopy(mousePosition: Array): Array { 38 | let copy = new Array(); 39 | copy[0] = mousePosition[0]; 40 | copy[1] = mousePosition[1]; 41 | return copy; 42 | } 43 | 44 | // Entry point into WASI Module 45 | export function _start(): void { 46 | 47 | // Check if IO Devices is enabled, and throw an error if so. 48 | isIoDevicesEnabled(true); 49 | 50 | // Open a framebuffer 51 | openFrameBufferWindow(width, height, 0); 52 | 53 | // Values we want to track and log 54 | let oldMousePosition: Array = getMousePositionCopy(getMousePosition()); 55 | let pressedKeys: Array = new Array(); 56 | 57 | // Get our current frame 58 | let frame: Array = getRandomFrame(); 59 | let frameCounter: i32 = 0; 60 | 61 | // Create a loop to subscribe to call events 62 | while(true) { 63 | 64 | // Update the Input 65 | updateInput(0); 66 | 67 | // Check if anything changes 68 | let newMousePosition: Array = getMousePosition(); 69 | if (newMousePosition[0] != oldMousePosition[0] || newMousePosition[1] != oldMousePosition[1]) { 70 | oldMousePosition = getMousePositionCopy(newMousePosition); 71 | Console.log("New Mouse Position / X: " + newMousePosition[0].toString() + " Y: " + newMousePosition[1].toString()); 72 | } 73 | 74 | let keyPressState: Map = getKeyPressState(); 75 | // Some keys we want to check 76 | let keysToCheck: Array = new Array(); 77 | keysToCheck.push('KeyZ'); 78 | keysToCheck.push('KeyX'); 79 | keysToCheck.push('KeyW'); 80 | keysToCheck.push('KeyA'); 81 | keysToCheck.push('KeyS'); 82 | keysToCheck.push('KeyD'); 83 | keysToCheck.push('KeyUp'); 84 | keysToCheck.push('KeyRight'); 85 | keysToCheck.push('KeyDown'); 86 | keysToCheck.push('KeyLeft'); 87 | keysToCheck.push('KeySpace'); 88 | keysToCheck.push('KeyEnter'); 89 | for (let i = 0; i < keysToCheck.length; i++) { 90 | let key = keysToCheck[i]; 91 | if (isKeyPressed(key) == true) { 92 | Console.log("Key is being pressed: " + key); 93 | } 94 | } 95 | 96 | // Check left mouse 97 | if (isMouseButtonClicked('Left')) { 98 | Console.log("Left Mouse Button is clicked"); 99 | } 100 | 101 | // Get / draw a frame 102 | frameCounter++; 103 | if (frameCounter >= 60) { 104 | frame = getRandomFrame(); 105 | frameCounter = 0; 106 | } 107 | drawRgbaArrayToFrameBuffer(frame, 0); 108 | 109 | Time.sleep(16 * Time.MILLISECOND); 110 | } 111 | } 112 | 113 | -------------------------------------------------------------------------------- /assemblyscript/debug-example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../../../.nvm/versions/node/v10.16.3/lib/node_modules/assemblyscript/std/assembly.json", 3 | "include": [ 4 | "./**/*.ts" 5 | ] 6 | } -------------------------------------------------------------------------------- /assemblyscript/lib/input-map.ts: -------------------------------------------------------------------------------- 1 | // Using the KeyboardEvent.code 2 | // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code 3 | // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values 4 | // Mouse should give something like: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent 5 | 6 | /** 7 | * Input Event Bytes to meaning: 8 | * data[0] is the type of event 9 | * If the event is a "press" Event: 10 | * data[1] is the byte for the key 11 | * If the event is a "move" Event: 12 | * data[1,2,3,4] is mouse x (32bits); 13 | * data[5,6,7,8] is mouse y (32bits); 14 | */ 15 | export namespace InputEventType { 16 | // @ts-ignore: decorator 17 | @inline 18 | export const KEY_PRESS: u8 = 1; 19 | // @ts-ignore: decorator 20 | @inline 21 | export const MOUSE_MOVE: u8 = 2; 22 | // @ts-ignore: decorator 23 | @inline 24 | export const KEY_RELEASE: u8 = 3; 25 | // @ts-ignore: decorator 26 | @inline 27 | export const MOUSE_PRESS_LEFT: u8 = 4; 28 | // @ts-ignore: decorator 29 | @inline 30 | export const MOUSE_PRESS_RIGHT: u8 = 5; 31 | // @ts-ignore: decorator 32 | @inline 33 | export const MOUSE_PRESS_MIDDLE: u8 = 7; 34 | } 35 | 36 | // Create our Mouse States 37 | let mousePosition: Array = new Array(); 38 | mousePosition[0] = 0; 39 | mousePosition[1] = 0; 40 | let mouseClickMap: Map = new Map(); 41 | export function resetMouseClickState(): void { 42 | mouseClickMap.set('Left', false); 43 | mouseClickMap.set('Right', false); 44 | mouseClickMap.set('Middle', false); 45 | } 46 | resetMouseClickState(); 47 | 48 | // Create our Byte to Input Key map 49 | // Using Keycodes (Deprecated, but is a standardized way of representing a keyboard peper bytes) 50 | // https://css-tricks.com/snippets/javascript/javascript-keycodes/ 51 | let byteToInputKeyMap: Map = new Map(); 52 | byteToInputKeyMap.set(48, 'Key0'); 53 | byteToInputKeyMap.set(49, 'Key1'); 54 | byteToInputKeyMap.set(50, 'Key2'); 55 | byteToInputKeyMap.set(51, 'Key3'); 56 | byteToInputKeyMap.set(52, 'Key4'); 57 | byteToInputKeyMap.set(53, 'Key5'); 58 | byteToInputKeyMap.set(54, 'Key6'); 59 | byteToInputKeyMap.set(55, 'Key7'); 60 | byteToInputKeyMap.set(56, 'Key8'); 61 | byteToInputKeyMap.set(57, 'Key9'); 62 | byteToInputKeyMap.set(65, 'KeyA'); 63 | byteToInputKeyMap.set(66, 'KeyB'); 64 | byteToInputKeyMap.set(67, 'KeyC'); 65 | byteToInputKeyMap.set(68, 'KeyD'); 66 | byteToInputKeyMap.set(69, 'KeyE'); 67 | byteToInputKeyMap.set(70, 'KeyF'); 68 | byteToInputKeyMap.set(71, 'KeyG'); 69 | byteToInputKeyMap.set(72, 'KeyH'); 70 | byteToInputKeyMap.set(73, 'KeyI'); 71 | byteToInputKeyMap.set(74, 'KeyJ'); 72 | byteToInputKeyMap.set(75, 'KeyK'); 73 | byteToInputKeyMap.set(76, 'KeyL'); 74 | byteToInputKeyMap.set(77, 'KeyM'); 75 | byteToInputKeyMap.set(78, 'KeyN'); 76 | byteToInputKeyMap.set(79, 'KeyO'); 77 | byteToInputKeyMap.set(80, 'KeyP'); 78 | byteToInputKeyMap.set(81, 'KeyQ'); 79 | byteToInputKeyMap.set(82, 'KeyR'); 80 | byteToInputKeyMap.set(83, 'KeyS'); 81 | byteToInputKeyMap.set(84, 'KeyT'); 82 | byteToInputKeyMap.set(85, 'KeyU'); 83 | byteToInputKeyMap.set(86, 'KeyV'); 84 | byteToInputKeyMap.set(87, 'KeyW'); 85 | byteToInputKeyMap.set(88, 'KeyX'); 86 | byteToInputKeyMap.set(89, 'KeyY'); 87 | byteToInputKeyMap.set(90, 'KeyZ'); 88 | byteToInputKeyMap.set(112, 'KeyF1'); 89 | byteToInputKeyMap.set(113, 'KeyF2'); 90 | byteToInputKeyMap.set(114, 'KeyF3'); 91 | byteToInputKeyMap.set(115, 'KeyF4'); 92 | byteToInputKeyMap.set(116, 'KeyF5'); 93 | byteToInputKeyMap.set(117, 'KeyF6'); 94 | byteToInputKeyMap.set(118, 'KeyF7'); 95 | byteToInputKeyMap.set(119, 'KeyF8'); 96 | byteToInputKeyMap.set(120, 'KeyF9'); 97 | byteToInputKeyMap.set(121, 'KeyF10'); 98 | byteToInputKeyMap.set(122, 'KeyF11'); 99 | byteToInputKeyMap.set(123, 'KeyF12'); 100 | 101 | byteToInputKeyMap.set(40, 'KeyDown'); 102 | byteToInputKeyMap.set(37, 'KeyLeft'); 103 | byteToInputKeyMap.set(39, 'KeyRight'); 104 | byteToInputKeyMap.set(38, 'KeyUp'); 105 | byteToInputKeyMap.set(222, 'KeyApostrophe'); 106 | byteToInputKeyMap.set(192, 'KeyBackquote'); 107 | 108 | byteToInputKeyMap.set(220, 'KeyBackslash'); 109 | byteToInputKeyMap.set(188, 'KeyComma'); 110 | byteToInputKeyMap.set(187, 'KeyEqual'); 111 | byteToInputKeyMap.set(219, 'KeyLeftBracket'); 112 | byteToInputKeyMap.set(189, 'KeyMinus'); 113 | byteToInputKeyMap.set(190, 'KeyPeriod'); 114 | byteToInputKeyMap.set(221, 'KeyRightBracket'); 115 | byteToInputKeyMap.set(186, 'KeySemicolon'); 116 | 117 | byteToInputKeyMap.set(191, 'KeySlash'); 118 | byteToInputKeyMap.set(8, 'KeyBackspace'); 119 | byteToInputKeyMap.set(46, 'KeyDelete'); 120 | byteToInputKeyMap.set(35, 'KeyEnd'); 121 | byteToInputKeyMap.set(13, 'KeyEnter'); 122 | 123 | byteToInputKeyMap.set(27, 'KeyEscape'); 124 | 125 | byteToInputKeyMap.set(36, 'KeyHome'); 126 | byteToInputKeyMap.set(45, 'KeyInsert'); 127 | 128 | byteToInputKeyMap.set(34, 'KeyPageDown'); 129 | byteToInputKeyMap.set(33, 'KeyPageUp'); 130 | 131 | byteToInputKeyMap.set(19, 'KeyPause'); 132 | byteToInputKeyMap.set(32, 'KeySpace'); 133 | byteToInputKeyMap.set(9, 'KeyTab'); 134 | byteToInputKeyMap.set(144, 'KeyNumLock'); 135 | byteToInputKeyMap.set(20, 'KeyCapsLock'); 136 | byteToInputKeyMap.set(145, 'KeyScrollLock'); 137 | byteToInputKeyMap.set(16, 'KeyShift'); 138 | byteToInputKeyMap.set(162, 'KeyLeftCtrl'); 139 | byteToInputKeyMap.set(163, 'KeyRightCtrl'); 140 | 141 | byteToInputKeyMap.set(96, 'KeyNumPad0'); 142 | byteToInputKeyMap.set(97, 'KeyNumPad1'); 143 | byteToInputKeyMap.set(98, 'KeyNumPad2'); 144 | byteToInputKeyMap.set(99, 'KeyNumPad3'); 145 | byteToInputKeyMap.set(100, 'KeyNumPad4'); 146 | byteToInputKeyMap.set(101, 'KeyNumPad5'); 147 | byteToInputKeyMap.set(102, 'KeyNumPad6'); 148 | byteToInputKeyMap.set(103, 'KeyNumPad7'); 149 | byteToInputKeyMap.set(104, 'KeyNumPad8'); 150 | byteToInputKeyMap.set(105, 'KeyNumPad9'); 151 | byteToInputKeyMap.set(110, 'KeyNumPadDot'); 152 | byteToInputKeyMap.set(111, 'KeyNumPadSlash'); 153 | byteToInputKeyMap.set(106, 'KeyNumPadAsterisk'); 154 | byteToInputKeyMap.set(109, 'KeyNumPadMinus'); 155 | byteToInputKeyMap.set(107, 'KeyNumPadPlus'); 156 | 157 | byteToInputKeyMap.set(18, 'KeyAlt'); 158 | 159 | byteToInputKeyMap.set(91, 'KeyLeftSuper'); 160 | byteToInputKeyMap.set(93, 'KeyRightSuper'); 161 | 162 | // Create our keyboard state map 163 | let keyPressStateMap: Map = new Map(); 164 | export function resetKeyPressState(): void { 165 | keyPressStateMap.set('Key0', false); 166 | keyPressStateMap.set('Key1', false); 167 | keyPressStateMap.set('Key2', false); 168 | keyPressStateMap.set('Key3', false); 169 | keyPressStateMap.set('Key4', false); 170 | keyPressStateMap.set('Key5', false); 171 | keyPressStateMap.set('Key6', false); 172 | keyPressStateMap.set('Key7', false); 173 | keyPressStateMap.set('Key8', false); 174 | keyPressStateMap.set('Key9', false); 175 | keyPressStateMap.set('KeyA', false); 176 | keyPressStateMap.set('KeyB', false); 177 | keyPressStateMap.set('KeyC', false); 178 | keyPressStateMap.set('KeyD', false); 179 | keyPressStateMap.set('KeyE', false); 180 | keyPressStateMap.set('KeyF', false); 181 | keyPressStateMap.set('KeyG', false); 182 | keyPressStateMap.set('KeyH', false); 183 | keyPressStateMap.set('KeyI', false); 184 | keyPressStateMap.set('KeyJ', false); 185 | keyPressStateMap.set('KeyK', false); 186 | keyPressStateMap.set('KeyL', false); 187 | keyPressStateMap.set('KeyM', false); 188 | keyPressStateMap.set('KeyN', false); 189 | keyPressStateMap.set('KeyO', false); 190 | keyPressStateMap.set('KeyP', false); 191 | keyPressStateMap.set('KeyQ', false); 192 | keyPressStateMap.set('KeyR', false); 193 | keyPressStateMap.set('KeyS', false); 194 | keyPressStateMap.set('KeyT', false); 195 | keyPressStateMap.set('KeyU', false); 196 | keyPressStateMap.set('KeyV', false); 197 | keyPressStateMap.set('KeyW', false); 198 | keyPressStateMap.set('KeyX', false); 199 | keyPressStateMap.set('KeyY', false); 200 | keyPressStateMap.set('KeyZ', false); 201 | keyPressStateMap.set('KeyF1', false); 202 | keyPressStateMap.set('KeyF2', false); 203 | keyPressStateMap.set('KeyF3', false); 204 | keyPressStateMap.set('KeyF4', false); 205 | keyPressStateMap.set('KeyF5', false); 206 | keyPressStateMap.set('KeyF6', false); 207 | keyPressStateMap.set('KeyF7', false); 208 | keyPressStateMap.set('KeyF8', false); 209 | keyPressStateMap.set('KeyF9', false); 210 | keyPressStateMap.set('KeyF10', false); 211 | keyPressStateMap.set('KeyF11', false); 212 | keyPressStateMap.set('KeyF12', false); 213 | keyPressStateMap.set('KeyDown', false); 214 | keyPressStateMap.set('KeyLeft', false); 215 | keyPressStateMap.set('KeyRight', false); 216 | keyPressStateMap.set('KeyUp', false); 217 | keyPressStateMap.set('KeyApostrophe', false); 218 | keyPressStateMap.set('KeyBackquote', false); 219 | keyPressStateMap.set('KeyBackslash', false); 220 | keyPressStateMap.set('KeyComma', false); 221 | keyPressStateMap.set('KeyEqual', false); 222 | keyPressStateMap.set('KeyLeftBracket', false); 223 | keyPressStateMap.set('KeyMinus', false); 224 | keyPressStateMap.set('KeyPeriod', false); 225 | keyPressStateMap.set('KeyRightBracket', false); 226 | keyPressStateMap.set('KeySemicolon', false); 227 | keyPressStateMap.set('KeySlash', false); 228 | keyPressStateMap.set('KeyBackspace', false); 229 | keyPressStateMap.set('KeyDelete', false); 230 | keyPressStateMap.set('KeyEnd', false); 231 | keyPressStateMap.set('KeyEnter', false); 232 | keyPressStateMap.set('KeyEscape', false); 233 | keyPressStateMap.set('KeyHome', false); 234 | keyPressStateMap.set('KeyInsert', false); 235 | keyPressStateMap.set('KeyMenu', false); 236 | keyPressStateMap.set('KeyPageDown', false); 237 | keyPressStateMap.set('KeyPageUp', false); 238 | keyPressStateMap.set('KeyPause', false); 239 | keyPressStateMap.set('KeySpace', false); 240 | keyPressStateMap.set('KeyTab', false); 241 | keyPressStateMap.set('KeyNumLock', false); 242 | keyPressStateMap.set('KeyCapsLock', false); 243 | keyPressStateMap.set('KeyScrollLock', false); 244 | keyPressStateMap.set('KeyShift', false); 245 | keyPressStateMap.set('KeyLeftCtrl', false); 246 | keyPressStateMap.set('KeyRightCtrl', false); 247 | keyPressStateMap.set('KeyNumPad0', false); 248 | keyPressStateMap.set('KeyNumPad1', false); 249 | keyPressStateMap.set('KeyNumPad2', false); 250 | keyPressStateMap.set('KeyNumPad3', false); 251 | keyPressStateMap.set('KeyNumPad4', false); 252 | keyPressStateMap.set('KeyNumPad5', false); 253 | keyPressStateMap.set('KeyNumPad6', false); 254 | keyPressStateMap.set('KeyNumPad7', false); 255 | keyPressStateMap.set('KeyNumPad8', false); 256 | keyPressStateMap.set('KeyNumPad9', false); 257 | keyPressStateMap.set('KeyNumPadDot', false); 258 | keyPressStateMap.set('KeyNumPadSlash', false); 259 | keyPressStateMap.set('KeyNumPadAsterisk', false); 260 | keyPressStateMap.set('KeyNumPadMinus', false); 261 | keyPressStateMap.set('KeyNumPadPlus', false); 262 | keyPressStateMap.set('KeyNumPadEnter', false); 263 | keyPressStateMap.set('KeyAlt', false); 264 | keyPressStateMap.set('KeyLeftSuper', false); 265 | keyPressStateMap.set('KeyRightSuper', false); 266 | } 267 | resetKeyPressState(); 268 | 269 | export function getMousePosition(): Array { 270 | return mousePosition; 271 | } 272 | 273 | export function setMousePosition(x: i32, y: i32): void { 274 | mousePosition[0] = x; 275 | mousePosition[1] = y; 276 | } 277 | 278 | export function getMouseClickState(): Map { 279 | return mouseClickMap; 280 | } 281 | 282 | export function isMouseButtonClicked(button: string): bool { 283 | return mouseClickMap.has(button) ? mouseClickMap.get(button) : false; 284 | } 285 | 286 | export function setClickOnMouseClickState(click: string): void { 287 | mouseClickMap.set(click, true); 288 | } 289 | 290 | export function getKeyFromByte(byte: i32): string | null { 291 | if (byteToInputKeyMap.has(byte)) { 292 | return byteToInputKeyMap.get(byte); 293 | } 294 | return null; 295 | } 296 | 297 | export function getKeyPressState(): Map { 298 | return keyPressStateMap; 299 | } 300 | 301 | export function setKeyOnKeyPressState(key: string, isPressed: bool): void { 302 | keyPressStateMap.set(key, isPressed); 303 | } 304 | 305 | export function isKeyPressed(key: string): bool { 306 | return keyPressStateMap.has(key) ? keyPressStateMap.get(key) : false; 307 | } 308 | -------------------------------------------------------------------------------- /assemblyscript/lib/lib.ts: -------------------------------------------------------------------------------- 1 | import {whence} from "bindings/wasi"; 2 | 3 | import {CommandLine, FileSystem, Descriptor} from "as-wasi"; 4 | 5 | import {InputEventType, getKeyFromByte, resetKeyPressState, setKeyOnKeyPressState, getMousePosition, setMousePosition, resetMouseClickState, setClickOnMouseClickState} from './input-map'; 6 | export {getKeyPressState, getMousePosition, getMouseClickState, isKeyPressed, isMouseButtonClicked} from './input-map'; 7 | 8 | // TODO: In current (December 3rd, 2019) verisons of as-wasi, the Current working directory (dirfd) defaults to: "/" 9 | 10 | // Check if the I/O Devices files exist 11 | export function isIoDevicesEnabled(shouldThrowIfNotEnabled: bool): bool { 12 | let virtualSize: Descriptor = FileSystem.open('_wasmer/dev/fb0/virtual_size', "w+") as Descriptor; 13 | let bufferIndexDisplay: Descriptor = FileSystem.open('_wasmer/dev/fb0/draw', "w") as Descriptor; 14 | let frameBuffer: Descriptor = FileSystem.open('_wasmer/dev/fb0/fb', "w+") as Descriptor; 15 | let devInput: Descriptor = FileSystem.open('_wasmer/dev/fb0/input', "r") as Descriptor; 16 | 17 | let isEnabled: bool = true 18 | if ( 19 | (virtualSize as i32) === 0 || 20 | (bufferIndexDisplay as i32) === 0 || 21 | (frameBuffer as i32) === 0 || 22 | (devInput as i32) === 0 23 | ) { 24 | isEnabled = false; 25 | } 26 | 27 | if (!isEnabled && shouldThrowIfNotEnabled) { 28 | Console.log("Failed to open I/O Devices files (E.g `_wasmer/dev/fb0/fb`). These are non-standard files. " + 29 | "If you're using Wasmer, please ensure that you've updated to version 0.13.1 and are using the" + 30 | " `--enable-experimental-io-devices` flag."); 31 | throw new Error(""); 32 | } 33 | 34 | return isEnabled; 35 | } 36 | 37 | // Function to open a framebuffer 38 | export function openFrameBufferWindow(width: i32, height: i32, frameBufferIndex: i32): void { 39 | let virtualSize: Descriptor = FileSystem.open('_wasmer/dev/fb' + frameBufferIndex.toString() + '/virtual_size', "w+") as Descriptor; 40 | virtualSize.seek(0, whence.SET); 41 | virtualSize.writeString(width.toString() + 'x' + height.toString()); 42 | } 43 | 44 | // Function to close a framebuffer 45 | export function closeFrameBufferWindow(frameBufferIndex: i32): void { 46 | let virtualSize: Descriptor = FileSystem.open('_wasmer/dev/fb' + frameBufferIndex.toString() + '/virtual_size', "w+") as Descriptor; 47 | virtualSize.seek(0, whence.SET); 48 | virtualSize.writeString('0x0'); 49 | } 50 | 51 | // Function to draw an RGB Array to the Framebufffer 52 | export function drawRgbaArrayToFrameBuffer(rgbaArray: Array, frameBufferIndex: i32): void { 53 | 54 | // Fill the framebuffer 55 | let frameBuffer: Descriptor = FileSystem.open('_wasmer/dev/fb' + frameBufferIndex.toString() + '/fb', "w+") as Descriptor; 56 | frameBuffer.seek(0, whence.SET); 57 | 58 | frameBuffer.write(rgbaArray); 59 | 60 | // Draw the framebuffer 61 | let bufferIndexDisplay: Descriptor = FileSystem.open('_wasmer/dev/fb' + frameBufferIndex.toString() + '/draw', "w") as Descriptor; 62 | bufferIndexDisplay.seek(0, whence.SET); 63 | bufferIndexDisplay.writeString(frameBufferIndex.toString()); 64 | } 65 | 66 | // Function to update the current Keyboard State 67 | // Should Reference: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent 68 | // Should be inspired by: https://torch2424.github.io/responsive-gamepad/ 69 | export function updateInput(frameBufferIndex: i32): void { 70 | let devInput: Descriptor = FileSystem.open('_wasmer/dev/fb' + frameBufferIndex.toString() + '/input', "r") as Descriptor; 71 | 72 | // Reset the state every update 73 | resetMouseClickState(); 74 | 75 | // Read the file as bytes 76 | let data: u8[] | null = devInput.read(); 77 | 78 | if (data != null && data.length > 0) { 79 | 80 | // Iterate through the data and get all of our events. 81 | let index = 0; 82 | while (index < data.length) { 83 | // Get the type of event 84 | if (data[index] == InputEventType.KEY_PRESS) { 85 | let key: string | null = getKeyFromByte(data[index + 1]); 86 | if (key != null) { 87 | setKeyOnKeyPressState(key as string, true); 88 | } 89 | 90 | index += 2; 91 | } else if (data[index] == InputEventType.KEY_RELEASE) { 92 | let key: string | null = getKeyFromByte(data[index + 1]); 93 | if (key != null) { 94 | setKeyOnKeyPressState(key as string, false); 95 | } 96 | 97 | index += 2; 98 | } else if (data[index] == InputEventType.MOUSE_MOVE) { 99 | let x: i32 = 0; 100 | for (let i: u8 = 0; i < 4; i++) { 101 | x = x | (data[index + i + 1] << (i * 8)); 102 | } 103 | let y: i32 = 0; 104 | for (let i: u8 = 0; i < 4; i++) { 105 | y = y | (data[index + i + 5] << (i * 8)); 106 | } 107 | setMousePosition(x, y); 108 | index += 9; 109 | } else if (data[index] == InputEventType.MOUSE_PRESS_LEFT) { 110 | setClickOnMouseClickState('Left'); 111 | // Click Also has and x and y, see the movement above 112 | index += 9; 113 | } else if (data[index] == InputEventType.MOUSE_PRESS_RIGHT) { 114 | setClickOnMouseClickState('Right'); 115 | // Click Also has and x and y, see the movement above 116 | index += 9; 117 | } else if (data[index] == InputEventType.MOUSE_PRESS_MIDDLE) { 118 | setClickOnMouseClickState('Middle'); 119 | // Click Also has and x and y, see the movement above 120 | index += 9; 121 | } 122 | } 123 | } 124 | } 125 | 126 | 127 | -------------------------------------------------------------------------------- /assemblyscript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@wasmer/io-devices-lib-assemblyscript", 3 | "version": "0.1.3", 4 | "description": "Library for interacting with the Wasmer Experimental IO Devices in AssemblyScript", 5 | "main": "lib/lib.ts", 6 | "scripts": { 7 | "start": "../../wasmer/target/release/wasmer run --enable-experimental-io-devices debug-example/build/optimized.wasm", 8 | "start:no-flag": "../../wasmer/target/release/wasmer run debug-example/build/optimized.wasm", 9 | "start:quick-start": "../../wasmer/target/release/wasmer run --enable-experimental-io-devices quick-start/build/optimized.wasm", 10 | "build": "npm run asbuild", 11 | "deploy": "npm run build && np", 12 | "asbuild": "npm run asbuild:untouched && npm run asbuild:optimized && npm run asbuild:quick-start", 13 | "asbuild:untouched": "asc debug-example/index.ts -b debug-example/build/untouched.wasm -t debug-example/build/untouched.wat --sourceMap --validate --debug --use abort=wasi_abort --runtime stub", 14 | "asbuild:optimized": "asc debug-example/index.ts -b debug-example/build/optimized.wasm -t debug-example/build/optimized.wat --sourceMap --validate --optimize --use abort=wasi_abort --runtime stub", 15 | "asbuild:quick-start": "asc quick-start/graphics.ts -b quick-start/build/optimized.wasm -t quick-start/build/optimized.wat --sourceMap --validate --optimize --use abort=wasi_abort --runtime stub" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/wasmerio/io-devices-lib.git" 20 | }, 21 | "keywords": [ 22 | "assemblyscript", 23 | "wasmer", 24 | "graphics", 25 | "audio", 26 | "input", 27 | "wasi", 28 | "wasm", 29 | "web", 30 | "assembly", 31 | "webassembly" 32 | ], 33 | "author": "Wasmer Engineering Team ", 34 | "license": "MIT", 35 | "bugs": { 36 | "url": "https://github.com/wasmerio/io-devices-lib/issues" 37 | }, 38 | "homepage": "https://github.com/wasmerio/io-devices-lib#readme", 39 | "dependencies": { 40 | "as-wasi": "git+https://github.com/jedisct1/as-wasi.git" 41 | }, 42 | "devDependencies": { 43 | "np": "^5.2.1" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /assemblyscript/quick-start/build/optimized.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasmerio/io-devices-lib/3595940c91f2304c9897c55dc281cdcd4d99c7cc/assemblyscript/quick-start/build/optimized.wasm -------------------------------------------------------------------------------- /assemblyscript/quick-start/build/optimized.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (type $FUNCSIG$iii (func (param i32 i32) (result i32))) 3 | (type $FUNCSIG$vi (func (param i32))) 4 | (type $FUNCSIG$ii (func (param i32) (result i32))) 5 | (type $FUNCSIG$v (func)) 6 | (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) 7 | (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) 8 | (type $FUNCSIG$viii (func (param i32 i32 i32))) 9 | (type $FUNCSIG$vii (func (param i32 i32))) 10 | (type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32))) 11 | (type $FUNCSIG$iiiiiijjii (func (param i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i32))) 12 | (type $FUNCSIG$iijii (func (param i32 i64 i32 i32) (result i32))) 13 | (type $FUNCSIG$i (func (result i32))) 14 | (import "wasi_unstable" "fd_write" (func $~lib/bindings/wasi_unstable/fd_write (param i32 i32 i32 i32) (result i32))) 15 | (import "wasi_unstable" "proc_exit" (func $~lib/bindings/wasi_unstable/proc_exit (param i32))) 16 | (import "wasi_unstable" "path_open" (func $~lib/bindings/wasi_unstable/path_open (param i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i32))) 17 | (import "wasi_unstable" "fd_seek" (func $~lib/bindings/wasi_unstable/fd_seek (param i32 i64 i32 i32) (result i32))) 18 | (import "wasi_unstable" "poll_oneoff" (func $~lib/bindings/wasi_unstable/poll_oneoff (param i32 i32 i32 i32) (result i32))) 19 | (memory $0 1) 20 | (data (i32.const 8) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\00:") 21 | (data (i32.const 32) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00n\00u\00l\00l") 22 | (data (i32.const 60) "\01\00\00\00\01") 23 | (data (i32.const 72) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\000") 24 | (data (i32.const 96) "\12\00\00\00\01\00\00\00\01\00\00\00\12\00\00\00:\00 \00e\00r\00r\00o\00r\00:\00 ") 25 | (data (i32.const 136) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s") 26 | (data (i32.const 184) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00s\00t\00u\00b\00.\00t\00s") 27 | (data (i32.const 232) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") 28 | (data (i32.const 280) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") 29 | (data (i32.const 336) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e") 30 | (data (i32.const 392) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s") 31 | (data (i32.const 440) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00L\00e\00f\00t") 32 | (data (i32.const 464) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00R\00i\00g\00h\00t") 33 | (data (i32.const 496) "\0c\00\00\00\01\00\00\00\01\00\00\00\0c\00\00\00M\00i\00d\00d\00l\00e") 34 | (data (i32.const 528) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\000") 35 | (data (i32.const 552) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\001") 36 | (data (i32.const 576) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\002") 37 | (data (i32.const 600) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\003") 38 | (data (i32.const 624) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\004") 39 | (data (i32.const 648) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\005") 40 | (data (i32.const 672) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\006") 41 | (data (i32.const 696) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\007") 42 | (data (i32.const 720) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\008") 43 | (data (i32.const 744) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\009") 44 | (data (i32.const 768) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00A") 45 | (data (i32.const 792) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00B") 46 | (data (i32.const 816) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00C") 47 | (data (i32.const 840) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00D") 48 | (data (i32.const 864) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00E") 49 | (data (i32.const 888) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00F") 50 | (data (i32.const 912) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00G") 51 | (data (i32.const 936) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00H") 52 | (data (i32.const 960) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00I") 53 | (data (i32.const 984) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00J") 54 | (data (i32.const 1008) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00K") 55 | (data (i32.const 1032) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00L") 56 | (data (i32.const 1056) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00M") 57 | (data (i32.const 1080) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00N") 58 | (data (i32.const 1104) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00O") 59 | (data (i32.const 1128) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00P") 60 | (data (i32.const 1152) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00Q") 61 | (data (i32.const 1176) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00R") 62 | (data (i32.const 1200) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00S") 63 | (data (i32.const 1224) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00T") 64 | (data (i32.const 1248) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00U") 65 | (data (i32.const 1272) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00V") 66 | (data (i32.const 1296) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00W") 67 | (data (i32.const 1320) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00X") 68 | (data (i32.const 1344) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00Y") 69 | (data (i32.const 1368) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00K\00e\00y\00Z") 70 | (data (i32.const 1392) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00K\00e\00y\00F\001") 71 | (data (i32.const 1424) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00K\00e\00y\00F\002") 72 | (data (i32.const 1456) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00K\00e\00y\00F\003") 73 | (data (i32.const 1488) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00K\00e\00y\00F\004") 74 | (data (i32.const 1520) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00K\00e\00y\00F\005") 75 | (data (i32.const 1552) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00K\00e\00y\00F\006") 76 | (data (i32.const 1584) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00K\00e\00y\00F\007") 77 | (data (i32.const 1616) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00K\00e\00y\00F\008") 78 | (data (i32.const 1648) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00K\00e\00y\00F\009") 79 | (data (i32.const 1680) "\0c\00\00\00\01\00\00\00\01\00\00\00\0c\00\00\00K\00e\00y\00F\001\000") 80 | (data (i32.const 1712) "\0c\00\00\00\01\00\00\00\01\00\00\00\0c\00\00\00K\00e\00y\00F\001\001") 81 | (data (i32.const 1744) "\0c\00\00\00\01\00\00\00\01\00\00\00\0c\00\00\00K\00e\00y\00F\001\002") 82 | (data (i32.const 1776) "\0e\00\00\00\01\00\00\00\01\00\00\00\0e\00\00\00K\00e\00y\00D\00o\00w\00n") 83 | (data (i32.const 1808) "\0e\00\00\00\01\00\00\00\01\00\00\00\0e\00\00\00K\00e\00y\00L\00e\00f\00t") 84 | (data (i32.const 1840) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00K\00e\00y\00R\00i\00g\00h\00t") 85 | (data (i32.const 1872) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00K\00e\00y\00U\00p") 86 | (data (i32.const 1904) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00K\00e\00y\00A\00p\00o\00s\00t\00r\00o\00p\00h\00e") 87 | (data (i32.const 1952) "\18\00\00\00\01\00\00\00\01\00\00\00\18\00\00\00K\00e\00y\00B\00a\00c\00k\00q\00u\00o\00t\00e") 88 | (data (i32.const 1992) "\18\00\00\00\01\00\00\00\01\00\00\00\18\00\00\00K\00e\00y\00B\00a\00c\00k\00s\00l\00a\00s\00h") 89 | (data (i32.const 2032) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00K\00e\00y\00C\00o\00m\00m\00a") 90 | (data (i32.const 2064) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00K\00e\00y\00E\00q\00u\00a\00l") 91 | (data (i32.const 2096) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00K\00e\00y\00L\00e\00f\00t\00B\00r\00a\00c\00k\00e\00t") 92 | (data (i32.const 2144) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00K\00e\00y\00M\00i\00n\00u\00s") 93 | (data (i32.const 2176) "\12\00\00\00\01\00\00\00\01\00\00\00\12\00\00\00K\00e\00y\00P\00e\00r\00i\00o\00d") 94 | (data (i32.const 2216) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00K\00e\00y\00R\00i\00g\00h\00t\00B\00r\00a\00c\00k\00e\00t") 95 | (data (i32.const 2264) "\18\00\00\00\01\00\00\00\01\00\00\00\18\00\00\00K\00e\00y\00S\00e\00m\00i\00c\00o\00l\00o\00n") 96 | (data (i32.const 2304) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00K\00e\00y\00S\00l\00a\00s\00h") 97 | (data (i32.const 2336) "\18\00\00\00\01\00\00\00\01\00\00\00\18\00\00\00K\00e\00y\00B\00a\00c\00k\00s\00p\00a\00c\00e") 98 | (data (i32.const 2376) "\12\00\00\00\01\00\00\00\01\00\00\00\12\00\00\00K\00e\00y\00D\00e\00l\00e\00t\00e") 99 | (data (i32.const 2416) "\0c\00\00\00\01\00\00\00\01\00\00\00\0c\00\00\00K\00e\00y\00E\00n\00d") 100 | (data (i32.const 2448) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00K\00e\00y\00E\00n\00t\00e\00r") 101 | (data (i32.const 2480) "\12\00\00\00\01\00\00\00\01\00\00\00\12\00\00\00K\00e\00y\00E\00s\00c\00a\00p\00e") 102 | (data (i32.const 2520) "\0e\00\00\00\01\00\00\00\01\00\00\00\0e\00\00\00K\00e\00y\00H\00o\00m\00e") 103 | (data (i32.const 2552) "\12\00\00\00\01\00\00\00\01\00\00\00\12\00\00\00K\00e\00y\00I\00n\00s\00e\00r\00t") 104 | (data (i32.const 2592) "\16\00\00\00\01\00\00\00\01\00\00\00\16\00\00\00K\00e\00y\00P\00a\00g\00e\00D\00o\00w\00n") 105 | (data (i32.const 2632) "\12\00\00\00\01\00\00\00\01\00\00\00\12\00\00\00K\00e\00y\00P\00a\00g\00e\00U\00p") 106 | (data (i32.const 2672) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00K\00e\00y\00P\00a\00u\00s\00e") 107 | (data (i32.const 2704) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00K\00e\00y\00S\00p\00a\00c\00e") 108 | (data (i32.const 2736) "\0c\00\00\00\01\00\00\00\01\00\00\00\0c\00\00\00K\00e\00y\00T\00a\00b") 109 | (data (i32.const 2768) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00K\00e\00y\00N\00u\00m\00L\00o\00c\00k") 110 | (data (i32.const 2808) "\16\00\00\00\01\00\00\00\01\00\00\00\16\00\00\00K\00e\00y\00C\00a\00p\00s\00L\00o\00c\00k") 111 | (data (i32.const 2848) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00K\00e\00y\00S\00c\00r\00o\00l\00l\00L\00o\00c\00k") 112 | (data (i32.const 2896) "\10\00\00\00\01\00\00\00\01\00\00\00\10\00\00\00K\00e\00y\00S\00h\00i\00f\00t") 113 | (data (i32.const 2928) "\16\00\00\00\01\00\00\00\01\00\00\00\16\00\00\00K\00e\00y\00L\00e\00f\00t\00C\00t\00r\00l") 114 | (data (i32.const 2968) "\18\00\00\00\01\00\00\00\01\00\00\00\18\00\00\00K\00e\00y\00R\00i\00g\00h\00t\00C\00t\00r\00l") 115 | (data (i32.const 3008) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\000") 116 | (data (i32.const 3048) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\001") 117 | (data (i32.const 3088) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\002") 118 | (data (i32.const 3128) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\003") 119 | (data (i32.const 3168) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\004") 120 | (data (i32.const 3208) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\005") 121 | (data (i32.const 3248) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\006") 122 | (data (i32.const 3288) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\007") 123 | (data (i32.const 3328) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\008") 124 | (data (i32.const 3368) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\009") 125 | (data (i32.const 3408) "\18\00\00\00\01\00\00\00\01\00\00\00\18\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\00D\00o\00t") 126 | (data (i32.const 3448) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\00S\00l\00a\00s\00h") 127 | (data (i32.const 3496) "\"\00\00\00\01\00\00\00\01\00\00\00\"\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\00A\00s\00t\00e\00r\00i\00s\00k") 128 | (data (i32.const 3552) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\00M\00i\00n\00u\00s") 129 | (data (i32.const 3600) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\00P\00l\00u\00s") 130 | (data (i32.const 3648) "\0c\00\00\00\01\00\00\00\01\00\00\00\0c\00\00\00K\00e\00y\00A\00l\00t") 131 | (data (i32.const 3680) "\18\00\00\00\01\00\00\00\01\00\00\00\18\00\00\00K\00e\00y\00L\00e\00f\00t\00S\00u\00p\00e\00r") 132 | (data (i32.const 3720) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00K\00e\00y\00R\00i\00g\00h\00t\00S\00u\00p\00e\00r") 133 | (data (i32.const 3768) "\0e\00\00\00\01\00\00\00\01\00\00\00\0e\00\00\00K\00e\00y\00M\00e\00n\00u") 134 | (data (i32.const 3800) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00K\00e\00y\00N\00u\00m\00P\00a\00d\00E\00n\00t\00e\00r") 135 | (data (i32.const 3848) "8\00\00\00\01\00\00\00\01\00\00\008\00\00\00_\00w\00a\00s\00m\00e\00r\00/\00d\00e\00v\00/\00f\00b\000\00/\00v\00i\00r\00t\00u\00a\00l\00_\00s\00i\00z\00e") 136 | (data (i32.const 3920) "\04\00\00\00\01\00\00\00\01\00\00\00\04\00\00\00w\00+") 137 | (data (i32.const 3944) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\00r") 138 | (data (i32.const 3968) "\04\00\00\00\01\00\00\00\01\00\00\00\04\00\00\00r\00+") 139 | (data (i32.const 3992) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\00w") 140 | (data (i32.const 4016) "\04\00\00\00\01\00\00\00\01\00\00\00\04\00\00\00w\00x") 141 | (data (i32.const 4040) "\06\00\00\00\01\00\00\00\01\00\00\00\06\00\00\00x\00w\00+") 142 | (data (i32.const 4064) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00_\00w\00a\00s\00m\00e\00r\00/\00d\00e\00v\00/\00f\00b\000\00/\00d\00r\00a\00w") 143 | (data (i32.const 4120) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00_\00w\00a\00s\00m\00e\00r\00/\00d\00e\00v\00/\00f\00b\000\00/\00f\00b") 144 | (data (i32.const 4176) "*\00\00\00\01\00\00\00\01\00\00\00*\00\00\00_\00w\00a\00s\00m\00e\00r\00/\00d\00e\00v\00/\00f\00b\000\00/\00i\00n\00p\00u\00t") 145 | (data (i32.const 4240) "\b6\00\00\00\01\00\00\00\01\00\00\00\b6\00\00\00F\00a\00i\00l\00e\00d\00 \00t\00o\00 \00o\00p\00e\00n\00 \00I\00/\00O\00 \00D\00e\00v\00i\00c\00e\00s\00 \00f\00i\00l\00e\00s\00 \00(\00E\00.\00g\00 \00`\00_\00w\00a\00s\00m\00e\00r\00/\00d\00e\00v\00/\00f\00b\000\00/\00f\00b\00`\00)\00.\00 \00T\00h\00e\00s\00e\00 \00a\00r\00e\00 \00n\00o\00n\00-\00s\00t\00a\00n\00d\00a\00r\00d\00 \00f\00i\00l\00e\00s\00.\00 ") 146 | (data (i32.const 4440) "\ba\00\00\00\01\00\00\00\01\00\00\00\ba\00\00\00I\00f\00 \00y\00o\00u\00\'\00r\00e\00 \00u\00s\00i\00n\00g\00 \00W\00a\00s\00m\00e\00r\00,\00 \00p\00l\00e\00a\00s\00e\00 \00e\00n\00s\00u\00r\00e\00 \00t\00h\00a\00t\00 \00y\00o\00u\00\'\00v\00e\00 \00u\00p\00d\00a\00t\00e\00d\00 \00t\00o\00 \00v\00e\00r\00s\00i\00o\00n\00 \000\00.\001\003\00.\001\00 \00a\00n\00d\00 \00a\00r\00e\00 \00u\00s\00i\00n\00g\00 \00t\00h\00e") 147 | (data (i32.const 4648) "R\00\00\00\01\00\00\00\01\00\00\00R\00\00\00 \00`\00-\00-\00e\00n\00a\00b\00l\00e\00-\00e\00x\00p\00e\00r\00i\00m\00e\00n\00t\00a\00l\00-\00i\00o\00-\00d\00e\00v\00i\00c\00e\00s\00`\00 \00f\00l\00a\00g\00.") 148 | (data (i32.const 4752) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00l\00i\00b\00/\00l\00i\00b\00.\00t\00s") 149 | (data (i32.const 4792) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00_\00w\00a\00s\00m\00e\00r\00/\00d\00e\00v\00/\00f\00b") 150 | (data (i32.const 4840) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00/\00v\00i\00r\00t\00u\00a\00l\00_\00s\00i\00z\00e") 151 | (data (i32.const 4888) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\00x") 152 | (data (i32.const 4912) "\06\00\00\00\01\00\00\00\01\00\00\00\06\00\00\00/\00f\00b") 153 | (data (i32.const 4936) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00/\00d\00r\00a\00w") 154 | (data (i32.const 4968) "\08\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\93\04\00\00\02\00\00\00\10\00\00\00\00\00\00\008\00A\00\00\00\00\00\98 \t\00\00\00\00\003\00\00\00\02") 155 | (global $~lib/rt/stub/startOffset (mut i32) (i32.const 0)) 156 | (global $~lib/rt/stub/offset (mut i32) (i32.const 0)) 157 | (global $~lib/as-wasi/as-wasi/Time.MILLISECOND (mut i32) (i32.const 0)) 158 | (global $~lib/as-wasi/as-wasi/Time.SECOND (mut i32) (i32.const 0)) 159 | (global $lib/input-map/mousePosition (mut i32) (i32.const 0)) 160 | (global $lib/input-map/mouseClickMap (mut i32) (i32.const 0)) 161 | (global $lib/input-map/byteToInputKeyMap (mut i32) (i32.const 0)) 162 | (global $lib/input-map/keyPressStateMap (mut i32) (i32.const 0)) 163 | (global $~lib/rt/__rtti_base i32 (i32.const 4968)) 164 | (export "memory" (memory $0)) 165 | (export "__alloc" (func $~lib/rt/stub/__alloc)) 166 | (export "__retain" (func $~lib/rt/stub/__retain)) 167 | (export "__release" (func $~lib/rt/stub/__release)) 168 | (export "__collect" (func $~lib/rt/stub/__collect)) 169 | (export "__rtti_base" (global $~lib/rt/__rtti_base)) 170 | (export "_start" (func $quick-start/graphics/_start)) 171 | (start $start) 172 | (func $~lib/rt/stub/maybeGrowMemory (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) 173 | (local $1 i32) 174 | (local $2 i32) 175 | local.get $0 176 | memory.size 177 | local.tee $2 178 | i32.const 16 179 | i32.shl 180 | local.tee $1 181 | i32.gt_u 182 | if 183 | local.get $2 184 | local.get $0 185 | local.get $1 186 | i32.sub 187 | i32.const 65535 188 | i32.add 189 | i32.const -65536 190 | i32.and 191 | i32.const 16 192 | i32.shr_u 193 | local.tee $1 194 | local.get $2 195 | local.get $1 196 | i32.gt_s 197 | select 198 | memory.grow 199 | i32.const 0 200 | i32.lt_s 201 | if 202 | local.get $1 203 | memory.grow 204 | i32.const 0 205 | i32.lt_s 206 | if 207 | unreachable 208 | end 209 | end 210 | end 211 | local.get $0 212 | global.set $~lib/rt/stub/offset 213 | ) 214 | (func $~lib/rt/stub/__alloc (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) 215 | (local $2 i32) 216 | (local $3 i32) 217 | (local $4 i32) 218 | local.get $0 219 | i32.const 1073741808 220 | i32.gt_u 221 | if 222 | unreachable 223 | end 224 | global.get $~lib/rt/stub/offset 225 | i32.const 16 226 | i32.add 227 | local.tee $3 228 | local.get $0 229 | i32.const 15 230 | i32.add 231 | i32.const -16 232 | i32.and 233 | local.tee $2 234 | i32.const 16 235 | local.get $2 236 | i32.const 16 237 | i32.gt_u 238 | select 239 | local.tee $4 240 | i32.add 241 | call $~lib/rt/stub/maybeGrowMemory 242 | local.get $3 243 | i32.const 16 244 | i32.sub 245 | local.tee $2 246 | local.get $4 247 | i32.store 248 | local.get $2 249 | i32.const -1 250 | i32.store offset=4 251 | local.get $2 252 | local.get $1 253 | i32.store offset=8 254 | local.get $2 255 | local.get $0 256 | i32.store offset=12 257 | local.get $3 258 | ) 259 | (func $~lib/rt/stub/__retain (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 260 | local.get $0 261 | ) 262 | (func $~lib/rt/stub/__release (; 8 ;) (type $FUNCSIG$vi) (param $0 i32) 263 | nop 264 | ) 265 | (func $~lib/rt/stub/__collect (; 9 ;) (type $FUNCSIG$v) 266 | nop 267 | ) 268 | (func $~lib/string/String#get:length (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 269 | local.get $0 270 | i32.const 16 271 | i32.sub 272 | i32.load offset=12 273 | i32.const 1 274 | i32.shr_u 275 | ) 276 | (func $~lib/memory/memory.copy (; 11 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) 277 | (local $3 i32) 278 | (local $4 i32) 279 | block $~lib/util/memory/memmove|inlined.0 280 | local.get $2 281 | local.set $3 282 | local.get $0 283 | local.get $1 284 | i32.eq 285 | br_if $~lib/util/memory/memmove|inlined.0 286 | local.get $0 287 | local.get $1 288 | i32.lt_u 289 | if 290 | local.get $1 291 | i32.const 7 292 | i32.and 293 | local.get $0 294 | i32.const 7 295 | i32.and 296 | i32.eq 297 | if 298 | loop $continue|0 299 | local.get $0 300 | i32.const 7 301 | i32.and 302 | if 303 | local.get $3 304 | i32.eqz 305 | br_if $~lib/util/memory/memmove|inlined.0 306 | local.get $3 307 | i32.const 1 308 | i32.sub 309 | local.set $3 310 | local.get $0 311 | local.tee $2 312 | i32.const 1 313 | i32.add 314 | local.set $0 315 | local.get $1 316 | local.tee $4 317 | i32.const 1 318 | i32.add 319 | local.set $1 320 | local.get $2 321 | local.get $4 322 | i32.load8_u 323 | i32.store8 324 | br $continue|0 325 | end 326 | end 327 | loop $continue|1 328 | local.get $3 329 | i32.const 8 330 | i32.lt_u 331 | i32.eqz 332 | if 333 | local.get $0 334 | local.get $1 335 | i64.load 336 | i64.store 337 | local.get $3 338 | i32.const 8 339 | i32.sub 340 | local.set $3 341 | local.get $0 342 | i32.const 8 343 | i32.add 344 | local.set $0 345 | local.get $1 346 | i32.const 8 347 | i32.add 348 | local.set $1 349 | br $continue|1 350 | end 351 | end 352 | end 353 | loop $continue|2 354 | local.get $3 355 | if 356 | local.get $0 357 | local.tee $2 358 | i32.const 1 359 | i32.add 360 | local.set $0 361 | local.get $1 362 | local.tee $4 363 | i32.const 1 364 | i32.add 365 | local.set $1 366 | local.get $2 367 | local.get $4 368 | i32.load8_u 369 | i32.store8 370 | local.get $3 371 | i32.const 1 372 | i32.sub 373 | local.set $3 374 | br $continue|2 375 | end 376 | end 377 | else 378 | local.get $1 379 | i32.const 7 380 | i32.and 381 | local.get $0 382 | i32.const 7 383 | i32.and 384 | i32.eq 385 | if 386 | loop $continue|3 387 | local.get $0 388 | local.get $3 389 | i32.add 390 | i32.const 7 391 | i32.and 392 | if 393 | local.get $3 394 | i32.eqz 395 | br_if $~lib/util/memory/memmove|inlined.0 396 | local.get $0 397 | local.get $3 398 | i32.const 1 399 | i32.sub 400 | local.tee $3 401 | i32.add 402 | local.get $1 403 | local.get $3 404 | i32.add 405 | i32.load8_u 406 | i32.store8 407 | br $continue|3 408 | end 409 | end 410 | loop $continue|4 411 | local.get $3 412 | i32.const 8 413 | i32.lt_u 414 | i32.eqz 415 | if 416 | local.get $0 417 | local.get $3 418 | i32.const 8 419 | i32.sub 420 | local.tee $3 421 | i32.add 422 | local.get $1 423 | local.get $3 424 | i32.add 425 | i64.load 426 | i64.store 427 | br $continue|4 428 | end 429 | end 430 | end 431 | loop $continue|5 432 | local.get $3 433 | if 434 | local.get $0 435 | local.get $3 436 | i32.const 1 437 | i32.sub 438 | local.tee $3 439 | i32.add 440 | local.get $1 441 | local.get $3 442 | i32.add 443 | i32.load8_u 444 | i32.store8 445 | br $continue|5 446 | end 447 | end 448 | end 449 | end 450 | ) 451 | (func $~lib/string/String#concat (; 12 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) 452 | (local $2 i32) 453 | (local $3 i32) 454 | (local $4 i32) 455 | local.get $0 456 | call $~lib/string/String#get:length 457 | i32.const 1 458 | i32.shl 459 | local.tee $3 460 | local.get $1 461 | i32.const 48 462 | local.get $1 463 | select 464 | local.tee $1 465 | call $~lib/string/String#get:length 466 | i32.const 1 467 | i32.shl 468 | local.tee $4 469 | i32.add 470 | local.tee $2 471 | i32.eqz 472 | if 473 | i32.const 72 474 | return 475 | end 476 | local.get $2 477 | i32.const 1 478 | call $~lib/rt/stub/__alloc 479 | local.tee $2 480 | local.get $0 481 | local.get $3 482 | call $~lib/memory/memory.copy 483 | local.get $2 484 | local.get $3 485 | i32.add 486 | local.get $1 487 | local.get $4 488 | call $~lib/memory/memory.copy 489 | local.get $2 490 | ) 491 | (func $~lib/string/String.__concat (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) 492 | local.get $0 493 | i32.const 48 494 | local.get $0 495 | select 496 | local.get $1 497 | call $~lib/string/String#concat 498 | ) 499 | (func $~lib/util/number/decimalCount32 (; 14 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 500 | i32.const 1 501 | i32.const 2 502 | local.get $0 503 | i32.const 10 504 | i32.lt_u 505 | select 506 | i32.const 3 507 | i32.const 4 508 | i32.const 5 509 | local.get $0 510 | i32.const 10000 511 | i32.lt_u 512 | select 513 | local.get $0 514 | i32.const 1000 515 | i32.lt_u 516 | select 517 | local.get $0 518 | i32.const 100 519 | i32.lt_u 520 | select 521 | i32.const 6 522 | i32.const 7 523 | local.get $0 524 | i32.const 1000000 525 | i32.lt_u 526 | select 527 | i32.const 8 528 | i32.const 9 529 | i32.const 10 530 | local.get $0 531 | i32.const 1000000000 532 | i32.lt_u 533 | select 534 | local.get $0 535 | i32.const 100000000 536 | i32.lt_u 537 | select 538 | local.get $0 539 | i32.const 10000000 540 | i32.lt_u 541 | select 542 | local.get $0 543 | i32.const 100000 544 | i32.lt_u 545 | select 546 | ) 547 | (func $~lib/util/number/utoa_simple (; 15 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) 548 | (local $3 i32) 549 | loop $continue|0 550 | local.get $1 551 | i32.const 10 552 | i32.rem_u 553 | local.set $3 554 | local.get $1 555 | i32.const 10 556 | i32.div_u 557 | local.set $1 558 | local.get $2 559 | i32.const 1 560 | i32.sub 561 | local.tee $2 562 | i32.const 1 563 | i32.shl 564 | local.get $0 565 | i32.add 566 | local.get $3 567 | i32.const 48 568 | i32.add 569 | i32.store16 570 | local.get $1 571 | br_if $continue|0 572 | end 573 | ) 574 | (func $~lib/util/number/utoa32 (; 16 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 575 | (local $1 i32) 576 | (local $2 i32) 577 | local.get $0 578 | i32.eqz 579 | if 580 | i32.const 88 581 | return 582 | end 583 | local.get $0 584 | call $~lib/util/number/decimalCount32 585 | local.tee $1 586 | i32.const 1 587 | i32.shl 588 | i32.const 1 589 | call $~lib/rt/stub/__alloc 590 | local.tee $2 591 | local.get $0 592 | local.get $1 593 | call $~lib/util/number/utoa_simple 594 | local.get $2 595 | ) 596 | (func $~lib/as-wasi/as-wasi/Descriptor#constructor (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 597 | (local $1 i32) 598 | i32.const 4 599 | i32.const 4 600 | call $~lib/rt/stub/__alloc 601 | local.tee $1 602 | local.get $0 603 | i32.store 604 | local.get $1 605 | ) 606 | (func $~lib/string/String.UTF8.byteLength (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 607 | (local $1 i32) 608 | (local $2 i32) 609 | (local $3 i32) 610 | local.get $0 611 | local.tee $1 612 | local.get $1 613 | i32.const 16 614 | i32.sub 615 | i32.load offset=12 616 | i32.add 617 | local.set $3 618 | loop $continue|0 619 | local.get $1 620 | local.get $3 621 | i32.lt_u 622 | if 623 | local.get $1 624 | i32.load16_u 625 | local.tee $0 626 | i32.const 128 627 | i32.lt_u 628 | if (result i32) 629 | local.get $2 630 | i32.const 1 631 | i32.add 632 | else 633 | local.get $0 634 | i32.const 2048 635 | i32.lt_u 636 | if (result i32) 637 | local.get $2 638 | i32.const 2 639 | i32.add 640 | else 641 | local.get $1 642 | i32.const 2 643 | i32.add 644 | local.get $3 645 | i32.lt_u 646 | i32.const 0 647 | local.get $0 648 | i32.const 64512 649 | i32.and 650 | i32.const 55296 651 | i32.eq 652 | select 653 | if 654 | local.get $1 655 | i32.load16_u offset=2 656 | i32.const 64512 657 | i32.and 658 | i32.const 56320 659 | i32.eq 660 | if 661 | local.get $1 662 | i32.const 4 663 | i32.add 664 | local.set $1 665 | local.get $2 666 | i32.const 4 667 | i32.add 668 | local.set $2 669 | br $continue|0 670 | end 671 | end 672 | local.get $2 673 | i32.const 3 674 | i32.add 675 | end 676 | end 677 | local.set $2 678 | local.get $1 679 | i32.const 2 680 | i32.add 681 | local.set $1 682 | br $continue|0 683 | end 684 | end 685 | local.get $2 686 | ) 687 | (func $~lib/rt/stub/__realloc (; 19 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) 688 | (local $2 i32) 689 | (local $3 i32) 690 | (local $4 i32) 691 | (local $5 i32) 692 | local.get $0 693 | i32.const 15 694 | i32.and 695 | i32.eqz 696 | i32.const 0 697 | local.get $0 698 | select 699 | i32.eqz 700 | if 701 | i32.const 0 702 | i32.const 200 703 | i32.const 43 704 | i32.const 2 705 | call $~lib/as-wasi/as-wasi/wasi_abort 706 | unreachable 707 | end 708 | local.get $0 709 | i32.const 16 710 | i32.sub 711 | local.tee $3 712 | i32.load 713 | local.set $4 714 | local.get $3 715 | i32.load offset=4 716 | i32.const -1 717 | i32.ne 718 | if 719 | i32.const 0 720 | i32.const 200 721 | i32.const 46 722 | i32.const 13 723 | call $~lib/as-wasi/as-wasi/wasi_abort 724 | unreachable 725 | end 726 | global.get $~lib/rt/stub/offset 727 | local.get $0 728 | local.get $4 729 | i32.add 730 | i32.eq 731 | local.set $5 732 | local.get $1 733 | i32.const 15 734 | i32.add 735 | i32.const -16 736 | i32.and 737 | local.set $2 738 | local.get $1 739 | local.get $4 740 | i32.gt_u 741 | if 742 | local.get $5 743 | if 744 | local.get $1 745 | i32.const 1073741808 746 | i32.gt_u 747 | if 748 | unreachable 749 | end 750 | local.get $0 751 | local.get $2 752 | i32.add 753 | call $~lib/rt/stub/maybeGrowMemory 754 | local.get $3 755 | local.get $2 756 | i32.store 757 | else 758 | local.get $2 759 | local.get $4 760 | i32.const 1 761 | i32.shl 762 | local.tee $4 763 | local.get $2 764 | local.get $4 765 | i32.gt_u 766 | select 767 | local.get $3 768 | i32.load offset=8 769 | call $~lib/rt/stub/__alloc 770 | local.tee $2 771 | local.get $0 772 | local.get $3 773 | i32.load offset=12 774 | call $~lib/memory/memory.copy 775 | local.get $2 776 | local.tee $0 777 | i32.const 16 778 | i32.sub 779 | local.set $3 780 | end 781 | else 782 | local.get $5 783 | if 784 | local.get $0 785 | local.get $2 786 | i32.add 787 | global.set $~lib/rt/stub/offset 788 | local.get $3 789 | local.get $2 790 | i32.store 791 | end 792 | end 793 | local.get $3 794 | local.get $1 795 | i32.store offset=12 796 | local.get $0 797 | ) 798 | (func $~lib/string/String.UTF8.encode (; 20 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 799 | (local $1 i32) 800 | (local $2 i32) 801 | (local $3 i32) 802 | (local $4 i32) 803 | (local $5 i32) 804 | local.get $0 805 | local.tee $2 806 | local.get $0 807 | i32.const 16 808 | i32.sub 809 | i32.load offset=12 810 | i32.add 811 | local.set $3 812 | local.get $0 813 | call $~lib/string/String.UTF8.byteLength 814 | i32.const 0 815 | call $~lib/rt/stub/__alloc 816 | local.tee $4 817 | local.set $0 818 | loop $continue|0 819 | local.get $2 820 | local.get $3 821 | i32.lt_u 822 | if 823 | local.get $2 824 | i32.load16_u 825 | local.tee $1 826 | i32.const 128 827 | i32.lt_u 828 | if (result i32) 829 | local.get $0 830 | local.get $1 831 | i32.store8 832 | local.get $0 833 | i32.const 1 834 | i32.add 835 | else 836 | local.get $1 837 | i32.const 2048 838 | i32.lt_u 839 | if (result i32) 840 | local.get $0 841 | local.get $1 842 | i32.const 6 843 | i32.shr_u 844 | i32.const 192 845 | i32.or 846 | i32.store8 847 | local.get $0 848 | local.get $1 849 | i32.const 63 850 | i32.and 851 | i32.const 128 852 | i32.or 853 | i32.store8 offset=1 854 | local.get $0 855 | i32.const 2 856 | i32.add 857 | else 858 | local.get $2 859 | i32.const 2 860 | i32.add 861 | local.get $3 862 | i32.lt_u 863 | i32.const 0 864 | local.get $1 865 | i32.const 64512 866 | i32.and 867 | i32.const 55296 868 | i32.eq 869 | select 870 | if 871 | local.get $2 872 | i32.load16_u offset=2 873 | local.tee $5 874 | i32.const 64512 875 | i32.and 876 | i32.const 56320 877 | i32.eq 878 | if 879 | local.get $0 880 | local.get $1 881 | i32.const 1023 882 | i32.and 883 | i32.const 10 884 | i32.shl 885 | i32.const 65536 886 | i32.add 887 | local.get $5 888 | i32.const 1023 889 | i32.and 890 | i32.add 891 | local.tee $1 892 | i32.const 18 893 | i32.shr_u 894 | i32.const 240 895 | i32.or 896 | i32.store8 897 | local.get $0 898 | local.get $1 899 | i32.const 12 900 | i32.shr_u 901 | i32.const 63 902 | i32.and 903 | i32.const 128 904 | i32.or 905 | i32.store8 offset=1 906 | local.get $0 907 | local.get $1 908 | i32.const 6 909 | i32.shr_u 910 | i32.const 63 911 | i32.and 912 | i32.const 128 913 | i32.or 914 | i32.store8 offset=2 915 | local.get $0 916 | local.get $1 917 | i32.const 63 918 | i32.and 919 | i32.const 128 920 | i32.or 921 | i32.store8 offset=3 922 | local.get $2 923 | i32.const 4 924 | i32.add 925 | local.set $2 926 | local.get $0 927 | i32.const 4 928 | i32.add 929 | local.set $0 930 | br $continue|0 931 | end 932 | end 933 | local.get $0 934 | local.get $1 935 | i32.const 12 936 | i32.shr_u 937 | i32.const 224 938 | i32.or 939 | i32.store8 940 | local.get $0 941 | local.get $1 942 | i32.const 6 943 | i32.shr_u 944 | i32.const 63 945 | i32.and 946 | i32.const 128 947 | i32.or 948 | i32.store8 offset=1 949 | local.get $0 950 | local.get $1 951 | i32.const 63 952 | i32.and 953 | i32.const 128 954 | i32.or 955 | i32.store8 offset=2 956 | local.get $0 957 | i32.const 3 958 | i32.add 959 | end 960 | end 961 | local.set $0 962 | local.get $2 963 | i32.const 2 964 | i32.add 965 | local.set $2 966 | br $continue|0 967 | end 968 | end 969 | local.get $2 970 | local.get $3 971 | i32.ne 972 | if 973 | i32.const 0 974 | i32.const 152 975 | i32.const 571 976 | i32.const 8 977 | call $~lib/as-wasi/as-wasi/wasi_abort 978 | unreachable 979 | end 980 | local.get $4 981 | ) 982 | (func $~lib/memory/memory.fill (; 21 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) 983 | (local $2 i32) 984 | block $~lib/util/memory/memset|inlined.0 985 | local.get $1 986 | i32.eqz 987 | br_if $~lib/util/memory/memset|inlined.0 988 | local.get $0 989 | i32.const 0 990 | i32.store8 991 | local.get $0 992 | local.get $1 993 | i32.add 994 | i32.const 1 995 | i32.sub 996 | i32.const 0 997 | i32.store8 998 | local.get $1 999 | i32.const 2 1000 | i32.le_u 1001 | br_if $~lib/util/memory/memset|inlined.0 1002 | local.get $0 1003 | i32.const 1 1004 | i32.add 1005 | i32.const 0 1006 | i32.store8 1007 | local.get $0 1008 | i32.const 2 1009 | i32.add 1010 | i32.const 0 1011 | i32.store8 1012 | local.get $0 1013 | local.get $1 1014 | i32.add 1015 | local.tee $2 1016 | i32.const 2 1017 | i32.sub 1018 | i32.const 0 1019 | i32.store8 1020 | local.get $2 1021 | i32.const 3 1022 | i32.sub 1023 | i32.const 0 1024 | i32.store8 1025 | local.get $1 1026 | i32.const 6 1027 | i32.le_u 1028 | br_if $~lib/util/memory/memset|inlined.0 1029 | local.get $0 1030 | i32.const 3 1031 | i32.add 1032 | i32.const 0 1033 | i32.store8 1034 | local.get $0 1035 | local.get $1 1036 | i32.add 1037 | i32.const 4 1038 | i32.sub 1039 | i32.const 0 1040 | i32.store8 1041 | local.get $1 1042 | i32.const 8 1043 | i32.le_u 1044 | br_if $~lib/util/memory/memset|inlined.0 1045 | local.get $1 1046 | i32.const 0 1047 | local.get $0 1048 | i32.sub 1049 | i32.const 3 1050 | i32.and 1051 | local.tee $1 1052 | i32.sub 1053 | local.get $0 1054 | local.get $1 1055 | i32.add 1056 | local.tee $0 1057 | i32.const 0 1058 | i32.store 1059 | i32.const -4 1060 | i32.and 1061 | local.tee $1 1062 | local.get $0 1063 | i32.add 1064 | i32.const 4 1065 | i32.sub 1066 | i32.const 0 1067 | i32.store 1068 | local.get $1 1069 | i32.const 8 1070 | i32.le_u 1071 | br_if $~lib/util/memory/memset|inlined.0 1072 | local.get $0 1073 | i32.const 4 1074 | i32.add 1075 | i32.const 0 1076 | i32.store 1077 | local.get $0 1078 | i32.const 8 1079 | i32.add 1080 | i32.const 0 1081 | i32.store 1082 | local.get $0 1083 | local.get $1 1084 | i32.add 1085 | local.tee $2 1086 | i32.const 12 1087 | i32.sub 1088 | i32.const 0 1089 | i32.store 1090 | local.get $2 1091 | i32.const 8 1092 | i32.sub 1093 | i32.const 0 1094 | i32.store 1095 | local.get $1 1096 | i32.const 24 1097 | i32.le_u 1098 | br_if $~lib/util/memory/memset|inlined.0 1099 | local.get $0 1100 | i32.const 12 1101 | i32.add 1102 | i32.const 0 1103 | i32.store 1104 | local.get $0 1105 | i32.const 16 1106 | i32.add 1107 | i32.const 0 1108 | i32.store 1109 | local.get $0 1110 | i32.const 20 1111 | i32.add 1112 | i32.const 0 1113 | i32.store 1114 | local.get $0 1115 | i32.const 24 1116 | i32.add 1117 | i32.const 0 1118 | i32.store 1119 | local.get $0 1120 | local.get $1 1121 | i32.add 1122 | local.tee $2 1123 | i32.const 28 1124 | i32.sub 1125 | i32.const 0 1126 | i32.store 1127 | local.get $2 1128 | i32.const 24 1129 | i32.sub 1130 | i32.const 0 1131 | i32.store 1132 | local.get $2 1133 | i32.const 20 1134 | i32.sub 1135 | i32.const 0 1136 | i32.store 1137 | local.get $2 1138 | i32.const 16 1139 | i32.sub 1140 | i32.const 0 1141 | i32.store 1142 | local.get $0 1143 | i32.const 4 1144 | i32.and 1145 | i32.const 24 1146 | i32.add 1147 | local.tee $2 1148 | local.get $0 1149 | i32.add 1150 | local.set $0 1151 | local.get $1 1152 | local.get $2 1153 | i32.sub 1154 | local.set $1 1155 | loop $continue|0 1156 | local.get $1 1157 | i32.const 32 1158 | i32.ge_u 1159 | if 1160 | local.get $0 1161 | i64.const 0 1162 | i64.store 1163 | local.get $0 1164 | i32.const 8 1165 | i32.add 1166 | i64.const 0 1167 | i64.store 1168 | local.get $0 1169 | i32.const 16 1170 | i32.add 1171 | i64.const 0 1172 | i64.store 1173 | local.get $0 1174 | i32.const 24 1175 | i32.add 1176 | i64.const 0 1177 | i64.store 1178 | local.get $1 1179 | i32.const 32 1180 | i32.sub 1181 | local.set $1 1182 | local.get $0 1183 | i32.const 32 1184 | i32.add 1185 | local.set $0 1186 | br $continue|0 1187 | end 1188 | end 1189 | end 1190 | ) 1191 | (func $~lib/arraybuffer/ArrayBuffer#constructor (; 22 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 1192 | (local $1 i32) 1193 | local.get $0 1194 | i32.const 1073741808 1195 | i32.gt_u 1196 | if 1197 | i32.const 248 1198 | i32.const 296 1199 | i32.const 54 1200 | i32.const 42 1201 | call $~lib/as-wasi/as-wasi/wasi_abort 1202 | unreachable 1203 | end 1204 | local.get $0 1205 | i32.const 0 1206 | call $~lib/rt/stub/__alloc 1207 | local.tee $1 1208 | local.get $0 1209 | call $~lib/memory/memory.fill 1210 | local.get $1 1211 | ) 1212 | (func $~lib/as-wasi/as-wasi/Descriptor#writeStringLn (; 23 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) 1213 | (local $2 i32) 1214 | (local $3 i32) 1215 | local.get $1 1216 | call $~lib/string/String.UTF8.byteLength 1217 | local.set $2 1218 | local.get $1 1219 | call $~lib/string/String.UTF8.encode 1220 | local.set $3 1221 | i32.const 16 1222 | call $~lib/arraybuffer/ArrayBuffer#constructor 1223 | local.tee $1 1224 | local.get $3 1225 | i32.store 1226 | local.get $1 1227 | i32.const 4 1228 | i32.add 1229 | local.get $2 1230 | i32.store 1231 | i32.const 1 1232 | call $~lib/arraybuffer/ArrayBuffer#constructor 1233 | local.tee $2 1234 | i32.const 10 1235 | i32.store8 1236 | local.get $1 1237 | i32.const 8 1238 | i32.add 1239 | local.get $2 1240 | i32.store 1241 | local.get $1 1242 | i32.const 12 1243 | i32.add 1244 | i32.const 1 1245 | i32.store 1246 | i32.const 4 1247 | call $~lib/arraybuffer/ArrayBuffer#constructor 1248 | local.set $2 1249 | local.get $0 1250 | i32.load 1251 | local.get $1 1252 | i32.const 2 1253 | local.get $2 1254 | call $~lib/bindings/wasi_unstable/fd_write 1255 | drop 1256 | ) 1257 | (func $~lib/as-wasi/as-wasi/Descriptor#writeString (; 24 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) 1258 | (local $3 i32) 1259 | local.get $2 1260 | if 1261 | local.get $0 1262 | local.get $1 1263 | call $~lib/as-wasi/as-wasi/Descriptor#writeStringLn 1264 | return 1265 | end 1266 | local.get $1 1267 | call $~lib/string/String.UTF8.byteLength 1268 | local.set $2 1269 | local.get $1 1270 | call $~lib/string/String.UTF8.encode 1271 | local.set $3 1272 | i32.const 8 1273 | call $~lib/arraybuffer/ArrayBuffer#constructor 1274 | local.tee $1 1275 | local.get $3 1276 | i32.store 1277 | local.get $1 1278 | i32.const 4 1279 | i32.add 1280 | local.get $2 1281 | i32.store 1282 | i32.const 4 1283 | call $~lib/arraybuffer/ArrayBuffer#constructor 1284 | local.set $2 1285 | local.get $0 1286 | i32.load 1287 | local.get $1 1288 | i32.const 1 1289 | local.get $2 1290 | call $~lib/bindings/wasi_unstable/fd_write 1291 | drop 1292 | ) 1293 | (func $~lib/as-wasi/as-wasi/wasi_abort (; 25 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) 1294 | local.get $1 1295 | i32.const 24 1296 | call $~lib/string/String.__concat 1297 | local.get $2 1298 | call $~lib/util/number/utoa32 1299 | call $~lib/string/String.__concat 1300 | i32.const 24 1301 | call $~lib/string/String.__concat 1302 | local.get $3 1303 | call $~lib/util/number/utoa32 1304 | call $~lib/string/String.__concat 1305 | i32.const 112 1306 | call $~lib/string/String.__concat 1307 | local.get $0 1308 | call $~lib/string/String.__concat 1309 | local.set $0 1310 | i32.const 2 1311 | call $~lib/as-wasi/as-wasi/Descriptor#constructor 1312 | local.get $0 1313 | i32.const 1 1314 | call $~lib/as-wasi/as-wasi/Descriptor#writeString 1315 | i32.const 255 1316 | call $~lib/bindings/wasi_unstable/proc_exit 1317 | ) 1318 | (func $~lib/arraybuffer/ArrayBufferView#constructor (; 26 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) 1319 | i32.const 0 1320 | i32.const 1073741808 1321 | local.get $1 1322 | i32.shr_u 1323 | i32.gt_u 1324 | if 1325 | i32.const 248 1326 | i32.const 296 1327 | i32.const 23 1328 | i32.const 56 1329 | call $~lib/as-wasi/as-wasi/wasi_abort 1330 | unreachable 1331 | end 1332 | i32.const 0 1333 | i32.const 0 1334 | call $~lib/rt/stub/__alloc 1335 | local.tee $1 1336 | i32.const 0 1337 | call $~lib/memory/memory.fill 1338 | local.get $0 1339 | i32.eqz 1340 | if 1341 | i32.const 12 1342 | i32.const 2 1343 | call $~lib/rt/stub/__alloc 1344 | local.set $0 1345 | end 1346 | local.get $0 1347 | i32.const 0 1348 | i32.store 1349 | local.get $0 1350 | i32.const 0 1351 | i32.store offset=4 1352 | local.get $0 1353 | i32.const 0 1354 | i32.store offset=8 1355 | local.get $0 1356 | i32.load 1357 | drop 1358 | local.get $0 1359 | local.get $1 1360 | i32.store 1361 | local.get $0 1362 | local.get $1 1363 | i32.store offset=4 1364 | local.get $0 1365 | i32.const 0 1366 | i32.store offset=8 1367 | local.get $0 1368 | ) 1369 | (func $~lib/array/ensureSize (; 27 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) 1370 | (local $3 i32) 1371 | (local $4 i32) 1372 | local.get $1 1373 | local.get $0 1374 | i32.load offset=8 1375 | local.tee $3 1376 | local.get $2 1377 | i32.shr_u 1378 | i32.gt_u 1379 | if 1380 | local.get $1 1381 | i32.const 1073741808 1382 | local.get $2 1383 | i32.shr_u 1384 | i32.gt_u 1385 | if 1386 | i32.const 248 1387 | i32.const 408 1388 | i32.const 14 1389 | i32.const 47 1390 | call $~lib/as-wasi/as-wasi/wasi_abort 1391 | unreachable 1392 | end 1393 | local.get $0 1394 | i32.load 1395 | local.tee $4 1396 | local.get $1 1397 | local.get $2 1398 | i32.shl 1399 | local.tee $2 1400 | call $~lib/rt/stub/__realloc 1401 | local.tee $1 1402 | local.get $3 1403 | i32.add 1404 | local.get $2 1405 | local.get $3 1406 | i32.sub 1407 | call $~lib/memory/memory.fill 1408 | local.get $1 1409 | local.get $4 1410 | i32.ne 1411 | if 1412 | local.get $0 1413 | local.get $1 1414 | i32.store 1415 | local.get $0 1416 | local.get $1 1417 | i32.store offset=4 1418 | end 1419 | local.get $0 1420 | local.get $2 1421 | i32.store offset=8 1422 | end 1423 | ) 1424 | (func $~lib/array/Array#__set (; 28 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) 1425 | (local $2 i32) 1426 | local.get $1 1427 | local.get $0 1428 | i32.load offset=12 1429 | i32.ge_u 1430 | if 1431 | local.get $1 1432 | i32.const 0 1433 | i32.lt_s 1434 | if 1435 | i32.const 352 1436 | i32.const 408 1437 | i32.const 109 1438 | i32.const 21 1439 | call $~lib/as-wasi/as-wasi/wasi_abort 1440 | unreachable 1441 | end 1442 | local.get $0 1443 | local.get $1 1444 | i32.const 1 1445 | i32.add 1446 | local.tee $2 1447 | i32.const 2 1448 | call $~lib/array/ensureSize 1449 | local.get $0 1450 | local.get $2 1451 | i32.store offset=12 1452 | end 1453 | local.get $0 1454 | i32.load offset=4 1455 | local.get $1 1456 | i32.const 2 1457 | i32.shl 1458 | i32.add 1459 | i32.const 0 1460 | i32.store 1461 | ) 1462 | (func $~lib/map/Map<~lib/string/String,bool>#clear (; 29 ;) (type $FUNCSIG$vi) (param $0 i32) 1463 | (local $1 i32) 1464 | i32.const 16 1465 | call $~lib/arraybuffer/ArrayBuffer#constructor 1466 | local.set $1 1467 | local.get $0 1468 | i32.load 1469 | drop 1470 | local.get $0 1471 | local.get $1 1472 | i32.store 1473 | local.get $0 1474 | i32.const 3 1475 | i32.store offset=4 1476 | i32.const 48 1477 | call $~lib/arraybuffer/ArrayBuffer#constructor 1478 | local.set $1 1479 | local.get $0 1480 | i32.load offset=8 1481 | drop 1482 | local.get $0 1483 | local.get $1 1484 | i32.store offset=8 1485 | local.get $0 1486 | i32.const 4 1487 | i32.store offset=12 1488 | local.get $0 1489 | i32.const 0 1490 | i32.store offset=16 1491 | local.get $0 1492 | i32.const 0 1493 | i32.store offset=20 1494 | ) 1495 | (func $~lib/map/Map<~lib/string/String,bool>#constructor (; 30 ;) (type $FUNCSIG$i) (result i32) 1496 | (local $0 i32) 1497 | i32.const 24 1498 | i32.const 5 1499 | call $~lib/rt/stub/__alloc 1500 | local.tee $0 1501 | i32.const 0 1502 | i32.store 1503 | local.get $0 1504 | i32.const 0 1505 | i32.store offset=4 1506 | local.get $0 1507 | i32.const 0 1508 | i32.store offset=8 1509 | local.get $0 1510 | i32.const 0 1511 | i32.store offset=12 1512 | local.get $0 1513 | i32.const 0 1514 | i32.store offset=16 1515 | local.get $0 1516 | i32.const 0 1517 | i32.store offset=20 1518 | local.get $0 1519 | call $~lib/map/Map<~lib/string/String,bool>#clear 1520 | local.get $0 1521 | ) 1522 | (func $~lib/util/hash/hashStr (; 31 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 1523 | (local $1 i32) 1524 | (local $2 i32) 1525 | (local $3 i32) 1526 | i32.const -2128831035 1527 | local.set $1 1528 | local.get $0 1529 | if 1530 | block $break|0 1531 | local.get $0 1532 | call $~lib/string/String#get:length 1533 | i32.const 1 1534 | i32.shl 1535 | local.set $3 1536 | loop $loop|0 1537 | local.get $2 1538 | local.get $3 1539 | i32.ge_u 1540 | br_if $break|0 1541 | local.get $0 1542 | local.get $2 1543 | i32.add 1544 | i32.load8_u 1545 | local.get $1 1546 | i32.xor 1547 | i32.const 16777619 1548 | i32.mul 1549 | local.set $1 1550 | local.get $2 1551 | i32.const 1 1552 | i32.add 1553 | local.set $2 1554 | br $loop|0 1555 | end 1556 | unreachable 1557 | end 1558 | end 1559 | local.get $1 1560 | ) 1561 | (func $~lib/util/string/compareImpl (; 32 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) 1562 | (local $3 i32) 1563 | (local $4 i32) 1564 | local.get $0 1565 | i32.const 7 1566 | i32.and 1567 | local.get $1 1568 | i32.const 7 1569 | i32.and 1570 | i32.or 1571 | i32.eqz 1572 | i32.const 0 1573 | local.get $2 1574 | i32.const 4 1575 | i32.ge_u 1576 | select 1577 | if 1578 | loop $continue|0 1579 | local.get $0 1580 | i64.load 1581 | local.get $1 1582 | i64.load 1583 | i64.eq 1584 | if 1585 | local.get $0 1586 | i32.const 8 1587 | i32.add 1588 | local.set $0 1589 | local.get $1 1590 | i32.const 8 1591 | i32.add 1592 | local.set $1 1593 | local.get $2 1594 | i32.const 4 1595 | i32.sub 1596 | local.tee $2 1597 | i32.const 4 1598 | i32.ge_u 1599 | br_if $continue|0 1600 | end 1601 | end 1602 | end 1603 | loop $continue|1 1604 | block $break|1 1605 | local.get $2 1606 | local.tee $3 1607 | i32.const 1 1608 | i32.sub 1609 | local.set $2 1610 | local.get $3 1611 | i32.eqz 1612 | br_if $break|1 1613 | local.get $0 1614 | i32.load16_u 1615 | local.tee $3 1616 | local.get $1 1617 | i32.load16_u 1618 | local.tee $4 1619 | i32.ne 1620 | if 1621 | local.get $3 1622 | local.get $4 1623 | i32.sub 1624 | return 1625 | else 1626 | local.get $0 1627 | i32.const 2 1628 | i32.add 1629 | local.set $0 1630 | local.get $1 1631 | i32.const 2 1632 | i32.add 1633 | local.set $1 1634 | br $continue|1 1635 | end 1636 | unreachable 1637 | end 1638 | end 1639 | i32.const 0 1640 | ) 1641 | (func $~lib/string/String.__eq (; 33 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) 1642 | (local $2 i32) 1643 | local.get $0 1644 | local.get $1 1645 | i32.eq 1646 | if 1647 | i32.const 1 1648 | return 1649 | end 1650 | block $folding-inner0 1651 | local.get $1 1652 | i32.eqz 1653 | i32.const 1 1654 | local.get $0 1655 | select 1656 | br_if $folding-inner0 1657 | local.get $0 1658 | call $~lib/string/String#get:length 1659 | local.tee $2 1660 | local.get $1 1661 | call $~lib/string/String#get:length 1662 | i32.ne 1663 | br_if $folding-inner0 1664 | local.get $0 1665 | local.get $1 1666 | local.get $2 1667 | call $~lib/util/string/compareImpl 1668 | i32.eqz 1669 | return 1670 | end 1671 | i32.const 0 1672 | ) 1673 | (func $~lib/map/Map<~lib/string/String,bool>#find (; 34 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) 1674 | local.get $0 1675 | i32.load 1676 | local.get $0 1677 | i32.load offset=4 1678 | local.get $2 1679 | i32.and 1680 | i32.const 2 1681 | i32.shl 1682 | i32.add 1683 | i32.load 1684 | local.set $0 1685 | loop $continue|0 1686 | local.get $0 1687 | if 1688 | local.get $0 1689 | i32.load offset=8 1690 | i32.const 1 1691 | i32.and 1692 | if (result i32) 1693 | i32.const 0 1694 | else 1695 | local.get $0 1696 | i32.load 1697 | local.get $1 1698 | call $~lib/string/String.__eq 1699 | end 1700 | if 1701 | local.get $0 1702 | return 1703 | else 1704 | local.get $0 1705 | i32.load offset=8 1706 | i32.const -2 1707 | i32.and 1708 | local.set $0 1709 | br $continue|0 1710 | end 1711 | unreachable 1712 | end 1713 | end 1714 | i32.const 0 1715 | ) 1716 | (func $~lib/map/Map<~lib/string/String,bool>#rehash (; 35 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) 1717 | (local $2 i32) 1718 | (local $3 i32) 1719 | (local $4 i32) 1720 | (local $5 i32) 1721 | (local $6 i32) 1722 | (local $7 i32) 1723 | (local $8 i32) 1724 | local.get $1 1725 | i32.const 1 1726 | i32.add 1727 | local.tee $2 1728 | i32.const 2 1729 | i32.shl 1730 | call $~lib/arraybuffer/ArrayBuffer#constructor 1731 | local.set $4 1732 | local.get $2 1733 | i32.const 3 1734 | i32.shl 1735 | i32.const 3 1736 | i32.div_s 1737 | local.tee $6 1738 | i32.const 12 1739 | i32.mul 1740 | call $~lib/arraybuffer/ArrayBuffer#constructor 1741 | local.set $5 1742 | local.get $0 1743 | i32.load offset=8 1744 | local.tee $3 1745 | local.get $0 1746 | i32.load offset=16 1747 | i32.const 12 1748 | i32.mul 1749 | i32.add 1750 | local.set $7 1751 | local.get $5 1752 | local.set $2 1753 | loop $continue|0 1754 | local.get $3 1755 | local.get $7 1756 | i32.ne 1757 | if 1758 | local.get $3 1759 | i32.load offset=8 1760 | i32.const 1 1761 | i32.and 1762 | i32.eqz 1763 | if 1764 | local.get $2 1765 | local.get $3 1766 | i32.load 1767 | i32.store 1768 | local.get $2 1769 | local.get $3 1770 | i32.load8_u offset=4 1771 | i32.store8 offset=4 1772 | local.get $2 1773 | local.get $3 1774 | i32.load 1775 | call $~lib/util/hash/hashStr 1776 | local.get $1 1777 | i32.and 1778 | i32.const 2 1779 | i32.shl 1780 | local.get $4 1781 | i32.add 1782 | local.tee $8 1783 | i32.load 1784 | i32.store offset=8 1785 | local.get $8 1786 | local.get $2 1787 | i32.store 1788 | local.get $2 1789 | i32.const 12 1790 | i32.add 1791 | local.set $2 1792 | end 1793 | local.get $3 1794 | i32.const 12 1795 | i32.add 1796 | local.set $3 1797 | br $continue|0 1798 | end 1799 | end 1800 | local.get $0 1801 | i32.load 1802 | drop 1803 | local.get $0 1804 | local.get $4 1805 | i32.store 1806 | local.get $0 1807 | local.get $1 1808 | i32.store offset=4 1809 | local.get $0 1810 | i32.load offset=8 1811 | drop 1812 | local.get $0 1813 | local.get $5 1814 | i32.store offset=8 1815 | local.get $0 1816 | local.get $6 1817 | i32.store offset=12 1818 | local.get $0 1819 | local.get $0 1820 | i32.load offset=20 1821 | i32.store offset=16 1822 | ) 1823 | (func $~lib/map/Map<~lib/string/String,bool>#set (; 36 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) 1824 | (local $2 i32) 1825 | (local $3 i32) 1826 | (local $4 i32) 1827 | local.get $0 1828 | local.get $1 1829 | local.get $1 1830 | call $~lib/util/hash/hashStr 1831 | local.tee $3 1832 | call $~lib/map/Map<~lib/string/String,bool>#find 1833 | local.tee $2 1834 | if 1835 | local.get $2 1836 | i32.const 0 1837 | i32.store8 offset=4 1838 | else 1839 | local.get $0 1840 | i32.load offset=16 1841 | local.get $0 1842 | i32.load offset=12 1843 | i32.eq 1844 | if 1845 | local.get $0 1846 | local.get $0 1847 | i32.load offset=20 1848 | local.get $0 1849 | i32.load offset=12 1850 | i32.const 3 1851 | i32.mul 1852 | i32.const 4 1853 | i32.div_s 1854 | i32.lt_s 1855 | if (result i32) 1856 | local.get $0 1857 | i32.load offset=4 1858 | else 1859 | local.get $0 1860 | i32.load offset=4 1861 | i32.const 1 1862 | i32.shl 1863 | i32.const 1 1864 | i32.or 1865 | end 1866 | call $~lib/map/Map<~lib/string/String,bool>#rehash 1867 | end 1868 | local.get $0 1869 | i32.load offset=8 1870 | local.set $2 1871 | local.get $0 1872 | local.get $0 1873 | i32.load offset=16 1874 | local.tee $4 1875 | i32.const 1 1876 | i32.add 1877 | i32.store offset=16 1878 | local.get $4 1879 | i32.const 12 1880 | i32.mul 1881 | local.get $2 1882 | i32.add 1883 | local.tee $2 1884 | local.get $1 1885 | i32.store 1886 | local.get $2 1887 | i32.const 0 1888 | i32.store8 offset=4 1889 | local.get $0 1890 | local.get $0 1891 | i32.load offset=20 1892 | i32.const 1 1893 | i32.add 1894 | i32.store offset=20 1895 | local.get $2 1896 | local.get $0 1897 | i32.load 1898 | local.get $0 1899 | i32.load offset=4 1900 | local.get $3 1901 | i32.and 1902 | i32.const 2 1903 | i32.shl 1904 | i32.add 1905 | local.tee $0 1906 | i32.load 1907 | i32.store offset=8 1908 | local.get $0 1909 | local.get $2 1910 | i32.store 1911 | end 1912 | ) 1913 | (func $~lib/map/Map#constructor (; 37 ;) (type $FUNCSIG$i) (result i32) 1914 | (local $0 i32) 1915 | i32.const 24 1916 | i32.const 6 1917 | call $~lib/rt/stub/__alloc 1918 | local.tee $0 1919 | i32.const 0 1920 | i32.store 1921 | local.get $0 1922 | i32.const 0 1923 | i32.store offset=4 1924 | local.get $0 1925 | i32.const 0 1926 | i32.store offset=8 1927 | local.get $0 1928 | i32.const 0 1929 | i32.store offset=12 1930 | local.get $0 1931 | i32.const 0 1932 | i32.store offset=16 1933 | local.get $0 1934 | i32.const 0 1935 | i32.store offset=20 1936 | local.get $0 1937 | call $~lib/map/Map<~lib/string/String,bool>#clear 1938 | local.get $0 1939 | ) 1940 | (func $~lib/util/hash/hash32 (; 38 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 1941 | local.get $0 1942 | i32.const 255 1943 | i32.and 1944 | i32.const -2128831035 1945 | i32.xor 1946 | i32.const 16777619 1947 | i32.mul 1948 | local.get $0 1949 | i32.const 8 1950 | i32.shr_u 1951 | i32.const 255 1952 | i32.and 1953 | i32.xor 1954 | i32.const 16777619 1955 | i32.mul 1956 | local.get $0 1957 | i32.const 16 1958 | i32.shr_u 1959 | i32.const 255 1960 | i32.and 1961 | i32.xor 1962 | i32.const 16777619 1963 | i32.mul 1964 | local.get $0 1965 | i32.const 24 1966 | i32.shr_u 1967 | i32.xor 1968 | i32.const 16777619 1969 | i32.mul 1970 | ) 1971 | (func $~lib/map/Map#find (; 39 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) 1972 | local.get $0 1973 | i32.load 1974 | local.get $0 1975 | i32.load offset=4 1976 | local.get $2 1977 | i32.and 1978 | i32.const 2 1979 | i32.shl 1980 | i32.add 1981 | i32.load 1982 | local.set $0 1983 | loop $continue|0 1984 | local.get $0 1985 | if 1986 | local.get $0 1987 | i32.load offset=8 1988 | i32.const 1 1989 | i32.and 1990 | if (result i32) 1991 | i32.const 0 1992 | else 1993 | local.get $0 1994 | i32.load 1995 | local.get $1 1996 | i32.eq 1997 | end 1998 | if 1999 | local.get $0 2000 | return 2001 | else 2002 | local.get $0 2003 | i32.load offset=8 2004 | i32.const -2 2005 | i32.and 2006 | local.set $0 2007 | br $continue|0 2008 | end 2009 | unreachable 2010 | end 2011 | end 2012 | i32.const 0 2013 | ) 2014 | (func $~lib/map/Map#rehash (; 40 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) 2015 | (local $2 i32) 2016 | (local $3 i32) 2017 | (local $4 i32) 2018 | (local $5 i32) 2019 | (local $6 i32) 2020 | (local $7 i32) 2021 | (local $8 i32) 2022 | local.get $1 2023 | i32.const 1 2024 | i32.add 2025 | local.tee $2 2026 | i32.const 2 2027 | i32.shl 2028 | call $~lib/arraybuffer/ArrayBuffer#constructor 2029 | local.set $4 2030 | local.get $2 2031 | i32.const 3 2032 | i32.shl 2033 | i32.const 3 2034 | i32.div_s 2035 | local.tee $6 2036 | i32.const 12 2037 | i32.mul 2038 | call $~lib/arraybuffer/ArrayBuffer#constructor 2039 | local.set $5 2040 | local.get $0 2041 | i32.load offset=8 2042 | local.tee $3 2043 | local.get $0 2044 | i32.load offset=16 2045 | i32.const 12 2046 | i32.mul 2047 | i32.add 2048 | local.set $7 2049 | local.get $5 2050 | local.set $2 2051 | loop $continue|0 2052 | local.get $3 2053 | local.get $7 2054 | i32.ne 2055 | if 2056 | local.get $3 2057 | i32.load offset=8 2058 | i32.const 1 2059 | i32.and 2060 | i32.eqz 2061 | if 2062 | local.get $2 2063 | local.get $3 2064 | i32.load 2065 | i32.store 2066 | local.get $2 2067 | local.get $3 2068 | i32.load offset=4 2069 | i32.store offset=4 2070 | local.get $2 2071 | local.get $3 2072 | i32.load 2073 | call $~lib/util/hash/hash32 2074 | local.get $1 2075 | i32.and 2076 | i32.const 2 2077 | i32.shl 2078 | local.get $4 2079 | i32.add 2080 | local.tee $8 2081 | i32.load 2082 | i32.store offset=8 2083 | local.get $8 2084 | local.get $2 2085 | i32.store 2086 | local.get $2 2087 | i32.const 12 2088 | i32.add 2089 | local.set $2 2090 | end 2091 | local.get $3 2092 | i32.const 12 2093 | i32.add 2094 | local.set $3 2095 | br $continue|0 2096 | end 2097 | end 2098 | local.get $0 2099 | i32.load 2100 | drop 2101 | local.get $0 2102 | local.get $4 2103 | i32.store 2104 | local.get $0 2105 | local.get $1 2106 | i32.store offset=4 2107 | local.get $0 2108 | i32.load offset=8 2109 | drop 2110 | local.get $0 2111 | local.get $5 2112 | i32.store offset=8 2113 | local.get $0 2114 | local.get $6 2115 | i32.store offset=12 2116 | local.get $0 2117 | local.get $0 2118 | i32.load offset=20 2119 | i32.store offset=16 2120 | ) 2121 | (func $~lib/map/Map#set (; 41 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) 2122 | (local $3 i32) 2123 | (local $4 i32) 2124 | (local $5 i32) 2125 | local.get $0 2126 | local.get $1 2127 | local.get $1 2128 | call $~lib/util/hash/hash32 2129 | local.tee $4 2130 | call $~lib/map/Map#find 2131 | local.tee $3 2132 | if 2133 | local.get $3 2134 | i32.load offset=4 2135 | local.get $2 2136 | i32.ne 2137 | if 2138 | local.get $3 2139 | local.get $2 2140 | i32.store offset=4 2141 | end 2142 | else 2143 | local.get $0 2144 | i32.load offset=16 2145 | local.get $0 2146 | i32.load offset=12 2147 | i32.eq 2148 | if 2149 | local.get $0 2150 | local.get $0 2151 | i32.load offset=20 2152 | local.get $0 2153 | i32.load offset=12 2154 | i32.const 3 2155 | i32.mul 2156 | i32.const 4 2157 | i32.div_s 2158 | i32.lt_s 2159 | if (result i32) 2160 | local.get $0 2161 | i32.load offset=4 2162 | else 2163 | local.get $0 2164 | i32.load offset=4 2165 | i32.const 1 2166 | i32.shl 2167 | i32.const 1 2168 | i32.or 2169 | end 2170 | call $~lib/map/Map#rehash 2171 | end 2172 | local.get $0 2173 | i32.load offset=8 2174 | local.set $3 2175 | local.get $0 2176 | local.get $0 2177 | i32.load offset=16 2178 | local.tee $5 2179 | i32.const 1 2180 | i32.add 2181 | i32.store offset=16 2182 | local.get $5 2183 | i32.const 12 2184 | i32.mul 2185 | local.get $3 2186 | i32.add 2187 | local.tee $3 2188 | local.get $1 2189 | i32.store 2190 | local.get $3 2191 | local.get $2 2192 | i32.store offset=4 2193 | local.get $0 2194 | local.get $0 2195 | i32.load offset=20 2196 | i32.const 1 2197 | i32.add 2198 | i32.store offset=20 2199 | local.get $3 2200 | local.get $0 2201 | i32.load 2202 | local.get $0 2203 | i32.load offset=4 2204 | local.get $4 2205 | i32.and 2206 | i32.const 2 2207 | i32.shl 2208 | i32.add 2209 | local.tee $0 2210 | i32.load 2211 | i32.store offset=8 2212 | local.get $0 2213 | local.get $3 2214 | i32.store 2215 | end 2216 | ) 2217 | (func $lib/input-map/resetKeyPressState (; 42 ;) (type $FUNCSIG$v) 2218 | global.get $lib/input-map/keyPressStateMap 2219 | i32.const 544 2220 | call $~lib/map/Map<~lib/string/String,bool>#set 2221 | global.get $lib/input-map/keyPressStateMap 2222 | i32.const 568 2223 | call $~lib/map/Map<~lib/string/String,bool>#set 2224 | global.get $lib/input-map/keyPressStateMap 2225 | i32.const 592 2226 | call $~lib/map/Map<~lib/string/String,bool>#set 2227 | global.get $lib/input-map/keyPressStateMap 2228 | i32.const 616 2229 | call $~lib/map/Map<~lib/string/String,bool>#set 2230 | global.get $lib/input-map/keyPressStateMap 2231 | i32.const 640 2232 | call $~lib/map/Map<~lib/string/String,bool>#set 2233 | global.get $lib/input-map/keyPressStateMap 2234 | i32.const 664 2235 | call $~lib/map/Map<~lib/string/String,bool>#set 2236 | global.get $lib/input-map/keyPressStateMap 2237 | i32.const 688 2238 | call $~lib/map/Map<~lib/string/String,bool>#set 2239 | global.get $lib/input-map/keyPressStateMap 2240 | i32.const 712 2241 | call $~lib/map/Map<~lib/string/String,bool>#set 2242 | global.get $lib/input-map/keyPressStateMap 2243 | i32.const 736 2244 | call $~lib/map/Map<~lib/string/String,bool>#set 2245 | global.get $lib/input-map/keyPressStateMap 2246 | i32.const 760 2247 | call $~lib/map/Map<~lib/string/String,bool>#set 2248 | global.get $lib/input-map/keyPressStateMap 2249 | i32.const 784 2250 | call $~lib/map/Map<~lib/string/String,bool>#set 2251 | global.get $lib/input-map/keyPressStateMap 2252 | i32.const 808 2253 | call $~lib/map/Map<~lib/string/String,bool>#set 2254 | global.get $lib/input-map/keyPressStateMap 2255 | i32.const 832 2256 | call $~lib/map/Map<~lib/string/String,bool>#set 2257 | global.get $lib/input-map/keyPressStateMap 2258 | i32.const 856 2259 | call $~lib/map/Map<~lib/string/String,bool>#set 2260 | global.get $lib/input-map/keyPressStateMap 2261 | i32.const 880 2262 | call $~lib/map/Map<~lib/string/String,bool>#set 2263 | global.get $lib/input-map/keyPressStateMap 2264 | i32.const 904 2265 | call $~lib/map/Map<~lib/string/String,bool>#set 2266 | global.get $lib/input-map/keyPressStateMap 2267 | i32.const 928 2268 | call $~lib/map/Map<~lib/string/String,bool>#set 2269 | global.get $lib/input-map/keyPressStateMap 2270 | i32.const 952 2271 | call $~lib/map/Map<~lib/string/String,bool>#set 2272 | global.get $lib/input-map/keyPressStateMap 2273 | i32.const 976 2274 | call $~lib/map/Map<~lib/string/String,bool>#set 2275 | global.get $lib/input-map/keyPressStateMap 2276 | i32.const 1000 2277 | call $~lib/map/Map<~lib/string/String,bool>#set 2278 | global.get $lib/input-map/keyPressStateMap 2279 | i32.const 1024 2280 | call $~lib/map/Map<~lib/string/String,bool>#set 2281 | global.get $lib/input-map/keyPressStateMap 2282 | i32.const 1048 2283 | call $~lib/map/Map<~lib/string/String,bool>#set 2284 | global.get $lib/input-map/keyPressStateMap 2285 | i32.const 1072 2286 | call $~lib/map/Map<~lib/string/String,bool>#set 2287 | global.get $lib/input-map/keyPressStateMap 2288 | i32.const 1096 2289 | call $~lib/map/Map<~lib/string/String,bool>#set 2290 | global.get $lib/input-map/keyPressStateMap 2291 | i32.const 1120 2292 | call $~lib/map/Map<~lib/string/String,bool>#set 2293 | global.get $lib/input-map/keyPressStateMap 2294 | i32.const 1144 2295 | call $~lib/map/Map<~lib/string/String,bool>#set 2296 | global.get $lib/input-map/keyPressStateMap 2297 | i32.const 1168 2298 | call $~lib/map/Map<~lib/string/String,bool>#set 2299 | global.get $lib/input-map/keyPressStateMap 2300 | i32.const 1192 2301 | call $~lib/map/Map<~lib/string/String,bool>#set 2302 | global.get $lib/input-map/keyPressStateMap 2303 | i32.const 1216 2304 | call $~lib/map/Map<~lib/string/String,bool>#set 2305 | global.get $lib/input-map/keyPressStateMap 2306 | i32.const 1240 2307 | call $~lib/map/Map<~lib/string/String,bool>#set 2308 | global.get $lib/input-map/keyPressStateMap 2309 | i32.const 1264 2310 | call $~lib/map/Map<~lib/string/String,bool>#set 2311 | global.get $lib/input-map/keyPressStateMap 2312 | i32.const 1288 2313 | call $~lib/map/Map<~lib/string/String,bool>#set 2314 | global.get $lib/input-map/keyPressStateMap 2315 | i32.const 1312 2316 | call $~lib/map/Map<~lib/string/String,bool>#set 2317 | global.get $lib/input-map/keyPressStateMap 2318 | i32.const 1336 2319 | call $~lib/map/Map<~lib/string/String,bool>#set 2320 | global.get $lib/input-map/keyPressStateMap 2321 | i32.const 1360 2322 | call $~lib/map/Map<~lib/string/String,bool>#set 2323 | global.get $lib/input-map/keyPressStateMap 2324 | i32.const 1384 2325 | call $~lib/map/Map<~lib/string/String,bool>#set 2326 | global.get $lib/input-map/keyPressStateMap 2327 | i32.const 1408 2328 | call $~lib/map/Map<~lib/string/String,bool>#set 2329 | global.get $lib/input-map/keyPressStateMap 2330 | i32.const 1440 2331 | call $~lib/map/Map<~lib/string/String,bool>#set 2332 | global.get $lib/input-map/keyPressStateMap 2333 | i32.const 1472 2334 | call $~lib/map/Map<~lib/string/String,bool>#set 2335 | global.get $lib/input-map/keyPressStateMap 2336 | i32.const 1504 2337 | call $~lib/map/Map<~lib/string/String,bool>#set 2338 | global.get $lib/input-map/keyPressStateMap 2339 | i32.const 1536 2340 | call $~lib/map/Map<~lib/string/String,bool>#set 2341 | global.get $lib/input-map/keyPressStateMap 2342 | i32.const 1568 2343 | call $~lib/map/Map<~lib/string/String,bool>#set 2344 | global.get $lib/input-map/keyPressStateMap 2345 | i32.const 1600 2346 | call $~lib/map/Map<~lib/string/String,bool>#set 2347 | global.get $lib/input-map/keyPressStateMap 2348 | i32.const 1632 2349 | call $~lib/map/Map<~lib/string/String,bool>#set 2350 | global.get $lib/input-map/keyPressStateMap 2351 | i32.const 1664 2352 | call $~lib/map/Map<~lib/string/String,bool>#set 2353 | global.get $lib/input-map/keyPressStateMap 2354 | i32.const 1696 2355 | call $~lib/map/Map<~lib/string/String,bool>#set 2356 | global.get $lib/input-map/keyPressStateMap 2357 | i32.const 1728 2358 | call $~lib/map/Map<~lib/string/String,bool>#set 2359 | global.get $lib/input-map/keyPressStateMap 2360 | i32.const 1760 2361 | call $~lib/map/Map<~lib/string/String,bool>#set 2362 | global.get $lib/input-map/keyPressStateMap 2363 | i32.const 1792 2364 | call $~lib/map/Map<~lib/string/String,bool>#set 2365 | global.get $lib/input-map/keyPressStateMap 2366 | i32.const 1824 2367 | call $~lib/map/Map<~lib/string/String,bool>#set 2368 | global.get $lib/input-map/keyPressStateMap 2369 | i32.const 1856 2370 | call $~lib/map/Map<~lib/string/String,bool>#set 2371 | global.get $lib/input-map/keyPressStateMap 2372 | i32.const 1888 2373 | call $~lib/map/Map<~lib/string/String,bool>#set 2374 | global.get $lib/input-map/keyPressStateMap 2375 | i32.const 1920 2376 | call $~lib/map/Map<~lib/string/String,bool>#set 2377 | global.get $lib/input-map/keyPressStateMap 2378 | i32.const 1968 2379 | call $~lib/map/Map<~lib/string/String,bool>#set 2380 | global.get $lib/input-map/keyPressStateMap 2381 | i32.const 2008 2382 | call $~lib/map/Map<~lib/string/String,bool>#set 2383 | global.get $lib/input-map/keyPressStateMap 2384 | i32.const 2048 2385 | call $~lib/map/Map<~lib/string/String,bool>#set 2386 | global.get $lib/input-map/keyPressStateMap 2387 | i32.const 2080 2388 | call $~lib/map/Map<~lib/string/String,bool>#set 2389 | global.get $lib/input-map/keyPressStateMap 2390 | i32.const 2112 2391 | call $~lib/map/Map<~lib/string/String,bool>#set 2392 | global.get $lib/input-map/keyPressStateMap 2393 | i32.const 2160 2394 | call $~lib/map/Map<~lib/string/String,bool>#set 2395 | global.get $lib/input-map/keyPressStateMap 2396 | i32.const 2192 2397 | call $~lib/map/Map<~lib/string/String,bool>#set 2398 | global.get $lib/input-map/keyPressStateMap 2399 | i32.const 2232 2400 | call $~lib/map/Map<~lib/string/String,bool>#set 2401 | global.get $lib/input-map/keyPressStateMap 2402 | i32.const 2280 2403 | call $~lib/map/Map<~lib/string/String,bool>#set 2404 | global.get $lib/input-map/keyPressStateMap 2405 | i32.const 2320 2406 | call $~lib/map/Map<~lib/string/String,bool>#set 2407 | global.get $lib/input-map/keyPressStateMap 2408 | i32.const 2352 2409 | call $~lib/map/Map<~lib/string/String,bool>#set 2410 | global.get $lib/input-map/keyPressStateMap 2411 | i32.const 2392 2412 | call $~lib/map/Map<~lib/string/String,bool>#set 2413 | global.get $lib/input-map/keyPressStateMap 2414 | i32.const 2432 2415 | call $~lib/map/Map<~lib/string/String,bool>#set 2416 | global.get $lib/input-map/keyPressStateMap 2417 | i32.const 2464 2418 | call $~lib/map/Map<~lib/string/String,bool>#set 2419 | global.get $lib/input-map/keyPressStateMap 2420 | i32.const 2496 2421 | call $~lib/map/Map<~lib/string/String,bool>#set 2422 | global.get $lib/input-map/keyPressStateMap 2423 | i32.const 2536 2424 | call $~lib/map/Map<~lib/string/String,bool>#set 2425 | global.get $lib/input-map/keyPressStateMap 2426 | i32.const 2568 2427 | call $~lib/map/Map<~lib/string/String,bool>#set 2428 | global.get $lib/input-map/keyPressStateMap 2429 | i32.const 3784 2430 | call $~lib/map/Map<~lib/string/String,bool>#set 2431 | global.get $lib/input-map/keyPressStateMap 2432 | i32.const 2608 2433 | call $~lib/map/Map<~lib/string/String,bool>#set 2434 | global.get $lib/input-map/keyPressStateMap 2435 | i32.const 2648 2436 | call $~lib/map/Map<~lib/string/String,bool>#set 2437 | global.get $lib/input-map/keyPressStateMap 2438 | i32.const 2688 2439 | call $~lib/map/Map<~lib/string/String,bool>#set 2440 | global.get $lib/input-map/keyPressStateMap 2441 | i32.const 2720 2442 | call $~lib/map/Map<~lib/string/String,bool>#set 2443 | global.get $lib/input-map/keyPressStateMap 2444 | i32.const 2752 2445 | call $~lib/map/Map<~lib/string/String,bool>#set 2446 | global.get $lib/input-map/keyPressStateMap 2447 | i32.const 2784 2448 | call $~lib/map/Map<~lib/string/String,bool>#set 2449 | global.get $lib/input-map/keyPressStateMap 2450 | i32.const 2824 2451 | call $~lib/map/Map<~lib/string/String,bool>#set 2452 | global.get $lib/input-map/keyPressStateMap 2453 | i32.const 2864 2454 | call $~lib/map/Map<~lib/string/String,bool>#set 2455 | global.get $lib/input-map/keyPressStateMap 2456 | i32.const 2912 2457 | call $~lib/map/Map<~lib/string/String,bool>#set 2458 | global.get $lib/input-map/keyPressStateMap 2459 | i32.const 2944 2460 | call $~lib/map/Map<~lib/string/String,bool>#set 2461 | global.get $lib/input-map/keyPressStateMap 2462 | i32.const 2984 2463 | call $~lib/map/Map<~lib/string/String,bool>#set 2464 | global.get $lib/input-map/keyPressStateMap 2465 | i32.const 3024 2466 | call $~lib/map/Map<~lib/string/String,bool>#set 2467 | global.get $lib/input-map/keyPressStateMap 2468 | i32.const 3064 2469 | call $~lib/map/Map<~lib/string/String,bool>#set 2470 | global.get $lib/input-map/keyPressStateMap 2471 | i32.const 3104 2472 | call $~lib/map/Map<~lib/string/String,bool>#set 2473 | global.get $lib/input-map/keyPressStateMap 2474 | i32.const 3144 2475 | call $~lib/map/Map<~lib/string/String,bool>#set 2476 | global.get $lib/input-map/keyPressStateMap 2477 | i32.const 3184 2478 | call $~lib/map/Map<~lib/string/String,bool>#set 2479 | global.get $lib/input-map/keyPressStateMap 2480 | i32.const 3224 2481 | call $~lib/map/Map<~lib/string/String,bool>#set 2482 | global.get $lib/input-map/keyPressStateMap 2483 | i32.const 3264 2484 | call $~lib/map/Map<~lib/string/String,bool>#set 2485 | global.get $lib/input-map/keyPressStateMap 2486 | i32.const 3304 2487 | call $~lib/map/Map<~lib/string/String,bool>#set 2488 | global.get $lib/input-map/keyPressStateMap 2489 | i32.const 3344 2490 | call $~lib/map/Map<~lib/string/String,bool>#set 2491 | global.get $lib/input-map/keyPressStateMap 2492 | i32.const 3384 2493 | call $~lib/map/Map<~lib/string/String,bool>#set 2494 | global.get $lib/input-map/keyPressStateMap 2495 | i32.const 3424 2496 | call $~lib/map/Map<~lib/string/String,bool>#set 2497 | global.get $lib/input-map/keyPressStateMap 2498 | i32.const 3464 2499 | call $~lib/map/Map<~lib/string/String,bool>#set 2500 | global.get $lib/input-map/keyPressStateMap 2501 | i32.const 3512 2502 | call $~lib/map/Map<~lib/string/String,bool>#set 2503 | global.get $lib/input-map/keyPressStateMap 2504 | i32.const 3568 2505 | call $~lib/map/Map<~lib/string/String,bool>#set 2506 | global.get $lib/input-map/keyPressStateMap 2507 | i32.const 3616 2508 | call $~lib/map/Map<~lib/string/String,bool>#set 2509 | global.get $lib/input-map/keyPressStateMap 2510 | i32.const 3816 2511 | call $~lib/map/Map<~lib/string/String,bool>#set 2512 | global.get $lib/input-map/keyPressStateMap 2513 | i32.const 3664 2514 | call $~lib/map/Map<~lib/string/String,bool>#set 2515 | global.get $lib/input-map/keyPressStateMap 2516 | i32.const 3696 2517 | call $~lib/map/Map<~lib/string/String,bool>#set 2518 | global.get $lib/input-map/keyPressStateMap 2519 | i32.const 3736 2520 | call $~lib/map/Map<~lib/string/String,bool>#set 2521 | ) 2522 | (func $start:lib/input-map (; 43 ;) (type $FUNCSIG$v) 2523 | (local $0 i32) 2524 | i32.const 16 2525 | i32.const 3 2526 | call $~lib/rt/stub/__alloc 2527 | i32.const 2 2528 | call $~lib/arraybuffer/ArrayBufferView#constructor 2529 | local.tee $0 2530 | i32.const 0 2531 | i32.store offset=12 2532 | local.get $0 2533 | i32.const 0 2534 | i32.store offset=12 2535 | local.get $0 2536 | global.set $lib/input-map/mousePosition 2537 | global.get $lib/input-map/mousePosition 2538 | i32.const 0 2539 | call $~lib/array/Array#__set 2540 | global.get $lib/input-map/mousePosition 2541 | i32.const 1 2542 | call $~lib/array/Array#__set 2543 | call $~lib/map/Map<~lib/string/String,bool>#constructor 2544 | global.set $lib/input-map/mouseClickMap 2545 | global.get $lib/input-map/mouseClickMap 2546 | i32.const 456 2547 | call $~lib/map/Map<~lib/string/String,bool>#set 2548 | global.get $lib/input-map/mouseClickMap 2549 | i32.const 480 2550 | call $~lib/map/Map<~lib/string/String,bool>#set 2551 | global.get $lib/input-map/mouseClickMap 2552 | i32.const 512 2553 | call $~lib/map/Map<~lib/string/String,bool>#set 2554 | call $~lib/map/Map#constructor 2555 | global.set $lib/input-map/byteToInputKeyMap 2556 | global.get $lib/input-map/byteToInputKeyMap 2557 | i32.const 48 2558 | i32.const 544 2559 | call $~lib/map/Map#set 2560 | global.get $lib/input-map/byteToInputKeyMap 2561 | i32.const 49 2562 | i32.const 568 2563 | call $~lib/map/Map#set 2564 | global.get $lib/input-map/byteToInputKeyMap 2565 | i32.const 50 2566 | i32.const 592 2567 | call $~lib/map/Map#set 2568 | global.get $lib/input-map/byteToInputKeyMap 2569 | i32.const 51 2570 | i32.const 616 2571 | call $~lib/map/Map#set 2572 | global.get $lib/input-map/byteToInputKeyMap 2573 | i32.const 52 2574 | i32.const 640 2575 | call $~lib/map/Map#set 2576 | global.get $lib/input-map/byteToInputKeyMap 2577 | i32.const 53 2578 | i32.const 664 2579 | call $~lib/map/Map#set 2580 | global.get $lib/input-map/byteToInputKeyMap 2581 | i32.const 54 2582 | i32.const 688 2583 | call $~lib/map/Map#set 2584 | global.get $lib/input-map/byteToInputKeyMap 2585 | i32.const 55 2586 | i32.const 712 2587 | call $~lib/map/Map#set 2588 | global.get $lib/input-map/byteToInputKeyMap 2589 | i32.const 56 2590 | i32.const 736 2591 | call $~lib/map/Map#set 2592 | global.get $lib/input-map/byteToInputKeyMap 2593 | i32.const 57 2594 | i32.const 760 2595 | call $~lib/map/Map#set 2596 | global.get $lib/input-map/byteToInputKeyMap 2597 | i32.const 65 2598 | i32.const 784 2599 | call $~lib/map/Map#set 2600 | global.get $lib/input-map/byteToInputKeyMap 2601 | i32.const 66 2602 | i32.const 808 2603 | call $~lib/map/Map#set 2604 | global.get $lib/input-map/byteToInputKeyMap 2605 | i32.const 67 2606 | i32.const 832 2607 | call $~lib/map/Map#set 2608 | global.get $lib/input-map/byteToInputKeyMap 2609 | i32.const 68 2610 | i32.const 856 2611 | call $~lib/map/Map#set 2612 | global.get $lib/input-map/byteToInputKeyMap 2613 | i32.const 69 2614 | i32.const 880 2615 | call $~lib/map/Map#set 2616 | global.get $lib/input-map/byteToInputKeyMap 2617 | i32.const 70 2618 | i32.const 904 2619 | call $~lib/map/Map#set 2620 | global.get $lib/input-map/byteToInputKeyMap 2621 | i32.const 71 2622 | i32.const 928 2623 | call $~lib/map/Map#set 2624 | global.get $lib/input-map/byteToInputKeyMap 2625 | i32.const 72 2626 | i32.const 952 2627 | call $~lib/map/Map#set 2628 | global.get $lib/input-map/byteToInputKeyMap 2629 | i32.const 73 2630 | i32.const 976 2631 | call $~lib/map/Map#set 2632 | global.get $lib/input-map/byteToInputKeyMap 2633 | i32.const 74 2634 | i32.const 1000 2635 | call $~lib/map/Map#set 2636 | global.get $lib/input-map/byteToInputKeyMap 2637 | i32.const 75 2638 | i32.const 1024 2639 | call $~lib/map/Map#set 2640 | global.get $lib/input-map/byteToInputKeyMap 2641 | i32.const 76 2642 | i32.const 1048 2643 | call $~lib/map/Map#set 2644 | global.get $lib/input-map/byteToInputKeyMap 2645 | i32.const 77 2646 | i32.const 1072 2647 | call $~lib/map/Map#set 2648 | global.get $lib/input-map/byteToInputKeyMap 2649 | i32.const 78 2650 | i32.const 1096 2651 | call $~lib/map/Map#set 2652 | global.get $lib/input-map/byteToInputKeyMap 2653 | i32.const 79 2654 | i32.const 1120 2655 | call $~lib/map/Map#set 2656 | global.get $lib/input-map/byteToInputKeyMap 2657 | i32.const 80 2658 | i32.const 1144 2659 | call $~lib/map/Map#set 2660 | global.get $lib/input-map/byteToInputKeyMap 2661 | i32.const 81 2662 | i32.const 1168 2663 | call $~lib/map/Map#set 2664 | global.get $lib/input-map/byteToInputKeyMap 2665 | i32.const 82 2666 | i32.const 1192 2667 | call $~lib/map/Map#set 2668 | global.get $lib/input-map/byteToInputKeyMap 2669 | i32.const 83 2670 | i32.const 1216 2671 | call $~lib/map/Map#set 2672 | global.get $lib/input-map/byteToInputKeyMap 2673 | i32.const 84 2674 | i32.const 1240 2675 | call $~lib/map/Map#set 2676 | global.get $lib/input-map/byteToInputKeyMap 2677 | i32.const 85 2678 | i32.const 1264 2679 | call $~lib/map/Map#set 2680 | global.get $lib/input-map/byteToInputKeyMap 2681 | i32.const 86 2682 | i32.const 1288 2683 | call $~lib/map/Map#set 2684 | global.get $lib/input-map/byteToInputKeyMap 2685 | i32.const 87 2686 | i32.const 1312 2687 | call $~lib/map/Map#set 2688 | global.get $lib/input-map/byteToInputKeyMap 2689 | i32.const 88 2690 | i32.const 1336 2691 | call $~lib/map/Map#set 2692 | global.get $lib/input-map/byteToInputKeyMap 2693 | i32.const 89 2694 | i32.const 1360 2695 | call $~lib/map/Map#set 2696 | global.get $lib/input-map/byteToInputKeyMap 2697 | i32.const 90 2698 | i32.const 1384 2699 | call $~lib/map/Map#set 2700 | global.get $lib/input-map/byteToInputKeyMap 2701 | i32.const 112 2702 | i32.const 1408 2703 | call $~lib/map/Map#set 2704 | global.get $lib/input-map/byteToInputKeyMap 2705 | i32.const 113 2706 | i32.const 1440 2707 | call $~lib/map/Map#set 2708 | global.get $lib/input-map/byteToInputKeyMap 2709 | i32.const 114 2710 | i32.const 1472 2711 | call $~lib/map/Map#set 2712 | global.get $lib/input-map/byteToInputKeyMap 2713 | i32.const 115 2714 | i32.const 1504 2715 | call $~lib/map/Map#set 2716 | global.get $lib/input-map/byteToInputKeyMap 2717 | i32.const 116 2718 | i32.const 1536 2719 | call $~lib/map/Map#set 2720 | global.get $lib/input-map/byteToInputKeyMap 2721 | i32.const 117 2722 | i32.const 1568 2723 | call $~lib/map/Map#set 2724 | global.get $lib/input-map/byteToInputKeyMap 2725 | i32.const 118 2726 | i32.const 1600 2727 | call $~lib/map/Map#set 2728 | global.get $lib/input-map/byteToInputKeyMap 2729 | i32.const 119 2730 | i32.const 1632 2731 | call $~lib/map/Map#set 2732 | global.get $lib/input-map/byteToInputKeyMap 2733 | i32.const 120 2734 | i32.const 1664 2735 | call $~lib/map/Map#set 2736 | global.get $lib/input-map/byteToInputKeyMap 2737 | i32.const 121 2738 | i32.const 1696 2739 | call $~lib/map/Map#set 2740 | global.get $lib/input-map/byteToInputKeyMap 2741 | i32.const 122 2742 | i32.const 1728 2743 | call $~lib/map/Map#set 2744 | global.get $lib/input-map/byteToInputKeyMap 2745 | i32.const 123 2746 | i32.const 1760 2747 | call $~lib/map/Map#set 2748 | global.get $lib/input-map/byteToInputKeyMap 2749 | i32.const 40 2750 | i32.const 1792 2751 | call $~lib/map/Map#set 2752 | global.get $lib/input-map/byteToInputKeyMap 2753 | i32.const 37 2754 | i32.const 1824 2755 | call $~lib/map/Map#set 2756 | global.get $lib/input-map/byteToInputKeyMap 2757 | i32.const 39 2758 | i32.const 1856 2759 | call $~lib/map/Map#set 2760 | global.get $lib/input-map/byteToInputKeyMap 2761 | i32.const 38 2762 | i32.const 1888 2763 | call $~lib/map/Map#set 2764 | global.get $lib/input-map/byteToInputKeyMap 2765 | i32.const 222 2766 | i32.const 1920 2767 | call $~lib/map/Map#set 2768 | global.get $lib/input-map/byteToInputKeyMap 2769 | i32.const 192 2770 | i32.const 1968 2771 | call $~lib/map/Map#set 2772 | global.get $lib/input-map/byteToInputKeyMap 2773 | i32.const 220 2774 | i32.const 2008 2775 | call $~lib/map/Map#set 2776 | global.get $lib/input-map/byteToInputKeyMap 2777 | i32.const 188 2778 | i32.const 2048 2779 | call $~lib/map/Map#set 2780 | global.get $lib/input-map/byteToInputKeyMap 2781 | i32.const 187 2782 | i32.const 2080 2783 | call $~lib/map/Map#set 2784 | global.get $lib/input-map/byteToInputKeyMap 2785 | i32.const 219 2786 | i32.const 2112 2787 | call $~lib/map/Map#set 2788 | global.get $lib/input-map/byteToInputKeyMap 2789 | i32.const 189 2790 | i32.const 2160 2791 | call $~lib/map/Map#set 2792 | global.get $lib/input-map/byteToInputKeyMap 2793 | i32.const 190 2794 | i32.const 2192 2795 | call $~lib/map/Map#set 2796 | global.get $lib/input-map/byteToInputKeyMap 2797 | i32.const 221 2798 | i32.const 2232 2799 | call $~lib/map/Map#set 2800 | global.get $lib/input-map/byteToInputKeyMap 2801 | i32.const 186 2802 | i32.const 2280 2803 | call $~lib/map/Map#set 2804 | global.get $lib/input-map/byteToInputKeyMap 2805 | i32.const 191 2806 | i32.const 2320 2807 | call $~lib/map/Map#set 2808 | global.get $lib/input-map/byteToInputKeyMap 2809 | i32.const 8 2810 | i32.const 2352 2811 | call $~lib/map/Map#set 2812 | global.get $lib/input-map/byteToInputKeyMap 2813 | i32.const 46 2814 | i32.const 2392 2815 | call $~lib/map/Map#set 2816 | global.get $lib/input-map/byteToInputKeyMap 2817 | i32.const 35 2818 | i32.const 2432 2819 | call $~lib/map/Map#set 2820 | global.get $lib/input-map/byteToInputKeyMap 2821 | i32.const 13 2822 | i32.const 2464 2823 | call $~lib/map/Map#set 2824 | global.get $lib/input-map/byteToInputKeyMap 2825 | i32.const 27 2826 | i32.const 2496 2827 | call $~lib/map/Map#set 2828 | global.get $lib/input-map/byteToInputKeyMap 2829 | i32.const 36 2830 | i32.const 2536 2831 | call $~lib/map/Map#set 2832 | global.get $lib/input-map/byteToInputKeyMap 2833 | i32.const 45 2834 | i32.const 2568 2835 | call $~lib/map/Map#set 2836 | global.get $lib/input-map/byteToInputKeyMap 2837 | i32.const 34 2838 | i32.const 2608 2839 | call $~lib/map/Map#set 2840 | global.get $lib/input-map/byteToInputKeyMap 2841 | i32.const 33 2842 | i32.const 2648 2843 | call $~lib/map/Map#set 2844 | global.get $lib/input-map/byteToInputKeyMap 2845 | i32.const 19 2846 | i32.const 2688 2847 | call $~lib/map/Map#set 2848 | global.get $lib/input-map/byteToInputKeyMap 2849 | i32.const 32 2850 | i32.const 2720 2851 | call $~lib/map/Map#set 2852 | global.get $lib/input-map/byteToInputKeyMap 2853 | i32.const 9 2854 | i32.const 2752 2855 | call $~lib/map/Map#set 2856 | global.get $lib/input-map/byteToInputKeyMap 2857 | i32.const 144 2858 | i32.const 2784 2859 | call $~lib/map/Map#set 2860 | global.get $lib/input-map/byteToInputKeyMap 2861 | i32.const 20 2862 | i32.const 2824 2863 | call $~lib/map/Map#set 2864 | global.get $lib/input-map/byteToInputKeyMap 2865 | i32.const 145 2866 | i32.const 2864 2867 | call $~lib/map/Map#set 2868 | global.get $lib/input-map/byteToInputKeyMap 2869 | i32.const 16 2870 | i32.const 2912 2871 | call $~lib/map/Map#set 2872 | global.get $lib/input-map/byteToInputKeyMap 2873 | i32.const 162 2874 | i32.const 2944 2875 | call $~lib/map/Map#set 2876 | global.get $lib/input-map/byteToInputKeyMap 2877 | i32.const 163 2878 | i32.const 2984 2879 | call $~lib/map/Map#set 2880 | global.get $lib/input-map/byteToInputKeyMap 2881 | i32.const 96 2882 | i32.const 3024 2883 | call $~lib/map/Map#set 2884 | global.get $lib/input-map/byteToInputKeyMap 2885 | i32.const 97 2886 | i32.const 3064 2887 | call $~lib/map/Map#set 2888 | global.get $lib/input-map/byteToInputKeyMap 2889 | i32.const 98 2890 | i32.const 3104 2891 | call $~lib/map/Map#set 2892 | global.get $lib/input-map/byteToInputKeyMap 2893 | i32.const 99 2894 | i32.const 3144 2895 | call $~lib/map/Map#set 2896 | global.get $lib/input-map/byteToInputKeyMap 2897 | i32.const 100 2898 | i32.const 3184 2899 | call $~lib/map/Map#set 2900 | global.get $lib/input-map/byteToInputKeyMap 2901 | i32.const 101 2902 | i32.const 3224 2903 | call $~lib/map/Map#set 2904 | global.get $lib/input-map/byteToInputKeyMap 2905 | i32.const 102 2906 | i32.const 3264 2907 | call $~lib/map/Map#set 2908 | global.get $lib/input-map/byteToInputKeyMap 2909 | i32.const 103 2910 | i32.const 3304 2911 | call $~lib/map/Map#set 2912 | global.get $lib/input-map/byteToInputKeyMap 2913 | i32.const 104 2914 | i32.const 3344 2915 | call $~lib/map/Map#set 2916 | global.get $lib/input-map/byteToInputKeyMap 2917 | i32.const 105 2918 | i32.const 3384 2919 | call $~lib/map/Map#set 2920 | global.get $lib/input-map/byteToInputKeyMap 2921 | i32.const 110 2922 | i32.const 3424 2923 | call $~lib/map/Map#set 2924 | global.get $lib/input-map/byteToInputKeyMap 2925 | i32.const 111 2926 | i32.const 3464 2927 | call $~lib/map/Map#set 2928 | global.get $lib/input-map/byteToInputKeyMap 2929 | i32.const 106 2930 | i32.const 3512 2931 | call $~lib/map/Map#set 2932 | global.get $lib/input-map/byteToInputKeyMap 2933 | i32.const 109 2934 | i32.const 3568 2935 | call $~lib/map/Map#set 2936 | global.get $lib/input-map/byteToInputKeyMap 2937 | i32.const 107 2938 | i32.const 3616 2939 | call $~lib/map/Map#set 2940 | global.get $lib/input-map/byteToInputKeyMap 2941 | i32.const 18 2942 | i32.const 3664 2943 | call $~lib/map/Map#set 2944 | global.get $lib/input-map/byteToInputKeyMap 2945 | i32.const 91 2946 | i32.const 3696 2947 | call $~lib/map/Map#set 2948 | global.get $lib/input-map/byteToInputKeyMap 2949 | i32.const 93 2950 | i32.const 3736 2951 | call $~lib/map/Map#set 2952 | call $~lib/map/Map<~lib/string/String,bool>#constructor 2953 | global.set $lib/input-map/keyPressStateMap 2954 | call $lib/input-map/resetKeyPressState 2955 | ) 2956 | (func $~lib/as-wasi/as-wasi/FileSystem.open (; 44 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) 2957 | (local $2 i32) 2958 | (local $3 i64) 2959 | (local $4 i32) 2960 | (local $5 i32) 2961 | local.get $1 2962 | i32.const 3960 2963 | call $~lib/string/String.__eq 2964 | if (result i64) 2965 | i64.const 2113574 2966 | else 2967 | local.get $1 2968 | i32.const 3984 2969 | call $~lib/string/String.__eq 2970 | if (result i64) 2971 | i64.const 2098278 2972 | else 2973 | local.get $1 2974 | i32.const 4008 2975 | call $~lib/string/String.__eq 2976 | if (result i64) 2977 | i32.const 9 2978 | local.set $2 2979 | i64.const 2098276 2980 | else 2981 | local.get $1 2982 | i32.const 4032 2983 | call $~lib/string/String.__eq 2984 | if (result i64) 2985 | i32.const 13 2986 | local.set $2 2987 | i64.const 2098276 2988 | else 2989 | local.get $1 2990 | i32.const 3936 2991 | call $~lib/string/String.__eq 2992 | if (result i32) 2993 | i32.const 9 2994 | else 2995 | local.get $1 2996 | i32.const 4056 2997 | call $~lib/string/String.__eq 2998 | i32.eqz 2999 | if 3000 | i32.const 0 3001 | return 3002 | end 3003 | i32.const 13 3004 | end 3005 | local.set $2 3006 | i64.const 2098278 3007 | end 3008 | end 3009 | end 3010 | end 3011 | local.set $3 3012 | local.get $0 3013 | call $~lib/string/String.UTF8.byteLength 3014 | local.set $1 3015 | local.get $0 3016 | call $~lib/string/String.UTF8.encode 3017 | local.set $0 3018 | i32.const 4 3019 | call $~lib/arraybuffer/ArrayBuffer#constructor 3020 | local.tee $4 3021 | i32.const 3 3022 | i32.const 1 3023 | local.get $0 3024 | local.get $1 3025 | local.get $2 3026 | local.get $3 3027 | local.get $3 3028 | i32.const 0 3029 | local.get $4 3030 | call $~lib/bindings/wasi_unstable/path_open 3031 | i32.const 65535 3032 | i32.and 3033 | if 3034 | i32.const 0 3035 | return 3036 | end 3037 | i32.load 3038 | call $~lib/as-wasi/as-wasi/Descriptor#constructor 3039 | ) 3040 | (func $lib/lib/isIoDevicesEnabled (; 45 ;) (type $FUNCSIG$v) 3041 | (local $0 i32) 3042 | (local $1 i32) 3043 | (local $2 i32) 3044 | i32.const 3864 3045 | i32.const 3936 3046 | call $~lib/as-wasi/as-wasi/FileSystem.open 3047 | local.set $0 3048 | i32.const 4080 3049 | i32.const 4008 3050 | call $~lib/as-wasi/as-wasi/FileSystem.open 3051 | local.set $1 3052 | i32.const 4136 3053 | i32.const 3936 3054 | call $~lib/as-wasi/as-wasi/FileSystem.open 3055 | local.set $2 3056 | i32.const 0 3057 | i32.const 1 3058 | i32.const 1 3059 | i32.const 4192 3060 | i32.const 3960 3061 | call $~lib/as-wasi/as-wasi/FileSystem.open 3062 | i32.eqz 3063 | i32.const 1 3064 | local.get $2 3065 | i32.eqz 3066 | local.get $1 3067 | i32.eqz 3068 | i32.const 1 3069 | local.get $0 3070 | select 3071 | select 3072 | select 3073 | select 3074 | if (result i32) 3075 | i32.const 0 3076 | else 3077 | i32.const 1 3078 | end 3079 | if 3080 | i32.const 4256 3081 | i32.const 4456 3082 | call $~lib/string/String.__concat 3083 | i32.const 4664 3084 | call $~lib/string/String.__concat 3085 | local.set $0 3086 | i32.const 1 3087 | call $~lib/as-wasi/as-wasi/Descriptor#constructor 3088 | local.get $0 3089 | i32.const 1 3090 | call $~lib/as-wasi/as-wasi/Descriptor#writeString 3091 | i32.const 72 3092 | i32.const 4768 3093 | i32.const 31 3094 | i32.const 4 3095 | call $~lib/as-wasi/as-wasi/wasi_abort 3096 | unreachable 3097 | end 3098 | ) 3099 | (func $~lib/util/number/itoa32 (; 46 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 3100 | (local $1 i32) 3101 | (local $2 i32) 3102 | (local $3 i32) 3103 | local.get $0 3104 | i32.eqz 3105 | if 3106 | i32.const 88 3107 | return 3108 | end 3109 | local.get $0 3110 | i32.const 0 3111 | i32.lt_s 3112 | local.tee $1 3113 | if 3114 | i32.const 0 3115 | local.get $0 3116 | i32.sub 3117 | local.set $0 3118 | end 3119 | local.get $0 3120 | call $~lib/util/number/decimalCount32 3121 | local.get $1 3122 | i32.add 3123 | local.tee $3 3124 | i32.const 1 3125 | i32.shl 3126 | i32.const 1 3127 | call $~lib/rt/stub/__alloc 3128 | local.tee $2 3129 | local.get $0 3130 | local.get $3 3131 | call $~lib/util/number/utoa_simple 3132 | local.get $1 3133 | if 3134 | local.get $2 3135 | i32.const 45 3136 | i32.store16 3137 | end 3138 | local.get $2 3139 | ) 3140 | (func $~lib/as-wasi/as-wasi/Descriptor#seek (; 47 ;) (type $FUNCSIG$vi) (param $0 i32) 3141 | (local $1 i32) 3142 | i32.const 8 3143 | call $~lib/arraybuffer/ArrayBuffer#constructor 3144 | local.set $1 3145 | local.get $0 3146 | i32.load 3147 | i64.const 0 3148 | i32.const 2 3149 | local.get $1 3150 | call $~lib/bindings/wasi_unstable/fd_seek 3151 | drop 3152 | ) 3153 | (func $lib/lib/openFrameBufferWindow (; 48 ;) (type $FUNCSIG$v) 3154 | (local $0 i32) 3155 | i32.const 4808 3156 | i32.const 0 3157 | call $~lib/util/number/itoa32 3158 | call $~lib/string/String.__concat 3159 | i32.const 4856 3160 | call $~lib/string/String.__concat 3161 | i32.const 3936 3162 | call $~lib/as-wasi/as-wasi/FileSystem.open 3163 | local.tee $0 3164 | call $~lib/as-wasi/as-wasi/Descriptor#seek 3165 | local.get $0 3166 | i32.const 400 3167 | call $~lib/util/number/itoa32 3168 | i32.const 4904 3169 | call $~lib/string/String.__concat 3170 | i32.const 400 3171 | call $~lib/util/number/itoa32 3172 | call $~lib/string/String.__concat 3173 | i32.const 0 3174 | call $~lib/as-wasi/as-wasi/Descriptor#writeString 3175 | ) 3176 | (func $~lib/array/Array#__set (; 49 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) 3177 | (local $3 i32) 3178 | local.get $1 3179 | local.get $0 3180 | i32.load offset=12 3181 | i32.ge_u 3182 | if 3183 | local.get $1 3184 | i32.const 0 3185 | i32.lt_s 3186 | if 3187 | i32.const 352 3188 | i32.const 408 3189 | i32.const 109 3190 | i32.const 21 3191 | call $~lib/as-wasi/as-wasi/wasi_abort 3192 | unreachable 3193 | end 3194 | local.get $0 3195 | local.get $1 3196 | i32.const 1 3197 | i32.add 3198 | local.tee $3 3199 | i32.const 0 3200 | call $~lib/array/ensureSize 3201 | local.get $0 3202 | local.get $3 3203 | i32.store offset=12 3204 | end 3205 | local.get $0 3206 | i32.load offset=4 3207 | local.get $1 3208 | i32.add 3209 | local.get $2 3210 | i32.store8 3211 | ) 3212 | (func $~lib/as-wasi/as-wasi/Descriptor#write (; 50 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) 3213 | (local $2 i32) 3214 | (local $3 i32) 3215 | (local $4 i32) 3216 | local.get $1 3217 | i32.load offset=12 3218 | local.tee $3 3219 | call $~lib/arraybuffer/ArrayBuffer#constructor 3220 | local.set $4 3221 | loop $loop|0 3222 | local.get $2 3223 | local.get $3 3224 | i32.lt_s 3225 | if 3226 | local.get $2 3227 | local.get $4 3228 | i32.add 3229 | local.get $1 3230 | i32.load offset=4 3231 | local.get $2 3232 | i32.add 3233 | i32.load8_u 3234 | i32.store8 3235 | local.get $2 3236 | i32.const 1 3237 | i32.add 3238 | local.set $2 3239 | br $loop|0 3240 | end 3241 | end 3242 | i32.const 8 3243 | call $~lib/arraybuffer/ArrayBuffer#constructor 3244 | local.tee $1 3245 | local.get $4 3246 | i32.store 3247 | local.get $1 3248 | i32.const 4 3249 | i32.add 3250 | local.get $3 3251 | i32.store 3252 | i32.const 4 3253 | call $~lib/arraybuffer/ArrayBuffer#constructor 3254 | local.set $2 3255 | local.get $0 3256 | i32.load 3257 | local.get $1 3258 | i32.const 1 3259 | local.get $2 3260 | call $~lib/bindings/wasi_unstable/fd_write 3261 | drop 3262 | ) 3263 | (func $lib/lib/drawRgbaArrayToFrameBuffer (; 51 ;) (type $FUNCSIG$vi) (param $0 i32) 3264 | (local $1 i32) 3265 | i32.const 4808 3266 | i32.const 0 3267 | call $~lib/util/number/itoa32 3268 | call $~lib/string/String.__concat 3269 | i32.const 4928 3270 | call $~lib/string/String.__concat 3271 | i32.const 3936 3272 | call $~lib/as-wasi/as-wasi/FileSystem.open 3273 | local.tee $1 3274 | call $~lib/as-wasi/as-wasi/Descriptor#seek 3275 | local.get $1 3276 | local.get $0 3277 | call $~lib/as-wasi/as-wasi/Descriptor#write 3278 | i32.const 4808 3279 | i32.const 0 3280 | call $~lib/util/number/itoa32 3281 | call $~lib/string/String.__concat 3282 | i32.const 4952 3283 | call $~lib/string/String.__concat 3284 | i32.const 4008 3285 | call $~lib/as-wasi/as-wasi/FileSystem.open 3286 | local.tee $0 3287 | call $~lib/as-wasi/as-wasi/Descriptor#seek 3288 | local.get $0 3289 | i32.const 0 3290 | call $~lib/util/number/itoa32 3291 | i32.const 0 3292 | call $~lib/as-wasi/as-wasi/Descriptor#writeString 3293 | ) 3294 | (func $~lib/bindings/wasi_unstable/subscription#constructor (; 52 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) 3295 | local.get $0 3296 | i32.eqz 3297 | if 3298 | i32.const 16 3299 | i32.const 0 3300 | call $~lib/rt/stub/__alloc 3301 | local.set $0 3302 | end 3303 | local.get $0 3304 | i64.const 0 3305 | i64.store 3306 | local.get $0 3307 | i32.const 0 3308 | i32.store8 offset=8 3309 | local.get $0 3310 | i32.const 0 3311 | i32.store offset=12 3312 | local.get $0 3313 | ) 3314 | (func $~lib/bindings/wasi_unstable/clocksubscription#constructor (; 53 ;) (type $FUNCSIG$i) (result i32) 3315 | (local $0 i32) 3316 | i32.const 56 3317 | i32.const 0 3318 | call $~lib/rt/stub/__alloc 3319 | call $~lib/bindings/wasi_unstable/subscription#constructor 3320 | local.tee $0 3321 | i64.const 0 3322 | i64.store offset=16 3323 | local.get $0 3324 | i32.const 0 3325 | i32.store offset=24 3326 | local.get $0 3327 | i64.const 0 3328 | i64.store offset=32 3329 | local.get $0 3330 | i64.const 0 3331 | i64.store offset=40 3332 | local.get $0 3333 | i32.const 0 3334 | i32.store16 offset=48 3335 | local.get $0 3336 | i32.const 0 3337 | i32.store offset=52 3338 | local.get $0 3339 | ) 3340 | (func $~lib/bindings/wasi_unstable/event#constructor (; 54 ;) (type $FUNCSIG$i) (result i32) 3341 | (local $0 i32) 3342 | i32.const 14 3343 | i32.const 0 3344 | call $~lib/rt/stub/__alloc 3345 | local.tee $0 3346 | i64.const 0 3347 | i64.store 3348 | local.get $0 3349 | i32.const 0 3350 | i32.store16 offset=8 3351 | local.get $0 3352 | i32.const 0 3353 | i32.store8 offset=10 3354 | local.get $0 3355 | i32.const 0 3356 | i32.store16 offset=12 3357 | local.get $0 3358 | ) 3359 | (func $~lib/as-wasi/as-wasi/Time.sleep (; 55 ;) (type $FUNCSIG$vi) (param $0 i32) 3360 | (local $1 i32) 3361 | call $~lib/bindings/wasi_unstable/clocksubscription#constructor 3362 | local.tee $1 3363 | i64.const 0 3364 | i64.store 3365 | local.get $1 3366 | i64.const 0 3367 | i64.store offset=16 3368 | local.get $1 3369 | i32.const 0 3370 | i32.store offset=24 3371 | local.get $1 3372 | local.get $0 3373 | i64.extend_i32_s 3374 | i64.store offset=32 3375 | local.get $1 3376 | i64.const 10000 3377 | i64.store offset=40 3378 | local.get $1 3379 | i32.const 0 3380 | i32.store8 offset=8 3381 | local.get $1 3382 | call $~lib/bindings/wasi_unstable/event#constructor 3383 | i32.const 1 3384 | i32.const 4 3385 | i32.const 0 3386 | call $~lib/rt/stub/__alloc 3387 | call $~lib/bindings/wasi_unstable/poll_oneoff 3388 | drop 3389 | ) 3390 | (func $quick-start/graphics/_start (; 56 ;) (type $FUNCSIG$v) 3391 | (local $0 i32) 3392 | (local $1 i32) 3393 | (local $2 i32) 3394 | (local $3 i32) 3395 | call $lib/lib/isIoDevicesEnabled 3396 | call $lib/lib/openFrameBufferWindow 3397 | loop $continue|0 3398 | i32.const 16 3399 | i32.const 7 3400 | call $~lib/rt/stub/__alloc 3401 | i32.const 0 3402 | call $~lib/arraybuffer/ArrayBufferView#constructor 3403 | local.tee $0 3404 | i32.const 0 3405 | i32.store offset=12 3406 | local.get $0 3407 | i32.const 0 3408 | i32.store offset=12 3409 | i32.const 0 3410 | local.set $1 3411 | loop $loop|1 3412 | local.get $1 3413 | i32.const 400 3414 | i32.lt_s 3415 | if 3416 | i32.const 0 3417 | local.set $2 3418 | loop $loop|2 3419 | local.get $2 3420 | i32.const 400 3421 | i32.lt_s 3422 | if 3423 | local.get $0 3424 | local.get $2 3425 | i32.const 400 3426 | i32.mul 3427 | local.get $1 3428 | i32.add 3429 | i32.const 2 3430 | i32.shl 3431 | local.tee $3 3432 | i32.const 0 3433 | call $~lib/array/Array#__set 3434 | local.get $0 3435 | local.get $3 3436 | i32.const 0 3437 | call $~lib/array/Array#__set 3438 | local.get $0 3439 | local.get $3 3440 | i32.const 255 3441 | call $~lib/array/Array#__set 3442 | local.get $0 3443 | local.get $3 3444 | i32.const 255 3445 | call $~lib/array/Array#__set 3446 | local.get $2 3447 | i32.const 1 3448 | i32.add 3449 | local.set $2 3450 | br $loop|2 3451 | end 3452 | end 3453 | local.get $1 3454 | i32.const 1 3455 | i32.add 3456 | local.set $1 3457 | br $loop|1 3458 | end 3459 | end 3460 | local.get $0 3461 | call $lib/lib/drawRgbaArrayToFrameBuffer 3462 | global.get $~lib/as-wasi/as-wasi/Time.MILLISECOND 3463 | i32.const 4 3464 | i32.shl 3465 | call $~lib/as-wasi/as-wasi/Time.sleep 3466 | br $continue|0 3467 | end 3468 | unreachable 3469 | ) 3470 | (func $start (; 57 ;) (type $FUNCSIG$v) 3471 | i32.const 5040 3472 | global.set $~lib/rt/stub/startOffset 3473 | i32.const 5040 3474 | global.set $~lib/rt/stub/offset 3475 | i32.const 1000000 3476 | global.set $~lib/as-wasi/as-wasi/Time.MILLISECOND 3477 | global.get $~lib/as-wasi/as-wasi/Time.MILLISECOND 3478 | i32.const 1000 3479 | i32.mul 3480 | global.set $~lib/as-wasi/as-wasi/Time.SECOND 3481 | call $start:lib/input-map 3482 | ) 3483 | ) 3484 | -------------------------------------------------------------------------------- /assemblyscript/quick-start/graphics.ts: -------------------------------------------------------------------------------- 1 | // Import some common functions from io-devices-lib-assemblyscript 2 | import { 3 | isIoDevicesEnabled, 4 | openFrameBufferWindow, 5 | closeFrameBufferWindow, 6 | drawRgbaArrayToFrameBuffer, 7 | } from "../lib/lib"; 8 | 9 | // Import some useful utilities from as-wasi 10 | import {Console, Time} from "as-wasi"; 11 | 12 | // Entry point into WASI Module 13 | export function _start(): void { 14 | 15 | // Check if IO Devices is enabled, and throw an error if so. 16 | isIoDevicesEnabled(true); 17 | 18 | // Open a framebuffer that is 400 pixels wide, and 400 pixels tall, and use fb0 19 | openFrameBufferWindow(400, 400, 0); 20 | 21 | // Loop infinitely to keep the program running 22 | while(true) { 23 | 24 | // Create an one dimensional, Uint8 array for storing our RGBA information 25 | let rgbaFrame: Array = new Array(); 26 | 27 | // Fill the rgbaFrame with a solid green color 28 | for (let x = 0; x < 400; x++) { 29 | for (let y = 0; y < 400; y++) { 30 | 31 | // Get which pixel we currently are at 32 | let pixelIndex = ((y * 400) + x) * 4; 33 | 34 | // Set our Red 35 | rgbaFrame[pixelIndex + 0] = 0; 36 | // Set our Blue 37 | rgbaFrame[pixelIndex + 0] = 0; 38 | // Set our Green 39 | rgbaFrame[pixelIndex + 0] = 255; 40 | // Set our Alpha 41 | rgbaFrame[pixelIndex + 0] = 255; 42 | } 43 | } 44 | 45 | // Draw the rgbaFrame to fb0 46 | drawRgbaArrayToFrameBuffer(rgbaFrame, 0); 47 | 48 | // Sleep approximately 16 milliseconds. 49 | // This will make our loop run at 60 fps. 50 | Time.sleep(16 * Time.MILLISECOND); 51 | } 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /assemblyscript/quick-start/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../../../.nvm/versions/node/v10.16.3/lib/node_modules/assemblyscript/std/assembly.json", 3 | "include": [ 4 | "./**/*.ts" 5 | ] 6 | } -------------------------------------------------------------------------------- /assets/framebufferScreenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasmerio/io-devices-lib/3595940c91f2304c9897c55dc281cdcd4d99c7cc/assets/framebufferScreenshot.png -------------------------------------------------------------------------------- /rust/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | Cargo.lock 4 | -------------------------------------------------------------------------------- /rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wasmer-experimental-io-devices-lib" 3 | version = "0.1.1" 4 | authors = ["The Wasmer Engineering Team "] 5 | edition = "2018" 6 | publish = true 7 | description = "Convenient bindings to use the experimental wasmer io devices" 8 | license = "MIT" 9 | 10 | [badges] 11 | maintenance = { status = "experimental" } 12 | 13 | [dependencies] 14 | num-traits = "0.2" 15 | num-derive = "0.2" 16 | -------------------------------------------------------------------------------- /rust/README.md: -------------------------------------------------------------------------------- 1 | # io_devices_lib Rust 2 | 3 | Rust crate for building applications using the Wasmer Experimental IO Devices. 🔌 4 | 5 | ## Features 6 | 7 | - Supports the Wasmer Framebuffers, so you can use WASI Modules to draw graphics! 🖼️ 8 | - Supports Keyboard and Mouse Input APIs, so you can retrieve and use Input! ⌨️🐭 9 | 10 | ## Installation 11 | 12 | Add `wasmer-experimental-io-devices-lib = "0.1"` to your `[dependencies]` in your `Cargo.toml` 13 | 14 | 15 | ## Quick Start 16 | # TODO(mark): restructure io-devices-lib so that current stuff is namespaced under framebuffer 17 | 18 | The program below demonstrates how to use this API to create an interactive framebuffer application. 19 | 20 | ```Rust 21 | use std::iter; 22 | use wasmer_experimental_io_devices_lib::{color::*, *}; 23 | 24 | const X_RES: u32 = 300; 25 | const Y_RES: u32 = 300; 26 | 27 | fn main() { 28 | // create a framebuffer instance with the specified resolution 29 | let mut fb_ctx = FrameBufferCtx::new(X_RES, Y_RES).unwrap(); 30 | 31 | // declare some data 32 | let colors: Vec = vec![ 33 | (255, 0, 0).into(), // red 34 | (0, 255, 0).into(), // green 35 | (0, 0, 255).into(), // blue 36 | (255, 255, 0).into(), // yellow 37 | (255, 255, 255).into(), // white 38 | ]; 39 | 40 | let mut color_selector = 1; 41 | 'mainloop: loop { 42 | // get input event iterator 43 | let iter = fb_ctx.get_input().unwrap(); 44 | 45 | for ie in iter { 46 | match ie { 47 | InputEvent::WindowClosed | InputEvent::KeyPress(Key::Escape) => break 'mainloop, 48 | InputEvent::KeyPress(Key::Key1) => color_selector = 1, 49 | InputEvent::KeyPress(Key::Key2) => color_selector = 2, 50 | InputEvent::KeyPress(Key::Key3) => color_selector = 3, 51 | InputEvent::KeyPress(Key::Key4) => color_selector = 4, 52 | InputEvent::KeyPress(Key::Key5) => color_selector = 5, 53 | InputEvent::MouseEvent(x, y, et) => { 54 | println!("{:?} at {}, {}", et, x, y); 55 | } 56 | _ => (), 57 | } 58 | } 59 | 60 | let color = colors[color_selector - 1]; 61 | // draw all the pixels with the selected color 62 | fb_ctx 63 | .update_pixels(0, 0, iter::repeat(color).take((X_RES * Y_RES) as usize)) 64 | .unwrap(); 65 | 66 | fb_ctx.draw().unwrap(); 67 | // std::thread::sleep_ms(16); 68 | } 69 | } 70 | ``` 71 | 72 | Inside your crate, just run `cargo build --release --target=wasm32-wasi` to compile. 73 | 74 | Check your version of wasmer with `wasmer -V`, if you haven't updated to version 0.12.0 or higher yet, run `wasmer self-update`. 75 | 76 | Then, run `wasmer run --enable-experimental-io-devices target/wasm32-wasi/release/wasm-module-name.wasm`. 77 | 78 | TODO: add screenshot 79 | -------------------------------------------------------------------------------- /rust/examples/fb_test_2/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | Cargo.lock 4 | -------------------------------------------------------------------------------- /rust/examples/fb_test_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fb_test_2" 3 | version = "0.1.0" 4 | authors = ["Mark McCaskey "] 5 | edition = "2018" 6 | 7 | [workspace] 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | wasmer-experimental-io-devices-lib = { path = "../.." } 13 | -------------------------------------------------------------------------------- /rust/examples/fb_test_2/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::iter; 2 | use wasmer_experimental_io_devices_lib::framebuffer::{ 3 | color::RGBA, FrameBufferCtx, InputEvent, Key, 4 | }; 5 | 6 | const X_RES: u32 = 300; 7 | const Y_RES: u32 = 300; 8 | 9 | fn main() { 10 | // create a framebuffer instance with the specified resolution 11 | let mut fb_ctx = FrameBufferCtx::new(X_RES, Y_RES).unwrap(); 12 | 13 | // declare some data 14 | let colors: Vec = vec![ 15 | (255, 0, 0).into(), // red 16 | (0, 255, 0).into(), // green 17 | (0, 0, 255).into(), // blue 18 | (255, 255, 0).into(), // yellow 19 | (255, 255, 255).into(), // white 20 | ]; 21 | 22 | let mut color_selector = 1; 23 | 'mainloop: loop { 24 | // get input event iterator 25 | let iter = fb_ctx.get_input().unwrap(); 26 | 27 | for ie in iter { 28 | match ie { 29 | InputEvent::WindowClosed | InputEvent::KeyPress(Key::Escape) => break 'mainloop, 30 | InputEvent::KeyPress(Key::Key1) => color_selector = 1, 31 | InputEvent::KeyPress(Key::Key2) => color_selector = 2, 32 | InputEvent::KeyPress(Key::Key3) => color_selector = 3, 33 | InputEvent::KeyPress(Key::Key4) => color_selector = 4, 34 | InputEvent::KeyPress(Key::Key5) => color_selector = 5, 35 | InputEvent::MouseEvent(x, y, et) => { 36 | println!("{:?} at {}, {}", et, x, y); 37 | } 38 | _ => (), 39 | } 40 | } 41 | 42 | let color = colors[color_selector - 1]; 43 | // draw all the pixels with the selected color 44 | fb_ctx 45 | .update_pixels(0, 0, iter::repeat(color).take((X_RES * Y_RES) as usize)) 46 | .unwrap(); 47 | 48 | fb_ctx.draw().unwrap(); 49 | // FIXME(mark): sleeping broke again 50 | //std::thread::sleep_ms(16); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /rust/src/framebuffer/color.rs: -------------------------------------------------------------------------------- 1 | //! Data and functions for dealing with color 2 | 3 | /// A color value representing Red, Green, Blue, and Alpha 4 | #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, PartialOrd, Ord)] 5 | #[repr(C)] 6 | pub struct RGBA { 7 | pub b: u8, 8 | pub g: u8, 9 | pub r: u8, 10 | pub a: u8, 11 | } 12 | 13 | impl RGBA { 14 | /// return the raw bytes 15 | pub const fn as_bytes(&self) -> [u8; 4] { 16 | [self.b, self.g, self.r, self.a] 17 | } 18 | } 19 | 20 | impl std::convert::From<(u8, u8, u8, u8)> for RGBA { 21 | fn from(item: (u8, u8, u8, u8)) -> Self { 22 | RGBA { 23 | r: item.0, 24 | g: item.1, 25 | b: item.2, 26 | a: item.3, 27 | } 28 | } 29 | } 30 | 31 | impl std::convert::From<(u8, u8, u8)> for RGBA { 32 | fn from(item: (u8, u8, u8)) -> Self { 33 | RGBA { 34 | r: item.0, 35 | g: item.1, 36 | b: item.2, 37 | a: u8::max_value(), 38 | } 39 | } 40 | } 41 | 42 | impl std::convert::From<[u8; 4]> for RGBA { 43 | fn from(item: [u8; 4]) -> Self { 44 | RGBA { 45 | r: item[0], 46 | g: item[1], 47 | b: item[2], 48 | a: item[3], 49 | } 50 | } 51 | } 52 | 53 | impl std::convert::From<[u8; 3]> for RGBA { 54 | fn from(item: [u8; 3]) -> Self { 55 | RGBA { 56 | r: item[0], 57 | g: item[1], 58 | b: item[2], 59 | a: u8::max_value(), 60 | } 61 | } 62 | } 63 | 64 | impl std::convert::TryFrom<&[u8]> for RGBA { 65 | type Error = (); 66 | 67 | fn try_from(item: &[u8]) -> Result { 68 | if item.len() < 3 { 69 | return Err(()); 70 | } 71 | Ok(RGBA { 72 | r: item[0], 73 | g: item[1], 74 | b: item[2], 75 | a: item.get(3).cloned().unwrap_or(u8::max_value()), 76 | }) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /rust/src/framebuffer/mod.rs: -------------------------------------------------------------------------------- 1 | //! Code for interacting the experimental Wasmer Framebuffer. 2 | //! 3 | //! See the [example][fb-example] for details about how to use this crate to 4 | //! interact with the framebuffer. 5 | //! 6 | //! [fb-example]: https://github.com/wasmerio/io-devices-lib/blob/master/rust/examples/fb_test_2/src/main.rs 7 | 8 | use num_traits::FromPrimitive; 9 | 10 | use std::fs::File; 11 | use std::io::{Read, Seek, SeekFrom, Write}; 12 | use std::{fs, io}; 13 | 14 | pub mod color; 15 | 16 | use color::*; 17 | 18 | /// Wrapper around framebuffer primitives, allows you to draw and get input easily 19 | pub struct FrameBufferCtx { 20 | frame_buffer_handle: File, 21 | resolution_handle: File, 22 | index_handle: File, 23 | input_handle: File, 24 | 25 | resolution: (u32, u32), 26 | } 27 | 28 | impl FrameBufferCtx { 29 | /// Create a new framebuffer with the specified resolution. 30 | pub fn new(x: u32, y: u32) -> Result { 31 | Self::new_inner(x, y).map_err(|e| { 32 | format!( 33 | "Failed to open files at `/_wasmer/dev/fb0`: \"{}\". These are \ 34 | non-standard files. If you're using Wasmer, please ensure that \ 35 | you've updated to version 0.13.1 and are using the \ 36 | `--enable-experimental-io-devices` flag.", 37 | e.to_string() 38 | ) 39 | }) 40 | } 41 | 42 | /// Build a new framebuffer 43 | fn new_inner(x: u32, y: u32) -> io::Result { 44 | let frame_buffer_handle = fs::OpenOptions::new() 45 | .read(true) 46 | .write(true) 47 | .open("/_wasmer/dev/fb0/fb")?; 48 | 49 | let mut resolution_handle = fs::OpenOptions::new() 50 | .read(true) 51 | .write(true) 52 | .open("/_wasmer/dev/fb0/virtual_size")?; 53 | 54 | let index_handle = fs::OpenOptions::new() 55 | .read(true) 56 | .write(true) 57 | .open("/_wasmer/dev/fb0/draw")?; 58 | 59 | let input_handle = fs::OpenOptions::new() 60 | .read(true) 61 | .open("/_wasmer/dev/fb0/input")?; 62 | 63 | resolution_handle.write(format!("{}x{}", x, y).as_bytes())?; 64 | 65 | Ok(Self { 66 | frame_buffer_handle, 67 | resolution_handle, 68 | index_handle, 69 | input_handle, 70 | 71 | resolution: (x, y), 72 | }) 73 | } 74 | 75 | /// Gets the input from the input file and returns an iterator that parses the results 76 | pub fn get_input(&mut self) -> Option { 77 | let mut input_vec = vec![]; 78 | self.input_handle.read_to_end(&mut input_vec).ok()?; 79 | 80 | Some(InputIter { 81 | idx: 0, 82 | bytes: input_vec, 83 | }) 84 | } 85 | 86 | /// resize the window 87 | pub fn set_resolution(&mut self, x: u32, y: u32) -> Option<()> { 88 | self.resolution_handle 89 | .write(format!("{}x{}", x, y).as_bytes()) 90 | .ok()?; 91 | 92 | self.resolution.0 = x; 93 | self.resolution.1 = y; 94 | 95 | Some(()) 96 | } 97 | 98 | /// Draws the values in the buffer to the screen 99 | pub fn draw(&mut self) -> Option<()> { 100 | self.index_handle.write(&[b'0']).ok()?; 101 | Some(()) 102 | } 103 | 104 | /// Updates the buffer starting at position (x,y) with the specified colors 105 | /// If the length of `pixels` + x is greater than the max length of the row, 106 | /// drawing will continue at (0, y + 1) and so on. 107 | /// 108 | /// Returns `None` if something went wrong, otherwise returns the numbers of pixels 109 | /// written to the buffer. 110 | /// 111 | /// To be able to see these updates, you must call `draw` 112 | pub fn update_pixels(&mut self, x: u32, y: u32, pixels: I) -> Option 113 | where 114 | I: Iterator, 115 | { 116 | self.frame_buffer_handle 117 | .seek(SeekFrom::Start((self.resolution.0 * y + x) as u64 * 4)) 118 | .ok()?; 119 | 120 | let mut bytes_written = 0; 121 | for pixel in pixels { 122 | // TODO: if this is too slow, try stepping the iterator by a larger 123 | // amount and feeding more bytes at a time to the write calls 124 | bytes_written += self.frame_buffer_handle.write(&pixel.as_bytes()).ok()?; 125 | } 126 | 127 | Some(bytes_written as u32) 128 | } 129 | } 130 | 131 | // copied from Wasmer -- maybe this data should be shared somewhere? 132 | // though it is nice to have this crate be simple and self-contained 133 | const KEY_PRESS: u8 = 1; 134 | const MOUSE_MOVE: u8 = 2; 135 | const KEY_RELEASE: u8 = 3; 136 | const MOUSE_PRESS_LEFT: u8 = 4; 137 | const MOUSE_PRESS_RIGHT: u8 = 5; 138 | const MOUSE_PRESS_MIDDLE: u8 = 7; 139 | const WINDOW_CLOSED: u8 = 8; 140 | 141 | /// Iterator over [`InputEvent`]s. 142 | pub struct InputIter { 143 | idx: usize, 144 | bytes: Vec, 145 | } 146 | 147 | impl Iterator for InputIter { 148 | type Item = InputEvent; 149 | fn next(&mut self) -> Option { 150 | if self.idx >= self.bytes.len() { 151 | return None; 152 | } 153 | match self.bytes[self.idx] { 154 | KEY_PRESS => { 155 | if self.bytes.len() >= self.idx + 2 { 156 | if let Some(key) = FromPrimitive::from_u8(self.bytes[self.idx + 1]) { 157 | self.idx += 2; 158 | return Some(InputEvent::KeyPress(key)); 159 | } 160 | } 161 | } 162 | KEY_RELEASE => { 163 | if self.bytes.len() >= self.idx + 2 { 164 | if let Some(key) = FromPrimitive::from_u8(self.bytes[self.idx + 1]) { 165 | self.idx += 2; 166 | return Some(InputEvent::KeyRelease(key)); 167 | } 168 | } 169 | } 170 | MOUSE_MOVE | MOUSE_PRESS_LEFT | MOUSE_PRESS_RIGHT | MOUSE_PRESS_MIDDLE => { 171 | if self.bytes.len() >= self.idx + 9 { 172 | // TODO: fix bug here, reading wrong values 173 | let mut byte_array_x = [0u8; 4]; 174 | let mut byte_array_y = [0u8; 4]; 175 | for i in 0..4 { 176 | byte_array_x[i] = self.bytes[self.idx + 1 + i]; 177 | byte_array_y[i] = self.bytes[self.idx + 1 + 4 + i]; 178 | } 179 | let x = u32::from_le_bytes(byte_array_x); 180 | let y = u32::from_le_bytes(byte_array_y); 181 | 182 | let event_type = match self.bytes[self.idx] { 183 | MOUSE_MOVE => MouseEventType::Move, 184 | MOUSE_PRESS_LEFT => MouseEventType::LeftClick, 185 | MOUSE_PRESS_RIGHT => MouseEventType::RightClick, 186 | MOUSE_PRESS_MIDDLE => MouseEventType::MiddleClick, 187 | _ => unreachable!("Fatal internal logic error in input event parsing"), 188 | }; 189 | 190 | self.idx += 9; 191 | return Some(InputEvent::MouseEvent(x, y, event_type)); 192 | } 193 | } 194 | WINDOW_CLOSED => { 195 | return Some(InputEvent::WindowClosed); 196 | } 197 | _ => { 198 | // data corrupted 199 | return None; 200 | } 201 | } 202 | 203 | None 204 | } 205 | } 206 | 207 | // copied from Wasmer code which uses a match expression over minifb's `Key` type 208 | // Numbers from https://css-tricks.com/snippets/javascript/javascript-keycodes/ 209 | /// A key on a keyboard. 210 | #[derive(Debug, FromPrimitive, ToPrimitive)] 211 | #[repr(u8)] 212 | pub enum Key { 213 | Backspace = 8, 214 | Tab = 9, 215 | Enter = 13, 216 | Shift = 16, 217 | Ctrl = 17, 218 | Alt = 18, 219 | Pause = 19, 220 | CapsLock = 20, 221 | Escape = 27, 222 | Space = 32, 223 | PageUp = 33, 224 | PageDown = 34, 225 | End = 35, 226 | Home = 36, 227 | 228 | Left = 37, 229 | Up = 38, 230 | Right = 39, 231 | Down = 40, 232 | 233 | Insert = 45, 234 | Delete = 46, 235 | 236 | Key0 = 48, 237 | Key1 = 49, 238 | Key2 = 50, 239 | Key3 = 51, 240 | Key4 = 52, 241 | Key5 = 53, 242 | Key6 = 54, 243 | Key7 = 55, 244 | Key8 = 56, 245 | Key9 = 57, 246 | 247 | A = b'A', 248 | B = b'B', 249 | C = b'C', 250 | D = b'D', 251 | E = b'E', 252 | F = b'F', 253 | G = b'G', 254 | H = b'H', 255 | I = b'I', 256 | J = b'J', 257 | K = b'K', 258 | L = b'L', 259 | M = b'M', 260 | N = b'N', 261 | O = b'O', 262 | P = b'P', 263 | Q = b'Q', 264 | R = b'R', 265 | S = b'S', 266 | T = b'T', 267 | U = b'U', 268 | V = b'V', 269 | W = b'W', 270 | X = b'X', 271 | Y = b'Y', 272 | Z = b'Z', 273 | 274 | LeftSuper = 91, 275 | RightSuper = 92, 276 | 277 | NumPad0 = 96, 278 | NumPad1 = 97, 279 | NumPad2 = 98, 280 | NumPad3 = 99, 281 | NumPad4 = 100, 282 | NumPad5 = 101, 283 | NumPad6 = 102, 284 | NumPad7 = 103, 285 | NumPad8 = 104, 286 | NumPad9 = 105, 287 | NumPadAsterisk = 106, 288 | NumPadPlus = 107, 289 | NumPadMinus = 109, 290 | NumPadDot = 110, 291 | NumPadSlash = 111, 292 | 293 | F1 = 112, 294 | F2 = 113, 295 | F3 = 114, 296 | F4 = 115, 297 | F5 = 116, 298 | F6 = 117, 299 | F7 = 118, 300 | F8 = 119, 301 | F9 = 120, 302 | F10 = 121, 303 | F11 = 122, 304 | F12 = 123, 305 | 306 | NumLock = 144, 307 | ScrollLock = 145, 308 | 309 | Semicolon = 186, 310 | Equal = 187, 311 | Comma = 188, 312 | Minus = 189, 313 | Period = 190, 314 | Slash = 191, 315 | Backquote = 192, 316 | Backslash = 220, 317 | Apostrophe = 222, 318 | 319 | LeftBracket = 219, 320 | RightBracket = 221, 321 | 322 | Unknown = 255, 323 | } 324 | 325 | /// The type of mouse event. 326 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] 327 | pub enum MouseEventType { 328 | LeftClick, 329 | RightClick, 330 | MiddleClick, 331 | Move, 332 | } 333 | 334 | /// An event of an input from the user. 335 | #[derive(Debug)] 336 | pub enum InputEvent { 337 | KeyPress(Key), 338 | KeyRelease(Key), 339 | MouseEvent(u32, u32, MouseEventType), 340 | WindowClosed, 341 | } 342 | -------------------------------------------------------------------------------- /rust/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Library for interacting with experimental Wasmer IO devices. 2 | 3 | #[macro_use] 4 | extern crate num_derive; 5 | 6 | pub mod framebuffer; 7 | --------------------------------------------------------------------------------