diff --git a/raylib/audio.c b/raylib/audio.c
index c7c3750..9932f14 100644
--- a/raylib/audio.c
+++ b/raylib/audio.c
@@ -1,4 +1,4 @@
-// +build !noaudio,!js
+// +build !noaudio
/**********************************************************************************************
*
diff --git a/raylib/audio.go b/raylib/audio.go
index 3b2f412..1068816 100644
--- a/raylib/audio.go
+++ b/raylib/audio.go
@@ -1,4 +1,4 @@
-// +build !noaudio,!js
+// +build !noaudio
package raylib
diff --git a/raylib/camera.go b/raylib/camera.go
index e224dcd..960cf7b 100644
--- a/raylib/camera.go
+++ b/raylib/camera.go
@@ -1,4 +1,4 @@
-// +build !android,!js
+// +build !android
package raylib
diff --git a/raylib/cgo.go b/raylib/cgo.go
index 3046677..18f493c 100644
--- a/raylib/cgo.go
+++ b/raylib/cgo.go
@@ -1,5 +1,3 @@
-// +build !js
-
package raylib
/*
diff --git a/raylib/cgo_android.go b/raylib/cgo_android.go
index 50459f5..e56b130 100644
--- a/raylib/cgo_android.go
+++ b/raylib/cgo_android.go
@@ -1,4 +1,4 @@
-// +build android,!js
+// +build android
package raylib
diff --git a/raylib/cgo_darwin.go b/raylib/cgo_darwin.go
index 8c96fea..8b7bf07 100644
--- a/raylib/cgo_darwin.go
+++ b/raylib/cgo_darwin.go
@@ -1,4 +1,4 @@
-// +build darwin,!js
+// +build darwin
package raylib
diff --git a/raylib/cgo_linux.go b/raylib/cgo_linux.go
index 2675bc6..5297216 100644
--- a/raylib/cgo_linux.go
+++ b/raylib/cgo_linux.go
@@ -1,4 +1,4 @@
-// +build linux,!arm,!arm64,!js
+// +build linux,!arm,!arm64
package raylib
diff --git a/raylib/cgo_linux_arm.go b/raylib/cgo_linux_arm.go
index 739d508..3326212 100644
--- a/raylib/cgo_linux_arm.go
+++ b/raylib/cgo_linux_arm.go
@@ -1,4 +1,4 @@
-// +build linux,arm,!android,!js
+// +build linux,arm,!android
package raylib
diff --git a/raylib/cgo_windows.go b/raylib/cgo_windows.go
index 4245ba4..6615cc2 100644
--- a/raylib/cgo_windows.go
+++ b/raylib/cgo_windows.go
@@ -1,4 +1,4 @@
-// +build windows,!js
+// +build windows
package raylib
diff --git a/raylib/core.go b/raylib/core.go
index 1638cb3..6b5f36b 100644
--- a/raylib/core.go
+++ b/raylib/core.go
@@ -1,5 +1,3 @@
-// +build !js
-
package raylib
/*
diff --git a/raylib/external/scripts/emcc-generate-js.sh b/raylib/external/scripts/emcc-generate-js.sh
deleted file mode 100755
index f20b6b1..0000000
--- a/raylib/external/scripts/emcc-generate-js.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-BASE_DIR="${GOPATH}/src/github.com/gen2brain/raylib-go/raylib"
-EMCC_EXPORT="['_InitWindow','_CloseWindow','_WindowShouldClose','_IsWindowMinimized','_ToggleFullscreen','_SetWindowIcon','_SetWindowTitle','_SetWindowPosition','_SetWindowMonitor','_SetWindowMinSize','_GetScreenWidth','_GetScreenHeight','_ShowCursor','_HideCursor','_IsCursorHidden','_EnableCursor','_DisableCursor','_ClearBackground','_BeginDrawing','_EndDrawing','_Begin2dMode','_End2dMode','_Begin3dMode','_End3dMode','_BeginTextureMode','_EndTextureMode','_GetMouseRay','_GetWorldToScreen','_GetCameraMatrix','_SetTargetFPS','_GetFPS','_GetFrameTime','_GetHexValue','_GetColor','_ColorToFloat','_Vector3ToFloat','_MatrixToFloat','_Vector3Zero','_Vector3One','_MatrixIdentity','_ShowLogo','_SetConfigFlags','_TraceLog','_TakeScreenshot','_GetRandomValue','_StorageSaveValue','_StorageLoadValue','_IsKeyPressed','_IsKeyDown','_IsKeyReleased','_IsKeyUp','_GetKeyPressed','_SetExitKey','_IsGamepadAvailable','_IsGamepadName','_IsGamepadButtonPressed','_IsGamepadButtonDown','_IsGamepadButtonReleased','_IsGamepadButtonUp','_GetGamepadButtonPressed','_GetGamepadAxisCount','_GetGamepadAxisMovement','_IsMouseButtonPressed','_IsMouseButtonDown','_IsMouseButtonReleased','_IsMouseButtonUp','_GetMouseX','_GetMouseY','_GetMousePosition','_SetMousePosition','_GetMouseWheelMove','_GetTouchX','_GetTouchY','_GetTouchPosition','_SetGesturesEnabled','_IsGestureDetected','_GetGestureDetected','_GetTouchPointsCount','_GetGestureHoldDuration','_GetGestureDragVector','_GetGestureDragAngle','_GetGesturePinchVector','_GetGesturePinchAngle','_SetCameraMode','_UpdateCamera','_SetCameraPanControl','_SetCameraAltControl','_SetCameraSmoothZoomControl','_SetCameraMoveControls','_DrawPixel','_DrawPixelV','_DrawLine','_DrawLineV','_DrawLineEx','_DrawLineBezier','_DrawCircle','_DrawCircleGradient','_DrawCircleV','_DrawCircleLines','_DrawRectangle','_DrawRectangleRec','_DrawRectanglePro','_DrawRectangleGradientV','_DrawRectangleGradientH','_DrawRectangleGradientEx','_DrawRectangleV','_DrawRectangleLines','_DrawRectangleT','_DrawTriangle','_DrawTriangleLines','_DrawPoly','_DrawPolyEx','_DrawPolyExLines','_CheckCollisionRecs','_CheckCollisionCircles','_CheckCollisionCircleRec','_GetCollisionRec','_CheckCollisionPointRec','_CheckCollisionPointCircle','_CheckCollisionPointTriangle','_LoadImage','_LoadImageEx','_LoadImagePro','_LoadImageRaw','_LoadTexture','_LoadTextureFromImage','_LoadRenderTexture','_UnloadImage','_UnloadTexture','_UnloadRenderTexture','_GetImageData','_GetTextureData','_UpdateTexture','_SaveImageAs','_ImageToPOT','_ImageFormat','_ImageAlphaMask','_ImageDither','_ImageCopy','_ImageCrop','_ImageResize','_ImageResizeNN','_ImageText','_ImageTextEx','_ImageDraw','_ImageDrawText','_ImageDrawTextEx','_ImageFlipVertical','_ImageFlipHorizontal','_ImageColorTint','_ImageColorInvert','_ImageColorGrayscale','_ImageColorContrast','_ImageColorBrightness','_GenImageColor','_GenImageGradientV','_GenImageGradientH','_GenImageGradientRadial','_GenImageChecked','_GenImageWhiteNoise','_GenImagePerlinNoise','_GenImageCellular','_GenTextureMipmaps','_SetTextureFilter','_SetTextureWrap','_DrawTexture','_DrawTextureV','_DrawTextureEx','_DrawTextureRec','_DrawTexturePro','_GetDefaultFont','_LoadSpriteFont','_LoadSpriteFontEx','_UnloadSpriteFont','_DrawFPS','_DrawText','_DrawTextEx','_MeasureText','_MeasureTextEx','_DrawLine3D','_DrawCircle3D','_DrawCube','_DrawCubeV','_DrawCubeWires','_DrawCubeTexture','_DrawSphere','_DrawSphereEx','_DrawSphereWires','_DrawCylinder','_DrawCylinderWires','_DrawPlane','_DrawRay','_DrawGrid','_DrawGizmo','_LoadModel','_LoadModelFromMesh','_UnloadModel','_LoadMesh','_UnloadMesh','_GenMeshPlane','_GenMeshCube','_GenMeshSphere','_GenMeshHemiSphere','_GenMeshCylinder','_GenMeshTorus','_GenMeshKnot','_GenMeshHeightmap','_GenMeshCubicmap','_LoadMaterial','_LoadMaterialDefault','_UnloadMaterial','_DrawModel','_DrawModelEx','_DrawModelWires','_DrawModelWiresEx','_DrawBoundingBox','_DrawBillboard','_DrawBillboardRec','_CalculateBoundingBox','_CheckCollisionSpheres','_CheckCollisionBoxes','_CheckCollisionBoxSphere','_CheckCollisionRaySphere','_CheckCollisionRaySphereEx','_CheckCollisionRayBox','_GetCollisionRayMesh','_GetCollisionRayTriangle','_GetCollisionRayGround','_LoadText','_LoadShader','_UnloadShader','_GetShaderDefault','_GetTextureDefault','_GetShaderLocation','_SetShaderValue','_SetShaderValuei','_SetShaderValueMatrix','_SetMatrixProjection','_SetMatrixModelview','_GenTextureCubemap','_GenTextureIrradiance','_GenTexturePrefilter','_GenTextureBRDF','_BeginShaderMode','_EndShaderMode','_BeginBlendMode','_EndBlendMode','_GetVrDeviceInfo','_InitVrSimulator','_CloseVrSimulator','_IsVrSimulatorReady','_SetVrDistortionShader','_UpdateVrTracking','_ToggleVrMode','_BeginVrDrawing','_EndVrDrawing','_InitAudioDevice','_CloseAudioDevice','_IsAudioDeviceReady','_SetMasterVolume','_LoadWave','_LoadWaveEx','_LoadSound','_LoadSoundFromWave','_UpdateSound','_UnloadWave','_UnloadSound','_PlaySound','_PauseSound','_ResumeSound','_StopSound','_IsSoundPlaying','_SetSoundVolume','_SetSoundPitch','_WaveFormat','_WaveCopy','_WaveCrop','_GetWaveData','_LoadMusicStream','_UnloadMusicStream','_PlayMusicStream','_UpdateMusicStream','_StopMusicStream','_PauseMusicStream','_ResumeMusicStream','_IsMusicPlaying','_SetMusicVolume','_SetMusicPitch','_SetMusicLoopCount','_GetMusicTimeLength','_GetMusicTimePlayed','_InitAudioStream','_UpdateAudioStream','_CloseAudioStream','_IsAudioBufferProcessed','_PlayAudioStream','_PauseAudioStream','_ResumeAudioStream','_IsAudioStreamPlaying','_StopAudioStream','_SetAudioStreamVolume','_SetAudioStreamPitch','_emscripten_set_main_loop']"
-RAYLIB_SRC=( "audio.c" "core.c" "mini_al.c" "models.c" "rlgl.c" "shapes.c" "text.c" "textures.c" "utils.c" "external/stb_vorbis.c" )
-RAYLIB_OBJ=( "audio.o" "core.o" "mini_al.o" "models.o" "rlgl.o" "shapes.o" "text.o" "textures.o" "utils.o" "external/stb_vorbis.o" )
-
-for i in "${RAYLIB_SRC[@]}"; do
- emcc "${i}" -o "${i/.c}.o" -O1 -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Wno-unused-function -Wno-unused-variable -Iexternal -Iexternal/glfw/include -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2
-done
-
-emcc `echo "${RAYLIB_OBJ[*]}"` -o raylib.js -g3 -s USE_GLFW=3 -s EXPORTED_FUNCTIONS=$EMCC_EXPORT
-
-sed -i "/Module\['dynCall_vi'\]/c\ func(arg);" raylib.js
-sed -i "/Module\['dynCall_v'\]/c\ func();" raylib.js
-
-rm -f "${BASE_DIR}"/*.o "${BASE_DIR}"/external/*.o
diff --git a/raylib/external/web/index.html b/raylib/external/web/index.html
deleted file mode 100644
index f61ee38..0000000
--- a/raylib/external/web/index.html
+++ /dev/null
@@ -1,240 +0,0 @@
-
-
-
-
-
-
- raylib-go HTML5
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/raylib/external/web/raylib.js b/raylib/external/web/raylib.js
deleted file mode 100644
index 9d28ea0..0000000
--- a/raylib/external/web/raylib.js
+++ /dev/null
@@ -1,105109 +0,0 @@
-// The Module object: Our interface to the outside world. We import
-// and export values on it, and do the work to get that through
-// closure compiler if necessary. There are various ways Module can be used:
-// 1. Not defined. We create it here
-// 2. A function parameter, function(Module) { ..generated code.. }
-// 3. pre-run appended it, var Module = {}; ..generated code..
-// 4. External script tag defines var Module.
-// We need to do an eval in order to handle the closure compiler
-// case, where this code here is minified but Module was defined
-// elsewhere (e.g. case 4 above). We also need to check if Module
-// already exists (e.g. case 3 above).
-// Note that if you want to run closure, and also to use Module
-// after the generated code, you will need to define var Module = {};
-// before the code. Then that object will be used in the code, and you
-// can continue to use Module afterwards as well.
-var Module;
-if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
-
-// Sometimes an existing Module object exists with properties
-// meant to overwrite the default module functionality. Here
-// we collect those properties and reapply _after_ we configure
-// the current environment's defaults to avoid having to be so
-// defensive during initialization.
-var moduleOverrides = {};
-for (var key in Module) {
- if (Module.hasOwnProperty(key)) {
- moduleOverrides[key] = Module[key];
- }
-}
-
-// The environment setup code below is customized to use Module.
-// *** Environment setup code ***
-var ENVIRONMENT_IS_WEB = false;
-var ENVIRONMENT_IS_WORKER = false;
-var ENVIRONMENT_IS_NODE = false;
-var ENVIRONMENT_IS_SHELL = false;
-
-// Three configurations we can be running in:
-// 1) We could be the application main() thread running in the main JS UI thread. (ENVIRONMENT_IS_WORKER == false and ENVIRONMENT_IS_PTHREAD == false)
-// 2) We could be the application main() thread proxied to worker. (with Emscripten -s PROXY_TO_WORKER=1) (ENVIRONMENT_IS_WORKER == true, ENVIRONMENT_IS_PTHREAD == false)
-// 3) We could be an application pthread running in a worker. (ENVIRONMENT_IS_WORKER == true and ENVIRONMENT_IS_PTHREAD == true)
-
-if (Module['ENVIRONMENT']) {
- if (Module['ENVIRONMENT'] === 'WEB') {
- ENVIRONMENT_IS_WEB = true;
- } else if (Module['ENVIRONMENT'] === 'WORKER') {
- ENVIRONMENT_IS_WORKER = true;
- } else if (Module['ENVIRONMENT'] === 'NODE') {
- ENVIRONMENT_IS_NODE = true;
- } else if (Module['ENVIRONMENT'] === 'SHELL') {
- ENVIRONMENT_IS_SHELL = true;
- } else {
- throw new Error('The provided Module[\'ENVIRONMENT\'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.');
- }
-} else {
- ENVIRONMENT_IS_WEB = typeof window === 'object';
- ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
- ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function' && !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER;
- ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
-}
-
-
-if (ENVIRONMENT_IS_NODE) {
- // Expose functionality in the same simple way that the shells work
- // Note that we pollute the global namespace here, otherwise we break in node
- if (!Module['print']) Module['print'] = console.log;
- if (!Module['printErr']) Module['printErr'] = console.warn;
-
- var nodeFS;
- var nodePath;
-
- Module['read'] = function shell_read(filename, binary) {
- if (!nodeFS) nodeFS = require('fs');
- if (!nodePath) nodePath = require('path');
- filename = nodePath['normalize'](filename);
- var ret = nodeFS['readFileSync'](filename);
- return binary ? ret : ret.toString();
- };
-
- Module['readBinary'] = function readBinary(filename) {
- var ret = Module['read'](filename, true);
- if (!ret.buffer) {
- ret = new Uint8Array(ret);
- }
- assert(ret.buffer);
- return ret;
- };
-
- Module['load'] = function load(f) {
- globalEval(read(f));
- };
-
- if (!Module['thisProgram']) {
- if (process['argv'].length > 1) {
- Module['thisProgram'] = process['argv'][1].replace(/\\/g, '/');
- } else {
- Module['thisProgram'] = 'unknown-program';
- }
- }
-
- Module['arguments'] = process['argv'].slice(2);
-
- if (typeof module !== 'undefined') {
- module['exports'] = Module;
- }
-
- process['on']('uncaughtException', function(ex) {
- // suppress ExitStatus exceptions from showing an error
- if (!(ex instanceof ExitStatus)) {
- throw ex;
- }
- });
-
- Module['inspect'] = function () { return '[Emscripten Module object]'; };
-}
-else if (ENVIRONMENT_IS_SHELL) {
- if (!Module['print']) Module['print'] = print;
- if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
-
- if (typeof read != 'undefined') {
- Module['read'] = read;
- } else {
- Module['read'] = function shell_read() { throw 'no read() available' };
- }
-
- Module['readBinary'] = function readBinary(f) {
- if (typeof readbuffer === 'function') {
- return new Uint8Array(readbuffer(f));
- }
- var data = read(f, 'binary');
- assert(typeof data === 'object');
- return data;
- };
-
- if (typeof scriptArgs != 'undefined') {
- Module['arguments'] = scriptArgs;
- } else if (typeof arguments != 'undefined') {
- Module['arguments'] = arguments;
- }
-
- if (typeof quit === 'function') {
- Module['quit'] = function(status, toThrow) {
- quit(status);
- }
- }
-
-}
-else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
- Module['read'] = function shell_read(url) {
- var xhr = new XMLHttpRequest();
- xhr.open('GET', url, false);
- xhr.send(null);
- return xhr.responseText;
- };
-
- if (ENVIRONMENT_IS_WORKER) {
- Module['readBinary'] = function readBinary(url) {
- var xhr = new XMLHttpRequest();
- xhr.open('GET', url, false);
- xhr.responseType = 'arraybuffer';
- xhr.send(null);
- return new Uint8Array(xhr.response);
- };
- }
-
- Module['readAsync'] = function readAsync(url, onload, onerror) {
- var xhr = new XMLHttpRequest();
- xhr.open('GET', url, true);
- xhr.responseType = 'arraybuffer';
- xhr.onload = function xhr_onload() {
- if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
- onload(xhr.response);
- } else {
- onerror();
- }
- };
- xhr.onerror = onerror;
- xhr.send(null);
- };
-
- if (typeof arguments != 'undefined') {
- Module['arguments'] = arguments;
- }
-
- if (typeof console !== 'undefined') {
- if (!Module['print']) Module['print'] = function shell_print(x) {
- console.log(x);
- };
- if (!Module['printErr']) Module['printErr'] = function shell_printErr(x) {
- console.warn(x);
- };
- } else {
- // Probably a worker, and without console.log. We can do very little here...
- var TRY_USE_DUMP = false;
- if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
- dump(x);
- }) : (function(x) {
- // self.postMessage(x); // enable this if you want stdout to be sent as messages
- }));
- }
-
- if (ENVIRONMENT_IS_WORKER) {
- Module['load'] = importScripts;
- }
-
- if (typeof Module['setWindowTitle'] === 'undefined') {
- Module['setWindowTitle'] = function(title) { document.title = title };
- }
-}
-else {
- // Unreachable because SHELL is dependant on the others
- throw 'Unknown runtime environment. Where are we?';
-}
-
-function globalEval(x) {
- eval.call(null, x);
-}
-if (!Module['load'] && Module['read']) {
- Module['load'] = function load(f) {
- globalEval(Module['read'](f));
- };
-}
-if (!Module['print']) {
- Module['print'] = function(){};
-}
-if (!Module['printErr']) {
- Module['printErr'] = Module['print'];
-}
-if (!Module['arguments']) {
- Module['arguments'] = [];
-}
-if (!Module['thisProgram']) {
- Module['thisProgram'] = './this.program';
-}
-if (!Module['quit']) {
- Module['quit'] = function(status, toThrow) {
- throw toThrow;
- }
-}
-
-// *** Environment setup code ***
-
-// Closure helpers
-Module.print = Module['print'];
-Module.printErr = Module['printErr'];
-
-// Callbacks
-Module['preRun'] = [];
-Module['postRun'] = [];
-
-// Merge back in the overrides
-for (var key in moduleOverrides) {
- if (moduleOverrides.hasOwnProperty(key)) {
- Module[key] = moduleOverrides[key];
- }
-}
-// Free the object hierarchy contained in the overrides, this lets the GC
-// reclaim data used e.g. in memoryInitializerRequest, which is a large typed array.
-moduleOverrides = undefined;
-
-
-
-// {{PREAMBLE_ADDITIONS}}
-
-// === Preamble library stuff ===
-
-// Documentation for the public APIs defined in this file must be updated in:
-// site/source/docs/api_reference/preamble.js.rst
-// A prebuilt local version of the documentation is available at:
-// site/build/text/docs/api_reference/preamble.js.txt
-// You can also build docs locally as HTML or other formats in site/
-// An online HTML version (which may be of a different version of Emscripten)
-// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
-
-//========================================
-// Runtime code shared with compiler
-//========================================
-
-var Runtime = {
- setTempRet0: function (value) {
- tempRet0 = value;
- return value;
- },
- getTempRet0: function () {
- return tempRet0;
- },
- stackSave: function () {
- return STACKTOP;
- },
- stackRestore: function (stackTop) {
- STACKTOP = stackTop;
- },
- getNativeTypeSize: function (type) {
- switch (type) {
- case 'i1': case 'i8': return 1;
- case 'i16': return 2;
- case 'i32': return 4;
- case 'i64': return 8;
- case 'float': return 4;
- case 'double': return 8;
- default: {
- if (type[type.length-1] === '*') {
- return Runtime.QUANTUM_SIZE; // A pointer
- } else if (type[0] === 'i') {
- var bits = parseInt(type.substr(1));
- assert(bits % 8 === 0);
- return bits/8;
- } else {
- return 0;
- }
- }
- }
- },
- getNativeFieldSize: function (type) {
- return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
- },
- STACK_ALIGN: 16,
- prepVararg: function (ptr, type) {
- if (type === 'double' || type === 'i64') {
- // move so the load is aligned
- if (ptr & 7) {
- assert((ptr & 7) === 4);
- ptr += 4;
- }
- } else {
- assert((ptr & 3) === 0);
- }
- return ptr;
- },
- getAlignSize: function (type, size, vararg) {
- // we align i64s and doubles on 64-bit boundaries, unlike x86
- if (!vararg && (type == 'i64' || type == 'double')) return 8;
- if (!type) return Math.min(size, 8); // align structures internally to 64 bits
- return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
- },
- dynCall: function (sig, ptr, args) {
- if (args && args.length) {
- assert(args.length == sig.length-1);
- assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\'');
- return Module['dynCall_' + sig].apply(null, [ptr].concat(args));
- } else {
- assert(sig.length == 1);
- assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\'');
- return Module['dynCall_' + sig].call(null, ptr);
- }
- },
- functionPointers: [],
- addFunction: function (func) {
- for (var i = 0; i < Runtime.functionPointers.length; i++) {
- if (!Runtime.functionPointers[i]) {
- Runtime.functionPointers[i] = func;
- return 2*(1 + i);
- }
- }
- throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
- },
- removeFunction: function (index) {
- Runtime.functionPointers[(index-2)/2] = null;
- },
- warnOnce: function (text) {
- if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
- if (!Runtime.warnOnce.shown[text]) {
- Runtime.warnOnce.shown[text] = 1;
- Module.printErr(text);
- }
- },
- funcWrappers: {},
- getFuncWrapper: function (func, sig) {
- if (!func) return; // on null pointer, return undefined
- assert(sig);
- if (!Runtime.funcWrappers[sig]) {
- Runtime.funcWrappers[sig] = {};
- }
- var sigCache = Runtime.funcWrappers[sig];
- if (!sigCache[func]) {
- // optimize away arguments usage in common cases
- if (sig.length === 1) {
- sigCache[func] = function dynCall_wrapper() {
- return Runtime.dynCall(sig, func);
- };
- } else if (sig.length === 2) {
- sigCache[func] = function dynCall_wrapper(arg) {
- return Runtime.dynCall(sig, func, [arg]);
- };
- } else {
- // general case
- sigCache[func] = function dynCall_wrapper() {
- return Runtime.dynCall(sig, func, Array.prototype.slice.call(arguments));
- };
- }
- }
- return sigCache[func];
- },
- getCompilerSetting: function (name) {
- throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
- },
- stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+15)&-16);(assert((((STACKTOP|0) < (STACK_MAX|0))|0))|0); return ret; },
- staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + (assert(!staticSealed),size))|0;STATICTOP = (((STATICTOP)+15)&-16); return ret; },
- dynamicAlloc: function (size) { assert(DYNAMICTOP_PTR);var ret = HEAP32[DYNAMICTOP_PTR>>2];var end = (((ret + size + 15)|0) & -16);HEAP32[DYNAMICTOP_PTR>>2] = end;if (end >= TOTAL_MEMORY) {var success = enlargeMemory();if (!success) {HEAP32[DYNAMICTOP_PTR>>2] = ret;return 0;}}return ret;},
- alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 16))*(quantum ? quantum : 16); return ret; },
- makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*4294967296.0)) : ((+((low>>>0)))+((+((high|0)))*4294967296.0))); return ret; },
- GLOBAL_BASE: 8,
- QUANTUM_SIZE: 4,
- __dummy__: 0
-}
-
-
-
-Module["Runtime"] = Runtime;
-
-
-
-//========================================
-// Runtime essentials
-//========================================
-
-var ABORT = 0; // whether we are quitting the application. no code should run after this. set in exit() and abort()
-var EXITSTATUS = 0;
-
-/** @type {function(*, string=)} */
-function assert(condition, text) {
- if (!condition) {
- abort('Assertion failed: ' + text);
- }
-}
-
-var globalScope = this;
-
-// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
-function getCFunc(ident) {
- var func = Module['_' + ident]; // closure exported function
- if (!func) {
- try { func = eval('_' + ident); } catch(e) {}
- }
- assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
- return func;
-}
-
-var cwrap, ccall;
-(function(){
- var JSfuncs = {
- // Helpers for cwrap -- it can't refer to Runtime directly because it might
- // be renamed by closure, instead it calls JSfuncs['stackSave'].body to find
- // out what the minified function name is.
- 'stackSave': function() {
- Runtime.stackSave()
- },
- 'stackRestore': function() {
- Runtime.stackRestore()
- },
- // type conversion from js to c
- 'arrayToC' : function(arr) {
- var ret = Runtime.stackAlloc(arr.length);
- writeArrayToMemory(arr, ret);
- return ret;
- },
- 'stringToC' : function(str) {
- var ret = 0;
- if (str !== null && str !== undefined && str !== 0) { // null string
- // at most 4 bytes per UTF-8 code point, +1 for the trailing '\0'
- var len = (str.length << 2) + 1;
- ret = Runtime.stackAlloc(len);
- stringToUTF8(str, ret, len);
- }
- return ret;
- }
- };
- // For fast lookup of conversion functions
- var toC = {'string' : JSfuncs['stringToC'], 'array' : JSfuncs['arrayToC']};
-
- // C calling interface.
- ccall = function ccallFunc(ident, returnType, argTypes, args, opts) {
- var func = getCFunc(ident);
- var cArgs = [];
- var stack = 0;
- assert(returnType !== 'array', 'Return type should not be "array".');
- if (args) {
- for (var i = 0; i < args.length; i++) {
- var converter = toC[argTypes[i]];
- if (converter) {
- if (stack === 0) stack = Runtime.stackSave();
- cArgs[i] = converter(args[i]);
- } else {
- cArgs[i] = args[i];
- }
- }
- }
- var ret = func.apply(null, cArgs);
- if ((!opts || !opts.async) && typeof EmterpreterAsync === 'object') {
- assert(!EmterpreterAsync.state, 'cannot start async op with normal JS calling ccall');
- }
- if (opts && opts.async) assert(!returnType, 'async ccalls cannot return values');
- if (returnType === 'string') ret = Pointer_stringify(ret);
- if (stack !== 0) {
- if (opts && opts.async) {
- EmterpreterAsync.asyncFinalizers.push(function() {
- Runtime.stackRestore(stack);
- });
- return;
- }
- Runtime.stackRestore(stack);
- }
- return ret;
- }
-
- var sourceRegex = /^function\s*[a-zA-Z$_0-9]*\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;
- function parseJSFunc(jsfunc) {
- // Match the body and the return value of a javascript function source
- var parsed = jsfunc.toString().match(sourceRegex).slice(1);
- return {arguments : parsed[0], body : parsed[1], returnValue: parsed[2]}
- }
-
- // sources of useful functions. we create this lazily as it can trigger a source decompression on this entire file
- var JSsource = null;
- function ensureJSsource() {
- if (!JSsource) {
- JSsource = {};
- for (var fun in JSfuncs) {
- if (JSfuncs.hasOwnProperty(fun)) {
- // Elements of toCsource are arrays of three items:
- // the code, and the return value
- JSsource[fun] = parseJSFunc(JSfuncs[fun]);
- }
- }
- }
- }
-
- cwrap = function cwrap(ident, returnType, argTypes) {
- argTypes = argTypes || [];
- var cfunc = getCFunc(ident);
- // When the function takes numbers and returns a number, we can just return
- // the original function
- var numericArgs = argTypes.every(function(type){ return type === 'number'});
- var numericRet = (returnType !== 'string');
- if ( numericRet && numericArgs) {
- return cfunc;
- }
- // Creation of the arguments list (["$1","$2",...,"$nargs"])
- var argNames = argTypes.map(function(x,i){return '$'+i});
- var funcstr = "(function(" + argNames.join(',') + ") {";
- var nargs = argTypes.length;
- if (!numericArgs) {
- // Generate the code needed to convert the arguments from javascript
- // values to pointers
- ensureJSsource();
- funcstr += 'var stack = ' + JSsource['stackSave'].body + ';';
- for (var i = 0; i < nargs; i++) {
- var arg = argNames[i], type = argTypes[i];
- if (type === 'number') continue;
- var convertCode = JSsource[type + 'ToC']; // [code, return]
- funcstr += 'var ' + convertCode.arguments + ' = ' + arg + ';';
- funcstr += convertCode.body + ';';
- funcstr += arg + '=(' + convertCode.returnValue + ');';
- }
- }
-
- // When the code is compressed, the name of cfunc is not literally 'cfunc' anymore
- var cfuncname = parseJSFunc(function(){return cfunc}).returnValue;
- // Call the function
- funcstr += 'var ret = ' + cfuncname + '(' + argNames.join(',') + ');';
- if (!numericRet) { // Return type can only by 'string' or 'number'
- // Convert the result to a string
- var strgfy = parseJSFunc(function(){return Pointer_stringify}).returnValue;
- funcstr += 'ret = ' + strgfy + '(ret);';
- }
- funcstr += "if (typeof EmterpreterAsync === 'object') { assert(!EmterpreterAsync.state, 'cannot start async op with normal JS calling cwrap') }";
- if (!numericArgs) {
- // If we had a stack, restore it
- ensureJSsource();
- funcstr += JSsource['stackRestore'].body.replace('()', '(stack)') + ';';
- }
- funcstr += 'return ret})';
- return eval(funcstr);
- };
-})();
-Module["ccall"] = ccall;
-Module["cwrap"] = cwrap;
-
-/** @type {function(number, number, string, boolean=)} */
-function setValue(ptr, value, type, noSafe) {
- type = type || 'i8';
- if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
- switch(type) {
- case 'i1': HEAP8[((ptr)>>0)]=value; break;
- case 'i8': HEAP8[((ptr)>>0)]=value; break;
- case 'i16': HEAP16[((ptr)>>1)]=value; break;
- case 'i32': HEAP32[((ptr)>>2)]=value; break;
- case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? ((Math_min((+(Math_floor((tempDouble)/4294967296.0))), 4294967295.0))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
- case 'float': HEAPF32[((ptr)>>2)]=value; break;
- case 'double': HEAPF64[((ptr)>>3)]=value; break;
- default: abort('invalid type for setValue: ' + type);
- }
-}
-Module["setValue"] = setValue;
-
-/** @type {function(number, string, boolean=)} */
-function getValue(ptr, type, noSafe) {
- type = type || 'i8';
- if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
- switch(type) {
- case 'i1': return HEAP8[((ptr)>>0)];
- case 'i8': return HEAP8[((ptr)>>0)];
- case 'i16': return HEAP16[((ptr)>>1)];
- case 'i32': return HEAP32[((ptr)>>2)];
- case 'i64': return HEAP32[((ptr)>>2)];
- case 'float': return HEAPF32[((ptr)>>2)];
- case 'double': return HEAPF64[((ptr)>>3)];
- default: abort('invalid type for setValue: ' + type);
- }
- return null;
-}
-Module["getValue"] = getValue;
-
-var ALLOC_NORMAL = 0; // Tries to use _malloc()
-var ALLOC_STACK = 1; // Lives for the duration of the current function call
-var ALLOC_STATIC = 2; // Cannot be freed
-var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
-var ALLOC_NONE = 4; // Do not allocate
-Module["ALLOC_NORMAL"] = ALLOC_NORMAL;
-Module["ALLOC_STACK"] = ALLOC_STACK;
-Module["ALLOC_STATIC"] = ALLOC_STATIC;
-Module["ALLOC_DYNAMIC"] = ALLOC_DYNAMIC;
-Module["ALLOC_NONE"] = ALLOC_NONE;
-
-// allocate(): This is for internal use. You can use it yourself as well, but the interface
-// is a little tricky (see docs right below). The reason is that it is optimized
-// for multiple syntaxes to save space in generated code. So you should
-// normally not use allocate(), and instead allocate memory using _malloc(),
-// initialize it with setValue(), and so forth.
-// @slab: An array of data, or a number. If a number, then the size of the block to allocate,
-// in *bytes* (note that this is sometimes confusing: the next parameter does not
-// affect this!)
-// @types: Either an array of types, one for each byte (or 0 if no type at that position),
-// or a single type which is used for the entire block. This only matters if there
-// is initial data - if @slab is a number, then this does not matter at all and is
-// ignored.
-// @allocator: How to allocate memory, see ALLOC_*
-/** @type {function((TypedArray|Array|number), string, number, number=)} */
-function allocate(slab, types, allocator, ptr) {
- var zeroinit, size;
- if (typeof slab === 'number') {
- zeroinit = true;
- size = slab;
- } else {
- zeroinit = false;
- size = slab.length;
- }
-
- var singleType = typeof types === 'string' ? types : null;
-
- var ret;
- if (allocator == ALLOC_NONE) {
- ret = ptr;
- } else {
- ret = [typeof _malloc === 'function' ? _malloc : Runtime.staticAlloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
- }
-
- if (zeroinit) {
- var ptr = ret, stop;
- assert((ret & 3) == 0);
- stop = ret + (size & ~3);
- for (; ptr < stop; ptr += 4) {
- HEAP32[((ptr)>>2)]=0;
- }
- stop = ret + size;
- while (ptr < stop) {
- HEAP8[((ptr++)>>0)]=0;
- }
- return ret;
- }
-
- if (singleType === 'i8') {
- if (slab.subarray || slab.slice) {
- HEAPU8.set(/** @type {!Uint8Array} */ (slab), ret);
- } else {
- HEAPU8.set(new Uint8Array(slab), ret);
- }
- return ret;
- }
-
- var i = 0, type, typeSize, previousType;
- while (i < size) {
- var curr = slab[i];
-
- if (typeof curr === 'function') {
- curr = Runtime.getFunctionIndex(curr);
- }
-
- type = singleType || types[i];
- if (type === 0) {
- i++;
- continue;
- }
- assert(type, 'Must know what type to store in allocate!');
-
- if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
-
- setValue(ret+i, curr, type);
-
- // no need to look up size unless type changes, so cache it
- if (previousType !== type) {
- typeSize = Runtime.getNativeTypeSize(type);
- previousType = type;
- }
- i += typeSize;
- }
-
- return ret;
-}
-Module["allocate"] = allocate;
-
-// Allocate memory during any stage of startup - static memory early on, dynamic memory later, malloc when ready
-function getMemory(size) {
- if (!staticSealed) return Runtime.staticAlloc(size);
- if (!runtimeInitialized) return Runtime.dynamicAlloc(size);
- return _malloc(size);
-}
-Module["getMemory"] = getMemory;
-
-/** @type {function(number, number=)} */
-function Pointer_stringify(ptr, length) {
- if (length === 0 || !ptr) return '';
- // TODO: use TextDecoder
- // Find the length, and check for UTF while doing so
- var hasUtf = 0;
- var t;
- var i = 0;
- while (1) {
- assert(ptr + i < TOTAL_MEMORY);
- t = HEAPU8[(((ptr)+(i))>>0)];
- hasUtf |= t;
- if (t == 0 && !length) break;
- i++;
- if (length && i == length) break;
- }
- if (!length) length = i;
-
- var ret = '';
-
- if (hasUtf < 128) {
- var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
- var curr;
- while (length > 0) {
- curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
- ret = ret ? ret + curr : curr;
- ptr += MAX_CHUNK;
- length -= MAX_CHUNK;
- }
- return ret;
- }
- return Module['UTF8ToString'](ptr);
-}
-Module["Pointer_stringify"] = Pointer_stringify;
-
-// Given a pointer 'ptr' to a null-terminated ASCII-encoded string in the emscripten HEAP, returns
-// a copy of that string as a Javascript String object.
-
-function AsciiToString(ptr) {
- var str = '';
- while (1) {
- var ch = HEAP8[((ptr++)>>0)];
- if (!ch) return str;
- str += String.fromCharCode(ch);
- }
-}
-Module["AsciiToString"] = AsciiToString;
-
-// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
-// null-terminated and encoded in ASCII form. The copy will require at most str.length+1 bytes of space in the HEAP.
-
-function stringToAscii(str, outPtr) {
- return writeAsciiToMemory(str, outPtr, false);
-}
-Module["stringToAscii"] = stringToAscii;
-
-// Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the given array that contains uint8 values, returns
-// a copy of that string as a Javascript String object.
-
-var UTF8Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined;
-function UTF8ArrayToString(u8Array, idx) {
- var endPtr = idx;
- // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
- // Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
- while (u8Array[endPtr]) ++endPtr;
-
- if (endPtr - idx > 16 && u8Array.subarray && UTF8Decoder) {
- return UTF8Decoder.decode(u8Array.subarray(idx, endPtr));
- } else {
- var u0, u1, u2, u3, u4, u5;
-
- var str = '';
- while (1) {
- // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description and https://www.ietf.org/rfc/rfc2279.txt and https://tools.ietf.org/html/rfc3629
- u0 = u8Array[idx++];
- if (!u0) return str;
- if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
- u1 = u8Array[idx++] & 63;
- if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
- u2 = u8Array[idx++] & 63;
- if ((u0 & 0xF0) == 0xE0) {
- u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
- } else {
- u3 = u8Array[idx++] & 63;
- if ((u0 & 0xF8) == 0xF0) {
- u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | u3;
- } else {
- u4 = u8Array[idx++] & 63;
- if ((u0 & 0xFC) == 0xF8) {
- u0 = ((u0 & 3) << 24) | (u1 << 18) | (u2 << 12) | (u3 << 6) | u4;
- } else {
- u5 = u8Array[idx++] & 63;
- u0 = ((u0 & 1) << 30) | (u1 << 24) | (u2 << 18) | (u3 << 12) | (u4 << 6) | u5;
- }
- }
- }
- if (u0 < 0x10000) {
- str += String.fromCharCode(u0);
- } else {
- var ch = u0 - 0x10000;
- str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
- }
- }
- }
-}
-Module["UTF8ArrayToString"] = UTF8ArrayToString;
-
-// Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the emscripten HEAP, returns
-// a copy of that string as a Javascript String object.
-
-function UTF8ToString(ptr) {
- return UTF8ArrayToString(HEAPU8,ptr);
-}
-Module["UTF8ToString"] = UTF8ToString;
-
-// Copies the given Javascript String object 'str' to the given byte array at address 'outIdx',
-// encoded in UTF8 form and null-terminated. The copy will require at most str.length*4+1 bytes of space in the HEAP.
-// Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write.
-// Parameters:
-// str: the Javascript string to copy.
-// outU8Array: the array to copy to. Each index in this array is assumed to be one 8-byte element.
-// outIdx: The starting offset in the array to begin the copying.
-// maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
-// terminator, i.e. if maxBytesToWrite=1, only the null terminator will be written and nothing else.
-// maxBytesToWrite=0 does not write any bytes to the output, not even the null terminator.
-// Returns the number of bytes written, EXCLUDING the null terminator.
-
-function stringToUTF8Array(str, outU8Array, outIdx, maxBytesToWrite) {
- if (!(maxBytesToWrite > 0)) // Parameter maxBytesToWrite is not optional. Negative values, 0, null, undefined and false each don't write out any bytes.
- return 0;
-
- var startIdx = outIdx;
- var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
- for (var i = 0; i < str.length; ++i) {
- // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
- // See http://unicode.org/faq/utf_bom.html#utf16-3
- // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description and https://www.ietf.org/rfc/rfc2279.txt and https://tools.ietf.org/html/rfc3629
- var u = str.charCodeAt(i); // possibly a lead surrogate
- if (u >= 0xD800 && u <= 0xDFFF) u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt(++i) & 0x3FF);
- if (u <= 0x7F) {
- if (outIdx >= endIdx) break;
- outU8Array[outIdx++] = u;
- } else if (u <= 0x7FF) {
- if (outIdx + 1 >= endIdx) break;
- outU8Array[outIdx++] = 0xC0 | (u >> 6);
- outU8Array[outIdx++] = 0x80 | (u & 63);
- } else if (u <= 0xFFFF) {
- if (outIdx + 2 >= endIdx) break;
- outU8Array[outIdx++] = 0xE0 | (u >> 12);
- outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63);
- outU8Array[outIdx++] = 0x80 | (u & 63);
- } else if (u <= 0x1FFFFF) {
- if (outIdx + 3 >= endIdx) break;
- outU8Array[outIdx++] = 0xF0 | (u >> 18);
- outU8Array[outIdx++] = 0x80 | ((u >> 12) & 63);
- outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63);
- outU8Array[outIdx++] = 0x80 | (u & 63);
- } else if (u <= 0x3FFFFFF) {
- if (outIdx + 4 >= endIdx) break;
- outU8Array[outIdx++] = 0xF8 | (u >> 24);
- outU8Array[outIdx++] = 0x80 | ((u >> 18) & 63);
- outU8Array[outIdx++] = 0x80 | ((u >> 12) & 63);
- outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63);
- outU8Array[outIdx++] = 0x80 | (u & 63);
- } else {
- if (outIdx + 5 >= endIdx) break;
- outU8Array[outIdx++] = 0xFC | (u >> 30);
- outU8Array[outIdx++] = 0x80 | ((u >> 24) & 63);
- outU8Array[outIdx++] = 0x80 | ((u >> 18) & 63);
- outU8Array[outIdx++] = 0x80 | ((u >> 12) & 63);
- outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63);
- outU8Array[outIdx++] = 0x80 | (u & 63);
- }
- }
- // Null-terminate the pointer to the buffer.
- outU8Array[outIdx] = 0;
- return outIdx - startIdx;
-}
-Module["stringToUTF8Array"] = stringToUTF8Array;
-
-// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
-// null-terminated and encoded in UTF8 form. The copy will require at most str.length*4+1 bytes of space in the HEAP.
-// Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write.
-// Returns the number of bytes written, EXCLUDING the null terminator.
-
-function stringToUTF8(str, outPtr, maxBytesToWrite) {
- assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
- return stringToUTF8Array(str, HEAPU8,outPtr, maxBytesToWrite);
-}
-Module["stringToUTF8"] = stringToUTF8;
-
-// Returns the number of bytes the given Javascript string takes if encoded as a UTF8 byte array, EXCLUDING the null terminator byte.
-
-function lengthBytesUTF8(str) {
- var len = 0;
- for (var i = 0; i < str.length; ++i) {
- // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
- // See http://unicode.org/faq/utf_bom.html#utf16-3
- var u = str.charCodeAt(i); // possibly a lead surrogate
- if (u >= 0xD800 && u <= 0xDFFF) u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt(++i) & 0x3FF);
- if (u <= 0x7F) {
- ++len;
- } else if (u <= 0x7FF) {
- len += 2;
- } else if (u <= 0xFFFF) {
- len += 3;
- } else if (u <= 0x1FFFFF) {
- len += 4;
- } else if (u <= 0x3FFFFFF) {
- len += 5;
- } else {
- len += 6;
- }
- }
- return len;
-}
-Module["lengthBytesUTF8"] = lengthBytesUTF8;
-
-// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
-// a copy of that string as a Javascript String object.
-
-var UTF16Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-16le') : undefined;
-function UTF16ToString(ptr) {
- assert(ptr % 2 == 0, 'Pointer passed to UTF16ToString must be aligned to two bytes!');
- var endPtr = ptr;
- // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
- // Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
- var idx = endPtr >> 1;
- while (HEAP16[idx]) ++idx;
- endPtr = idx << 1;
-
- if (endPtr - ptr > 32 && UTF16Decoder) {
- return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
- } else {
- var i = 0;
-
- var str = '';
- while (1) {
- var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
- if (codeUnit == 0) return str;
- ++i;
- // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
- str += String.fromCharCode(codeUnit);
- }
- }
-}
-
-
-// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
-// null-terminated and encoded in UTF16 form. The copy will require at most str.length*4+2 bytes of space in the HEAP.
-// Use the function lengthBytesUTF16() to compute the exact number of bytes (excluding null terminator) that this function will write.
-// Parameters:
-// str: the Javascript string to copy.
-// outPtr: Byte address in Emscripten HEAP where to write the string to.
-// maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
-// terminator, i.e. if maxBytesToWrite=2, only the null terminator will be written and nothing else.
-// maxBytesToWrite<2 does not write any bytes to the output, not even the null terminator.
-// Returns the number of bytes written, EXCLUDING the null terminator.
-
-function stringToUTF16(str, outPtr, maxBytesToWrite) {
- assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!');
- assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
- // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
- if (maxBytesToWrite === undefined) {
- maxBytesToWrite = 0x7FFFFFFF;
- }
- if (maxBytesToWrite < 2) return 0;
- maxBytesToWrite -= 2; // Null terminator.
- var startPtr = outPtr;
- var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length;
- for (var i = 0; i < numCharsToWrite; ++i) {
- // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
- var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
- HEAP16[((outPtr)>>1)]=codeUnit;
- outPtr += 2;
- }
- // Null-terminate the pointer to the HEAP.
- HEAP16[((outPtr)>>1)]=0;
- return outPtr - startPtr;
-}
-
-
-// Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
-
-function lengthBytesUTF16(str) {
- return str.length*2;
-}
-
-
-function UTF32ToString(ptr) {
- assert(ptr % 4 == 0, 'Pointer passed to UTF32ToString must be aligned to four bytes!');
- var i = 0;
-
- var str = '';
- while (1) {
- var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
- if (utf32 == 0)
- return str;
- ++i;
- // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
- // See http://unicode.org/faq/utf_bom.html#utf16-3
- if (utf32 >= 0x10000) {
- var ch = utf32 - 0x10000;
- str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
- } else {
- str += String.fromCharCode(utf32);
- }
- }
-}
-
-
-// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
-// null-terminated and encoded in UTF32 form. The copy will require at most str.length*4+4 bytes of space in the HEAP.
-// Use the function lengthBytesUTF32() to compute the exact number of bytes (excluding null terminator) that this function will write.
-// Parameters:
-// str: the Javascript string to copy.
-// outPtr: Byte address in Emscripten HEAP where to write the string to.
-// maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
-// terminator, i.e. if maxBytesToWrite=4, only the null terminator will be written and nothing else.
-// maxBytesToWrite<4 does not write any bytes to the output, not even the null terminator.
-// Returns the number of bytes written, EXCLUDING the null terminator.
-
-function stringToUTF32(str, outPtr, maxBytesToWrite) {
- assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!');
- assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
- // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
- if (maxBytesToWrite === undefined) {
- maxBytesToWrite = 0x7FFFFFFF;
- }
- if (maxBytesToWrite < 4) return 0;
- var startPtr = outPtr;
- var endPtr = startPtr + maxBytesToWrite - 4;
- for (var i = 0; i < str.length; ++i) {
- // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
- // See http://unicode.org/faq/utf_bom.html#utf16-3
- var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
- if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
- var trailSurrogate = str.charCodeAt(++i);
- codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
- }
- HEAP32[((outPtr)>>2)]=codeUnit;
- outPtr += 4;
- if (outPtr + 4 > endPtr) break;
- }
- // Null-terminate the pointer to the HEAP.
- HEAP32[((outPtr)>>2)]=0;
- return outPtr - startPtr;
-}
-
-
-// Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
-
-function lengthBytesUTF32(str) {
- var len = 0;
- for (var i = 0; i < str.length; ++i) {
- // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
- // See http://unicode.org/faq/utf_bom.html#utf16-3
- var codeUnit = str.charCodeAt(i);
- if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) ++i; // possibly a lead surrogate, so skip over the tail surrogate.
- len += 4;
- }
-
- return len;
-}
-
-
-function demangle(func) {
- var __cxa_demangle_func = Module['___cxa_demangle'] || Module['__cxa_demangle'];
- if (__cxa_demangle_func) {
- try {
- var s =
- func.substr(1);
- var len = lengthBytesUTF8(s)+1;
- var buf = _malloc(len);
- stringToUTF8(s, buf, len);
- var status = _malloc(4);
- var ret = __cxa_demangle_func(buf, 0, 0, status);
- if (getValue(status, 'i32') === 0 && ret) {
- return Pointer_stringify(ret);
- }
- // otherwise, libcxxabi failed
- } catch(e) {
- // ignore problems here
- } finally {
- if (buf) _free(buf);
- if (status) _free(status);
- if (ret) _free(ret);
- }
- // failure when using libcxxabi, don't demangle
- return func;
- }
- Runtime.warnOnce('warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling');
- return func;
-}
-
-function demangleAll(text) {
- var regex =
- /__Z[\w\d_]+/g;
- return text.replace(regex,
- function(x) {
- var y = demangle(x);
- return x === y ? x : (x + ' [' + y + ']');
- });
-}
-
-function jsStackTrace() {
- var err = new Error();
- if (!err.stack) {
- // IE10+ special cases: It does have callstack info, but it is only populated if an Error object is thrown,
- // so try that as a special-case.
- try {
- throw new Error(0);
- } catch(e) {
- err = e;
- }
- if (!err.stack) {
- return '(no stack trace available)';
- }
- }
- return err.stack.toString();
-}
-
-function stackTrace() {
- var js = jsStackTrace();
- if (Module['extraStackTrace']) js += '\n' + Module['extraStackTrace']();
- return demangleAll(js);
-}
-Module["stackTrace"] = stackTrace;
-
-// Memory management
-
-var PAGE_SIZE = 16384;
-var WASM_PAGE_SIZE = 65536;
-var ASMJS_PAGE_SIZE = 16777216;
-var MIN_TOTAL_MEMORY = 16777216;
-
-function alignUp(x, multiple) {
- if (x % multiple > 0) {
- x += multiple - (x % multiple);
- }
- return x;
-}
-
-var HEAP,
-/** @type {ArrayBuffer} */
- buffer,
-/** @type {Int8Array} */
- HEAP8,
-/** @type {Uint8Array} */
- HEAPU8,
-/** @type {Int16Array} */
- HEAP16,
-/** @type {Uint16Array} */
- HEAPU16,
-/** @type {Int32Array} */
- HEAP32,
-/** @type {Uint32Array} */
- HEAPU32,
-/** @type {Float32Array} */
- HEAPF32,
-/** @type {Float64Array} */
- HEAPF64;
-
-function updateGlobalBuffer(buf) {
- Module['buffer'] = buffer = buf;
-}
-
-function updateGlobalBufferViews() {
- Module['HEAP8'] = HEAP8 = new Int8Array(buffer);
- Module['HEAP16'] = HEAP16 = new Int16Array(buffer);
- Module['HEAP32'] = HEAP32 = new Int32Array(buffer);
- Module['HEAPU8'] = HEAPU8 = new Uint8Array(buffer);
- Module['HEAPU16'] = HEAPU16 = new Uint16Array(buffer);
- Module['HEAPU32'] = HEAPU32 = new Uint32Array(buffer);
- Module['HEAPF32'] = HEAPF32 = new Float32Array(buffer);
- Module['HEAPF64'] = HEAPF64 = new Float64Array(buffer);
-}
-
-var STATIC_BASE, STATICTOP, staticSealed; // static area
-var STACK_BASE, STACKTOP, STACK_MAX; // stack area
-var DYNAMIC_BASE, DYNAMICTOP_PTR; // dynamic area handled by sbrk
-
- STATIC_BASE = STATICTOP = STACK_BASE = STACKTOP = STACK_MAX = DYNAMIC_BASE = DYNAMICTOP_PTR = 0;
- staticSealed = false;
-
-
-// Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
-function writeStackCookie() {
- assert((STACK_MAX & 3) == 0);
- HEAPU32[(STACK_MAX >> 2)-1] = 0x02135467;
- HEAPU32[(STACK_MAX >> 2)-2] = 0x89BACDFE;
-}
-
-function checkStackCookie() {
- if (HEAPU32[(STACK_MAX >> 2)-1] != 0x02135467 || HEAPU32[(STACK_MAX >> 2)-2] != 0x89BACDFE) {
- abort('Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x02135467, but received 0x' + HEAPU32[(STACK_MAX >> 2)-2].toString(16) + ' ' + HEAPU32[(STACK_MAX >> 2)-1].toString(16));
- }
- // Also test the global address 0 for integrity. This check is not compatible with SAFE_SPLIT_MEMORY though, since that mode already tests all address 0 accesses on its own.
- if (HEAP32[0] !== 0x63736d65 /* 'emsc' */) throw 'Runtime error: The application has corrupted its heap memory area (address zero)!';
-}
-
-function abortStackOverflow(allocSize) {
- abort('Stack overflow! Attempted to allocate ' + allocSize + ' bytes on the stack, but stack has only ' + (STACK_MAX - Module['asm'].stackSave() + allocSize) + ' bytes available!');
-}
-
-function abortOnCannotGrowMemory() {
- abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ');
-}
-
-
-function enlargeMemory() {
- abortOnCannotGrowMemory();
-}
-
-
-var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
-var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 16777216;
-if (TOTAL_MEMORY < TOTAL_STACK) Module.printErr('TOTAL_MEMORY should be larger than TOTAL_STACK, was ' + TOTAL_MEMORY + '! (TOTAL_STACK=' + TOTAL_STACK + ')');
-
-// Initialize the runtime's memory
-// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
-assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray !== undefined && Int32Array.prototype.set !== undefined,
- 'JS engine does not provide full typed array support');
-
-
-
-// Use a provided buffer, if there is one, or else allocate a new one
-if (Module['buffer']) {
- buffer = Module['buffer'];
- assert(buffer.byteLength === TOTAL_MEMORY, 'provided buffer should be ' + TOTAL_MEMORY + ' bytes, but it is ' + buffer.byteLength);
-} else {
- // Use a WebAssembly memory where available
- {
- buffer = new ArrayBuffer(TOTAL_MEMORY);
- }
- assert(buffer.byteLength === TOTAL_MEMORY);
-}
-updateGlobalBufferViews();
-
-
-function getTotalMemory() {
- return TOTAL_MEMORY;
-}
-
-// Endianness check (note: assumes compiler arch was little-endian)
- HEAP32[0] = 0x63736d65; /* 'emsc' */
-HEAP16[1] = 0x6373;
-if (HEAPU8[2] !== 0x73 || HEAPU8[3] !== 0x63) throw 'Runtime error: expected the system to be little-endian!';
-
-Module['HEAP'] = HEAP;
-Module['buffer'] = buffer;
-Module['HEAP8'] = HEAP8;
-Module['HEAP16'] = HEAP16;
-Module['HEAP32'] = HEAP32;
-Module['HEAPU8'] = HEAPU8;
-Module['HEAPU16'] = HEAPU16;
-Module['HEAPU32'] = HEAPU32;
-Module['HEAPF32'] = HEAPF32;
-Module['HEAPF64'] = HEAPF64;
-
-function callRuntimeCallbacks(callbacks) {
- while(callbacks.length > 0) {
- var callback = callbacks.shift();
- if (typeof callback == 'function') {
- callback();
- continue;
- }
- var func = callback.func;
- if (typeof func === 'number') {
- if (callback.arg === undefined) {
- func();
- } else {
- func(arg);
- }
- } else {
- func(callback.arg === undefined ? null : callback.arg);
- }
- }
-}
-
-var __ATPRERUN__ = []; // functions called before the runtime is initialized
-var __ATINIT__ = []; // functions called during startup
-var __ATMAIN__ = []; // functions called when main() is to be run
-var __ATEXIT__ = []; // functions called during shutdown
-var __ATPOSTRUN__ = []; // functions called after the runtime has exited
-
-var runtimeInitialized = false;
-var runtimeExited = false;
-
-
-function preRun() {
- // compatibility - merge in anything from Module['preRun'] at this time
- if (Module['preRun']) {
- if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
- while (Module['preRun'].length) {
- addOnPreRun(Module['preRun'].shift());
- }
- }
- callRuntimeCallbacks(__ATPRERUN__);
-}
-
-function ensureInitRuntime() {
- checkStackCookie();
- if (runtimeInitialized) return;
- runtimeInitialized = true;
- callRuntimeCallbacks(__ATINIT__);
-}
-
-function preMain() {
- checkStackCookie();
- callRuntimeCallbacks(__ATMAIN__);
-}
-
-function exitRuntime() {
- checkStackCookie();
- callRuntimeCallbacks(__ATEXIT__);
- runtimeExited = true;
-}
-
-function postRun() {
- checkStackCookie();
- // compatibility - merge in anything from Module['postRun'] at this time
- if (Module['postRun']) {
- if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
- while (Module['postRun'].length) {
- addOnPostRun(Module['postRun'].shift());
- }
- }
- callRuntimeCallbacks(__ATPOSTRUN__);
-}
-
-function addOnPreRun(cb) {
- __ATPRERUN__.unshift(cb);
-}
-Module["addOnPreRun"] = addOnPreRun;
-
-function addOnInit(cb) {
- __ATINIT__.unshift(cb);
-}
-Module["addOnInit"] = addOnInit;
-
-function addOnPreMain(cb) {
- __ATMAIN__.unshift(cb);
-}
-Module["addOnPreMain"] = addOnPreMain;
-
-function addOnExit(cb) {
- __ATEXIT__.unshift(cb);
-}
-Module["addOnExit"] = addOnExit;
-
-function addOnPostRun(cb) {
- __ATPOSTRUN__.unshift(cb);
-}
-Module["addOnPostRun"] = addOnPostRun;
-
-// Tools
-
-/** @type {function(string, boolean=, number=)} */
-function intArrayFromString(stringy, dontAddNull, length) {
- var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
- var u8array = new Array(len);
- var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
- if (dontAddNull) u8array.length = numBytesWritten;
- return u8array;
-}
-Module["intArrayFromString"] = intArrayFromString;
-
-function intArrayToString(array) {
- var ret = [];
- for (var i = 0; i < array.length; i++) {
- var chr = array[i];
- if (chr > 0xFF) {
- assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.');
- chr &= 0xFF;
- }
- ret.push(String.fromCharCode(chr));
- }
- return ret.join('');
-}
-Module["intArrayToString"] = intArrayToString;
-
-// Deprecated: This function should not be called because it is unsafe and does not provide
-// a maximum length limit of how many bytes it is allowed to write. Prefer calling the
-// function stringToUTF8Array() instead, which takes in a maximum length that can be used
-// to be secure from out of bounds writes.
-/** @deprecated */
-function writeStringToMemory(string, buffer, dontAddNull) {
- Runtime.warnOnce('writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!');
-
- var /** @type {number} */ lastChar, /** @type {number} */ end;
- if (dontAddNull) {
- // stringToUTF8Array always appends null. If we don't want to do that, remember the
- // character that existed at the location where the null will be placed, and restore
- // that after the write (below).
- end = buffer + lengthBytesUTF8(string);
- lastChar = HEAP8[end];
- }
- stringToUTF8(string, buffer, Infinity);
- if (dontAddNull) HEAP8[end] = lastChar; // Restore the value under the null character.
-}
-Module["writeStringToMemory"] = writeStringToMemory;
-
-function writeArrayToMemory(array, buffer) {
- assert(array.length >= 0, 'writeArrayToMemory array must have a length (should be an array or typed array)')
- HEAP8.set(array, buffer);
-}
-Module["writeArrayToMemory"] = writeArrayToMemory;
-
-function writeAsciiToMemory(str, buffer, dontAddNull) {
- for (var i = 0; i < str.length; ++i) {
- assert(str.charCodeAt(i) === str.charCodeAt(i)&0xff);
- HEAP8[((buffer++)>>0)]=str.charCodeAt(i);
- }
- // Null-terminate the pointer to the HEAP.
- if (!dontAddNull) HEAP8[((buffer)>>0)]=0;
-}
-Module["writeAsciiToMemory"] = writeAsciiToMemory;
-
-function unSign(value, bits, ignore) {
- if (value >= 0) {
- return value;
- }
- return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
- : Math.pow(2, bits) + value;
-}
-function reSign(value, bits, ignore) {
- if (value <= 0) {
- return value;
- }
- var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
- : Math.pow(2, bits-1);
- if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
- // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
- // TODO: In i64 mode 1, resign the two parts separately and safely
- value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
- }
- return value;
-}
-
-// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
-if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
- var ah = a >>> 16;
- var al = a & 0xffff;
- var bh = b >>> 16;
- var bl = b & 0xffff;
- return (al*bl + ((ah*bl + al*bh) << 16))|0;
-};
-Math.imul = Math['imul'];
-
-
-if (!Math['clz32']) Math['clz32'] = function(x) {
- x = x >>> 0;
- for (var i = 0; i < 32; i++) {
- if (x & (1 << (31 - i))) return i;
- }
- return 32;
-};
-Math.clz32 = Math['clz32']
-
-if (!Math['trunc']) Math['trunc'] = function(x) {
- return x < 0 ? Math.ceil(x) : Math.floor(x);
-};
-Math.trunc = Math['trunc'];
-
-var Math_abs = Math.abs;
-var Math_cos = Math.cos;
-var Math_sin = Math.sin;
-var Math_tan = Math.tan;
-var Math_acos = Math.acos;
-var Math_asin = Math.asin;
-var Math_atan = Math.atan;
-var Math_atan2 = Math.atan2;
-var Math_exp = Math.exp;
-var Math_log = Math.log;
-var Math_sqrt = Math.sqrt;
-var Math_ceil = Math.ceil;
-var Math_floor = Math.floor;
-var Math_pow = Math.pow;
-var Math_imul = Math.imul;
-var Math_fround = Math.fround;
-var Math_round = Math.round;
-var Math_min = Math.min;
-var Math_clz32 = Math.clz32;
-var Math_trunc = Math.trunc;
-
-// A counter of dependencies for calling run(). If we need to
-// do asynchronous work before running, increment this and
-// decrement it. Incrementing must happen in a place like
-// PRE_RUN_ADDITIONS (used by emcc to add file preloading).
-// Note that you can add dependencies in preRun, even though
-// it happens right before run - run will be postponed until
-// the dependencies are met.
-var runDependencies = 0;
-var runDependencyWatcher = null;
-var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
-var runDependencyTracking = {};
-
-function getUniqueRunDependency(id) {
- var orig = id;
- while (1) {
- if (!runDependencyTracking[id]) return id;
- id = orig + Math.random();
- }
- return id;
-}
-
-function addRunDependency(id) {
- runDependencies++;
- if (Module['monitorRunDependencies']) {
- Module['monitorRunDependencies'](runDependencies);
- }
- if (id) {
- assert(!runDependencyTracking[id]);
- runDependencyTracking[id] = 1;
- if (runDependencyWatcher === null && typeof setInterval !== 'undefined') {
- // Check for missing dependencies every few seconds
- runDependencyWatcher = setInterval(function() {
- if (ABORT) {
- clearInterval(runDependencyWatcher);
- runDependencyWatcher = null;
- return;
- }
- var shown = false;
- for (var dep in runDependencyTracking) {
- if (!shown) {
- shown = true;
- Module.printErr('still waiting on run dependencies:');
- }
- Module.printErr('dependency: ' + dep);
- }
- if (shown) {
- Module.printErr('(end of list)');
- }
- }, 10000);
- }
- } else {
- Module.printErr('warning: run dependency added without ID');
- }
-}
-Module["addRunDependency"] = addRunDependency;
-
-function removeRunDependency(id) {
- runDependencies--;
- if (Module['monitorRunDependencies']) {
- Module['monitorRunDependencies'](runDependencies);
- }
- if (id) {
- assert(runDependencyTracking[id]);
- delete runDependencyTracking[id];
- } else {
- Module.printErr('warning: run dependency removed without ID');
- }
- if (runDependencies == 0) {
- if (runDependencyWatcher !== null) {
- clearInterval(runDependencyWatcher);
- runDependencyWatcher = null;
- }
- if (dependenciesFulfilled) {
- var callback = dependenciesFulfilled;
- dependenciesFulfilled = null;
- callback(); // can add another dependenciesFulfilled
- }
- }
-}
-Module["removeRunDependency"] = removeRunDependency;
-
-Module["preloadedImages"] = {}; // maps url to image data
-Module["preloadedAudios"] = {}; // maps url to audio data
-
-
-
-var memoryInitializer = null;
-
-
-
-
-
-
-// === Body ===
-
-var ASM_CONSTS = [function($0, $1) { Module.printErr('bad name in getProcAddress: ' + [Pointer_stringify($0), Pointer_stringify($1)]) }];
-
-function _emscripten_asm_const_iii(code, a0, a1) {
- return ASM_CONSTS[code](a0, a1);
-}
-
-
-
-STATIC_BASE = Runtime.GLOBAL_BASE;
-
-STATICTOP = STATIC_BASE + 85840;
-/* global initializers */ __ATINIT__.push();
-
-
-/* memory initializer */ allocate([77,33,75,33,0,0,0,0,4,0,0,0,77,46,75,46,0,0,0,0,4,0,0,0,70,76,84,52,0,0,0,0,4,0,0,0,70,76,84,56,0,0,0,0,8,0,0,0,52,67,72,78,0,0,0,0,4,0,0,0,54,67,72,78,0,0,0,0,6,0,0,0,56,67,72,78,0,0,0,0,8,0,0,0,49,48,67,72,0,0,0,0,10,0,0,0,49,50,67,72,0,0,0,0,12,0,0,0,49,52,67,72,0,0,0,0,14,0,0,0,49,54,67,72,0,0,0,0,16,0,0,0,49,56,67,72,0,0,0,0,18,0,0,0,50,48,67,72,0,0,0,0,20,0,0,0,50,50,67,72,0,0,0,0,22,0,0,0,50,52,67,72,0,0,0,0,24,0,0,0,50,54,67,72,0,0,0,0,26,0,0,0,50,56,67,72,0,0,0,0,28,0,0,0,51,48,67,72,0,0,0,0,30,0,0,0,51,50,67,72,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,63,0,0,128,63,0,0,128,63,0,0,128,63,0,0,128,63,171,170,42,63,0,0,0,63,0,0,128,63,0,0,128,63,0,0,128,63,0,0,128,63,0,0,128,63,0,0,128,63,0,0,192,63,0,0,0,64,0,0,0,0,0,0,128,191,0,0,0,192,0,0,128,192,0,0,0,193,0,0,128,193,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,64,0,0,128,64,0,0,0,65,0,0,128,65,0,0,0,0,0,0,0,0,172,95,0,0,255,3,0,0,255,255,255,255,205,204,236,63,2,0,0,0,86,1,0,0,85,1,0,0,87,0,0,0,83,0,0,0,68,0,0,0,65,0,0,0,69,0,0,0,81,0,0,0,255,255,255,255,0,1,0,0,255,255,255,255,0,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,128,63,0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,63,0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,32,0,0,176,1,0,0,0,0,0,0,0,0,0,32,37,249,142,0,10,2,0,0,128,190,125,95,244,125,31,160,242,43,74,30,9,82,8,0,64,34,65,80,20,4,16,32,32,41,46,18,8,34,8,0,32,34,65,80,20,4,16,32,32,249,16,76,8,250,62,60,16,34,125,222,247,125,16,32,32,161,232,50,8,34,8,0,8,34,5,16,4,69,16,0,240,163,164,50,8,82,8,0,4,34,5,16,4,69,16,32,32,249,226,94,8,2,0,129,2,62,125,31,244,125,16,0,0,32,0,0,176,1,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,190,15,0,192,15,224,247,251,125,126,191,95,232,190,80,0,162,8,8,68,232,47,20,10,133,2,129,80,72,160,80,0,162,40,228,73,40,40,20,10,132,2,129,64,72,160,72,0,190,15,2,16,175,235,247,9,132,62,159,216,79,160,71,0,34,136,228,9,161,42,20,10,132,2,129,80,72,160,72,0,34,40,8,4,160,47,20,10,133,2,129,80,72,162,80,0,190,143,0,0,33,32,244,251,125,126,129,95,232,156,208,7,0,128,0,0,224,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,1,12,0,130,66,191,223,239,247,251,11,5,5,133,66,191,4,72,0,198,66,161,80,40,20,64,8,5,37,133,66,160,8,168,0,170,70,161,80,40,20,64,8,5,37,133,66,144,16,8,0,146,74,161,95,232,247,67,8,5,37,121,126,136,32,8,0,130,82,161,64,40,1,66,8,137,36,133,64,132,64,8,0,130,98,161,64,42,2,66,8,81,36,133,64,130,128,8,0,130,66,191,192,47,244,67,248,33,252,133,126,191,0,9,62,0,0,0,0,4,0,0,0,0,0,0,0,128,1,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,0,4,0,32,72,65,0,0,0,0,0,8,0,0,4,4,0,4,60,32,0,65,0,0,0,0,0,8,0,0,240,125,223,247,133,239,75,81,190,239,251,190,239,59,81,4,0,69,65,20,133,40,74,73,170,40,138,162,32,8,81,4,240,69,65,244,157,40,74,71,170,40,138,162,224,11,81,4,16,69,65,20,132,40,74,73,170,40,138,162,0,10,145,2,240,125,223,247,133,47,74,209,170,232,251,190,224,123,31,1,0,0,0,0,4,8,64,0,0,0,8,32,0,0,0,0,0,0,0,0,132,15,96,0,0,0,8,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,1,15,0,0,0,0,0,0,0,0,0,0,0,0,0,36,1,15,0,0,0,0,0,0,0,0,0,6,0,0,0,36,1,15,0,0,0,0,0,0,0,128,16,9,162,40,250,36,1,15,0,0,0,0,0,0,0,0,62,1,42,37,66,34,82,15,0,0,0,0,0,0,0,128,138,3,42,34,34,36,41,15,0,0,0,0,0,0,0,128,10,1,42,37,18,36,1,15,0,0,0,0,0,0,0,128,10,1,190,232,251,36,1,15,0,0,0,0,0,0,0,128,190,14,0,0,2,172,1,15,0,0,0,0,0,0,0,128,4,0,0,224,3,0,0,15,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,56,0,0,0,14,184,67,132,3,58,32,0,128,160,190,2,32,0,0,240,138,32,82,196,2,43,32,4,34,145,2,248,59,0,240,7,142,56,75,228,2,58,32,2,28,138,30,8,42,233,17,4,224,11,66,244,2,130,36,1,20,4,20,232,186,4,209,5,128,184,195,231,10,58,137,0,28,14,60,40,2,9,80,4,128,0,64,196,2,128,68,0,34,132,32,232,2,0,80,4,0,0,64,128,2,0,32,5,0,142,62,8,2,0,16,4,224,3,64,128,66,0,0,7,0,132,0,248,3,0,240,7,0,0,64,128,34,0,0,4,0,0,0,0,0,0,0,0,0,0,64,128,2,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,7,128,0,194,160,72,24,0,0,1,132,33,9,146,2,66,38,4,1,33,81,0,0,127,63,2,66,2,16,41,0,34,20,192,239,247,251,253,126,9,161,223,239,247,187,187,3,18,15,68,40,20,10,133,66,9,129,64,32,16,16,17,1,8,4,68,40,20,10,133,66,127,129,64,32,16,16,17,1,4,130,199,239,247,251,253,126,9,129,207,231,243,17,17,1,50,169,80,40,20,10,133,66,9,161,64,32,16,16,17,1,64,184,80,40,20,10,133,66,121,191,223,239,247,187,187,3,32,160,31,0,0,0,0,0,0,16,0,0,0,0,0,0,112,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,2,8,131,34,1,0,2,8,67,2,1,0,1,1,124,20,4,132,68,1,0,32,4,132,4,128,8,63,130,0,132,66,191,223,239,247,3,126,161,80,40,20,10,33,0,0,132,70,161,80,40,20,138,82,161,80,40,20,122,161,239,3,158,74,161,80,40,20,82,82,161,80,40,20,74,31,8,2,132,82,161,80,40,20,34,74,161,80,40,244,75,161,239,3,132,98,161,80,40,20,82,74,161,80,40,4,122,161,40,2,124,66,191,223,239,247,139,126,191,223,239,247,11,189,239,3,0,0,0,0,0,0,0,4,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,5,32,0,0,4,132,0,34,129,69,17,16,66,1,0,148,66,81,0,0,8,66,81,148,42,162,32,8,165,80,0,0,0,32,0,0,0,0,0,0,0,5,0,0,0,0,8,190,239,251,254,251,190,239,251,20,145,235,251,190,239,251,0,32,8,130,32,10,162,40,138,20,145,40,138,162,40,138,62,190,239,251,254,11,190,239,251,20,145,40,138,162,40,138,0,162,40,138,34,8,130,32,8,20,145,40,138,162,40,138,8,190,239,251,254,251,190,239,251,20,145,47,250,190,239,251,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,33,0,4,0,0,0,0,0,0,0,0,0,0,0,0,130,80,20,2,20,0,0,0,0,0,0,0,0,0,0,16,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,190,40,138,162,40,34,0,0,0,0,0,0,0,0,0,0,170,40,138,162,232,34,0,0,0,0,0,0,0,0,0,0,170,40,138,162,168,34,0,0,0,0,0,0,0,0,0,0,170,40,138,162,232,34,0,0,0,0,0,0,0,0,0,0,190,239,251,190,47,62,0,0,0,0,0,0,0,0,0,0,4,0,0,0,40,32,0,0,0,0,0,0,0,0,0,0,0,0,0,128,15,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,4,0,0,0,6,0,0,0,5,0,0,0,7,0,0,0,6,0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,5,0,0,0,5,0,0,0,2,0,0,0,4,0,0,0,1,0,0,0,7,0,0,0,5,0,0,0,2,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,1,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,3,0,0,0,6,0,0,0,7,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,3,0,0,0,5,0,0,0,6,0,0,0,5,0,0,0,7,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,7,0,0,0,6,0,0,0,7,0,0,0,7,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,2,0,0,0,7,0,0,0,2,0,0,0,3,0,0,0,5,0,0,0,2,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,4,0,0,0,5,0,0,0,5,0,0,0,1,0,0,0,2,0,0,0,5,0,0,0,2,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,4,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,7,0,0,0,1,0,0,0,5,0,0,0,3,0,0,0,7,0,0,0,3,0,0,0,5,0,0,0,4,0,0,0,1,0,0,0,7,0,0,0,4,0,0,0,3,0,0,0,5,0,0,0,3,0,0,0,3,0,0,0,2,0,0,0,5,0,0,0,6,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,5,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,7,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,7,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,5,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,6,0,0,0,4,0,0,0,6,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,9,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,3,0,0,0,5,0,0,0,20,0,0,0,0,0,128,63,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,191,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,191,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,191,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,63,0,0,0,0,0,0,128,191,0,0,0,0,0,0,128,191,0,0,0,0,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,191,0,0,128,63,0,0,0,0,0,0,0,0,0,0,128,63,0,0,128,191,0,0,0,0,0,0,0,0,0,0,128,191,0,0,128,191,0,0,0,0,0,0,128,63,46,186,232,62,0,0,0,0,4,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,8,0,0,0,8,0,0,0,4,0,0,0,4,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,8,0,0,0,8,0,0,0,8,0,0,0,4,0,0,0,4,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,205,204,12,64,0,0,128,63,0,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,11,0,0,0,10,0,0,0,12,0,0,0,10,0,0,0,0,0,0,0,48,98,159,57,21,31,31,58,45,208,110,58,21,31,159,58,161,247,198,58,159,174,238,58,150,67,11,59,21,31,31,59,91,11,51,59,218,230,70,59,88,89,91,59,211,249,112,59,38,228,131,59,97,226,143,59,97,136,156,59,196,205,169,59,38,170,183,59,177,54,198,59,158,98,213,59,80,54,229,59,44,186,245,59,231,114,3,60,204,96,12,60,198,166,21,60,212,68,31,60,41,63,41,60,146,145,51,60,66,64,62,60,56,75,73,60,166,182,84,60,90,126,96,60,135,166,108,60,43,47,121,60,11,10,131,60,213,174,137,60,245,133,144,60,80,141,151,60,0,199,158,60,30,53,166,60,120,211,173,60,64,166,181,60,92,171,189,60,255,230,197,60,248,84,206,60,94,247,214,60,74,208,223,60,165,221,232,60,134,33,242,60,212,153,251,60,97,165,2,61,28,153,7,61,26,168,12,61,91,210,17,61,236,24,23,61,204,123,28,61,253,250,33,61,125,150,39,61,77,78,45,61,121,35,51,61,245,20,57,61,205,35,63,61,1,80,69,61,145,153,75,61,113,255,81,61,199,132,88,61,108,38,95,61,121,230,101,61,240,196,108,61,206,193,115,61,22,221,122,61,99,11,129,61,111,183,132,61,54,115,136,61,50,62,140,61,231,24,144,61,88,3,148,61,130,253,151,61,226,6,156,61,129,32,160,61,98,74,164,61,253,131,168,61,83,205,172,61,233,38,177,61,71,145,181,61,95,11,186,61,184,149,190,61,81,48,195,61,177,219,199,61,217,151,204,61,65,100,209,61,234,64,214,61,224,46,219,61,157,45,224,61,155,60,229,61,230,92,234,61,126,142,239,61,87,208,244,61,3,36,250,61,118,136,255,61,27,127,2,62,95,66,5,62,141,14,8,62,97,227,10,62,30,193,13,62,63,167,16,62,74,150,19,62,63,142,22,62,29,143,25,62,162,152,28,62,17,171,31,62,172,198,34,62,238,234,37,62,93,24,41,62,181,78,44,62,59,142,47,62,170,214,50,62,70,40,54,62,14,131,57,62,4,231,60,62,38,84,64,62,117,202,67,62,241,73,71,62,154,210,74,62,178,100,78,62,59,0,82,62,240,164,85,62,21,83,89,62,170,10,93,62,108,203,96,62,225,149,100,62,198,105,104,62,27,71,108,62,35,46,112,62,155,30,116,62,131,24,120,62,29,28,124,62,182,20,128,62,54,32,130,62,144,48,132,62,195,69,134,62,208,95,136,62,183,126,138,62,119,162,140,62,50,203,142,62,232,248,144,62,119,43,147,62,2,99,149,62,102,159,151,62,231,224,153,62,66,39,156,62,185,114,158,62,43,195,160,62,152,24,163,62,0,115,165,62,133,210,167,62,38,55,170,62,195,160,172,62,90,15,175,62,48,131,177,62,34,252,179,62,16,122,182,62,59,253,184,62,131,133,187,62,232,18,190,62,106,165,192,62,41,61,195,62,39,218,197,62,66,124,200,62,121,35,203,62,15,208,205,62,195,129,208,62,214,56,211,62,6,245,213,62,149,182,216,62,99,125,219,62,111,73,222,62,185,26,225,62,99,241,227,62,108,205,230,62,180,174,233,62,91,149,236,62,98,129,239,62,201,114,242,62,110,105,245,62,149,101,248,62,27,103,251,62,1,110,254,62,52,189,0,63,6,70,2,63,171,209,3,63,254,95,5,63,2,241,6,63,199,132,8,63,92,27,10,63,162,180,11,63,152,80,13,63,95,239,14,63,247,144,16,63,63,53,18,63,89,220,19,63,35,134,21,63,207,50,23,63,59,226,24,63,104,148,26,63,119,73,28,63,71,1,30,63,216,187,31,63,74,121,33,63,143,57,35,63,164,252,36,63,139,194,38,63,68,139,40,63,205,86,42,63,57,37,44,63,136,246,45,63,151,202,47,63,152,161,49,63,108,123,51,63,33,88,53,63,185,55,55,63,34,26,57,63,126,255,58,63,188,231,60,63,204,210,62,63,207,192,64,63,196,177,66,63,139,165,68,63,69,156,70,63,242,149,72,63,129,146,74,63,4,146,76,63,104,148,78,63,208,153,80,63,26,162,82,63,88,173,84,63,136,187,86,63,171,204,88,63,210,224,90,63,219,247,92,63,232,17,95,63,232,46,97,63,236,78,99,63,227,113,101,63,221,151,103,63,219,192,105,63,204,236,107,63,193,27,110,63,186,77,112,63,182,130,114,63,182,186,116,63,169,245,118,63,177,51,121,63,205,116,123,63,220,184,125,63,0,0,128,63,13,0,115,0,13,0,122,0,13,0,128,0,13,0,135,0,13,0,141,0,13,0,148,0,13,0,154,0,13,0,161,0,26,0,167,0,26,0,180,0,26,0,193,0,26,0,206,0,26,0,218,0,26,0,231,0,26,0,244,0,26,0,1,1,51,0,14,1,51,0,40,1,51,0,65,1,51,0,91,1,51,0,117,1,51,0,143,1,51,0,168,1,51,0,194,1,103,0,220,1,103,0,15,2,103,0,67,2,103,0,118,2,103,0,170,2,103,0,221,2,103,0,17,3,103,0,68,3,206,0,120,3,206,0,223,3,206,0,70,4,206,0,173,4,206,0,20,5,197,0,123,5,188,0,221,5,181,0,59,6,88,1,151,6,66,1,66,7,48,1,227,7,32,1,123,8,18,1,11,9,6,1,148,9,252,0,23,10,242,0,149,10,203,1,15,11,174,1,244,11,149,1,203,12,128,1,149,13,110,1,86,14,94,1,13,15,80,1,188,15,67,1,99,16,100,2,7,17,62,2,56,18,29,2,87,19,1,2,102,20,233,1,102,21,211,1,90,22,192,1,68,23,175,1,36,24,49,3,254,24,254,2,150,26,210,2,21,28,173,2,126,29,141,2,212,30,112,2,26,32,86,2,82,33,64,2,125,34,67,4,159,35,254,3,192,37,196,3,191,39,146,3,161,41,103,3,106,43,65,3,29,45,31,3,190,46,0,3,77,48,176,5,209,49,85,5,168,52,7,5,82,55,197,4,213,57,139,4,55,60,88,4,124,62,42,4,168,64,1,4,189,66,152,7,194,68,30,7,142,72,182,6,28,76,93,6,118,79,16,6,165,82,204,5,172,85,143,5,146,88,89,5,89,91,35,10,12,94,128,9,28,99,246,8,219,103,127,8,85,108,24,8,148,112,189,7,160,116,108,7,125,120,35,7,51,124,1,1,0,0,1,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,4,0,0,0,4,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,11,0,0,0,13,0,0,0,15,0,0,0,17,0,0,0,19,0,0,0,23,0,0,0,27,0,0,0,31,0,0,0,35,0,0,0,43,0,0,0,51,0,0,0,59,0,0,0,67,0,0,0,83,0,0,0,99,0,0,0,115,0,0,0,131,0,0,0,163,0,0,0,195,0,0,0,227,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,5,0,0,0,5,0,0,0,6,0,0,0,6,0,0,0,7,0,0,0,7,0,0,0,8,0,0,0,8,0,0,0,9,0,0,0,9,0,0,0,10,0,0,0,10,0,0,0,11,0,0,0,11,0,0,0,12,0,0,0,12,0,0,0,13,0,0,0,13,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,5,0,0,0,7,0,0,0,9,0,0,0,13,0,0,0,17,0,0,0,25,0,0,0,33,0,0,0,49,0,0,0,65,0,0,0,97,0,0,0,129,0,0,0,193,0,0,0,1,1,0,0,129,1,0,0,1,2,0,0,1,3,0,0,1,4,0,0,1,6,0,0,1,8,0,0,1,12,0,0,1,16,0,0,1,24,0,0,1,32,0,0,1,48,0,0,1,64,0,0,1,96,0,0,0,0,0,0,0,0,0,0,0,1,0,0,128,0,0,0,86,0,0,0,64,0,0,0,62,180,228,51,9,145,243,51,139,178,1,52,60,32,10,52,35,26,19,52,96,169,28,52,167,215,38,52,75,175,49,52,80,59,61,52,112,135,73,52,35,160,86,52,184,146,100,52,85,109,115,52,136,159,129,52,252,11,138,52,147,4,147,52,105,146,156,52,50,191,166,52,63,149,177,52,147,31,189,52,228,105,201,52,173,128,214,52,54,113,228,52,166,73,243,52,136,140,1,53,192,247,9,53,6,239,18,53,118,123,28,53,192,166,38,53,55,123,49,53,218,3,61,53,94,76,73,53,59,97,86,53,185,79,100,53,252,37,115,53,138,121,129,53,134,227,137,53,124,217,146,53,133,100,156,53,82,142,166,53,51,97,177,53,37,232,188,53,220,46,201,53,206,65,214,53,65,46,228,53,87,2,243,53,143,102,1,54,79,207,9,54,245,195,18,54,152,77,28,54,232,117,38,54,50,71,49,54,116,204,60,54,94,17,73,54,101,34,86,54,206,12,100,54,184,222,114,54,151,83,129,54,28,187,137,54,114,174,146,54,175,54,156,54,129,93,166,54,53,45,177,54,199,176,188,54,228,243,200,54,1,3,214,54,96,235,227,54,30,187,242,54,162,64,1,55,235,166,9,55,241,152,18,55,201,31,28,55,30,69,38,55,61,19,49,55,30,149,60,55,111,214,72,55,162,227,85,55,247,201,99,55,137,151,114,55,175,45,129,55,190,146,137,55,116,131,146,55,230,8,156,55,190,44,166,55,71,249,176,55,121,121,188,55,254,184,200,55,71,196,213,55,146,168,227,55,248,115,242,55,192,26,1,56,147,126,9,56,249,109,18,56,6,242,27,56,98,20,38,56,86,223,48,56,216,93,60,56,146,155,72,56,242,164,85,56,51,135,99,56,110,80,114,56,211,7,129,56,107,106,137,56,130,88,146,56,42,219,155,56,9,252,165,56,104,197,176,56,59,66,188,56,41,126,200,56,160,133,213,56,217,101,227,56,232,44,242,56,233,244,0,57,70,86,9,57,14,67,18,57,81,196,27,57,181,227,37,57,127,171,48,57,162,38,60,57,197,96,72,57,83,102,85,57,131,68,99,57,104,9,114,57,1,226,128,57,36,66,137,57,157,45,146,57,123,173,155,57,99,203,165,57,153,145,176,57,13,11,188,57,102,67,200,57,11,71,213,57,50,35,227,57,237,229,241,57,29,207,0,58,5,46,9,58,48,24,18,58,169,150,27,58,21,179,37,58,183,119,48,58,124,239,59,58,10,38,72,58,199,39,85,58,230,1,99,58,120,194,113,58,59,188,128,58,233,25,137,58,198,2,146,58,219,127,155,58,203,154,165,58,216,93,176,58,239,211,187,58,179,8,200,58,136,8,213,58,159,224,226,58,7,159,241,58,92,169,0,59,208,5,9,59,94,237,17,59,15,105,27,59,132,130,37,59,253,67,48,59,103,184,59,59,97,235,71,59,77,233,84,59,93,191,98,59,156,123,113,59,127,150,128,59,186,241,136,59,249,215,145,59,71,82,155,59,65,106,165,59,39,42,176,59,226,156,187,59,18,206,199,59,23,202,212,59,32,158,226,59,53,88,241,59,166,131,0,60,167,221,8,60,152,194,17,60,130,59,27,60,1,82,37,60,84,16,48,60,97,129,59,60,200,176,71,60,229,170,84,60,232,124,98,60,212,52,113,60,207,112,128,60,150,201,136,60,58,173,145,60,192,36,155,60,197,57,165,60,133,246,175,60,229,101,187,60,130,147,199,60,185,139,212,60,180,91,226,60,121,17,241,60,251,93,0,61,137,181,8,61,223,151,17,61,2,14,27,61,141,33,37,61,185,220,47,61,109,74,59,61,64,118,71,61,145,108,84,61,133,58,98,61,34,238,112,61,42,75,128,61,127,161,136,61,136,130,145,61,72,247,154,61,88,9,165,61,242,194,175,61,248,46,187,61,3,89,199,61,109,77,212,61,92,25,226,61,209,202,240,61,91,56,0,62,119,141,8,62,51,109,17,62,144,224,26,62,39,241,36,62,46,169,47,62,135,19,59,62,202,59,71,62,77,46,84,62,55,248,97,62,132,167,112,62,143,37,128,62,115,121,136,62,226,87,145,62,220,201,154,62,249,216,164,62,109,143,175,62,27,248,186,62,149,30,199,62,51,15,212,62,23,215,225,62,61,132,240,62,198,18,0,63,114,101,8,63,147,66,17,63,43,179,26,63,206,192,36,63,177,117,47,63,178,220,58,63,101,1,71,63,29,240,83,63,251,181,97,63,251,96,112,63,0,0,128,63,79,103,103,83,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,196,69,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,232,29,0,0,5,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,15,0,0,0,63,75,1,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,104,30,0,0,5,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,15,0,0,0,71,75,1,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,104,30,0,0,2,0,0,192,3,0,0,192,4,0,0,192,5,0,0,192,6,0,0,192,7,0,0,192,8,0,0,192,9,0,0,192,10,0,0,192,11,0,0,192,12,0,0,192,13,0,0,192,14,0,0,192,15,0,0,192,16,0,0,192,17,0,0,192,18,0,0,192,19,0,0,192,20,0,0,192,21,0,0,192,22,0,0,192,23,0,0,192,24,0,0,192,25,0,0,192,26,0,0,192,27,0,0,192,28,0,0,192,29,0,0,192,30,0,0,192,31,0,0,192,0,0,0,179,1,0,0,195,2,0,0,195,3,0,0,195,4,0,0,195,5,0,0,195,6,0,0,195,7,0,0,195,8,0,0,195,9,0,0,195,10,0,0,195,11,0,0,195,12,0,0,195,13,0,0,211,14,0,0,195,15,0,0,195,0,0,12,187,1,0,12,195,2,0,12,195,3,0,12,195,4,0,12,211,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,100,0,0,0,232,3,0,0,16,39,0,0,160,134,1,0,64,66,15,0,128,150,152,0,0,225,245,5,95,112,137,0,255,9,47,15,0,107,0,101,64,95,0,90,192,84,0,80,128,75,64,71,64,67,128,63,0,60,160,56,128,53,128,50,160,47,0,45,96,42,0,40,192,37,160,35,158,33,192,31,0,30,80,28,192,26,64,25,208,23,128,22,48,21,0,20,224,18,208,17,208,16,224,15,0,15,40,14,96,13,160,12,232,11,64,11,152,10,0,10,112,9,232,8,104,8,240,7,128,7,20,7,176,6,80,6,244,5,160,5,76,5,0,5,184,4,116,4,52,4,248,3,192,3,138,3,88,3,40,3,250,2,208,2,166,2,128,2,92,2,58,2,26,2,252,1,224,1,197,1,172,1,148,1,125,1,104,1,83,1,64,1,46,1,29,1,13,1,254,0,240,0,226,0,214,0,202,0,190,0,180,0,170,0,160,0,151,0,143,0,135,0,127,0,120,0,113,0,107,0,101,0,95,0,90,0,85,0,80,0,75,0,71,0,67,0,63,0,60,0,56,0,53,0,50,0,47,0,45,0,42,0,40,0,37,0,35,0,33,0,31,0,30,0,28,0,27,0,25,0,24,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,13,0,12,0,11,0,11,0,10,0,9,0,9,0,8,0,8,0,7,0,7,0,176,6,80,6,245,5,160,5,77,5,1,5,185,4,117,4,53,4,249,3,193,3,139,3,88,3,0,0,24,0,49,0,74,0,97,0,120,0,141,0,161,0,180,0,197,0,212,0,224,0,235,0,244,0,250,0,253,0,255,0,253,0,250,0,244,0,235,0,224,0,212,0,197,0,180,0,161,0,141,0,120,0,97,0,74,0,49,0,24,0,69,120,116,101,110,100,101,100,32,77,111,100,117,108,101,58,32,0,67,111,117,108,100,32,110,111,116,32,111,112,101,110,32,105,110,112,117,116,32,102,105,108,101,0,102,115,101,101,107,40,41,32,102,97,105,108,101,100,0,102,114,101,97,100,40,41,32,102,97,105,108,101,100,0,99,111,117,108,100,32,110,111,116,32,99,114,101,97,116,101,32,99,111,110,116,101,120,116,58,32,109,111,100,117,108,101,32,105,115,32,110,111,116,32,115,97,110,101,10,0,99,111,117,108,100,32,110,111,116,32,99,114,101,97,116,101,32,99,111,110,116,101,120,116,58,32,109,97,108,108,111,99,32,102,97,105,108,101,100,10,0,99,111,117,108,100,32,110,111,116,32,99,114,101,97,116,101,32,99,111,110,116,101,120,116,58,32,117,110,107,110,111,119,110,32,101,114,114,111,114,10,0,70,97,105,108,101,100,32,116,111,32,105,110,105,116,105,97,108,105,122,101,32,97,117,100,105,111,32,99,111,110,116,101,120,116,0,70,97,105,108,101,100,32,116,111,32,105,110,105,116,105,97,108,105,122,101,32,97,117,100,105,111,32,112,108,97,121,98,97,99,107,32,100,101,118,105,99,101,0,70,97,105,108,101,100,32,116,111,32,115,116,97,114,116,32,97,117,100,105,111,32,112,108,97,121,98,97,99,107,32,100,101,118,105,99,101,0,70,97,105,108,101,100,32,116,111,32,99,114,101,97,116,101,32,109,117,116,101,120,32,102,111,114,32,97,117,100,105,111,32,109,105,120,105,110,103,0,65,117,100,105,111,32,100,101,118,105,99,101,32,105,110,105,116,105,97,108,105,122,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,58,32,37,115,0,65,117,100,105,111,32,98,97,99,107,101,110,100,58,32,109,105,110,105,95,97,108,32,47,32,37,115,0,65,117,100,105,111,32,102,111,114,109,97,116,58,32,37,115,32,45,62,32,37,115,0,65,117,100,105,111,32,99,104,97,110,110,101,108,115,58,32,37,100,32,45,62,32,37,100,0,65,117,100,105,111,32,115,97,109,112,108,101,32,114,97,116,101,58,32,37,100,32,45,62,32,37,100,0,65,117,100,105,111,32,98,117,102,102,101,114,32,115,105,122,101,58,32,37,100,0,67,111,117,108,100,32,110,111,116,32,99,108,111,115,101,32,97,117,100,105,111,32,100,101,118,105,99,101,32,98,101,99,97,117,115,101,32,105,116,32,105,115,32,110,111,116,32,99,117,114,114,101,110,116,108,121,32,105,110,105,116,105,97,108,105,122,101,100,0,65,117,100,105,111,32,100,101,118,105,99,101,32,99,108,111,115,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,67,114,101,97,116,101,65,117,100,105,111,66,117,102,102,101,114,40,41,32,58,32,70,97,105,108,101,100,32,116,111,32,97,108,108,111,99,97,116,101,32,109,101,109,111,114,121,32,102,111,114,32,97,117,100,105,111,32,98,117,102,102,101,114,0,76,111,97,100,83,111,117,110,100,70,114,111,109,87,97,118,101,40,41,32,58,32,70,97,105,108,101,100,32,116,111,32,99,114,101,97,116,101,32,100,97,116,97,32,99,111,110,118,101,114,115,105,111,110,32,112,105,112,101,108,105,110,101,0,80,108,97,121,65,117,100,105,111,66,117,102,102,101,114,40,41,32,58,32,78,111,32,97,117,100,105,111,32,98,117,102,102,101,114,0,46,119,97,118,0,46,111,103,103,0,91,37,115,93,32,82,101,115,111,117,114,99,101,32,102,105,108,101,32,100,111,101,115,32,110,111,116,32,99,111,110,116,97,105,110,32,119,97,118,101,32,100,97,116,97,0,91,37,115,93,32,65,117,100,105,111,32,102,105,108,101,102,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,44,32,105,116,32,99,97,110,39,116,32,98,101,32,108,111,97,100,101,100,0,76,111,97,100,83,111,117,110,100,70,114,111,109,87,97,118,101,40,41,32,58,32,70,97,105,108,101,100,32,116,111,32,103,101,116,32,102,114,97,109,101,32,99,111,117,110,116,32,102,111,114,32,102,111,114,109,97,116,32,99,111,110,118,101,114,115,105,111,110,0,76,111,97,100,83,111,117,110,100,70,114,111,109,87,97,118,101,40,41,32,58,32,70,97,105,108,101,100,32,116,111,32,99,114,101,97,116,101,32,97,117,100,105,111,32,98,117,102,102,101,114,0,76,111,97,100,83,111,117,110,100,70,114,111,109,87,97,118,101,40,41,32,58,32,70,111,114,109,97,116,32,99,111,110,118,101,114,115,105,111,110,32,102,97,105,108,101,100,0,85,110,108,111,97,100,101,100,32,119,97,118,101,32,100,97,116,97,32,102,114,111,109,32,82,65,77,0,91,83,78,68,32,73,68,32,37,105,93,91,66,85,70,82,32,73,68,32,37,105,93,32,85,110,108,111,97,100,101,100,32,115,111,117,110,100,32,100,97,116,97,32,102,114,111,109,32,82,65,77,0,85,112,100,97,116,101,83,111,117,110,100,40,41,32,58,32,73,110,118,97,108,105,100,32,115,111,117,110,100,32,45,32,110,111,32,97,117,100,105,111,32,98,117,102,102,101,114,0,87,97,118,101,70,111,114,109,97,116,40,41,32,58,32,70,97,105,108,101,100,32,116,111,32,103,101,116,32,102,114,97,109,101,32,99,111,117,110,116,32,102,111,114,32,102,111,114,109,97,116,32,99,111,110,118,101,114,115,105,111,110,46,0,87,97,118,101,70,111,114,109,97,116,40,41,32,58,32,70,111,114,109,97,116,32,99,111,110,118,101,114,115,105,111,110,32,102,97,105,108,101,100,46,0,87,97,118,101,32,99,114,111,112,32,114,97,110,103,101,32,111,117,116,32,111,102,32,98,111,117,110,100,115,0,91,37,115,93,32,79,71,71,32,97,117,100,105,111,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,91,37,115,93,32,70,76,65,67,32,116,111,116,97,108,32,115,97,109,112,108,101,115,58,32,37,105,0,91,37,115,93,32,79,71,71,32,115,97,109,112,108,101,32,114,97,116,101,58,32,37,105,0,91,37,115,93,32,79,71,71,32,99,104,97,110,110,101,108,115,58,32,37,105,0,91,37,115,93,32,79,71,71,32,109,101,109,111,114,121,32,114,101,113,117,105,114,101,100,58,32,37,105,0,46,120,109,0,91,37,115,93,32,88,77,32,110,117,109,98,101,114,32,111,102,32,115,97,109,112,108,101,115,58,32,37,105,0,91,37,115,93,32,88,77,32,116,114,97,99,107,32,108,101,110,103,116,104,58,32,37,49,49,46,54,102,32,115,101,99,0,91,37,115,93,32,88,77,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,46,109,111,100,0,91,37,115], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
-/* memory initializer */ allocate([93,32,77,79,68,32,110,117,109,98,101,114,32,111,102,32,115,97,109,112,108,101,115,58,32,37,105,0,91,37,115,93,32,77,79,68,32,116,114,97,99,107,32,108,101,110,103,116,104,58,32,37,49,49,46,54,102,32,115,101,99,0,91,37,115,93,32,77,79,68,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,80,108,97,121,77,117,115,105,99,83,116,114,101,97,109,40,41,32,58,32,78,111,32,97,117,100,105,111,32,98,117,102,102,101,114,0,73,110,105,116,32,97,117,100,105,111,32,115,116,114,101,97,109,58,32,78,117,109,98,101,114,32,111,102,32,99,104,97,110,110,101,108,115,32,110,111,116,32,115,117,112,112,111,114,116,101,100,58,32,37,105,0,73,110,105,116,65,117,100,105,111,83,116,114,101,97,109,40,41,32,58,32,70,97,105,108,101,100,32,116,111,32,99,114,101,97,116,101,32,97,117,100,105,111,32,98,117,102,102,101,114,0,91,65,85,68,32,73,68,32,37,105,93,32,65,117,100,105,111,32,115,116,114,101,97,109,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,37,105,32,72,122,44,32,37,105,32,98,105,116,44,32,37,115,41,0,77,111,110,111,0,83,116,101,114,101,111,0,91,65,85,68,32,73,68,32,37,105,93,32,85,110,108,111,97,100,101,100,32,97,117,100,105,111,32,115,116,114,101,97,109,32,100,97,116,97,0,85,112,100,97,116,101,65,117,100,105,111,83,116,114,101,97,109,40,41,32,58,32,78,111,32,97,117,100,105,111,32,98,117,102,102,101,114,0,85,112,100,97,116,101,65,117,100,105,111,83,116,114,101,97,109,40,41,32,58,32,65,116,116,101,109,112,116,105,110,103,32,116,111,32,119,114,105,116,101,32,116,111,111,32,109,97,110,121,32,102,114,97,109,101,115,32,116,111,32,98,117,102,102,101,114,0,65,117,100,105,111,32,98,117,102,102,101,114,32,110,111,116,32,97,118,97,105,108,97,98,108,101,32,102,111,114,32,117,112,100,97,116,105,110,103,0,73,115,65,117,100,105,111,66,117,102,102,101,114,80,114,111,99,101,115,115,101,100,40,41,32,58,32,78,111,32,97,117,100,105,111,32,98,117,102,102,101,114,0,77,46,75,46,0,77,105,120,101,100,32,116,111,111,32,109,97,110,121,32,102,114,97,109,101,115,32,102,114,111,109,32,97,117,100,105,111,32,98,117,102,102,101,114,0,70,114,97,109,101,32,99,117,114,115,111,114,32,112,111,115,105,116,105,111,110,32,109,111,118,101,100,32,116,111,111,32,102,97,114,32,102,111,114,119,97,114,100,32,105,110,32,97,117,100,105,111,32,115,116,114,101,97,109,0,91,37,115,93,32,87,65,86,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,82,73,70,70,0,87,65,86,69,0,91,37,115,93,32,73,110,118,97,108,105,100,32,82,73,70,70,32,111,114,32,87,65,86,69,32,72,101,97,100,101,114,0,91,37,115,93,32,73,110,118,97,108,105,100,32,87,97,118,101,32,102,111,114,109,97,116,0,91,37,115,93,32,73,110,118,97,108,105,100,32,100,97,116,97,32,104,101,97,100,101,114,0,91,37,115,93,32,87,65,86,32,115,97,109,112,108,101,32,115,105,122,101,32,40,37,105,98,105,116,41,32,110,111,116,32,115,117,112,112,111,114,116,101,100,44,32,99,111,110,118,101,114,116,101,100,32,116,111,32,49,54,98,105,116,0,91,37,115,93,32,87,65,86,32,99,104,97,110,110,101,108,115,32,110,117,109,98,101,114,32,40,37,105,41,32,110,111,116,32,115,117,112,112,111,114,116,101,100,44,32,99,111,110,118,101,114,116,101,100,32,116,111,32,50,32,99,104,97,110,110,101,108,115,0,91,37,115,93,32,87,65,86,32,102,105,108,101,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,37,105,32,72,122,44,32,37,105,32,98,105,116,44,32,37,115,41,0,91,37,115,93,32,79,71,71,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,91,37,115,93,32,79,103,103,32,97,117,100,105,111,32,108,101,110,103,116,104,32,105,115,32,108,97,114,103,101,114,32,116,104,97,110,32,49,48,32,115,101,99,111,110,100,115,32,40,37,102,41,44,32,116,104,97,116,39,115,32,97,32,98,105,103,32,102,105,108,101,32,105,110,32,109,101,109,111,114,121,44,32,99,111,110,115,105,100,101,114,32,109,117,115,105,99,32,115,116,114,101,97,109,105,110,103,0,91,37,115,93,32,83,97,109,112,108,101,115,32,111,98,116,97,105,110,101,100,58,32,37,105,0,91,37,115,93,32,79,71,71,32,102,105,108,101,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,37,105,32,72,122,44,32,37,105,32,98,105,116,44,32,37,115,41,0,119,98,0,73,110,105,116,105,97,108,105,122,105,110,103,32,114,97,121,108,105,98,32,40,118,49,46,57,45,100,101,118,41,0,35,99,97,110,118,97,115,0,84,97,114,103,101,116,32,116,105,109,101,32,112,101,114,32,102,114,97,109,101,58,32,37,48,50,46,48,51,102,32,109,105,108,108,105,115,101,99,111,110,100,115,0,69,115,99,97,112,101,0,67,97,110,118,97,115,32,115,99,97,108,101,100,32,116,111,32,102,117,108,108,115,99,114,101,101,110,46,32,69,108,101,109,101,110,116,83,105,122,101,58,32,40,37,105,120,37,105,41,44,32,83,99,114,101,101,110,83,105,122,101,40,37,105,120,37,105,41,0,67,97,110,118,97,115,32,115,99,97,108,101,100,32,116,111,32,119,105,110,100,111,119,101,100,46,32,69,108,101,109,101,110,116,83,105,122,101,58,32,40,37,105,120,37,105,41,44,32,83,99,114,101,101,110,83,105,122,101,40,37,105,120,37,105,41,0,70,97,105,108,101,100,32,116,111,32,105,110,105,116,105,97,108,105,122,101,32,71,76,70,87,0,84,114,121,105,110,103,32,116,111,32,101,110,97,98,108,101,32,77,83,65,65,32,120,52,0,67,108,111,115,101,115,116,32,102,117,108,108,115,99,114,101,101,110,32,118,105,100,101,111,109,111,100,101,58,32,37,105,32,120,32,37,105,0,71,76,70,87,32,70,97,105,108,101,100,32,116,111,32,105,110,105,116,105,97,108,105,122,101,32,87,105,110,100,111,119,0,68,105,115,112,108,97,121,32,100,101,118,105,99,101,32,105,110,105,116,105,97,108,105,122,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,82,101,110,100,101,114,32,115,105,122,101,58,32,37,105,32,120,32,37,105,0,83,99,114,101,101,110,32,115,105,122,101,58,32,37,105,32,120,32,37,105,0,86,105,101,119,112,111,114,116,32,111,102,102,115,101,116,115,58,32,37,105,44,32,37,105,0,84,114,121,105,110,103,32,116,111,32,101,110,97,98,108,101,32,86,83,89,78,67,0,68,79,87,78,83,67,65,76,73,78,71,58,32,82,101,113,117,105,114,101,100,32,115,99,114,101,101,110,32,115,105,122,101,32,40,37,105,120,37,105,41,32,105,115,32,98,105,103,103,101,114,32,116,104,97,110,32,100,105,115,112,108,97,121,32,115,105,122,101,32,40,37,105,120,37,105,41,0,68,111,119,110,115,99,97,108,101,32,109,97,116,114,105,120,32,103,101,110,101,114,97,116,101,100,44,32,99,111,110,116,101,110,116,32,119,105,108,108,32,98,101,32,114,101,110,100,101,114,101,100,32,97,116,58,32,37,105,32,120,32,37,105,0,85,80,83,67,65,76,73,78,71,58,32,82,101,113,117,105,114,101,100,32,115,99,114,101,101,110,32,115,105,122,101,58,32,37,105,32,120,32,37,105,32,45,62,32,68,105,115,112,108,97,121,32,115,105,122,101,58,32,37,105,32,120,32,37,105,0,91,71,76,70,87,51,32,69,114,114,111,114,93,32,67,111,100,101,58,32,37,105,32,68,101,99,114,105,112,116,105,111,110,58,32,37,115,0,87,105,110,100,111,119,32,99,108,111,115,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,68,101,118,105,99,101,32,99,111,111,114,100,105,110,97,116,101,115,58,32,40,37,102,44,32,37,102,44,32,37,102,41,0,115,116,111,114,97,103,101,46,100,97,116,97,0,114,98,43,0,83,116,111,114,97,103,101,32,100,97,116,97,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,99,114,101,97,116,101,100,0,83,116,111,114,97,103,101,32,112,111,115,105,116,105,111,110,32,99,111,117,108,100,32,110,111,116,32,98,101,32,102,111,117,110,100,0,83,116,111,114,97,103,101,32,100,97,116,97,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,102,111,117,110,100,0,82,101,113,117,105,114,101,100,32,116,111,117,99,104,32,112,111,105,110,116,32,111,117,116,32,111,102,32,114,97,110,103,101,32,40,77,97,120,32,116,111,117,99,104,32,112,111,105,110,116,115,58,32,37,105,41,0,112,67,111,110,116,101,120,116,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,101,120,116,101,114,110,97,108,47,109,105,110,105,95,97,108,46,104,0,109,97,108,95,99,111,110,116,101,120,116,95,105,110,105,116,95,95,115,100,108,0,109,97,108,95,99,111,110,116,101,120,116,95,117,110,105,110,105,116,95,95,115,100,108,0,112,67,111,110,116,101,120,116,45,62,98,97,99,107,101,110,100,32,61,61,32,109,97,108,95,98,97,99,107,101,110,100,95,115,100,108,0,68,101,102,97,117,108,116,32,80,108,97,121,98,97,99,107,32,68,101,118,105,99,101,0,68,101,102,97,117,108,116,32,67,97,112,116,117,114,101,32,68,101,118,105,99,101,0,112,68,101,118,105,99,101,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,109,97,108,95,100,101,118,105,99,101,95,117,110,105,110,105,116,95,95,115,100,108,0,109,97,108,95,100,101,118,105,99,101,95,105,110,105,116,95,95,115,100,108,0,112,67,111,110,102,105,103,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,98,117,102,102,101,114,83,105,122,101,32,60,61,32,51,50,55,54,56,0,70,97,105,108,101,100,32,116,111,32,111,112,101,110,32,83,68,76,32,100,101,118,105,99,101,46,0,109,97,108,95,97,117,100,105,111,95,99,97,108,108,98,97,99,107,95,95,115,100,108,0,109,97,108,95,100,101,118,105,99,101,95,95,115,101,110,100,95,102,114,97,109,101,115,95,116,111,95,99,108,105,101,110,116,0,102,114,97,109,101,67,111,117,110,116,32,62,32,48,0,112,83,97,109,112,108,101,115,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,112,70,114,97,109,101,115,79,117,116,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,109,97,108,95,100,115,112,95,109,105,120,95,99,104,97,110,110,101,108,115,95,95,100,101,99,0,99,104,97,110,110,101,108,115,79,117,116,32,62,32,48,0,112,70,114,97,109,101,115,73,110,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,99,104,97,110,110,101,108,115,73,110,32,62,32,48,0,99,104,97,110,110,101,108,115,79,117,116,32,60,32,99,104,97,110,110,101,108,115,73,110,0,109,97,108,95,100,115,112,95,109,105,120,95,99,104,97,110,110,101,108,115,95,95,105,110,99,0,99,104,97,110,110,101,108,115,79,117,116,32,62,32,99,104,97,110,110,101,108,115,73,110,0,112,83,82,67,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,109,97,108,95,115,114,99,95,114,101,97,100,95,102,114,97,109,101,115,95,108,105,110,101,97,114,0,112,67,97,99,104,101,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,109,97,108,95,115,114,99,95,99,97,99,104,101,95,114,101,97,100,95,102,114,97,109,101,115,0,112,67,97,99,104,101,45,62,112,83,82,67,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,112,67,97,99,104,101,45,62,112,83,82,67,45,62,111,110,82,101,97,100,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,109,97,108,95,115,114,99,95,114,101,97,100,95,102,114,97,109,101,115,95,112,97,115,115,116,104,114,111,117,103,104,0,109,97,108,95,100,101,118,105,99,101,95,95,114,101,97,100,95,102,114,97,109,101,115,95,102,114,111,109,95,99,108,105,101,110,116,0,99,104,97,110,110,101,108,115,32,62,32,48,0,109,97,108,95,95,105,115,95,99,104,97,110,110,101,108,95,109,97,112,95,118,97,108,105,100,0,109,97,108,95,119,111,114,107,101,114,95,116,104,114,101,97,100,0,109,97,108,95,100,101,118,105,99,101,95,95,103,101,116,95,115,116,97,116,101,40,112,68,101,118,105,99,101,41,32,61,61,32,51,0,109,97,108,95,100,101,118,105,99,101,95,95,115,116,97,114,116,95,98,97,99,107,101,110,100,0,109,97,108,95,100,101,118,105,99,101,95,95,115,116,111,112,95,98,97,99,107,101,110,100,0,109,97,108,95,99,111,110,116,101,120,116,95,117,110,105,110,105,116,0,109,97,108,95,101,110,117,109,101,114,97,116,101,95,100,101,118,105,99,101,115,40,41,32,99,97,108,108,101,100,32,119,105,116,104,32,105,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,115,32,40,112,67,111,117,110,116,32,61,61,32,48,41,46,0,109,97,108,95,101,110,117,109,101,114,97,116,101,95,100,101,118,105,99,101,115,0,109,97,108,95,100,101,118,105,99,101,95,105,110,105,116,40,41,32,99,97,108,108,101,100,32,119,105,116,104,32,105,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,115,32,40,112,68,101,118,105,99,101,32,61,61,32,78,85,76,76,41,46,0,109,97,108,95,100,101,118,105,99,101,95,105,110,105,116,40,41,32,99,97,108,108,101,100,32,119,105,116,104,32,105,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,115,32,40,112,67,111,110,102,105,103,32,61,61,32,78,85,76,76,41,46,0,87,65,82,78,73,78,71,58,32,109,97,108,95,100,101,118,105,99,101,95,105,110,105,116,40,41,32,99,97,108,108,101,100,32,102,111,114,32,97,32,100,101,118,105,99,101,32,116,104,97,116,32,105,115,32,110,111,116,32,112,114,111,112,101,114,108,121,32,97,108,105,103,110,101,100,46,32,84,104,114,101,97,100,32,115,97,102,101,116,121,32,105,115,32,110,111,116,32,115,117,112,112,111,114,116,101,100,46,0,109,97,108,95,100,101,118,105,99,101,95,105,110,105,116,40,41,32,99,97,108,108,101,100,32,119,105,116,104,32,105,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,115,32,40,112,67,111,110,116,101,120,116,32,61,61,32,78,85,76,76,41,46,0,109,97,108,95,100,101,118,105,99,101,95,105,110,105,116,40,41,32,99,97,108,108,101,100,32,119,105,116,104,32,97,110,32,105,110,118,97,108,105,100,32,99,111,110,102,105,103,46,32,67,104,97,110,110,101,108,32,99,111,117,110,116,32,109,117,115,116,32,98,101,32,103,114,101,97,116,101,114,32,116,104,97,110,32,48,46,0,109,97,108,95,100,101,118,105,99,101,95,105,110,105,116,40,41,32,99,97,108,108,101,100,32,119,105,116,104,32,97,110,32,105,110,118,97,108,105,100,32,99,111,110,102,105,103,46,32,67,104,97,110,110,101,108,32,99,111,117,110,116,32,99,97,110,110,111,116,32,101,120,99,101,101,100,32,49,56,46,0,109,97,108,95,100,101,118,105,99,101,95,105,110,105,116,40,41,32,99,97,108,108,101,100,32,119,105,116,104,32,97,110,32,105,110,118,97,108,105,100,32,99,111,110,102,105,103,46,32,83,97,109,112,108,101,32,114,97,116,101,32,109,117,115,116,32,98,101,32,103,114,101,97,116,101,114,32,116,104,97,110,32,48,46,0,109,97,108,95,100,101,118,105,99,101,95,105,110,105,116,40,41,32,99,97,108,108,101,100,32,119,105,116,104,32,105,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,115,46,32,67,104,97,110,110,101,108,32,109,97,112,32,105,115,32,105,110,118,97,108,105,100,46,0,70,97,105,108,101,100,32,116,111,32,99,114,101,97,116,101,32,109,117,116,101,120,46,0,70,97,105,108,101,100,32,116,111,32,99,114,101,97,116,101,32,119,111,114,107,101,114,32,116,104,114,101,97,100,32,119,97,107,101,117,112,32,101,118,101,110,116,46,0,70,97,105,108,101,100,32,116,111,32,99,114,101,97,116,101,32,119,111,114,107,101,114,32,116,104,114,101,97,100,32,115,116,97,114,116,32,101,118,101,110,116,46,0,70,97,105,108,101,100,32,116,111,32,99,114,101,97,116,101,32,119,111,114,107,101,114,32,116,104,114,101,97,100,32,115,116,111,112,32,101,118,101,110,116,46,0,80,108,97,121,98,97,99,107,32,68,101,118,105,99,101,0,67,97,112,116,117,114,101,32,68,101,118,105,99,101,0,70,97,105,108,101,100,32,116,111,32,99,114,101,97,116,101,32,119,111,114,107,101,114,32,116,104,114,101,97,100,46,0,109,97,108,95,100,101,118,105,99,101,95,95,103,101,116,95,115,116,97,116,101,40,112,68,101,118,105,99,101,41,32,61,61,32,49,0,109,97,108,95,100,101,118,105,99,101,95,105,110,105,116,0,109,97,108,95,100,101,118,105,99,101,95,115,116,111,112,40,41,32,99,97,108,108,101,100,32,119,105,116,104,32,105,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,115,32,40,112,68,101,118,105,99,101,32,61,61,32,78,85,76,76,41,46,0,109,97,108,95,100,101,118,105,99,101,95,115,116,111,112,40,41,32,99,97,108,108,101,100,32,102,111,114,32,97,110,32,117,110,105,110,105,116,105,97,108,105,122,101,100,32,100,101,118,105,99,101,46,0,109,97,108,95,100,101,118,105,99,101,95,115,116,111,112,40,41,32,99,97,108,108,101,100,32,119,104,105,108,101,32,97,110,111,116,104,101,114,32,116,104,114,101,97,100,32,105,115,32,97,108,114,101,97,100,121,32,115,116,111,112,112,105,110,103,32,105,116,46,0,109,97,108,95,100,101,118,105,99,101,95,115,116,111,112,40,41,32,99,97,108,108,101,100,32,102,111,114,32,97,32,100,101,118,105,99,101,32,116,104,97,116,39,115,32,97,108,114,101,97,100,121,32,115,116,111,112,112,101,100,46,0,109,97,108,95,100,101,118,105,99,101,95,115,116,111,112,40,41,32,99,97,108,108,101,100,32,119,104,105,108,101,32,97,110,111,116,104,101,114,32,116,104,114,101,97,100,32,105,115,32,105,110,32,116,104,101,32,112,114,111,99,101,115,115,32,111,102,32,115,116,97,114,116,105,110,103,32,105,116,46,0,109,97,108,95,100,101,118,105,99,101,95,95,98,114,101,97,107,95,109,97,105,110,95,108,111,111,112,0,109,97,108,95,100,101,118,105,99,101,95,95,115,116,111,112,95,98,97,99,107,101,110,100,95,95,115,100,108,0,109,97,108,95,100,101,118,105,99,101,95,95,111,110,95,114,101,97,100,95,102,114,111,109,95,100,101,118,105,99,101,0,109,97,108,95,115,114,99,95,99,97,99,104,101,95,105,110,105,116,0,112,68,83,80,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,109,97,108,95,100,115,112,95,95,115,114,99,95,111,110,95,114,101,97,100,0,109,97,108,95,100,101,118,105,99,101,95,95,111,110,95,114,101,97,100,95,102,114,111,109,95,99,108,105,101,110,116,0,109,97,108,95,99,111,110,116,101,120,116,95,95,116,114,121,95,103,101,116,95,100,101,118,105,99,101,95,110,97,109,101,95,98,121,95,105,100,0,112,78,97,109,101,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,109,97,108,95,100,101,118,105,99,101,95,115,116,97,114,116,40,41,32,99,97,108,108,101,100,32,119,105,116,104,32,105,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,115,32,40,112,68,101,118,105,99,101,32,61,61,32,78,85,76,76,41,46,0,109,97,108,95,100,101,118,105,99,101,95,115,116,97,114,116,40,41,32,99,97,108,108,101,100,32,102,111,114,32,97,110,32,117,110,105,110,105,116,105,97,108,105,122,101,100,32,100,101,118,105,99,101,46,0,109,97,108,95,100,101,118,105,99,101,95,115,116,97,114,116,40,41,32,99,97,108,108,101,100,32,119,104,105,108,101,32,97,110,111,116,104,101,114,32,116,104,114,101,97,100,32,105,115,32,97,108,114,101,97,100,121,32,115,116,97,114,116,105,110,103,32,105,116,46,0,109,97,108,95,100,101,118,105,99,101,95,115,116,97,114,116,40,41,32,99,97,108,108,101,100,32,102,111,114,32,97,32,100,101,118,105,99,101,32,116,104,97,116,39,115,32,97,108,114,101,97,100,121,32,115,116,97,114,116,101,100,46,0,109,97,108,95,100,101,118,105,99,101,95,115,116,97,114,116,40,41,32,99,97,108,108,101,100,32,119,104,105,108,101,32,97,110,111,116,104,101,114,32,116,104,114,101,97,100,32,105,115,32,105,110,32,116,104,101,32,112,114,111,99,101,115,115,32,111,102,32,115,116,111,112,112,105,110,103,32,105,116,46,0,109,97,108,95,100,101,118,105,99,101,95,95,115,116,97,114,116,95,98,97,99,107,101,110,100,95,95,115,100,108,0,112,68,97,116,97,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,109,97,108,95,99,111,110,118,101,114,116,95,102,114,97,109,101,115,95,95,111,110,95,114,101,97,100,0,112,68,97,116,97,45,62,116,111,116,97,108,70,114,97,109,101,67,111,117,110,116,32,62,61,32,112,68,97,116,97,45,62,105,78,101,120,116,70,114,97,109,101,0,85,110,107,110,111,119,110,0,83,68,76,0,79,112,101,110,65,76,0,79,112,101,110,83,76,124,69,83,0,79,83,83,0,65,76,83,65,0,87,105,110,77,77,0,68,105,114,101,99,116,83,111,117,110,100,0,87,65,83,65,80,73,0,78,117,108,108,0,73,110,118,97,108,105,100,0,51,50,45,98,105,116,32,73,69,69,69,32,70,108,111,97,116,105,110,103,32,80,111,105,110,116,0,51,50,45,98,105,116,32,83,105,103,110,101,100,32,73,110,116,101,103,101,114,0,50,52,45,98,105,116,32,83,105,103,110,101,100,32,73,110,116,101,103,101,114,32,40,84,105,103,104,116,108,121,32,80,97,99,107,101,100,41,0,49,54,45,98,105,116,32,83,105,103,110,101,100,32,73,110,116,101,103,101,114,0,56,45,98,105,116,32,85,110,115,105,103,110,101,100,32,73,110,116,101,103,101,114,0,69,112,115,105,108,111,110,32,118,97,108,117,101,32,105,115,32,116,111,111,32,108,97,114,103,101,46,0,99,105,32,61,61,32,110,112,111,105,110,116,115,0,46,47,101,120,116,101,114,110,97,108,47,112,97,114,95,115,104,97,112,101,115,46,104,0,112,97,114,95,115,104,97,112,101,115,95,95,119,101,108,100,95,112,111,105,110,116,115,0,114,97,100,105,117,115,32,60,61,32,49,46,48,32,38,38,32,34,85,115,101,32,115,109,97,108,108,101,114,32,114,97,100,105,117,115,32,116,111,32,97,118,111,105,100,32,115,101,108,102,45,105,110,116,101,114,115,101,99,116,105,111,110,46,34,0,112,97,114,95,115,104,97,112,101,115,95,99,114,101,97,116,101,95,116,111,114,117,115,0,114,97,100,105,117,115,32,62,61,32,48,46,49,32,38,38,32,34,85,115,101,32,108,97,114,103,101,114,32,114,97,100,105,117,115,32,116,111,32,97,118,111,105,100,32,115,101,108,102,45,105,110,116,101,114,115,101,99,116,105,111,110,46,34,0,114,97,100,105,117,115,32,60,61,32,51,46,48,32,38,38,32,34,85,115,101,32,115,109,97,108,108,101,114,32,114,97,100,105,117,115,32,116,111,32,97,118,111,105,100,32,115,101,108,102,45,105,110,116,101,114,115,101,99,116,105,111,110,46,34,0,112,97,114,95,115,104,97,112,101,115,95,99,114,101,97,116,101,95,116,114,101,102,111,105,108,95,107,110,111,116,0,114,97,100,105,117,115,32,62,61,32,48,46,53,32,38,38,32,34,85,115,101,32,108,97,114,103,101,114,32,114,97,100,105,117,115,32,116,111,32,97,118,111,105,100,32,115,101,108,102,45,105,110,116,101,114,115,101,99,116,105,111,110,46,34,0,46,111,98,106,0,77,101,115,104,32,99,111,117,108,100,32,110,111,116,32,98,101,32,108,111,97,100,101,100,0,91,37,115,93,32,79,66,74,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,37,99,0,91,37,115,93,32,77,111,100,101,108,32,118,101,114,116,105,99,101,115,58,32,37,105,0,91,37,115,93,32,77,111,100,101,108,32,116,101,120,99,111,111,114,100,115,58,32,37,105,0,91,37,115,93,32,77,111,100,101,108,32,110,111,114,109,97,108,115,58,32,37,105,0,91,37,115,93,32,77,111,100,101,108,32,116,114,105,97,110,103,108,101,115,58,32,37,105,0,37,102,32,37,102,37,42,91,94,10,93,115,10,0,37,102,32,37,102,32,37,102,0,91,37,115,93,32,78,111,32,110,111,114,109,97,108,115,32,100,97,116,97,32,111,110,32,79,66,74,44,32,110,111,114,109,97,108,115,32,119,105,108,108,32,98,101,32,103,101,110,101,114,97,116,101,100,32,102,114,111,109,32,102,97,99,101,115,32,100,97,116,97,0,37,105,32,37,105,32,37,105,0,37,105,47,37,105,32,37,105,47,37,105,32,37,105,47,37,105,0,37,105,47,47,37,105,32,37,105,47,47,37,105,32,37,105,47,47,37,105,0,37,105,47,37,105,47,37,105,32,37,105,47,37,105,47,37,105,32,37,105,47,37,105,47,37,105,0,91,37,115,93,32,77,111,100,101,108,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,105,110,32,82,65,77,32,40,67,80,85,41,0,85,110,108,111,97,100,101,100,32,109,111,100,101,108,32,100,97,116,97,32,40,109,101,115,104,32,97,110,100,32,109,97,116,101,114,105,97,108,41,32,102,114,111,109,32,82,65,77,32,97,110,100,32,86,82,65,77,0,46,109,116,108,0,91,37,115,93,32,77,84,76,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,110,101,119,109,116,108,32,37,115,0,91,37,115,93,32,76,111,97,100,105,110,103,32,109,97,116,101,114,105,97,108,46,46,46,0,75,97,32,37,102,32,37,102,32,37,102,0,75,100,32,37,102,32,37,102,32,37,102,0,75,115,32,37,102,32,37,102,32,37,102,0,78,115,32,37,105,0,109,97,112,95,75,100,32,37,115,0,109,97,112,95,75,115,32,37,115,0,109,97,112,95,66,117,109,112,32,37,115,0,109,97,112,95,98,117,109,112,32,37,115,0,100,32,37,102,0,98,117,109,112,32,37,115,0,84,114,32,37,102,0,91,37,115,93,32,77,97,116,101,114,105,97,108,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,83,116,97,99,107,32,66,117,102,102,101,114,32,79,118,101,114,102,108,111,119,32,40,77,65,88,32,37,105,32,77,97,116,114,105,120,41,0,77,65,88,95,76,73,78,69,83,95,66,65,84,67,72,32,111,118,101,114,102,108,111,119,0,77,65,88,95,84,82,73,65,78,71,76,69,83,95,66,65,84,67,72,32,111,118,101,114,102,108,111,119,0,77,65,88,95,81,85,65,68,83,95,66,65,84,67,72,32,111,118,101,114,102,108,111,119,0,67,108,97,109,112,32,109,105,114,114,111,114,32,119,114,97,112,32,109,111,100,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,91,84,69,88,32,73,68,32,37,105,93,32,77,97,120,105,109,117,109,32,97,110,105,115,111,116,114,111,112,105,99,32,102,105,108,116,101,114,32,108,101,118,101,108,32,115,117,112,112,111,114,116,101,100,32,105,115,32,37,105,88,0,65,110,105,115,111,116,114,111,112,105,99,32,102,105,108,116,101,114,105,110,103,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,91,70,66,79,32,73,68,32,37,105,93,32,85,110,108,111,97,100,101,100,32,114,101,110,100,101,114,32,116,101,120,116,117,114,101,32,100,97,116,97,32,102,114,111,109,32,86,82,65,77,32,40,71,80,85,41,0,91,86,65,79,32,73,68,32,37,105,93,32,85,110,108,111,97,100,101,100,32,109,111,100,101,108,32,100,97,116,97,32,102,114,111,109,32,86,82,65,77,32,40,71,80,85,41,0,91,86,66,79,32,73,68,32,37,105,93,32,85,110,108,111,97,100,101,100,32,109,111,100,101,108,32,118,101,114,116,101,120,32,100,97,116,97,32,102,114,111,109,32,86,82,65,77,32,40,71,80,85,41,0,71,80,85,58,32,86,101,110,100,111,114,58,32,32,32,37,115,0,71,80,85,58,32,82,101,110,100,101,114,101,114,58,32,37,115,0,71,80,85,58,32,86,101,114,115,105,111,110,58,32,32,37,115,0,71,80,85,58,32,71,76,83,76,58,32,32,32,32,32,37,115,0,32,0,78,117,109,98,101,114,32,111,102,32,115,117,112,112,111,114,116,101,100,32,101,120,116,101,110,115,105,111,110,115,58,32,37,105,0,71,76,95,79,69,83,95,118,101,114,116,101,120,95,97,114,114,97,121,95,111,98,106,101,99,116,0,103,108,71,101,110,86,101,114,116,101,120,65,114,114,97,121,115,79,69,83,0,103,108,66,105,110,100,86,101,114,116,101,120,65,114,114,97,121,79,69,83,0,103,108,68,101,108,101,116,101,86,101,114,116,101,120,65,114,114,97,121,115,79,69,83,0,71,76,95,79,69,83,95,116,101,120,116,117,114,101,95,110,112,111,116,0,79,69,83,95,116,101,120,116,117,114,101,95,102,108,111,97,116,0,71,76,95,69,88,84,95,116,101,120,116,117,114,101,95,99,111,109,112,114,101,115,115,105,111,110,95,115,51,116,99,0,71,76,95,87,69,66,71,76,95,99,111,109,112,114,101,115,115,101,100,95,116,101,120,116,117,114,101,95,115,51,116,99,0,71,76,95,87,69,66,75,73,84,95,87,69,66,71,76,95,99,111,109,112,114,101,115,115,101,100,95,116,101,120,116,117,114,101,95,115,51,116,99,0,71,76,95,79,69,83,95,99,111,109,112,114,101,115,115,101,100,95,69,84,67,49,95,82,71,66,56,95,116,101,120,116,117,114,101,0,71,76,95,87,69,66,71,76,95,99,111,109,112,114,101,115,115,101,100,95,116,101,120,116,117,114,101,95,101,116,99,49,0,71,76,95,65,82,66,95,69,83,51,95,99,111,109,112,97,116,105,98,105,108,105,116,121,0,71,76,95,73,77,71,95,116,101,120,116,117,114,101,95,99,111,109,112,114,101,115,115,105,111,110,95,112,118,114,116,99,0,71,76,95,75,72,82,95,116,101,120,116,117,114,101,95,99,111,109,112,114,101,115,115,105,111,110,95,97,115,116,99,95,104,100,114,0,71,76,95,69,88,84,95,116,101,120,116,117,114,101,95,102,105,108,116,101,114,95,97,110,105,115,111,116,114,111,112,105,99,0,71,76,95,69,88,84,95,116,101,120,116,117,114,101,95,109,105,114,114,111,114,95,99,108,97,109,112,0,91,69,88,84,69,78,83,73,79,78,93,32,86,65,79,32,101,120,116,101,110,115,105,111,110,32,100,101,116,101,99,116,101,100,44,32,86,65,79,32,102,117,110,99,116,105,111,110,115,32,105,110,105,116,105,97,108,105,122,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,91,69,88,84,69,78,83,73,79,78,93,32,86,65,79,32,101,120,116,101,110,115,105,111,110,32,110,111,116,32,102,111,117,110,100,44,32,86,65,79,32,117,115,97,103,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,91,69,88,84,69,78,83,73,79,78,93,32,78,80,79,84,32,116,101,120,116,117,114,101,115,32,101,120,116,101,110,115,105,111,110,32,100,101,116,101,99,116,101,100,44,32,102,117,108,108,32,78,80,79,84,32,116,101,120,116,117,114,101,115,32,115,117,112,112,111,114,116,101,100,0,91,69,88,84,69,78,83,73,79,78,93,32,78,80,79,84,32,116,101,120,116,117,114,101,115,32,101,120,116,101,110,115,105,111,110,32,110,111,116,32,102,111,117,110,100,44,32,108,105,109,105,116,101,100,32,78,80,79,84,32,115,117,112,112,111,114,116,32,40,110,111,45,109,105,112,109,97,112,115,44,32,110,111,45,114,101,112,101,97,116,41,0,91,69,88,84,69,78,83,73,79,78,93,32,68,88,84,32,99,111,109,112,114,101,115,115,101,100,32,116,101,120,116,117,114,101,115,32,115,117,112,112,111,114,116,101,100,0,91,69,88,84,69,78,83,73,79,78,93,32,69,84,67,49,32,99,111,109,112,114,101,115,115,101,100,32,116,101,120,116,117,114,101,115,32,115,117,112,112,111,114,116,101,100,0,91,69,88,84,69,78,83,73,79,78,93,32,69,84,67,50,47,69,65,67,32,99,111,109,112,114,101,115,115,101,100,32,116,101,120,116,117,114,101,115,32,115,117,112,112,111,114,116,101,100,0,91,69,88,84,69,78,83,73,79,78,93,32,80,86,82,84,32,99,111,109,112,114,101,115,115,101,100,32,116,101,120,116,117,114,101,115,32,115,117,112,112,111,114,116,101,100,0,91,69,88,84,69,78,83,73,79,78,93,32,65,83,84,67,32,99,111,109,112,114,101,115,115,101,100,32,116,101,120,116,117,114,101,115,32,115,117,112,112,111,114,116,101,100,0,91,69,88,84,69,78,83,73,79,78,93,32,65,110,105,115,111,116,114,111,112,105,99,32,116,101,120,116,117,114,101,115,32,102,105,108,116,101,114,105,110,103,32,115,117,112,112,111,114,116,101,100,32,40,109,97,120,58,32,37,46,48,102,88,41,0,91,69,88,84,69,78,83,73,79,78,93,32,67,108,97,109,112,32,109,105,114,114,111,114,32,119,114,97,112,32,116,101,120,116,117,114,101,32,109,111,100,101,32,115,117,112,112,111,114,116,101,100,0,91,84,69,88,32,73,68,32,37,105,93,32,66,97,115,101,32,119,104,105,116,101,32,116,101,120,116,117,114,101,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,66,97,115,101,32,119,104,105,116,101,32,116,101,120,116,117,114,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,108,111,97,100,101,100,0,79,112,101,110,71,76,32,100,101,102,97,117,108,116,32,115,116,97,116,101,115,32,105,110,105,116,105,97,108,105,122,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,91,67,80,85,93,32,68,101,102,97,117,108,116,32,98,117,102,102,101,114,115,32,105,110,105,116,105,97,108,105,122,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,108,105,110,101,115,44,32,116,114,105,97,110,103,108,101,115,44,32,113,117,97,100,115,41,0,91,86,65,79,32,73,68,32,37,105,93,32,68,101,102,97,117,108,116,32,98,117,102,102,101,114,115,32,86,65,79,32,105,110,105,116,105,97,108,105,122,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,108,105,110,101,115,41,0,91,86,66,79,32,73,68,32,37,105,93,91,86,66,79,32,73,68,32,37,105,93,32,68,101,102,97,117,108,116,32,98,117,102,102,101,114,115,32,86,66,79,115,32,105,110,105,116,105,97,108,105,122,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,108,105,110,101,115,41,0,91,86,65,79,32,73,68,32,37,105,93,32,68,101,102,97,117,108,116,32,98,117,102,102,101,114,115,32,86,65,79,32,105,110,105,116,105,97,108,105,122,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,116,114,105,97,110,103,108,101,115,41,0,91,86,66,79,32,73,68,32,37,105,93,91,86,66,79,32,73,68,32,37,105,93,32,68,101,102,97,117,108,116,32,98,117,102,102,101,114,115,32,86,66,79,115,32,105,110,105,116,105,97,108,105,122,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,116,114,105,97,110,103,108,101,115,41,0,91,86,65,79,32,73,68,32,37,105,93,32,68,101,102,97,117,108,116,32,98,117,102,102,101,114,115,32,86,65,79,32,105,110,105,116,105,97,108,105,122,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,113,117,97,100,115,41,0,91,86,66,79,32,73,68,32,37,105,93,91,86,66,79,32,73,68,32,37,105,93,91,86,66,79,32,73,68,32,37,105,93,91,86,66,79,32,73,68,32,37,105,93,32,68,101,102,97,117,108,116,32,98,117,102,102,101,114,115,32,86,66,79,115,32,105,110,105,116,105,97,108,105,122,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,113,117,97,100,115,41,0,35,118,101,114,115,105,111,110,32,49,48,48,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,97,116,116,114,105,98,117,116,101,32,118,101,99,51,32,118,101,114,116,101,120,80,111,115,105,116,105,111,110,59,32,32,32,32,32,10,97,116,116,114,105,98,117,116,101,32,118,101,99,50,32,118,101,114,116,101,120,84,101,120,67,111,111,114,100,59,32,32,32,32,32,10,97,116,116,114,105,98,117,116,101,32,118,101,99,52,32,118,101,114,116,101,120,67,111,108,111,114,59,32,32,32,32,32,32,32,32,10,118,97,114,121,105,110,103,32,118,101,99,50,32,102,114,97,103,84,101,120,67,111,111,114,100,59,32,32,32,32,32,32,32,32,32,10,118,97,114,121,105,110,103,32,118,101,99,52,32,102,114,97,103,67,111,108,111,114,59,32,32,32,32,32,32,32,32,32,32,32,32,10,117,110,105,102,111,114,109,32,109,97,116,52,32,109,118,112,59,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,118,111,105,100,32,109,97,105,110,40,41,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,123,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,32,32,32,32,102,114,97,103,84,101,120,67,111,111,114,100,32,61,32,118,101,114,116,101,120,84,101,120,67,111,111,114,100,59,32,10,32,32,32,32,102,114,97,103,67,111,108,111,114,32,61,32,118,101,114,116,101,120,67,111,108,111,114,59,32,32,32,32,32,32,32,10,32,32,32,32,103,108,95,80,111,115,105,116,105,111,110,32,61,32,109,118,112,42,118,101,99,52,40,118,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,32,10,125,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,0,35,118,101,114,115,105,111,110,32,49,48,48,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,112,114,101,99,105,115,105,111,110,32,109,101,100,105,117,109,112,32,102,108,111,97,116,59,32,32,32,32,32,32,32,32,32,32,32,10,118,97,114,121,105,110,103,32,118,101,99,50,32,102,114,97,103,84,101,120,67,111,111,114,100,59,32,32,32,32,32,32,32,32,32,10,118,97,114,121,105,110,103,32,118,101,99,52,32,102,114,97,103,67,111,108,111,114,59,32,32,32,32,32,32,32,32,32,32,32,32,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,116,101,120,116,117,114,101,48,59,32,32,32,32,32,32,32,32,10,117,110,105,102,111,114,109,32,118,101,99,52,32,99,111,108,68,105,102,102,117,115,101,59,32,32,32,32,32,32,32,32,32,32,32,10,118,111,105,100,32,109,97,105,110,40,41,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,123,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,32,32,32,32,118,101,99,52,32,116,101,120,101,108,67,111,108,111,114,32,61,32,116,101,120,116,117,114,101,50,68,40,116,101,120,116,117,114,101,48,44,32,102,114,97,103,84,101,120,67,111,111,114,100,41,59,32,10,32,32,32,32,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,116,101,120,101,108,67,111,108,111,114,42,99,111,108,68,105,102,102,117,115,101,42,102,114,97,103,67,111,108,111,114,59,32,32,32,32,32,32,10,125,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,0,91,83,72,68,82,32,73,68,32,37,105,93,32,68,101,102,97,117,108,116,32,115,104,97,100,101,114,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,118,101,114,116,101,120,80,111,115,105,116,105,111,110,0,118,101,114,116,101,120,84,101,120,67,111,111,114,100,0,118,101,114,116,101,120,67,111,108,111,114,0,109,118,112,0,99,111,108,68,105,102,102,117,115,101,0,116,101,120,116,117,114,101,48,0,91,83,72,68,82,32,73,68,32,37,105,93,32,68,101,102,97,117,108,116,32,115,104,97,100,101,114,32,99,111,117,108,100,32,110,111,116,32,98,101,32,108,111,97,100,101,100,0,118,101,114,116,101,120,78,111,114,109,97,108,0,118,101,114,116,101,120,84,97,110,103,101,110,116,0,118,101,114,116,101,120,84,101,120,67,111,111,114,100,50,0,91,83,72,68,82,32,73,68,32,37,105,93,32,70,97,105,108,101,100,32,116,111,32,108,105,110,107,32,115,104,97,100,101,114,32,112,114,111,103,114,97,109,46,46,46,0,37,115,0,91,83,72,68,82,32,73,68,32,37,105,93,32,83,104,97,100,101,114,32,112,114,111,103,114,97,109,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,91,83,72,68,82,32,73,68,32,37,105,93,32,70,97,105,108,101,100,32,116,111,32,99,111,109,112,105,108,101,32,115,104,97,100,101,114,46,46,46,0,91,83,72,68,82,32,73,68,32,37,105,93,32,83,104,97,100,101,114,32,99,111,109,112,105,108,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,68,88,84,32,99,111,109,112,114,101,115,115,101,100,32,116,101,120,116,117,114,101,32,102,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,69,84,67,49,32,99,111,109,112,114,101,115,115,101,100,32,116,101,120,116,117,114,101,32,102,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,69,84,67,50,32,99,111,109,112,114,101,115,115,101,100,32,116,101,120,116,117,114,101,32,102,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,80,86,82,84,32,99,111,109,112,114,101,115,115,101,100,32,116,101,120,116,117,114,101,32,102,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,83,84,67,32,99,111,109,112,114,101,115,115,101,100,32,116,101,120], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE+10240);
-/* memory initializer */ allocate([116,117,114,101,32,102,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,84,101,120,116,117,114,101,32,102,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,91,84,69,88,32,73,68,32,37,105,93,32,84,101,120,116,117,114,101,32,99,114,101,97,116,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,37,105,120,37,105,41,0,91,84,69,88,32,73,68,32,37,105,93,32,85,110,108,111,97,100,101,100,32,116,101,120,116,117,114,101,32,100,97,116,97,32,40,98,97,115,101,32,119,104,105,116,101,32,116,101,120,116,117,114,101,41,32,102,114,111,109,32,86,82,65,77,0,84,101,120,116,117,114,101,32,102,111,114,109,97,116,32,117,112,100,97,116,105,110,103,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,70,114,97,109,101,98,117,102,102,101,114,32,111,98,106,101,99,116,32,99,111,117,108,100,32,110,111,116,32,98,101,32,99,114,101,97,116,101,100,46,46,46,0,70,114,97,109,101,98,117,102,102,101,114,32,105,115,32,117,110,115,117,112,112,111,114,116,101,100,0,70,114,97,109,101,98,117,102,102,101,114,32,105,110,99,111,109,112,108,101,116,101,32,97,116,116,97,99,104,109,101,110,116,0,70,114,97,109,101,98,117,102,102,101,114,32,105,110,99,111,109,112,108,101,116,101,32,100,105,109,101,110,115,105,111,110,115,0,70,114,97,109,101,98,117,102,102,101,114,32,105,110,99,111,109,112,108,101,116,101,32,109,105,115,115,105,110,103,32,97,116,116,97,99,104,109,101,110,116,0,91,70,66,79,32,73,68,32,37,105,93,32,70,114,97,109,101,98,117,102,102,101,114,32,111,98,106,101,99,116,32,99,114,101,97,116,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,91,84,69,88,32,73,68,32,37,105,93,32,77,105,112,109,97,112,115,32,103,101,110,101,114,97,116,101,100,32,97,117,116,111,109,97,116,105,99,97,108,108,121,0,91,84,69,88,32,73,68,32,37,105,93,32,77,105,112,109,97,112,115,32,99,97,110,32,110,111,116,32,98,101,32,103,101,110,101,114,97,116,101,100,0,91,86,65,79,32,73,68,32,37,105,93,32,77,101,115,104,32,117,112,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,116,111,32,86,82,65,77,32,40,71,80,85,41,0,77,101,115,104,32,99,111,117,108,100,32,110,111,116,32,98,101,32,117,112,108,111,97,100,101,100,32,116,111,32,86,82,65,77,32,40,71,80,85,41,0,91,86,66,79,115,93,32,77,101,115,104,32,117,112,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,116,111,32,86,82,65,77,32,40,71,80,85,41,0,91,37,115,93,32,84,101,120,116,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,67,117,115,116,111,109,32,115,104,97,100,101,114,32,99,111,117,108,100,32,110,111,116,32,98,101,32,108,111,97,100,101,100,0,91,83,72,68,82,32,73,68,32,37,105,93,32,65,99,116,105,118,101,32,117,110,105,102,111,114,109,32,91,37,115,93,32,115,101,116,32,97,116,32,108,111,99,97,116,105,111,110,58,32,37,105,0,112,114,111,106,101,99,116,105,111,110,0,118,105,101,119,0,116,101,120,116,117,114,101,49,0,116,101,120,116,117,114,101,50,0,91,83,72,68,82,32,73,68,32,37,105,93,32,85,110,108,111,97,100,101,100,32,115,104,97,100,101,114,32,112,114,111,103,114,97,109,32,100,97,116,97,0,91,83,72,68,82,32,73,68,32,37,105,93,32,83,104,97,100,101,114,32,117,110,105,102,111,114,109,32,91,37,115,93,32,67,79,85,76,68,32,78,79,84,32,66,69,32,70,79,85,78,68,0,91,83,72,68,82,32,73,68,32,37,105,93,32,83,104,97,100,101,114,32,117,110,105,102,111,114,109,32,91,37,115,93,32,115,101,116,32,97,116,32,108,111,99,97,116,105,111,110,58,32,37,105,0,83,104,97,100,101,114,32,118,97,108,117,101,32,102,108,111,97,116,32,97,114,114,97,121,32,115,105,122,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,104,97,100,101,114,32,118,97,108,117,101,32,105,110,116,32,97,114,114,97,121,32,115,105,122,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,73,110,105,116,105,97,108,105,122,105,110,103,32,86,82,32,83,105,109,117,108,97,116,111,114,32,40,79,99,117,108,117,115,32,82,105,102,116,32,67,86,49,41,0,73,110,105,116,105,97,108,105,122,105,110,103,32,86,82,32,83,105,109,117,108,97,116,111,114,32,40,79,99,117,108,117,115,32,82,105,102,116,32,68,75,50,41,0,35,118,101,114,115,105,111,110,32,49,48,48,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,97,116,116,114,105,98,117,116,101,32,118,101,99,51,32,118,101,114,116,101,120,80,111,115,105,116,105,111,110,59,32,32,32,32,32,10,97,116,116,114,105,98,117,116,101,32,118,101,99,50,32,118,101,114,116,101,120,84,101,120,67,111,111,114,100,59,32,32,32,32,32,10,97,116,116,114,105,98,117,116,101,32,118,101,99,52,32,118,101,114,116,101,120,67,111,108,111,114,59,32,32,32,32,32,32,32,32,10,118,97,114,121,105,110,103,32,118,101,99,50,32,102,114,97,103,84,101,120,67,111,111,114,100,59,32,32,32,32,32,32,32,32,32,10,118,97,114,121,105,110,103,32,118,101,99,52,32,102,114,97,103,67,111,108,111,114,59,32,32,32,32,32,32,32,32,32,32,32,32,10,117,110,105,102,111,114,109,32,109,97,116,52,32,109,118,112,59,32,32,32,32,32,32,32,32,32,32,32,32,10,118,111,105,100,32,109,97,105,110,40,41,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,123,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,32,32,32,32,102,114,97,103,84,101,120,67,111,111,114,100,32,61,32,118,101,114,116,101,120,84,101,120,67,111,111,114,100,59,32,10,32,32,32,32,102,114,97,103,67,111,108,111,114,32,61,32,118,101,114,116,101,120,67,111,108,111,114,59,32,32,32,32,32,32,32,10,32,32,32,32,103,108,95,80,111,115,105,116,105,111,110,32,61,32,109,118,112,42,118,101,99,52,40,118,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,32,10,125,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,0,35,118,101,114,115,105,111,110,32,49,48,48,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,112,114,101,99,105,115,105,111,110,32,109,101,100,105,117,109,112,32,102,108,111,97,116,59,32,32,32,32,32,32,32,32,32,32,32,10,118,97,114,121,105,110,103,32,118,101,99,50,32,102,114,97,103,84,101,120,67,111,111,114,100,59,32,32,32,32,32,32,32,32,32,10,118,97,114,121,105,110,103,32,118,101,99,52,32,102,114,97,103,67,111,108,111,114,59,32,32,32,32,32,32,32,32,32,32,32,32,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,116,101,120,116,117,114,101,48,59,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,117,110,105,102,111,114,109,32,118,101,99,50,32,108,101,102,116,76,101,110,115,67,101,110,116,101,114,59,32,32,32,32,32,32,32,10,117,110,105,102,111,114,109,32,118,101,99,50,32,114,105,103,104,116,76,101,110,115,67,101,110,116,101,114,59,32,32,32,32,32,32,10,117,110,105,102,111,114,109,32,118,101,99,50,32,108,101,102,116,83,99,114,101,101,110,67,101,110,116,101,114,59,32,32,32,32,32,10,117,110,105,102,111,114,109,32,118,101,99,50,32,114,105,103,104,116,83,99,114,101,101,110,67,101,110,116,101,114,59,32,32,32,32,10,117,110,105,102,111,114,109,32,118,101,99,50,32,115,99,97,108,101,59,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,117,110,105,102,111,114,109,32,118,101,99,50,32,115,99,97,108,101,73,110,59,32,32,32,32,32,32,32,32,32,32,32,32,32,32,10,117,110,105,102,111,114,109,32,118,101,99,52,32,104,109,100,87,97,114,112,80,97,114,97,109,59,32,32,32,32,32,32,32,32,32,10,117,110,105,102,111,114,109,32,118,101,99,52,32,99,104,114,111,109,97,65,98,80,97,114,97,109,59,32,32,32,32,32,32,32,32,10,118,111,105,100,32,109,97,105,110,40,41,32,10,123,32,10,32,32,32,118,101,99,50,32,108,101,110,115,67,101,110,116,101,114,32,61,32,102,114,97,103,84,101,120,67,111,111,114,100,46,120,32,60,32,48,46,53,32,63,32,108,101,102,116,76,101,110,115,67,101,110,116,101,114,32,58,32,114,105,103,104,116,76,101,110,115,67,101,110,116,101,114,59,32,10,32,32,32,118,101,99,50,32,115,99,114,101,101,110,67,101,110,116,101,114,32,61,32,102,114,97,103,84,101,120,67,111,111,114,100,46,120,32,60,32,48,46,53,32,63,32,108,101,102,116,83,99,114,101,101,110,67,101,110,116,101,114,32,58,32,114,105,103,104,116,83,99,114,101,101,110,67,101,110,116,101,114,59,32,10,32,32,32,118,101,99,50,32,116,104,101,116,97,32,61,32,40,102,114,97,103,84,101,120,67,111,111,114,100,32,45,32,108,101,110,115,67,101,110,116,101,114,41,42,115,99,97,108,101,73,110,59,32,10,32,32,32,102,108,111,97,116,32,114,83,113,32,61,32,116,104,101,116,97,46,120,42,116,104,101,116,97,46,120,32,43,32,116,104,101,116,97,46,121,42,116,104,101,116,97,46,121,59,32,10,32,32,32,118,101,99,50,32,116,104,101,116,97,49,32,61,32,116,104,101,116,97,42,40,104,109,100,87,97,114,112,80,97,114,97,109,46,120,32,43,32,104,109,100,87,97,114,112,80,97,114,97,109,46,121,42,114,83,113,32,43,32,104,109,100,87,97,114,112,80,97,114,97,109,46,122,42,114,83,113,42,114,83,113,32,43,32,104,109,100,87,97,114,112,80,97,114,97,109,46,119,42,114,83,113,42,114,83,113,42,114,83,113,41,59,32,10,32,32,32,118,101,99,50,32,116,104,101,116,97,66,108,117,101,32,61,32,116,104,101,116,97,49,42,40,99,104,114,111,109,97,65,98,80,97,114,97,109,46,122,32,43,32,99,104,114,111,109,97,65,98,80,97,114,97,109,46,119,42,114,83,113,41,59,32,10,32,32,32,118,101,99,50,32,116,99,66,108,117,101,32,61,32,108,101,110,115,67,101,110,116,101,114,32,43,32,115,99,97,108,101,42,116,104,101,116,97,66,108,117,101,59,32,10,32,32,32,105,102,32,40,97,110,121,40,98,118,101,99,50,40,99,108,97,109,112,40,116,99,66,108,117,101,44,32,115,99,114,101,101,110,67,101,110,116,101,114,32,45,32,118,101,99,50,40,48,46,50,53,44,32,48,46,53,41,44,32,115,99,114,101,101,110,67,101,110,116,101,114,32,43,32,118,101,99,50,40,48,46,50,53,44,32,48,46,53,41,41,32,45,32,116,99,66,108,117,101,41,41,41,32,10,32,32,32,123,32,10,32,32,32,32,32,32,32,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,118,101,99,52,40,48,46,48,44,32,48,46,48,44,32,48,46,48,44,32,49,46,48,41,59,32,10,32,32,32,125,32,10,32,32,32,101,108,115,101,32,10,32,32,32,123,32,10,32,32,32,32,32,32,32,102,108,111,97,116,32,98,108,117,101,32,61,32,116,101,120,116,117,114,101,50,68,40,116,101,120,116,117,114,101,48,44,32,116,99,66,108,117,101,41,46,98,59,32,10,32,32,32,32,32,32,32,118,101,99,50,32,116,99,71,114,101,101,110,32,61,32,108,101,110,115,67,101,110,116,101,114,32,43,32,115,99,97,108,101,42,116,104,101,116,97,49,59,32,10,32,32,32,32,32,32,32,102,108,111,97,116,32,103,114,101,101,110,32,61,32,116,101,120,116,117,114,101,50,68,40,116,101,120,116,117,114,101,48,44,32,116,99,71,114,101,101,110,41,46,103,59,32,10,32,32,32,32,32,32,32,118,101,99,50,32,116,104,101,116,97,82,101,100,32,61,32,116,104,101,116,97,49,42,40,99,104,114,111,109,97,65,98,80,97,114,97,109,46,120,32,43,32,99,104,114,111,109,97,65,98,80,97,114,97,109,46,121,42,114,83,113,41,59,32,10,32,32,32,32,32,32,32,118,101,99,50,32,116,99,82,101,100,32,61,32,108,101,110,115,67,101,110,116,101,114,32,43,32,115,99,97,108,101,42,116,104,101,116,97,82,101,100,59,32,10,32,32,32,32,32,32,32,102,108,111,97,116,32,114,101,100,32,61,32,116,101,120,116,117,114,101,50,68,40,116,101,120,116,117,114,101,48,44,32,116,99,82,101,100,41,46,114,59,32,10,32,32,32,32,32,32,32,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,118,101,99,52,40,114,101,100,44,32,103,114,101,101,110,44,32,98,108,117,101,44,32,49,46,48,41,59,32,10,32,32,32,32,125,32,10,125,32,10,0,86,82,58,32,68,105,115,116,111,114,116,105,111,110,32,83,99,97,108,101,58,32,37,102,0,86,82,58,32,68,105,115,116,111,114,116,105,111,110,32,83,104,97,100,101,114,58,32,76,101,102,116,76,101,110,115,67,101,110,116,101,114,32,61,32,123,32,37,102,44,32,37,102,32,125,0,86,82,58,32,68,105,115,116,111,114,116,105,111,110,32,83,104,97,100,101,114,58,32,82,105,103,104,116,76,101,110,115,67,101,110,116,101,114,32,61,32,123,32,37,102,44,32,37,102,32,125,0,86,82,58,32,68,105,115,116,111,114,116,105,111,110,32,83,104,97,100,101,114,58,32,83,99,97,108,101,32,61,32,123,32,37,102,44,32,37,102,32,125,0,86,82,58,32,68,105,115,116,111,114,116,105,111,110,32,83,104,97,100,101,114,58,32,83,99,97,108,101,73,110,32,61,32,123,32,37,102,44,32,37,102,32,125,0,108,101,102,116,76,101,110,115,67,101,110,116,101,114,0,114,105,103,104,116,76,101,110,115,67,101,110,116,101,114,0,108,101,102,116,83,99,114,101,101,110,67,101,110,116,101,114,0,114,105,103,104,116,83,99,114,101,101,110,67,101,110,116,101,114,0,115,99,97,108,101,0,115,99,97,108,101,73,110,0,104,109,100,87,97,114,112,80,97,114,97,109,0,99,104,114,111,109,97,65,98,80,97,114,97,109,0,91,84,69,88,32,73,68,32,37,105,93,32,68,101,102,97,117,108,116,32,102,111,110,116,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,46,116,116,102,0,46,102,110,116,0,91,37,115,93,32,83,112,114,105,116,101,70,111,110,116,32,99,111,117,108,100,32,110,111,116,32,98,101,32,108,111,97,100,101,100,44,32,117,115,105,110,103,32,100,101,102,97,117,108,116,32,102,111,110,116,0,83,112,114,105,116,101,70,111,110,116,32,100,97,116,97,32,112,97,114,115,101,100,32,99,111,114,114,101,99,116,108,121,32,102,114,111,109,32,105,109,97,103,101,0,73,109,97,103,101,32,102,105,108,101,32,108,111,97,100,101,100,32,99,111,114,114,101,99,116,108,121,32,97,115,32,83,112,114,105,116,101,70,111,110,116,0,114,116,0,91,37,115,93,32,70,78,84,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,108,105,110,101,72,101,105,103,104,116,0,108,105,110,101,72,101,105,103,104,116,61,37,105,32,98,97,115,101,61,37,105,32,115,99,97,108,101,87,61,37,105,32,115,99,97,108,101,72,61,37,105,0,91,37,115,93,32,70,111,110,116,32,115,105,122,101,58,32,37,105,0,91,37,115,93,32,70,111,110,116,32,116,101,120,116,117,114,101,32,115,99,97,108,101,58,32,37,105,120,37,105,0,102,105,108,101,0,102,105,108,101,61,34,37,49,50,56,91,94,34,93,34,0,91,37,115,93,32,70,111,110,116,32,116,101,120,116,117,114,101,32,102,105,108,101,110,97,109,101,58,32,37,115,0,99,111,117,110,116,0,99,111,117,110,116,61,37,105,0,91,37,115,93,32,70,111,110,116,32,110,117,109,32,99,104,97,114,115,58,32,37,105,0,91,37,115,93,32,70,111,110,116,32,116,101,120,116,117,114,101,32,108,111,97,100,105,110,103,32,112,97,116,104,58,32,37,115,0,99,104,97,114,32,105,100,61,37,105,32,120,61,37,105,32,121,61,37,105,32,119,105,100,116,104,61,37,105,32,104,101,105,103,104,116,61,37,105,32,120,111,102,102,115,101,116,61,37,105,32,121,111,102,102,115,101,116,61,37,105,32,120,97,100,118,97,110,99,101,61,37,105,0,91,37,115,93,32,83,112,114,105,116,101,70,111,110,116,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,85,110,108,111,97,100,101,100,32,115,112,114,105,116,101,32,102,111,110,116,32,100,97,116,97,0,91,37,115,93,32,83,112,114,105,116,101,70,111,110,116,32,99,111,117,108,100,32,110,111,116,32,98,101,32,103,101,110,101,114,97,116,101,100,44,32,117,115,105,110,103,32,100,101,102,97,117,108,116,32,102,111,110,116,0,84,84,70,32,115,112,114,105,116,101,102,111,110,116,32,108,111,97,100,105,110,103,58,32,80,114,101,100,105,99,116,101,100,32,116,101,120,116,117,114,101,32,115,105,122,101,58,32,37,105,120,37,105,0,91,37,115,93,32,84,84,70,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,84,84,70,32,115,112,114,105,116,101,102,111,110,116,32,108,111,97,100,105,110,103,58,32,102,105,114,115,116,32,99,104,97,114,97,99,116,101,114,32,105,115,32,110,111,116,32,83,80,65,67,69,40,51,50,41,32,99,104,97,114,97,99,116,101,114,0,84,84,70,32,115,112,114,105,116,101,102,111,110,116,32,108,111,97,100,105,110,103,58,32,78,111,116,32,97,108,108,32,116,104,101,32,99,104,97,114,97,99,116,101,114,115,32,102,105,116,32,105,110,32,116,104,101,32,102,111,110,116,0,120,43,103,119,32,60,32,112,119,0,46,47,101,120,116,101,114,110,97,108,47,115,116,98,95,116,114,117,101,116,121,112,101,46,104,0,115,116,98,116,116,95,66,97,107,101,70,111,110,116,66,105,116,109,97,112,95,105,110,116,101,114,110,97,108,0,122,45,62,100,105,114,101,99,116,105,111,110,0,115,116,98,116,116,95,95,114,97,115,116,101,114,105,122,101,95,115,111,114,116,101,100,95,101,100,103,101,115,0,122,45,62,101,121,32,62,61,32,115,99,97,110,95,121,95,116,111,112,0,101,45,62,101,121,32,62,61,32,121,95,116,111,112,0,115,116,98,116,116,95,95,102,105,108,108,95,97,99,116,105,118,101,95,101,100,103,101,115,95,110,101,119,0,101,45,62,115,121,32,60,61,32,121,95,98,111,116,116,111,109,32,38,38,32,101,45,62,101,121,32,62,61,32,121,95,116,111,112,0,120,32,62,61,32,48,32,38,38,32,120,32,60,32,108,101,110,0,102,97,98,115,40,97,114,101,97,41,32,60,61,32,49,46,48,49,102,0,121,48,32,60,32,121,49,0,115,116,98,116,116,95,95,104,97,110,100,108,101,95,99,108,105,112,112,101,100,95,101,100,103,101,0,101,45,62,115,121,32,60,61,32,101,45,62,101,121,0,120,49,32,60,61,32,120,43,49,0,120,49,32,62,61,32,120,0,120,49,32,60,61,32,120,0,120,49,32,62,61,32,120,43,49,0,120,49,32,62,61,32,120,32,38,38,32,120,49,32,60,61,32,120,43,49,0,120,48,32,62,61,32,120,32,38,38,32,120,48,32,60,61,32,120,43,49,32,38,38,32,120,49,32,62,61,32,120,32,38,38,32,120,49,32,60,61,32,120,43,49,0,122,32,33,61,32,40,40,118,111,105,100,42,41,48,41,0,115,116,98,116,116,95,95,110,101,119,95,97,99,116,105,118,101,0,33,105,110,102,111,45,62,99,102,102,46,115,105,122,101,0,115,116,98,116,116,95,95,71,101,116,71,108,121,102,79,102,102,115,101,116,0,115,116,98,116,116,95,95,99,102,102,95,105,110,116,0,110,32,62,61,32,49,32,38,38,32,110,32,60,61,32,52,0,115,116,98,116,116,95,95,98,117,102,95,103,101,116,0,115,105,122,101,32,60,32,48,120,52,48,48,48,48,48,48,48,0,115,116,98,116,116,95,95,110,101,119,95,98,117,102,0,33,40,111,32,62,32,98,45,62,115,105,122,101,32,124,124,32,111,32,60,32,48,41,0,115,116,98,116,116,95,95,98,117,102,95,115,101,101,107,0,111,102,102,115,105,122,101,32,62,61,32,49,32,38,38,32,111,102,102,115,105,122,101,32,60,61,32,52,0,115,116,98,116,116,95,95,99,102,102,95,103,101,116,95,105,110,100,101,120,0,98,48,32,62,61,32,50,56,0,115,116,98,116,116,95,95,99,102,102,95,115,107,105,112,95,111,112,101,114,97,110,100,0,105,32,62,61,32,48,32,38,38,32,105,32,60,32,99,111,117,110,116,0,115,116,98,116,116,95,95,99,102,102,95,105,110,100,101,120,95,103,101,116,0,111,117,116,112,117,116,95,99,116,120,46,110,117,109,95,118,101,114,116,105,99,101,115,32,61,61,32,99,111,117,110,116,95,99,116,120,46,110,117,109,95,118,101,114,116,105,99,101,115,0,115,116,98,116,116,95,95,71,101,116,71,108,121,112,104,83,104,97,112,101,84,50,0,115,116,98,116,116,95,95,71,101,116,71,108,121,112,104,83,104,97,112,101,84,84,0,115,116,98,116,116,95,70,105,110,100,71,108,121,112,104,73,110,100,101,120,0,117,110,105,99,111,100,101,95,99,111,100,101,112,111,105,110,116,32,60,61,32,116,116,85,83,72,79,82,84,40,100,97,116,97,32,43,32,101,110,100,67,111,117,110,116,32,43,32,50,42,105,116,101,109,41,0,99,109,97,112,0,108,111,99,97,0,104,101,97,100,0,103,108,121,102,0,104,104,101,97,0,104,109,116,120,0,107,101,114,110,0,67,70,70,32,0,109,97,120,112,0,37,50,105,32,70,80,83,0,23,125,161,52,103,117,70,37,247,101,203,169,124,126,44,123,152,238,145,45,171,114,253,10,192,136,4,157,249,30,35,72,175,63,77,90,181,16,96,111,133,104,75,162,93,56,66,240,8,50,84,229,49,210,173,239,141,1,87,18,2,198,143,57,225,160,58,217,168,206,245,204,199,6,73,60,20,230,211,233,94,200,88,9,74,155,33,15,219,130,226,202,83,236,42,172,165,218,55,222,46,107,98,154,109,67,196,178,127,158,13,243,65,79,166,248,25,224,115,80,68,51,184,128,232,208,151,122,26,212,105,43,179,213,235,148,146,89,14,195,28,78,112,76,250,47,24,251,140,108,186,190,228,170,183,139,39,188,244,246,132,48,119,144,180,138,134,193,82,182,120,121,86,220,209,3,91,241,149,85,205,150,113,216,31,100,41,164,177,214,153,231,38,71,185,174,97,201,29,95,7,92,54,254,191,118,34,221,131,11,163,99,234,81,227,147,156,176,17,142,69,12,110,62,27,255,0,194,59,116,242,252,19,21,187,53,207,129,64,135,61,40,167,237,102,223,106,159,197,189,215,137,36,32,22,5,23,125,161,52,103,117,70,37,247,101,203,169,124,126,44,123,152,238,145,45,171,114,253,10,192,136,4,157,249,30,35,72,175,63,77,90,181,16,96,111,133,104,75,162,93,56,66,240,8,50,84,229,49,210,173,239,141,1,87,18,2,198,143,57,225,160,58,217,168,206,245,204,199,6,73,60,20,230,211,233,94,200,88,9,74,155,33,15,219,130,226,202,83,236,42,172,165,218,55,222,46,107,98,154,109,67,196,178,127,158,13,243,65,79,166,248,25,224,115,80,68,51,184,128,232,208,151,122,26,212,105,43,179,213,235,148,146,89,14,195,28,78,112,76,250,47,24,251,140,108,186,190,228,170,183,139,39,188,244,246,132,48,119,144,180,138,134,193,82,182,120,121,86,220,209,3,91,241,149,85,205,150,113,216,31,100,41,164,177,214,153,231,38,71,185,174,97,201,29,95,7,92,54,254,191,118,34,221,131,11,163,99,234,81,227,147,156,176,17,142,69,12,110,62,27,255,0,194,59,116,242,252,19,21,187,53,207,129,64,135,61,40,167,237,102,223,106,159,197,189,215,137,36,32,22,5,0,1,2,3,4,5,6,7,8,9,10,11,0,9,1,11,0,1,2,3,4,5,6,7,8,9,10,11,0,1,2,3,4,5,6,7,8,9,10,11,0,1,2,3,4,5,6,7,8,9,10,11,0,1,2,3,4,5,6,7,8,9,10,11,114,105,46,98,105,116,115,95,112,101,114,95,99,104,97,110,110,101,108,32,61,61,32,49,54,0,46,47,101,120,116,101,114,110,97,108,47,115,116,98,95,105,109,97,103,101,46,104,0,115,116,98,105,95,95,108,111,97,100,95,97,110,100,95,112,111,115,116,112,114,111,99,101,115,115,95,56,98,105,116,0,111,117,116,111,102,109,101,109,0,117,110,107,110,111,119,110,32,105,109,97,103,101,32,116,121,112,101,0,35,63,82,65,68,73,65,78,67,69,0,35,63,82,71,66,69,0,110,111,116,32,72,68,82,0,70,79,82,77,65,84,61,51,50,45,98,105,116,95,114,108,101,95,114,103,98,101,0,117,110,115,117,112,112,111,114,116,101,100,32,102,111,114,109,97,116,0,45,89,32,0,117,110,115,117,112,112,111,114,116,101,100,32,100,97,116,97,32,108,97,121,111,117,116,0,43,88,32,0,116,111,111,32,108,97,114,103,101,0,105,110,118,97,108,105,100,32,100,101,99,111,100,101,100,32,115,99,97,110,108,105,110,101,32,108,101,110,103,116,104,0,99,111,114,114,117,112,116,0,35,63,82,65,68,73,65,78,67,69,10,0,35,63,82,71,66,69,10,0,98,97,100,32,114,101,113,95,99,111,109,112,0,114,101,113,95,99,111,109,112,32,62,61,32,49,32,38,38,32,114,101,113,95,99,111,109,112,32,60,61,32,52,0,115,116,98,105,95,95,99,111,110,118,101,114,116,95,102,111,114,109,97,116,49,54,0,115,116,98,105,95,95,99,111,110,118,101,114,116,95,102,111,114,109,97,116,0,109,117,108,116,105,112,108,101,32,73,72,68,82,0,98,97,100,32,73,72,68,82,32,108,101,110,0,49,47,50,47,52,47,56,47,49,54,45,98,105,116,32,111,110,108,121,0,98,97,100,32,99,116,121,112,101,0,98,97,100,32,99,111,109,112,32,109,101,116,104,111,100,0,98,97,100,32,102,105,108,116,101,114,32,109,101,116,104,111,100,0,98,97,100,32,105,110,116,101,114,108,97,99,101,32,109,101,116,104,111,100,0,48,45,112,105,120,101,108,32,105,109,97,103,101,0,102,105,114,115,116,32,110,111,116,32,73,72,68,82,0,105,110,118,97,108,105,100,32,80,76,84,69,0,116,82,78,83,32,97,102,116,101,114,32,73,68,65,84,0,116,82,78,83,32,98,101,102,111,114,101,32,80,76,84,69,0,98,97,100,32,116,82,78,83,32,108,101,110,0,116,82,78,83,32,119,105,116,104,32,97,108,112,104,97,0,0,255,85,0,17,0,0,0,1,110,111,32,80,76,84,69,0,111,117,116,111,102,100,97,116,97,0,110,111,32,73,68,65,84,0,88,88,88,88,32,80,78,71,32,99,104,117,110,107,32,110,111,116,32,107,110,111,119,110,0,115,45,62,105,109,103,95,111,117,116,95,110,32,61,61,32,52,0,115,116,98,105,95,95,100,101,95,105,112,104,111,110,101,0,111,117,116,95,110,32,61,61,32,50,32,124,124,32,111,117,116,95,110,32,61,61,32,52,0,115,116,98,105,95,95,99,111,109,112,117,116,101,95,116,114,97,110,115,112,97,114,101,110,99,121,0,115,116,98,105,95,95,99,111,109,112,117,116,101,95,116,114,97,110,115,112,97,114,101,110,99,121,49,54,0,111,117,116,95,110,32,61,61,32,115,45,62,105,109,103,95,110,32,124,124,32,111,117,116,95,110,32,61,61,32,115,45,62,105,109,103,95,110,43,49,0,115,116,98,105,95,95,99,114,101,97,116,101,95,112,110,103,95,105,109,97,103,101,95,114,97,119,0,110,111,116,32,101,110,111,117,103,104,32,112,105,120,101,108,115,0,105,109,103,95,119,105,100,116,104,95,98,121,116,101,115,32,60,61,32,120,0,0,1,0,5,6,105,109,103,95,110,43,49,32,61,61,32,111,117,116,95,110,0,105,110,118,97,108,105,100,32,102,105,108,116,101,114,0,105,109,103,95,110,32,61,61,32,51,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,98,97,100,32,104,117,102,102,109,97,110,32,99,111,100,101,0,98,97,100,32,100,105,115,116,0,111,117,116,112,117,116,32,98,117,102,102,101,114,32,108,105,109,105,116,0,122,45,62,115,105,122,101,91,98,93,32,61,61,32,115,0,115,116,98,105,95,95,122,104,117,102,102,109,97,110,95,100,101,99,111,100,101,95,115,108,111,119,112,97,116,104,0,98,105,116,115,32,60,61,32,49,54,0,115,116,98,105,95,95,98,105,116,95,114,101,118,101,114,115,101,0,122,45,62,99,111,100,101,95,98,117,102,102,101,114,32,60,32,40,49,85,32,60,60,32,122,45,62,110,117,109,95,98,105,116,115,41,0,115,116,98,105,95,95,102,105,108,108,95,98,105,116,115,0,98,97,100,32,99,111,100,101,108,101,110,103,116,104,115,0,99,32,61,61,32,49,56,0,115,116,98,105,95,95,99,111,109,112,117,116,101,95,104,117,102,102,109,97,110,95,99,111,100,101,115,0,98,97,100,32,115,105,122,101,115,0,97,45,62,110,117,109,95,98,105,116,115,32,61,61,32,48,0,115,116,98,105,95,95,112,97,114,115,101,95,117,110,99,111,109,112,114,101,115,115,101,100,95,98,108,111,99,107,0,122,108,105,98,32,99,111,114,114,117,112,116,0,114,101,97,100,32,112,97,115,116,32,98,117,102,102,101,114,0,98,97,100,32,122,108,105,98,32,104,101,97,100,101,114,0,110,111,32,112,114,101,115,101,116,32,100,105,99,116,0,98,97,100,32,99,111,109,112,114,101,115,115,105,111,110,0,98,97,100,32,112,110,103,32,115,105,103,0,1,2,4,4,105,110,102,111,45,62,99,104,97,110,110,101,108,115,32,62,61,32,48,0,46,47,101,120,116,101,114,110,97,108,47,115,116,98,95,105,109,97,103,101,95,114,101,115,105,122,101,46,104,0,115,116,98,105,114,95,95,114,101,115,105,122,101,95,97,108,108,111,99,97,116,101,100,0,105,110,102,111,45,62,99,104,97,110,110,101,108,115,32,60,61,32,54,52,0,105,110,102,111,45,62,104,111,114,105,122,111,110,116,97,108,95,102,105,108,116,101,114,32,60,32,40,115,105,122,101,111,102,40,40,115,116,98,105,114,95,95,102,105,108,116,101,114,95,105,110,102,111,95,116,97,98,108,101,41,41,47,115,105,122,101,111,102,40,40,115,116,98,105,114,95,95,102,105,108,116,101,114,95,105,110,102,111,95,116,97,98,108,101,41,91,48,93,41,41,0,105,110,102,111,45,62,118,101,114,116,105,99,97,108,95,102,105,108,116,101,114,32,60,32,40,115,105,122,101,111,102,40,40,115,116,98,105,114,95,95,102,105,108,116,101,114,95,105,110,102,111,95,116,97,98,108,101,41,41,47,115,105,122,101,111,102,40,40,115,116,98,105,114,95,95,102,105,108,116,101,114,95,105,110,102,111,95,116,97,98,108,101,41,91,48,93,41,41,0,97,108,112,104,97,95,99,104,97,110,110,101,108,32,62,61,32,48,32,38,38,32,97,108,112,104,97,95,99,104,97,110,110,101,108,32,60,32,105,110,102,111,45,62,99,104,97,110,110,101,108,115,0,116,101,109,112,109,101,109,0,116,101,109,112,109,101,109,95,115,105,122,101,95,105,110,95,98,121,116,101,115,32,62,61,32,109,101,109,111,114,121,95,114,101,113,117,105,114,101,100,0,40,115,105,122,101,95,116,41,40,117,110,115,105,103,110,101,100,32,99,104,97,114,42,41,40,40,40,117,110,115,105,103,110,101,100,32,99,104,97,114,42,41,105,110,102,111,45,62,101,110,99,111,100,101,95,98,117,102,102,101,114,41,32,43,32,105,110,102,111,45,62,101,110,99,111,100,101,95,98,117,102,102,101,114,95,115,105,122,101,41,32,61,61,32,40,115,105,122,101,95,116,41,116,101,109,112,109,101,109,32,43,32,116,101,109,112,109,101,109,95,115,105,122,101,95,105,110,95,98,121,116,101,115,0,40,115,105,122,101,95,116,41,40,117,110,115,105,103,110,101,100,32,99,104,97,114,42,41,40,40,40,117,110,115,105,103,110,101,100,32,99,104,97,114,42,41,105,110,102,111,45,62,114,105,110,103,95,98,117,102,102,101,114,41,32,43,32,105,110,102,111,45,62,114,105,110,103,95,98,117,102,102,101,114,95,115,105,122,101,41,32,61,61,32,40,115,105,122,101,95,116,41,116,101,109,112,109,101,109,32,43,32,116,101,109,112,109,101,109,95,115,105,122,101,95,105,110,95,98,121,116,101,115,0,33,115,116,98,105,114,95,95,117,115,101,95,104,101,105,103,104,116,95,117,112,115,97,109,112,108,105,110,103,40,115,116,98,105,114,95,105,110,102,111,41,0,115,116,98,105,114,95,95,98,117,102,102,101,114,95,108,111,111,112,95,100,111,119,110,115,97,109,112,108,101,0,111,117,116,95,108,97,115,116,95,115,99,97,110,108,105,110,101,32,45,32,111,117,116,95,102,105,114,115,116,95,115,99,97,110,108,105,110,101,32,43,32,49,32,60,61,32,115,116,98,105,114,95,105,110,102,111,45,62,114,105,110,103,95,98,117,102,102,101,114,95,110,117,109,95,101,110,116,114,105,101,115,0,115,116,98,105,114,95,95,114,101,115,97,109,112,108,101,95,118,101,114,116,105,99,97,108,95,100,111,119,110,115,97,109,112,108,101,0,114,105,110,103,95,98,117,102,102,101,114,95,105,110,100,101,120,32,33,61,32,115,116,98,105,114,95,105,110,102,111,45,62,114,105,110,103,95,98,117,102,102,101,114,95,98,101,103,105,110,95,105,110,100,101,120,0,115,116,98,105,114,95,95,97,100,100,95,101,109,112,116,121,95,114,105,110,103,95,98,117,102,102,101,114,95,101,110,116,114,121,0,33,115,116,98,105,114,95,95,117,115,101,95,119,105,100,116,104,95,117,112,115,97,109,112,108,105,110,103,40,115,116,98,105,114,95,105,110,102,111,41,0,115,116,98,105,114,95,95,114,101,115,97,109,112,108,101,95,104,111,114,105,122,111,110,116,97,108,95,100,111,119,110,115,97,109,112,108,101,0,99,111,101,102,102,105,99,105,101,110,116,32,33,61,32,48,0,110,49,32,62,61,32,110,48,0,115,116,98,105,114,95,95,114,101,115,97,109,112,108,101,95,104,111,114,105,122,111,110,116,97,108,95,117,112,115,97,109,112,108,101,0,110,48,32,62,61,32,45,115,116,98,105,114,95,105,110,102,111,45,62,104,111,114,105,122,111,110,116,97,108,95,102,105,108,116,101,114,95,112,105,120,101,108,95,109,97,114,103,105,110,0,110,49,32,62,61,32,45,115,116,98,105,114,95,105,110,102,111,45,62,104,111,114,105,122,111,110,116,97,108,95,102,105,108,116,101,114,95,112,105,120,101,108,95,109,97,114,103,105,110,0,110,48,32,60,32,115,116,98,105,114,95,105,110,102,111,45,62,105,110,112,117,116,95,119,32,43,32,115,116,98,105,114,95,105,110,102,111,45,62,104,111,114,105,122,111,110,116,97,108,95,102,105,108,116,101,114,95,112,105,120,101,108,95,109,97,114,103,105,110,0,110,49,32,60,32,115,116,98,105,114,95,105,110,102,111,45,62,105,110,112,117,116,95,119,32,43,32,115,116,98,105,114,95,105,110,102,111,45,62,104,111,114,105,122,111,110,116,97,108,95,102,105,108,116,101,114,95,112,105,120,101,108,95,109,97,114,103,105,110,0,33,34,85,110,107,110,111,119,110,32,116,121,112,101,47,99,111,108,111,114,115,112,97,99,101,47,99,104,97,110,110,101,108,115,32,99,111,109,98,105,110,97,116,105,111,110,46,34,0,115,116,98,105,114,95,95,100,101,99,111,100,101,95,115,99,97,110,108,105,110,101,0,33,34,85,110,105,109,112,108,101,109,101,110,116,101,100,32,101,100,103,101,32,116,121,112,101,34,0,115,116,98,105,114,95,95,101,100,103,101,95,119,114,97,112,95,115,108,111,119,0,115,116,98,105,114,95,95,101,110,99,111,100,101,95,115,99,97,110,108,105,110,101,0,115,99,97,108,101,32,60,61,32,49,0,115,116,98,105,114,95,95,115,117,112,112,111,114,116,95,116,114,97,112,101,122,111,105,100,0,115,116,98,105,114,95,95,102,105,108,116,101,114,95,116,114,97,112,101,122,111,105,100,0,115,116,98,105,114,95,95,117,115,101,95,104,101,105,103,104,116,95,117,112,115,97,109,112,108,105,110,103,40,115,116,98,105,114,95,105,110,102,111,41,0,115,116,98,105,114,95,95,98,117,102,102,101,114,95,108,111,111,112,95,117,112,115,97,109,112,108,101,0,105,110,95,108,97,115,116,95,115,99,97,110,108,105,110,101,32,45,32,105,110,95,102,105,114,115,116,95,115,99,97,110,108,105,110,101,32,43,32,49,32,60,61,32,115,116,98,105,114,95,105,110,102,111,45,62,114,105,110,103,95,98,117,102,102,101,114,95,110,117,109,95,101,110,116,114,105,101,115,0,115,116,98,105,114,95,95,114,101,115,97,109,112,108,101,95,118,101,114,116,105,99,97,108,95,117,112,115,97,109,112,108,101,0,116,111,116,97,108,32,62,32,48,46,57,102,0,115,116,98,105,114,95,95,110,111,114,109,97,108,105,122,101,95,100,111,119,110,115,97,109,112,108,101,95,99,111,101,102,102,105,99,105,101,110,116,115,0,116,111,116,97,108,32,60,32,49,46,49,102,0,111,117,116,95,108,97,115,116,95,112,105,120,101,108,32,45,32,111,117,116,95,102,105,114,115,116,95,112,105,120,101,108,32,60,61,32,40,105,110,116,41,99,101,105,108,40,115,116,98,105,114,95,95,102,105,108,116,101,114,95,105,110,102,111,95,116,97,98,108,101,91,102,105,108,116,101,114,93,46,115,117,112,112,111,114,116,40,115,99,97,108,101,95,114,97,116,105,111,41,32,42,32,50,41,0,115,116,98,105,114,95,95,99,97,108,99,117,108,97,116,101,95,99,111,101,102,102,105,99,105,101,110,116,115,95,100,111,119,110,115,97,109,112,108,101,0,99,111,110,116,114,105,98,117,116,111,114,45,62,110,49,32,62,61,32,99,111,110,116,114,105,98,117,116,111,114,45,62,110,48,0,115,116,98,105,114,95,95,102,105,108,116,101,114,95,105,110,102,111,95,116,97,98,108,101,91,102,105,108,116,101,114,93,46,107,101,114,110,101,108,40,40,102,108,111,97,116,41,40,111,117,116,95,108,97,115,116,95,112,105,120,101,108,32,43,32,49,41,32,43,32,48,46,53,102,32,45,32,111,117,116,95,99,101,110,116,101,114,95,111,102,95,105,110,44,32,115,99,97,108,101,95,114,97,116,105,111,41,32,61,61,32,48,0,105,110,95,108,97,115,116,95,112,105,120,101,108,32,45,32,105,110,95,102,105,114,115,116,95,112,105,120,101,108,32,60,61,32,40,105,110,116,41,99,101,105,108,40,115,116,98,105,114,95,95,102,105,108,116,101,114,95,105,110,102,111,95,116,97,98,108,101,91,102,105,108,116,101,114,93,46,115,117,112,112,111,114,116,40,49,47,115,99,97,108,101,41,32,42,32,50,41,0,115,116,98,105,114,95,95,99,97,108,99,117,108,97,116,101,95,99,111,101,102,102,105,99,105,101,110,116,115,95,117,112,115,97,109,112,108,101,0,115,116,98,105,114,95,95,102,105,108,116,101,114,95,105,110,102,111,95,116,97,98,108,101,91,102,105,108,116,101,114,93,46,107,101,114,110,101,108,40,40,102,108,111,97,116,41,40,105,110,95,108,97,115,116,95,112,105,120,101,108,32,43,32,49,41,32,43,32,48,46,53,102,32,45,32,105,110,95,99,101,110,116,101,114,95,111,102,95,111,117,116,44,32,49,47,115,99,97,108,101,41,32,61,61,32,48,0,116,111,116,97,108,95,102,105,108,116,101,114,32,62,32,48,46,57,0,116,111,116,97,108,95,102,105,108,116,101,114,32,60,32,49,46,49,102,0,102,105,108,116,101,114,32,33,61,32,48,0,115,116,98,105,114,95,95,103,101,116,95,102,105,108,116,101,114,95,112,105,120,101,108,95,119,105,100,116,104,0,102,105,108,116,101,114,32,60,32,40,115,105,122,101,111,102,40,40,115,116,98,105,114,95,95,102,105,108,116,101,114,95,105,110,102,111,95,116,97,98,108,101,41,41,47,115,105,122,101,111,102,40,40,115,116,98,105,114,95,95,102,105,108,116,101,114,95,105,110,102,111,95,116,97,98,108,101,41,91,48,93,41,41,0,105,110,102,111,45,62,104,111,114,105,122,111,110,116,97,108,95,102,105,108,116,101,114,32,33,61,32,48,0,115,116,98,105,114,95,95,99,97,108,99,117,108,97,116,101,95,109,101,109,111,114,121,0,105,110,102,111,45,62,118,101,114,116,105,99,97,108,95,102,105,108,116,101,114,32,33,61,32,48,0,46,114,114,101,115,0,91,37,115,93,32,82,101,115,111,117,114,99,101,32,102,105,108,101,32,100,111,101,115,32,110,111,116,32,99,111,110,116,97,105,110,32,105,109,97,103,101,32,100,97,116,97,0,46,112,110,103,0,46,103,105,102,0,46,104,100,114,0,91,37,115,93,32,73,109,97,103,101,32,102,105,108,101,102,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,40,111,110,108,121,32,51,32,99,104,97,110,110,101,108,32,51,50,32,98,105,116,32,102,108,111,97,116,115,41,0,46,100,100,115,0,46,107], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE+20480);
-/* memory initializer */ allocate([116,120,0,46,97,115,116,99,0,91,37,115,93,32,73,109,97,103,101,32,102,105,108,101,102,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,91,37,115,93,32,73,109,97,103,101,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,40,37,105,120,37,105,41,0,91,37,115,93,32,73,109,97,103,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,108,111,97,100,101,100,0,91,37,115,93,32,65,83,84,67,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,91,37,115,93,32,65,83,84,67,32,102,105,108,101,32,100,111,101,115,32,110,111,116,32,115,101,101,109,32,116,111,32,98,101,32,97,32,118,97,108,105,100,32,105,109,97,103,101,0,65,83,84,67,32,105,109,97,103,101,32,119,105,100,116,104,58,32,37,105,0,65,83,84,67,32,105,109,97,103,101,32,104,101,105,103,104,116,58,32,37,105,0,65,83,84,67,32,105,109,97,103,101,32,98,108,111,99,107,115,58,32,37,105,120,37,105,0,91,37,115,93,32,65,83,84,67,32,98,108,111,99,107,32,115,105,122,101,32,99,111,110,102,105,103,117,114,97,116,105,111,110,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,91,37,115,93,32,75,84,88,32,105,109,97,103,101,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,91,37,115,93,32,75,84,88,32,102,105,108,101,32,100,111,101,115,32,110,111,116,32,115,101,101,109,32,116,111,32,98,101,32,97,32,118,97,108,105,100,32,102,105,108,101,0,75,84,88,32,40,69,84,67,41,32,105,109,97,103,101,32,119,105,100,116,104,58,32,37,105,0,75,84,88,32,40,69,84,67,41,32,105,109,97,103,101,32,104,101,105,103,104,116,58,32,37,105,0,75,84,88,32,40,69,84,67,41,32,105,109,97,103,101,32,102,111,114,109,97,116,58,32,48,120,37,120,0,91,37,115,93,32,68,68,83,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,68,68,83,32,0,91,37,115,93,32,68,68,83,32,102,105,108,101,32,100,111,101,115,32,110,111,116,32,115,101,101,109,32,116,111,32,98,101,32,97,32,118,97,108,105,100,32,105,109,97,103,101,0,91,37,115,93,32,68,68,83,32,102,105,108,101,32,104,101,97,100,101,114,32,115,105,122,101,58,32,37,105,0,91,37,115,93,32,68,68,83,32,102,105,108,101,32,112,105,120,101,108,32,102,111,114,109,97,116,32,115,105,122,101,58,32,37,105,0,91,37,115,93,32,68,68,83,32,102,105,108,101,32,112,105,120,101,108,32,102,111,114,109,97,116,32,102,108,97,103,115,58,32,48,120,37,120,0,91,37,115,93,32,68,68,83,32,102,105,108,101,32,102,111,114,109,97,116,58,32,48,120,37,120,0,91,37,115,93,32,68,68,83,32,102,105,108,101,32,98,105,116,32,99,111,117,110,116,58,32,48,120,37,120,0,80,105,116,99,104,32,111,114,32,108,105,110,101,97,114,32,115,105,122,101,58,32,37,105,0,73,109,97,103,101,32,102,111,114,109,97,116,32,110,111,116,32,114,101,99,111,103,110,105,122,101,100,0,91,37,115,93,32,82,65,87,32,105,109,97,103,101,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,73,109,97,103,101,32,102,111,114,109,97,116,32,110,111,116,32,115,117,112,111,114,116,101,100,0,91,37,115,93,32,82,65,87,32,105,109,97,103,101,32,100,97,116,97,32,99,97,110,32,110,111,116,32,98,101,32,114,101,97,100,44,32,119,114,111,110,103,32,114,101,113,117,101,115,116,101,100,32,102,111,114,109,97,116,32,111,114,32,115,105,122,101,0,84,101,120,116,117,114,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,99,114,101,97,116,101,100,0,91,84,69,88,32,73,68,32,37,105,93,32,80,97,114,97,109,101,116,101,114,115,58,32,37,105,120,37,105,44,32,37,105,32,109,105,112,115,44,32,102,111,114,109,97,116,32,37,105,0,91,84,69,88,32,73,68,32,37,105,93,32,85,110,108,111,97,100,101,100,32,116,101,120,116,117,114,101,32,100,97,116,97,32,102,114,111,109,32,86,82,65,77,32,40,71,80,85,41,0,70,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,102,111,114,32,112,105,120,101,108,32,100,97,116,97,32,114,101,116,114,105,101,118,97,108,0,84,101,120,116,117,114,101,32,112,105,120,101,108,32,100,97,116,97,32,111,98,116,97,105,110,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,84,101,120,116,117,114,101,32,112,105,120,101,108,32,100,97,116,97,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,98,116,97,105,110,101,100,0,67,111,109,112,114,101,115,115,101,100,32,116,101,120,116,117,114,101,32,100,97,116,97,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,98,116,97,105,110,101,100,0,73,109,97,103,101,32,100,97,116,97,32,102,111,114,109,97,116,32,105,115,32,99,111,109,112,114,101,115,115,101,100,44,32,99,97,110,32,110,111,116,32,98,101,32,99,111,110,118,101,114,116,101,100,0,65,108,112,104,97,32,109,97,115,107,32,109,117,115,116,32,98,101,32,115,97,109,101,32,115,105,122,101,32,97,115,32,105,109,97,103,101,0,65,108,112,104,97,32,109,97,115,107,32,99,97,110,32,110,111,116,32,98,101,32,97,112,112,108,105,101,100,32,116,111,32,99,111,109,112,114,101,115,115,101,100,32,100,97,116,97,32,102,111,114,109,97,116,115,0,73,109,97,103,101,32,99,111,110,118,101,114,116,101,100,32,116,111,32,80,79,84,58,32,40,37,105,120,37,105,41,32,45,62,32,40,37,105,120,37,105,41,0,67,114,111,112,32,114,101,99,116,97,110,103,108,101,32,119,105,100,116,104,32,111,117,116,32,111,102,32,98,111,117,110,100,115,44,32,114,101,115,99,97,108,101,100,32,99,114,111,112,32,119,105,100,116,104,58,32,37,105,0,67,114,111,112,32,114,101,99,116,97,110,103,108,101,32,104,101,105,103,104,116,32,111,117,116,32,111,102,32,98,111,117,110,100,115,44,32,114,101,115,99,97,108,101,100,32,99,114,111,112,32,104,101,105,103,104,116,58,32,37,105,0,73,109,97,103,101,32,99,97,110,32,110,111,116,32,98,101,32,99,114,111,112,112,101,100,44,32,99,114,111,112,32,114,101,99,116,97,110,103,108,101,32,111,117,116,32,111,102,32,98,111,117,110,100,115,0,83,111,117,114,99,101,32,114,101,99,116,97,110,103,108,101,32,119,105,100,116,104,32,111,117,116,32,111,102,32,98,111,117,110,100,115,44,32,114,101,115,99,97,108,101,100,32,119,105,100,116,104,58,32,37,105,0,83,111,117,114,99,101,32,114,101,99,116,97,110,103,108,101,32,104,101,105,103,104,116,32,111,117,116,32,111,102,32,98,111,117,110,100,115,44,32,114,101,115,99,97,108,101,100,32,104,101,105,103,104,116,58,32,37,105,0,68,101,115,116,105,110,97,116,105,111,110,32,114,101,99,116,97,110,103,108,101,32,119,105,100,116,104,32,111,117,116,32,111,102,32,98,111,117,110,100,115,44,32,114,101,115,99,97,108,101,100,32,119,105,100,116,104,58,32,37,105,0,68,101,115,116,105,110,97,116,105,111,110,32,114,101,99,116,97,110,103,108,101,32,104,101,105,103,104,116,32,111,117,116,32,111,102,32,98,111,117,110,100,115,44,32,114,101,115,99,97,108,101,100,32,104,101,105,103,104,116,58,32,37,105,0,84,101,120,116,32,73,109,97,103,101,32,115,105,122,101,58,32,37,102,44,32,37,102,0,83,99,97,108,101,102,97,99,116,111,114,58,32,37,102,0,67,111,109,112,114,101,115,115,101,100,32,100,97,116,97,32,102,111,114,109,97,116,115,32,99,97,110,32,110,111,116,32,98,101,32,100,105,116,104,101,114,101,100,0,85,110,115,117,112,112,111,114,116,101,100,32,100,105,116,104,101,114,105,110,103,32,98,112,112,115,32,40,37,105,98,112,112,41,44,32,111,110,108,121,32,49,54,98,112,112,32,111,114,32,108,111,119,101,114,32,109,111,100,101,115,32,115,117,112,112,111,114,116,101,100,0,73,109,97,103,101,32,102,111,114,109,97,116,32,105,115,32,97,108,114,101,97,100,121,32,49,54,98,112,112,32,111,114,32,108,111,119,101,114,44,32,100,105,116,104,101,114,105,110,103,32,99,111,117,108,100,32,104,97,118,101,32,110,111,32,101,102,102,101,99,116,0,85,110,115,117,112,112,111,114,116,101,100,32,100,105,116,104,101,114,101,100,32,79,112,101,110,71,76,32,105,110,116,101,114,110,97,108,32,102,111,114,109,97,116,58,32,37,105,98,112,112,32,40,82,37,105,71,37,105,66,37,105,65,37,105,41,0,73,110,102,0,76,105,109,105,116,101,100,32,78,80,79,84,32,115,117,112,112,111,114,116,44,32,110,111,32,109,105,112,109,97,112,115,32,97,118,97,105,108,97,98,108,101,32,102,111,114,32,78,80,79,84,32,116,101,120,116,117,114,101,115,0,91,84,69,88,32,73,68,32,37,105,93,32,78,111,32,109,105,112,109,97,112,115,32,97,118,97,105,108,97,98,108,101,32,102,111,114,32,84,82,73,76,73,78,69,65,82,32,116,101,120,116,117,114,101,32,102,105,108,116,101,114,105,110,103,0,5,5,4,0,16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15,2,3,7,0,3,3,11,0,91,37,115,93,32,114,82,69,83,32,114,97,121,108,105,98,32,114,101,115,111,117,114,99,101,32,102,105,108,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,111,112,101,110,101,100,0,91,37,115,93,32,84,104,105,115,32,105,115,32,110,111,116,32,97,32,118,97,108,105,100,32,114,97,121,108,105,98,32,114,101,115,111,117,114,99,101,32,102,105,108,101,0,91,37,115,93,91,73,68,32,37,105,93,32,82,101,115,111,117,114,99,101,32,100,97,116,97,32,108,111,97,100,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,0,91,37,115,93,91,73,68,32,37,105,93,32,82,101,113,117,101,115,116,101,100,32,114,101,115,111,117,114,99,101,32,99,111,117,108,100,32,110,111,116,32,98,101,32,102,111,117,110,100,0,79,117,116,32,111,102,32,109,101,109,111,114,121,32,119,104,105,108,101,32,100,101,99,111,109,112,114,101,115,115,105,110,103,32,100,97,116,97,0,68,97,116,97,32,100,101,99,111,109,112,114,101,115,115,105,111,110,32,102,97,105,108,101,100,0,69,120,112,101,99,116,101,100,32,117,110,99,111,109,112,114,101,115,115,101,100,32,115,105,122,101,32,100,111,32,110,111,116,32,109,97,116,99,104,44,32,100,97,116,97,32,109,97,121,32,98,101,32,99,111,114,114,117,112,116,101,100,0,32,45,45,32,69,120,112,101,99,116,101,100,32,117,110,99,111,109,112,114,101,115,115,101,100,32,115,105,122,101,58,32,37,105,0,32,45,45,32,82,101,116,117,114,110,101,100,32,117,110,99,111,109,112,114,101,115,115,101,100,32,115,105,122,101,58,32,37,105,0,68,97,116,97,32,100,101,99,111,109,112,114,101,115,115,101,100,32,115,117,99,99,101,115,115,102,117,108,108,121,32,102,114,111,109,32,37,117,32,98,121,116,101,115,32,116,111,32,37,117,32,98,121,116,101,115,0,73,78,70,79,58,32,0,87,65,82,78,73,78,71,58,32,0,48,0,101,120,116,101,114,110,97,108,47,115,116,98,95,118,111,114,98,105,115,46,99,0,103,101,116,95,119,105,110,100,111,119,0,102,45,62,98,121,116,101,115,95,105,110,95,115,101,103,32,62,32,48,0,103,101,116,56,95,112,97,99,107,101,116,95,114,97,119,0,102,45,62,98,121,116,101,115,95,105,110,95,115,101,103,32,61,61,32,48,0,110,101,120,116,95,115,101,103,109,101,110,116,0,102,45,62,97,108,108,111,99,46,97,108,108,111,99,95,98,117,102,102,101,114,95,108,101,110,103,116,104,95,105,110,95,98,121,116,101,115,32,61,61,32,102,45,62,116,101,109,112,95,111,102,102,115,101,116,0,118,111,114,98,105,115,95,100,101,99,111,100,101,95,112,97,99,107,101,116,95,114,101,115,116,0,40,110,32,38,32,51,41,32,61,61,32,48,0,105,109,100,99,116,95,115,116,101,112,51,95,105,116,101,114,48,95,108,111,111,112,0,122,32,60,32,99,45,62,115,111,114,116,101,100,95,101,110,116,114,105,101,115,0,99,111,100,101,98,111,111,107,95,100,101,99,111,100,101,95,115,116,97,114,116,0,33,99,45,62,115,112,97,114,115,101,32,124,124,32,122,32,60,32,99,45,62,115,111,114,116,101,100,95,101,110,116,114,105,101,115,0,99,111,100,101,98,111,111,107,95,100,101,99,111,100,101,95,100,101,105,110,116,101,114,108,101,97,118,101,95,114,101,112,101,97,116,0,33,99,45,62,115,112,97,114,115,101,0,99,111,100,101,98,111,111,107,95,100,101,99,111,100,101,95,115,99,97,108,97,114,95,114,97,119,0,0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,118,111,114,98,105,115,95,100,101,99,111,100,101,95,105,110,105,116,105,97,108,0,102,45,62,116,101,109,112,95,111,102,102,115,101,116,32,61,61,32,102,45,62,97,108,108,111,99,46,97,108,108,111,99,95,98,117,102,102,101,114,95,108,101,110,103,116,104,95,105,110,95,98,121,116,101,115,0,115,116,97,114,116,95,100,101,99,111,100,101,114,0,112,111,119,40,40,102,108,111,97,116,41,32,114,43,49,44,32,100,105,109,41,32,62,32,101,110,116,114,105,101,115,0,108,111,111,107,117,112,49,95,118,97,108,117,101,115,0,40,105,110,116,41,32,102,108,111,111,114,40,112,111,119,40,40,102,108,111,97,116,41,32,114,44,32,100,105,109,41,41,32,60,61,32,101,110,116,114,105,101,115,0,107,32,61,61,32,99,45,62,115,111,114,116,101,100,95,101,110,116,114,105,101,115,0,99,111,109,112,117,116,101,95,115,111,114,116,101,100,95,104,117,102,102,109,97,110,0,99,45,62,115,111,114,116,101,100,95,99,111,100,101,119,111,114,100,115,91,120,93,32,61,61,32,99,111,100,101,0,108,101,110,32,33,61,32,78,79,95,67,79,68,69,0,105,110,99,108,117,100,101,95,105,110,95,115,111,114,116,0,99,45,62,115,111,114,116,101,100,95,101,110,116,114,105,101,115,32,61,61,32,48,0,99,111,109,112,117,116,101,95,99,111,100,101,119,111,114,100,115,0,122,32,62,61,32,48,32,38,38,32,122,32,60,32,51,50,0,108,101,110,91,105,93,32,62,61,32,48,32,38,38,32,108,101,110,91,105,93,32,60,32,51,50,0,97,118,97,105,108,97,98,108,101,91,121,93,32,61,61,32,48,0,118,111,114,98,105,115,114,98,0,0,0,0,0,0,0,7,0,0,0,0,0,3,5,0,0,0,0,3,7,5,0,0,0,3,5,3,5,0,0,3,7,5,3,5,0,3,7,5,3,5,7,98,117,102,95,99,32,61,61,32,50,0,99,111,110,118,101,114,116,95,99,104,97,110,110,101,108,115,95,115,104,111,114,116,95,105,110,116,101,114,108,101,97,118,101,100,0,69,88,84,0,65,82,66,0,79,69,83,0,65,78,71,76,69,0,103,108,67,114,101,97,116,101,80,114,111,103,114,97,109,79,98,106,101,99,116,0,103,108,67,114,101,97,116,101,80,114,111,103,114,97,109,0,103,108,85,115,101,80,114,111,103,114,97,109,79,98,106,101,99,116,0,103,108,85,115,101,80,114,111,103,114,97,109,0,103,108,67,114,101,97,116,101,83,104,97,100,101,114,79,98,106,101,99,116,0,103,108,67,114,101,97,116,101,83,104,97,100,101,114,0,103,108,65,116,116,97,99,104,79,98,106,101,99,116,0,103,108,65,116,116,97,99,104,83,104,97,100,101,114,0,103,108,68,101,116,97,99,104,79,98,106,101,99,116,0,103,108,68,101,116,97,99,104,83,104,97,100,101,114,0,103,108,80,105,120,101,108,83,116,111,114,101,105,0,103,108,71,101,116,83,116,114,105,110,103,0,103,108,71,101,116,73,110,116,101,103,101,114,118,0,103,108,71,101,116,70,108,111,97,116,118,0,103,108,71,101,116,66,111,111,108,101,97,110,118,0,103,108,71,101,110,84,101,120,116,117,114,101,115,0,103,108,68,101,108,101,116,101,84,101,120,116,117,114,101,115,0,103,108,67,111,109,112,114,101,115,115,101,100,84,101,120,73,109,97,103,101,50,68,0,103,108,67,111,109,112,114,101,115,115,101,100,84,101,120,83,117,98,73,109,97,103,101,50,68,0,103,108,84,101,120,73,109,97,103,101,50,68,0,103,108,84,101,120,83,117,98,73,109,97,103,101,50,68,0,103,108,82,101,97,100,80,105,120,101,108,115,0,103,108,66,105,110,100,84,101,120,116,117,114,101,0,103,108,71,101,116,84,101,120,80,97,114,97,109,101,116,101,114,102,118,0,103,108,71,101,116,84,101,120,80,97,114,97,109,101,116,101,114,105,118,0,103,108,84,101,120,80,97,114,97,109,101,116,101,114,102,118,0,103,108,84,101,120,80,97,114,97,109,101,116,101,114,105,118,0,103,108,73,115,84,101,120,116,117,114,101,0,103,108,71,101,110,66,117,102,102,101,114,115,0,103,108,68,101,108,101,116,101,66,117,102,102,101,114,115,0,103,108,71,101,116,66,117,102,102,101,114,80,97,114,97,109,101,116,101,114,105,118,0,103,108,66,117,102,102,101,114,68,97,116,97,0,103,108,66,117,102,102,101,114,83,117,98,68,97,116,97,0,103,108,73,115,66,117,102,102,101,114,0,103,108,71,101,110,82,101,110,100,101,114,98,117,102,102,101,114,115,0,103,108,68,101,108,101,116,101,82,101,110,100,101,114,98,117,102,102,101,114,115,0,103,108,66,105,110,100,82,101,110,100,101,114,98,117,102,102,101,114,0,103,108,71,101,116,82,101,110,100,101,114,98,117,102,102,101,114,80,97,114,97,109,101,116,101,114,105,118,0,103,108,73,115,82,101,110,100,101,114,98,117,102,102,101,114,0,103,108,71,101,116,85,110,105,102,111,114,109,102,118,0,103,108,71,101,116,85,110,105,102,111,114,109,105,118,0,103,108,71,101,116,85,110,105,102,111,114,109,76,111,99,97,116,105,111,110,0,103,108,71,101,116,86,101,114,116,101,120,65,116,116,114,105,98,102,118,0,103,108,71,101,116,86,101,114,116,101,120,65,116,116,114,105,98,105,118,0,103,108,71,101,116,86,101,114,116,101,120,65,116,116,114,105,98,80,111,105,110,116,101,114,118,0,103,108,71,101,116,65,99,116,105,118,101,85,110,105,102,111,114,109,0,103,108,85,110,105,102,111,114,109,49,102,0,103,108,85,110,105,102,111,114,109,50,102,0,103,108,85,110,105,102,111,114,109,51,102,0,103,108,85,110,105,102,111,114,109,52,102,0,103,108,85,110,105,102,111,114,109,49,105,0,103,108,85,110,105,102,111,114,109,50,105,0,103,108,85,110,105,102,111,114,109,51,105,0,103,108,85,110,105,102,111,114,109,52,105,0,103,108,85,110,105,102,111,114,109,49,105,118,0,103,108,85,110,105,102,111,114,109,50,105,118,0,103,108,85,110,105,102,111,114,109,51,105,118,0,103,108,85,110,105,102,111,114,109,52,105,118,0,103,108,85,110,105,102,111,114,109,49,102,118,0,103,108,85,110,105,102,111,114,109,50,102,118,0,103,108,85,110,105,102,111,114,109,51,102,118,0,103,108,85,110,105,102,111,114,109,52,102,118,0,103,108,85,110,105,102,111,114,109,77,97,116,114,105,120,50,102,118,0,103,108,85,110,105,102,111,114,109,77,97,116,114,105,120,51,102,118,0,103,108,85,110,105,102,111,114,109,77,97,116,114,105,120,52,102,118,0,103,108,66,105,110,100,66,117,102,102,101,114,0,103,108,86,101,114,116,101,120,65,116,116,114,105,98,49,102,118,0,103,108,86,101,114,116,101,120,65,116,116,114,105,98,50,102,118,0,103,108,86,101,114,116,101,120,65,116,116,114,105,98,51,102,118,0,103,108,86,101,114,116,101,120,65,116,116,114,105,98,52,102,118,0,103,108,71,101,116,65,116,116,114,105,98,76,111,99,97,116,105,111,110,0,103,108,71,101,116,65,99,116,105,118,101,65,116,116,114,105,98,0,103,108,68,101,108,101,116,101,83,104,97,100,101,114,0,103,108,71,101,116,65,116,116,97,99,104,101,100,83,104,97,100,101,114,115,0,103,108,83,104,97,100,101,114,83,111,117,114,99,101,0,103,108,71,101,116,83,104,97,100,101,114,83,111,117,114,99,101,0,103,108,67,111,109,112,105,108,101,83,104,97,100,101,114,0,103,108,71,101,116,83,104,97,100,101,114,73,110,102,111,76,111,103,0,103,108,71,101,116,83,104,97,100,101,114,105,118,0,103,108,71,101,116,80,114,111,103,114,97,109,105,118,0,103,108,73,115,83,104,97,100,101,114,0,103,108,68,101,108,101,116,101,80,114,111,103,114,97,109,0,103,108,71,101,116,83,104,97,100,101,114,80,114,101,99,105,115,105,111,110,70,111,114,109,97,116,0,103,108,76,105,110,107,80,114,111,103,114,97,109,0,103,108,71,101,116,80,114,111,103,114,97,109,73,110,102,111,76,111,103,0,103,108,86,97,108,105,100,97,116,101,80,114,111,103,114,97,109,0,103,108,73,115,80,114,111,103,114,97,109,0,103,108,66,105,110,100,65,116,116,114,105,98,76,111,99,97,116,105,111,110,0,103,108,66,105,110,100,70,114,97,109,101,98,117,102,102,101,114,0,103,108,71,101,110,70,114,97,109,101,98,117,102,102,101,114,115,0,103,108,68,101,108,101,116,101,70,114,97,109,101,98,117,102,102,101,114,115,0,103,108,70,114,97,109,101,98,117,102,102,101,114,82,101,110,100,101,114,98,117,102,102,101,114,0,103,108,70,114,97,109,101,98,117,102,102,101,114,84,101,120,116,117,114,101,50,68,0,103,108,71,101,116,70,114,97,109,101,98,117,102,102,101,114,65,116,116,97,99,104,109,101,110,116,80,97,114,97,109,101,116,101,114,105,118,0,103,108,73,115,70,114,97,109,101,98,117,102,102,101,114,0,103,108,68,101,108,101,116,101,79,98,106,101,99,116,0,103,108,71,101,116,79,98,106,101,99,116,80,97,114,97,109,101,116,101,114,105,118,0,103,108,71,101,116,73,110,102,111,76,111,103,0,103,108,66,105,110,100,80,114,111,103,114,97,109,0,103,108,71,101,116,80,111,105,110,116,101,114,118,0,103,108,68,114,97,119,82,97,110,103,101,69,108,101,109,101,110,116,115,0,103,108,69,110,97,98,108,101,67,108,105,101,110,116,83,116,97,116,101,0,103,108,86,101,114,116,101,120,80,111,105,110,116,101,114,0,103,108,84,101,120,67,111,111,114,100,80,111,105,110,116,101,114,0,103,108,78,111,114,109,97,108,80,111,105,110,116,101,114,0,103,108,67,111,108,111,114,80,111,105,110,116,101,114,0,103,108,67,108,105,101,110,116,65,99,116,105,118,101,84,101,120,116,117,114,101,0,103,108,73,115,86,101,114,116,101,120,65,114,114,97,121,0,103,108,71,101,110,86,101,114,116,101,120,65,114,114,97,121,115,0,103,108,68,101,108,101,116,101,86,101,114,116,101,120,65,114,114,97,121,115,0,103,108,66,105,110,100,86,101,114,116,101,120,65,114,114,97,121,0,103,108,77,97,116,114,105,120,77,111,100,101,0,103,108,76,111,97,100,73,100,101,110,116,105,116,121,0,103,108,76,111,97,100,77,97,116,114,105,120,102,0,103,108,70,114,117,115,116,117,109,0,103,108,82,111,116,97,116,101,102,0,103,108,86,101,114,116,101,120,65,116,116,114,105,98,80,111,105,110,116,101,114,0,103,108,69,110,97,98,108,101,86,101,114,116,101,120,65,116,116,114,105,98,65,114,114,97,121,0,103,108,68,105,115,97,98,108,101,86,101,114,116,101,120,65,116,116,114,105,98,65,114,114,97,121,0,103,108,68,114,97,119,65,114,114,97,121,115,0,103,108,68,114,97,119,69,108,101,109,101,110,116,115,0,103,108,83,104,97,100,101,114,66,105,110,97,114,121,0,103,108,82,101,108,101,97,115,101,83,104,97,100,101,114,67,111,109,112,105,108,101,114,0,103,108,71,101,116,69,114,114,111,114,0,103,108,86,101,114,116,101,120,65,116,116,114,105,98,68,105,118,105,115,111,114,0,103,108,68,114,97,119,65,114,114,97,121,115,73,110,115,116,97,110,99,101,100,0,103,108,68,114,97,119,69,108,101,109,101,110,116,115,73,110,115,116,97,110,99,101,100,0,103,108,70,105,110,105,115,104,0,103,108,70,108,117,115,104,0,103,108,67,108,101,97,114,68,101,112,116,104,0,103,108,67,108,101,97,114,68,101,112,116,104,102,0,103,108,68,101,112,116,104,70,117,110,99,0,103,108,69,110,97,98,108,101,0,103,108,68,105,115,97,98,108,101,0,103,108,70,114,111,110,116,70,97,99,101,0,103,108,67,117,108,108,70,97,99,101,0,103,108,67,108,101,97,114,0,103,108,76,105,110,101,87,105,100,116,104,0,103,108,67,108,101,97,114,83,116,101,110,99,105,108,0,103,108,68,101,112,116,104,77,97,115,107,0,103,108,83,116,101,110,99,105,108,77,97,115,107,0,103,108,67,104,101,99,107,70,114,97,109,101,98,117,102,102,101,114,83,116,97,116,117,115,0,103,108,71,101,110,101,114,97,116,101,77,105,112,109,97,112,0,103,108,65,99,116,105,118,101,84,101,120,116,117,114,101,0,103,108,66,108,101,110,100,69,113,117,97,116,105,111,110,0,103,108,73,115,69,110,97,98,108,101,100,0,103,108,66,108,101,110,100,70,117,110,99,0,103,108,66,108,101,110,100,69,113,117,97,116,105,111,110,83,101,112,97,114,97,116,101,0,103,108,68,101,112,116,104,82,97,110,103,101,0,103,108,68,101,112,116,104,82,97,110,103,101,102,0,103,108,83,116,101,110,99,105,108,77,97,115,107,83,101,112,97,114,97,116,101,0,103,108,72,105,110,116,0,103,108,80,111,108,121,103,111,110,79,102,102,115,101,116,0,103,108,86,101,114,116,101,120,65,116,116,114,105,98,49,102,0,103,108,83,97,109,112,108,101,67,111,118,101,114,97,103,101,0,103,108,84,101,120,80,97,114,97,109,101,116,101,114,105,0,103,108,84,101,120,80,97,114,97,109,101,116,101,114,102,0,103,108,86,101,114,116,101,120,65,116,116,114,105,98,50,102,0,103,108,83,116,101,110,99,105,108,70,117,110,99,0,103,108,83,116,101,110,99,105,108,79,112,0,103,108,86,105,101,119,112,111,114,116,0,103,108,67,108,101,97,114,67,111,108,111,114,0,103,108,83,99,105,115,115,111,114,0,103,108,86,101,114,116,101,120,65,116,116,114,105,98,51,102,0,103,108,67,111,108,111,114,77,97,115,107,0,103,108,82,101,110,100,101,114,98,117,102,102,101,114,83,116,111,114,97,103,101,0,103,108,66,108,101,110,100,70,117,110,99,83,101,112,97,114,97,116,101,0,103,108,66,108,101,110,100,67,111,108,111,114,0,103,108,83,116,101,110,99,105,108,70,117,110,99,83,101,112,97,114,97,116,101,0,103,108,83,116,101,110,99,105,108,79,112,83,101,112,97,114,97,116,101,0,103,108,86,101,114,116,101,120,65,116,116,114,105,98,52,102,0,103,108,67,111,112,121,84,101,120,73,109,97,103,101,50,68,0,103,108,67,111,112,121,84,101,120,83,117,98,73,109,97,103,101,50,68,0,103,108,68,114,97,119,66,117,102,102,101,114,115,0,77,111,100,117,108,101,46,112,114,105,110,116,69,114,114,40,39,98,97,100,32,110,97,109,101,32,105,110,32,103,101,116,80,114,111,99,65,100,100,114,101,115,115,58,32,39,32,43,32,91,80,111,105,110,116,101,114,95,115,116,114,105,110,103,105,102,121,40,36,48,41,44,32,80,111,105,110,116,101,114,95,115,116,114,105,110,103,105,102,121,40,36,49,41,93,41,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,255,255,255,255,255,255,255,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,255,255,255,255,255,255,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,1,2,4,7,3,6,5,0,17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,45,43,32,32,32,48,88,48,120,0,40,110,117,108,108,41,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,78,65,78,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,46,0,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112,116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100,100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116,111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111,99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112,101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111,117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115,32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117,112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116,32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100,105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,105,110,102,105,110,105,116,121,0,110,97,110,0,114,119,97,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE+30720);
-
-
-
-
-
-/* no memory initializer */
-var tempDoublePtr = STATICTOP; STATICTOP += 16;
-
-assert(tempDoublePtr % 8 == 0);
-
-function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
-
- HEAP8[tempDoublePtr] = HEAP8[ptr];
-
- HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
-
- HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
-
- HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
-
-}
-
-function copyTempDouble(ptr) {
-
- HEAP8[tempDoublePtr] = HEAP8[ptr];
-
- HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
-
- HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
-
- HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
-
- HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
-
- HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
-
- HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
-
- HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
-
-}
-
-// {{PRE_LIBRARY}}
-
-
-
- var GL={counter:1,lastError:0,buffers:[],mappedBuffers:{},programs:[],framebuffers:[],renderbuffers:[],textures:[],uniforms:[],shaders:[],vaos:[],contexts:[],currentContext:null,offscreenCanvases:{},timerQueriesEXT:[],byteSizeByTypeRoot:5120,byteSizeByType:[1,1,2,2,4,4,4,2,3,4,8],programInfos:{},stringCache:{},tempFixedLengthArray:[],packAlignment:4,unpackAlignment:4,init:function () {
- GL.miniTempBuffer = new Float32Array(GL.MINI_TEMP_BUFFER_SIZE);
- for (var i = 0; i < GL.MINI_TEMP_BUFFER_SIZE; i++) {
- GL.miniTempBufferViews[i] = GL.miniTempBuffer.subarray(0, i+1);
- }
-
- // For functions such as glDrawBuffers, glInvalidateFramebuffer and glInvalidateSubFramebuffer that need to pass a short array to the WebGL API,
- // create a set of short fixed-length arrays to avoid having to generate any garbage when calling those functions.
- for (var i = 0; i < 32; i++) {
- GL.tempFixedLengthArray.push(new Array(i));
- }
- },recordError:function recordError(errorCode) {
- if (!GL.lastError) {
- GL.lastError = errorCode;
- }
- },getNewId:function (table) {
- var ret = GL.counter++;
- for (var i = table.length; i < ret; i++) {
- table[i] = null;
- }
- return ret;
- },MINI_TEMP_BUFFER_SIZE:256,miniTempBuffer:null,miniTempBufferViews:[0],getSource:function (shader, count, string, length) {
- var source = '';
- for (var i = 0; i < count; ++i) {
- var frag;
- if (length) {
- var len = HEAP32[(((length)+(i*4))>>2)];
- if (len < 0) {
- frag = Pointer_stringify(HEAP32[(((string)+(i*4))>>2)]);
- } else {
- frag = Pointer_stringify(HEAP32[(((string)+(i*4))>>2)], len);
- }
- } else {
- frag = Pointer_stringify(HEAP32[(((string)+(i*4))>>2)]);
- }
- source += frag;
- }
- return source;
- },createContext:function (canvas, webGLContextAttributes) {
- if (typeof webGLContextAttributes['majorVersion'] === 'undefined' && typeof webGLContextAttributes['minorVersion'] === 'undefined') {
- webGLContextAttributes['majorVersion'] = 1;
- webGLContextAttributes['minorVersion'] = 0;
- }
-
-
- var ctx;
- var errorInfo = '?';
- function onContextCreationError(event) {
- errorInfo = event.statusMessage || errorInfo;
- }
- try {
- canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
- try {
- if (webGLContextAttributes['majorVersion'] == 1 && webGLContextAttributes['minorVersion'] == 0) {
- ctx = canvas.getContext("webgl", webGLContextAttributes) || canvas.getContext("experimental-webgl", webGLContextAttributes);
- } else if (webGLContextAttributes['majorVersion'] == 2 && webGLContextAttributes['minorVersion'] == 0) {
- ctx = canvas.getContext("webgl2", webGLContextAttributes);
- } else {
- throw 'Unsupported WebGL context version ' + majorVersion + '.' + minorVersion + '!'
- }
- } finally {
- canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
- }
- if (!ctx) throw ':(';
- } catch (e) {
- Module.print('Could not create canvas: ' + [errorInfo, e, JSON.stringify(webGLContextAttributes)]);
- return 0;
- }
-
- if (!ctx) return 0;
- var context = GL.registerContext(ctx, webGLContextAttributes);
- return context;
- },registerContext:function (ctx, webGLContextAttributes) {
- var handle = GL.getNewId(GL.contexts);
- var context = {
- handle: handle,
- attributes: webGLContextAttributes,
- version: webGLContextAttributes['majorVersion'],
- GLctx: ctx
- };
-
-
- // Store the created context object so that we can access the context given a canvas without having to pass the parameters again.
- if (ctx.canvas) ctx.canvas.GLctxObject = context;
- GL.contexts[handle] = context;
- if (typeof webGLContextAttributes['enableExtensionsByDefault'] === 'undefined' || webGLContextAttributes['enableExtensionsByDefault']) {
- GL.initExtensions(context);
- }
- return handle;
- },makeContextCurrent:function (contextHandle) {
- var context = GL.contexts[contextHandle];
- if (!context) return false;
- GLctx = Module.ctx = context.GLctx; // Active WebGL context object.
- GL.currentContext = context; // Active Emscripten GL layer context object.
- return true;
- },getContext:function (contextHandle) {
- return GL.contexts[contextHandle];
- },deleteContext:function (contextHandle) {
- if (GL.currentContext === GL.contexts[contextHandle]) GL.currentContext = null;
- if (typeof JSEvents === 'object') JSEvents.removeAllHandlersOnTarget(GL.contexts[contextHandle].GLctx.canvas); // Release all JS event handlers on the DOM element that the GL context is associated with since the context is now deleted.
- if (GL.contexts[contextHandle] && GL.contexts[contextHandle].GLctx.canvas) GL.contexts[contextHandle].GLctx.canvas.GLctxObject = undefined; // Make sure the canvas object no longer refers to the context object so there are no GC surprises.
- GL.contexts[contextHandle] = null;
- },initExtensions:function (context) {
- // If this function is called without a specific context object, init the extensions of the currently active context.
- if (!context) context = GL.currentContext;
-
- if (context.initExtensionsDone) return;
- context.initExtensionsDone = true;
-
- var GLctx = context.GLctx;
-
- context.maxVertexAttribs = GLctx.getParameter(GLctx.MAX_VERTEX_ATTRIBS);
-
- // Detect the presence of a few extensions manually, this GL interop layer itself will need to know if they exist.
-
- if (context.version < 2) {
- // Extension available from Firefox 26 and Google Chrome 30
- var instancedArraysExt = GLctx.getExtension('ANGLE_instanced_arrays');
- if (instancedArraysExt) {
- GLctx['vertexAttribDivisor'] = function(index, divisor) { instancedArraysExt['vertexAttribDivisorANGLE'](index, divisor); };
- GLctx['drawArraysInstanced'] = function(mode, first, count, primcount) { instancedArraysExt['drawArraysInstancedANGLE'](mode, first, count, primcount); };
- GLctx['drawElementsInstanced'] = function(mode, count, type, indices, primcount) { instancedArraysExt['drawElementsInstancedANGLE'](mode, count, type, indices, primcount); };
- }
-
- // Extension available from Firefox 25 and WebKit
- var vaoExt = GLctx.getExtension('OES_vertex_array_object');
- if (vaoExt) {
- GLctx['createVertexArray'] = function() { return vaoExt['createVertexArrayOES'](); };
- GLctx['deleteVertexArray'] = function(vao) { vaoExt['deleteVertexArrayOES'](vao); };
- GLctx['bindVertexArray'] = function(vao) { vaoExt['bindVertexArrayOES'](vao); };
- GLctx['isVertexArray'] = function(vao) { return vaoExt['isVertexArrayOES'](vao); };
- }
-
- var drawBuffersExt = GLctx.getExtension('WEBGL_draw_buffers');
- if (drawBuffersExt) {
- GLctx['drawBuffers'] = function(n, bufs) { drawBuffersExt['drawBuffersWEBGL'](n, bufs); };
- }
- }
-
- GLctx.disjointTimerQueryExt = GLctx.getExtension("EXT_disjoint_timer_query");
-
- // These are the 'safe' feature-enabling extensions that don't add any performance impact related to e.g. debugging, and
- // should be enabled by default so that client GLES2/GL code will not need to go through extra hoops to get its stuff working.
- // As new extensions are ratified at http://www.khronos.org/registry/webgl/extensions/ , feel free to add your new extensions
- // here, as long as they don't produce a performance impact for users that might not be using those extensions.
- // E.g. debugging-related extensions should probably be off by default.
- var automaticallyEnabledExtensions = [ "OES_texture_float", "OES_texture_half_float", "OES_standard_derivatives",
- "OES_vertex_array_object", "WEBGL_compressed_texture_s3tc", "WEBGL_depth_texture",
- "OES_element_index_uint", "EXT_texture_filter_anisotropic", "ANGLE_instanced_arrays",
- "OES_texture_float_linear", "OES_texture_half_float_linear", "WEBGL_compressed_texture_atc",
- "WEBGL_compressed_texture_pvrtc", "EXT_color_buffer_half_float", "WEBGL_color_buffer_float",
- "EXT_frag_depth", "EXT_sRGB", "WEBGL_draw_buffers", "WEBGL_shared_resources",
- "EXT_shader_texture_lod", "EXT_color_buffer_float"];
-
- function shouldEnableAutomatically(extension) {
- var ret = false;
- automaticallyEnabledExtensions.forEach(function(include) {
- if (ext.indexOf(include) != -1) {
- ret = true;
- }
- });
- return ret;
- }
-
- var exts = GLctx.getSupportedExtensions();
- if (exts && exts.length > 0) {
- GLctx.getSupportedExtensions().forEach(function(ext) {
- if (automaticallyEnabledExtensions.indexOf(ext) != -1) {
- GLctx.getExtension(ext); // Calling .getExtension enables that extension permanently, no need to store the return value to be enabled.
- }
- });
- }
- },populateUniformTable:function (program) {
- var p = GL.programs[program];
- GL.programInfos[program] = {
- uniforms: {},
- maxUniformLength: 0, // This is eagerly computed below, since we already enumerate all uniforms anyway.
- maxAttributeLength: -1, // This is lazily computed and cached, computed when/if first asked, "-1" meaning not computed yet.
- maxUniformBlockNameLength: -1 // Lazily computed as well
- };
-
- var ptable = GL.programInfos[program];
- var utable = ptable.uniforms;
- // A program's uniform table maps the string name of an uniform to an integer location of that uniform.
- // The global GL.uniforms map maps integer locations to WebGLUniformLocations.
- var numUniforms = GLctx.getProgramParameter(p, GLctx.ACTIVE_UNIFORMS);
- for (var i = 0; i < numUniforms; ++i) {
- var u = GLctx.getActiveUniform(p, i);
-
- var name = u.name;
- ptable.maxUniformLength = Math.max(ptable.maxUniformLength, name.length+1);
-
- // Strip off any trailing array specifier we might have got, e.g. "[0]".
- if (name.indexOf(']', name.length-1) !== -1) {
- var ls = name.lastIndexOf('[');
- name = name.slice(0, ls);
- }
-
- // Optimize memory usage slightly: If we have an array of uniforms, e.g. 'vec3 colors[3];', then
- // only store the string 'colors' in utable, and 'colors[0]', 'colors[1]' and 'colors[2]' will be parsed as 'colors'+i.
- // Note that for the GL.uniforms table, we still need to fetch the all WebGLUniformLocations for all the indices.
- var loc = GLctx.getUniformLocation(p, name);
- if (loc != null)
- {
- var id = GL.getNewId(GL.uniforms);
- utable[name] = [u.size, id];
- GL.uniforms[id] = loc;
-
- for (var j = 1; j < u.size; ++j) {
- var n = name + '['+j+']';
- loc = GLctx.getUniformLocation(p, n);
- id = GL.getNewId(GL.uniforms);
-
- GL.uniforms[id] = loc;
- }
- }
- }
- }};function _emscripten_glIsRenderbuffer(renderbuffer) {
- var rb = GL.renderbuffers[renderbuffer];
- if (!rb) return 0;
- return GLctx.isRenderbuffer(rb);
- }
-
- function _emscripten_glStencilMaskSeparate(x0, x1) { GLctx['stencilMaskSeparate'](x0, x1) }
-
-
-
-
-
- function _emscripten_get_now() { abort() }
-
-
-
- function _emscripten_set_main_loop_timing(mode, value) {
- Browser.mainLoop.timingMode = mode;
- Browser.mainLoop.timingValue = value;
-
- if (!Browser.mainLoop.func) {
- console.error('emscripten_set_main_loop_timing: Cannot set timing mode for main loop since a main loop does not exist! Call emscripten_set_main_loop first to set one up.');
- return 1; // Return non-zero on failure, can't set timing mode when there is no main loop.
- }
-
- if (mode == 0 /*EM_TIMING_SETTIMEOUT*/) {
- Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler_setTimeout() {
- var timeUntilNextTick = Math.max(0, Browser.mainLoop.tickStartTime + value - _emscripten_get_now())|0;
- setTimeout(Browser.mainLoop.runner, timeUntilNextTick); // doing this each time means that on exception, we stop
- };
- Browser.mainLoop.method = 'timeout';
- } else if (mode == 1 /*EM_TIMING_RAF*/) {
- Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler_rAF() {
- Browser.requestAnimationFrame(Browser.mainLoop.runner);
- };
- Browser.mainLoop.method = 'rAF';
- } else if (mode == 2 /*EM_TIMING_SETIMMEDIATE*/) {
- if (!window['setImmediate']) {
- // Emulate setImmediate. (note: not a complete polyfill, we don't emulate clearImmediate() to keep code size to minimum, since not needed)
- var setImmediates = [];
- var emscriptenMainLoopMessageId = 'setimmediate';
- function Browser_setImmediate_messageHandler(event) {
- if (event.source === window && event.data === emscriptenMainLoopMessageId) {
- event.stopPropagation();
- setImmediates.shift()();
- }
- }
- window.addEventListener("message", Browser_setImmediate_messageHandler, true);
- window['setImmediate'] = function Browser_emulated_setImmediate(func) {
- setImmediates.push(func);
- if (ENVIRONMENT_IS_WORKER) {
- if (Module['setImmediates'] === undefined) Module['setImmediates'] = [];
- Module['setImmediates'].push(func);
- window.postMessage({target: emscriptenMainLoopMessageId}); // In --proxy-to-worker, route the message via proxyClient.js
- } else window.postMessage(emscriptenMainLoopMessageId, "*"); // On the main thread, can just send the message to itself.
- }
- }
- Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler_setImmediate() {
- window['setImmediate'](Browser.mainLoop.runner);
- };
- Browser.mainLoop.method = 'immediate';
- }
- return 0;
- }function _emscripten_set_main_loop(func, fps, simulateInfiniteLoop, arg, noSetTiming) {
- Module['noExitRuntime'] = true;
-
- assert(!Browser.mainLoop.func, 'emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters.');
-
- Browser.mainLoop.func = func;
- Browser.mainLoop.arg = arg;
-
- var browserIterationFunc;
- if (typeof arg !== 'undefined') {
- browserIterationFunc = function() {
- func(arg);
- };
- } else {
- browserIterationFunc = function() {
- func();
- };
- }
-
- var thisMainLoopId = Browser.mainLoop.currentlyRunningMainloop;
-
- Browser.mainLoop.runner = function Browser_mainLoop_runner() {
- if (ABORT) return;
- if (Browser.mainLoop.queue.length > 0) {
- var start = Date.now();
- var blocker = Browser.mainLoop.queue.shift();
- blocker.func(blocker.arg);
- if (Browser.mainLoop.remainingBlockers) {
- var remaining = Browser.mainLoop.remainingBlockers;
- var next = remaining%1 == 0 ? remaining-1 : Math.floor(remaining);
- if (blocker.counted) {
- Browser.mainLoop.remainingBlockers = next;
- } else {
- // not counted, but move the progress along a tiny bit
- next = next + 0.5; // do not steal all the next one's progress
- Browser.mainLoop.remainingBlockers = (8*remaining + next)/9;
- }
- }
- console.log('main loop blocker "' + blocker.name + '" took ' + (Date.now() - start) + ' ms'); //, left: ' + Browser.mainLoop.remainingBlockers);
- Browser.mainLoop.updateStatus();
-
- // catches pause/resume main loop from blocker execution
- if (thisMainLoopId < Browser.mainLoop.currentlyRunningMainloop) return;
-
- setTimeout(Browser.mainLoop.runner, 0);
- return;
- }
-
- // catch pauses from non-main loop sources
- if (thisMainLoopId < Browser.mainLoop.currentlyRunningMainloop) return;
-
- // Implement very basic swap interval control
- Browser.mainLoop.currentFrameNumber = Browser.mainLoop.currentFrameNumber + 1 | 0;
- if (Browser.mainLoop.timingMode == 1/*EM_TIMING_RAF*/ && Browser.mainLoop.timingValue > 1 && Browser.mainLoop.currentFrameNumber % Browser.mainLoop.timingValue != 0) {
- // Not the scheduled time to render this frame - skip.
- Browser.mainLoop.scheduler();
- return;
- } else if (Browser.mainLoop.timingMode == 0/*EM_TIMING_SETTIMEOUT*/) {
- Browser.mainLoop.tickStartTime = _emscripten_get_now();
- }
-
- // Signal GL rendering layer that processing of a new frame is about to start. This helps it optimize
- // VBO double-buffering and reduce GPU stalls.
-
-
- if (Browser.mainLoop.method === 'timeout' && Module.ctx) {
- Module.printErr('Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!');
- Browser.mainLoop.method = ''; // just warn once per call to set main loop
- }
-
- Browser.mainLoop.runIter(browserIterationFunc);
-
- checkStackCookie();
-
- // catch pauses from the main loop itself
- if (thisMainLoopId < Browser.mainLoop.currentlyRunningMainloop) return;
-
- // Queue new audio data. This is important to be right after the main loop invocation, so that we will immediately be able
- // to queue the newest produced audio samples.
- // TODO: Consider adding pre- and post- rAF callbacks so that GL.newRenderingFrameStarted() and SDL.audio.queueNewAudioData()
- // do not need to be hardcoded into this function, but can be more generic.
- if (typeof SDL === 'object' && SDL.audio && SDL.audio.queueNewAudioData) SDL.audio.queueNewAudioData();
-
- Browser.mainLoop.scheduler();
- }
-
- if (!noSetTiming) {
- if (fps && fps > 0) _emscripten_set_main_loop_timing(0/*EM_TIMING_SETTIMEOUT*/, 1000.0 / fps);
- else _emscripten_set_main_loop_timing(1/*EM_TIMING_RAF*/, 1); // Do rAF by rendering each frame (no decimating)
-
- Browser.mainLoop.scheduler();
- }
-
- if (simulateInfiniteLoop) {
- throw 'SimulateInfiniteLoop';
- }
- }
- Module["_emscripten_set_main_loop"] = _emscripten_set_main_loop;var Browser={mainLoop:{scheduler:null,method:"",currentlyRunningMainloop:0,func:null,arg:0,timingMode:0,timingValue:0,currentFrameNumber:0,queue:[],pause:function () {
- Browser.mainLoop.scheduler = null;
- Browser.mainLoop.currentlyRunningMainloop++; // Incrementing this signals the previous main loop that it's now become old, and it must return.
- },resume:function () {
- Browser.mainLoop.currentlyRunningMainloop++;
- var timingMode = Browser.mainLoop.timingMode;
- var timingValue = Browser.mainLoop.timingValue;
- var func = Browser.mainLoop.func;
- Browser.mainLoop.func = null;
- _emscripten_set_main_loop(func, 0, false, Browser.mainLoop.arg, true /* do not set timing and call scheduler, we will do it on the next lines */);
- _emscripten_set_main_loop_timing(timingMode, timingValue);
- Browser.mainLoop.scheduler();
- },updateStatus:function () {
- if (Module['setStatus']) {
- var message = Module['statusMessage'] || 'Please wait...';
- var remaining = Browser.mainLoop.remainingBlockers;
- var expected = Browser.mainLoop.expectedBlockers;
- if (remaining) {
- if (remaining < expected) {
- Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
- } else {
- Module['setStatus'](message);
- }
- } else {
- Module['setStatus']('');
- }
- }
- },runIter:function (func) {
- if (ABORT) return;
- if (Module['preMainLoop']) {
- var preRet = Module['preMainLoop']();
- if (preRet === false) {
- return; // |return false| skips a frame
- }
- }
- try {
- func();
- } catch (e) {
- if (e instanceof ExitStatus) {
- return;
- } else {
- if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
- throw e;
- }
- }
- if (Module['postMainLoop']) Module['postMainLoop']();
- }},isFullscreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
- if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
-
- if (Browser.initted) return;
- Browser.initted = true;
-
- try {
- new Blob();
- Browser.hasBlobConstructor = true;
- } catch(e) {
- Browser.hasBlobConstructor = false;
- console.log("warning: no blob constructor, cannot create blobs with mimetypes");
- }
- Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
- Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
- if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
- console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
- Module.noImageDecoding = true;
- }
-
- // Support for plugins that can process preloaded files. You can add more of these to
- // your app by creating and appending to Module.preloadPlugins.
- //
- // Each plugin is asked if it can handle a file based on the file's name. If it can,
- // it is given the file's raw data. When it is done, it calls a callback with the file's
- // (possibly modified) data. For example, a plugin might decompress a file, or it
- // might create some side data structure for use later (like an Image element, etc.).
-
- var imagePlugin = {};
- imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
- return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
- };
- imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
- var b = null;
- if (Browser.hasBlobConstructor) {
- try {
- b = new Blob([byteArray], { type: Browser.getMimetype(name) });
- if (b.size !== byteArray.length) { // Safari bug #118630
- // Safari's Blob can only take an ArrayBuffer
- b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
- }
- } catch(e) {
- Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
- }
- }
- if (!b) {
- var bb = new Browser.BlobBuilder();
- bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
- b = bb.getBlob();
- }
- var url = Browser.URLObject.createObjectURL(b);
- assert(typeof url == 'string', 'createObjectURL must return a url as a string');
- var img = new Image();
- img.onload = function img_onload() {
- assert(img.complete, 'Image ' + name + ' could not be decoded');
- var canvas = document.createElement('canvas');
- canvas.width = img.width;
- canvas.height = img.height;
- var ctx = canvas.getContext('2d');
- ctx.drawImage(img, 0, 0);
- Module["preloadedImages"][name] = canvas;
- Browser.URLObject.revokeObjectURL(url);
- if (onload) onload(byteArray);
- };
- img.onerror = function img_onerror(event) {
- console.log('Image ' + url + ' could not be decoded');
- if (onerror) onerror();
- };
- img.src = url;
- };
- Module['preloadPlugins'].push(imagePlugin);
-
- var audioPlugin = {};
- audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
- return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
- };
- audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
- var done = false;
- function finish(audio) {
- if (done) return;
- done = true;
- Module["preloadedAudios"][name] = audio;
- if (onload) onload(byteArray);
- }
- function fail() {
- if (done) return;
- done = true;
- Module["preloadedAudios"][name] = new Audio(); // empty shim
- if (onerror) onerror();
- }
- if (Browser.hasBlobConstructor) {
- try {
- var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
- } catch(e) {
- return fail();
- }
- var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
- assert(typeof url == 'string', 'createObjectURL must return a url as a string');
- var audio = new Audio();
- audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
- audio.onerror = function audio_onerror(event) {
- if (done) return;
- console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
- function encode64(data) {
- var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
- var PAD = '=';
- var ret = '';
- var leftchar = 0;
- var leftbits = 0;
- for (var i = 0; i < data.length; i++) {
- leftchar = (leftchar << 8) | data[i];
- leftbits += 8;
- while (leftbits >= 6) {
- var curr = (leftchar >> (leftbits-6)) & 0x3f;
- leftbits -= 6;
- ret += BASE[curr];
- }
- }
- if (leftbits == 2) {
- ret += BASE[(leftchar&3) << 4];
- ret += PAD + PAD;
- } else if (leftbits == 4) {
- ret += BASE[(leftchar&0xf) << 2];
- ret += PAD;
- }
- return ret;
- }
- audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
- finish(audio); // we don't wait for confirmation this worked - but it's worth trying
- };
- audio.src = url;
- // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
- Browser.safeSetTimeout(function() {
- finish(audio); // try to use it even though it is not necessarily ready to play
- }, 10000);
- } else {
- return fail();
- }
- };
- Module['preloadPlugins'].push(audioPlugin);
-
- // Canvas event setup
-
- function pointerLockChange() {
- Browser.pointerLock = document['pointerLockElement'] === Module['canvas'] ||
- document['mozPointerLockElement'] === Module['canvas'] ||
- document['webkitPointerLockElement'] === Module['canvas'] ||
- document['msPointerLockElement'] === Module['canvas'];
- }
- var canvas = Module['canvas'];
- if (canvas) {
- // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
- // Module['forcedAspectRatio'] = 4 / 3;
-
- canvas.requestPointerLock = canvas['requestPointerLock'] ||
- canvas['mozRequestPointerLock'] ||
- canvas['webkitRequestPointerLock'] ||
- canvas['msRequestPointerLock'] ||
- function(){};
- canvas.exitPointerLock = document['exitPointerLock'] ||
- document['mozExitPointerLock'] ||
- document['webkitExitPointerLock'] ||
- document['msExitPointerLock'] ||
- function(){}; // no-op if function does not exist
- canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
-
- document.addEventListener('pointerlockchange', pointerLockChange, false);
- document.addEventListener('mozpointerlockchange', pointerLockChange, false);
- document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
- document.addEventListener('mspointerlockchange', pointerLockChange, false);
-
- if (Module['elementPointerLock']) {
- canvas.addEventListener("click", function(ev) {
- if (!Browser.pointerLock && Module['canvas'].requestPointerLock) {
- Module['canvas'].requestPointerLock();
- ev.preventDefault();
- }
- }, false);
- }
- }
- },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
- if (useWebGL && Module.ctx && canvas == Module.canvas) return Module.ctx; // no need to recreate GL context if it's already been created for this canvas.
-
- var ctx;
- var contextHandle;
- if (useWebGL) {
- // For GLES2/desktop GL compatibility, adjust a few defaults to be different to WebGL defaults, so that they align better with the desktop defaults.
- var contextAttributes = {
- antialias: false,
- alpha: false
- };
-
- if (webGLContextAttributes) {
- for (var attribute in webGLContextAttributes) {
- contextAttributes[attribute] = webGLContextAttributes[attribute];
- }
- }
-
- contextHandle = GL.createContext(canvas, contextAttributes);
- if (contextHandle) {
- ctx = GL.getContext(contextHandle).GLctx;
- }
- } else {
- ctx = canvas.getContext('2d');
- }
-
- if (!ctx) return null;
-
- if (setInModule) {
- if (!useWebGL) assert(typeof GLctx === 'undefined', 'cannot set in module if GLctx is used, but we are a non-GL context that would replace it');
-
- Module.ctx = ctx;
- if (useWebGL) GL.makeContextCurrent(contextHandle);
- Module.useWebGL = useWebGL;
- Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
- Browser.init();
- }
- return ctx;
- },destroyContext:function (canvas, useWebGL, setInModule) {},fullscreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullscreen:function (lockPointer, resizeCanvas, vrDevice) {
- Browser.lockPointer = lockPointer;
- Browser.resizeCanvas = resizeCanvas;
- Browser.vrDevice = vrDevice;
- if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
- if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
- if (typeof Browser.vrDevice === 'undefined') Browser.vrDevice = null;
-
- var canvas = Module['canvas'];
- function fullscreenChange() {
- Browser.isFullscreen = false;
- var canvasContainer = canvas.parentNode;
- if ((document['fullscreenElement'] || document['mozFullScreenElement'] ||
- document['msFullscreenElement'] || document['webkitFullscreenElement'] ||
- document['webkitCurrentFullScreenElement']) === canvasContainer) {
- canvas.exitFullscreen = document['exitFullscreen'] ||
- document['cancelFullScreen'] ||
- document['mozCancelFullScreen'] ||
- document['msExitFullscreen'] ||
- document['webkitCancelFullScreen'] ||
- function() {};
- canvas.exitFullscreen = canvas.exitFullscreen.bind(document);
- if (Browser.lockPointer) canvas.requestPointerLock();
- Browser.isFullscreen = true;
- if (Browser.resizeCanvas) Browser.setFullscreenCanvasSize();
- } else {
-
- // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen
- canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
- canvasContainer.parentNode.removeChild(canvasContainer);
-
- if (Browser.resizeCanvas) Browser.setWindowedCanvasSize();
- }
- if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullscreen);
- if (Module['onFullscreen']) Module['onFullscreen'](Browser.isFullscreen);
- Browser.updateCanvasDimensions(canvas);
- }
-
- if (!Browser.fullscreenHandlersInstalled) {
- Browser.fullscreenHandlersInstalled = true;
- document.addEventListener('fullscreenchange', fullscreenChange, false);
- document.addEventListener('mozfullscreenchange', fullscreenChange, false);
- document.addEventListener('webkitfullscreenchange', fullscreenChange, false);
- document.addEventListener('MSFullscreenChange', fullscreenChange, false);
- }
-
- // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
- var canvasContainer = document.createElement("div");
- canvas.parentNode.insertBefore(canvasContainer, canvas);
- canvasContainer.appendChild(canvas);
-
- // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
- canvasContainer.requestFullscreen = canvasContainer['requestFullscreen'] ||
- canvasContainer['mozRequestFullScreen'] ||
- canvasContainer['msRequestFullscreen'] ||
- (canvasContainer['webkitRequestFullscreen'] ? function() { canvasContainer['webkitRequestFullscreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null) ||
- (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
-
- if (vrDevice) {
- canvasContainer.requestFullscreen({ vrDisplay: vrDevice });
- } else {
- canvasContainer.requestFullscreen();
- }
- },requestFullScreen:function (lockPointer, resizeCanvas, vrDevice) {
- Module.printErr('Browser.requestFullScreen() is deprecated. Please call Browser.requestFullscreen instead.');
- Browser.requestFullScreen = function(lockPointer, resizeCanvas, vrDevice) {
- return Browser.requestFullscreen(lockPointer, resizeCanvas, vrDevice);
- }
- return Browser.requestFullscreen(lockPointer, resizeCanvas, vrDevice);
- },nextRAF:0,fakeRequestAnimationFrame:function (func) {
- // try to keep 60fps between calls to here
- var now = Date.now();
- if (Browser.nextRAF === 0) {
- Browser.nextRAF = now + 1000/60;
- } else {
- while (now + 2 >= Browser.nextRAF) { // fudge a little, to avoid timer jitter causing us to do lots of delay:0
- Browser.nextRAF += 1000/60;
- }
- }
- var delay = Math.max(Browser.nextRAF - now, 0);
- setTimeout(func, delay);
- },requestAnimationFrame:function requestAnimationFrame(func) {
- if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
- Browser.fakeRequestAnimationFrame(func);
- } else {
- if (!window.requestAnimationFrame) {
- window.requestAnimationFrame = window['requestAnimationFrame'] ||
- window['mozRequestAnimationFrame'] ||
- window['webkitRequestAnimationFrame'] ||
- window['msRequestAnimationFrame'] ||
- window['oRequestAnimationFrame'] ||
- Browser.fakeRequestAnimationFrame;
- }
- window.requestAnimationFrame(func);
- }
- },safeCallback:function (func) {
- return function() {
- if (!ABORT) return func.apply(null, arguments);
- };
- },allowAsyncCallbacks:true,queuedAsyncCallbacks:[],pauseAsyncCallbacks:function () {
- Browser.allowAsyncCallbacks = false;
- },resumeAsyncCallbacks:function () { // marks future callbacks as ok to execute, and synchronously runs any remaining ones right now
- Browser.allowAsyncCallbacks = true;
- if (Browser.queuedAsyncCallbacks.length > 0) {
- var callbacks = Browser.queuedAsyncCallbacks;
- Browser.queuedAsyncCallbacks = [];
- callbacks.forEach(function(func) {
- func();
- });
- }
- },safeRequestAnimationFrame:function (func) {
- return Browser.requestAnimationFrame(function() {
- if (ABORT) return;
- if (Browser.allowAsyncCallbacks) {
- func();
- } else {
- Browser.queuedAsyncCallbacks.push(func);
- }
- });
- },safeSetTimeout:function (func, timeout) {
- Module['noExitRuntime'] = true;
- return setTimeout(function() {
- if (ABORT) return;
- if (Browser.allowAsyncCallbacks) {
- func();
- } else {
- Browser.queuedAsyncCallbacks.push(func);
- }
- }, timeout);
- },safeSetInterval:function (func, timeout) {
- Module['noExitRuntime'] = true;
- return setInterval(function() {
- if (ABORT) return;
- if (Browser.allowAsyncCallbacks) {
- func();
- } // drop it on the floor otherwise, next interval will kick in
- }, timeout);
- },getMimetype:function (name) {
- return {
- 'jpg': 'image/jpeg',
- 'jpeg': 'image/jpeg',
- 'png': 'image/png',
- 'bmp': 'image/bmp',
- 'ogg': 'audio/ogg',
- 'wav': 'audio/wav',
- 'mp3': 'audio/mpeg'
- }[name.substr(name.lastIndexOf('.')+1)];
- },getUserMedia:function (func) {
- if(!window.getUserMedia) {
- window.getUserMedia = navigator['getUserMedia'] ||
- navigator['mozGetUserMedia'];
- }
- window.getUserMedia(func);
- },getMovementX:function (event) {
- return event['movementX'] ||
- event['mozMovementX'] ||
- event['webkitMovementX'] ||
- 0;
- },getMovementY:function (event) {
- return event['movementY'] ||
- event['mozMovementY'] ||
- event['webkitMovementY'] ||
- 0;
- },getMouseWheelDelta:function (event) {
- var delta = 0;
- switch (event.type) {
- case 'DOMMouseScroll':
- delta = event.detail;
- break;
- case 'mousewheel':
- delta = event.wheelDelta;
- break;
- case 'wheel':
- delta = event['deltaY'];
- break;
- default:
- throw 'unrecognized mouse wheel event: ' + event.type;
- }
- return delta;
- },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,touches:{},lastTouches:{},calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
- if (Browser.pointerLock) {
- // When the pointer is locked, calculate the coordinates
- // based on the movement of the mouse.
- // Workaround for Firefox bug 764498
- if (event.type != 'mousemove' &&
- ('mozMovementX' in event)) {
- Browser.mouseMovementX = Browser.mouseMovementY = 0;
- } else {
- Browser.mouseMovementX = Browser.getMovementX(event);
- Browser.mouseMovementY = Browser.getMovementY(event);
- }
-
- // check if SDL is available
- if (typeof SDL != "undefined") {
- Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
- Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
- } else {
- // just add the mouse delta to the current absolut mouse position
- // FIXME: ideally this should be clamped against the canvas size and zero
- Browser.mouseX += Browser.mouseMovementX;
- Browser.mouseY += Browser.mouseMovementY;
- }
- } else {
- // Otherwise, calculate the movement based on the changes
- // in the coordinates.
- var rect = Module["canvas"].getBoundingClientRect();
- var cw = Module["canvas"].width;
- var ch = Module["canvas"].height;
-
- // Neither .scrollX or .pageXOffset are defined in a spec, but
- // we prefer .scrollX because it is currently in a spec draft.
- // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
- var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset);
- var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset);
- // If this assert lands, it's likely because the browser doesn't support scrollX or pageXOffset
- // and we have no viable fallback.
- assert((typeof scrollX !== 'undefined') && (typeof scrollY !== 'undefined'), 'Unable to retrieve scroll position, mouse positions likely broken.');
-
- if (event.type === 'touchstart' || event.type === 'touchend' || event.type === 'touchmove') {
- var touch = event.touch;
- if (touch === undefined) {
- return; // the "touch" property is only defined in SDL
-
- }
- var adjustedX = touch.pageX - (scrollX + rect.left);
- var adjustedY = touch.pageY - (scrollY + rect.top);
-
- adjustedX = adjustedX * (cw / rect.width);
- adjustedY = adjustedY * (ch / rect.height);
-
- var coords = { x: adjustedX, y: adjustedY };
-
- if (event.type === 'touchstart') {
- Browser.lastTouches[touch.identifier] = coords;
- Browser.touches[touch.identifier] = coords;
- } else if (event.type === 'touchend' || event.type === 'touchmove') {
- var last = Browser.touches[touch.identifier];
- if (!last) last = coords;
- Browser.lastTouches[touch.identifier] = last;
- Browser.touches[touch.identifier] = coords;
- }
- return;
- }
-
- var x = event.pageX - (scrollX + rect.left);
- var y = event.pageY - (scrollY + rect.top);
-
- // the canvas might be CSS-scaled compared to its backbuffer;
- // SDL-using content will want mouse coordinates in terms
- // of backbuffer units.
- x = x * (cw / rect.width);
- y = y * (ch / rect.height);
-
- Browser.mouseMovementX = x - Browser.mouseX;
- Browser.mouseMovementY = y - Browser.mouseY;
- Browser.mouseX = x;
- Browser.mouseY = y;
- }
- },asyncLoad:function (url, onload, onerror, noRunDep) {
- var dep = !noRunDep ? getUniqueRunDependency('al ' + url) : '';
- Module['readAsync'](url, function(arrayBuffer) {
- assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
- onload(new Uint8Array(arrayBuffer));
- if (dep) removeRunDependency(dep);
- }, function(event) {
- if (onerror) {
- onerror();
- } else {
- throw 'Loading data file "' + url + '" failed.';
- }
- });
- if (dep) addRunDependency(dep);
- },resizeListeners:[],updateResizeListeners:function () {
- var canvas = Module['canvas'];
- Browser.resizeListeners.forEach(function(listener) {
- listener(canvas.width, canvas.height);
- });
- },setCanvasSize:function (width, height, noUpdates) {
- var canvas = Module['canvas'];
- Browser.updateCanvasDimensions(canvas, width, height);
- if (!noUpdates) Browser.updateResizeListeners();
- },windowedWidth:0,windowedHeight:0,setFullscreenCanvasSize:function () {
- // check if SDL is available
- if (typeof SDL != "undefined") {
- var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
- flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
- HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
- }
- Browser.updateResizeListeners();
- },setWindowedCanvasSize:function () {
- // check if SDL is available
- if (typeof SDL != "undefined") {
- var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
- flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
- HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
- }
- Browser.updateResizeListeners();
- },updateCanvasDimensions:function (canvas, wNative, hNative) {
- if (wNative && hNative) {
- canvas.widthNative = wNative;
- canvas.heightNative = hNative;
- } else {
- wNative = canvas.widthNative;
- hNative = canvas.heightNative;
- }
- var w = wNative;
- var h = hNative;
- if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
- if (w/h < Module['forcedAspectRatio']) {
- w = Math.round(h * Module['forcedAspectRatio']);
- } else {
- h = Math.round(w / Module['forcedAspectRatio']);
- }
- }
- if (((document['fullscreenElement'] || document['mozFullScreenElement'] ||
- document['msFullscreenElement'] || document['webkitFullscreenElement'] ||
- document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
- var factor = Math.min(screen.width / w, screen.height / h);
- w = Math.round(w * factor);
- h = Math.round(h * factor);
- }
- if (Browser.resizeCanvas) {
- if (canvas.width != w) canvas.width = w;
- if (canvas.height != h) canvas.height = h;
- if (typeof canvas.style != 'undefined') {
- canvas.style.removeProperty( "width");
- canvas.style.removeProperty("height");
- }
- } else {
- if (canvas.width != wNative) canvas.width = wNative;
- if (canvas.height != hNative) canvas.height = hNative;
- if (typeof canvas.style != 'undefined') {
- if (w != wNative || h != hNative) {
- canvas.style.setProperty( "width", w + "px", "important");
- canvas.style.setProperty("height", h + "px", "important");
- } else {
- canvas.style.removeProperty( "width");
- canvas.style.removeProperty("height");
- }
- }
- }
- },wgetRequests:{},nextWgetRequestHandle:0,getNextWgetRequestHandle:function () {
- var handle = Browser.nextWgetRequestHandle;
- Browser.nextWgetRequestHandle++;
- return handle;
- }};var GLFW={Window:function (id, width, height, title, monitor, share) {
- this.id = id;
- this.x = 0;
- this.y = 0;
- this.fullscreen = false; // Used to determine if app in fullscreen mode
- this.storedX = 0; // Used to store X before fullscreen
- this.storedY = 0; // Used to store Y before fullscreen
- this.width = width;
- this.height = height;
- this.storedWidth = width; // Used to store width before fullscreen
- this.storedHeight = height; // Used to store height before fullscreen
- this.title = title;
- this.monitor = monitor;
- this.share = share;
- this.attributes = GLFW.hints;
- this.inputModes = {
- 0x00033001:0x00034001, // GLFW_CURSOR (GLFW_CURSOR_NORMAL)
- 0x00033002:0, // GLFW_STICKY_KEYS
- 0x00033003:0, // GLFW_STICKY_MOUSE_BUTTONS
- };
- this.buttons = 0;
- this.keys = new Array();
- this.domKeys = new Array();
- this.shouldClose = 0;
- this.title = null;
- this.windowPosFunc = null; // GLFWwindowposfun
- this.windowSizeFunc = null; // GLFWwindowsizefun
- this.windowCloseFunc = null; // GLFWwindowclosefun
- this.windowRefreshFunc = null; // GLFWwindowrefreshfun
- this.windowFocusFunc = null; // GLFWwindowfocusfun
- this.windowIconifyFunc = null; // GLFWwindowiconifyfun
- this.framebufferSizeFunc = null; // GLFWframebuffersizefun
- this.mouseButtonFunc = null; // GLFWmousebuttonfun
- this.cursorPosFunc = null; // GLFWcursorposfun
- this.cursorEnterFunc = null; // GLFWcursorenterfun
- this.scrollFunc = null; // GLFWscrollfun
- this.dropFunc = null; // GLFWdropfun
- this.keyFunc = null; // GLFWkeyfun
- this.charFunc = null; // GLFWcharfun
- this.userptr = null;
- },WindowFromId:function (id) {
- if (id <= 0 || !GLFW.windows) return null;
- return GLFW.windows[id - 1];
- },joystickFunc:null,errorFunc:null,monitorFunc:null,active:null,windows:null,monitors:null,monitorString:null,versionString:null,initialTime:null,extensions:null,hints:null,defaultHints:{131073:0,131074:0,131075:1,131076:1,131077:1,135169:8,135170:8,135171:8,135172:8,135173:24,135174:8,135175:0,135176:0,135177:0,135178:0,135179:0,135180:0,135181:0,135182:0,135183:0,139265:196609,139266:1,139267:0,139268:0,139269:0,139270:0,139271:0,139272:0},DOMToGLFWKeyCode:function (keycode) {
- switch (keycode) {
- // these keycodes are only defined for GLFW3, assume they are the same for GLFW2
- case 0x20:return 32; // DOM_VK_SPACE -> GLFW_KEY_SPACE
- case 0xDE:return 39; // DOM_VK_QUOTE -> GLFW_KEY_APOSTROPHE
- case 0xBC:return 44; // DOM_VK_COMMA -> GLFW_KEY_COMMA
- case 0xAD:return 45; // DOM_VK_HYPHEN_MINUS -> GLFW_KEY_MINUS
- case 0xBD:return 45; // DOM_VK_MINUS -> GLFW_KEY_MINUS
- case 0xBE:return 46; // DOM_VK_PERIOD -> GLFW_KEY_PERIOD
- case 0xBF:return 47; // DOM_VK_SLASH -> GLFW_KEY_SLASH
- case 0x30:return 48; // DOM_VK_0 -> GLFW_KEY_0
- case 0x31:return 49; // DOM_VK_1 -> GLFW_KEY_1
- case 0x32:return 50; // DOM_VK_2 -> GLFW_KEY_2
- case 0x33:return 51; // DOM_VK_3 -> GLFW_KEY_3
- case 0x34:return 52; // DOM_VK_4 -> GLFW_KEY_4
- case 0x35:return 53; // DOM_VK_5 -> GLFW_KEY_5
- case 0x36:return 54; // DOM_VK_6 -> GLFW_KEY_6
- case 0x37:return 55; // DOM_VK_7 -> GLFW_KEY_7
- case 0x38:return 56; // DOM_VK_8 -> GLFW_KEY_8
- case 0x39:return 57; // DOM_VK_9 -> GLFW_KEY_9
- case 0x3B:return 59; // DOM_VK_SEMICOLON -> GLFW_KEY_SEMICOLON
- case 0x3D:return 61; // DOM_VK_EQUALS -> GLFW_KEY_EQUAL
- case 0xBB:return 61; // DOM_VK_EQUALS -> GLFW_KEY_EQUAL
- case 0x41:return 65; // DOM_VK_A -> GLFW_KEY_A
- case 0x42:return 66; // DOM_VK_B -> GLFW_KEY_B
- case 0x43:return 67; // DOM_VK_C -> GLFW_KEY_C
- case 0x44:return 68; // DOM_VK_D -> GLFW_KEY_D
- case 0x45:return 69; // DOM_VK_E -> GLFW_KEY_E
- case 0x46:return 70; // DOM_VK_F -> GLFW_KEY_F
- case 0x47:return 71; // DOM_VK_G -> GLFW_KEY_G
- case 0x48:return 72; // DOM_VK_H -> GLFW_KEY_H
- case 0x49:return 73; // DOM_VK_I -> GLFW_KEY_I
- case 0x4A:return 74; // DOM_VK_J -> GLFW_KEY_J
- case 0x4B:return 75; // DOM_VK_K -> GLFW_KEY_K
- case 0x4C:return 76; // DOM_VK_L -> GLFW_KEY_L
- case 0x4D:return 77; // DOM_VK_M -> GLFW_KEY_M
- case 0x4E:return 78; // DOM_VK_N -> GLFW_KEY_N
- case 0x4F:return 79; // DOM_VK_O -> GLFW_KEY_O
- case 0x50:return 80; // DOM_VK_P -> GLFW_KEY_P
- case 0x51:return 81; // DOM_VK_Q -> GLFW_KEY_Q
- case 0x52:return 82; // DOM_VK_R -> GLFW_KEY_R
- case 0x53:return 83; // DOM_VK_S -> GLFW_KEY_S
- case 0x54:return 84; // DOM_VK_T -> GLFW_KEY_T
- case 0x55:return 85; // DOM_VK_U -> GLFW_KEY_U
- case 0x56:return 86; // DOM_VK_V -> GLFW_KEY_V
- case 0x57:return 87; // DOM_VK_W -> GLFW_KEY_W
- case 0x58:return 88; // DOM_VK_X -> GLFW_KEY_X
- case 0x59:return 89; // DOM_VK_Y -> GLFW_KEY_Y
- case 0x5a:return 90; // DOM_VK_Z -> GLFW_KEY_Z
- case 0xDB:return 91; // DOM_VK_OPEN_BRACKET -> GLFW_KEY_LEFT_BRACKET
- case 0xDC:return 92; // DOM_VK_BACKSLASH -> GLFW_KEY_BACKSLASH
- case 0xDD:return 93; // DOM_VK_CLOSE_BRACKET -> GLFW_KEY_RIGHT_BRACKET
- case 0xC0:return 94; // DOM_VK_BACK_QUOTE -> GLFW_KEY_GRAVE_ACCENT
-
-
- case 0x1B:return 256; // DOM_VK_ESCAPE -> GLFW_KEY_ESCAPE
- case 0x0D:return 257; // DOM_VK_RETURN -> GLFW_KEY_ENTER
- case 0x09:return 258; // DOM_VK_TAB -> GLFW_KEY_TAB
- case 0x08:return 259; // DOM_VK_BACK -> GLFW_KEY_BACKSPACE
- case 0x2D:return 260; // DOM_VK_INSERT -> GLFW_KEY_INSERT
- case 0x2E:return 261; // DOM_VK_DELETE -> GLFW_KEY_DELETE
- case 0x27:return 262; // DOM_VK_RIGHT -> GLFW_KEY_RIGHT
- case 0x25:return 263; // DOM_VK_LEFT -> GLFW_KEY_LEFT
- case 0x28:return 264; // DOM_VK_DOWN -> GLFW_KEY_DOWN
- case 0x26:return 265; // DOM_VK_UP -> GLFW_KEY_UP
- case 0x21:return 266; // DOM_VK_PAGE_UP -> GLFW_KEY_PAGE_UP
- case 0x22:return 267; // DOM_VK_PAGE_DOWN -> GLFW_KEY_PAGE_DOWN
- case 0x24:return 268; // DOM_VK_HOME -> GLFW_KEY_HOME
- case 0x23:return 269; // DOM_VK_END -> GLFW_KEY_END
- case 0x14:return 280; // DOM_VK_CAPS_LOCK -> GLFW_KEY_CAPS_LOCK
- case 0x91:return 281; // DOM_VK_SCROLL_LOCK -> GLFW_KEY_SCROLL_LOCK
- case 0x90:return 282; // DOM_VK_NUM_LOCK -> GLFW_KEY_NUM_LOCK
- case 0x2C:return 283; // DOM_VK_SNAPSHOT -> GLFW_KEY_PRINT_SCREEN
- case 0x13:return 284; // DOM_VK_PAUSE -> GLFW_KEY_PAUSE
- case 0x70:return 290; // DOM_VK_F1 -> GLFW_KEY_F1
- case 0x71:return 291; // DOM_VK_F2 -> GLFW_KEY_F2
- case 0x72:return 292; // DOM_VK_F3 -> GLFW_KEY_F3
- case 0x73:return 293; // DOM_VK_F4 -> GLFW_KEY_F4
- case 0x74:return 294; // DOM_VK_F5 -> GLFW_KEY_F5
- case 0x75:return 295; // DOM_VK_F6 -> GLFW_KEY_F6
- case 0x76:return 296; // DOM_VK_F7 -> GLFW_KEY_F7
- case 0x77:return 297; // DOM_VK_F8 -> GLFW_KEY_F8
- case 0x78:return 298; // DOM_VK_F9 -> GLFW_KEY_F9
- case 0x79:return 299; // DOM_VK_F10 -> GLFW_KEY_F10
- case 0x7A:return 300; // DOM_VK_F11 -> GLFW_KEY_F11
- case 0x7B:return 301; // DOM_VK_F12 -> GLFW_KEY_F12
- case 0x7C:return 302; // DOM_VK_F13 -> GLFW_KEY_F13
- case 0x7D:return 303; // DOM_VK_F14 -> GLFW_KEY_F14
- case 0x7E:return 304; // DOM_VK_F15 -> GLFW_KEY_F15
- case 0x7F:return 305; // DOM_VK_F16 -> GLFW_KEY_F16
- case 0x80:return 306; // DOM_VK_F17 -> GLFW_KEY_F17
- case 0x81:return 307; // DOM_VK_F18 -> GLFW_KEY_F18
- case 0x82:return 308; // DOM_VK_F19 -> GLFW_KEY_F19
- case 0x83:return 309; // DOM_VK_F20 -> GLFW_KEY_F20
- case 0x84:return 310; // DOM_VK_F21 -> GLFW_KEY_F21
- case 0x85:return 311; // DOM_VK_F22 -> GLFW_KEY_F22
- case 0x86:return 312; // DOM_VK_F23 -> GLFW_KEY_F23
- case 0x87:return 313; // DOM_VK_F24 -> GLFW_KEY_F24
- case 0x88:return 314; // 0x88 (not used?) -> GLFW_KEY_F25
- case 0x60:return 320; // DOM_VK_NUMPAD0 -> GLFW_KEY_KP_0
- case 0x61:return 321; // DOM_VK_NUMPAD1 -> GLFW_KEY_KP_1
- case 0x62:return 322; // DOM_VK_NUMPAD2 -> GLFW_KEY_KP_2
- case 0x63:return 323; // DOM_VK_NUMPAD3 -> GLFW_KEY_KP_3
- case 0x64:return 324; // DOM_VK_NUMPAD4 -> GLFW_KEY_KP_4
- case 0x65:return 325; // DOM_VK_NUMPAD5 -> GLFW_KEY_KP_5
- case 0x66:return 326; // DOM_VK_NUMPAD6 -> GLFW_KEY_KP_6
- case 0x67:return 327; // DOM_VK_NUMPAD7 -> GLFW_KEY_KP_7
- case 0x68:return 328; // DOM_VK_NUMPAD8 -> GLFW_KEY_KP_8
- case 0x69:return 329; // DOM_VK_NUMPAD9 -> GLFW_KEY_KP_9
- case 0x6E:return 330; // DOM_VK_DECIMAL -> GLFW_KEY_KP_DECIMAL
- case 0x6F:return 331; // DOM_VK_DIVIDE -> GLFW_KEY_KP_DIVIDE
- case 0x6A:return 332; // DOM_VK_MULTIPLY -> GLFW_KEY_KP_MULTIPLY
- case 0x6D:return 333; // DOM_VK_SUBTRACT -> GLFW_KEY_KP_SUBTRACT
- case 0x6B:return 334; // DOM_VK_ADD -> GLFW_KEY_KP_ADD
- // case 0x0D:return 335; // DOM_VK_RETURN -> GLFW_KEY_KP_ENTER (DOM_KEY_LOCATION_RIGHT)
- // case 0x61:return 336; // DOM_VK_EQUALS -> GLFW_KEY_KP_EQUAL (DOM_KEY_LOCATION_RIGHT)
- case 0x10:return 340; // DOM_VK_SHIFT -> GLFW_KEY_LEFT_SHIFT
- case 0x11:return 341; // DOM_VK_CONTROL -> GLFW_KEY_LEFT_CONTROL
- case 0x12:return 342; // DOM_VK_ALT -> GLFW_KEY_LEFT_ALT
- case 0x5B:return 343; // DOM_VK_WIN -> GLFW_KEY_LEFT_SUPER
- // case 0x10:return 344; // DOM_VK_SHIFT -> GLFW_KEY_RIGHT_SHIFT (DOM_KEY_LOCATION_RIGHT)
- // case 0x11:return 345; // DOM_VK_CONTROL -> GLFW_KEY_RIGHT_CONTROL (DOM_KEY_LOCATION_RIGHT)
- // case 0x12:return 346; // DOM_VK_ALT -> GLFW_KEY_RIGHT_ALT (DOM_KEY_LOCATION_RIGHT)
- // case 0x5B:return 347; // DOM_VK_WIN -> GLFW_KEY_RIGHT_SUPER (DOM_KEY_LOCATION_RIGHT)
- case 0x5D:return 348; // DOM_VK_CONTEXT_MENU -> GLFW_KEY_MENU
- // XXX: GLFW_KEY_WORLD_1, GLFW_KEY_WORLD_2 what are these?
- default:return -1; // GLFW_KEY_UNKNOWN
- };
- },getModBits:function (win) {
- var mod = 0;
- if (win.keys[340]) mod |= 0x0001; // GLFW_MOD_SHIFT
- if (win.keys[341]) mod |= 0x0002; // GLFW_MOD_CONTROL
- if (win.keys[342]) mod |= 0x0004; // GLFW_MOD_ALT
- if (win.keys[343]) mod |= 0x0008; // GLFW_MOD_SUPER
- return mod;
- },onKeyPress:function (event) {
- if (!GLFW.active || !GLFW.active.charFunc) return;
- if (event.ctrlKey || event.metaKey) return;
-
- // correct unicode charCode is only available with onKeyPress event
- var charCode = event.charCode;
- if (charCode == 0 || (charCode >= 0x00 && charCode <= 0x1F)) return;
-
-
- Module['dynCall_vii'](GLFW.active.charFunc, GLFW.active.id, charCode);
- },onKeyChanged:function (keyCode, status) {
- if (!GLFW.active) return;
-
- var key = GLFW.DOMToGLFWKeyCode(keyCode);
- if (key == -1) return;
-
- var repeat = status && GLFW.active.keys[key];
- GLFW.active.keys[key] = status;
- GLFW.active.domKeys[keyCode] = status;
- if (!GLFW.active.keyFunc) return;
-
-
- if (repeat) status = 2; // GLFW_REPEAT
- Module['dynCall_viiiii'](GLFW.active.keyFunc, GLFW.active.id, key, keyCode, status, GLFW.getModBits(GLFW.active));
- },onGamepadConnected:function (event) {
- GLFW.refreshJoysticks();
- },onGamepadDisconnected:function (event) {
- GLFW.refreshJoysticks();
- },onKeydown:function (event) {
- GLFW.onKeyChanged(event.keyCode, 1); // GLFW_PRESS or GLFW_REPEAT
-
- // This logic comes directly from the sdl implementation. We cannot
- // call preventDefault on all keydown events otherwise onKeyPress will
- // not get called
- if (event.keyCode === 8 /* backspace */ || event.keyCode === 9 /* tab */) {
- event.preventDefault();
- }
- },onKeyup:function (event) {
- GLFW.onKeyChanged(event.keyCode, 0); // GLFW_RELEASE
- },onBlur:function (event) {
- if (!GLFW.active) return;
-
- for (var i = 0; i < GLFW.active.domKeys.length; ++i) {
- if (GLFW.active.domKeys[i]) {
- GLFW.onKeyChanged(i, 0); // GLFW_RELEASE
- }
- }
- },onMousemove:function (event) {
- if (!GLFW.active) return;
-
- Browser.calculateMouseEvent(event);
-
- if (event.target != Module["canvas"] || !GLFW.active.cursorPosFunc) return;
-
-
- Module['dynCall_vidd'](GLFW.active.cursorPosFunc, GLFW.active.id, Browser.mouseX, Browser.mouseY);
- },DOMToGLFWMouseButton:function (event) {
- // DOM and glfw have different button codes.
- // See http://www.w3schools.com/jsref/event_button.asp.
- var eventButton = event['button'];
- if (eventButton > 0) {
- if (eventButton == 1) {
- eventButton = 2;
- } else {
- eventButton = 1;
- }
- }
- return eventButton;
- },onMouseenter:function (event) {
- if (!GLFW.active) return;
-
- if (event.target != Module["canvas"] || !GLFW.active.cursorEnterFunc) return;
-
- Module['dynCall_vii'](GLFW.active.cursorEnterFunc, GLFW.active.id, 1);
- },onMouseleave:function (event) {
- if (!GLFW.active) return;
-
- if (event.target != Module["canvas"] || !GLFW.active.cursorEnterFunc) return;
-
- Module['dynCall_vii'](GLFW.active.cursorEnterFunc, GLFW.active.id, 0);
- },onMouseButtonChanged:function (event, status) {
- if (!GLFW.active) return;
-
- Browser.calculateMouseEvent(event);
-
- if (event.target != Module["canvas"]) return;
-
- eventButton = GLFW.DOMToGLFWMouseButton(event);
-
- if (status == 1) { // GLFW_PRESS
- GLFW.active.buttons |= (1 << eventButton);
- try {
- event.target.setCapture();
- } catch (e) {}
- } else { // GLFW_RELEASE
- GLFW.active.buttons &= ~(1 << eventButton);
- }
-
- if (!GLFW.active.mouseButtonFunc) return;
-
-
- Module['dynCall_viiii'](GLFW.active.mouseButtonFunc, GLFW.active.id, eventButton, status, GLFW.getModBits(GLFW.active));
- },onMouseButtonDown:function (event) {
- if (!GLFW.active) return;
- GLFW.onMouseButtonChanged(event, 1); // GLFW_PRESS
- },onMouseButtonUp:function (event) {
- if (!GLFW.active) return;
- GLFW.onMouseButtonChanged(event, 0); // GLFW_RELEASE
- },onMouseWheel:function (event) {
- // Note the minus sign that flips browser wheel direction (positive direction scrolls page down) to native wheel direction (positive direction is mouse wheel up)
- var delta = -Browser.getMouseWheelDelta(event);
- delta = (delta == 0) ? 0 : (delta > 0 ? Math.max(delta, 1) : Math.min(delta, -1)); // Quantize to integer so that minimum scroll is at least +/- 1.
- GLFW.wheelPos += delta;
-
- if (!GLFW.active || !GLFW.active.scrollFunc || event.target != Module['canvas']) return;
-
-
- var sx = 0;
- var sy = 0;
- if (event.type == 'mousewheel') {
- sx = event.wheelDeltaX;
- sy = event.wheelDeltaY;
- } else {
- sx = event.deltaX;
- sy = event.deltaY;
- }
-
- Module['dynCall_vidd'](GLFW.active.scrollFunc, GLFW.active.id, sx, sy);
-
- event.preventDefault();
- },onCanvasResize:function (width, height) {
- if (!GLFW.active) return;
-
- var resizeNeeded = true;
-
- // If the client is requestiong fullscreen mode
- if (document["fullscreen"] || document["fullScreen"] || document["mozFullScreen"] || document["webkitIsFullScreen"]) {
- GLFW.active.storedX = GLFW.active.x;
- GLFW.active.storedY = GLFW.active.y;
- GLFW.active.storedWidth = GLFW.active.width;
- GLFW.active.storedHeight = GLFW.active.height;
- GLFW.active.x = GLFW.active.y = 0;
- GLFW.active.width = screen.width;
- GLFW.active.height = screen.height;
- GLFW.active.fullscreen = true;
-
- // If the client is reverting from fullscreen mode
- } else if (GLFW.active.fullscreen == true) {
- GLFW.active.x = GLFW.active.storedX;
- GLFW.active.y = GLFW.active.storedY;
- GLFW.active.width = GLFW.active.storedWidth;
- GLFW.active.height = GLFW.active.storedHeight;
- GLFW.active.fullscreen = false;
-
- // If the width/height values do not match current active window sizes
- } else if (GLFW.active.width != width || GLFW.active.height != height) {
- GLFW.active.width = width;
- GLFW.active.height = height;
- } else {
- resizeNeeded = false;
- }
-
- // If any of the above conditions were true, we need to resize the canvas
- if (resizeNeeded) {
- // resets the canvas size to counter the aspect preservation of Browser.updateCanvasDimensions
- Browser.setCanvasSize(GLFW.active.width, GLFW.active.height, true);
- // TODO: Client dimensions (clientWidth/clientHeight) vs pixel dimensions (width/height) of
- // the canvas should drive window and framebuffer size respectfully.
- GLFW.onWindowSizeChanged();
- GLFW.onFramebufferSizeChanged();
- }
- },onWindowSizeChanged:function () {
- if (!GLFW.active) return;
-
- if (!GLFW.active.windowSizeFunc) return;
-
-
- Module['dynCall_viii'](GLFW.active.windowSizeFunc, GLFW.active.id, GLFW.active.width, GLFW.active.height);
- },onFramebufferSizeChanged:function () {
- if (!GLFW.active) return;
-
- if (!GLFW.active.framebufferSizeFunc) return;
-
- Module['dynCall_viii'](GLFW.active.framebufferSizeFunc, GLFW.active.id, GLFW.active.width, GLFW.active.height);
- },requestFullscreen:function () {
- var RFS = Module["canvas"]['requestFullscreen'] ||
- Module["canvas"]['mozRequestFullScreen'] ||
- Module["canvas"]['webkitRequestFullScreen'] ||
- (function() {});
- RFS.apply(Module["canvas"], []);
- },requestFullScreen:function () {
- Module.printErr('GLFW.requestFullScreen() is deprecated. Please call GLFW.requestFullscreen instead.');
- GLFW.requestFullScreen = function() {
- return GLFW.requestFullscreen();
- }
- return GLFW.requestFullscreen();
- },exitFullscreen:function () {
- var CFS = document['exitFullscreen'] ||
- document['cancelFullScreen'] ||
- document['mozCancelFullScreen'] ||
- document['webkitCancelFullScreen'] ||
- (function() {});
- CFS.apply(document, []);
- },cancelFullScreen:function () {
- Module.printErr('GLFW.cancelFullScreen() is deprecated. Please call GLFW.exitFullscreen instead.');
- GLFW.cancelFullScreen = function() {
- return GLFW.exitFullscreen();
- }
- return GLFW.exitFullscreen();
- },getTime:function () {
- return _emscripten_get_now() / 1000;
- },setWindowTitle:function (winid, title) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
-
- win.title = Pointer_stringify(title);
- if (GLFW.active.id == win.id) {
- document.title = win.title;
- }
- },setJoystickCallback:function (cbfun) {
- GLFW.joystickFunc = cbfun;
- GLFW.refreshJoysticks();
- },joys:{},lastGamepadState:null,lastGamepadStateFrame:null,refreshJoysticks:function () {
- // Produce a new Gamepad API sample if we are ticking a new game frame, or if not using emscripten_set_main_loop() at all to drive animation.
- if (Browser.mainLoop.currentFrameNumber !== GLFW.lastGamepadStateFrame || !Browser.mainLoop.currentFrameNumber) {
- GLFW.lastGamepadState = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : null);
- GLFW.lastGamepadStateFrame = Browser.mainLoop.currentFrameNumber;
-
- for (var joy = 0; joy < GLFW.lastGamepadState.length; ++joy) {
- var gamepad = GLFW.lastGamepadState[joy];
-
- if (gamepad) {
- if (!GLFW.joys[joy]) {
- console.log('glfw joystick connected:',joy);
- GLFW.joys[joy] = {
- id: allocate(intArrayFromString(gamepad.id), 'i8', ALLOC_NORMAL),
- buttonsCount: gamepad.buttons.length,
- axesCount: gamepad.axes.length,
- buttons: allocate(new Array(gamepad.buttons.length), 'i8', ALLOC_NORMAL),
- axes: allocate(new Array(gamepad.axes.length*4), 'float', ALLOC_NORMAL)
- };
-
- if (GLFW.joystickFunc) {
- Module['dynCall_vii'](GLFW.joystickFunc, joy, 0x00040001); // GLFW_CONNECTED
- }
- }
-
- var data = GLFW.joys[joy];
-
- for (var i = 0; i < gamepad.buttons.length; ++i) {
- setValue(data.buttons + i, gamepad.buttons[i].pressed, 'i8');
- }
-
- for (var i = 0; i < gamepad.axes.length; ++i) {
- setValue(data.axes + i*4, gamepad.axes[i], 'float');
- }
- } else {
- if (GLFW.joys[joy]) {
- console.log('glfw joystick disconnected',joy);
-
- if (GLFW.joystickFunc) {
- Module['dynCall_vii'](GLFW.joystickFunc, joy, 0x00040002); // GLFW_DISCONNECTED
- }
-
- _free(GLFW.joys[joy].id);
- _free(GLFW.joys[joy].buttons);
- _free(GLFW.joys[joy].axes);
-
- delete GLFW.joys[joy];
- }
- }
- }
- }
- },setKeyCallback:function (winid, cbfun) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
- win.keyFunc = cbfun;
- },setCharCallback:function (winid, cbfun) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
- win.charFunc = cbfun;
- },setMouseButtonCallback:function (winid, cbfun) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
- win.mouseButtonFunc = cbfun;
- },setCursorPosCallback:function (winid, cbfun) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
- win.cursorPosFunc = cbfun;
- },setScrollCallback:function (winid, cbfun) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
- win.scrollFunc = cbfun;
- },setDropCallback:function (winid, cbfun) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
- win.dropFunc = cbfun;
- },onDrop:function (event) {
- if (!GLFW.active || !GLFW.active.dropFunc) return;
- if (!event.dataTransfer || !event.dataTransfer.files || event.dataTransfer.files.length == 0) return;
-
- event.preventDefault();
-
- var filenames = allocate(new Array(event.dataTransfer.files.length*4), 'i8*', ALLOC_NORMAL);
- var filenamesArray = [];
- var count = event.dataTransfer.files.length;
-
- // Read and save the files to emscripten's FS
- var written = 0;
- var drop_dir = '.glfw_dropped_files';
- FS.createPath('/', drop_dir);
-
- function save(file) {
- var path = '/' + drop_dir + '/' + file.name.replace(/\//g, '_');
- var reader = new FileReader();
- reader.onloadend = function(e) {
- if (reader.readyState != 2) { // not DONE
- ++written;
- console.log('failed to read dropped file: '+file.name+': '+reader.error);
- return;
- }
-
- var data = e.target.result;
- FS.writeFile(path, new Uint8Array(data), { encoding: 'binary' });
- if (++written === count) {
- Module['dynCall_viii'](GLFW.active.dropFunc, GLFW.active.id, count, filenames);
-
- for (var i = 0; i < filenamesArray.length; ++i) {
- _free(filenamesArray[i]);
- }
- _free(filenames);
- }
- };
- reader.readAsArrayBuffer(file);
-
- var filename = allocate(intArrayFromString(path), 'i8', ALLOC_NORMAL);
- filenamesArray.push(filename);
- setValue(filenames + i*4, filename, 'i8*');
- }
-
- for (var i = 0; i < count; ++i) {
- save(event.dataTransfer.files[i]);
- }
-
- return false;
- },onDragover:function (event) {
- if (!GLFW.active || !GLFW.active.dropFunc) return;
-
- event.preventDefault();
- return false;
- },setWindowSizeCallback:function (winid, cbfun) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
- win.windowSizeFunc = cbfun;
-
- },setWindowCloseCallback:function (winid, cbfun) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
- win.windowCloseFunc = cbfun;
- },setWindowRefreshCallback:function (winid, cbfun) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
- win.windowRefreshFunc = cbfun;
- },onClickRequestPointerLock:function (e) {
- if (!Browser.pointerLock && Module['canvas'].requestPointerLock) {
- Module['canvas'].requestPointerLock();
- e.preventDefault();
- }
- },setInputMode:function (winid, mode, value) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
-
- switch(mode) {
- case 0x00033001: { // GLFW_CURSOR
- switch(value) {
- case 0x00034001: { // GLFW_CURSOR_NORMAL
- win.inputModes[mode] = value;
- Module['canvas'].removeEventListener('click', GLFW.onClickRequestPointerLock, true);
- Module['canvas'].exitPointerLock();
- break;
- }
- case 0x00034002: { // GLFW_CURSOR_HIDDEN
- console.log("glfwSetInputMode called with GLFW_CURSOR_HIDDEN value not implemented.");
- break;
- }
- case 0x00034003: { // GLFW_CURSOR_DISABLED
- win.inputModes[mode] = value;
- Module['canvas'].addEventListener('click', GLFW.onClickRequestPointerLock, true);
- Module['canvas'].requestPointerLock();
- break;
- }
- default: {
- console.log("glfwSetInputMode called with unknown value parameter value: " + value + ".");
- break;
- }
- }
- break;
- }
- case 0x00033002: { // GLFW_STICKY_KEYS
- console.log("glfwSetInputMode called with GLFW_STICKY_KEYS mode not implemented.");
- break;
- }
- case 0x00033003: { // GLFW_STICKY_MOUSE_BUTTONS
- console.log("glfwSetInputMode called with GLFW_STICKY_MOUSE_BUTTONS mode not implemented.");
- break;
- }
- default: {
- console.log("glfwSetInputMode called with unknown mode parameter value: " + mode + ".");
- break;
- }
- }
- },getKey:function (winid, key) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return 0;
- return win.keys[key];
- },getMouseButton:function (winid, button) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return 0;
- return (win.buttons & (1 << button)) > 0;
- },getCursorPos:function (winid, x, y) {
- setValue(x, Browser.mouseX, 'double');
- setValue(y, Browser.mouseY, 'double');
- },getMousePos:function (winid, x, y) {
- setValue(x, Browser.mouseX, 'i32');
- setValue(y, Browser.mouseY, 'i32');
- },setCursorPos:function (winid, x, y) {
- },getWindowPos:function (winid, x, y) {
- var wx = 0;
- var wy = 0;
-
- var win = GLFW.WindowFromId(winid);
- if (win) {
- wx = win.x;
- wy = win.y;
- }
-
- setValue(x, wx, 'i32');
- setValue(y, wy, 'i32');
- },setWindowPos:function (winid, x, y) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
- win.x = x;
- win.y = y;
- },getWindowSize:function (winid, width, height) {
- var ww = 0;
- var wh = 0;
-
- var win = GLFW.WindowFromId(winid);
- if (win) {
- ww = win.width;
- wh = win.height;
- }
-
- setValue(width, ww, 'i32');
- setValue(height, wh, 'i32');
- },setWindowSize:function (winid, width, height) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
-
- if (GLFW.active.id == win.id) {
- if (width == screen.width && height == screen.height) {
- GLFW.requestFullscreen();
- } else {
- GLFW.exitFullscreen();
- Browser.setCanvasSize(width, height);
- win.width = width;
- win.height = height;
- }
- }
-
- if (!win.windowSizeFunc) return;
-
-
- Module['dynCall_viii'](win.windowSizeFunc, win.id, width, height);
- },createWindow:function (width, height, title, monitor, share) {
- var i, id;
- for (i = 0; i < GLFW.windows.length && GLFW.windows[i] !== null; i++);
- if (i > 0) throw "glfwCreateWindow only supports one window at time currently";
-
- // id for window
- id = i + 1;
-
- // not valid
- if (width <= 0 || height <= 0) return 0;
-
- if (monitor) {
- GLFW.requestFullscreen();
- } else {
- Browser.setCanvasSize(width, height);
- }
-
- // Create context when there are no existing alive windows
- for (i = 0; i < GLFW.windows.length && GLFW.windows[i] == null; i++);
- if (i == GLFW.windows.length) {
- var contextAttributes = {
- antialias: (GLFW.hints[0x0002100D] > 1), // GLFW_SAMPLES
- depth: (GLFW.hints[0x00021005] > 0), // GLFW_DEPTH_BITS
- stencil: (GLFW.hints[0x00021006] > 0), // GLFW_STENCIL_BITS
- alpha: (GLFW.hints[0x00021004] > 0) // GLFW_ALPHA_BITS
- }
- Module.ctx = Browser.createContext(Module['canvas'], true, true, contextAttributes);
- }
-
- // If context creation failed, do not return a valid window
- if (!Module.ctx) return 0;
-
- // Get non alive id
- var win = new GLFW.Window(id, width, height, title, monitor, share);
-
- // Set window to array
- if (id - 1 == GLFW.windows.length) {
- GLFW.windows.push(win);
- } else {
- GLFW.windows[id - 1] = win;
- }
-
- GLFW.active = win;
- return win.id;
- },destroyWindow:function (winid) {
- var win = GLFW.WindowFromId(winid);
- if (!win) return;
-
- if (win.windowCloseFunc)
- func(arg);
-
- GLFW.windows[win.id - 1] = null;
- if (GLFW.active.id == win.id)
- GLFW.active = null;
-
- // Destroy context when no alive windows
- for (var i = 0; i < GLFW.windows.length; i++)
- if (GLFW.windows[i] !== null) return;
-
- Module.ctx = Browser.destroyContext(Module['canvas'], true, true);
- },swapBuffers:function (winid) {
- },GLFW2ParamToGLFW3Param:function (param) {
- table = {
- 0x00030001:0, // GLFW_MOUSE_CURSOR
- 0x00030002:0, // GLFW_STICKY_KEYS
- 0x00030003:0, // GLFW_STICKY_MOUSE_BUTTONS
- 0x00030004:0, // GLFW_SYSTEM_KEYS
- 0x00030005:0, // GLFW_KEY_REPEAT
- 0x00030006:0, // GLFW_AUTO_POLL_EVENTS
- 0x00020001:0, // GLFW_OPENED
- 0x00020002:0, // GLFW_ACTIVE
- 0x00020003:0, // GLFW_ICONIFIED
- 0x00020004:0, // GLFW_ACCELERATED
- 0x00020005:0x00021001, // GLFW_RED_BITS
- 0x00020006:0x00021002, // GLFW_GREEN_BITS
- 0x00020007:0x00021003, // GLFW_BLUE_BITS
- 0x00020008:0x00021004, // GLFW_ALPHA_BITS
- 0x00020009:0x00021005, // GLFW_DEPTH_BITS
- 0x0002000A:0x00021006, // GLFW_STENCIL_BITS
- 0x0002000B:0x0002100F, // GLFW_REFRESH_RATE
- 0x0002000C:0x00021007, // GLFW_ACCUM_RED_BITS
- 0x0002000D:0x00021008, // GLFW_ACCUM_GREEN_BITS
- 0x0002000E:0x00021009, // GLFW_ACCUM_BLUE_BITS
- 0x0002000F:0x0002100A, // GLFW_ACCUM_ALPHA_BITS
- 0x00020010:0x0002100B, // GLFW_AUX_BUFFERS
- 0x00020011:0x0002100C, // GLFW_STEREO
- 0x00020012:0, // GLFW_WINDOW_NO_RESIZE
- 0x00020013:0x0002100D, // GLFW_FSAA_SAMPLES
- 0x00020014:0x00022002, // GLFW_OPENGL_VERSION_MAJOR
- 0x00020015:0x00022003, // GLFW_OPENGL_VERSION_MINOR
- 0x00020016:0x00022006, // GLFW_OPENGL_FORWARD_COMPAT
- 0x00020017:0x00022007, // GLFW_OPENGL_DEBUG_CONTEXT
- 0x00020018:0x00022008, // GLFW_OPENGL_PROFILE
- };
- return table[param];
- }};function _glfwGetVideoModes(monitor, count) {
- setValue(count, 0, 'i32');
- return 0;
- }
-
- function _glLinkProgram(program) {
- GLctx.linkProgram(GL.programs[program]);
- GL.programInfos[program] = null; // uniforms no longer keep the same names after linking
- GL.populateUniformTable(program);
- }
-
- function _glBindTexture(target, texture) {
- GLctx.bindTexture(target, texture ? GL.textures[texture] : null);
- }
-
- function _emscripten_glStencilFunc(x0, x1, x2) { GLctx['stencilFunc'](x0, x1, x2) }
-
- function _glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer) {
- GLctx.framebufferRenderbuffer(target, attachment, renderbuffertarget,
- GL.renderbuffers[renderbuffer]);
- }
-
- function _glGetString(name_) {
- if (GL.stringCache[name_]) return GL.stringCache[name_];
- var ret;
- switch(name_) {
- case 0x1F00 /* GL_VENDOR */:
- case 0x1F01 /* GL_RENDERER */:
- case 0x9245 /* UNMASKED_VENDOR_WEBGL */:
- case 0x9246 /* UNMASKED_RENDERER_WEBGL */:
- ret = allocate(intArrayFromString(GLctx.getParameter(name_)), 'i8', ALLOC_NORMAL);
- break;
- case 0x1F02 /* GL_VERSION */:
- var glVersion = GLctx.getParameter(GLctx.VERSION);
- // return GLES version string corresponding to the version of the WebGL context
- {
- glVersion = 'OpenGL ES 2.0 (' + glVersion + ')';
- }
- ret = allocate(intArrayFromString(glVersion), 'i8', ALLOC_NORMAL);
- break;
- case 0x1F03 /* GL_EXTENSIONS */:
- var exts = GLctx.getSupportedExtensions();
- var gl_exts = [];
- for (var i = 0; i < exts.length; ++i) {
- gl_exts.push(exts[i]);
- gl_exts.push("GL_" + exts[i]);
- }
- ret = allocate(intArrayFromString(gl_exts.join(' ')), 'i8', ALLOC_NORMAL);
- break;
- case 0x8B8C /* GL_SHADING_LANGUAGE_VERSION */:
- var glslVersion = GLctx.getParameter(GLctx.SHADING_LANGUAGE_VERSION);
- // extract the version number 'N.M' from the string 'WebGL GLSL ES N.M ...'
- var ver_re = /^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/;
- var ver_num = glslVersion.match(ver_re);
- if (ver_num !== null) {
- if (ver_num[1].length == 3) ver_num[1] = ver_num[1] + '0'; // ensure minor version has 2 digits
- glslVersion = 'OpenGL ES GLSL ES ' + ver_num[1] + ' (' + glslVersion + ')';
- }
- ret = allocate(intArrayFromString(glslVersion), 'i8', ALLOC_NORMAL);
- break;
- default:
- GL.recordError(0x0500/*GL_INVALID_ENUM*/);
- return 0;
- }
- GL.stringCache[name_] = ret;
- return ret;
- }
-
- function _emscripten_glUniform3iv(location, count, value) {
-
-
- GLctx.uniform3iv(GL.uniforms[location], HEAP32.subarray((value)>>2,(value+count*12)>>2));
- }
-
- function _glDetachShader(program, shader) {
- GLctx.detachShader(GL.programs[program],
- GL.shaders[shader]);
- }
-
- function _pthread_mutex_init() {}
-
- function _emscripten_glReleaseShaderCompiler() {
- // NOP (as allowed by GLES 2.0 spec)
- }
-
- function _glfwSetScrollCallback(winid, cbfun) {
- GLFW.setScrollCallback(winid, cbfun);
- }
-
- function _emscripten_glTexParameterf(x0, x1, x2) { GLctx['texParameterf'](x0, x1, x2) }
-
- function _emscripten_glTexParameteri(x0, x1, x2) { GLctx['texParameteri'](x0, x1, x2) }
-
- function _glCompileShader(shader) {
- GLctx.compileShader(GL.shaders[shader]);
- }
-
-
-
-
- var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
-
- var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
-
- function ___setErrNo(value) {
- if (Module['___errno_location']) HEAP32[((Module['___errno_location']())>>2)]=value;
- else Module.printErr('failed to set errno from JS');
- return value;
- }
-
- var PATH={splitPath:function (filename) {
- var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
- return splitPathRe.exec(filename).slice(1);
- },normalizeArray:function (parts, allowAboveRoot) {
- // if the path tries to go above the root, `up` ends up > 0
- var up = 0;
- for (var i = parts.length - 1; i >= 0; i--) {
- var last = parts[i];
- if (last === '.') {
- parts.splice(i, 1);
- } else if (last === '..') {
- parts.splice(i, 1);
- up++;
- } else if (up) {
- parts.splice(i, 1);
- up--;
- }
- }
- // if the path is allowed to go above the root, restore leading ..s
- if (allowAboveRoot) {
- for (; up; up--) {
- parts.unshift('..');
- }
- }
- return parts;
- },normalize:function (path) {
- var isAbsolute = path.charAt(0) === '/',
- trailingSlash = path.substr(-1) === '/';
- // Normalize the path
- path = PATH.normalizeArray(path.split('/').filter(function(p) {
- return !!p;
- }), !isAbsolute).join('/');
- if (!path && !isAbsolute) {
- path = '.';
- }
- if (path && trailingSlash) {
- path += '/';
- }
- return (isAbsolute ? '/' : '') + path;
- },dirname:function (path) {
- var result = PATH.splitPath(path),
- root = result[0],
- dir = result[1];
- if (!root && !dir) {
- // No dirname whatsoever
- return '.';
- }
- if (dir) {
- // It has a dirname, strip trailing slash
- dir = dir.substr(0, dir.length - 1);
- }
- return root + dir;
- },basename:function (path) {
- // EMSCRIPTEN return '/'' for '/', not an empty string
- if (path === '/') return '/';
- var lastSlash = path.lastIndexOf('/');
- if (lastSlash === -1) return path;
- return path.substr(lastSlash+1);
- },extname:function (path) {
- return PATH.splitPath(path)[3];
- },join:function () {
- var paths = Array.prototype.slice.call(arguments, 0);
- return PATH.normalize(paths.join('/'));
- },join2:function (l, r) {
- return PATH.normalize(l + '/' + r);
- },resolve:function () {
- var resolvedPath = '',
- resolvedAbsolute = false;
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
- var path = (i >= 0) ? arguments[i] : FS.cwd();
- // Skip empty and invalid entries
- if (typeof path !== 'string') {
- throw new TypeError('Arguments to path.resolve must be strings');
- } else if (!path) {
- return ''; // an invalid portion invalidates the whole thing
- }
- resolvedPath = path + '/' + resolvedPath;
- resolvedAbsolute = path.charAt(0) === '/';
- }
- // At this point the path should be resolved to a full absolute path, but
- // handle relative paths to be safe (might happen when process.cwd() fails)
- resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
- return !!p;
- }), !resolvedAbsolute).join('/');
- return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
- },relative:function (from, to) {
- from = PATH.resolve(from).substr(1);
- to = PATH.resolve(to).substr(1);
- function trim(arr) {
- var start = 0;
- for (; start < arr.length; start++) {
- if (arr[start] !== '') break;
- }
- var end = arr.length - 1;
- for (; end >= 0; end--) {
- if (arr[end] !== '') break;
- }
- if (start > end) return [];
- return arr.slice(start, end - start + 1);
- }
- var fromParts = trim(from.split('/'));
- var toParts = trim(to.split('/'));
- var length = Math.min(fromParts.length, toParts.length);
- var samePartsLength = length;
- for (var i = 0; i < length; i++) {
- if (fromParts[i] !== toParts[i]) {
- samePartsLength = i;
- break;
- }
- }
- var outputParts = [];
- for (var i = samePartsLength; i < fromParts.length; i++) {
- outputParts.push('..');
- }
- outputParts = outputParts.concat(toParts.slice(samePartsLength));
- return outputParts.join('/');
- }};
-
- var TTY={ttys:[],init:function () {
- // https://github.com/kripken/emscripten/pull/1555
- // if (ENVIRONMENT_IS_NODE) {
- // // currently, FS.init does not distinguish if process.stdin is a file or TTY
- // // device, it always assumes it's a TTY device. because of this, we're forcing
- // // process.stdin to UTF8 encoding to at least make stdin reading compatible
- // // with text files until FS.init can be refactored.
- // process['stdin']['setEncoding']('utf8');
- // }
- },shutdown:function () {
- // https://github.com/kripken/emscripten/pull/1555
- // if (ENVIRONMENT_IS_NODE) {
- // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
- // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
- // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
- // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
- // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
- // process['stdin']['pause']();
- // }
- },register:function (dev, ops) {
- TTY.ttys[dev] = { input: [], output: [], ops: ops };
- FS.registerDevice(dev, TTY.stream_ops);
- },stream_ops:{open:function (stream) {
- var tty = TTY.ttys[stream.node.rdev];
- if (!tty) {
- throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
- }
- stream.tty = tty;
- stream.seekable = false;
- },close:function (stream) {
- // flush any pending line data
- stream.tty.ops.flush(stream.tty);
- },flush:function (stream) {
- stream.tty.ops.flush(stream.tty);
- },read:function (stream, buffer, offset, length, pos /* ignored */) {
- if (!stream.tty || !stream.tty.ops.get_char) {
- throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
- }
- var bytesRead = 0;
- for (var i = 0; i < length; i++) {
- var result;
- try {
- result = stream.tty.ops.get_char(stream.tty);
- } catch (e) {
- throw new FS.ErrnoError(ERRNO_CODES.EIO);
- }
- if (result === undefined && bytesRead === 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
- }
- if (result === null || result === undefined) break;
- bytesRead++;
- buffer[offset+i] = result;
- }
- if (bytesRead) {
- stream.node.timestamp = Date.now();
- }
- return bytesRead;
- },write:function (stream, buffer, offset, length, pos) {
- if (!stream.tty || !stream.tty.ops.put_char) {
- throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
- }
- for (var i = 0; i < length; i++) {
- try {
- stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
- } catch (e) {
- throw new FS.ErrnoError(ERRNO_CODES.EIO);
- }
- }
- if (length) {
- stream.node.timestamp = Date.now();
- }
- return i;
- }},default_tty_ops:{get_char:function (tty) {
- if (!tty.input.length) {
- var result = null;
- if (ENVIRONMENT_IS_NODE) {
- // we will read data by chunks of BUFSIZE
- var BUFSIZE = 256;
- var buf = new Buffer(BUFSIZE);
- var bytesRead = 0;
-
- var isPosixPlatform = (process.platform != 'win32'); // Node doesn't offer a direct check, so test by exclusion
-
- var fd = process.stdin.fd;
- if (isPosixPlatform) {
- // Linux and Mac cannot use process.stdin.fd (which isn't set up as sync)
- var usingDevice = false;
- try {
- fd = fs.openSync('/dev/stdin', 'r');
- usingDevice = true;
- } catch (e) {}
- }
-
- try {
- bytesRead = fs.readSync(fd, buf, 0, BUFSIZE, null);
- } catch(e) {
- // Cross-platform differences: on Windows, reading EOF throws an exception, but on other OSes,
- // reading EOF returns 0. Uniformize behavior by treating the EOF exception to return 0.
- if (e.toString().indexOf('EOF') != -1) bytesRead = 0;
- else throw e;
- }
-
- if (usingDevice) { fs.closeSync(fd); }
- if (bytesRead > 0) {
- result = buf.slice(0, bytesRead).toString('utf-8');
- } else {
- result = null;
- }
-
- } else if (typeof window != 'undefined' &&
- typeof window.prompt == 'function') {
- // Browser.
- result = window.prompt('Input: '); // returns null on cancel
- if (result !== null) {
- result += '\n';
- }
- } else if (typeof readline == 'function') {
- // Command line.
- result = readline();
- if (result !== null) {
- result += '\n';
- }
- }
- if (!result) {
- return null;
- }
- tty.input = intArrayFromString(result, true);
- }
- return tty.input.shift();
- },put_char:function (tty, val) {
- if (val === null || val === 10) {
- Module['print'](UTF8ArrayToString(tty.output, 0));
- tty.output = [];
- } else {
- if (val != 0) tty.output.push(val); // val == 0 would cut text output off in the middle.
- }
- },flush:function (tty) {
- if (tty.output && tty.output.length > 0) {
- Module['print'](UTF8ArrayToString(tty.output, 0));
- tty.output = [];
- }
- }},default_tty1_ops:{put_char:function (tty, val) {
- if (val === null || val === 10) {
- Module['printErr'](UTF8ArrayToString(tty.output, 0));
- tty.output = [];
- } else {
- if (val != 0) tty.output.push(val);
- }
- },flush:function (tty) {
- if (tty.output && tty.output.length > 0) {
- Module['printErr'](UTF8ArrayToString(tty.output, 0));
- tty.output = [];
- }
- }}};
-
- var MEMFS={ops_table:null,mount:function (mount) {
- return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
- },createNode:function (parent, name, mode, dev) {
- if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
- // no supported
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- }
- if (!MEMFS.ops_table) {
- MEMFS.ops_table = {
- dir: {
- node: {
- getattr: MEMFS.node_ops.getattr,
- setattr: MEMFS.node_ops.setattr,
- lookup: MEMFS.node_ops.lookup,
- mknod: MEMFS.node_ops.mknod,
- rename: MEMFS.node_ops.rename,
- unlink: MEMFS.node_ops.unlink,
- rmdir: MEMFS.node_ops.rmdir,
- readdir: MEMFS.node_ops.readdir,
- symlink: MEMFS.node_ops.symlink
- },
- stream: {
- llseek: MEMFS.stream_ops.llseek
- }
- },
- file: {
- node: {
- getattr: MEMFS.node_ops.getattr,
- setattr: MEMFS.node_ops.setattr
- },
- stream: {
- llseek: MEMFS.stream_ops.llseek,
- read: MEMFS.stream_ops.read,
- write: MEMFS.stream_ops.write,
- allocate: MEMFS.stream_ops.allocate,
- mmap: MEMFS.stream_ops.mmap,
- msync: MEMFS.stream_ops.msync
- }
- },
- link: {
- node: {
- getattr: MEMFS.node_ops.getattr,
- setattr: MEMFS.node_ops.setattr,
- readlink: MEMFS.node_ops.readlink
- },
- stream: {}
- },
- chrdev: {
- node: {
- getattr: MEMFS.node_ops.getattr,
- setattr: MEMFS.node_ops.setattr
- },
- stream: FS.chrdev_stream_ops
- }
- };
- }
- var node = FS.createNode(parent, name, mode, dev);
- if (FS.isDir(node.mode)) {
- node.node_ops = MEMFS.ops_table.dir.node;
- node.stream_ops = MEMFS.ops_table.dir.stream;
- node.contents = {};
- } else if (FS.isFile(node.mode)) {
- node.node_ops = MEMFS.ops_table.file.node;
- node.stream_ops = MEMFS.ops_table.file.stream;
- node.usedBytes = 0; // The actual number of bytes used in the typed array, as opposed to contents.length which gives the whole capacity.
- // When the byte data of the file is populated, this will point to either a typed array, or a normal JS array. Typed arrays are preferred
- // for performance, and used by default. However, typed arrays are not resizable like normal JS arrays are, so there is a small disk size
- // penalty involved for appending file writes that continuously grow a file similar to std::vector capacity vs used -scheme.
- node.contents = null;
- } else if (FS.isLink(node.mode)) {
- node.node_ops = MEMFS.ops_table.link.node;
- node.stream_ops = MEMFS.ops_table.link.stream;
- } else if (FS.isChrdev(node.mode)) {
- node.node_ops = MEMFS.ops_table.chrdev.node;
- node.stream_ops = MEMFS.ops_table.chrdev.stream;
- }
- node.timestamp = Date.now();
- // add the new node to the parent
- if (parent) {
- parent.contents[name] = node;
- }
- return node;
- },getFileDataAsRegularArray:function (node) {
- if (node.contents && node.contents.subarray) {
- var arr = [];
- for (var i = 0; i < node.usedBytes; ++i) arr.push(node.contents[i]);
- return arr; // Returns a copy of the original data.
- }
- return node.contents; // No-op, the file contents are already in a JS array. Return as-is.
- },getFileDataAsTypedArray:function (node) {
- if (!node.contents) return new Uint8Array;
- if (node.contents.subarray) return node.contents.subarray(0, node.usedBytes); // Make sure to not return excess unused bytes.
- return new Uint8Array(node.contents);
- },expandFileStorage:function (node, newCapacity) {
- // If we are asked to expand the size of a file that already exists, revert to using a standard JS array to store the file
- // instead of a typed array. This makes resizing the array more flexible because we can just .push() elements at the back to
- // increase the size.
- if (node.contents && node.contents.subarray && newCapacity > node.contents.length) {
- node.contents = MEMFS.getFileDataAsRegularArray(node);
- node.usedBytes = node.contents.length; // We might be writing to a lazy-loaded file which had overridden this property, so force-reset it.
- }
-
- if (!node.contents || node.contents.subarray) { // Keep using a typed array if creating a new storage, or if old one was a typed array as well.
- var prevCapacity = node.contents ? node.contents.length : 0;
- if (prevCapacity >= newCapacity) return; // No need to expand, the storage was already large enough.
- // Don't expand strictly to the given requested limit if it's only a very small increase, but instead geometrically grow capacity.
- // For small filesizes (<1MB), perform size*2 geometric increase, but for large sizes, do a much more conservative size*1.125 increase to
- // avoid overshooting the allocation cap by a very large margin.
- var CAPACITY_DOUBLING_MAX = 1024 * 1024;
- newCapacity = Math.max(newCapacity, (prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2.0 : 1.125)) | 0);
- if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256); // At minimum allocate 256b for each file when expanding.
- var oldContents = node.contents;
- node.contents = new Uint8Array(newCapacity); // Allocate new storage.
- if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0); // Copy old data over to the new storage.
- return;
- }
- // Not using a typed array to back the file storage. Use a standard JS array instead.
- if (!node.contents && newCapacity > 0) node.contents = [];
- while (node.contents.length < newCapacity) node.contents.push(0);
- },resizeFileStorage:function (node, newSize) {
- if (node.usedBytes == newSize) return;
- if (newSize == 0) {
- node.contents = null; // Fully decommit when requesting a resize to zero.
- node.usedBytes = 0;
- return;
- }
- if (!node.contents || node.contents.subarray) { // Resize a typed array if that is being used as the backing store.
- var oldContents = node.contents;
- node.contents = new Uint8Array(new ArrayBuffer(newSize)); // Allocate new storage.
- if (oldContents) {
- node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes))); // Copy old data over to the new storage.
- }
- node.usedBytes = newSize;
- return;
- }
- // Backing with a JS array.
- if (!node.contents) node.contents = [];
- if (node.contents.length > newSize) node.contents.length = newSize;
- else while (node.contents.length < newSize) node.contents.push(0);
- node.usedBytes = newSize;
- },node_ops:{getattr:function (node) {
- var attr = {};
- // device numbers reuse inode numbers.
- attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
- attr.ino = node.id;
- attr.mode = node.mode;
- attr.nlink = 1;
- attr.uid = 0;
- attr.gid = 0;
- attr.rdev = node.rdev;
- if (FS.isDir(node.mode)) {
- attr.size = 4096;
- } else if (FS.isFile(node.mode)) {
- attr.size = node.usedBytes;
- } else if (FS.isLink(node.mode)) {
- attr.size = node.link.length;
- } else {
- attr.size = 0;
- }
- attr.atime = new Date(node.timestamp);
- attr.mtime = new Date(node.timestamp);
- attr.ctime = new Date(node.timestamp);
- // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
- // but this is not required by the standard.
- attr.blksize = 4096;
- attr.blocks = Math.ceil(attr.size / attr.blksize);
- return attr;
- },setattr:function (node, attr) {
- if (attr.mode !== undefined) {
- node.mode = attr.mode;
- }
- if (attr.timestamp !== undefined) {
- node.timestamp = attr.timestamp;
- }
- if (attr.size !== undefined) {
- MEMFS.resizeFileStorage(node, attr.size);
- }
- },lookup:function (parent, name) {
- throw FS.genericErrors[ERRNO_CODES.ENOENT];
- },mknod:function (parent, name, mode, dev) {
- return MEMFS.createNode(parent, name, mode, dev);
- },rename:function (old_node, new_dir, new_name) {
- // if we're overwriting a directory at new_name, make sure it's empty.
- if (FS.isDir(old_node.mode)) {
- var new_node;
- try {
- new_node = FS.lookupNode(new_dir, new_name);
- } catch (e) {
- }
- if (new_node) {
- for (var i in new_node.contents) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
- }
- }
- }
- // do the internal rewiring
- delete old_node.parent.contents[old_node.name];
- old_node.name = new_name;
- new_dir.contents[new_name] = old_node;
- old_node.parent = new_dir;
- },unlink:function (parent, name) {
- delete parent.contents[name];
- },rmdir:function (parent, name) {
- var node = FS.lookupNode(parent, name);
- for (var i in node.contents) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
- }
- delete parent.contents[name];
- },readdir:function (node) {
- var entries = ['.', '..']
- for (var key in node.contents) {
- if (!node.contents.hasOwnProperty(key)) {
- continue;
- }
- entries.push(key);
- }
- return entries;
- },symlink:function (parent, newname, oldpath) {
- var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
- node.link = oldpath;
- return node;
- },readlink:function (node) {
- if (!FS.isLink(node.mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- return node.link;
- }},stream_ops:{read:function (stream, buffer, offset, length, position) {
- var contents = stream.node.contents;
- if (position >= stream.node.usedBytes) return 0;
- var size = Math.min(stream.node.usedBytes - position, length);
- assert(size >= 0);
- if (size > 8 && contents.subarray) { // non-trivial, and typed array
- buffer.set(contents.subarray(position, position + size), offset);
- } else {
- for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
- }
- return size;
- },write:function (stream, buffer, offset, length, position, canOwn) {
- if (!length) return 0;
- var node = stream.node;
- node.timestamp = Date.now();
-
- if (buffer.subarray && (!node.contents || node.contents.subarray)) { // This write is from a typed array to a typed array?
- if (canOwn) {
- assert(position === 0, 'canOwn must imply no weird position inside the file');
- node.contents = buffer.subarray(offset, offset + length);
- node.usedBytes = length;
- return length;
- } else if (node.usedBytes === 0 && position === 0) { // If this is a simple first write to an empty file, do a fast set since we don't need to care about old data.
- node.contents = new Uint8Array(buffer.subarray(offset, offset + length));
- node.usedBytes = length;
- return length;
- } else if (position + length <= node.usedBytes) { // Writing to an already allocated and used subrange of the file?
- node.contents.set(buffer.subarray(offset, offset + length), position);
- return length;
- }
- }
-
- // Appending to an existing file and we need to reallocate, or source data did not come as a typed array.
- MEMFS.expandFileStorage(node, position+length);
- if (node.contents.subarray && buffer.subarray) node.contents.set(buffer.subarray(offset, offset + length), position); // Use typed array write if available.
- else {
- for (var i = 0; i < length; i++) {
- node.contents[position + i] = buffer[offset + i]; // Or fall back to manual write if not.
- }
- }
- node.usedBytes = Math.max(node.usedBytes, position+length);
- return length;
- },llseek:function (stream, offset, whence) {
- var position = offset;
- if (whence === 1) { // SEEK_CUR.
- position += stream.position;
- } else if (whence === 2) { // SEEK_END.
- if (FS.isFile(stream.node.mode)) {
- position += stream.node.usedBytes;
- }
- }
- if (position < 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- return position;
- },allocate:function (stream, offset, length) {
- MEMFS.expandFileStorage(stream.node, offset + length);
- stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length);
- },mmap:function (stream, buffer, offset, length, position, prot, flags) {
- if (!FS.isFile(stream.node.mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
- }
- var ptr;
- var allocated;
- var contents = stream.node.contents;
- // Only make a new copy when MAP_PRIVATE is specified.
- if ( !(flags & 2) &&
- (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
- // We can't emulate MAP_SHARED when the file is not backed by the buffer
- // we're mapping to (e.g. the HEAP buffer).
- allocated = false;
- ptr = contents.byteOffset;
- } else {
- // Try to avoid unnecessary slices.
- if (position > 0 || position + length < stream.node.usedBytes) {
- if (contents.subarray) {
- contents = contents.subarray(position, position + length);
- } else {
- contents = Array.prototype.slice.call(contents, position, position + length);
- }
- }
- allocated = true;
- ptr = _malloc(length);
- if (!ptr) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
- }
- buffer.set(contents, ptr);
- }
- return { ptr: ptr, allocated: allocated };
- },msync:function (stream, buffer, offset, length, mmapFlags) {
- if (!FS.isFile(stream.node.mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
- }
- if (mmapFlags & 2) {
- // MAP_PRIVATE calls need not to be synced back to underlying fs
- return 0;
- }
-
- var bytesWritten = MEMFS.stream_ops.write(stream, buffer, 0, length, offset, false);
- // should we check if bytesWritten and length are the same?
- return 0;
- }}};
-
- var IDBFS={dbs:{},indexedDB:function () {
- if (typeof indexedDB !== 'undefined') return indexedDB;
- var ret = null;
- if (typeof window === 'object') ret = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
- assert(ret, 'IDBFS used, but indexedDB not supported');
- return ret;
- },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
- // reuse all of the core MEMFS functionality
- return MEMFS.mount.apply(null, arguments);
- },syncfs:function (mount, populate, callback) {
- IDBFS.getLocalSet(mount, function(err, local) {
- if (err) return callback(err);
-
- IDBFS.getRemoteSet(mount, function(err, remote) {
- if (err) return callback(err);
-
- var src = populate ? remote : local;
- var dst = populate ? local : remote;
-
- IDBFS.reconcile(src, dst, callback);
- });
- });
- },getDB:function (name, callback) {
- // check the cache first
- var db = IDBFS.dbs[name];
- if (db) {
- return callback(null, db);
- }
-
- var req;
- try {
- req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
- } catch (e) {
- return callback(e);
- }
- if (!req) {
- return callback("Unable to connect to IndexedDB");
- }
- req.onupgradeneeded = function(e) {
- var db = e.target.result;
- var transaction = e.target.transaction;
-
- var fileStore;
-
- if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
- fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
- } else {
- fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
- }
-
- if (!fileStore.indexNames.contains('timestamp')) {
- fileStore.createIndex('timestamp', 'timestamp', { unique: false });
- }
- };
- req.onsuccess = function() {
- db = req.result;
-
- // add to the cache
- IDBFS.dbs[name] = db;
- callback(null, db);
- };
- req.onerror = function(e) {
- callback(this.error);
- e.preventDefault();
- };
- },getLocalSet:function (mount, callback) {
- var entries = {};
-
- function isRealDir(p) {
- return p !== '.' && p !== '..';
- };
- function toAbsolute(root) {
- return function(p) {
- return PATH.join2(root, p);
- }
- };
-
- var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
-
- while (check.length) {
- var path = check.pop();
- var stat;
-
- try {
- stat = FS.stat(path);
- } catch (e) {
- return callback(e);
- }
-
- if (FS.isDir(stat.mode)) {
- check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
- }
-
- entries[path] = { timestamp: stat.mtime };
- }
-
- return callback(null, { type: 'local', entries: entries });
- },getRemoteSet:function (mount, callback) {
- var entries = {};
-
- IDBFS.getDB(mount.mountpoint, function(err, db) {
- if (err) return callback(err);
-
- var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
- transaction.onerror = function(e) {
- callback(this.error);
- e.preventDefault();
- };
-
- var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
- var index = store.index('timestamp');
-
- index.openKeyCursor().onsuccess = function(event) {
- var cursor = event.target.result;
-
- if (!cursor) {
- return callback(null, { type: 'remote', db: db, entries: entries });
- }
-
- entries[cursor.primaryKey] = { timestamp: cursor.key };
-
- cursor.continue();
- };
- });
- },loadLocalEntry:function (path, callback) {
- var stat, node;
-
- try {
- var lookup = FS.lookupPath(path);
- node = lookup.node;
- stat = FS.stat(path);
- } catch (e) {
- return callback(e);
- }
-
- if (FS.isDir(stat.mode)) {
- return callback(null, { timestamp: stat.mtime, mode: stat.mode });
- } else if (FS.isFile(stat.mode)) {
- // Performance consideration: storing a normal JavaScript array to a IndexedDB is much slower than storing a typed array.
- // Therefore always convert the file contents to a typed array first before writing the data to IndexedDB.
- node.contents = MEMFS.getFileDataAsTypedArray(node);
- return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
- } else {
- return callback(new Error('node type not supported'));
- }
- },storeLocalEntry:function (path, entry, callback) {
- try {
- if (FS.isDir(entry.mode)) {
- FS.mkdir(path, entry.mode);
- } else if (FS.isFile(entry.mode)) {
- FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
- } else {
- return callback(new Error('node type not supported'));
- }
-
- FS.chmod(path, entry.mode);
- FS.utime(path, entry.timestamp, entry.timestamp);
- } catch (e) {
- return callback(e);
- }
-
- callback(null);
- },removeLocalEntry:function (path, callback) {
- try {
- var lookup = FS.lookupPath(path);
- var stat = FS.stat(path);
-
- if (FS.isDir(stat.mode)) {
- FS.rmdir(path);
- } else if (FS.isFile(stat.mode)) {
- FS.unlink(path);
- }
- } catch (e) {
- return callback(e);
- }
-
- callback(null);
- },loadRemoteEntry:function (store, path, callback) {
- var req = store.get(path);
- req.onsuccess = function(event) { callback(null, event.target.result); };
- req.onerror = function(e) {
- callback(this.error);
- e.preventDefault();
- };
- },storeRemoteEntry:function (store, path, entry, callback) {
- var req = store.put(entry, path);
- req.onsuccess = function() { callback(null); };
- req.onerror = function(e) {
- callback(this.error);
- e.preventDefault();
- };
- },removeRemoteEntry:function (store, path, callback) {
- var req = store.delete(path);
- req.onsuccess = function() { callback(null); };
- req.onerror = function(e) {
- callback(this.error);
- e.preventDefault();
- };
- },reconcile:function (src, dst, callback) {
- var total = 0;
-
- var create = [];
- Object.keys(src.entries).forEach(function (key) {
- var e = src.entries[key];
- var e2 = dst.entries[key];
- if (!e2 || e.timestamp > e2.timestamp) {
- create.push(key);
- total++;
- }
- });
-
- var remove = [];
- Object.keys(dst.entries).forEach(function (key) {
- var e = dst.entries[key];
- var e2 = src.entries[key];
- if (!e2) {
- remove.push(key);
- total++;
- }
- });
-
- if (!total) {
- return callback(null);
- }
-
- var errored = false;
- var completed = 0;
- var db = src.type === 'remote' ? src.db : dst.db;
- var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
- var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
-
- function done(err) {
- if (err) {
- if (!done.errored) {
- done.errored = true;
- return callback(err);
- }
- return;
- }
- if (++completed >= total) {
- return callback(null);
- }
- };
-
- transaction.onerror = function(e) {
- done(this.error);
- e.preventDefault();
- };
-
- // sort paths in ascending order so directory entries are created
- // before the files inside them
- create.sort().forEach(function (path) {
- if (dst.type === 'local') {
- IDBFS.loadRemoteEntry(store, path, function (err, entry) {
- if (err) return done(err);
- IDBFS.storeLocalEntry(path, entry, done);
- });
- } else {
- IDBFS.loadLocalEntry(path, function (err, entry) {
- if (err) return done(err);
- IDBFS.storeRemoteEntry(store, path, entry, done);
- });
- }
- });
-
- // sort paths in descending order so files are deleted before their
- // parent directories
- remove.sort().reverse().forEach(function(path) {
- if (dst.type === 'local') {
- IDBFS.removeLocalEntry(path, done);
- } else {
- IDBFS.removeRemoteEntry(store, path, done);
- }
- });
- }};
-
- var NODEFS={isWindows:false,staticInit:function () {
- NODEFS.isWindows = !!process.platform.match(/^win/);
- },mount:function (mount) {
- assert(ENVIRONMENT_IS_NODE);
- return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
- },createNode:function (parent, name, mode, dev) {
- if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- var node = FS.createNode(parent, name, mode);
- node.node_ops = NODEFS.node_ops;
- node.stream_ops = NODEFS.stream_ops;
- return node;
- },getMode:function (path) {
- var stat;
- try {
- stat = fs.lstatSync(path);
- if (NODEFS.isWindows) {
- // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so
- // propagate write bits to execute bits.
- stat.mode = stat.mode | ((stat.mode & 146) >> 1);
- }
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- return stat.mode;
- },realPath:function (node) {
- var parts = [];
- while (node.parent !== node) {
- parts.push(node.name);
- node = node.parent;
- }
- parts.push(node.mount.opts.root);
- parts.reverse();
- return PATH.join.apply(null, parts);
- },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
- flags &= ~0x200000 /*O_PATH*/; // Ignore this flag from musl, otherwise node.js fails to open the file.
- flags &= ~0x800 /*O_NONBLOCK*/; // Ignore this flag from musl, otherwise node.js fails to open the file.
- flags &= ~0x8000 /*O_LARGEFILE*/; // Ignore this flag from musl, otherwise node.js fails to open the file.
- flags &= ~0x80000 /*O_CLOEXEC*/; // Some applications may pass it; it makes no sense for a single process.
- if (flags in NODEFS.flagsToPermissionStringMap) {
- return NODEFS.flagsToPermissionStringMap[flags];
- } else {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- },node_ops:{getattr:function (node) {
- var path = NODEFS.realPath(node);
- var stat;
- try {
- stat = fs.lstatSync(path);
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
- // See http://support.microsoft.com/kb/140365
- if (NODEFS.isWindows && !stat.blksize) {
- stat.blksize = 4096;
- }
- if (NODEFS.isWindows && !stat.blocks) {
- stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
- }
- return {
- dev: stat.dev,
- ino: stat.ino,
- mode: stat.mode,
- nlink: stat.nlink,
- uid: stat.uid,
- gid: stat.gid,
- rdev: stat.rdev,
- size: stat.size,
- atime: stat.atime,
- mtime: stat.mtime,
- ctime: stat.ctime,
- blksize: stat.blksize,
- blocks: stat.blocks
- };
- },setattr:function (node, attr) {
- var path = NODEFS.realPath(node);
- try {
- if (attr.mode !== undefined) {
- fs.chmodSync(path, attr.mode);
- // update the common node structure mode as well
- node.mode = attr.mode;
- }
- if (attr.timestamp !== undefined) {
- var date = new Date(attr.timestamp);
- fs.utimesSync(path, date, date);
- }
- if (attr.size !== undefined) {
- fs.truncateSync(path, attr.size);
- }
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- },lookup:function (parent, name) {
- var path = PATH.join2(NODEFS.realPath(parent), name);
- var mode = NODEFS.getMode(path);
- return NODEFS.createNode(parent, name, mode);
- },mknod:function (parent, name, mode, dev) {
- var node = NODEFS.createNode(parent, name, mode, dev);
- // create the backing node for this in the fs root as well
- var path = NODEFS.realPath(node);
- try {
- if (FS.isDir(node.mode)) {
- fs.mkdirSync(path, node.mode);
- } else {
- fs.writeFileSync(path, '', { mode: node.mode });
- }
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- return node;
- },rename:function (oldNode, newDir, newName) {
- var oldPath = NODEFS.realPath(oldNode);
- var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
- try {
- fs.renameSync(oldPath, newPath);
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- },unlink:function (parent, name) {
- var path = PATH.join2(NODEFS.realPath(parent), name);
- try {
- fs.unlinkSync(path);
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- },rmdir:function (parent, name) {
- var path = PATH.join2(NODEFS.realPath(parent), name);
- try {
- fs.rmdirSync(path);
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- },readdir:function (node) {
- var path = NODEFS.realPath(node);
- try {
- return fs.readdirSync(path);
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- },symlink:function (parent, newName, oldPath) {
- var newPath = PATH.join2(NODEFS.realPath(parent), newName);
- try {
- fs.symlinkSync(oldPath, newPath);
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- },readlink:function (node) {
- var path = NODEFS.realPath(node);
- try {
- path = fs.readlinkSync(path);
- path = NODEJS_PATH.relative(NODEJS_PATH.resolve(node.mount.opts.root), path);
- return path;
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- }},stream_ops:{open:function (stream) {
- var path = NODEFS.realPath(stream.node);
- try {
- if (FS.isFile(stream.node.mode)) {
- stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
- }
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- },close:function (stream) {
- try {
- if (FS.isFile(stream.node.mode) && stream.nfd) {
- fs.closeSync(stream.nfd);
- }
- } catch (e) {
- if (!e.code) throw e;
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- },read:function (stream, buffer, offset, length, position) {
- if (length === 0) return 0; // node errors on 0 length reads
- // FIXME this is terrible.
- var nbuffer = new Buffer(length);
- var res;
- try {
- res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
- } catch (e) {
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- if (res > 0) {
- for (var i = 0; i < res; i++) {
- buffer[offset + i] = nbuffer[i];
- }
- }
- return res;
- },write:function (stream, buffer, offset, length, position) {
- // FIXME this is terrible.
- var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
- var res;
- try {
- res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
- } catch (e) {
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- return res;
- },llseek:function (stream, offset, whence) {
- var position = offset;
- if (whence === 1) { // SEEK_CUR.
- position += stream.position;
- } else if (whence === 2) { // SEEK_END.
- if (FS.isFile(stream.node.mode)) {
- try {
- var stat = fs.fstatSync(stream.nfd);
- position += stat.size;
- } catch (e) {
- throw new FS.ErrnoError(ERRNO_CODES[e.code]);
- }
- }
- }
-
- if (position < 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
-
- return position;
- }}};
-
- var WORKERFS={DIR_MODE:16895,FILE_MODE:33279,reader:null,mount:function (mount) {
- assert(ENVIRONMENT_IS_WORKER);
- if (!WORKERFS.reader) WORKERFS.reader = new FileReaderSync();
- var root = WORKERFS.createNode(null, '/', WORKERFS.DIR_MODE, 0);
- var createdParents = {};
- function ensureParent(path) {
- // return the parent node, creating subdirs as necessary
- var parts = path.split('/');
- var parent = root;
- for (var i = 0; i < parts.length-1; i++) {
- var curr = parts.slice(0, i+1).join('/');
- // Issue 4254: Using curr as a node name will prevent the node
- // from being found in FS.nameTable when FS.open is called on
- // a path which holds a child of this node,
- // given that all FS functions assume node names
- // are just their corresponding parts within their given path,
- // rather than incremental aggregates which include their parent's
- // directories.
- if (!createdParents[curr]) {
- createdParents[curr] = WORKERFS.createNode(parent, parts[i], WORKERFS.DIR_MODE, 0);
- }
- parent = createdParents[curr];
- }
- return parent;
- }
- function base(path) {
- var parts = path.split('/');
- return parts[parts.length-1];
- }
- // We also accept FileList here, by using Array.prototype
- Array.prototype.forEach.call(mount.opts["files"] || [], function(file) {
- WORKERFS.createNode(ensureParent(file.name), base(file.name), WORKERFS.FILE_MODE, 0, file, file.lastModifiedDate);
- });
- (mount.opts["blobs"] || []).forEach(function(obj) {
- WORKERFS.createNode(ensureParent(obj["name"]), base(obj["name"]), WORKERFS.FILE_MODE, 0, obj["data"]);
- });
- (mount.opts["packages"] || []).forEach(function(pack) {
- pack['metadata'].files.forEach(function(file) {
- var name = file.filename.substr(1); // remove initial slash
- WORKERFS.createNode(ensureParent(name), base(name), WORKERFS.FILE_MODE, 0, pack['blob'].slice(file.start, file.end));
- });
- });
- return root;
- },createNode:function (parent, name, mode, dev, contents, mtime) {
- var node = FS.createNode(parent, name, mode);
- node.mode = mode;
- node.node_ops = WORKERFS.node_ops;
- node.stream_ops = WORKERFS.stream_ops;
- node.timestamp = (mtime || new Date).getTime();
- assert(WORKERFS.FILE_MODE !== WORKERFS.DIR_MODE);
- if (mode === WORKERFS.FILE_MODE) {
- node.size = contents.size;
- node.contents = contents;
- } else {
- node.size = 4096;
- node.contents = {};
- }
- if (parent) {
- parent.contents[name] = node;
- }
- return node;
- },node_ops:{getattr:function (node) {
- return {
- dev: 1,
- ino: undefined,
- mode: node.mode,
- nlink: 1,
- uid: 0,
- gid: 0,
- rdev: undefined,
- size: node.size,
- atime: new Date(node.timestamp),
- mtime: new Date(node.timestamp),
- ctime: new Date(node.timestamp),
- blksize: 4096,
- blocks: Math.ceil(node.size / 4096),
- };
- },setattr:function (node, attr) {
- if (attr.mode !== undefined) {
- node.mode = attr.mode;
- }
- if (attr.timestamp !== undefined) {
- node.timestamp = attr.timestamp;
- }
- },lookup:function (parent, name) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
- },mknod:function (parent, name, mode, dev) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- },rename:function (oldNode, newDir, newName) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- },unlink:function (parent, name) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- },rmdir:function (parent, name) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- },readdir:function (node) {
- var entries = ['.', '..'];
- for (var key in node.contents) {
- if (!node.contents.hasOwnProperty(key)) {
- continue;
- }
- entries.push(key);
- }
- return entries;
- },symlink:function (parent, newName, oldPath) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- },readlink:function (node) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- }},stream_ops:{read:function (stream, buffer, offset, length, position) {
- if (position >= stream.node.size) return 0;
- var chunk = stream.node.contents.slice(position, position + length);
- var ab = WORKERFS.reader.readAsArrayBuffer(chunk);
- buffer.set(new Uint8Array(ab), offset);
- return chunk.size;
- },write:function (stream, buffer, offset, length, position) {
- throw new FS.ErrnoError(ERRNO_CODES.EIO);
- },llseek:function (stream, offset, whence) {
- var position = offset;
- if (whence === 1) { // SEEK_CUR.
- position += stream.position;
- } else if (whence === 2) { // SEEK_END.
- if (FS.isFile(stream.node.mode)) {
- position += stream.node.size;
- }
- }
- if (position < 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- return position;
- }}};
-
- var _stdin=STATICTOP; STATICTOP += 16;;
-
- var _stdout=STATICTOP; STATICTOP += 16;;
-
- var _stderr=STATICTOP; STATICTOP += 16;;var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,handleFSError:function (e) {
- if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
- return ___setErrNo(e.errno);
- },lookupPath:function (path, opts) {
- path = PATH.resolve(FS.cwd(), path);
- opts = opts || {};
-
- if (!path) return { path: '', node: null };
-
- var defaults = {
- follow_mount: true,
- recurse_count: 0
- };
- for (var key in defaults) {
- if (opts[key] === undefined) {
- opts[key] = defaults[key];
- }
- }
-
- if (opts.recurse_count > 8) { // max recursive lookup of 8
- throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
- }
-
- // split the path
- var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
- return !!p;
- }), false);
-
- // start at the root
- var current = FS.root;
- var current_path = '/';
-
- for (var i = 0; i < parts.length; i++) {
- var islast = (i === parts.length-1);
- if (islast && opts.parent) {
- // stop resolving
- break;
- }
-
- current = FS.lookupNode(current, parts[i]);
- current_path = PATH.join2(current_path, parts[i]);
-
- // jump to the mount's root node if this is a mountpoint
- if (FS.isMountpoint(current)) {
- if (!islast || (islast && opts.follow_mount)) {
- current = current.mounted.root;
- }
- }
-
- // by default, lookupPath will not follow a symlink if it is the final path component.
- // setting opts.follow = true will override this behavior.
- if (!islast || opts.follow) {
- var count = 0;
- while (FS.isLink(current.mode)) {
- var link = FS.readlink(current_path);
- current_path = PATH.resolve(PATH.dirname(current_path), link);
-
- var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
- current = lookup.node;
-
- if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
- throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
- }
- }
- }
- }
-
- return { path: current_path, node: current };
- },getPath:function (node) {
- var path;
- while (true) {
- if (FS.isRoot(node)) {
- var mount = node.mount.mountpoint;
- if (!path) return mount;
- return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
- }
- path = path ? node.name + '/' + path : node.name;
- node = node.parent;
- }
- },hashName:function (parentid, name) {
- var hash = 0;
-
-
- for (var i = 0; i < name.length; i++) {
- hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
- }
- return ((parentid + hash) >>> 0) % FS.nameTable.length;
- },hashAddNode:function (node) {
- var hash = FS.hashName(node.parent.id, node.name);
- node.name_next = FS.nameTable[hash];
- FS.nameTable[hash] = node;
- },hashRemoveNode:function (node) {
- var hash = FS.hashName(node.parent.id, node.name);
- if (FS.nameTable[hash] === node) {
- FS.nameTable[hash] = node.name_next;
- } else {
- var current = FS.nameTable[hash];
- while (current) {
- if (current.name_next === node) {
- current.name_next = node.name_next;
- break;
- }
- current = current.name_next;
- }
- }
- },lookupNode:function (parent, name) {
- var err = FS.mayLookup(parent);
- if (err) {
- throw new FS.ErrnoError(err, parent);
- }
- var hash = FS.hashName(parent.id, name);
- for (var node = FS.nameTable[hash]; node; node = node.name_next) {
- var nodeName = node.name;
- if (node.parent.id === parent.id && nodeName === name) {
- return node;
- }
- }
- // if we failed to find it in the cache, call into the VFS
- return FS.lookup(parent, name);
- },createNode:function (parent, name, mode, rdev) {
- if (!FS.FSNode) {
- FS.FSNode = function(parent, name, mode, rdev) {
- if (!parent) {
- parent = this; // root node sets parent to itself
- }
- this.parent = parent;
- this.mount = parent.mount;
- this.mounted = null;
- this.id = FS.nextInode++;
- this.name = name;
- this.mode = mode;
- this.node_ops = {};
- this.stream_ops = {};
- this.rdev = rdev;
- };
-
- FS.FSNode.prototype = {};
-
- // compatibility
- var readMode = 292 | 73;
- var writeMode = 146;
-
- // NOTE we must use Object.defineProperties instead of individual calls to
- // Object.defineProperty in order to make closure compiler happy
- Object.defineProperties(FS.FSNode.prototype, {
- read: {
- get: function() { return (this.mode & readMode) === readMode; },
- set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
- },
- write: {
- get: function() { return (this.mode & writeMode) === writeMode; },
- set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
- },
- isFolder: {
- get: function() { return FS.isDir(this.mode); }
- },
- isDevice: {
- get: function() { return FS.isChrdev(this.mode); }
- }
- });
- }
-
- var node = new FS.FSNode(parent, name, mode, rdev);
-
- FS.hashAddNode(node);
-
- return node;
- },destroyNode:function (node) {
- FS.hashRemoveNode(node);
- },isRoot:function (node) {
- return node === node.parent;
- },isMountpoint:function (node) {
- return !!node.mounted;
- },isFile:function (mode) {
- return (mode & 61440) === 32768;
- },isDir:function (mode) {
- return (mode & 61440) === 16384;
- },isLink:function (mode) {
- return (mode & 61440) === 40960;
- },isChrdev:function (mode) {
- return (mode & 61440) === 8192;
- },isBlkdev:function (mode) {
- return (mode & 61440) === 24576;
- },isFIFO:function (mode) {
- return (mode & 61440) === 4096;
- },isSocket:function (mode) {
- return (mode & 49152) === 49152;
- },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
- var flags = FS.flagModes[str];
- if (typeof flags === 'undefined') {
- throw new Error('Unknown file open mode: ' + str);
- }
- return flags;
- },flagsToPermissionString:function (flag) {
- var perms = ['r', 'w', 'rw'][flag & 3];
- if ((flag & 512)) {
- perms += 'w';
- }
- return perms;
- },nodePermissions:function (node, perms) {
- if (FS.ignorePermissions) {
- return 0;
- }
- // return 0 if any user, group or owner bits are set.
- if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
- return ERRNO_CODES.EACCES;
- } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
- return ERRNO_CODES.EACCES;
- } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
- return ERRNO_CODES.EACCES;
- }
- return 0;
- },mayLookup:function (dir) {
- var err = FS.nodePermissions(dir, 'x');
- if (err) return err;
- if (!dir.node_ops.lookup) return ERRNO_CODES.EACCES;
- return 0;
- },mayCreate:function (dir, name) {
- try {
- var node = FS.lookupNode(dir, name);
- return ERRNO_CODES.EEXIST;
- } catch (e) {
- }
- return FS.nodePermissions(dir, 'wx');
- },mayDelete:function (dir, name, isdir) {
- var node;
- try {
- node = FS.lookupNode(dir, name);
- } catch (e) {
- return e.errno;
- }
- var err = FS.nodePermissions(dir, 'wx');
- if (err) {
- return err;
- }
- if (isdir) {
- if (!FS.isDir(node.mode)) {
- return ERRNO_CODES.ENOTDIR;
- }
- if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
- return ERRNO_CODES.EBUSY;
- }
- } else {
- if (FS.isDir(node.mode)) {
- return ERRNO_CODES.EISDIR;
- }
- }
- return 0;
- },mayOpen:function (node, flags) {
- if (!node) {
- return ERRNO_CODES.ENOENT;
- }
- if (FS.isLink(node.mode)) {
- return ERRNO_CODES.ELOOP;
- } else if (FS.isDir(node.mode)) {
- if (FS.flagsToPermissionString(flags) !== 'r' || // opening for write
- (flags & 512)) { // TODO: check for O_SEARCH? (== search for dir only)
- return ERRNO_CODES.EISDIR;
- }
- }
- return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
- },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
- fd_start = fd_start || 0;
- fd_end = fd_end || FS.MAX_OPEN_FDS;
- for (var fd = fd_start; fd <= fd_end; fd++) {
- if (!FS.streams[fd]) {
- return fd;
- }
- }
- throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
- },getStream:function (fd) {
- return FS.streams[fd];
- },createStream:function (stream, fd_start, fd_end) {
- if (!FS.FSStream) {
- FS.FSStream = function(){};
- FS.FSStream.prototype = {};
- // compatibility
- Object.defineProperties(FS.FSStream.prototype, {
- object: {
- get: function() { return this.node; },
- set: function(val) { this.node = val; }
- },
- isRead: {
- get: function() { return (this.flags & 2097155) !== 1; }
- },
- isWrite: {
- get: function() { return (this.flags & 2097155) !== 0; }
- },
- isAppend: {
- get: function() { return (this.flags & 1024); }
- }
- });
- }
- // clone it, so we can return an instance of FSStream
- var newStream = new FS.FSStream();
- for (var p in stream) {
- newStream[p] = stream[p];
- }
- stream = newStream;
- var fd = FS.nextfd(fd_start, fd_end);
- stream.fd = fd;
- FS.streams[fd] = stream;
- return stream;
- },closeStream:function (fd) {
- FS.streams[fd] = null;
- },chrdev_stream_ops:{open:function (stream) {
- var device = FS.getDevice(stream.node.rdev);
- // override node's stream ops with the device's
- stream.stream_ops = device.stream_ops;
- // forward the open call
- if (stream.stream_ops.open) {
- stream.stream_ops.open(stream);
- }
- },llseek:function () {
- throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
- }},major:function (dev) {
- return ((dev) >> 8);
- },minor:function (dev) {
- return ((dev) & 0xff);
- },makedev:function (ma, mi) {
- return ((ma) << 8 | (mi));
- },registerDevice:function (dev, ops) {
- FS.devices[dev] = { stream_ops: ops };
- },getDevice:function (dev) {
- return FS.devices[dev];
- },getMounts:function (mount) {
- var mounts = [];
- var check = [mount];
-
- while (check.length) {
- var m = check.pop();
-
- mounts.push(m);
-
- check.push.apply(check, m.mounts);
- }
-
- return mounts;
- },syncfs:function (populate, callback) {
- if (typeof(populate) === 'function') {
- callback = populate;
- populate = false;
- }
-
- FS.syncFSRequests++;
-
- if (FS.syncFSRequests > 1) {
- console.log('warning: ' + FS.syncFSRequests + ' FS.syncfs operations in flight at once, probably just doing extra work');
- }
-
- var mounts = FS.getMounts(FS.root.mount);
- var completed = 0;
-
- function doCallback(err) {
- assert(FS.syncFSRequests > 0);
- FS.syncFSRequests--;
- return callback(err);
- }
-
- function done(err) {
- if (err) {
- if (!done.errored) {
- done.errored = true;
- return doCallback(err);
- }
- return;
- }
- if (++completed >= mounts.length) {
- doCallback(null);
- }
- };
-
- // sync all mounts
- mounts.forEach(function (mount) {
- if (!mount.type.syncfs) {
- return done(null);
- }
- mount.type.syncfs(mount, populate, done);
- });
- },mount:function (type, opts, mountpoint) {
- var root = mountpoint === '/';
- var pseudo = !mountpoint;
- var node;
-
- if (root && FS.root) {
- throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
- } else if (!root && !pseudo) {
- var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
-
- mountpoint = lookup.path; // use the absolute path
- node = lookup.node;
-
- if (FS.isMountpoint(node)) {
- throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
- }
-
- if (!FS.isDir(node.mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
- }
- }
-
- var mount = {
- type: type,
- opts: opts,
- mountpoint: mountpoint,
- mounts: []
- };
-
- // create a root node for the fs
- var mountRoot = type.mount(mount);
- mountRoot.mount = mount;
- mount.root = mountRoot;
-
- if (root) {
- FS.root = mountRoot;
- } else if (node) {
- // set as a mountpoint
- node.mounted = mount;
-
- // add the new mount to the current mount's children
- if (node.mount) {
- node.mount.mounts.push(mount);
- }
- }
-
- return mountRoot;
- },unmount:function (mountpoint) {
- var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
-
- if (!FS.isMountpoint(lookup.node)) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
-
- // destroy the nodes for this mount, and all its child mounts
- var node = lookup.node;
- var mount = node.mounted;
- var mounts = FS.getMounts(mount);
-
- Object.keys(FS.nameTable).forEach(function (hash) {
- var current = FS.nameTable[hash];
-
- while (current) {
- var next = current.name_next;
-
- if (mounts.indexOf(current.mount) !== -1) {
- FS.destroyNode(current);
- }
-
- current = next;
- }
- });
-
- // no longer a mountpoint
- node.mounted = null;
-
- // remove this mount from the child mounts
- var idx = node.mount.mounts.indexOf(mount);
- assert(idx !== -1);
- node.mount.mounts.splice(idx, 1);
- },lookup:function (parent, name) {
- return parent.node_ops.lookup(parent, name);
- },mknod:function (path, mode, dev) {
- var lookup = FS.lookupPath(path, { parent: true });
- var parent = lookup.node;
- var name = PATH.basename(path);
- if (!name || name === '.' || name === '..') {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- var err = FS.mayCreate(parent, name);
- if (err) {
- throw new FS.ErrnoError(err);
- }
- if (!parent.node_ops.mknod) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- }
- return parent.node_ops.mknod(parent, name, mode, dev);
- },create:function (path, mode) {
- mode = mode !== undefined ? mode : 438 /* 0666 */;
- mode &= 4095;
- mode |= 32768;
- return FS.mknod(path, mode, 0);
- },mkdir:function (path, mode) {
- mode = mode !== undefined ? mode : 511 /* 0777 */;
- mode &= 511 | 512;
- mode |= 16384;
- return FS.mknod(path, mode, 0);
- },mkdirTree:function (path, mode) {
- var dirs = path.split('/');
- var d = '';
- for (var i = 0; i < dirs.length; ++i) {
- if (!dirs[i]) continue;
- d += '/' + dirs[i];
- try {
- FS.mkdir(d, mode);
- } catch(e) {
- if (e.errno != ERRNO_CODES.EEXIST) throw e;
- }
- }
- },mkdev:function (path, mode, dev) {
- if (typeof(dev) === 'undefined') {
- dev = mode;
- mode = 438 /* 0666 */;
- }
- mode |= 8192;
- return FS.mknod(path, mode, dev);
- },symlink:function (oldpath, newpath) {
- if (!PATH.resolve(oldpath)) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
- }
- var lookup = FS.lookupPath(newpath, { parent: true });
- var parent = lookup.node;
- if (!parent) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
- }
- var newname = PATH.basename(newpath);
- var err = FS.mayCreate(parent, newname);
- if (err) {
- throw new FS.ErrnoError(err);
- }
- if (!parent.node_ops.symlink) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- }
- return parent.node_ops.symlink(parent, newname, oldpath);
- },rename:function (old_path, new_path) {
- var old_dirname = PATH.dirname(old_path);
- var new_dirname = PATH.dirname(new_path);
- var old_name = PATH.basename(old_path);
- var new_name = PATH.basename(new_path);
- // parents must exist
- var lookup, old_dir, new_dir;
- try {
- lookup = FS.lookupPath(old_path, { parent: true });
- old_dir = lookup.node;
- lookup = FS.lookupPath(new_path, { parent: true });
- new_dir = lookup.node;
- } catch (e) {
- throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
- }
- if (!old_dir || !new_dir) throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
- // need to be part of the same mount
- if (old_dir.mount !== new_dir.mount) {
- throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
- }
- // source must exist
- var old_node = FS.lookupNode(old_dir, old_name);
- // old path should not be an ancestor of the new path
- var relative = PATH.relative(old_path, new_dirname);
- if (relative.charAt(0) !== '.') {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- // new path should not be an ancestor of the old path
- relative = PATH.relative(new_path, old_dirname);
- if (relative.charAt(0) !== '.') {
- throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
- }
- // see if the new path already exists
- var new_node;
- try {
- new_node = FS.lookupNode(new_dir, new_name);
- } catch (e) {
- // not fatal
- }
- // early out if nothing needs to change
- if (old_node === new_node) {
- return;
- }
- // we'll need to delete the old entry
- var isdir = FS.isDir(old_node.mode);
- var err = FS.mayDelete(old_dir, old_name, isdir);
- if (err) {
- throw new FS.ErrnoError(err);
- }
- // need delete permissions if we'll be overwriting.
- // need create permissions if new doesn't already exist.
- err = new_node ?
- FS.mayDelete(new_dir, new_name, isdir) :
- FS.mayCreate(new_dir, new_name);
- if (err) {
- throw new FS.ErrnoError(err);
- }
- if (!old_dir.node_ops.rename) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- }
- if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
- throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
- }
- // if we are going to change the parent, check write permissions
- if (new_dir !== old_dir) {
- err = FS.nodePermissions(old_dir, 'w');
- if (err) {
- throw new FS.ErrnoError(err);
- }
- }
- try {
- if (FS.trackingDelegate['willMovePath']) {
- FS.trackingDelegate['willMovePath'](old_path, new_path);
- }
- } catch(e) {
- console.log("FS.trackingDelegate['willMovePath']('"+old_path+"', '"+new_path+"') threw an exception: " + e.message);
- }
- // remove the node from the lookup hash
- FS.hashRemoveNode(old_node);
- // do the underlying fs rename
- try {
- old_dir.node_ops.rename(old_node, new_dir, new_name);
- } catch (e) {
- throw e;
- } finally {
- // add the node back to the hash (in case node_ops.rename
- // changed its name)
- FS.hashAddNode(old_node);
- }
- try {
- if (FS.trackingDelegate['onMovePath']) FS.trackingDelegate['onMovePath'](old_path, new_path);
- } catch(e) {
- console.log("FS.trackingDelegate['onMovePath']('"+old_path+"', '"+new_path+"') threw an exception: " + e.message);
- }
- },rmdir:function (path) {
- var lookup = FS.lookupPath(path, { parent: true });
- var parent = lookup.node;
- var name = PATH.basename(path);
- var node = FS.lookupNode(parent, name);
- var err = FS.mayDelete(parent, name, true);
- if (err) {
- throw new FS.ErrnoError(err);
- }
- if (!parent.node_ops.rmdir) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- }
- if (FS.isMountpoint(node)) {
- throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
- }
- try {
- if (FS.trackingDelegate['willDeletePath']) {
- FS.trackingDelegate['willDeletePath'](path);
- }
- } catch(e) {
- console.log("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: " + e.message);
- }
- parent.node_ops.rmdir(parent, name);
- FS.destroyNode(node);
- try {
- if (FS.trackingDelegate['onDeletePath']) FS.trackingDelegate['onDeletePath'](path);
- } catch(e) {
- console.log("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: " + e.message);
- }
- },readdir:function (path) {
- var lookup = FS.lookupPath(path, { follow: true });
- var node = lookup.node;
- if (!node.node_ops.readdir) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
- }
- return node.node_ops.readdir(node);
- },unlink:function (path) {
- var lookup = FS.lookupPath(path, { parent: true });
- var parent = lookup.node;
- var name = PATH.basename(path);
- var node = FS.lookupNode(parent, name);
- var err = FS.mayDelete(parent, name, false);
- if (err) {
- // According to POSIX, we should map EISDIR to EPERM, but
- // we instead do what Linux does (and we must, as we use
- // the musl linux libc).
- throw new FS.ErrnoError(err);
- }
- if (!parent.node_ops.unlink) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- }
- if (FS.isMountpoint(node)) {
- throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
- }
- try {
- if (FS.trackingDelegate['willDeletePath']) {
- FS.trackingDelegate['willDeletePath'](path);
- }
- } catch(e) {
- console.log("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: " + e.message);
- }
- parent.node_ops.unlink(parent, name);
- FS.destroyNode(node);
- try {
- if (FS.trackingDelegate['onDeletePath']) FS.trackingDelegate['onDeletePath'](path);
- } catch(e) {
- console.log("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: " + e.message);
- }
- },readlink:function (path) {
- var lookup = FS.lookupPath(path);
- var link = lookup.node;
- if (!link) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
- }
- if (!link.node_ops.readlink) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- return PATH.resolve(FS.getPath(link.parent), link.node_ops.readlink(link));
- },stat:function (path, dontFollow) {
- var lookup = FS.lookupPath(path, { follow: !dontFollow });
- var node = lookup.node;
- if (!node) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
- }
- if (!node.node_ops.getattr) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- }
- return node.node_ops.getattr(node);
- },lstat:function (path) {
- return FS.stat(path, true);
- },chmod:function (path, mode, dontFollow) {
- var node;
- if (typeof path === 'string') {
- var lookup = FS.lookupPath(path, { follow: !dontFollow });
- node = lookup.node;
- } else {
- node = path;
- }
- if (!node.node_ops.setattr) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- }
- node.node_ops.setattr(node, {
- mode: (mode & 4095) | (node.mode & ~4095),
- timestamp: Date.now()
- });
- },lchmod:function (path, mode) {
- FS.chmod(path, mode, true);
- },fchmod:function (fd, mode) {
- var stream = FS.getStream(fd);
- if (!stream) {
- throw new FS.ErrnoError(ERRNO_CODES.EBADF);
- }
- FS.chmod(stream.node, mode);
- },chown:function (path, uid, gid, dontFollow) {
- var node;
- if (typeof path === 'string') {
- var lookup = FS.lookupPath(path, { follow: !dontFollow });
- node = lookup.node;
- } else {
- node = path;
- }
- if (!node.node_ops.setattr) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- }
- node.node_ops.setattr(node, {
- timestamp: Date.now()
- // we ignore the uid / gid for now
- });
- },lchown:function (path, uid, gid) {
- FS.chown(path, uid, gid, true);
- },fchown:function (fd, uid, gid) {
- var stream = FS.getStream(fd);
- if (!stream) {
- throw new FS.ErrnoError(ERRNO_CODES.EBADF);
- }
- FS.chown(stream.node, uid, gid);
- },truncate:function (path, len) {
- if (len < 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- var node;
- if (typeof path === 'string') {
- var lookup = FS.lookupPath(path, { follow: true });
- node = lookup.node;
- } else {
- node = path;
- }
- if (!node.node_ops.setattr) {
- throw new FS.ErrnoError(ERRNO_CODES.EPERM);
- }
- if (FS.isDir(node.mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
- }
- if (!FS.isFile(node.mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- var err = FS.nodePermissions(node, 'w');
- if (err) {
- throw new FS.ErrnoError(err);
- }
- node.node_ops.setattr(node, {
- size: len,
- timestamp: Date.now()
- });
- },ftruncate:function (fd, len) {
- var stream = FS.getStream(fd);
- if (!stream) {
- throw new FS.ErrnoError(ERRNO_CODES.EBADF);
- }
- if ((stream.flags & 2097155) === 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- FS.truncate(stream.node, len);
- },utime:function (path, atime, mtime) {
- var lookup = FS.lookupPath(path, { follow: true });
- var node = lookup.node;
- node.node_ops.setattr(node, {
- timestamp: Math.max(atime, mtime)
- });
- },open:function (path, flags, mode, fd_start, fd_end) {
- if (path === "") {
- throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
- }
- flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
- mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
- if ((flags & 64)) {
- mode = (mode & 4095) | 32768;
- } else {
- mode = 0;
- }
- var node;
- if (typeof path === 'object') {
- node = path;
- } else {
- path = PATH.normalize(path);
- try {
- var lookup = FS.lookupPath(path, {
- follow: !(flags & 131072)
- });
- node = lookup.node;
- } catch (e) {
- // ignore
- }
- }
- // perhaps we need to create the node
- var created = false;
- if ((flags & 64)) {
- if (node) {
- // if O_CREAT and O_EXCL are set, error out if the node already exists
- if ((flags & 128)) {
- throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
- }
- } else {
- // node doesn't exist, try to create it
- node = FS.mknod(path, mode, 0);
- created = true;
- }
- }
- if (!node) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
- }
- // can't truncate a device
- if (FS.isChrdev(node.mode)) {
- flags &= ~512;
- }
- // if asked only for a directory, then this must be one
- if ((flags & 65536) && !FS.isDir(node.mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
- }
- // check permissions, if this is not a file we just created now (it is ok to
- // create and write to a file with read-only permissions; it is read-only
- // for later use)
- if (!created) {
- var err = FS.mayOpen(node, flags);
- if (err) {
- throw new FS.ErrnoError(err);
- }
- }
- // do truncation if necessary
- if ((flags & 512)) {
- FS.truncate(node, 0);
- }
- // we've already handled these, don't pass down to the underlying vfs
- flags &= ~(128 | 512);
-
- // register the stream with the filesystem
- var stream = FS.createStream({
- node: node,
- path: FS.getPath(node), // we want the absolute path to the node
- flags: flags,
- seekable: true,
- position: 0,
- stream_ops: node.stream_ops,
- // used by the file family libc calls (fopen, fwrite, ferror, etc.)
- ungotten: [],
- error: false
- }, fd_start, fd_end);
- // call the new stream's open function
- if (stream.stream_ops.open) {
- stream.stream_ops.open(stream);
- }
- if (Module['logReadFiles'] && !(flags & 1)) {
- if (!FS.readFiles) FS.readFiles = {};
- if (!(path in FS.readFiles)) {
- FS.readFiles[path] = 1;
- Module['printErr']('read file: ' + path);
- }
- }
- try {
- if (FS.trackingDelegate['onOpenFile']) {
- var trackingFlags = 0;
- if ((flags & 2097155) !== 1) {
- trackingFlags |= FS.tracking.openFlags.READ;
- }
- if ((flags & 2097155) !== 0) {
- trackingFlags |= FS.tracking.openFlags.WRITE;
- }
- FS.trackingDelegate['onOpenFile'](path, trackingFlags);
- }
- } catch(e) {
- console.log("FS.trackingDelegate['onOpenFile']('"+path+"', flags) threw an exception: " + e.message);
- }
- return stream;
- },close:function (stream) {
- if (stream.getdents) stream.getdents = null; // free readdir state
- try {
- if (stream.stream_ops.close) {
- stream.stream_ops.close(stream);
- }
- } catch (e) {
- throw e;
- } finally {
- FS.closeStream(stream.fd);
- }
- },llseek:function (stream, offset, whence) {
- if (!stream.seekable || !stream.stream_ops.llseek) {
- throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
- }
- stream.position = stream.stream_ops.llseek(stream, offset, whence);
- stream.ungotten = [];
- return stream.position;
- },read:function (stream, buffer, offset, length, position) {
- if (length < 0 || position < 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- if ((stream.flags & 2097155) === 1) {
- throw new FS.ErrnoError(ERRNO_CODES.EBADF);
- }
- if (FS.isDir(stream.node.mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
- }
- if (!stream.stream_ops.read) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- var seeking = true;
- if (typeof position === 'undefined') {
- position = stream.position;
- seeking = false;
- } else if (!stream.seekable) {
- throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
- }
- var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
- if (!seeking) stream.position += bytesRead;
- return bytesRead;
- },write:function (stream, buffer, offset, length, position, canOwn) {
- if (length < 0 || position < 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- if ((stream.flags & 2097155) === 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EBADF);
- }
- if (FS.isDir(stream.node.mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
- }
- if (!stream.stream_ops.write) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- if (stream.flags & 1024) {
- // seek to the end before writing in append mode
- FS.llseek(stream, 0, 2);
- }
- var seeking = true;
- if (typeof position === 'undefined') {
- position = stream.position;
- seeking = false;
- } else if (!stream.seekable) {
- throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
- }
- var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
- if (!seeking) stream.position += bytesWritten;
- try {
- if (stream.path && FS.trackingDelegate['onWriteToFile']) FS.trackingDelegate['onWriteToFile'](stream.path);
- } catch(e) {
- console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: " + e.message);
- }
- return bytesWritten;
- },allocate:function (stream, offset, length) {
- if (offset < 0 || length <= 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
- }
- if ((stream.flags & 2097155) === 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EBADF);
- }
- if (!FS.isFile(stream.node.mode) && !FS.isDir(stream.node.mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
- }
- if (!stream.stream_ops.allocate) {
- throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
- }
- stream.stream_ops.allocate(stream, offset, length);
- },mmap:function (stream, buffer, offset, length, position, prot, flags) {
- // TODO if PROT is PROT_WRITE, make sure we have write access
- if ((stream.flags & 2097155) === 1) {
- throw new FS.ErrnoError(ERRNO_CODES.EACCES);
- }
- if (!stream.stream_ops.mmap) {
- throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
- }
- return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
- },msync:function (stream, buffer, offset, length, mmapFlags) {
- if (!stream || !stream.stream_ops.msync) {
- return 0;
- }
- return stream.stream_ops.msync(stream, buffer, offset, length, mmapFlags);
- },munmap:function (stream) {
- return 0;
- },ioctl:function (stream, cmd, arg) {
- if (!stream.stream_ops.ioctl) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
- }
- return stream.stream_ops.ioctl(stream, cmd, arg);
- },readFile:function (path, opts) {
- opts = opts || {};
- opts.flags = opts.flags || 'r';
- opts.encoding = opts.encoding || 'binary';
- if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
- throw new Error('Invalid encoding type "' + opts.encoding + '"');
- }
- var ret;
- var stream = FS.open(path, opts.flags);
- var stat = FS.stat(path);
- var length = stat.size;
- var buf = new Uint8Array(length);
- FS.read(stream, buf, 0, length, 0);
- if (opts.encoding === 'utf8') {
- ret = UTF8ArrayToString(buf, 0);
- } else if (opts.encoding === 'binary') {
- ret = buf;
- }
- FS.close(stream);
- return ret;
- },writeFile:function (path, data, opts) {
- opts = opts || {};
- opts.flags = opts.flags || 'w';
- opts.encoding = opts.encoding || 'utf8';
- if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
- throw new Error('Invalid encoding type "' + opts.encoding + '"');
- }
- var stream = FS.open(path, opts.flags, opts.mode);
- if (opts.encoding === 'utf8') {
- var buf = new Uint8Array(lengthBytesUTF8(data)+1);
- var actualNumBytes = stringToUTF8Array(data, buf, 0, buf.length);
- FS.write(stream, buf, 0, actualNumBytes, 0, opts.canOwn);
- } else if (opts.encoding === 'binary') {
- FS.write(stream, data, 0, data.length, 0, opts.canOwn);
- }
- FS.close(stream);
- },cwd:function () {
- return FS.currentPath;
- },chdir:function (path) {
- var lookup = FS.lookupPath(path, { follow: true });
- if (lookup.node === null) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
- }
- if (!FS.isDir(lookup.node.mode)) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
- }
- var err = FS.nodePermissions(lookup.node, 'x');
- if (err) {
- throw new FS.ErrnoError(err);
- }
- FS.currentPath = lookup.path;
- },createDefaultDirectories:function () {
- FS.mkdir('/tmp');
- FS.mkdir('/home');
- FS.mkdir('/home/web_user');
- },createDefaultDevices:function () {
- // create /dev
- FS.mkdir('/dev');
- // setup /dev/null
- FS.registerDevice(FS.makedev(1, 3), {
- read: function() { return 0; },
- write: function(stream, buffer, offset, length, pos) { return length; }
- });
- FS.mkdev('/dev/null', FS.makedev(1, 3));
- // setup /dev/tty and /dev/tty1
- // stderr needs to print output using Module['printErr']
- // so we register a second tty just for it.
- TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
- TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
- FS.mkdev('/dev/tty', FS.makedev(5, 0));
- FS.mkdev('/dev/tty1', FS.makedev(6, 0));
- // setup /dev/[u]random
- var random_device;
- if (typeof crypto !== 'undefined') {
- // for modern web browsers
- var randomBuffer = new Uint8Array(1);
- random_device = function() { crypto.getRandomValues(randomBuffer); return randomBuffer[0]; };
- } else if (ENVIRONMENT_IS_NODE) {
- // for nodejs
- random_device = function() { return require('crypto').randomBytes(1)[0]; };
- } else {
- // default for ES5 platforms
- random_device = function() { return (Math.random()*256)|0; };
- }
- FS.createDevice('/dev', 'random', random_device);
- FS.createDevice('/dev', 'urandom', random_device);
- // we're not going to emulate the actual shm device,
- // just create the tmp dirs that reside in it commonly
- FS.mkdir('/dev/shm');
- FS.mkdir('/dev/shm/tmp');
- },createSpecialDirectories:function () {
- // create /proc/self/fd which allows /proc/self/fd/6 => readlink gives the name of the stream for fd 6 (see test_unistd_ttyname)
- FS.mkdir('/proc');
- FS.mkdir('/proc/self');
- FS.mkdir('/proc/self/fd');
- FS.mount({
- mount: function() {
- var node = FS.createNode('/proc/self', 'fd', 16384 | 511 /* 0777 */, 73);
- node.node_ops = {
- lookup: function(parent, name) {
- var fd = +name;
- var stream = FS.getStream(fd);
- if (!stream) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
- var ret = {
- parent: null,
- mount: { mountpoint: 'fake' },
- node_ops: { readlink: function() { return stream.path } }
- };
- ret.parent = ret; // make it look like a simple root node
- return ret;
- }
- };
- return node;
- }
- }, {}, '/proc/self/fd');
- },createStandardStreams:function () {
- // TODO deprecate the old functionality of a single
- // input / output callback and that utilizes FS.createDevice
- // and instead require a unique set of stream ops
-
- // by default, we symlink the standard streams to the
- // default tty devices. however, if the standard streams
- // have been overwritten we create a unique device for
- // them instead.
- if (Module['stdin']) {
- FS.createDevice('/dev', 'stdin', Module['stdin']);
- } else {
- FS.symlink('/dev/tty', '/dev/stdin');
- }
- if (Module['stdout']) {
- FS.createDevice('/dev', 'stdout', null, Module['stdout']);
- } else {
- FS.symlink('/dev/tty', '/dev/stdout');
- }
- if (Module['stderr']) {
- FS.createDevice('/dev', 'stderr', null, Module['stderr']);
- } else {
- FS.symlink('/dev/tty1', '/dev/stderr');
- }
-
- // open default streams for the stdin, stdout and stderr devices
- var stdin = FS.open('/dev/stdin', 'r');
- assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
-
- var stdout = FS.open('/dev/stdout', 'w');
- assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
-
- var stderr = FS.open('/dev/stderr', 'w');
- assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
- },ensureErrnoError:function () {
- if (FS.ErrnoError) return;
- FS.ErrnoError = function ErrnoError(errno, node) {
- //Module.printErr(stackTrace()); // useful for debugging
- this.node = node;
- this.setErrno = function(errno) {
- this.errno = errno;
- for (var key in ERRNO_CODES) {
- if (ERRNO_CODES[key] === errno) {
- this.code = key;
- break;
- }
- }
- };
- this.setErrno(errno);
- this.message = ERRNO_MESSAGES[errno];
- if (this.stack) this.stack = demangleAll(this.stack);
- };
- FS.ErrnoError.prototype = new Error();
- FS.ErrnoError.prototype.constructor = FS.ErrnoError;
- // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
- [ERRNO_CODES.ENOENT].forEach(function(code) {
- FS.genericErrors[code] = new FS.ErrnoError(code);
- FS.genericErrors[code].stack = '';
- });
- },staticInit:function () {
- FS.ensureErrnoError();
-
- FS.nameTable = new Array(4096);
-
- FS.mount(MEMFS, {}, '/');
-
- FS.createDefaultDirectories();
- FS.createDefaultDevices();
- FS.createSpecialDirectories();
-
- FS.filesystems = {
- 'MEMFS': MEMFS,
- 'IDBFS': IDBFS,
- 'NODEFS': NODEFS,
- 'WORKERFS': WORKERFS,
- };
- },init:function (input, output, error) {
- assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
- FS.init.initialized = true;
-
- FS.ensureErrnoError();
-
- // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
- Module['stdin'] = input || Module['stdin'];
- Module['stdout'] = output || Module['stdout'];
- Module['stderr'] = error || Module['stderr'];
-
- FS.createStandardStreams();
- },quit:function () {
- FS.init.initialized = false;
- // force-flush all streams, so we get musl std streams printed out
- var fflush = Module['_fflush'];
- if (fflush) fflush(0);
- // close all of our streams
- for (var i = 0; i < FS.streams.length; i++) {
- var stream = FS.streams[i];
- if (!stream) {
- continue;
- }
- FS.close(stream);
- }
- },getMode:function (canRead, canWrite) {
- var mode = 0;
- if (canRead) mode |= 292 | 73;
- if (canWrite) mode |= 146;
- return mode;
- },joinPath:function (parts, forceRelative) {
- var path = PATH.join.apply(null, parts);
- if (forceRelative && path[0] == '/') path = path.substr(1);
- return path;
- },absolutePath:function (relative, base) {
- return PATH.resolve(base, relative);
- },standardizePath:function (path) {
- return PATH.normalize(path);
- },findObject:function (path, dontResolveLastLink) {
- var ret = FS.analyzePath(path, dontResolveLastLink);
- if (ret.exists) {
- return ret.object;
- } else {
- ___setErrNo(ret.error);
- return null;
- }
- },analyzePath:function (path, dontResolveLastLink) {
- // operate from within the context of the symlink's target
- try {
- var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
- path = lookup.path;
- } catch (e) {
- }
- var ret = {
- isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
- parentExists: false, parentPath: null, parentObject: null
- };
- try {
- var lookup = FS.lookupPath(path, { parent: true });
- ret.parentExists = true;
- ret.parentPath = lookup.path;
- ret.parentObject = lookup.node;
- ret.name = PATH.basename(path);
- lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
- ret.exists = true;
- ret.path = lookup.path;
- ret.object = lookup.node;
- ret.name = lookup.node.name;
- ret.isRoot = lookup.path === '/';
- } catch (e) {
- ret.error = e.errno;
- };
- return ret;
- },createFolder:function (parent, name, canRead, canWrite) {
- var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
- var mode = FS.getMode(canRead, canWrite);
- return FS.mkdir(path, mode);
- },createPath:function (parent, path, canRead, canWrite) {
- parent = typeof parent === 'string' ? parent : FS.getPath(parent);
- var parts = path.split('/').reverse();
- while (parts.length) {
- var part = parts.pop();
- if (!part) continue;
- var current = PATH.join2(parent, part);
- try {
- FS.mkdir(current);
- } catch (e) {
- // ignore EEXIST
- }
- parent = current;
- }
- return current;
- },createFile:function (parent, name, properties, canRead, canWrite) {
- var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
- var mode = FS.getMode(canRead, canWrite);
- return FS.create(path, mode);
- },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
- var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
- var mode = FS.getMode(canRead, canWrite);
- var node = FS.create(path, mode);
- if (data) {
- if (typeof data === 'string') {
- var arr = new Array(data.length);
- for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
- data = arr;
- }
- // make sure we can write to the file
- FS.chmod(node, mode | 146);
- var stream = FS.open(node, 'w');
- FS.write(stream, data, 0, data.length, 0, canOwn);
- FS.close(stream);
- FS.chmod(node, mode);
- }
- return node;
- },createDevice:function (parent, name, input, output) {
- var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
- var mode = FS.getMode(!!input, !!output);
- if (!FS.createDevice.major) FS.createDevice.major = 64;
- var dev = FS.makedev(FS.createDevice.major++, 0);
- // Create a fake device that a set of stream ops to emulate
- // the old behavior.
- FS.registerDevice(dev, {
- open: function(stream) {
- stream.seekable = false;
- },
- close: function(stream) {
- // flush any pending line data
- if (output && output.buffer && output.buffer.length) {
- output(10);
- }
- },
- read: function(stream, buffer, offset, length, pos /* ignored */) {
- var bytesRead = 0;
- for (var i = 0; i < length; i++) {
- var result;
- try {
- result = input();
- } catch (e) {
- throw new FS.ErrnoError(ERRNO_CODES.EIO);
- }
- if (result === undefined && bytesRead === 0) {
- throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
- }
- if (result === null || result === undefined) break;
- bytesRead++;
- buffer[offset+i] = result;
- }
- if (bytesRead) {
- stream.node.timestamp = Date.now();
- }
- return bytesRead;
- },
- write: function(stream, buffer, offset, length, pos) {
- for (var i = 0; i < length; i++) {
- try {
- output(buffer[offset+i]);
- } catch (e) {
- throw new FS.ErrnoError(ERRNO_CODES.EIO);
- }
- }
- if (length) {
- stream.node.timestamp = Date.now();
- }
- return i;
- }
- });
- return FS.mkdev(path, mode, dev);
- },createLink:function (parent, name, target, canRead, canWrite) {
- var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
- return FS.symlink(target, path);
- },forceLoadFile:function (obj) {
- if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
- var success = true;
- if (typeof XMLHttpRequest !== 'undefined') {
- throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
- } else if (Module['read']) {
- // Command-line.
- try {
- // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
- // read() will try to parse UTF8.
- obj.contents = intArrayFromString(Module['read'](obj.url), true);
- obj.usedBytes = obj.contents.length;
- } catch (e) {
- success = false;
- }
- } else {
- throw new Error('Cannot load without read() or XMLHttpRequest.');
- }
- if (!success) ___setErrNo(ERRNO_CODES.EIO);
- return success;
- },createLazyFile:function (parent, name, url, canRead, canWrite) {
- // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
- function LazyUint8Array() {
- this.lengthKnown = false;
- this.chunks = []; // Loaded chunks. Index is the chunk number
- }
- LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
- if (idx > this.length-1 || idx < 0) {
- return undefined;
- }
- var chunkOffset = idx % this.chunkSize;
- var chunkNum = (idx / this.chunkSize)|0;
- return this.getter(chunkNum)[chunkOffset];
- }
- LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
- this.getter = getter;
- }
- LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
- // Find length
- var xhr = new XMLHttpRequest();
- xhr.open('HEAD', url, false);
- xhr.send(null);
- if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
- var datalength = Number(xhr.getResponseHeader("Content-length"));
- var header;
- var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
- var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
-
- var chunkSize = 1024*1024; // Chunk size in bytes
-
- if (!hasByteServing) chunkSize = datalength;
-
- // Function to get a range from the remote URL.
- var doXHR = (function(from, to) {
- if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
- if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
-
- // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
- var xhr = new XMLHttpRequest();
- xhr.open('GET', url, false);
- if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
-
- // Some hints to the browser that we want binary data.
- if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
- if (xhr.overrideMimeType) {
- xhr.overrideMimeType('text/plain; charset=x-user-defined');
- }
-
- xhr.send(null);
- if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
- if (xhr.response !== undefined) {
- return new Uint8Array(xhr.response || []);
- } else {
- return intArrayFromString(xhr.responseText || '', true);
- }
- });
- var lazyArray = this;
- lazyArray.setDataGetter(function(chunkNum) {
- var start = chunkNum * chunkSize;
- var end = (chunkNum+1) * chunkSize - 1; // including this byte
- end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
- if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
- lazyArray.chunks[chunkNum] = doXHR(start, end);
- }
- if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
- return lazyArray.chunks[chunkNum];
- });
-
- if (usesGzip || !datalength) {
- // if the server uses gzip or doesn't supply the length, we have to download the whole file to get the (uncompressed) length
- chunkSize = datalength = 1; // this will force getter(0)/doXHR do download the whole file
- datalength = this.getter(0).length;
- chunkSize = datalength;
- console.log("LazyFiles on gzip forces download of the whole file when length is accessed");
- }
-
- this._length = datalength;
- this._chunkSize = chunkSize;
- this.lengthKnown = true;
- }
- if (typeof XMLHttpRequest !== 'undefined') {
- if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
- var lazyArray = new LazyUint8Array();
- Object.defineProperties(lazyArray, {
- length: {
- get: function() {
- if(!this.lengthKnown) {
- this.cacheLength();
- }
- return this._length;
- }
- },
- chunkSize: {
- get: function() {
- if(!this.lengthKnown) {
- this.cacheLength();
- }
- return this._chunkSize;
- }
- }
- });
-
- var properties = { isDevice: false, contents: lazyArray };
- } else {
- var properties = { isDevice: false, url: url };
- }
-
- var node = FS.createFile(parent, name, properties, canRead, canWrite);
- // This is a total hack, but I want to get this lazy file code out of the
- // core of MEMFS. If we want to keep this lazy file concept I feel it should
- // be its own thin LAZYFS proxying calls to MEMFS.
- if (properties.contents) {
- node.contents = properties.contents;
- } else if (properties.url) {
- node.contents = null;
- node.url = properties.url;
- }
- // Add a function that defers querying the file size until it is asked the first time.
- Object.defineProperties(node, {
- usedBytes: {
- get: function() { return this.contents.length; }
- }
- });
- // override each stream op with one that tries to force load the lazy file first
- var stream_ops = {};
- var keys = Object.keys(node.stream_ops);
- keys.forEach(function(key) {
- var fn = node.stream_ops[key];
- stream_ops[key] = function forceLoadLazyFile() {
- if (!FS.forceLoadFile(node)) {
- throw new FS.ErrnoError(ERRNO_CODES.EIO);
- }
- return fn.apply(null, arguments);
- };
- });
- // use a custom read function
- stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
- if (!FS.forceLoadFile(node)) {
- throw new FS.ErrnoError(ERRNO_CODES.EIO);
- }
- var contents = stream.node.contents;
- if (position >= contents.length)
- return 0;
- var size = Math.min(contents.length - position, length);
- assert(size >= 0);
- if (contents.slice) { // normal array
- for (var i = 0; i < size; i++) {
- buffer[offset + i] = contents[position + i];
- }
- } else {
- for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
- buffer[offset + i] = contents.get(position + i);
- }
- }
- return size;
- };
- node.stream_ops = stream_ops;
- return node;
- },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) {
- Browser.init(); // XXX perhaps this method should move onto Browser?
- // TODO we should allow people to just pass in a complete filename instead
- // of parent and name being that we just join them anyways
- var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
- var dep = getUniqueRunDependency('cp ' + fullname); // might have several active requests for the same fullname
- function processData(byteArray) {
- function finish(byteArray) {
- if (preFinish) preFinish();
- if (!dontCreateFile) {
- FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
- }
- if (onload) onload();
- removeRunDependency(dep);
- }
- var handled = false;
- Module['preloadPlugins'].forEach(function(plugin) {
- if (handled) return;
- if (plugin['canHandle'](fullname)) {
- plugin['handle'](byteArray, fullname, finish, function() {
- if (onerror) onerror();
- removeRunDependency(dep);
- });
- handled = true;
- }
- });
- if (!handled) finish(byteArray);
- }
- addRunDependency(dep);
- if (typeof url == 'string') {
- Browser.asyncLoad(url, function(byteArray) {
- processData(byteArray);
- }, onerror);
- } else {
- processData(url);
- }
- },indexedDB:function () {
- return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
- },DB_NAME:function () {
- return 'EM_FS_' + window.location.pathname;
- },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
- onload = onload || function(){};
- onerror = onerror || function(){};
- var indexedDB = FS.indexedDB();
- try {
- var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
- } catch (e) {
- return onerror(e);
- }
- openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
- console.log('creating db');
- var db = openRequest.result;
- db.createObjectStore(FS.DB_STORE_NAME);
- };
- openRequest.onsuccess = function openRequest_onsuccess() {
- var db = openRequest.result;
- var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
- var files = transaction.objectStore(FS.DB_STORE_NAME);
- var ok = 0, fail = 0, total = paths.length;
- function finish() {
- if (fail == 0) onload(); else onerror();
- }
- paths.forEach(function(path) {
- var putRequest = files.put(FS.analyzePath(path).object.contents, path);
- putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
- putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
- });
- transaction.onerror = onerror;
- };
- openRequest.onerror = onerror;
- },loadFilesFromDB:function (paths, onload, onerror) {
- onload = onload || function(){};
- onerror = onerror || function(){};
- var indexedDB = FS.indexedDB();
- try {
- var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
- } catch (e) {
- return onerror(e);
- }
- openRequest.onupgradeneeded = onerror; // no database to load from
- openRequest.onsuccess = function openRequest_onsuccess() {
- var db = openRequest.result;
- try {
- var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
- } catch(e) {
- onerror(e);
- return;
- }
- var files = transaction.objectStore(FS.DB_STORE_NAME);
- var ok = 0, fail = 0, total = paths.length;
- function finish() {
- if (fail == 0) onload(); else onerror();
- }
- paths.forEach(function(path) {
- var getRequest = files.get(path);
- getRequest.onsuccess = function getRequest_onsuccess() {
- if (FS.analyzePath(path).exists) {
- FS.unlink(path);
- }
- FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
- ok++;
- if (ok + fail == total) finish();
- };
- getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
- });
- transaction.onerror = onerror;
- };
- openRequest.onerror = onerror;
- }};var SYSCALLS={DEFAULT_POLLMASK:5,mappings:{},umask:511,calculateAt:function (dirfd, path) {
- if (path[0] !== '/') {
- // relative path
- var dir;
- if (dirfd === -100) {
- dir = FS.cwd();
- } else {
- var dirstream = FS.getStream(dirfd);
- if (!dirstream) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
- dir = dirstream.path;
- }
- path = PATH.join2(dir, path);
- }
- return path;
- },doStat:function (func, path, buf) {
- try {
- var stat = func(path);
- } catch (e) {
- if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) {
- // an error occurred while trying to look up the path; we should just report ENOTDIR
- return -ERRNO_CODES.ENOTDIR;
- }
- throw e;
- }
- HEAP32[((buf)>>2)]=stat.dev;
- HEAP32[(((buf)+(4))>>2)]=0;
- HEAP32[(((buf)+(8))>>2)]=stat.ino;
- HEAP32[(((buf)+(12))>>2)]=stat.mode;
- HEAP32[(((buf)+(16))>>2)]=stat.nlink;
- HEAP32[(((buf)+(20))>>2)]=stat.uid;
- HEAP32[(((buf)+(24))>>2)]=stat.gid;
- HEAP32[(((buf)+(28))>>2)]=stat.rdev;
- HEAP32[(((buf)+(32))>>2)]=0;
- HEAP32[(((buf)+(36))>>2)]=stat.size;
- HEAP32[(((buf)+(40))>>2)]=4096;
- HEAP32[(((buf)+(44))>>2)]=stat.blocks;
- HEAP32[(((buf)+(48))>>2)]=(stat.atime.getTime() / 1000)|0;
- HEAP32[(((buf)+(52))>>2)]=0;
- HEAP32[(((buf)+(56))>>2)]=(stat.mtime.getTime() / 1000)|0;
- HEAP32[(((buf)+(60))>>2)]=0;
- HEAP32[(((buf)+(64))>>2)]=(stat.ctime.getTime() / 1000)|0;
- HEAP32[(((buf)+(68))>>2)]=0;
- HEAP32[(((buf)+(72))>>2)]=stat.ino;
- return 0;
- },doMsync:function (addr, stream, len, flags) {
- var buffer = new Uint8Array(HEAPU8.subarray(addr, addr + len));
- FS.msync(stream, buffer, 0, len, flags);
- },doMkdir:function (path, mode) {
- // remove a trailing slash, if one - /a/b/ has basename of '', but
- // we want to create b in the context of this function
- path = PATH.normalize(path);
- if (path[path.length-1] === '/') path = path.substr(0, path.length-1);
- FS.mkdir(path, mode, 0);
- return 0;
- },doMknod:function (path, mode, dev) {
- // we don't want this in the JS API as it uses mknod to create all nodes.
- switch (mode & 61440) {
- case 32768:
- case 8192:
- case 24576:
- case 4096:
- case 49152:
- break;
- default: return -ERRNO_CODES.EINVAL;
- }
- FS.mknod(path, mode, dev);
- return 0;
- },doReadlink:function (path, buf, bufsize) {
- if (bufsize <= 0) return -ERRNO_CODES.EINVAL;
- var ret = FS.readlink(path);
-
- var len = Math.min(bufsize, lengthBytesUTF8(ret));
- var endChar = HEAP8[buf+len];
- stringToUTF8(ret, buf, bufsize+1);
- // readlink is one of the rare functions that write out a C string, but does never append a null to the output buffer(!)
- // stringToUTF8() always appends a null byte, so restore the character under the null byte after the write.
- HEAP8[buf+len] = endChar;
-
- return len;
- },doAccess:function (path, amode) {
- if (amode & ~7) {
- // need a valid mode
- return -ERRNO_CODES.EINVAL;
- }
- var node;
- var lookup = FS.lookupPath(path, { follow: true });
- node = lookup.node;
- var perms = '';
- if (amode & 4) perms += 'r';
- if (amode & 2) perms += 'w';
- if (amode & 1) perms += 'x';
- if (perms /* otherwise, they've just passed F_OK */ && FS.nodePermissions(node, perms)) {
- return -ERRNO_CODES.EACCES;
- }
- return 0;
- },doDup:function (path, flags, suggestFD) {
- var suggest = FS.getStream(suggestFD);
- if (suggest) FS.close(suggest);
- return FS.open(path, flags, 0, suggestFD, suggestFD).fd;
- },doReadv:function (stream, iov, iovcnt, offset) {
- var ret = 0;
- for (var i = 0; i < iovcnt; i++) {
- var ptr = HEAP32[(((iov)+(i*8))>>2)];
- var len = HEAP32[(((iov)+(i*8 + 4))>>2)];
- var curr = FS.read(stream, HEAP8,ptr, len, offset);
- if (curr < 0) return -1;
- ret += curr;
- if (curr < len) break; // nothing more to read
- }
- return ret;
- },doWritev:function (stream, iov, iovcnt, offset) {
- var ret = 0;
- for (var i = 0; i < iovcnt; i++) {
- var ptr = HEAP32[(((iov)+(i*8))>>2)];
- var len = HEAP32[(((iov)+(i*8 + 4))>>2)];
- var curr = FS.write(stream, HEAP8,ptr, len, offset);
- if (curr < 0) return -1;
- ret += curr;
- }
- return ret;
- },varargs:0,get:function (varargs) {
- SYSCALLS.varargs += 4;
- var ret = HEAP32[(((SYSCALLS.varargs)-(4))>>2)];
- return ret;
- },getStr:function () {
- var ret = Pointer_stringify(SYSCALLS.get());
- return ret;
- },getStreamFromFD:function () {
- var stream = FS.getStream(SYSCALLS.get());
- if (!stream) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
- return stream;
- },getSocketFromFD:function () {
- var socket = SOCKFS.getSocket(SYSCALLS.get());
- if (!socket) throw new FS.ErrnoError(ERRNO_CODES.EBADF);
- return socket;
- },getSocketAddress:function (allowNull) {
- var addrp = SYSCALLS.get(), addrlen = SYSCALLS.get();
- if (allowNull && addrp === 0) return null;
- var info = __read_sockaddr(addrp, addrlen);
- if (info.errno) throw new FS.ErrnoError(info.errno);
- info.addr = DNS.lookup_addr(info.addr) || info.addr;
- return info;
- },get64:function () {
- var low = SYSCALLS.get(), high = SYSCALLS.get();
- if (low >= 0) assert(high === 0);
- else assert(high === -1);
- return low;
- },getZero:function () {
- assert(SYSCALLS.get() === 0);
- }};function ___syscall54(which, varargs) {SYSCALLS.varargs = varargs;
- try {
- // ioctl
- var stream = SYSCALLS.getStreamFromFD(), op = SYSCALLS.get();
- switch (op) {
- case 21505: {
- if (!stream.tty) return -ERRNO_CODES.ENOTTY;
- return 0;
- }
- case 21506: {
- if (!stream.tty) return -ERRNO_CODES.ENOTTY;
- return 0; // no-op, not actually adjusting terminal settings
- }
- case 21519: {
- if (!stream.tty) return -ERRNO_CODES.ENOTTY;
- var argp = SYSCALLS.get();
- HEAP32[((argp)>>2)]=0;
- return 0;
- }
- case 21520: {
- if (!stream.tty) return -ERRNO_CODES.ENOTTY;
- return -ERRNO_CODES.EINVAL; // not supported
- }
- case 21531: {
- var argp = SYSCALLS.get();
- return FS.ioctl(stream, op, argp);
- }
- case 21523: {
- // TODO: in theory we should write to the winsize struct that gets
- // passed in, but for now musl doesn't read anything on it
- if (!stream.tty) return -ERRNO_CODES.ENOTTY;
- return 0;
- }
- default: abort('bad ioctl syscall ' + op);
- }
- } catch (e) {
- if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
- return -e.errno;
- }
- }
-
- function _emscripten_glSampleCoverage(value, invert) {
- GLctx.sampleCoverage(value, !!invert);
- }
-
- function _emscripten_glUniform4f(location, v0, v1, v2, v3) {
- GLctx.uniform4f(GL.uniforms[location], v0, v1, v2, v3);
- }
-
- function _emscripten_glFrustum() {
- Module['printErr']('missing function: emscripten_glFrustum'); abort(-1);
- }
-
- function _glVertexAttrib4f(x0, x1, x2, x3, x4) { GLctx['vertexAttrib4f'](x0, x1, x2, x3, x4) }
-
- function _glfwSetWindowSizeCallback(winid, cbfun) {
- GLFW.setWindowSizeCallback(winid, cbfun);
- }
-
- function _emscripten_glGetTexParameterfv(target, pname, params) {
- if (!params) {
- // GLES2 specification does not specify how to behave if params is a null pointer. Since calling this function does not make sense
- // if p == null, issue a GL error to notify user about it.
- GL.recordError(0x0501 /* GL_INVALID_VALUE */);
- return;
- }
- HEAPF32[((params)>>2)]=GLctx.getTexParameter(target, pname);
- }
-
- function _emscripten_glUniform4i(location, v0, v1, v2, v3) {
- GLctx.uniform4i(GL.uniforms[location], v0, v1, v2, v3);
- }
-
- function _emscripten_glBindRenderbuffer(target, renderbuffer) {
- GLctx.bindRenderbuffer(target, renderbuffer ? GL.renderbuffers[renderbuffer] : null);
- }
-
- function _emscripten_glViewport(x0, x1, x2, x3) { GLctx['viewport'](x0, x1, x2, x3) }
-
-
- var DLFCN={error:null,errorMsg:null,loadedLibs:{},loadedLibNames:{}};function _dlclose(handle) {
- // int dlclose(void *handle);
- // http://pubs.opengroup.org/onlinepubs/009695399/functions/dlclose.html
- if (!DLFCN.loadedLibs[handle]) {
- DLFCN.errorMsg = 'Tried to dlclose() unopened handle: ' + handle;
- return 1;
- } else {
- var lib_record = DLFCN.loadedLibs[handle];
- if (--lib_record.refcount == 0) {
- if (lib_record.module.cleanups) {
- lib_record.module.cleanups.forEach(function(cleanup) { cleanup() });
- }
- delete DLFCN.loadedLibNames[lib_record.name];
- delete DLFCN.loadedLibs[handle];
- }
- return 0;
- }
- }
-
-
-
- var JSEvents={keyEvent:0,mouseEvent:0,wheelEvent:0,uiEvent:0,focusEvent:0,deviceOrientationEvent:0,deviceMotionEvent:0,fullscreenChangeEvent:0,pointerlockChangeEvent:0,visibilityChangeEvent:0,touchEvent:0,lastGamepadState:null,lastGamepadStateFrame:null,numGamepadsConnected:0,previousFullscreenElement:null,previousScreenX:null,previousScreenY:null,removeEventListenersRegistered:false,staticInit:function () {
- if (typeof window !== 'undefined') {
- window.addEventListener("gamepadconnected", function() { ++JSEvents.numGamepadsConnected; });
- window.addEventListener("gamepaddisconnected", function() { --JSEvents.numGamepadsConnected; });
-
- // Chromium does not fire the gamepadconnected event on reload, so we need to get the number of gamepads here as a workaround.
- // See https://bugs.chromium.org/p/chromium/issues/detail?id=502824
- var firstState = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : null);
- if (firstState) {
- JSEvents.numGamepadsConnected = firstState.length;
- }
- }
- },registerRemoveEventListeners:function () {
- if (!JSEvents.removeEventListenersRegistered) {
- __ATEXIT__.push(function() {
- for(var i = JSEvents.eventHandlers.length-1; i >= 0; --i) {
- JSEvents._removeHandler(i);
- }
- });
- JSEvents.removeEventListenersRegistered = true;
- }
- },findEventTarget:function (target) {
- if (target) {
- if (typeof target == "number") {
- target = Pointer_stringify(target);
- }
- if (target == '#window') return window;
- else if (target == '#document') return document;
- else if (target == '#screen') return window.screen;
- else if (target == '#canvas') return Module['canvas'];
-
- if (typeof target == 'string') return document.getElementById(target);
- else return target;
- } else {
- // The sensible target varies between events, but use window as the default
- // since DOM events mostly can default to that. Specific callback registrations
- // override their own defaults.
- return window;
- }
- },deferredCalls:[],deferCall:function (targetFunction, precedence, argsList) {
- function arraysHaveEqualContent(arrA, arrB) {
- if (arrA.length != arrB.length) return false;
-
- for(var i in arrA) {
- if (arrA[i] != arrB[i]) return false;
- }
- return true;
- }
- // Test if the given call was already queued, and if so, don't add it again.
- for(var i in JSEvents.deferredCalls) {
- var call = JSEvents.deferredCalls[i];
- if (call.targetFunction == targetFunction && arraysHaveEqualContent(call.argsList, argsList)) {
- return;
- }
- }
- JSEvents.deferredCalls.push({
- targetFunction: targetFunction,
- precedence: precedence,
- argsList: argsList
- });
-
- JSEvents.deferredCalls.sort(function(x,y) { return x.precedence < y.precedence; });
- },removeDeferredCalls:function (targetFunction) {
- for(var i = 0; i < JSEvents.deferredCalls.length; ++i) {
- if (JSEvents.deferredCalls[i].targetFunction == targetFunction) {
- JSEvents.deferredCalls.splice(i, 1);
- --i;
- }
- }
- },canPerformEventHandlerRequests:function () {
- return JSEvents.inEventHandler && JSEvents.currentEventHandler.allowsDeferredCalls;
- },runDeferredCalls:function () {
- if (!JSEvents.canPerformEventHandlerRequests()) {
- return;
- }
- for(var i = 0; i < JSEvents.deferredCalls.length; ++i) {
- var call = JSEvents.deferredCalls[i];
- JSEvents.deferredCalls.splice(i, 1);
- --i;
- call.targetFunction.apply(this, call.argsList);
- }
- },inEventHandler:0,currentEventHandler:null,eventHandlers:[],isInternetExplorer:function () { return navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0; },removeAllHandlersOnTarget:function (target, eventTypeString) {
- for(var i = 0; i < JSEvents.eventHandlers.length; ++i) {
- if (JSEvents.eventHandlers[i].target == target &&
- (!eventTypeString || eventTypeString == JSEvents.eventHandlers[i].eventTypeString)) {
- JSEvents._removeHandler(i--);
- }
- }
- },_removeHandler:function (i) {
- var h = JSEvents.eventHandlers[i];
- h.target.removeEventListener(h.eventTypeString, h.eventListenerFunc, h.useCapture);
- JSEvents.eventHandlers.splice(i, 1);
- },registerOrRemoveHandler:function (eventHandler) {
- var jsEventHandler = function jsEventHandler(event) {
- // Increment nesting count for the event handler.
- ++JSEvents.inEventHandler;
- JSEvents.currentEventHandler = eventHandler;
- // Process any old deferred calls the user has placed.
- JSEvents.runDeferredCalls();
- // Process the actual event, calls back to user C code handler.
- eventHandler.handlerFunc(event);
- // Process any new deferred calls that were placed right now from this event handler.
- JSEvents.runDeferredCalls();
- // Out of event handler - restore nesting count.
- --JSEvents.inEventHandler;
- }
-
- if (eventHandler.callbackfunc) {
- eventHandler.eventListenerFunc = jsEventHandler;
- eventHandler.target.addEventListener(eventHandler.eventTypeString, jsEventHandler, eventHandler.useCapture);
- JSEvents.eventHandlers.push(eventHandler);
- JSEvents.registerRemoveEventListeners();
- } else {
- for(var i = 0; i < JSEvents.eventHandlers.length; ++i) {
- if (JSEvents.eventHandlers[i].target == eventHandler.target
- && JSEvents.eventHandlers[i].eventTypeString == eventHandler.eventTypeString) {
- JSEvents._removeHandler(i--);
- }
- }
- }
- },registerKeyEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.keyEvent) {
- JSEvents.keyEvent = _malloc( 164 );
- }
- var handlerFunc = function(event) {
- var e = event || window.event;
- stringToUTF8(e.key ? e.key : "", JSEvents.keyEvent + 0, 32);
- stringToUTF8(e.code ? e.code : "", JSEvents.keyEvent + 32, 32);
- HEAP32[(((JSEvents.keyEvent)+(64))>>2)]=e.location;
- HEAP32[(((JSEvents.keyEvent)+(68))>>2)]=e.ctrlKey;
- HEAP32[(((JSEvents.keyEvent)+(72))>>2)]=e.shiftKey;
- HEAP32[(((JSEvents.keyEvent)+(76))>>2)]=e.altKey;
- HEAP32[(((JSEvents.keyEvent)+(80))>>2)]=e.metaKey;
- HEAP32[(((JSEvents.keyEvent)+(84))>>2)]=e.repeat;
- stringToUTF8(e.locale ? e.locale : "", JSEvents.keyEvent + 88, 32);
- stringToUTF8(e.char ? e.char : "", JSEvents.keyEvent + 120, 32);
- HEAP32[(((JSEvents.keyEvent)+(152))>>2)]=e.charCode;
- HEAP32[(((JSEvents.keyEvent)+(156))>>2)]=e.keyCode;
- HEAP32[(((JSEvents.keyEvent)+(160))>>2)]=e.which;
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.keyEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: JSEvents.findEventTarget(target),
- allowsDeferredCalls: JSEvents.isInternetExplorer() ? false : true, // MSIE doesn't allow fullscreen and pointerlock requests from key handlers, others do.
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },getBoundingClientRectOrZeros:function (target) {
- return target.getBoundingClientRect ? target.getBoundingClientRect() : { left: 0, top: 0 };
- },fillMouseEventData:function (eventStruct, e, target) {
- HEAPF64[((eventStruct)>>3)]=JSEvents.tick();
- HEAP32[(((eventStruct)+(8))>>2)]=e.screenX;
- HEAP32[(((eventStruct)+(12))>>2)]=e.screenY;
- HEAP32[(((eventStruct)+(16))>>2)]=e.clientX;
- HEAP32[(((eventStruct)+(20))>>2)]=e.clientY;
- HEAP32[(((eventStruct)+(24))>>2)]=e.ctrlKey;
- HEAP32[(((eventStruct)+(28))>>2)]=e.shiftKey;
- HEAP32[(((eventStruct)+(32))>>2)]=e.altKey;
- HEAP32[(((eventStruct)+(36))>>2)]=e.metaKey;
- HEAP16[(((eventStruct)+(40))>>1)]=e.button;
- HEAP16[(((eventStruct)+(42))>>1)]=e.buttons;
- HEAP32[(((eventStruct)+(44))>>2)]=e["movementX"] || e["mozMovementX"] || e["webkitMovementX"] || (e.screenX-JSEvents.previousScreenX);
- HEAP32[(((eventStruct)+(48))>>2)]=e["movementY"] || e["mozMovementY"] || e["webkitMovementY"] || (e.screenY-JSEvents.previousScreenY);
-
- if (Module['canvas']) {
- var rect = Module['canvas'].getBoundingClientRect();
- HEAP32[(((eventStruct)+(60))>>2)]=e.clientX - rect.left;
- HEAP32[(((eventStruct)+(64))>>2)]=e.clientY - rect.top;
- } else { // Canvas is not initialized, return 0.
- HEAP32[(((eventStruct)+(60))>>2)]=0;
- HEAP32[(((eventStruct)+(64))>>2)]=0;
- }
- if (target) {
- var rect = JSEvents.getBoundingClientRectOrZeros(target);
- HEAP32[(((eventStruct)+(52))>>2)]=e.clientX - rect.left;
- HEAP32[(((eventStruct)+(56))>>2)]=e.clientY - rect.top;
- } else { // No specific target passed, return 0.
- HEAP32[(((eventStruct)+(52))>>2)]=0;
- HEAP32[(((eventStruct)+(56))>>2)]=0;
- }
- // wheel and mousewheel events contain wrong screenX/screenY on chrome/opera
- // https://github.com/kripken/emscripten/pull/4997
- // https://bugs.chromium.org/p/chromium/issues/detail?id=699956
- if (e.type !== 'wheel' && e.type !== 'mousewheel') {
- JSEvents.previousScreenX = e.screenX;
- JSEvents.previousScreenY = e.screenY;
- }
- },registerMouseEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.mouseEvent) {
- JSEvents.mouseEvent = _malloc( 72 );
- }
- target = JSEvents.findEventTarget(target);
- var handlerFunc = function(event) {
- var e = event || window.event;
- JSEvents.fillMouseEventData(JSEvents.mouseEvent, e, target);
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.mouseEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: target,
- allowsDeferredCalls: eventTypeString != 'mousemove' && eventTypeString != 'mouseenter' && eventTypeString != 'mouseleave', // Mouse move events do not allow fullscreen/pointer lock requests to be handled in them!
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- // In IE, mousedown events don't either allow deferred calls to be run!
- if (JSEvents.isInternetExplorer() && eventTypeString == 'mousedown') eventHandler.allowsDeferredCalls = false;
- JSEvents.registerOrRemoveHandler(eventHandler);
- },registerWheelEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.wheelEvent) {
- JSEvents.wheelEvent = _malloc( 104 );
- }
- target = JSEvents.findEventTarget(target);
- // The DOM Level 3 events spec event 'wheel'
- var wheelHandlerFunc = function(event) {
- var e = event || window.event;
- JSEvents.fillMouseEventData(JSEvents.wheelEvent, e, target);
- HEAPF64[(((JSEvents.wheelEvent)+(72))>>3)]=e["deltaX"];
- HEAPF64[(((JSEvents.wheelEvent)+(80))>>3)]=e["deltaY"];
- HEAPF64[(((JSEvents.wheelEvent)+(88))>>3)]=e["deltaZ"];
- HEAP32[(((JSEvents.wheelEvent)+(96))>>2)]=e["deltaMode"];
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.wheelEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
- // The 'mousewheel' event as implemented in Safari 6.0.5
- var mouseWheelHandlerFunc = function(event) {
- var e = event || window.event;
- JSEvents.fillMouseEventData(JSEvents.wheelEvent, e, target);
- HEAPF64[(((JSEvents.wheelEvent)+(72))>>3)]=e["wheelDeltaX"] || 0;
- HEAPF64[(((JSEvents.wheelEvent)+(80))>>3)]=-(e["wheelDeltaY"] ? e["wheelDeltaY"] : e["wheelDelta"]) /* 1. Invert to unify direction with the DOM Level 3 wheel event. 2. MSIE does not provide wheelDeltaY, so wheelDelta is used as a fallback. */;
- HEAPF64[(((JSEvents.wheelEvent)+(88))>>3)]=0 /* Not available */;
- HEAP32[(((JSEvents.wheelEvent)+(96))>>2)]=0 /* DOM_DELTA_PIXEL */;
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.wheelEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: target,
- allowsDeferredCalls: true,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: (eventTypeString == 'wheel') ? wheelHandlerFunc : mouseWheelHandlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },pageScrollPos:function () {
- if (window.pageXOffset > 0 || window.pageYOffset > 0) {
- return [window.pageXOffset, window.pageYOffset];
- }
- if (typeof document.documentElement.scrollLeft !== 'undefined' || typeof document.documentElement.scrollTop !== 'undefined') {
- return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
- }
- return [document.body.scrollLeft|0, document.body.scrollTop|0];
- },registerUiEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.uiEvent) {
- JSEvents.uiEvent = _malloc( 36 );
- }
-
- if (eventTypeString == "scroll" && !target) {
- target = document; // By default read scroll events on document rather than window.
- } else {
- target = JSEvents.findEventTarget(target);
- }
-
- var handlerFunc = function(event) {
- var e = event || window.event;
- if (e.target != target) {
- // Never take ui events such as scroll via a 'bubbled' route, but always from the direct element that
- // was targeted. Otherwise e.g. if app logs a message in response to a page scroll, the Emscripten log
- // message box could cause to scroll, generating a new (bubbled) scroll message, causing a new log print,
- // causing a new scroll, etc..
- return;
- }
- var scrollPos = JSEvents.pageScrollPos();
- HEAP32[((JSEvents.uiEvent)>>2)]=e.detail;
- HEAP32[(((JSEvents.uiEvent)+(4))>>2)]=document.body.clientWidth;
- HEAP32[(((JSEvents.uiEvent)+(8))>>2)]=document.body.clientHeight;
- HEAP32[(((JSEvents.uiEvent)+(12))>>2)]=window.innerWidth;
- HEAP32[(((JSEvents.uiEvent)+(16))>>2)]=window.innerHeight;
- HEAP32[(((JSEvents.uiEvent)+(20))>>2)]=window.outerWidth;
- HEAP32[(((JSEvents.uiEvent)+(24))>>2)]=window.outerHeight;
- HEAP32[(((JSEvents.uiEvent)+(28))>>2)]=scrollPos[0];
- HEAP32[(((JSEvents.uiEvent)+(32))>>2)]=scrollPos[1];
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.uiEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: target,
- allowsDeferredCalls: false, // Neither scroll or resize events allow running requests inside them.
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },getNodeNameForTarget:function (target) {
- if (!target) return '';
- if (target == window) return '#window';
- if (target == window.screen) return '#screen';
- return (target && target.nodeName) ? target.nodeName : '';
- },registerFocusEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.focusEvent) {
- JSEvents.focusEvent = _malloc( 256 );
- }
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- var nodeName = JSEvents.getNodeNameForTarget(e.target);
- var id = e.target.id ? e.target.id : '';
- stringToUTF8(nodeName, JSEvents.focusEvent + 0, 128);
- stringToUTF8(id, JSEvents.focusEvent + 128, 128);
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.focusEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: JSEvents.findEventTarget(target),
- allowsDeferredCalls: false,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },tick:function () {
- if (window['performance'] && window['performance']['now']) return window['performance']['now']();
- else return Date.now();
- },registerDeviceOrientationEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.deviceOrientationEvent) {
- JSEvents.deviceOrientationEvent = _malloc( 40 );
- }
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- HEAPF64[((JSEvents.deviceOrientationEvent)>>3)]=JSEvents.tick();
- HEAPF64[(((JSEvents.deviceOrientationEvent)+(8))>>3)]=e.alpha;
- HEAPF64[(((JSEvents.deviceOrientationEvent)+(16))>>3)]=e.beta;
- HEAPF64[(((JSEvents.deviceOrientationEvent)+(24))>>3)]=e.gamma;
- HEAP32[(((JSEvents.deviceOrientationEvent)+(32))>>2)]=e.absolute;
-
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.deviceOrientationEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: JSEvents.findEventTarget(target),
- allowsDeferredCalls: false,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },registerDeviceMotionEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.deviceMotionEvent) {
- JSEvents.deviceMotionEvent = _malloc( 80 );
- }
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- HEAPF64[((JSEvents.deviceMotionEvent)>>3)]=JSEvents.tick();
- HEAPF64[(((JSEvents.deviceMotionEvent)+(8))>>3)]=e.acceleration.x;
- HEAPF64[(((JSEvents.deviceMotionEvent)+(16))>>3)]=e.acceleration.y;
- HEAPF64[(((JSEvents.deviceMotionEvent)+(24))>>3)]=e.acceleration.z;
- HEAPF64[(((JSEvents.deviceMotionEvent)+(32))>>3)]=e.accelerationIncludingGravity.x;
- HEAPF64[(((JSEvents.deviceMotionEvent)+(40))>>3)]=e.accelerationIncludingGravity.y;
- HEAPF64[(((JSEvents.deviceMotionEvent)+(48))>>3)]=e.accelerationIncludingGravity.z;
- HEAPF64[(((JSEvents.deviceMotionEvent)+(56))>>3)]=e.rotationRate.alpha;
- HEAPF64[(((JSEvents.deviceMotionEvent)+(64))>>3)]=e.rotationRate.beta;
- HEAPF64[(((JSEvents.deviceMotionEvent)+(72))>>3)]=e.rotationRate.gamma;
-
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.deviceMotionEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: JSEvents.findEventTarget(target),
- allowsDeferredCalls: false,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },screenOrientation:function () {
- if (!window.screen) return undefined;
- return window.screen.orientation || window.screen.mozOrientation || window.screen.webkitOrientation || window.screen.msOrientation;
- },fillOrientationChangeEventData:function (eventStruct, e) {
- var orientations = ["portrait-primary", "portrait-secondary", "landscape-primary", "landscape-secondary"];
- var orientations2 = ["portrait", "portrait", "landscape", "landscape"];
-
- var orientationString = JSEvents.screenOrientation();
- var orientation = orientations.indexOf(orientationString);
- if (orientation == -1) {
- orientation = orientations2.indexOf(orientationString);
- }
-
- HEAP32[((eventStruct)>>2)]=1 << orientation;
- HEAP32[(((eventStruct)+(4))>>2)]=window.orientation;
- },registerOrientationChangeEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.orientationChangeEvent) {
- JSEvents.orientationChangeEvent = _malloc( 8 );
- }
-
- if (!target) {
- target = window.screen; // Orientation events need to be captured from 'window.screen' instead of 'window'
- } else {
- target = JSEvents.findEventTarget(target);
- }
-
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- JSEvents.fillOrientationChangeEventData(JSEvents.orientationChangeEvent, e);
-
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.orientationChangeEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- if (eventTypeString == "orientationchange" && window.screen.mozOrientation !== undefined) {
- eventTypeString = "mozorientationchange";
- }
-
- var eventHandler = {
- target: target,
- allowsDeferredCalls: false,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },fullscreenEnabled:function () {
- return document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled || document.msFullscreenEnabled;
- },fillFullscreenChangeEventData:function (eventStruct, e) {
- var fullscreenElement = document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement;
- var isFullscreen = !!fullscreenElement;
- HEAP32[((eventStruct)>>2)]=isFullscreen;
- HEAP32[(((eventStruct)+(4))>>2)]=JSEvents.fullscreenEnabled();
- // If transitioning to fullscreen, report info about the element that is now fullscreen.
- // If transitioning to windowed mode, report info about the element that just was fullscreen.
- var reportedElement = isFullscreen ? fullscreenElement : JSEvents.previousFullscreenElement;
- var nodeName = JSEvents.getNodeNameForTarget(reportedElement);
- var id = (reportedElement && reportedElement.id) ? reportedElement.id : '';
- stringToUTF8(nodeName, eventStruct + 8, 128);
- stringToUTF8(id, eventStruct + 136, 128);
- HEAP32[(((eventStruct)+(264))>>2)]=reportedElement ? reportedElement.clientWidth : 0;
- HEAP32[(((eventStruct)+(268))>>2)]=reportedElement ? reportedElement.clientHeight : 0;
- HEAP32[(((eventStruct)+(272))>>2)]=screen.width;
- HEAP32[(((eventStruct)+(276))>>2)]=screen.height;
- if (isFullscreen) {
- JSEvents.previousFullscreenElement = fullscreenElement;
- }
- },registerFullscreenChangeEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.fullscreenChangeEvent) {
- JSEvents.fullscreenChangeEvent = _malloc( 280 );
- }
-
- if (!target) {
- target = document; // Fullscreen change events need to be captured from 'document' by default instead of 'window'
- } else {
- target = JSEvents.findEventTarget(target);
- }
-
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- JSEvents.fillFullscreenChangeEventData(JSEvents.fullscreenChangeEvent, e);
-
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.fullscreenChangeEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: target,
- allowsDeferredCalls: false,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },resizeCanvasForFullscreen:function (target, strategy) {
- var restoreOldStyle = __registerRestoreOldStyle(target);
- var cssWidth = strategy.softFullscreen ? window.innerWidth : screen.width;
- var cssHeight = strategy.softFullscreen ? window.innerHeight : screen.height;
- var rect = target.getBoundingClientRect();
- var windowedCssWidth = rect.right - rect.left;
- var windowedCssHeight = rect.bottom - rect.top;
- var windowedRttWidth = target.width;
- var windowedRttHeight = target.height;
-
- if (strategy.scaleMode == 3) {
- __setLetterbox(target, (cssHeight - windowedCssHeight) / 2, (cssWidth - windowedCssWidth) / 2);
- cssWidth = windowedCssWidth;
- cssHeight = windowedCssHeight;
- } else if (strategy.scaleMode == 2) {
- if (cssWidth*windowedRttHeight < windowedRttWidth*cssHeight) {
- var desiredCssHeight = windowedRttHeight * cssWidth / windowedRttWidth;
- __setLetterbox(target, (cssHeight - desiredCssHeight) / 2, 0);
- cssHeight = desiredCssHeight;
- } else {
- var desiredCssWidth = windowedRttWidth * cssHeight / windowedRttHeight;
- __setLetterbox(target, 0, (cssWidth - desiredCssWidth) / 2);
- cssWidth = desiredCssWidth;
- }
- }
-
- // If we are adding padding, must choose a background color or otherwise Chrome will give the
- // padding a default white color. Do it only if user has not customized their own background color.
- if (!target.style.backgroundColor) target.style.backgroundColor = 'black';
- // IE11 does the same, but requires the color to be set in the document body.
- if (!document.body.style.backgroundColor) document.body.style.backgroundColor = 'black'; // IE11
- // Firefox always shows black letterboxes independent of style color.
-
- target.style.width = cssWidth + 'px';
- target.style.height = cssHeight + 'px';
-
- if (strategy.filteringMode == 1) {
- target.style.imageRendering = 'optimizeSpeed';
- target.style.imageRendering = '-moz-crisp-edges';
- target.style.imageRendering = '-o-crisp-edges';
- target.style.imageRendering = '-webkit-optimize-contrast';
- target.style.imageRendering = 'optimize-contrast';
- target.style.imageRendering = 'crisp-edges';
- target.style.imageRendering = 'pixelated';
- }
-
- var dpiScale = (strategy.canvasResolutionScaleMode == 2) ? window.devicePixelRatio : 1;
- if (strategy.canvasResolutionScaleMode != 0) {
- target.width = cssWidth * dpiScale;
- target.height = cssHeight * dpiScale;
- if (target.GLctxObject) target.GLctxObject.GLctx.viewport(0, 0, target.width, target.height);
- }
- return restoreOldStyle;
- },requestFullscreen:function (target, strategy) {
- // EMSCRIPTEN_FULLSCREEN_SCALE_DEFAULT + EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_NONE is a mode where no extra logic is performed to the DOM elements.
- if (strategy.scaleMode != 0 || strategy.canvasResolutionScaleMode != 0) {
- JSEvents.resizeCanvasForFullscreen(target, strategy);
- }
-
- if (target.requestFullscreen) {
- target.requestFullscreen();
- } else if (target.msRequestFullscreen) {
- target.msRequestFullscreen();
- } else if (target.mozRequestFullScreen) {
- target.mozRequestFullScreen();
- } else if (target.mozRequestFullscreen) {
- target.mozRequestFullscreen();
- } else if (target.webkitRequestFullscreen) {
- target.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
- } else {
- if (typeof JSEvents.fullscreenEnabled() === 'undefined') {
- return -1;
- } else {
- return -3;
- }
- }
-
- if (strategy.canvasResizedCallback) {
- Module['dynCall_iiii'](strategy.canvasResizedCallback, 37, 0, strategy.canvasResizedCallbackUserData);
- }
-
- return 0;
- },fillPointerlockChangeEventData:function (eventStruct, e) {
- var pointerLockElement = document.pointerLockElement || document.mozPointerLockElement || document.webkitPointerLockElement || document.msPointerLockElement;
- var isPointerlocked = !!pointerLockElement;
- HEAP32[((eventStruct)>>2)]=isPointerlocked;
- var nodeName = JSEvents.getNodeNameForTarget(pointerLockElement);
- var id = (pointerLockElement && pointerLockElement.id) ? pointerLockElement.id : '';
- stringToUTF8(nodeName, eventStruct + 4, 128);
- stringToUTF8(id, eventStruct + 132, 128);
- },registerPointerlockChangeEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.pointerlockChangeEvent) {
- JSEvents.pointerlockChangeEvent = _malloc( 260 );
- }
-
- if (!target) {
- target = document; // Pointer lock change events need to be captured from 'document' by default instead of 'window'
- } else {
- target = JSEvents.findEventTarget(target);
- }
-
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- JSEvents.fillPointerlockChangeEventData(JSEvents.pointerlockChangeEvent, e);
-
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.pointerlockChangeEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: target,
- allowsDeferredCalls: false,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },registerPointerlockErrorEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!target) {
- target = document; // Pointer lock events need to be captured from 'document' by default instead of 'window'
- } else {
- target = JSEvents.findEventTarget(target);
- }
-
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, 0, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: target,
- allowsDeferredCalls: false,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },requestPointerLock:function (target) {
- if (target.requestPointerLock) {
- target.requestPointerLock();
- } else if (target.mozRequestPointerLock) {
- target.mozRequestPointerLock();
- } else if (target.webkitRequestPointerLock) {
- target.webkitRequestPointerLock();
- } else if (target.msRequestPointerLock) {
- target.msRequestPointerLock();
- } else {
- // document.body is known to accept pointer lock, so use that to differentiate if the user passed a bad element,
- // or if the whole browser just doesn't support the feature.
- if (document.body.requestPointerLock || document.body.mozRequestPointerLock || document.body.webkitRequestPointerLock || document.body.msRequestPointerLock) {
- return -3;
- } else {
- return -1;
- }
- }
- return 0;
- },fillVisibilityChangeEventData:function (eventStruct, e) {
- var visibilityStates = [ "hidden", "visible", "prerender", "unloaded" ];
- var visibilityState = visibilityStates.indexOf(document.visibilityState);
-
- HEAP32[((eventStruct)>>2)]=document.hidden;
- HEAP32[(((eventStruct)+(4))>>2)]=visibilityState;
- },registerVisibilityChangeEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.visibilityChangeEvent) {
- JSEvents.visibilityChangeEvent = _malloc( 8 );
- }
-
- if (!target) {
- target = document; // Visibility change events need to be captured from 'document' by default instead of 'window'
- } else {
- target = JSEvents.findEventTarget(target);
- }
-
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- JSEvents.fillVisibilityChangeEventData(JSEvents.visibilityChangeEvent, e);
-
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.visibilityChangeEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: target,
- allowsDeferredCalls: false,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },registerTouchEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.touchEvent) {
- JSEvents.touchEvent = _malloc( 1684 );
- }
-
- target = JSEvents.findEventTarget(target);
-
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- var touches = {};
- for(var i = 0; i < e.touches.length; ++i) {
- var touch = e.touches[i];
- touches[touch.identifier] = touch;
- }
- for(var i = 0; i < e.changedTouches.length; ++i) {
- var touch = e.changedTouches[i];
- touches[touch.identifier] = touch;
- touch.changed = true;
- }
- for(var i = 0; i < e.targetTouches.length; ++i) {
- var touch = e.targetTouches[i];
- touches[touch.identifier].onTarget = true;
- }
-
- var ptr = JSEvents.touchEvent;
- HEAP32[(((ptr)+(4))>>2)]=e.ctrlKey;
- HEAP32[(((ptr)+(8))>>2)]=e.shiftKey;
- HEAP32[(((ptr)+(12))>>2)]=e.altKey;
- HEAP32[(((ptr)+(16))>>2)]=e.metaKey;
- ptr += 20; // Advance to the start of the touch array.
- var canvasRect = Module['canvas'] ? Module['canvas'].getBoundingClientRect() : undefined;
- var targetRect = JSEvents.getBoundingClientRectOrZeros(target);
- var numTouches = 0;
- for(var i in touches) {
- var t = touches[i];
- HEAP32[((ptr)>>2)]=t.identifier;
- HEAP32[(((ptr)+(4))>>2)]=t.screenX;
- HEAP32[(((ptr)+(8))>>2)]=t.screenY;
- HEAP32[(((ptr)+(12))>>2)]=t.clientX;
- HEAP32[(((ptr)+(16))>>2)]=t.clientY;
- HEAP32[(((ptr)+(20))>>2)]=t.pageX;
- HEAP32[(((ptr)+(24))>>2)]=t.pageY;
- HEAP32[(((ptr)+(28))>>2)]=t.changed;
- HEAP32[(((ptr)+(32))>>2)]=t.onTarget;
- if (canvasRect) {
- HEAP32[(((ptr)+(44))>>2)]=t.clientX - canvasRect.left;
- HEAP32[(((ptr)+(48))>>2)]=t.clientY - canvasRect.top;
- } else {
- HEAP32[(((ptr)+(44))>>2)]=0;
- HEAP32[(((ptr)+(48))>>2)]=0;
- }
- HEAP32[(((ptr)+(36))>>2)]=t.clientX - targetRect.left;
- HEAP32[(((ptr)+(40))>>2)]=t.clientY - targetRect.top;
-
- ptr += 52;
-
- if (++numTouches >= 32) {
- break;
- }
- }
- HEAP32[((JSEvents.touchEvent)>>2)]=numTouches;
-
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.touchEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: target,
- allowsDeferredCalls: eventTypeString == 'touchstart' || eventTypeString == 'touchend',
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },fillGamepadEventData:function (eventStruct, e) {
- HEAPF64[((eventStruct)>>3)]=e.timestamp;
- for(var i = 0; i < e.axes.length; ++i) {
- HEAPF64[(((eventStruct+i*8)+(16))>>3)]=e.axes[i];
- }
- for(var i = 0; i < e.buttons.length; ++i) {
- if (typeof(e.buttons[i]) === 'object') {
- HEAPF64[(((eventStruct+i*8)+(528))>>3)]=e.buttons[i].value;
- } else {
- HEAPF64[(((eventStruct+i*8)+(528))>>3)]=e.buttons[i];
- }
- }
- for(var i = 0; i < e.buttons.length; ++i) {
- if (typeof(e.buttons[i]) === 'object') {
- HEAP32[(((eventStruct+i*4)+(1040))>>2)]=e.buttons[i].pressed;
- } else {
- HEAP32[(((eventStruct+i*4)+(1040))>>2)]=e.buttons[i] == 1.0;
- }
- }
- HEAP32[(((eventStruct)+(1296))>>2)]=e.connected;
- HEAP32[(((eventStruct)+(1300))>>2)]=e.index;
- HEAP32[(((eventStruct)+(8))>>2)]=e.axes.length;
- HEAP32[(((eventStruct)+(12))>>2)]=e.buttons.length;
- stringToUTF8(e.id, eventStruct + 1304, 64);
- stringToUTF8(e.mapping, eventStruct + 1368, 64);
- },registerGamepadEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.gamepadEvent) {
- JSEvents.gamepadEvent = _malloc( 1432 );
- }
-
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- JSEvents.fillGamepadEventData(JSEvents.gamepadEvent, e.gamepad);
-
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.gamepadEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: JSEvents.findEventTarget(target),
- allowsDeferredCalls: true,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },registerBeforeUnloadEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- var confirmationMessage = Module['dynCall_iiii'](callbackfunc, eventTypeId, 0, userData);
-
- if (confirmationMessage) {
- confirmationMessage = Pointer_stringify(confirmationMessage);
- }
- if (confirmationMessage) {
- e.preventDefault();
- e.returnValue = confirmationMessage;
- return confirmationMessage;
- }
- };
-
- var eventHandler = {
- target: JSEvents.findEventTarget(target),
- allowsDeferredCalls: false,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },battery:function () { return navigator.battery || navigator.mozBattery || navigator.webkitBattery; },fillBatteryEventData:function (eventStruct, e) {
- HEAPF64[((eventStruct)>>3)]=e.chargingTime;
- HEAPF64[(((eventStruct)+(8))>>3)]=e.dischargingTime;
- HEAPF64[(((eventStruct)+(16))>>3)]=e.level;
- HEAP32[(((eventStruct)+(24))>>2)]=e.charging;
- },registerBatteryEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!JSEvents.batteryEvent) {
- JSEvents.batteryEvent = _malloc( 32 );
- }
-
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- JSEvents.fillBatteryEventData(JSEvents.batteryEvent, JSEvents.battery());
-
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.batteryEvent, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: JSEvents.findEventTarget(target),
- allowsDeferredCalls: false,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- },registerWebGlEventCallback:function (target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) {
- if (!target) {
- target = Module['canvas'];
- }
- var handlerFunc = function(event) {
- var e = event || window.event;
-
- var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, 0, userData);
- if (shouldCancel) {
- e.preventDefault();
- }
- };
-
- var eventHandler = {
- target: JSEvents.findEventTarget(target),
- allowsDeferredCalls: false,
- eventTypeString: eventTypeString,
- callbackfunc: callbackfunc,
- handlerFunc: handlerFunc,
- useCapture: useCapture
- };
- JSEvents.registerOrRemoveHandler(eventHandler);
- }};function __emscripten_sample_gamepad_data() {
- // Polling gamepads generates garbage, so don't do it when we know there are no gamepads connected.
- if (!JSEvents.numGamepadsConnected) return;
-
- // Produce a new Gamepad API sample if we are ticking a new game frame, or if not using emscripten_set_main_loop() at all to drive animation.
- if (Browser.mainLoop.currentFrameNumber !== JSEvents.lastGamepadStateFrame || !Browser.mainLoop.currentFrameNumber) {
- JSEvents.lastGamepadState = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : null);
- JSEvents.lastGamepadStateFrame = Browser.mainLoop.currentFrameNumber;
- }
- }function _emscripten_get_gamepad_status(index, gamepadState) {
- __emscripten_sample_gamepad_data();
- if (!JSEvents.lastGamepadState) return -1;
-
- // INVALID_PARAM is returned on a Gamepad index that never was there.
- if (index < 0 || index >= JSEvents.lastGamepadState.length) return -5;
-
- // NO_DATA is returned on a Gamepad index that was removed.
- // For previously disconnected gamepads there should be an empty slot (null/undefined/false) at the index.
- // This is because gamepads must keep their original position in the array.
- // For example, removing the first of two gamepads produces [null/undefined/false, gamepad].
- if (!JSEvents.lastGamepadState[index]) return -7;
-
- JSEvents.fillGamepadEventData(gamepadState, JSEvents.lastGamepadState[index]);
- return 0;
- }
-
- var _llvm_pow_f64=Math_pow;
-
- function _emscripten_glCopyTexImage2D(x0, x1, x2, x3, x4, x5, x6, x7) { GLctx['copyTexImage2D'](x0, x1, x2, x3, x4, x5, x6, x7) }
-
- function _emscripten_glTexParameterfv(target, pname, params) {
- var param = HEAPF32[((params)>>2)];
- GLctx.texParameterf(target, pname, param);
- }
-
-
-
-
-
-
-
-
-
- function _SDL_CloseAudio() {
- if (SDL.audio) {
- _SDL_PauseAudio(1);
- _free(SDL.audio.buffer);
- SDL.audio = null;
- SDL.allocateChannels(0);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- var _environ=STATICTOP; STATICTOP += 16;;var ___environ=_environ;function ___buildEnvironment(env) {
- // WARNING: Arbitrary limit!
- var MAX_ENV_VALUES = 64;
- var TOTAL_ENV_SIZE = 1024;
-
- // Statically allocate memory for the environment.
- var poolPtr;
- var envPtr;
- if (!___buildEnvironment.called) {
- ___buildEnvironment.called = true;
- // Set default values. Use string keys for Closure Compiler compatibility.
- ENV['USER'] = ENV['LOGNAME'] = 'web_user';
- ENV['PATH'] = '/';
- ENV['PWD'] = '/';
- ENV['HOME'] = '/home/web_user';
- ENV['LANG'] = 'C';
- ENV['_'] = Module['thisProgram'];
- // Allocate memory.
- poolPtr = allocate(TOTAL_ENV_SIZE, 'i8', ALLOC_STATIC);
- envPtr = allocate(MAX_ENV_VALUES * 4,
- 'i8*', ALLOC_STATIC);
- HEAP32[((envPtr)>>2)]=poolPtr;
- HEAP32[((_environ)>>2)]=envPtr;
- } else {
- envPtr = HEAP32[((_environ)>>2)];
- poolPtr = HEAP32[((envPtr)>>2)];
- }
-
- // Collect key=value lines.
- var strings = [];
- var totalSize = 0;
- for (var key in env) {
- if (typeof env[key] === 'string') {
- var line = key + '=' + env[key];
- strings.push(line);
- totalSize += line.length;
- }
- }
- if (totalSize > TOTAL_ENV_SIZE) {
- throw new Error('Environment size exceeded TOTAL_ENV_SIZE!');
- }
-
- // Make new.
- var ptrSize = 4;
- for (var i = 0; i < strings.length; i++) {
- var line = strings[i];
- writeAsciiToMemory(line, poolPtr);
- HEAP32[(((envPtr)+(i * ptrSize))>>2)]=poolPtr;
- poolPtr += line.length + 1;
- }
- HEAP32[(((envPtr)+(strings.length * ptrSize))>>2)]=0;
- }var ENV={};function _getenv(name) {
- // char *getenv(const char *name);
- // http://pubs.opengroup.org/onlinepubs/009695399/functions/getenv.html
- if (name === 0) return 0;
- name = Pointer_stringify(name);
- if (!ENV.hasOwnProperty(name)) return 0;
-
- if (_getenv.ret) _free(_getenv.ret);
- _getenv.ret = allocate(intArrayFromString(ENV[name]), 'i8', ALLOC_NORMAL);
- return _getenv.ret;
- }
-
- function _putenv(string) {
- // int putenv(char *string);
- // http://pubs.opengroup.org/onlinepubs/009695399/functions/putenv.html
- // WARNING: According to the standard (and the glibc implementation), the
- // string is taken by reference so future changes are reflected.
- // We copy it instead, possibly breaking some uses.
- if (string === 0) {
- ___setErrNo(ERRNO_CODES.EINVAL);
- return -1;
- }
- string = Pointer_stringify(string);
- var splitPoint = string.indexOf('=')
- if (string === '' || string.indexOf('=') === -1) {
- ___setErrNo(ERRNO_CODES.EINVAL);
- return -1;
- }
- var name = string.slice(0, splitPoint);
- var value = string.slice(splitPoint + 1);
- if (!(name in ENV) || ENV[name] !== value) {
- ENV[name] = value;
- ___buildEnvironment(ENV);
- }
- return 0;
- }
-
- function _SDL_RWFromConstMem(mem, size) {
- var id = SDL.rwops.length; // TODO: recycle ids when they are null
- SDL.rwops.push({ bytes: mem, count: size });
- return id;
- }function _TTF_FontHeight(font) {
- var fontData = SDL.fonts[font];
- return fontData.size;
- }function _TTF_SizeText(font, text, w, h) {
- var fontData = SDL.fonts[font];
- if (w) {
- HEAP32[((w)>>2)]=SDL.estimateTextWidth(fontData, Pointer_stringify(text));
- }
- if (h) {
- HEAP32[((h)>>2)]=fontData.size;
- }
- return 0;
- }function _TTF_RenderText_Solid(font, text, color) {
- // XXX the font and color are ignored
- text = Pointer_stringify(text) || ' '; // if given an empty string, still return a valid surface
- var fontData = SDL.fonts[font];
- var w = SDL.estimateTextWidth(fontData, text);
- var h = fontData.size;
- var color = SDL.loadColorToCSSRGB(color); // XXX alpha breaks fonts?
- var fontString = SDL.makeFontString(h, fontData.name);
- var surf = SDL.makeSurface(w, h, 0, false, 'text:' + text); // bogus numbers..
- var surfData = SDL.surfaces[surf];
- surfData.ctx.save();
- surfData.ctx.fillStyle = color;
- surfData.ctx.font = fontString;
- // use bottom alligment, because it works
- // same in all browsers, more info here:
- // https://bugzilla.mozilla.org/show_bug.cgi?id=737852
- surfData.ctx.textBaseline = 'bottom';
- surfData.ctx.fillText(text, 0, h|0);
- surfData.ctx.restore();
- return surf;
- }function _Mix_HaltMusic() {
- var audio = SDL.music.audio;
- if (audio) {
- audio.src = audio.src; // rewind element
- audio.currentPosition = 0; // rewind Web Audio graph playback.
- audio.pause();
- }
- SDL.music.audio = null;
- if (SDL.hookMusicFinished) {
- func();
- }
- return 0;
- }function _Mix_PlayMusic(id, loops) {
- // Pause old music if it exists.
- if (SDL.music.audio) {
- if (!SDL.music.audio.paused) Module.printErr('Music is already playing. ' + SDL.music.source);
- SDL.music.audio.pause();
- }
- var info = SDL.audios[id];
- var audio;
- if (info.webAudio) { // Play via Web Audio API
- // Create an instance of the WebAudio object.
- audio = {};
- audio.resource = info; // This new webAudio object is an instance that refers to this existing resource.
- audio.paused = false;
- audio.currentPosition = 0;
- audio.play = function() { SDL.playWebAudio(this); }
- audio.pause = function() { SDL.pauseWebAudio(this); }
- } else if (info.audio) { // Play via the