From 991f3ab8291c58a6e30cbf2dee46701377ef6cc3 Mon Sep 17 00:00:00 2001 From: maxgraey Date: Tue, 27 Jun 2017 20:39:36 +0300 Subject: [PATCH] additional options. --- .gitignore | 1 + lib/turboscript.js | 102 ++++++++++++++++--------------- lib/turboscript.min.js | 2 +- src/compiler/compiler-options.ts | 6 +- src/compiler/compiler.ts | 8 ++- src/turboscript.ts | 8 ++- 6 files changed, 72 insertions(+), 55 deletions(-) diff --git a/.gitignore b/.gitignore index 1fc8a46..de91765 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ node-v8/ *.swp src/**/*.js *.js.map +.turbo /TurboScript.iml !src/library/asmjs/runtime.js !src/library/webassembly/wrapper.js diff --git a/lib/turboscript.js b/lib/turboscript.js index 136cbec..8804744 100644 --- a/lib/turboscript.js +++ b/lib/turboscript.js @@ -1514,8 +1514,8 @@ var WasmSection; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var env_1 = __webpack_require__(20); -var color_1 = __webpack_require__(19); +var env_1 = __webpack_require__(21); +var color_1 = __webpack_require__(20); /** * Created by n.vinayakan on 06.06.17. */ @@ -1660,7 +1660,7 @@ exports.assert = assert; Object.defineProperty(exports, "__esModule", { value: true }); var bytearray_1 = __webpack_require__(0); var logger_1 = __webpack_require__(27); -var stringbuilder_1 = __webpack_require__(21); +var stringbuilder_1 = __webpack_require__(22); var wasm_section_1 = __webpack_require__(1); var utils_1 = __webpack_require__(8); /** @@ -1715,7 +1715,7 @@ exports.WasmSectionBinary = WasmSectionBinary; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var color_1 = __webpack_require__(19); +var color_1 = __webpack_require__(20); var assert_1 = __webpack_require__(3); var terminal_1 = __webpack_require__(2); var LineColumn = (function () { @@ -3941,7 +3941,7 @@ Object.freeze(exports.WasmOpcode); "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var bitness_1 = __webpack_require__(22); +var bitness_1 = __webpack_require__(16); var wasm_type_1 = __webpack_require__(6); var symbol_1 = __webpack_require__(7); /** @@ -4832,7 +4832,7 @@ exports.tokenize = tokenize; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var env_1 = __webpack_require__(20); +var env_1 = __webpack_require__(21); var terminal_1 = __webpack_require__(2); /** * Created by n.vinayakan on 06.06.17. @@ -4947,9 +4947,26 @@ exports.FileSystem = FileSystem; "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Created by n.vinayakan on 02.06.17. + */ +var Bitness; +(function (Bitness) { + Bitness[Bitness["x32"] = 0] = "x32"; + Bitness[Bitness["x64"] = 1] = "x64"; +})(Bitness = exports.Bitness || (exports.Bitness = {})); + + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); var wasm_type_1 = __webpack_require__(6); -var stringbuilder_1 = __webpack_require__(21); +var stringbuilder_1 = __webpack_require__(22); /** * Created by n.vinayakan on 02.06.17. */ @@ -4974,7 +4991,7 @@ exports.WasmFunction = WasmFunction; /***/ }), -/* 17 */ +/* 18 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -5151,7 +5168,7 @@ exports.WasmBinary = WasmBinary; /***/ }), -/* 18 */ +/* 19 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -5167,6 +5184,7 @@ var scanner_1 = __webpack_require__(14); var parser_1 = __webpack_require__(32); var shaking_1 = __webpack_require__(70); var webassembly_1 = __webpack_require__(66); +var bitness_1 = __webpack_require__(16); var library_1 = __webpack_require__(75); var preparser_1 = __webpack_require__(71); var compile_target_1 = __webpack_require__(9); @@ -5178,12 +5196,14 @@ var terminal_1 = __webpack_require__(2); var Compiler = (function () { function Compiler() { } - Compiler.prototype.initialize = function (target, outputName) { + Compiler.prototype.initialize = function (target, outputName, options) { + if (options === void 0) { options = {}; } assert_1.assert(this.log == null); this.log = new log_1.Log(); this.preprocessor = new preprocessor_1.Preprocessor(); Compiler.binaryImports = []; this.target = target; + this.options = options; this.outputName = outputName; this.librarySource = this.addInput("", library_1.Library.get(target)); this.librarySource.isLibrary = true; @@ -5321,7 +5341,8 @@ var Compiler = (function () { // jsEmit(this); // } else if (this.target == compile_target_1.CompileTarget.WEBASSEMBLY) { - webassembly_1.wasmEmit(this); + var _a = this.options, longPtr = _a.longPtr, optimize = _a.optimize; + webassembly_1.wasmEmit(this, longPtr ? bitness_1.Bitness.x64 : bitness_1.Bitness.x32, optimize); } terminal_1.Terminal.timeEnd("emitting"); terminal_1.Terminal.write("Done!"); @@ -5346,7 +5367,7 @@ exports.replaceFileExtension = replaceFileExtension; /***/ }), -/* 19 */ +/* 20 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -5384,7 +5405,7 @@ exports.HexColor = hexColor; /***/ }), -/* 20 */ +/* 21 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -5399,7 +5420,7 @@ exports.isNode = typeof global !== "undefined" && typeof process !== "undefined" /***/ }), -/* 21 */ +/* 22 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -5553,23 +5574,6 @@ var StringBuilder = (function () { exports.StringBuilder = StringBuilder; -/***/ }), -/* 22 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Created by n.vinayakan on 02.06.17. - */ -var Bitness; -(function (Bitness) { - Bitness[Bitness["x32"] = 0] = "x32"; - Bitness[Bitness["x64"] = 1] = "x64"; -})(Bitness = exports.Bitness || (exports.Bitness = {})); - - /***/ }), /* 23 */ /***/ (function(module, exports, __webpack_require__) { @@ -7461,7 +7465,7 @@ exports.parse = parse; Object.defineProperty(exports, "__esModule", { value: true }); var filesystem_1 = __webpack_require__(15); -var wasm_binary_1 = __webpack_require__(17); +var wasm_binary_1 = __webpack_require__(18); var wasm_section_1 = __webpack_require__(1); var wasm_external_kind_1 = __webpack_require__(11); var terminal_1 = __webpack_require__(2); @@ -7536,12 +7540,12 @@ exports.isBinaryImport = isBinaryImport; Object.defineProperty(exports, "__esModule", { value: true }); /// var log_1 = __webpack_require__(5); -var compiler_1 = __webpack_require__(18); +var compiler_1 = __webpack_require__(19); var compile_target_1 = __webpack_require__(9); var terminal_1 = __webpack_require__(2); var filesystem_1 = __webpack_require__(15); var compiler_options_1 = __webpack_require__(68); -var color_1 = __webpack_require__(19); +var color_1 = __webpack_require__(20); /** * TurboScript compiler main entry */ @@ -7569,7 +7573,7 @@ function main_reset() { } exports.main_reset = main_reset; function printUsage() { - terminal_1.Terminal.write("\nUsage: tc [FLAGS] [INPUTS]\n\n --help Print this message.\n --out [PATH] Emit code to PATH (the target format is the file extension).\n --wasm Explicit webassembly output \n --define [NAME] Define the flag NAME in all input files.\n\nExamples:\n\n tc src/*.tbs --out main.wasm\n"); + terminal_1.Terminal.write("\nUsage: tc [FLAGS] [INPUTS]\n\n --help Print this message.\n --out [PATH] Emit code to PATH (the target format is the file extension).\n --wasm Explicit webassembly output\n --define [NAME] Define the flag NAME in all input files.\n\nExamples:\n\n tc src/*.tbs --out main.wasm\n"); } exports.printUsage = printUsage; function main_entry() { @@ -7727,7 +7731,7 @@ function compileString(source, options) { var output = "/virtual/inline.wasm"; filesystem_1.FileSystem.writeTextFile(input, source, true); var compiler = new compiler_1.Compiler(); - compiler.initialize(options.target, output); + compiler.initialize(options.target, output, options); compiler.addInput(input, source); compiler.finish(); terminal_1.Terminal.silent = false; @@ -7749,7 +7753,7 @@ function compileString(source, options) { } } exports.compileString = compileString; -exports.version = "1.0.5-beta"; +exports.version = "1.0.6-beta"; terminal_1.Terminal.setTextColor(color_1.Color.MAGENTA); terminal_1.Terminal.write("~~~~~~~~~~~~~~~~~~~~~~~~~| TurboScript " + exports.version + " |~~~~~~~~~~~~~~~~~~~~~~~~~\n"); terminal_1.Terminal.clearColor(); @@ -8110,7 +8114,7 @@ exports.isBuiltin = isBuiltin; Object.defineProperty(exports, "__esModule", { value: true }); var bytearray_1 = __webpack_require__(0); -var stringbuilder_1 = __webpack_require__(21); +var stringbuilder_1 = __webpack_require__(22); /** * Created by 01 on 2017-06-23. */ @@ -8934,7 +8938,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); var wasm_binary_section_1 = __webpack_require__(4); var wasm_section_1 = __webpack_require__(1); var bytearray_1 = __webpack_require__(0); -var wasm_function_1 = __webpack_require__(16); +var wasm_function_1 = __webpack_require__(17); /** * Created by 01 on 2017-06-17. */ @@ -9139,7 +9143,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); var wasm_binary_section_1 = __webpack_require__(4); var wasm_section_1 = __webpack_require__(1); var bytearray_1 = __webpack_require__(0); -var wasm_function_1 = __webpack_require__(16); +var wasm_function_1 = __webpack_require__(17); var wasm_parser_1 = __webpack_require__(29); /** * Created by 01 on 2017-06-17. @@ -9530,8 +9534,8 @@ exports.TableSection = TableSection; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var wasm_binary_1 = __webpack_require__(17); -var wasm_function_1 = __webpack_require__(16); +var wasm_binary_1 = __webpack_require__(18); +var wasm_function_1 = __webpack_require__(17); var wasm_import_1 = __webpack_require__(25); var wasm_signature_1 = __webpack_require__(26); var wasm_global_1 = __webpack_require__(24); @@ -9718,7 +9722,7 @@ var builtins_helper_1 = __webpack_require__(47); var assert_1 = __webpack_require__(3); var wasm_type_1 = __webpack_require__(6); var logger_1 = __webpack_require__(27); -var bitness_1 = __webpack_require__(22); +var bitness_1 = __webpack_require__(16); var wasm_section_1 = __webpack_require__(1); var wasm_external_kind_1 = __webpack_require__(11); var wasm_local_1 = __webpack_require__(49); @@ -9727,7 +9731,7 @@ var wasm_assembler_1 = __webpack_require__(46); var terminal_1 = __webpack_require__(2); var utils_2 = __webpack_require__(13); var wasm_optimizer_1 = __webpack_require__(51); -var wasm_binary_1 = __webpack_require__(17); +var wasm_binary_1 = __webpack_require__(18); var binary_importer_1 = __webpack_require__(33); var WasmModuleEmitter = (function () { function WasmModuleEmitter(bitness) { @@ -11443,7 +11447,7 @@ var scope_1 = __webpack_require__(30); var utils_1 = __webpack_require__(8); var const_1 = __webpack_require__(69); var assert_1 = __webpack_require__(3); -var compiler_1 = __webpack_require__(18); +var compiler_1 = __webpack_require__(19); var terminal_1 = __webpack_require__(2); /** * Author : Nidin Vinayakan @@ -13228,7 +13232,9 @@ var compile_target_1 = __webpack_require__(9); exports.defaultCompilerOptions = { target: compile_target_1.CompileTarget.WEBASSEMBLY, silent: true, - logError: true + logError: true, + optimize: true, + longPtr: false }; @@ -13262,7 +13268,7 @@ exports.MAX_UINT64_VALUE = Math.pow(2, 64) - 1; Object.defineProperty(exports, "__esModule", { value: true }); var symbol_1 = __webpack_require__(7); var node_1 = __webpack_require__(10); -var compiler_1 = __webpack_require__(18); +var compiler_1 = __webpack_require__(19); function treeShakingMarkAllUsed(node) { var symbol = node.symbol; if (symbol != null && !symbol.isUsed() && symbol_1.isFunction(symbol.kind) && symbol.node != null) { @@ -13346,7 +13352,7 @@ var scanner_1 = __webpack_require__(14); var filesystem_1 = __webpack_require__(15); var terminal_1 = __webpack_require__(2); var binary_importer_1 = __webpack_require__(33); -var env_1 = __webpack_require__(20); +var env_1 = __webpack_require__(21); var javascript = __webpack_require__(36); var path; if (env_1.isNode) { diff --git a/lib/turboscript.min.js b/lib/turboscript.min.js index 75093df..16ac13f 100644 --- a/lib/turboscript.min.js +++ b/lib/turboscript.min.js @@ -1 +1 @@ -!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory(require("fs"),require("path")):"function"==typeof define&&define.amd?define(["fs","path"],factory):"object"==typeof exports?exports.turboscript=factory(require("fs"),require("path")):root.turboscript=factory(root.fs,root.path)}(this,function(__WEBPACK_EXTERNAL_MODULE_76__,__WEBPACK_EXTERNAL_MODULE_77__){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=74)}([function(module,exports,__webpack_require__){"use strict";function ByteArray_set16(array,index,value){array.set(index,value),array.set(index+1,value>>8)}function ByteArray_set32(array,index,value){array.set(index,value),array.set(index+1,value>>8),array.set(index+2,value>>16),array.set(index+3,value>>24)}function ByteArray_append32(array,value){array.append(value),array.append(value>>8),array.append(value>>16),array.append(value>>24)}function ByteArray_setString(data,index,text){var length=text.length;assert_1.assert(index>=0&&index+2*length<=data.length);for(var array=data.array,i=0;i>8,index+=2,i+=1}}Object.defineProperty(exports,"__esModule",{value:!0});var assert_1=__webpack_require__(3),utils_1=__webpack_require__(8);exports.ByteArray_set16=ByteArray_set16,exports.ByteArray_set32=ByteArray_set32,exports.ByteArray_append32=ByteArray_append32,exports.ByteArray_setString=ByteArray_setString;var ByteArray=function(){function ByteArray(buffer,byteOffset,byteLength){void 0===byteOffset&&(byteOffset=0),void 0===byteLength&&(byteLength=0),this.BUFFER_EXT_SIZE=1024,this._array=null,this.log="",this.EOF_byte=-1,this.EOF_code_point=-1,void 0==buffer?(buffer=new ArrayBuffer(this.BUFFER_EXT_SIZE),this.write_position=0):this.write_position=null==buffer?0:byteLength>0?byteLength:buffer.byteLength,buffer&&(this.data=new DataView(buffer,byteOffset,byteLength>0?byteLength:buffer.byteLength),this._array=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength)),this._position=0,this.endian=ByteArray.LITTLE_ENDIAN}return Object.defineProperty(ByteArray.prototype,"array",{get:function(){return this._array.subarray(0,this.length)},enumerable:!0,configurable:!0}),ByteArray.prototype.get=function(index){return this._array[index]},ByteArray.prototype.set=function(index,value){this._array[index]=value},ByteArray.prototype.append=function(value){var index=this.position;return this.resize(index+1),this._array[index]=value,this.position++,index},ByteArray.prototype.resize=function(length){if(length>this.data.byteLength){var pos=this.position,len=this.length,capacity=2*length,data=new Uint8Array(capacity);data.set(this.array),this.setArray(data),this._position=pos,this.write_position=len}return this},ByteArray.prototype.copy=function(source,offset,length){return void 0===offset&&(offset=0),void 0===length&&(length=0),offset=offset>0?offset:this.length,offset+source.length>this._array.length&&this.resize(offset+source.length),this._array.set(source.array,offset),this.position=offset+source.length,this},Object.defineProperty(ByteArray.prototype,"buffer",{get:function(){return this.data.buffer},set:function(value){this.data=new DataView(value)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"dataView",{get:function(){return this.data},set:function(value){this.data=value,this.write_position=value.byteLength},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"phyPosition",{get:function(){return this._position+this.data.byteOffset},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"byteOffset",{get:function(){return this.data.byteOffset},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"byteLength",{get:function(){return this.data.byteLength},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"position",{get:function(){return this._position},set:function(value){this._positionthis.write_position?value:this.write_position)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"length",{get:function(){return this.write_position},set:function(value){this.validateBuffer(value)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"bytesAvailable",{get:function(){return this.data.byteLength-this._position},enumerable:!0,configurable:!0}),ByteArray.prototype.clear=function(){this._position=0},ByteArray.prototype.setArray=function(array){this._array=array,this.setBuffer(array.buffer,array.byteOffset,array.byteLength)},ByteArray.prototype.setBuffer=function(buffer,offset,length){void 0===offset&&(offset=0),void 0===length&&(length=0),buffer&&(this.data=new DataView(buffer,offset,length>0?length:buffer.byteLength))},ByteArray.prototype.readU8LEB=function(){return this.readUnsignedLEB128(1)},ByteArray.prototype.readU16LEB=function(){return this.readUnsignedLEB128(2)},ByteArray.prototype.readU32LEB=function(){return this.readUnsignedLEB128(4)},ByteArray.prototype.readU64LEB=function(){return this.readUnsignedLEB128(8)},ByteArray.prototype.readS8LEB=function(){return this.readLEB128(1)},ByteArray.prototype.readS16LEB=function(){return this.readLEB128(2)},ByteArray.prototype.readS32LEB=function(){return this.readLEB128(4)},ByteArray.prototype.readS64LEB=function(){return this.readLEB128(8)},ByteArray.prototype.readUnsignedLEB128=function(size){for(var byte,value=0,shift=0;;){byte=this.readUnsignedByte();var last=!(128&byte),payload=127&byte,shift_mask=0==shift?-1:(1<<8*size-shift)-1,significant_payload=payload&shift_mask;if(significant_payload!=payload&&!(value<0&&last))throw"LEB dropped bits only valid for signed LEB";if(value|=significant_payload<=8*size)throw"LEB overflow"}return value},ByteArray.prototype.readLEB128=function(size){for(var byte,value=0,shift=0,sizeOfShift=0;;){byte=this.readByte();var last=!(128&byte),payload=127&byte,shift_mask=0==shift?-1:(1<<8*size-shift)-1,significant_payload=payload&shift_mask;if(!(significant_payload==payload||utils_1.isSigned(value)&&last))throw"LEB dropped bits only valid for signed LEB";if(value|=significant_payload<=8*size)throw"LEB overflow"}if(utils_1.isSigned(value)&&(shift+=7,sizeOfShift=utils_1.sizeOfNumber(shift),64&byte&&sizeOfShift<8*size)){var sext_bits=8*size-sizeOfShift;if(value<<=sext_bits,(value>>=sext_bits)>=0)throw"LEB sign-extend should produce a negative value"}return value},ByteArray.prototype.writeUnsignedLEB128=function(value){var b=0;value|=0;do{b=127&value,value>>>=7,value&&(b|=128),this.append(b)}while(value)},ByteArray.prototype.writeLEB128=function(value){var b;for(value|=0;;){b=127&value,value>>=7;var signBit=0!=(64&b);if(0===value&&!signBit||-1===value&&signBit){this.append(b);break}b|=128,this.append(b)}},ByteArray.prototype.readWasmString=function(){var length=this.readUnsignedLEB128(4);return this.readUTFBytes(length)},ByteArray.prototype.writeWasmString=function(value){var length=value.length;this.writeUnsignedLEB128(length);var index=this.length;this.resize(index+length);for(var i=0;i0?this.readUTFBytes(length):""},ByteArray.prototype.readUTFBytes=function(length){if(!this.validate(length))return null;var _bytes=new Uint8Array(this.buffer,this.byteOffset+this.position,length);return this.position+=length,this.decodeUTF8(_bytes)},ByteArray.prototype.readStandardString=function(length){if(!this.validate(length))return null;for(var str="",i=0;i0;){var _byte=this.data.getUint8(this.position++);if(num++,0==_byte){keepEvenByte&&num%2!=0&&this.position++;break}str+=String.fromCharCode(_byte)}return str},ByteArray.prototype.writeBoolean=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_BOOLEAN,offset),this.data.setUint8(offset,value?1:0)},ByteArray.prototype.writeByte=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_INT8,offset),this.data.setInt8(offset,value)},ByteArray.prototype.writeUnsignedByte=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_UINT8,offset),this.data.setUint8(offset,value)},ByteArray.prototype.writeBytes=function(_bytes,offset,length){void 0===offset&&(offset=0),void 0===length&&(length=0),this.copy(_bytes)},ByteArray.prototype.writeDouble=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_FLOAT64,position),this.data.setFloat64(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_FLOAT64)},ByteArray.prototype.writeFloat=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_FLOAT32,position),this.data.setFloat32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_FLOAT32)},ByteArray.prototype.writeInt=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_INT32,position),this.data.setInt32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_INT32)},ByteArray.prototype.writeMultiByte=function(value,charSet){},ByteArray.prototype.writeShort=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_INT16,position),this.data.setInt16(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_INT16)},ByteArray.prototype.writeUnsignedShort=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT16,position),this.data.setUint16(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_UINT16)},ByteArray.prototype.writeUnsignedInt=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT32,position),this.data.setUint32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_UINT32)},ByteArray.prototype.writeUTF=function(value,offset){void 0===offset&&(offset=null);var utf8bytes=this.encodeUTF8(value),length=utf8bytes.length,position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT16+length,position),this.data.setUint16(position,length,this.endian===ByteArray.LITTLE_ENDIAN),offset?(offset+=ByteArray.SIZE_OF_UINT16,this.writeUint8Array(utf8bytes,offset)):(this.position+=ByteArray.SIZE_OF_UINT16,this.writeUint8Array(utf8bytes))},ByteArray.prototype.writeUTFBytes=function(value,offset){void 0===offset&&(offset=null),this.writeUint8Array(this.encodeUTF8(value),offset)},ByteArray.prototype.toString=function(){return"[ByteArray] length:"+this.length+", bytesAvailable:"+this.bytesAvailable},ByteArray.prototype.writeUint8Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;return this.validateBuffer(_bytes.length,position),this._array.set(_bytes,position),offset||(this.position+=_bytes.length),this},ByteArray.prototype.writeUint16Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_UINT16,position);for(var i=0;i<_bytes.length;i++)this.data.setUint16(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_UINT16;offset||(this.position=position)},ByteArray.prototype.writeUint32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_UINT32,position);for(var i=0;i<_bytes.length;i++)this.data.setUint32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_UINT32;offset||(this.position=position)},ByteArray.prototype.writeInt8Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length,position);for(var i=0;i<_bytes.length;i++)this.data.setInt8(position++,_bytes[i]);offset||(this.position=position)},ByteArray.prototype.writeInt16Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_INT16,position);for(var i=0;i<_bytes.length;i++)this.data.setInt16(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_INT16;offset||(this.position=position)},ByteArray.prototype.writeInt32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_INT32,position);for(var i=0;i<_bytes.length;i++)this.data.setInt32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_INT32;offset||(this.position=position)},ByteArray.prototype.writeFloat32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_FLOAT32,position);for(var i=0;i<_bytes.length;i++)this.data.setFloat32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_FLOAT32;offset||(this.position=position)},ByteArray.prototype.writeFloat64Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length,position);for(var i=0;i<_bytes.length;i++)this.data.setFloat64(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_FLOAT64;offset||(this.position=position)},ByteArray.prototype.readUint8Array=function(length,createNewBuffer){if(void 0===createNewBuffer&&(createNewBuffer=!0),!this.validate(length))return null;if(createNewBuffer){result=new Uint8Array(new ArrayBuffer(length));for(var i=0;i0&&this._position+len<=this.data.byteLength)return!0;throw"Error #2030: End of file was encountered."},ByteArray.prototype.validateBuffer=function(size,offset){void 0===offset&&(offset=0);var length=offset+size;this.resize(length)},ByteArray.prototype.encodeUTF8=function(str){for(var pos=0,codePoints=this.stringToCodePoints(str),outputBytes=[];codePoints.length>pos;){var code_point=codePoints[pos++];if(this.inRange(code_point,55296,57343))this.encoderError(code_point);else if(this.inRange(code_point,0,127))outputBytes.push(code_point);else{var count,offset;for(this.inRange(code_point,128,2047)?(count=1,offset=192):this.inRange(code_point,2048,65535)?(count=2,offset=224):this.inRange(code_point,65536,1114111)&&(count=3,offset=240),outputBytes.push(this.div(code_point,Math.pow(64,count))+offset);count>0;){var temp=this.div(code_point,Math.pow(64,count-1));outputBytes.push(128+temp%64),count-=1}}}return new Uint8Array(outputBytes)},ByteArray.prototype.decodeUTF8=function(data){for(var code_point,pos=0,result="",utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0;data.length>pos;){var _byte=data[pos++];if(_byte===this.EOF_byte)code_point=0!==utf8_bytes_needed?this.decoderError(!1):this.EOF_code_point;else if(0===utf8_bytes_needed)this.inRange(_byte,0,127)?code_point=_byte:(this.inRange(_byte,194,223)?(utf8_bytes_needed=1,utf8_lower_boundary=128,utf8_code_point=_byte-192):this.inRange(_byte,224,239)?(utf8_bytes_needed=2,utf8_lower_boundary=2048,utf8_code_point=_byte-224):this.inRange(_byte,240,244)?(utf8_bytes_needed=3,utf8_lower_boundary=65536,utf8_code_point=_byte-240):this.decoderError(!1),utf8_code_point*=Math.pow(64,utf8_bytes_needed),code_point=null);else if(this.inRange(_byte,128,191))if(utf8_bytes_seen+=1,utf8_code_point+=(_byte-128)*Math.pow(64,utf8_bytes_needed-utf8_bytes_seen),utf8_bytes_seen!==utf8_bytes_needed)code_point=null;else{var cp=utf8_code_point,lower_boundary=utf8_lower_boundary;utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0,code_point=this.inRange(cp,lower_boundary,1114111)&&!this.inRange(cp,55296,57343)?cp:this.decoderError(!1,_byte)}else utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0,pos--,code_point=this.decoderError(!1,_byte);null!==code_point&&code_point!==this.EOF_code_point&&(code_point<=65535?code_point>0&&(result+=String.fromCharCode(code_point)):(code_point-=65536,result+=String.fromCharCode(55296+(code_point>>10&1023)),result+=String.fromCharCode(56320+(1023&code_point))))}return result},ByteArray.prototype.encoderError=function(code_point){throw"EncodingError! The code point "+code_point+" could not be encoded."},ByteArray.prototype.decoderError=function(fatal,opt_code_point){if(fatal)throw"DecodingError";return opt_code_point||65533},ByteArray.prototype.inRange=function(a,min,max){return min<=a&&a<=max},ByteArray.prototype.div=function(n,d){return Math.floor(n/d)},ByteArray.prototype.stringToCodePoints=function(string){for(var cps=[],i=0,n=string.length;i57343)&&(column+=1),i+=1}var location=new LineColumn;return location.line=line,location.column=column,location},Source}();exports.Source=Source;var SourceRange=function(){function SourceRange(){}return SourceRange.prototype.toString=function(){return this.source.contents.slice(this.start,this.end)},SourceRange.prototype.equals=function(other){return this.source==other.source&&this.start==other.start&&this.end==other.end},SourceRange.prototype.enclosingLine=function(){for(var contents=this.source.contents,start=this.start,end=this.start;start>0&&"\n"!=contents[start-1];)start-=1;for(var length=contents.length;end0;)rangeStr+=" ",column-=1;if(range.end-range.start<=1)rangeStr+="^";else for(var i=range.start;i=SymbolKind.TYPE_CLASS&&kind<=SymbolKind.TYPE_NATIVE}function isFunction(kind){return kind>=SymbolKind.FUNCTION_INSTANCE&&kind<=SymbolKind.FUNCTION_GLOBAL}function isVariable(kind){return kind>=SymbolKind.VARIABLE_ARGUMENT&&kind<=SymbolKind.VARIABLE_LOCAL}Object.defineProperty(exports,"__esModule",{value:!0});var SymbolKind,node_1=__webpack_require__(10),utils_1=__webpack_require__(8),assert_1=__webpack_require__(3);!function(SymbolKind){SymbolKind[SymbolKind.TYPE_MODULE=0]="TYPE_MODULE",SymbolKind[SymbolKind.TYPE_INTERFACE=1]="TYPE_INTERFACE",SymbolKind[SymbolKind.TYPE_CLASS=2]="TYPE_CLASS",SymbolKind[SymbolKind.TYPE_GENERIC=3]="TYPE_GENERIC",SymbolKind[SymbolKind.TYPE_TEMPLATE=4]="TYPE_TEMPLATE",SymbolKind[SymbolKind.TYPE_ENUM=5]="TYPE_ENUM",SymbolKind[SymbolKind.TYPE_GLOBAL=6]="TYPE_GLOBAL",SymbolKind[SymbolKind.TYPE_NATIVE=7]="TYPE_NATIVE",SymbolKind[SymbolKind.FUNCTION_INSTANCE=8]="FUNCTION_INSTANCE",SymbolKind[SymbolKind.FUNCTION_GLOBAL=9]="FUNCTION_GLOBAL",SymbolKind[SymbolKind.VARIABLE_ARGUMENT=10]="VARIABLE_ARGUMENT",SymbolKind[SymbolKind.VARIABLE_CONSTANT=11]="VARIABLE_CONSTANT",SymbolKind[SymbolKind.VARIABLE_GLOBAL=12]="VARIABLE_GLOBAL",SymbolKind[SymbolKind.VARIABLE_INSTANCE=13]="VARIABLE_INSTANCE",SymbolKind[SymbolKind.VARIABLE_LOCAL=14]="VARIABLE_LOCAL"}(SymbolKind=exports.SymbolKind||(exports.SymbolKind={})),exports.isModule=isModule,exports.isType=isType,exports.isFunction=isFunction,exports.isVariable=isVariable;var SymbolState;!function(SymbolState){SymbolState[SymbolState.UNINITIALIZED=0]="UNINITIALIZED",SymbolState[SymbolState.INITIALIZING=1]="INITIALIZING",SymbolState[SymbolState.INITIALIZED=2]="INITIALIZED"}(SymbolState=exports.SymbolState||(exports.SymbolState={})),exports.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL=1,exports.SYMBOL_FLAG_IS_BINARY_OPERATOR=2,exports.SYMBOL_FLAG_IS_REFERENCE=4,exports.SYMBOL_FLAG_IS_UNARY_OPERATOR=8,exports.SYMBOL_FLAG_IS_UNSIGNED=16,exports.SYMBOL_FLAG_NATIVE_INTEGER=32,exports.SYMBOL_FLAG_NATIVE_LONG=64,exports.SYMBOL_FLAG_NATIVE_FLOAT=128,exports.SYMBOL_FLAG_NATIVE_DOUBLE=256,exports.SYMBOL_FLAG_USED=512,exports.SYMBOL_FLAG_IS_ARRAY=1024,exports.SYMBOL_FLAG_IS_GENERIC=2048,exports.SYMBOL_FLAG_IS_TEMPLATE=4096;var Symbol=function(){function Symbol(){this.state=SymbolState.UNINITIALIZED,this.byteSize=0,this.maxAlignment=0}return Object.defineProperty(Symbol.prototype,"internalName",{get:function(){return null!=this.rename?this.rename:this.name},enumerable:!0,configurable:!0}),Symbol.prototype.clone=function(){var symbol=new Symbol;return symbol.kind=this.kind,symbol.name=this.name,symbol.node=this.node,symbol.range=this.range,symbol.scope=this.scope,symbol.resolvedType=this.resolvedType,symbol.byteSize=this.byteSize,symbol.state=this.state,symbol.maxAlignment=this.maxAlignment,symbol.flags=this.flags,symbol.rename=this.rename,symbol},Symbol.prototype.isEnumValue=function(){return this.node.parent.kind==node_1.NodeKind.ENUM},Symbol.prototype.isUnsafe=function(){return null!=this.node&&this.node.isUnsafe()},Symbol.prototype.isGetter=function(){return this.node.isGet()},Symbol.prototype.isSetter=function(){return this.node.isSet()},Symbol.prototype.isBinaryOperator=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_IS_BINARY_OPERATOR)},Symbol.prototype.isUnaryOperator=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_IS_UNARY_OPERATOR)},Symbol.prototype.shouldConvertInstanceToGlobal=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL)},Symbol.prototype.isUsed=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_USED)},Symbol.prototype.parent=function(){var parent=this.node.parent;return parent.kind==node_1.NodeKind.CLASS?parent.symbol:null},Symbol.prototype.resolvedTypeUnderlyingIfEnumValue=function(context){return this.isEnumValue()?this.resolvedType.underlyingType(context):this.resolvedType},Symbol.prototype.determineClassLayout=function(context){if(assert_1.assert(this.kind==SymbolKind.TYPE_CLASS),0==this.byteSize){for(var offset=0,child=this.node.firstChild,maxAlignment=1;null!=child;){if(child.kind==node_1.NodeKind.VARIABLE){var type=child.symbol.resolvedType;if(type!=context.errorType){var alignmentOf=type.variableAlignmentOf(context);offset=utils_1.alignToNextMultipleOf(offset,alignmentOf),alignmentOf>maxAlignment&&(maxAlignment=alignmentOf),child.symbol.offset=offset,offset+=type.variableSizeOf(context)}}child=child.nextSibling}0==offset&&(offset=1),offset=utils_1.alignToNextMultipleOf(offset,maxAlignment),this.byteSize=offset,this.maxAlignment=maxAlignment}},Symbol}();exports.Symbol=Symbol},function(module,exports,__webpack_require__){"use strict";function toHex(value,size){if(void 0===size&&(size=7),void 0==value||null==value)return"";for(var hex=value.toString(16),zero=[],i=0;i0&&0==(value&value-1)}function alignToNextMultipleOf(offset,alignment){return assert_1.assert(isPositivePowerOf2(alignment)),offset+alignment-1&-alignment}function sizeOfNumber(value){return value.toString(2).length/8}function isSigned(value){return value<0}Object.defineProperty(exports,"__esModule",{value:!0});var assert_1=__webpack_require__(3);exports.toHex=toHex,exports.isPositivePowerOf2=isPositivePowerOf2,exports.alignToNextMultipleOf=alignToNextMultipleOf,exports.sizeOfNumber=sizeOfNumber,exports.isSigned=isSigned},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});!function(CompileTarget){CompileTarget[CompileTarget.NONE=0]="NONE",CompileTarget[CompileTarget.AUTO=1]="AUTO",CompileTarget[CompileTarget.CPP=2]="CPP",CompileTarget[CompileTarget.JAVASCRIPT=3]="JAVASCRIPT",CompileTarget[CompileTarget.WEBASSEMBLY=4]="WEBASSEMBLY"}(exports.CompileTarget||(exports.CompileTarget={}))},function(module,exports,__webpack_require__){"use strict";function isUnary(kind){return kind>=NodeKind.ADDRESS_OF&&kind<=NodeKind.PREFIX_INCREMENT}function isUnaryPostfix(kind){return kind>=NodeKind.POSTFIX_DECREMENT&&kind<=NodeKind.POSTFIX_INCREMENT}function isBinary(kind){return kind>=NodeKind.ADD&&kind<=NodeKind.SUBTRACT}function invertedBinaryKind(kind){return kind==NodeKind.EQUAL?NodeKind.NOT_EQUAL:kind==NodeKind.NOT_EQUAL?NodeKind.EQUAL:kind==NodeKind.GREATER_THAN?NodeKind.LESS_THAN_EQUAL:kind==NodeKind.GREATER_THAN_EQUAL?NodeKind.LESS_THAN:kind==NodeKind.LESS_THAN?NodeKind.GREATER_THAN_EQUAL:kind==NodeKind.LESS_THAN_EQUAL?NodeKind.GREATER_THAN:kind}function isExpression(node){return node.kind>=NodeKind.ALIGN_OF&&node.kind<=NodeKind.SUBTRACT}function isCompactNodeKind(kind){return kind==NodeKind.CONSTANTS||kind==NodeKind.EXPRESSION||kind==NodeKind.VARIABLES}function appendFlag(first,flag,range){var link=new NodeFlag;if(link.flag=flag,link.range=range,null==first)return link;for(var secondToLast=first;null!=secondToLast.next;)secondToLast=secondToLast.next;return secondToLast.next=link,first}function allFlags(link){for(var all=0;null!=link;)all|=link.flag,link=link.next;return all}function rangeForFlag(link,flag){for(;null!=link;){if(link.flag==flag)return link.range;link=link.next}return null}function createNew(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.NEW,node.appendChild(type),node}function createDelete(value){assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.DELETE,null!=value&&node.appendChild(value),node}function createHook(test,primary,secondary){assert_1.assert(isExpression(test)),assert_1.assert(isExpression(primary)),assert_1.assert(isExpression(secondary));var node=new Node;return node.kind=NodeKind.HOOK,node.appendChild(test),node.appendChild(primary),node.appendChild(secondary),node}function createIndex(target){assert_1.assert(isExpression(target));var node=new Node;return node.kind=NodeKind.INDEX,node.appendChild(target),node}function createNull(){var node=new Node;return node.kind=NodeKind.NULL,node}function createUndefined(){var node=new Node;return node.kind=NodeKind.UNDEFINED,node}function createThis(){var node=new Node;return node.kind=NodeKind.THIS,node}function createAddressOf(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.ADDRESS_OF,node.appendChild(value),node}function createDereference(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.DEREFERENCE,node.appendChild(value),node}function createAlignOf(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.ALIGN_OF,node.appendChild(type),node}function createSizeOf(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.SIZE_OF,node.appendChild(type),node}function createboolean(value){var node=new Node;return node.kind=NodeKind.BOOLEAN,node.intValue=value?1:0,node}function createInt(value){var node=new Node;return node.kind=NodeKind.INT32,node.intValue=value,node}function createLong(value){var node=new Node;return node.kind=NodeKind.INT64,node.longValue=value,node}function createFloat(value){var node=new Node;return node.kind=NodeKind.FLOAT32,node.floatValue=value,node}function createDouble(value){var node=new Node;return node.kind=NodeKind.FLOAT64,node.doubleValue=value,node}function createString(value){var node=new Node;return node.kind=NodeKind.STRING,node.stringValue=value,node}function createArray(type){var node=new Node;return node.kind=NodeKind.ARRAY,node.resolvedType=type,node}function createName(value){var node=new Node;return node.kind=NodeKind.NAME,node.referenceValue=value,node}function createType(type){assert_1.assert(null!=type);var node=new Node;return node.kind=NodeKind.TYPE,node.resolvedType=type,node}function createAny(){var node=new Node;return node.kind=NodeKind.ANY,node}function createEmpty(){var node=new Node;return node.kind=NodeKind.EMPTY,node}function createExpression(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.EXPRESSION,node.appendChild(value),node}function createBlock(){var node=new Node;return node.kind=NodeKind.BLOCK,node}function createModule(name){var node=new Node;return node.kind=NodeKind.MODULE,node.stringValue=name,node}function createClass(name){var node=new Node;return node.kind=NodeKind.CLASS,node.stringValue=name,node}function createEnum(name){var node=new Node;return node.kind=NodeKind.ENUM,node.stringValue=name,node}function createIf(value,trueBranch,falseBranch){assert_1.assert(isExpression(value)),assert_1.assert(trueBranch.kind==NodeKind.BLOCK),assert_1.assert(null==falseBranch||falseBranch.kind==NodeKind.BLOCK);var node=new Node;return node.kind=NodeKind.IF,node.appendChild(value),node.appendChild(trueBranch),null!=falseBranch&&node.appendChild(falseBranch),node}function createWhile(value,body){assert_1.assert(isExpression(value)),assert_1.assert(body.kind==NodeKind.BLOCK);var node=new Node;return node.kind=NodeKind.WHILE,node.appendChild(value),node.appendChild(body),node}function createReturn(value){assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.RETURN,null!=value&&node.appendChild(value),node}function createImports(){var node=new Node;return node.kind=NodeKind.IMPORTS,node}function createImport(name){var node=new Node;return node.kind=NodeKind.IMPORT,node.stringValue=name,node}function createImportFrom(name){var node=new Node;return node.kind=NodeKind.IMPORT_FROM,node.stringValue=name,node}function createVariables(){var node=new Node;return node.kind=NodeKind.VARIABLES,node}function createConstants(){var node=new Node;return node.kind=NodeKind.CONSTANTS,node}function createParameters(){var node=new Node;return node.kind=NodeKind.PARAMETERS,node}function createExtends(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.EXTENDS,node.appendChild(type),node}function createImplements(){var node=new Node;return node.kind=NodeKind.IMPLEMENTS,node}function createParameter(name){var node=new Node;return node.kind=NodeKind.PARAMETER,node.stringValue=name,node}function createVariable(name,type,value){assert_1.assert(null==type||isExpression(type)),assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.VARIABLE,node.stringValue=name,node.appendChild(null!=type?type:createEmpty()),null!=value&&node.appendChild(value),node}function createFunction(name){var node=new Node;return node.kind=NodeKind.FUNCTION,node.stringValue=name,node}function createUnary(kind,value){assert_1.assert(isUnary(kind)),assert_1.assert(isExpression(value));var node=new Node;return node.kind=kind,node.appendChild(value),node}function createBinary(kind,left,right){assert_1.assert(isBinary(kind)),assert_1.assert(isExpression(left)),assert_1.assert(isExpression(right));var node=new Node;return node.kind=kind,node.appendChild(left),node.appendChild(right),node}function createCall(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.CALL,node.appendChild(value),node}function createCast(value,type){assert_1.assert(isExpression(value)),assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.CAST,node.appendChild(value),node.appendChild(type),node}function createDot(value,name){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.DOT,node.stringValue=name,node.appendChild(value),node}function createSymbolReference(symbol){var node=createName(symbol.name);return node.symbol=symbol,node.resolvedType=symbol.resolvedType,node}function createMemberReference(value,symbol){var node=createDot(value,symbol.name);return node.symbol=symbol,node.resolvedType=symbol.resolvedType,node}function createParseError(){var node=new Node;return node.kind=NodeKind.PARSE_ERROR,node}function createJSNumber(){var node=new Node;return node.kind=NodeKind.JS_NUMBER,node}function createJSObject(){var node=new Node;return node.kind=NodeKind.JS_OBJECT,node}function createJSString(){var node=new Node;return node.kind=NodeKind.JS_STRING,node}function createJSArray(){var node=new Node;return node.kind=NodeKind.JS_ARRAY,node}Object.defineProperty(exports,"__esModule",{value:!0});var NodeKind,symbol_1=__webpack_require__(7),assert_1=__webpack_require__(3);!function(NodeKind){NodeKind[NodeKind.EXTENDS=0]="EXTENDS",NodeKind[NodeKind.FILE=1]="FILE",NodeKind[NodeKind.GLOBAL=2]="GLOBAL",NodeKind[NodeKind.IMPLEMENTS=3]="IMPLEMENTS",NodeKind[NodeKind.PARAMETER=4]="PARAMETER",NodeKind[NodeKind.PARAMETERS=5]="PARAMETERS",NodeKind[NodeKind.VARIABLE=6]="VARIABLE",NodeKind[NodeKind.IMPORT=7]="IMPORT",NodeKind[NodeKind.IMPORT_FROM=8]="IMPORT_FROM",NodeKind[NodeKind.BLOCK=9]="BLOCK",NodeKind[NodeKind.BREAK=10]="BREAK",NodeKind[NodeKind.MODULE=11]="MODULE",NodeKind[NodeKind.IMPORTS=12]="IMPORTS",NodeKind[NodeKind.CLASS=13]="CLASS",NodeKind[NodeKind.CONSTANTS=14]="CONSTANTS",NodeKind[NodeKind.CONTINUE=15]="CONTINUE",NodeKind[NodeKind.EMPTY=16]="EMPTY",NodeKind[NodeKind.ENUM=17]="ENUM",NodeKind[NodeKind.EXPRESSION=18]="EXPRESSION",NodeKind[NodeKind.FUNCTION=19]="FUNCTION",NodeKind[NodeKind.IF=20]="IF",NodeKind[NodeKind.RETURN=21]="RETURN",NodeKind[NodeKind.UNSAFE=22]="UNSAFE",NodeKind[NodeKind.JAVASCRIPT=23]="JAVASCRIPT",NodeKind[NodeKind.START=24]="START",NodeKind[NodeKind.VARIABLES=25]="VARIABLES",NodeKind[NodeKind.WHILE=26]="WHILE",NodeKind[NodeKind.ALIGN_OF=27]="ALIGN_OF",NodeKind[NodeKind.BOOLEAN=28]="BOOLEAN",NodeKind[NodeKind.CALL=29]="CALL",NodeKind[NodeKind.CAST=30]="CAST",NodeKind[NodeKind.DOT=31]="DOT",NodeKind[NodeKind.HOOK=32]="HOOK",NodeKind[NodeKind.INDEX=33]="INDEX",NodeKind[NodeKind.POINTER_INDEX=34]="POINTER_INDEX",NodeKind[NodeKind.ANY=35]="ANY",NodeKind[NodeKind.INT32=36]="INT32",NodeKind[NodeKind.INT64=37]="INT64",NodeKind[NodeKind.FLOAT32=38]="FLOAT32",NodeKind[NodeKind.FLOAT64=39]="FLOAT64",NodeKind[NodeKind.ARRAY=40]="ARRAY",NodeKind[NodeKind.GENERIC=41]="GENERIC",NodeKind[NodeKind.NAME=42]="NAME",NodeKind[NodeKind.NEW=43]="NEW",NodeKind[NodeKind.DELETE=44]="DELETE",NodeKind[NodeKind.NULL=45]="NULL",NodeKind[NodeKind.UNDEFINED=46]="UNDEFINED",NodeKind[NodeKind.PARSE_ERROR=47]="PARSE_ERROR",NodeKind[NodeKind.SIZE_OF=48]="SIZE_OF",NodeKind[NodeKind.STRING=49]="STRING",NodeKind[NodeKind.THIS=50]="THIS",NodeKind[NodeKind.TYPE=51]="TYPE",NodeKind[NodeKind.ADDRESS_OF=52]="ADDRESS_OF",NodeKind[NodeKind.COMPLEMENT=53]="COMPLEMENT",NodeKind[NodeKind.DEREFERENCE=54]="DEREFERENCE",NodeKind[NodeKind.NEGATIVE=55]="NEGATIVE",NodeKind[NodeKind.NOT=56]="NOT",NodeKind[NodeKind.POINTER_TYPE=57]="POINTER_TYPE",NodeKind[NodeKind.POSITIVE=58]="POSITIVE",NodeKind[NodeKind.POSTFIX_DECREMENT=59]="POSTFIX_DECREMENT",NodeKind[NodeKind.POSTFIX_INCREMENT=60]="POSTFIX_INCREMENT",NodeKind[NodeKind.PREFIX_DECREMENT=61]="PREFIX_DECREMENT",NodeKind[NodeKind.PREFIX_INCREMENT=62]="PREFIX_INCREMENT",NodeKind[NodeKind.ADD=63]="ADD",NodeKind[NodeKind.ASSIGN=64]="ASSIGN",NodeKind[NodeKind.BITWISE_AND=65]="BITWISE_AND",NodeKind[NodeKind.BITWISE_OR=66]="BITWISE_OR",NodeKind[NodeKind.BITWISE_XOR=67]="BITWISE_XOR",NodeKind[NodeKind.DIVIDE=68]="DIVIDE",NodeKind[NodeKind.EQUAL=69]="EQUAL",NodeKind[NodeKind.EXPONENT=70]="EXPONENT",NodeKind[NodeKind.GREATER_THAN=71]="GREATER_THAN",NodeKind[NodeKind.GREATER_THAN_EQUAL=72]="GREATER_THAN_EQUAL",NodeKind[NodeKind.LESS_THAN=73]="LESS_THAN",NodeKind[NodeKind.LESS_THAN_EQUAL=74]="LESS_THAN_EQUAL",NodeKind[NodeKind.LOGICAL_AND=75]="LOGICAL_AND",NodeKind[NodeKind.LOGICAL_OR=76]="LOGICAL_OR",NodeKind[NodeKind.MULTIPLY=77]="MULTIPLY",NodeKind[NodeKind.NOT_EQUAL=78]="NOT_EQUAL",NodeKind[NodeKind.REMAINDER=79]="REMAINDER",NodeKind[NodeKind.SHIFT_LEFT=80]="SHIFT_LEFT",NodeKind[NodeKind.SHIFT_RIGHT=81]="SHIFT_RIGHT",NodeKind[NodeKind.SUBTRACT=82]="SUBTRACT",NodeKind[NodeKind.JS_NUMBER=83]="JS_NUMBER",NodeKind[NodeKind.JS_OBJECT=84]="JS_OBJECT",NodeKind[NodeKind.JS_STRING=85]="JS_STRING",NodeKind[NodeKind.JS_ARRAY=86]="JS_ARRAY"}(NodeKind=exports.NodeKind||(exports.NodeKind={})),exports.isUnary=isUnary,exports.isUnaryPostfix=isUnaryPostfix,exports.isBinary=isBinary,exports.invertedBinaryKind=invertedBinaryKind,exports.isExpression=isExpression,exports.isCompactNodeKind=isCompactNodeKind,exports.NODE_FLAG_DECLARE=1,exports.NODE_FLAG_EXPORT=2,exports.NODE_FLAG_IMPORT=4,exports.NODE_FLAG_LIBRARY=8,exports.NODE_FLAG_GET=16,exports.NODE_FLAG_OPERATOR=32,exports.NODE_FLAG_POSITIVE=64,exports.NODE_FLAG_PRIVATE=128,exports.NODE_FLAG_PROTECTED=256,exports.NODE_FLAG_PUBLIC=512,exports.NODE_FLAG_SET=1024,exports.NODE_FLAG_STATIC=2048,exports.NODE_FLAG_UNSAFE=4096,exports.NODE_FLAG_JAVASCRIPT=8192,exports.NODE_FLAG_UNSIGNED_OPERATOR=16384,exports.NODE_FLAG_VIRTUAL=32768,exports.NODE_FLAG_START=65536,exports.NODE_FLAG_ANYFUNC=1<<17,exports.NODE_FLAG_GENERIC=1<<18;var NodeFlag=function(){function NodeFlag(){}return NodeFlag}();exports.NodeFlag=NodeFlag,exports.appendFlag=appendFlag,exports.allFlags=allFlags,exports.rangeForFlag=rangeForFlag;var Node=function(){function Node(){}return Object.defineProperty(Node.prototype,"hasValue",{get:function(){return this._hasValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"rawValue",{get:function(){return this._hasStringValue?'"'+this._rawValue+'"':this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"__internal_rawValue",{get:function(){return this._rawValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"intValue",{get:function(){var n=this._rawValue;return Number(n)===n&&n%1==0?this._rawValue:null},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"longValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"floatValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"doubleValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"stringValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._hasStringValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"referenceValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Node.prototype.becomeTypeOf=function(node,context){switch(node.resolvedType){case context.int64Type:this.kind!=NodeKind.NAME&&(this.kind=NodeKind.INT64),this.resolvedType=context.int64Type;break;case context.float64Type:this.kind!=NodeKind.NAME&&(this.kind=NodeKind.FLOAT64),this.resolvedType=context.float64Type}node.flags&&(this.flags=node.flags)},Node.prototype.becomeValueTypeOf=function(symbol,context){if(symbol.resolvedType.symbol)switch(symbol.resolvedType){case context.int64Type:this.resolvedType=context.int64Type,this.kind==NodeKind.NULL&&(this.longValue=0),this.kind!=NodeKind.NAME&&(this.kind=NodeKind.INT64);break;case context.float64Type:this.resolvedType=context.float64Type,this.kind==NodeKind.NULL&&(this.doubleValue=0),this.kind!=NodeKind.NAME&&(this.kind=NodeKind.FLOAT64)}},Node.prototype.clone=function(){var node=new Node;return node.kind=this.kind,void 0!==this.offset&&(node.offset=this.offset),void 0!==this.flags&&(node.flags=this.flags),void 0!==this.firstFlag&&(node.firstFlag=this.firstFlag),void 0!==this.range&&(node.range=this.range),void 0!==this.internalRange&&(node.internalRange=this.internalRange),this.hasValue&&(node.rawValue=this.__internal_rawValue),node},Node.prototype.becomeSymbolReference=function(symbol){this.kind=NodeKind.NAME,this.symbol=symbol,this.referenceValue=symbol.name,this.resolvedType=symbol.resolvedType,this.removeChildren()},Node.prototype.becomeIntegerConstant=function(value){this.kind=NodeKind.INT32,this.symbol=null,this.intValue=value,this.removeChildren()},Node.prototype.becomeLongConstant=function(value){this.kind=NodeKind.INT64,this.symbol=null,this.longValue=value,this.removeChildren()},Node.prototype.becomeFloatConstant=function(value){this.kind=NodeKind.FLOAT32,this.symbol=null,this.floatValue=value,this.removeChildren()},Node.prototype.becomeDoubleConstant=function(value){this.kind=NodeKind.FLOAT64,this.symbol=null,this.doubleValue=value,this.removeChildren()},Node.prototype.becomeBooleanConstant=function(value){this.kind=NodeKind.BOOLEAN,this.symbol=null,this.intValue=value?1:0,this.removeChildren()},Node.prototype.isNegativeInteger=function(){return this.kind==NodeKind.INT32&&this.intValue<0},Node.prototype.isNonNegativeInteger=function(){return this.kind==NodeKind.INT32&&this.intValue>=0},Node.prototype.isDeclare=function(){return 0!=(this.flags&exports.NODE_FLAG_DECLARE)},Node.prototype.isLibrary=function(){return 0!=(this.flags&exports.NODE_FLAG_LIBRARY)},Node.prototype.isVirtual=function(){return 0!=(this.flags&exports.NODE_FLAG_VIRTUAL)},Node.prototype.isExport=function(){return 0!=(this.flags&exports.NODE_FLAG_EXPORT)},Node.prototype.isImport=function(){return 0!=(this.flags&exports.NODE_FLAG_IMPORT)},Node.prototype.isExternalImport=function(){return this.isDeclare()&&!this.isLibrary()},Node.prototype.isStart=function(){return 0!=(this.flags&exports.NODE_FLAG_START)},Node.prototype.isJavaScript=function(){return 0!=(this.flags&exports.NODE_FLAG_JAVASCRIPT)},Node.prototype.isStatic=function(){return 0!=(this.flags&exports.NODE_FLAG_STATIC)},Node.prototype.isAnyfunc=function(){return 0!=(this.flags&exports.NODE_FLAG_ANYFUNC)},Node.prototype.isDeclareOrJavaScript=function(){return 0!=(this.flags&(exports.NODE_FLAG_DECLARE|exports.NODE_FLAG_JAVASCRIPT))},Node.prototype.isDeclareOrExport=function(){return 0!=(this.flags&(exports.NODE_FLAG_DECLARE|exports.NODE_FLAG_EXPORT))},Node.prototype.isGet=function(){return 0!=(this.flags&exports.NODE_FLAG_GET)},Node.prototype.isSet=function(){return 0!=(this.flags&exports.NODE_FLAG_SET)},Node.prototype.isOperator=function(){return 0!=(this.flags&exports.NODE_FLAG_OPERATOR)},Node.prototype.isPositive=function(){return 0!=(this.flags&exports.NODE_FLAG_POSITIVE)},Node.prototype.isPrivate=function(){return 0!=(this.flags&exports.NODE_FLAG_PRIVATE)},Node.prototype.isUnsafe=function(){return 0!=(this.flags&exports.NODE_FLAG_UNSAFE)},Node.prototype.isGeneric=function(){return 0!=(this.flags&exports.NODE_FLAG_GENERIC)},Node.prototype.isTemplate=function(){return this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_IS_TEMPLATE)},Node.prototype.isUnsignedOperator=function(){return 0!=(this.flags&exports.NODE_FLAG_UNSIGNED_OPERATOR)},Node.prototype.childCount=function(){for(var count=0,child=this.firstChild;null!=child;)count+=1,child=child.nextSibling;return count},Node.prototype.parameterCount=function(){var count=0,child=this.firstChild;if(child.kind==NodeKind.PARAMETERS)for(child=child.firstChild;null!=child;)count+=1,child=child.nextSibling;return count},Node.prototype.hasParameters=function(){if(this.firstChild){var child=this.firstChild;if(child.kind==NodeKind.PARAMETERS)return child.childCount()>0}return!1},Node.prototype.appendChild=function(child){child.parent=this,null==this.firstChild?(this.firstChild=child,this.firstChild.offset=0):(child.previousSibling=this.lastChild,this.lastChild.nextSibling=child,child.offset=this.lastChild.offset+1),this.lastChild=child},Node.prototype.insertChildBefore=function(after,before){if(null!=before){if(assert_1.assert(before!=after),assert_1.assert(null==before.parent),assert_1.assert(null==before.previousSibling),assert_1.assert(null==before.nextSibling),assert_1.assert(null==after||after.parent==this),null==after)return void this.appendChild(before);before.parent=this,before.previousSibling=after.previousSibling,before.nextSibling=after,null!=after.previousSibling?(assert_1.assert(after==after.previousSibling.nextSibling),after.previousSibling.nextSibling=before):(assert_1.assert(after==this.firstChild),this.firstChild=before),after.previousSibling=before}},Node.prototype.insertChildAfter=function(before,after){if(null!=after){if(assert_1.assert(before!=after),assert_1.assert(null==after.parent),assert_1.assert(null==after.previousSibling),assert_1.assert(null==after.nextSibling),assert_1.assert(null==before||before.parent==this),null==before)return void this.appendChild(after);after.parent=this,after.previousSibling=before,after.nextSibling=before.nextSibling,null!=before.nextSibling&&(assert_1.assert(before==before.nextSibling.previousSibling),before.nextSibling.previousSibling=after),before.nextSibling=after}},Node.prototype.remove=function(){return assert_1.assert(null!=this.parent),null!=this.previousSibling?(assert_1.assert(this.previousSibling.nextSibling==this),this.previousSibling.nextSibling=this.nextSibling):(assert_1.assert(this.parent.firstChild==this),this.parent.firstChild=this.nextSibling),null!=this.nextSibling?(assert_1.assert(this.nextSibling.previousSibling==this),this.nextSibling.previousSibling=this.previousSibling):(assert_1.assert(this.parent.lastChild==this),this.parent.lastChild=this.previousSibling),this.parent=null,this.previousSibling=null,this.nextSibling=null,this},Node.prototype.removeChildren=function(){for(;null!=this.lastChild;)this.lastChild.remove()},Node.prototype.replaceWith=function(node){assert_1.assert(node!=this),assert_1.assert(null!=this.parent),assert_1.assert(null==node.parent),assert_1.assert(null==node.previousSibling),assert_1.assert(null==node.nextSibling),node.parent=this.parent,node.previousSibling=this.previousSibling,node.nextSibling=this.nextSibling,null!=this.previousSibling?(assert_1.assert(this.previousSibling.nextSibling==this),this.previousSibling.nextSibling=node):(assert_1.assert(this.parent.firstChild==this),this.parent.firstChild=node),null!=this.nextSibling?(assert_1.assert(this.nextSibling.previousSibling==this),this.nextSibling.previousSibling=node):(assert_1.assert(this.parent.lastChild==this),this.parent.lastChild=node),this.parent=null,this.previousSibling=null,this.nextSibling=null},Node.prototype.isType=function(){return this.kind==NodeKind.TYPE||this.kind==NodeKind.POINTER_TYPE||null!=this.symbol&&symbol_1.isType(this.symbol.kind)},Node.prototype.isCallValue=function(){return this.parent.kind==NodeKind.CALL&&this==this.parent.callValue()},Node.prototype.isAssignTarget=function(){return this.parent.kind==NodeKind.ASSIGN&&this==this.parent.binaryLeft()},Node.prototype.withRange=function(range){return this.range=range,this},Node.prototype.withInternalRange=function(range){return this.internalRange=range,this},Node.prototype.functionFirstArgument=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2);var child=this.firstChild;return child.kind==NodeKind.PARAMETERS&&(child=child.nextSibling),child},Node.prototype.functionLastArgument=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2);var child=this.firstChild;child.kind==NodeKind.PARAMETERS&&(child=child.nextSibling);for(var lastArgument=null;null!=child;){var nextChild=child.nextSibling;nextChild.kind!==NodeKind.VARIABLE?(lastArgument=child,child=null):child=nextChild}return lastArgument},Node.prototype.functionFirstArgumentIgnoringThis=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(null!=this.symbol);var child=this.functionFirstArgument();return this.symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE&&(child=child.nextSibling),child},Node.prototype.functionReturnType=function(){return assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(isExpression(this.lastChild.previousSibling)),this.lastChild.previousSibling},Node.prototype.constructorNode=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>0),assert_1.assert(this.resolvedType.symbol.node.kind==NodeKind.CLASS),this.resolvedType.symbol.node.constructorFunctionNode},Node.prototype.functionBody=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(this.lastChild.kind==NodeKind.BLOCK||this.lastChild.kind==NodeKind.EMPTY);var body=this.lastChild;return body.kind==NodeKind.BLOCK?body:null},Node.prototype.newType=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.deleteType=function(){return assert_1.assert(this.kind==NodeKind.DELETE),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.callValue=function(){return assert_1.assert(this.kind==NodeKind.CALL),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.castValue=function(){return assert_1.assert(this.kind==NodeKind.CAST),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.castType=function(){return assert_1.assert(this.kind==NodeKind.CAST),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.alignOfType=function(){return assert_1.assert(this.kind==NodeKind.ALIGN_OF),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.sizeOfType=function(){return assert_1.assert(this.kind==NodeKind.SIZE_OF),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.dotTarget=function(){return assert_1.assert(this.kind==NodeKind.DOT),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.returnValue=function(){return assert_1.assert(this.kind==NodeKind.RETURN),assert_1.assert(this.childCount()<=1),assert_1.assert(null==this.firstChild||isExpression(this.firstChild)),this.firstChild},Node.prototype.ifReturnNode=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(null!==this.firstChild),assert_1.assert(null!==this.firstChild.nextSibling),this.firstChild.nextSibling.returnNode||null},Node.prototype.deleteValue=function(){return assert_1.assert(this.kind==NodeKind.DELETE),assert_1.assert(this.childCount()<=1),assert_1.assert(null==this.firstChild||isExpression(this.firstChild)),this.firstChild},Node.prototype.extendsType=function(){return assert_1.assert(this.kind==NodeKind.EXTENDS),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.firstGenericType=function(){return assert_1.assert(this.firstChild.kind==NodeKind.PARAMETERS),assert_1.assert(this.firstChild.childCount()>0),this.firstChild.firstChild},Node.prototype.variableType=function(){assert_1.assert(this.kind==NodeKind.VARIABLE),assert_1.assert(this.childCount()<=2),assert_1.assert(isExpression(this.firstChild)||this.firstChild.kind==NodeKind.EMPTY);var type=this.firstChild;return type.kind!=NodeKind.EMPTY?type:null},Node.prototype.variableValue=function(){return assert_1.assert(this.kind==NodeKind.VARIABLE),assert_1.assert(this.childCount()<=2),assert_1.assert(null==this.firstChild.nextSibling||isExpression(this.firstChild.nextSibling)),this.firstChild.nextSibling},Node.prototype.hasVariableValue=function(){return assert_1.assert(this.kind==NodeKind.VARIABLE),void 0!=this.firstChild&&void 0!=this.firstChild.nextSibling},Node.prototype.expressionValue=function(){return assert_1.assert(this.kind==NodeKind.EXPRESSION),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.binaryLeft=function(){return assert_1.assert(isBinary(this.kind)),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.binaryRight=function(){return assert_1.assert(isBinary(this.kind)),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.unaryValue=function(){return assert_1.assert(isUnary(this.kind)),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.pointer=function(){return assert_1.assert(this.kind==NodeKind.POINTER_INDEX),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.pointerOffset=function(){return assert_1.assert(this.firstChild),assert_1.assert(this.firstChild.nextSibling),this.firstChild.nextSibling.intValue},Node.prototype.whileValue=function(){return assert_1.assert(this.kind==NodeKind.WHILE),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.whileBody=function(){return assert_1.assert(this.kind==NodeKind.WHILE),assert_1.assert(2==this.childCount()),assert_1.assert(this.lastChild.kind==NodeKind.BLOCK),this.lastChild},Node.prototype.hookValue=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.hookTrue=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.firstChild.nextSibling)),this.firstChild.nextSibling},Node.prototype.hookFalse=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.indexTarget=function(){return assert_1.assert(this.kind==NodeKind.INDEX),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.ifValue=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.ifTrue=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(this.firstChild.nextSibling.kind==NodeKind.BLOCK),this.firstChild.nextSibling},Node.prototype.ifFalse=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(null==this.firstChild.nextSibling.nextSibling||this.firstChild.nextSibling.nextSibling.kind==NodeKind.BLOCK),this.firstChild.nextSibling.nextSibling||null},Node.prototype.expandCallIntoOperatorTree=function(){if(this.kind!=NodeKind.CALL)return!1;var value=this.callValue(),symbol=value.symbol;if(value.kind==NodeKind.DOT&&symbol.node.isOperator()&&symbol.node.isDeclare()){var binaryKind=NodeKind.NULL;if("%"==symbol.name?binaryKind=NodeKind.REMAINDER:"&"==symbol.name?binaryKind=NodeKind.BITWISE_AND:"*"==symbol.name?binaryKind=NodeKind.MULTIPLY:"**"==symbol.name?binaryKind=NodeKind.EXPONENT:"/"==symbol.name?binaryKind=NodeKind.DIVIDE:"<"==symbol.name?binaryKind=NodeKind.LESS_THAN:"<<"==symbol.name?binaryKind=NodeKind.SHIFT_LEFT:"=="==symbol.name?binaryKind=NodeKind.EQUAL:">"==symbol.name?binaryKind=NodeKind.GREATER_THAN:">>"==symbol.name?binaryKind=NodeKind.SHIFT_RIGHT:"[]"==symbol.name?binaryKind=NodeKind.INDEX:"^"==symbol.name?binaryKind=NodeKind.BITWISE_XOR:"|"==symbol.name&&(binaryKind=NodeKind.BITWISE_OR),binaryKind!=NodeKind.NULL)return this.kind=binaryKind,value.remove(),this.insertChildBefore(this.firstChild,value.dotTarget().remove()),!0;if("[]="==symbol.name){this.kind=NodeKind.ASSIGN;var target=createIndex(value.remove().dotTarget().remove());return target.appendChild(this.firstChild.remove()),this.insertChildBefore(this.firstChild,target),!0}}return!1},Node.prototype.arrayLength=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),assert_1.assert(this.firstChild.resolvedType.isArray()),this.firstChild.nextSibling},Node}();exports.Node=Node,exports.createNew=createNew,exports.createDelete=createDelete,exports.createHook=createHook,exports.createIndex=createIndex,exports.createNull=createNull,exports.createUndefined=createUndefined,exports.createThis=createThis,exports.createAddressOf=createAddressOf,exports.createDereference=createDereference,exports.createAlignOf=createAlignOf,exports.createSizeOf=createSizeOf,exports.createboolean=createboolean,exports.createInt=createInt,exports.createLong=createLong,exports.createFloat=createFloat,exports.createDouble=createDouble,exports.createString=createString,exports.createArray=createArray,exports.createName=createName,exports.createType=createType,exports.createAny=createAny,exports.createEmpty=createEmpty,exports.createExpression=createExpression,exports.createBlock=createBlock,exports.createModule=createModule,exports.createClass=createClass,exports.createEnum=createEnum,exports.createIf=createIf,exports.createWhile=createWhile,exports.createReturn=createReturn,exports.createImports=createImports,exports.createImport=createImport,exports.createImportFrom=createImportFrom,exports.createVariables=createVariables,exports.createConstants=createConstants,exports.createParameters=createParameters,exports.createExtends=createExtends,exports.createImplements=createImplements,exports.createParameter=createParameter,exports.createVariable=createVariable,exports.createFunction=createFunction,exports.createUnary=createUnary,exports.createBinary=createBinary,exports.createCall=createCall,exports.createCast=createCast,exports.createDot=createDot,exports.createSymbolReference=createSymbolReference,exports.createMemberReference=createMemberReference,exports.createParseError=createParseError,exports.createJSNumber=createJSNumber,exports.createJSObject=createJSObject,exports.createJSString=createJSString,exports.createJSArray=createJSArray},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});!function(WasmExternalKind){WasmExternalKind[WasmExternalKind.Function=0]="Function",WasmExternalKind[WasmExternalKind.Table=1]="Table",WasmExternalKind[WasmExternalKind.Memory=2]="Memory",WasmExternalKind[WasmExternalKind.Global=3]="Global"}(exports.WasmExternalKind||(exports.WasmExternalKind={}))},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WasmOpcode={UNREACHABLE:0,NOP:1,BLOCK:2,LOOP:3,IF:4,IF_ELSE:5,END:11,BR:12,BR_IF:13,BR_TABLE:14,RETURN:15,CALL:16,CALL_INDIRECT:17,DROP:26,SELECT:27,GET_LOCAL:32,SET_LOCAL:33,TEE_LOCAL:34,GET_GLOBAL:35,SET_GLOBAL:36,I32_LOAD:40,I64_LOAD:41,F32_LOAD:42,F64_LOAD:43,I32_LOAD8_S:44,I32_LOAD8_U:45,I32_LOAD16_S:46,I32_LOAD16_U:47,I64_LOAD8_S:48,I64_LOAD8_U:49,I64_LOAD16_S:50,I64_LOAD16_U:51,I64_LOAD32_S:52,I64_LOAD32_U:53,I32_STORE:54,I64_STORE:55,F32_STORE:56,F64_STORE:57,I32_STORE8:58,I32_STORE16:59,I64_STORE8:60,I64_STORE16:61,I64_STORE32:62,MEMORY_SIZE:63,GROW_MEMORY:64,I32_CONST:65,I64_CONST:66,F32_CONST:67,F64_CONST:68,I32_EQZ:69,I32_EQ:70,I32_NE:71,I32_LT_S:72,I32_LT_U:73,I32_GT_S:74,I32_GT_U:75,I32_LE_S:76,I32_LE_U:77,I32_GE_S:78,I32_GE_U:79,I64_EQZ:80,I64_EQ:81,I64_NE:82,I64_LT_S:83,I64_LT_U:84,I64_GT_S:85,I64_GT_U:86,I64_LE_S:87,I64_LE_U:88,I64_GE_S:89,I64_GE_U:90,F32_EQ:91,F32_NE:92,F32_LT:93,F32_GT:94,F32_LE:95,F32_GE:96,F64_EQ:97,F64_NE:98,F64_LT:99,F64_GT:100,F64_LE:101,F64_GE:102,I32_CLZ:103,I32_CTZ:104,I32_POPCNT:105,I32_ADD:106,I32_SUB:107,I32_MUL:108,I32_DIV_S:109,I32_DIV_U:110,I32_REM_S:111,I32_REM_U:112,I32_AND:113,I32_OR:114,I32_XOR:115,I32_SHL:116,I32_SHR_S:117,I32_SHR_U:118,I32_ROTL:119,I32_ROTR:120,I64_CLZ:121,I64_CTZ:122,I64_POPCNT:123,I64_ADD:124,I64_SUB:125,I64_MUL:126,I64_DIV_S:127,I64_DIV_U:128,I64_REM_S:129,I64_REM_U:130,I64_AND:131,I64_OR:132,I64_XOR:133,I64_SHL:134,I64_SHR_S:135,I64_SHR_U:136,I64_ROTL:137,I64_ROTR:138,F32_ABS:139,F32_NEG:140,F32_CEIL:141,F32_FLOOR:142,F32_TRUNC:143,F32_NEAREST:144,F32_SQRT:145,F32_ADD:146,F32_SUB:147,F32_MUL:148,F32_DIV:149,F32_MIN:150,F32_MAX:151,F32_COPYSIGN:152,F64_ABS:153,F64_NEG:154,F64_CEIL:155,F64_FLOOR:156,F64_TRUNC:157,F64_NEAREST:158,F64_SQRT:159,F64_ADD:160,F64_SUB:161,F64_MUL:162,F64_DIV:163,F64_MIN:164,F64_MAX:165,F64_COPYSIGN:166,I32_WRAP_I64:167,I32_TRUNC_S_F32:168,I32_TRUNC_U_F32:169,I32_TRUNC_S_F64:170,I32_TRUNC_U_F64:171,I64_EXTEND_S_I32:172,I64_EXTEND_U_I32:173,I64_TRUNC_S_F32:174,I64_TRUNC_U_F32:175,I64_TRUNC_S_F64:176,I64_TRUNC_U_F64:177,F32_CONVERT_S_I32:178,F32_CONVERT_U_I32:179,F32_CONVERT_S_I64:180,F32_CONVERT_U_I64:181,F32_DEMOTE_F64:182,F64_CONVERT_S_I32:183,F64_CONVERT_U_I32:184,F64_CONVERT_S_I64:185,F64_CONVERT_U_I64:186,F64_PROMOTE_F32:187,I32_REINTERPRET_F32:188,I64_REINTERPRET_F64:189,F32_REINTERPRET_I32:190,F64_REINTERPRET_I64:191},exports.WasmOpcode[exports.WasmOpcode.UNREACHABLE]="unreachable",exports.WasmOpcode[exports.WasmOpcode.NOP]="nop",exports.WasmOpcode[exports.WasmOpcode.BLOCK]="block",exports.WasmOpcode[exports.WasmOpcode.LOOP]="loop",exports.WasmOpcode[exports.WasmOpcode.IF]="if",exports.WasmOpcode[exports.WasmOpcode.IF_ELSE]="else",exports.WasmOpcode[exports.WasmOpcode.END]="end",exports.WasmOpcode[exports.WasmOpcode.BR]="br",exports.WasmOpcode[exports.WasmOpcode.BR_IF]="br_if",exports.WasmOpcode[exports.WasmOpcode.BR_TABLE]="br_table",exports.WasmOpcode[exports.WasmOpcode.RETURN]="return",exports.WasmOpcode[exports.WasmOpcode.CALL]="call",exports.WasmOpcode[exports.WasmOpcode.CALL_INDIRECT]="call_indirect",exports.WasmOpcode[exports.WasmOpcode.DROP]="drop",exports.WasmOpcode[exports.WasmOpcode.SELECT]="select",exports.WasmOpcode[exports.WasmOpcode.GET_LOCAL]="get_local",exports.WasmOpcode[exports.WasmOpcode.SET_LOCAL]="set_local",exports.WasmOpcode[exports.WasmOpcode.TEE_LOCAL]="tee_local",exports.WasmOpcode[exports.WasmOpcode.GET_GLOBAL]="get_global",exports.WasmOpcode[exports.WasmOpcode.SET_GLOBAL]="set_global",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD]="i32.load",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD]="i64.load",exports.WasmOpcode[exports.WasmOpcode.F32_LOAD]="f32.load",exports.WasmOpcode[exports.WasmOpcode.F64_LOAD]="f64.load",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD8_S]="i32.load8_s",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD8_U]="i32_load8_u",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD16_S]="i32_load16_s",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD16_U]="i32_load16_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD8_S]="i64.load8_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD8_U]="i64.load8_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD16_S]="i64.load16_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD16_U]="i64.load16_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD32_S]="i64.load32_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD32_U]="i64.load32_u",exports.WasmOpcode[exports.WasmOpcode.I32_STORE]="i32.store",exports.WasmOpcode[exports.WasmOpcode.I64_STORE]="i64.store",exports.WasmOpcode[exports.WasmOpcode.F32_STORE]="f32.store",exports.WasmOpcode[exports.WasmOpcode.F64_STORE]="f64.store",exports.WasmOpcode[exports.WasmOpcode.I32_STORE8]="i32.store8",exports.WasmOpcode[exports.WasmOpcode.I32_STORE16]="i32.store16",exports.WasmOpcode[exports.WasmOpcode.I64_STORE8]="i64.store8",exports.WasmOpcode[exports.WasmOpcode.I64_STORE16]="i64.store16",exports.WasmOpcode[exports.WasmOpcode.I64_STORE32]="i64.store32",exports.WasmOpcode[exports.WasmOpcode.MEMORY_SIZE]="current_memory",exports.WasmOpcode[exports.WasmOpcode.GROW_MEMORY]="grow_memory",exports.WasmOpcode[exports.WasmOpcode.I32_CONST]="i32.const",exports.WasmOpcode[exports.WasmOpcode.I64_CONST]="i64.const",exports.WasmOpcode[exports.WasmOpcode.F32_CONST]="f32.const",exports.WasmOpcode[exports.WasmOpcode.F64_CONST]="f64.const",exports.WasmOpcode[exports.WasmOpcode.I32_EQZ]="i32.eqz",exports.WasmOpcode[exports.WasmOpcode.I32_EQ]="i32.eq",exports.WasmOpcode[exports.WasmOpcode.I32_NE]="i32.ne",exports.WasmOpcode[exports.WasmOpcode.I32_LT_S]="i32.lt_s",exports.WasmOpcode[exports.WasmOpcode.I32_LT_U]="i32.lt_u",exports.WasmOpcode[exports.WasmOpcode.I32_GT_S]="i32.gt_s",exports.WasmOpcode[exports.WasmOpcode.I32_GT_U]="i32.gt_u",exports.WasmOpcode[exports.WasmOpcode.I32_LE_S]="i32.le_s",exports.WasmOpcode[exports.WasmOpcode.I32_LE_U]="i32.le_u",exports.WasmOpcode[exports.WasmOpcode.I32_GE_S]="i32.ge_s",exports.WasmOpcode[exports.WasmOpcode.I32_GE_U]="i32.ge_u",exports.WasmOpcode[exports.WasmOpcode.I64_EQZ]="i64.eqz",exports.WasmOpcode[exports.WasmOpcode.I64_EQ]="i64.eq",exports.WasmOpcode[exports.WasmOpcode.I64_NE]="i64.ne",exports.WasmOpcode[exports.WasmOpcode.I64_LT_S]="i64.lt_s",exports.WasmOpcode[exports.WasmOpcode.I64_LT_U]="i64.lt_u",exports.WasmOpcode[exports.WasmOpcode.I64_GT_S]="i64.gt_s",exports.WasmOpcode[exports.WasmOpcode.I64_GT_U]="i64.gt_u",exports.WasmOpcode[exports.WasmOpcode.I64_LE_S]="i64.le_s",exports.WasmOpcode[exports.WasmOpcode.I64_LE_U]="i64.le_u",exports.WasmOpcode[exports.WasmOpcode.I64_GE_S]="i64.ge_s",exports.WasmOpcode[exports.WasmOpcode.I64_GE_U]="i64.ge_u",exports.WasmOpcode[exports.WasmOpcode.F32_EQ]="f32.eq",exports.WasmOpcode[exports.WasmOpcode.F32_NE]="f32.ne",exports.WasmOpcode[exports.WasmOpcode.F32_LT]="f32.lt",exports.WasmOpcode[exports.WasmOpcode.F32_GT]="f32.gt",exports.WasmOpcode[exports.WasmOpcode.F32_LE]="f32.le",exports.WasmOpcode[exports.WasmOpcode.F32_GE]="f32.ge",exports.WasmOpcode[exports.WasmOpcode.F64_EQ]="f64.eq",exports.WasmOpcode[exports.WasmOpcode.F64_NE]="f64.ne",exports.WasmOpcode[exports.WasmOpcode.F64_LT]="f64.lt",exports.WasmOpcode[exports.WasmOpcode.F64_GT]="f64.gt",exports.WasmOpcode[exports.WasmOpcode.F64_LE]="f64.le",exports.WasmOpcode[exports.WasmOpcode.F64_GE]="f64.ge",exports.WasmOpcode[exports.WasmOpcode.I32_CLZ]="i32.clz",exports.WasmOpcode[exports.WasmOpcode.I32_CTZ]="i32.ctz",exports.WasmOpcode[exports.WasmOpcode.I32_POPCNT]="i32.popcnt",exports.WasmOpcode[exports.WasmOpcode.I32_ADD]="i32.add",exports.WasmOpcode[exports.WasmOpcode.I32_SUB]="i32.sub",exports.WasmOpcode[exports.WasmOpcode.I32_MUL]="i32.mul",exports.WasmOpcode[exports.WasmOpcode.I32_DIV_S]="i32.div_s",exports.WasmOpcode[exports.WasmOpcode.I32_DIV_U]="i32.div_u",exports.WasmOpcode[exports.WasmOpcode.I32_REM_S]="i32.rem_s",exports.WasmOpcode[exports.WasmOpcode.I32_REM_U]="i32.rem_u",exports.WasmOpcode[exports.WasmOpcode.I32_AND]="i32.and",exports.WasmOpcode[exports.WasmOpcode.I32_OR]="i32.or",exports.WasmOpcode[exports.WasmOpcode.I32_XOR]="i32.xor",exports.WasmOpcode[exports.WasmOpcode.I32_SHL]="i32.shl",exports.WasmOpcode[exports.WasmOpcode.I32_SHR_S]="i32.shr_s",exports.WasmOpcode[exports.WasmOpcode.I32_SHR_U]="i32.shr_u",exports.WasmOpcode[exports.WasmOpcode.I32_ROTL]="i32.rotl",exports.WasmOpcode[exports.WasmOpcode.I32_ROTR]="i32.rotr",exports.WasmOpcode[exports.WasmOpcode.I64_CLZ]="i64.clz",exports.WasmOpcode[exports.WasmOpcode.I64_CTZ]="i64.ctz",exports.WasmOpcode[exports.WasmOpcode.I64_POPCNT]="i64.popcnt",exports.WasmOpcode[exports.WasmOpcode.I64_ADD]="i64.add",exports.WasmOpcode[exports.WasmOpcode.I64_SUB]="i64.sub",exports.WasmOpcode[exports.WasmOpcode.I64_MUL]="i64.mul",exports.WasmOpcode[exports.WasmOpcode.I64_DIV_S]="i64.div_s",exports.WasmOpcode[exports.WasmOpcode.I64_DIV_U]="i64.div_u",exports.WasmOpcode[exports.WasmOpcode.I64_REM_S]="i64.rem_s",exports.WasmOpcode[exports.WasmOpcode.I64_REM_U]="i64.rem_u",exports.WasmOpcode[exports.WasmOpcode.I64_AND]="i64.and",exports.WasmOpcode[exports.WasmOpcode.I64_OR]="i64.or",exports.WasmOpcode[exports.WasmOpcode.I64_XOR]="i64.xor",exports.WasmOpcode[exports.WasmOpcode.I64_SHL]="i64.shl",exports.WasmOpcode[exports.WasmOpcode.I64_SHR_S]="i64.shr_s",exports.WasmOpcode[exports.WasmOpcode.I64_SHR_U]="i64.shr_u",exports.WasmOpcode[exports.WasmOpcode.I64_ROTL]="i64.rotl",exports.WasmOpcode[exports.WasmOpcode.I64_ROTR]="i64.rotr",exports.WasmOpcode[exports.WasmOpcode.F32_ABS]="f32.abs",exports.WasmOpcode[exports.WasmOpcode.F32_NEG]="f32.neg",exports.WasmOpcode[exports.WasmOpcode.F32_CEIL]="f32.ceil",exports.WasmOpcode[exports.WasmOpcode.F32_FLOOR]="f32.floor",exports.WasmOpcode[exports.WasmOpcode.F32_TRUNC]="f32.trunc",exports.WasmOpcode[exports.WasmOpcode.F32_NEAREST]="f32.nearest",exports.WasmOpcode[exports.WasmOpcode.F32_SQRT]="f32.sqrt",exports.WasmOpcode[exports.WasmOpcode.F32_ADD]="f32.add",exports.WasmOpcode[exports.WasmOpcode.F32_SUB]="f32.sub",exports.WasmOpcode[exports.WasmOpcode.F32_MUL]="f32.mul",exports.WasmOpcode[exports.WasmOpcode.F32_DIV]="f32.div",exports.WasmOpcode[exports.WasmOpcode.F32_MIN]="f32.min",exports.WasmOpcode[exports.WasmOpcode.F32_MAX]="f32.max",exports.WasmOpcode[exports.WasmOpcode.F32_COPYSIGN]="f32.copysign",exports.WasmOpcode[exports.WasmOpcode.F64_ABS]="f64.abs",exports.WasmOpcode[exports.WasmOpcode.F64_NEG]="f64.neg",exports.WasmOpcode[exports.WasmOpcode.F64_CEIL]="f64.ceil",exports.WasmOpcode[exports.WasmOpcode.F64_FLOOR]="f64.floor",exports.WasmOpcode[exports.WasmOpcode.F64_TRUNC]="f64.trunc",exports.WasmOpcode[exports.WasmOpcode.F64_NEAREST]="f64.nearest",exports.WasmOpcode[exports.WasmOpcode.F64_SQRT]="f64.sqrt",exports.WasmOpcode[exports.WasmOpcode.F64_ADD]="f64.add",exports.WasmOpcode[exports.WasmOpcode.F64_SUB]="f64.sub",exports.WasmOpcode[exports.WasmOpcode.F64_MUL]="f64.mul",exports.WasmOpcode[exports.WasmOpcode.F64_DIV]="f64.div",exports.WasmOpcode[exports.WasmOpcode.F64_MIN]="f64.min",exports.WasmOpcode[exports.WasmOpcode.F64_MAX]="f64.max",exports.WasmOpcode[exports.WasmOpcode.F64_COPYSIGN]="f64.copysign",exports.WasmOpcode[exports.WasmOpcode.I32_WRAP_I64]="i32.wrap/i64",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_S_F32]="i32.trunc_s/f32",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_U_F32]="i32.trunc_u/f32",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_S_F64]="i32.trunc_s/f64",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_U_F64]="i32.trunc_u/f64",exports.WasmOpcode[exports.WasmOpcode.I64_EXTEND_S_I32]="i64.extend_s/i32",exports.WasmOpcode[exports.WasmOpcode.I64_EXTEND_U_I32]="i64.extend_u/i32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_S_F32]="i64.trunc_s/f32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_U_F32]="i64.trunc_u/f32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_S_F64]="i64.trunc_s/f64",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_U_F64]="i64.trunc_u/f64",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_S_I32]="f32.convert_s/i32",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_U_I32]="f32.convert_u/i32",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_S_I64]="f32.convert_s/i64",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_U_I64]="f32.convert_u/i64",exports.WasmOpcode[exports.WasmOpcode.F32_DEMOTE_F64]="f32.demote/f64",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_S_I32]="f64.convert_s/i32",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_U_I32]="f64.convert_u/i32",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_S_I64]="f64.convert_s/i64",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_U_I64]="f64.convert_u/i64",exports.WasmOpcode[exports.WasmOpcode.F64_PROMOTE_F32]="f64.promote/f32",exports.WasmOpcode[exports.WasmOpcode.I32_REINTERPRET_F32]="i32.reinterpret/f32",exports.WasmOpcode[exports.WasmOpcode.I64_REINTERPRET_F64]="i64.reinterpret/f64",exports.WasmOpcode[exports.WasmOpcode.F32_REINTERPRET_I32]="f32.reinterpret/i32",exports.WasmOpcode[exports.WasmOpcode.F64_REINTERPRET_I64]="f64.reinterpret/i64",Object.freeze(exports.WasmOpcode)},function(module,exports,__webpack_require__){"use strict";function getWasmFunctionName(symbol){if(void 0===symbol||null===symbol)return"";var moduleName=symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE?symbol.parent().internalName:"";return(""==moduleName?"":moduleName+"_")+symbol.internalName}function symbolToWasmType(symbol,bitness){var type=symbol.resolvedType;return type.isFloat()?wasm_type_1.WasmType.F32:type.isDouble()?wasm_type_1.WasmType.F64:type.isInteger()||bitness==bitness_1.Bitness.x32&&type.pointerTo?wasm_type_1.WasmType.I32:type.isLong()||bitness==bitness_1.Bitness.x64&&type.pointerTo?wasm_type_1.WasmType.I64:wasm_type_1.WasmType.I32}function wasmToTurboType(type){switch(type){case wasm_type_1.WasmType.VOID:return"void";case wasm_type_1.WasmType.I32:return"int32";case wasm_type_1.WasmType.I64:return"int64";case wasm_type_1.WasmType.F32:return"float32";case wasm_type_1.WasmType.F64:return"float64"}}function typeToDataType(type,bitness){return type.isFloat()?"F32":type.isDouble()?"F64":type.isInteger()||bitness==bitness_1.Bitness.x32&&type.pointerTo?"I32":type.isLong()||bitness==bitness_1.Bitness.x64&&type.pointerTo?"I64":"I32"}function getTypedArrayElementSize(name){switch(name){case"Uint8ClampedArray":case"Uint8Array":case"Int8Array":return 1;case"Uint16Array":case"Int16Array":return 2;case"Uint32Array":case"Int32Array":case"Float32Array":return 4;case"Float64Array":return 8;default:throw"unknown typed array"}}Object.defineProperty(exports,"__esModule",{value:!0});var bitness_1=__webpack_require__(22),wasm_type_1=__webpack_require__(6),symbol_1=__webpack_require__(7);exports.getWasmFunctionName=getWasmFunctionName,exports.symbolToWasmType=symbolToWasmType,exports.wasmToTurboType=wasmToTurboType,exports.typeToDataType=typeToDataType,exports.getTypedArrayElementSize=getTypedArrayElementSize},function(module,exports,__webpack_require__){"use strict";function isKeyword(kind){return kind>=TokenKind.ALIGNOF&&kind<=TokenKind.WHILE}function splitToken(first,firstKind,secondKind){var range=first.range;assert_1.assert(range.end-range.start>=2);var second=new Token;second.kind=secondKind,second.range=log_1.createRange(range.source,range.start+1,range.end),second.next=first.next,first.kind=firstKind,first.next=second,range.end=range.start+1}function tokenToString(token){return token==TokenKind.END_OF_FILE?"end of file":token==TokenKind.CHARACTER?"character literal":token==TokenKind.IDENTIFIER?"identifier":token==TokenKind.INT32?"integer32 literal":token==TokenKind.INT64?"integer64 literal":token==TokenKind.FLOAT32?"float32 literal":token==TokenKind.FLOAT64?"float64 literal":token==TokenKind.STRING?"string literal":token==TokenKind.ARRAY?"array literal":token==TokenKind.ASSIGN?"'='":token==TokenKind.BITWISE_AND?"'&'":token==TokenKind.BITWISE_OR?"'|'":token==TokenKind.BITWISE_XOR?"'^'":token==TokenKind.COLON?"':'":token==TokenKind.COMMA?"','":token==TokenKind.COMPLEMENT?"'~'":token==TokenKind.DIVIDE?"'/'":token==TokenKind.DOT?"'.'":token==TokenKind.EQUAL?"'=='":token==TokenKind.EXPONENT?"'**'":token==TokenKind.GREATER_THAN?"'>'":token==TokenKind.GREATER_THAN_EQUAL?"'>='":token==TokenKind.LEFT_BRACE?"'{'":token==TokenKind.LEFT_BRACKET?"'['":token==TokenKind.LEFT_PARENTHESIS?"'('":token==TokenKind.LESS_THAN?"'<'":token==TokenKind.LESS_THAN_EQUAL?"'<='":token==TokenKind.LOGICAL_AND?"'&&'":token==TokenKind.LOGICAL_OR?"'||'":token==TokenKind.MINUS?"'-'":token==TokenKind.MINUS_MINUS?"'--'":token==TokenKind.MULTIPLY?"'*'":token==TokenKind.NOT?"'!'":token==TokenKind.NOT_EQUAL?"'!='":token==TokenKind.PLUS?"'+'":token==TokenKind.PLUS_PLUS?"'++'":token==TokenKind.QUESTION_MARK?"'?'":token==TokenKind.REMAINDER?"'%'":token==TokenKind.RIGHT_BRACE?"'}'":token==TokenKind.RIGHT_BRACKET?"']'":token==TokenKind.RIGHT_PARENTHESIS?"')'":token==TokenKind.SEMICOLON?"';'":token==TokenKind.SHIFT_LEFT?"'<<'":token==TokenKind.SHIFT_RIGHT?"'>>'":token==TokenKind.FROM?"'from'":token==TokenKind.ALIGNOF?"'alignof'":token==TokenKind.AS?"'as'":token==TokenKind.BREAK?"'break'":token==TokenKind.MODULE?"'namespace'":token==TokenKind.CLASS?"'class'":token==TokenKind.CONST?"'const'":token==TokenKind.CONTINUE?"'continue'":token==TokenKind.DECLARE?"'declare'":token==TokenKind.ELSE?"'else'":token==TokenKind.ENUM?"'enum'":token==TokenKind.EXPORT?"'export'":token==TokenKind.EXTENDS?"'extends'":token==TokenKind.FALSE?"'false'":token==TokenKind.FUNCTION?"'function'":token==TokenKind.ANYFUNC?"'anyfunc'":token==TokenKind.IF?"'if'":token==TokenKind.IMPLEMENTS?"'implements'":token==TokenKind.IMPORT?"'import'":token==TokenKind.LET?"'let'":token==TokenKind.NEW?"'new'":token==TokenKind.DELETE?"'delete'":token==TokenKind.NULL?"'null'":token==TokenKind.UNDEFINED?"'undefined'":token==TokenKind.OPERATOR?"'operator'":token==TokenKind.PRIVATE?"'private'":token==TokenKind.PROTECTED?"'protected'":token==TokenKind.PUBLIC?"'public'":token==TokenKind.RETURN?"'return'":token==TokenKind.SIZEOF?"'sizeof'":token==TokenKind.STATIC?"'static'":token==TokenKind.THIS?"'this'":token==TokenKind.TRUE?"'true'":token==TokenKind.UNSAFE?"'unsafe'":token==TokenKind.JAVASCRIPT?"'@JS'":token==TokenKind.START?"'@start'":token==TokenKind.VIRTUAL?"'@virtual'":token==TokenKind.VAR?"'var'":token==TokenKind.WHILE?"'while'":token==TokenKind.PREPROCESSOR_DEFINE?"'#define'":token==TokenKind.PREPROCESSOR_ELIF?"'#elif'":token==TokenKind.PREPROCESSOR_ELSE?"'#else'":token==TokenKind.PREPROCESSOR_ENDIF?"'#endif'":token==TokenKind.PREPROCESSOR_ERROR?"'#error'":token==TokenKind.PREPROCESSOR_IF?"'#if'":token==TokenKind.PREPROCESSOR_NEWLINE?"newline":token==TokenKind.PREPROCESSOR_UNDEF?"'#undef'":token==TokenKind.PREPROCESSOR_WARNING?"'#warning'":(assert_1.assert(!1),null)}function isAlpha(c){return c>="a"&&c<="z"||c>="A"&&c<="Z"||"_"==c}function isASCII(c){return c>=32&&c<=126}function isNumber(c){return c>="0"&&c<="9"}function isDigit(c,base){return""!=c.trim()&&(16==base?isNumber(c)||c>="A"&&c<="F"||c>="a"&&c<="f":!isNaN(c))}function tokenize(source,log){for(var first=null,last=null,contents=source.contents,limit=contents.length,needsPreprocessor=!1,wantNewline=!1,i=0;i=2&&length<=10){var text=contents.slice(start,i);2==length?"as"==text?kind=TokenKind.AS:"if"==text&&(kind=TokenKind.IF):3==length?"let"==text?kind=TokenKind.LET:"new"==text?kind=TokenKind.NEW:"var"==text?kind=TokenKind.VAR:"@JS"==text&&(kind=TokenKind.JAVASCRIPT):4==length?"else"==text?kind=TokenKind.ELSE:"enum"==text?kind=TokenKind.ENUM:"null"==text?kind=TokenKind.NULL:"this"==text?kind=TokenKind.THIS:"true"==text?kind=TokenKind.TRUE:"from"==text&&(kind=TokenKind.FROM):5==length?"break"==text?kind=TokenKind.BREAK:"class"==text?kind=TokenKind.CLASS:"const"==text?kind=TokenKind.CONST:"false"==text?kind=TokenKind.FALSE:"while"==text&&(kind=TokenKind.WHILE):6==length?"export"==text?kind=TokenKind.EXPORT:"module"==text?kind=TokenKind.MODULE:"import"==text?kind=TokenKind.IMPORT:"public"==text?kind=TokenKind.PUBLIC:"return"==text?kind=TokenKind.RETURN:"sizeof"==text?kind=TokenKind.SIZEOF:"static"==text?kind=TokenKind.STATIC:"unsafe"==text?kind=TokenKind.UNSAFE:"@start"==text?kind=TokenKind.START:"delete"==text&&(kind=TokenKind.DELETE):7==length?"alignof"==text?kind=TokenKind.ALIGNOF:"declare"==text?kind=TokenKind.DECLARE:"extends"==text?kind=TokenKind.EXTENDS:"private"==text?kind=TokenKind.PRIVATE:"anyfunc"==text&&(kind=TokenKind.ANYFUNC):"continue"==text?kind=TokenKind.CONTINUE:"@virtual"==text?kind=TokenKind.VIRTUAL:"function"==text?kind=TokenKind.FUNCTION:"implements"==text?kind=TokenKind.IMPLEMENTS:"protected"==text&&(kind=TokenKind.PROTECTED)}}else if(isNumber(c)){var isFloat=!1;if(i"==c)kind=TokenKind.GREATER_THAN,i"==c?(kind=TokenKind.SHIFT_RIGHT,i+=1):"="==c&&(kind=TokenKind.GREATER_THAN_EQUAL,i+=1));else if("#"==c){for(;i=end&&"\n"!=contents[j];)j-=1;j"),this.name=name,this.symbol=symbol,this.isExternal=!1,this.isExported=!1,this.localVariables=[],this.returnType=wasm_type_1.WasmType.VOID,this.code=new stringbuilder_1.StringBuilder(2),this.chunks=[]}return WasmFunction.prototype.toString=function(){return"[WasmFunction]:: "+this.name+"()["+this.signatureIndex+"]"},WasmFunction}();exports.WasmFunction=WasmFunction},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var bytearray_1=__webpack_require__(0),terminal_1=__webpack_require__(2),wasm_section_1=__webpack_require__(1),wasm_parser_1=__webpack_require__(29),WasmBinary=function(){function WasmBinary(data){this.sections=[],this.sectionMap=new Map,void 0!==data?this.read(data):(this.data=new bytearray_1.ByteArray,this.data.log="",this.data.writeUnsignedInt(WasmBinary.MAGIC),this.data.writeUnsignedInt(WasmBinary.VERSION),this.data.log+="0000000: 0061 736d ; WASM_BINARY_MAGIC\n",this.data.log+="0000004: 0100 0000 ; WASM_BINARY_VERSION\n")}return WasmBinary.prototype.read=function(data){if(null!==data&&void 0!==data){this.data=new bytearray_1.ByteArray(data.buffer,data.byteOffset,data.byteLength),this.data.endian=bytearray_1.ByteArray.LITTLE_ENDIAN;var magic=this.data.readUnsignedInt();this.data.readUnsignedInt();magic!==WasmBinary.MAGIC&&terminal_1.Terminal.error("Found unknown WASM magic number "+magic+" instead of "+WasmBinary.MAGIC),this.readNextSection()}},WasmBinary.prototype.readNextSection=function(){if(this.data.bytesAvailable>0){var section=wasm_parser_1.parseSection(this.data);null!==section&&this.sectionMap.set(section.id,this.sections.push(section)-1),this.readNextSection()}else terminal_1.Terminal.log(this.sections.length+" Sections parsed!")},WasmBinary.prototype.reset=function(){this.sections=null,this.sections=[],this.sectionMap=null,this.sectionMap=new Map,this.data=new bytearray_1.ByteArray,this.data.log="",this.data.writeUnsignedInt(WasmBinary.MAGIC),this.data.writeUnsignedInt(WasmBinary.VERSION),this.data.log+="0000000: 0061 736d ; WASM_BINARY_MAGIC\n",this.data.log+="0000004: 0100 0000 ; WASM_BINARY_VERSION\n"},WasmBinary.prototype.appendSection=function(section){this.sectionMap.set(section.id,this.sections.push(section)-1)},WasmBinary.prototype.getSection=function(id,name){var index=this.sectionMap.get(id);if(void 0!==index)return this.sections[index];var section=wasm_parser_1.createSection(id,name);this.appendSection(section);var warn="Section "+wasm_section_1.WasmSection[id]+" created! Reason: Requested section not found in the imported wasm module";return terminal_1.Terminal.warn(warn),section},WasmBinary.prototype.initializeSections=function(){this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Signature)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Import)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Function)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Table)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Memory)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Global)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Export)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Start)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Element)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Code)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Data)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Custom,"name"))},WasmBinary.prototype.copySections=function(binary){var _this=this;binary.sections.forEach(function(importedSection){switch(importedSection.id){case wasm_section_1.WasmSection.Signature:var section=_this.getSection(importedSection.id);section.signatures=section.signatures.concat(importedSection.signatures);break;case wasm_section_1.WasmSection.Import:var section=_this.getSection(importedSection.id);section.imports=section.imports.concat(importedSection.imports);break;case wasm_section_1.WasmSection.Function:var section=_this.getSection(importedSection.id);section.functions=section.functions.concat(importedSection.functions);break;case wasm_section_1.WasmSection.Table:var section=_this.getSection(importedSection.id);section.tables=section.tables.concat(importedSection.tables);break;case wasm_section_1.WasmSection.Memory:var section=_this.getSection(importedSection.id);section.memory=section.memory.concat(importedSection.memory);break;case wasm_section_1.WasmSection.Global:var section=_this.getSection(importedSection.id);section.globals=section.globals.concat(importedSection.globals);break;case wasm_section_1.WasmSection.Export:var section=_this.getSection(importedSection.id);section.exports=section.exports.concat(importedSection.exports);break;case wasm_section_1.WasmSection.Start:var section=_this.getSection(importedSection.id);-1===section.startFunctionIndex&&(section.startFunctionIndex=importedSection.startFunctionIndex);break;case wasm_section_1.WasmSection.Element:var section=_this.getSection(importedSection.id);section.elements=section.elements.concat(importedSection.elements);break;case wasm_section_1.WasmSection.Code:var section=_this.getSection(importedSection.id);section.functions=section.functions.concat(importedSection.functions);break;case wasm_section_1.WasmSection.Data:var section=_this.getSection(importedSection.id);section.data=section.data.concat(importedSection.data);break;case wasm_section_1.WasmSection.Custom:var section=_this.getSection(importedSection.id);section.names=section.names.concat(importedSection.names)}})},WasmBinary}();WasmBinary.MAGIC=1836278016,WasmBinary.VERSION=1,WasmBinary.SIZE_IN_PAGES=1,WasmBinary.SET_MAX_MEMORY=!1,WasmBinary.MAX_MEMORY=1073741824,WasmBinary.MEMORY_INITIALIZER_BASE=8,exports.WasmBinary=WasmBinary},function(module,exports,__webpack_require__){"use strict";function replaceFileExtension(path,extension){var dot=path.lastIndexOf("."),forward=path.lastIndexOf("/"),backward=path.lastIndexOf("\\");return dot>0&&dot>forward&&dot>backward&&(path=path.slice(0,dot)),path+extension}Object.defineProperty(exports,"__esModule",{value:!0});var type_checker_1=__webpack_require__(67),node_1=__webpack_require__(10),log_1=__webpack_require__(5),preprocessor_1=__webpack_require__(72),scope_1=__webpack_require__(30),scanner_1=__webpack_require__(14),parser_1=__webpack_require__(32),shaking_1=__webpack_require__(70),webassembly_1=__webpack_require__(66),library_1=__webpack_require__(75),preparser_1=__webpack_require__(71),compile_target_1=__webpack_require__(9),assert_1=__webpack_require__(3),terminal_1=__webpack_require__(2),Compiler=function(){function Compiler(){}return Compiler.prototype.initialize=function(target,outputName){assert_1.assert(null==this.log),this.log=new log_1.Log,this.preprocessor=new preprocessor_1.Preprocessor,Compiler.binaryImports=[],this.target=target,this.outputName=outputName,this.librarySource=this.addInput("",library_1.Library.get(target)),this.librarySource.isLibrary=!0,this.runtimeSource=library_1.Library.getRuntime(target),this.wrapperSource=library_1.Library.getWrapper(target),this.createGlobals(),target==compile_target_1.CompileTarget.CPP?this.preprocessor.define("CPP",!0):target==compile_target_1.CompileTarget.JAVASCRIPT?this.preprocessor.define("JS",!0):target==compile_target_1.CompileTarget.WEBASSEMBLY&&this.preprocessor.define("WASM",!0)},Compiler.prototype.createGlobals=function(){var context=new type_checker_1.CheckContext;context.log=this.log,context.target=this.target,context.pointerByteSize=4;var global=new node_1.Node;global.kind=node_1.NodeKind.GLOBAL;var scope=new scope_1.Scope;global.scope=scope,context.anyType=scope.defineNativeType(context.log,"any"),context.errorType=scope.defineNativeType(context.log,""),context.nullType=scope.defineNativeType(context.log,"null"),context.undefinedType=scope.defineNativeType(context.log,"undefined"),context.voidType=scope.defineNativeType(context.log,"void"),this.context=context,this.global=global},Compiler.prototype.addInput=function(name,contents){var source=new log_1.Source;return source.name=name,source.contents=contents,null==this.firstSource?this.firstSource=source:(source.prev=this.lastSource,this.lastSource.next=source),this.lastSource=source,source},Compiler.prototype.addInputBefore=function(name,contents,nextSource){var source=new log_1.Source;return source.name=name,source.contents=contents,nextSource.prev.next=source,source.prev=nextSource.prev,nextSource.prev=source,source.next=nextSource,source},Compiler.prototype.finish=function(){terminal_1.Terminal.time("pre-parsing");for(var source=this.firstSource;null!=source;){if(!preparser_1.preparse(source,this,this.log))return!1;source=source.next}for(terminal_1.Terminal.timeEnd("pre-parsing"),terminal_1.Terminal.time("scanning"),source=this.firstSource;null!=source;)source.firstToken=scanner_1.tokenize(source,this.log),source=source.next;for(terminal_1.Terminal.timeEnd("scanning"),terminal_1.Terminal.time("pre-processing"),source=this.firstSource;null!=source;)this.preprocessor.run(source,this.log),source=source.next;for(terminal_1.Terminal.timeEnd("pre-processing"),terminal_1.Terminal.time("parsing"),source=this.firstSource;null!=source;)null!=source.firstToken&&(source.file=parser_1.parse(source.firstToken,this.log)),source=source.next;terminal_1.Terminal.timeEnd("parsing"),terminal_1.Terminal.time("type-checking");var global=this.global,context=this.context,fullResolve=!0;for(source=this.firstSource;null!=source;){var file=source.file;if(null!=file)for(source.isLibrary?(file.flags|=node_1.NODE_FLAG_LIBRARY,type_checker_1.initialize(context,file,global.scope,type_checker_1.CheckMode.INITIALIZE),type_checker_1.resolve(context,file,global.scope)):type_checker_1.initialize(context,file,global.scope,type_checker_1.CheckMode.NORMAL);null!=file.firstChild;){var child=file.firstChild;child.remove(),global.appendChild(child)}if(source.isLibrary&&this.log.hasErrors()){fullResolve=!1;break}source=source.next}return fullResolve&&type_checker_1.resolve(context,global,global.scope),terminal_1.Terminal.timeEnd("type-checking"),!this.log.hasErrors()&&(terminal_1.Terminal.time("optimizing"),shaking_1.treeShaking(global),terminal_1.Terminal.timeEnd("optimizing"),terminal_1.Terminal.time("emitting"),this.target==compile_target_1.CompileTarget.WEBASSEMBLY&&webassembly_1.wasmEmit(this),terminal_1.Terminal.timeEnd("emitting"),terminal_1.Terminal.write("Done!"),!0)},Compiler}();Compiler.mallocRequired=!1,Compiler.debug=!1,exports.Compiler=Compiler,exports.replaceFileExtension=replaceFileExtension},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Color={DEFAULT_TEXT:12,DEFAULT_BG:8,BLACK:0,WHITE:255,BOLD:1,RED:1,GREEN:2,YELLOW:3,BLUE:4,MAGENTA:5,ORANGE:208};var hexColor={};hexColor[exports.Color.DEFAULT_TEXT]="#000000",hexColor[exports.Color.DEFAULT_BG]="#FFFFFF",hexColor[exports.Color.BLACK]="#000000",hexColor[exports.Color.WHITE]="#FFFFFF",hexColor[exports.Color.BOLD]="",hexColor[exports.Color.RED]="#FF0000",hexColor[exports.Color.GREEN]="#00FF00",hexColor[exports.Color.BLUE]="#0000FF",hexColor[exports.Color.YELLOW]="#FFF600",hexColor[exports.Color.MAGENTA]="#FF00FF",hexColor[exports.Color.ORANGE]="#FF8C00",exports.HexColor=hexColor},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isBrowser=new Function("try {return this===window;}catch(e){ return false;}")(),exports.isWorker=new Function("try {return this===self && typeof importScripts !== 'undefined';}catch(e){return false;}")(),exports.isNode="undefined"!=typeof global&&"undefined"!=typeof process&&void 0!==process.stdout},function(module,exports,__webpack_require__){"use strict";function StringBuilder_new(){var sb=stringBuilderPool;return null!=sb?stringBuilderPool=sb.next:sb=new StringBuilder,sb.clear(),sb}function StringBuilder_appendQuoted(sb,text){var end=0,limit=text.length,start=end;for(sb.appendChar('"');end0;)this._text+=this.indentStr,i-=1},StringBuilder.prototype.appendChar=function(c){return this._text+=c,this},StringBuilder.prototype.appendSlice=function(text,start,end){return this._text+=text.slice(start,end),this},StringBuilder.prototype.breakChunk=function(){return this.chunks.push(this._text),this._text="",this.chunks.length-1},StringBuilder.prototype.appendLine=function(text,indent){return void 0===indent&&(indent=0),this.indent+=indent,this.emitIndent(),this._text+=text+"\n",this},StringBuilder.prototype.appendRaw=function(text){return this._text+=text+"\n",this},StringBuilder.prototype.append=function(text,indent){var _this=this;return void 0===indent&&(indent=0),this.indent+=indent,text.split("\n").forEach(function(line,i){i>0&&(_this._text+="\n",_this.emitIndent()),_this._text+=line}),this},StringBuilder.prototype.removeLastChar=function(){this._text=this._text.substring(0,this._text.length-1)},StringBuilder.prototype.removeLastLinebreak=function(){this._text=this._text.substring(0,this._text.lastIndexOf("\n"))},StringBuilder.prototype.finish=function(){if(this.next=stringBuilderPool,stringBuilderPool=this,this.chunks.length>0){var code_1="";return this.chunks.forEach(function(chunk){code_1+=chunk}),code_1+this._text}return this._text},StringBuilder}();exports.StringBuilder=StringBuilder},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});!function(Bitness){Bitness[Bitness.x32=0]="x32",Bitness[Bitness.x64=1]="x64"}(exports.Bitness||(exports.Bitness={}))},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmExport=function(){function WasmExport(name,kind,index){this.name=name,this.kind=kind,this.index=index,this.as=name}return WasmExport}();exports.WasmExport=WasmExport},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmGlobal=function(){function WasmGlobal(type,mutable,name,symbol){this.type=type,this.mutable=mutable,this.name=name,this.symbol=symbol}return WasmGlobal}();exports.WasmGlobal=WasmGlobal},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmImport=function(){function WasmImport(namespace,name,type,signatureIndex,signature){this.namespace=namespace,this.name=name,this.type=type,this.signatureIndex=signatureIndex,this.signature=signature}return WasmImport}();exports.WasmImport=WasmImport},function(module,exports,__webpack_require__){"use strict";function wasmAreSignaturesEqual(a,b){assert_1.assert(null!=a.returnType),assert_1.assert(null!=b.returnType);var x=a.argumentTypes,y=b.argumentTypes;if(x.length!==y.length)return!1;var equal=!0;return x.some(function(x_id,index){return x_id!==y[index]&&(equal=!1,!0)}),a.returnType==b.returnType&&equal}Object.defineProperty(exports,"__esModule",{value:!0});var wasm_type_1=__webpack_require__(6),assert_1=__webpack_require__(3),WasmSignature=function(){function WasmSignature(){this.argumentTypes=[],this.returnType=wasm_type_1.WasmType.VOID}return WasmSignature}();exports.WasmSignature=WasmSignature,exports.wasmAreSignaturesEqual=wasmAreSignaturesEqual},function(module,exports,__webpack_require__){"use strict";function log(array,offset,value,msg){void 0===offset&&(offset=0),void 0===msg&&(msg=""),array.log+=(null!=value?utils_1.toHex(offset+array.position)+": "+utils_1.toHex(value,2)+" ; ":"")+(null!=msg?msg+"\n":"\n")}function logData(array,offset,value,addPosition){void 0===offset&&(offset=0),void 0===addPosition&&(addPosition=!0),array.log+=addPosition?utils_1.toHex(offset+array.position)+": "+utils_1.toHex(value,2):" "+utils_1.toHex(value,2)}Object.defineProperty(exports,"__esModule",{value:!0});var utils_1=__webpack_require__(8);exports.log=log,exports.logData=logData},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmRuntimeProperty=function(){function WasmRuntimeProperty(type,name){this.type=type,this.name=name}return WasmRuntimeProperty}();exports.WasmRuntimeProperty=WasmRuntimeProperty},function(module,exports,__webpack_require__){"use strict";function createSection(id,name){var sectionBinary=null;switch(id){case wasm_section_1.WasmSection.Signature:sectionBinary=new signature_section_1.SignatureSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Import:sectionBinary=new import_section_1.ImportSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Function:sectionBinary=new function_section_1.FunctionSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Table:sectionBinary=new table_section_1.TableSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Memory:sectionBinary=new memory_section_1.MemorySection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Global:sectionBinary=new global_section_1.GlobalSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Export:sectionBinary=new export_section_1.ExportSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Start:sectionBinary=new start_section_1.StartSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Element:sectionBinary=new element_section_1.ElementSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Code:sectionBinary=new code_section_1.CodeSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Data:sectionBinary=new data_section_1.DataSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Custom:if(void 0===name){var error="Cannot create custom section without name";throw terminal_1.Terminal.error(error),error}sectionBinary=new name_section_1.CustomSection(name,new bytearray_1.ByteArray)}if(null===sectionBinary){var error="Unknown section id:"+id+" "+(void 0!==name?", "+name:"");throw terminal_1.Terminal.error(error),error}return sectionBinary}function parseSection(data){var id=data.readS32LEB(),name_len=0;0==this.id&&(name_len=data.readU32LEB(),data.readUTFBytes(name_len));var sectionBinary,payload_len=data.readU32LEB(),payload=data.readBytes(new bytearray_1.ByteArray,0,payload_len);switch(id){case wasm_section_1.WasmSection.Signature:sectionBinary=new signature_section_1.SignatureSection(payload),WasmParser.currentSignatures=sectionBinary.signatures;break;case wasm_section_1.WasmSection.Import:sectionBinary=new import_section_1.ImportSection(payload);break;case wasm_section_1.WasmSection.Function:sectionBinary=new function_section_1.FunctionSection(payload),WasmParser.currentFunctions=sectionBinary.functions;break;case wasm_section_1.WasmSection.Table:sectionBinary=new table_section_1.TableSection(payload);break;case wasm_section_1.WasmSection.Memory:sectionBinary=new memory_section_1.MemorySection(payload);break;case wasm_section_1.WasmSection.Global:sectionBinary=new global_section_1.GlobalSection(payload);break;case wasm_section_1.WasmSection.Export:sectionBinary=new export_section_1.ExportSection(payload);break;case wasm_section_1.WasmSection.Start:sectionBinary=new start_section_1.StartSection(payload);break;case wasm_section_1.WasmSection.Element:sectionBinary=new element_section_1.ElementSection(payload);break;case wasm_section_1.WasmSection.Code:sectionBinary=new code_section_1.CodeSection(payload),sectionBinary.functions=WasmParser.currentFunctions;break;case wasm_section_1.WasmSection.Data:sectionBinary=new data_section_1.DataSection(payload)}return void 0!==sectionBinary?(sectionBinary.read(),sectionBinary):null}Object.defineProperty(exports,"__esModule",{value:!0});var bytearray_1=__webpack_require__(0),wasm_section_1=__webpack_require__(1),signature_section_1=__webpack_require__(62),import_section_1=__webpack_require__(59),function_section_1=__webpack_require__(57),table_section_1=__webpack_require__(64),memory_section_1=__webpack_require__(60),global_section_1=__webpack_require__(58),export_section_1=__webpack_require__(56),start_section_1=__webpack_require__(63),element_section_1=__webpack_require__(55),code_section_1=__webpack_require__(53),data_section_1=__webpack_require__(54),name_section_1=__webpack_require__(61),terminal_1=__webpack_require__(2),WasmParser=function(){function WasmParser(){}return WasmParser}();exports.WasmParser=WasmParser,exports.createSection=createSection,exports.parseSection=parseSection},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var FindNested,symbol_1=__webpack_require__(7),type_1=__webpack_require__(31);!function(FindNested){FindNested[FindNested.NORMAL=0]="NORMAL",FindNested[FindNested.ALLOW_INSTANCE_ERRORS=1]="ALLOW_INSTANCE_ERRORS"}(FindNested=exports.FindNested||(exports.FindNested={}));var ScopeHint;!function(ScopeHint){ScopeHint[ScopeHint.NORMAL=0]="NORMAL",ScopeHint[ScopeHint.NOT_BINARY=1]="NOT_BINARY",ScopeHint[ScopeHint.NOT_GETTER=2]="NOT_GETTER",ScopeHint[ScopeHint.NOT_SETTER=3]="NOT_SETTER",ScopeHint[ScopeHint.NOT_UNARY=4]="NOT_UNARY",ScopeHint[ScopeHint.PREFER_GETTER=5]="PREFER_GETTER",ScopeHint[ScopeHint.PREFER_SETTER=6]="PREFER_SETTER"}(ScopeHint=exports.ScopeHint||(exports.ScopeHint={}));var Scope=function(){function Scope(){}return Scope.prototype.findLocal=function(name,hint){for(var symbol=this.firstSymbol,fallback=null;null!=symbol;){if(symbol.name==name)if(hint==ScopeHint.PREFER_GETTER&&symbol.isSetter()||hint==ScopeHint.PREFER_SETTER&&symbol.isGetter())fallback=symbol;else if(!(hint==ScopeHint.NOT_GETTER&&symbol.isGetter()||hint==ScopeHint.NOT_SETTER&&symbol.isSetter()||hint==ScopeHint.NOT_BINARY&&symbol.isBinaryOperator()||hint==ScopeHint.NOT_UNARY&&symbol.isUnaryOperator()))return symbol;symbol=symbol.next}return fallback},Scope.prototype.findNested=function(name,hint,mode){for(var scope=this;null!=scope;){if(null==scope.symbol||scope.symbol.kind!=symbol_1.SymbolKind.TYPE_CLASS||mode==FindNested.ALLOW_INSTANCE_ERRORS||scope.symbol.node.hasParameters()){var local=scope.findLocal(name,hint);if(null!=local)return local}scope=scope.parent}return null},Scope.prototype.define=function(log,symbol,hint){return null!=this.findLocal(symbol.name,hint)?"this"==symbol.name?(log.warning(symbol.range,"Duplicate 'this' symbol"),!0):(log.error(symbol.range,"Duplicate symbol '"+symbol.name+"'"),!1):(null==this.firstSymbol?this.firstSymbol=symbol:this.lastSymbol.next=symbol,this.lastSymbol=symbol,!0)},Scope.prototype.defineNativeType=function(log,name){var symbol=new symbol_1.Symbol;return symbol.kind=symbol_1.SymbolKind.TYPE_NATIVE,symbol.name=name,symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.state=symbol_1.SymbolState.INITIALIZED,this.define(log,symbol,ScopeHint.NORMAL),symbol.resolvedType},Scope}();exports.Scope=Scope},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(7);!function(ConversionKind){ConversionKind[ConversionKind.IMPLICIT=0]="IMPLICIT",ConversionKind[ConversionKind.EXPLICIT=1]="EXPLICIT"}(exports.ConversionKind||(exports.ConversionKind={}));var Type=function(){function Type(){}return Type.prototype.isClass=function(){return null!=this.symbol&&this.symbol.kind==symbol_1.SymbolKind.TYPE_CLASS},Type.prototype.isGeneric=function(){var symbol=this.symbol||this.pointerTo.symbol;return null!=symbol&&symbol.kind==symbol_1.SymbolKind.TYPE_GENERIC},Type.prototype.isTemplate=function(){var symbol=this.symbol||this.pointerTo.symbol;return null!=symbol&&symbol.kind==symbol_1.SymbolKind.TYPE_TEMPLATE},Type.prototype.isEnum=function(){return null!=this.symbol&&this.symbol.kind==symbol_1.SymbolKind.TYPE_ENUM},Type.prototype.isInteger=function(){return null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_NATIVE_INTEGER)||this.isEnum()},Type.prototype.isLong=function(){return null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_NATIVE_LONG)},Type.prototype.isUnsigned=function(){return null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_IS_UNSIGNED)},Type.prototype.isFloat=function(){return null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_NATIVE_FLOAT)},Type.prototype.isDouble=function(){return null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_NATIVE_DOUBLE)},Type.prototype.isArray=function(){return null!=this.symbol&&this.symbol.name.indexOf("Array<")>=0},Type.prototype.isTypedArray=function(){return null!=this.symbol&&("Float32Array"==this.symbol.name||"Float64Array"==this.symbol.name||"Int8Array"==this.symbol.name||"Int16Array"==this.symbol.name||"Int32Array"==this.symbol.name||"Uint8Array"==this.symbol.name||"Uint16Array"==this.symbol.name||"Uint32Array"==this.symbol.name)},Type.prototype.isReference=function(){return null!=this.pointerTo||null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_IS_REFERENCE)},Type.prototype.underlyingType=function(context){return this.isEnum()?context.int32Type:null!=this.pointerTo?context.uint32Type:this},Type.prototype.integerBitCount=function(context){return null!=this.symbol?8*this.symbol.byteSize:0},Type.prototype.integerBitMask=function(context){return-1>>32-this.integerBitCount(context)},Type.prototype.allocationSizeOf=function(context){return null==this.symbol?context.pointerByteSize:this.symbol.byteSize},Type.prototype.allocationAlignmentOf=function(context){return this.allocationSizeOf(context)},Type.prototype.variableSizeOf=function(context){return this.isReference()?context.pointerByteSize:this.symbol.byteSize},Type.prototype.variableAlignmentOf=function(context){return this.variableSizeOf(context)},Type.prototype.pointerType=function(){var type=this.cachedPointerType;return null==type&&(type=new Type,type.pointerTo=this,this.cachedPointerType=type),type},Type.prototype.toString=function(){return null==this.cachedToString&&(this.cachedToString=null!=this.pointerTo?"*"+this.pointerTo.toString():this.symbol.name),this.cachedToString},Type.prototype.findMember=function(name,hint){var symbol=this.symbol;return null!=symbol&&null!=symbol.scope?symbol.scope.findLocal(name,hint):null},Type.prototype.hasInstanceMembers=function(){var symbol=this.symbol;return null!=symbol&&(symbol.kind==symbol_1.SymbolKind.TYPE_TEMPLATE||symbol.kind==symbol_1.SymbolKind.TYPE_CLASS||symbol.kind==symbol_1.SymbolKind.TYPE_NATIVE)},Type}();exports.Type=Type},function(module,exports,__webpack_require__){"use strict";function isRightAssociative(precedence){return precedence==Precedence.ASSIGN||precedence==Precedence.EXPONENT}function parse(firstToken,log){var context=new ParserContext;context.current=firstToken,context.log=log;var file=new node_1.Node;return file.kind=node_1.NodeKind.FILE,context.parseStatements(file)?file:null}Object.defineProperty(exports,"__esModule",{value:!0});var Precedence,scanner_1=__webpack_require__(14),log_1=__webpack_require__(5),node_1=__webpack_require__(10),assert_1=__webpack_require__(3),terminal_1=__webpack_require__(2);!function(Precedence){Precedence[Precedence.LOWEST=0]="LOWEST",Precedence[Precedence.ASSIGN=1]="ASSIGN",Precedence[Precedence.LOGICAL_OR=2]="LOGICAL_OR",Precedence[Precedence.LOGICAL_AND=3]="LOGICAL_AND",Precedence[Precedence.BITWISE_OR=4]="BITWISE_OR",Precedence[Precedence.BITWISE_XOR=5]="BITWISE_XOR",Precedence[Precedence.BITWISE_AND=6]="BITWISE_AND",Precedence[Precedence.EQUAL=7]="EQUAL",Precedence[Precedence.COMPARE=8]="COMPARE",Precedence[Precedence.SHIFT=9]="SHIFT",Precedence[Precedence.ADD=10]="ADD",Precedence[Precedence.MULTIPLY=11]="MULTIPLY",Precedence[Precedence.EXPONENT=12]="EXPONENT",Precedence[Precedence.UNARY_PREFIX=13]="UNARY_PREFIX",Precedence[Precedence.UNARY_POSTFIX=14]="UNARY_POSTFIX",Precedence[Precedence.MEMBER=15]="MEMBER"}(Precedence=exports.Precedence||(exports.Precedence={}));var ParseKind;!function(ParseKind){ParseKind[ParseKind.EXPRESSION=0]="EXPRESSION",ParseKind[ParseKind.TYPE=1]="TYPE"}(ParseKind||(ParseKind={}));var StatementMode;!function(StatementMode){StatementMode[StatementMode.NORMAL=0]="NORMAL",StatementMode[StatementMode.FILE=1]="FILE"}(StatementMode||(StatementMode={}));var ParserContext=function(){function ParserContext(){}return ParserContext.prototype.peek=function(kind){return this.current.kind==kind},ParserContext.prototype.eat=function(kind){return!!this.peek(kind)&&(this.advance(),!0)},ParserContext.prototype.advance=function(){this.peek(scanner_1.TokenKind.END_OF_FILE)||(this.previous=this.current,this.current=this.current.next)},ParserContext.prototype.unexpectedToken=function(){this.lastError!=this.current&&(this.lastError=this.current,this.log.error(this.current.range,"Unexpected "+scanner_1.tokenToString(this.current.kind)))},ParserContext.prototype.expect=function(kind){if(!this.peek(kind)){if(this.lastError!=this.current){this.lastError=this.current;var previousLine=this.previous.range.enclosingLine(),currentLine=this.current.range.enclosingLine();kind==scanner_1.TokenKind.IDENTIFIER||previousLine.equals(currentLine)?this.log.error(this.current.range,"Expected "+scanner_1.tokenToString(kind)+" but found "+scanner_1.tokenToString(this.current.kind)):this.log.error(previousLine.rangeAtEnd(),"Expected "+scanner_1.tokenToString(kind))}return!1}return this.advance(),!0},ParserContext.prototype.parseUnaryPrefix=function(kind,mode){assert_1.assert(node_1.isUnary(kind));var token=this.current;this.advance();var value=this.parseExpression(Precedence.UNARY_PREFIX,mode);return null==value?null:node_1.createUnary(kind,value).withRange(log_1.spanRanges(token.range,value.range)).withInternalRange(token.range)},ParserContext.prototype.parseBinary=function(kind,left,localPrecedence,operatorPrecedence){if(localPrecedence>=operatorPrecedence)return left;var token=this.current;this.advance();var precedence=isRightAssociative(operatorPrecedence)?operatorPrecedence-1:operatorPrecedence,right=this.parseExpression(precedence,ParseKind.EXPRESSION);return null==right?null:node_1.createBinary(kind,left,right).withRange(log_1.spanRanges(left.range,right.range)).withInternalRange(token.range)},ParserContext.prototype.parseUnaryPostfix=function(kind,value,localPrecedence){if(localPrecedence>=Precedence.UNARY_POSTFIX)return value;var token=this.current;return this.advance(),node_1.createUnary(kind,value).withRange(log_1.spanRanges(value.range,token.range)).withInternalRange(token.range)},ParserContext.prototype.parseQuotedString=function(range){assert_1.assert(range.end-range.start>=2);for(var text=range.source.contents,end=range.start+1,limit=range.end-1,start=end,quotedString="";end')":end.kind==scanner_1.TokenKind.GREATER_THAN_EQUAL?"(it is automatically derived from '<')":""))):this.unexpectedToken()}else{if(null==parent&&(assert_1.assert(token.kind==scanner_1.TokenKind.FUNCTION),this.advance()),nameRange=this.current.range,!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;name=nameRange.toString()}var node=node_1.createFunction(name);if(node.firstFlag=firstFlag,node.flags=node_1.allFlags(firstFlag),isOperator&&(node.flags=node.flags|node_1.NODE_FLAG_OPERATOR),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;node.appendChild(parameters)}if(!this.expect(scanner_1.TokenKind.LEFT_PARENTHESIS))return null;if(!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))for(;;){var firstArgumentFlag=this.parseFlags(),argument=this.current;if(!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;var type=void 0,value=null,range=argument.range;if(this.expect(scanner_1.TokenKind.COLON)){if(type=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;type.appendChild(parameters)}if(null!=type)range=log_1.spanRanges(range,type.range);else{if(!this.peek(scanner_1.TokenKind.COMMA)&&!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;type=node_1.createParseError()}}else(this.peek(scanner_1.TokenKind.COMMA)||this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))&&(type=node_1.createParseError());for(var firstType=type;this.eat(scanner_1.TokenKind.BITWISE_OR);){var aliasType=this.parseType();if(this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;aliasType.appendChild(parameters)}if(null!=aliasType)range=log_1.spanRanges(range,aliasType.range);else{if(!this.peek(scanner_1.TokenKind.COMMA)&&!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;aliasType=node_1.createParseError()}type.appendChild(aliasType),type=aliasType}this.eat(scanner_1.TokenKind.ASSIGN)&&(value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION));var variable=node_1.createVariable(argument.range.toString(),firstType,value);if(variable.firstFlag=firstArgumentFlag,variable.flags=node_1.allFlags(firstArgumentFlag),node.appendChild(variable.withRange(range).withInternalRange(argument.range)),!this.eat(scanner_1.TokenKind.COMMA))break}if(!this.expect(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;var returnType;if(node.isAnyfunc())returnType=node_1.createAny();else if("constructor"==node.stringValue)returnType=new node_1.Node,returnType.kind=node_1.NodeKind.NAME,returnType.stringValue=parent.stringValue;else if(this.expect(scanner_1.TokenKind.COLON)){if(returnType=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;returnType.appendChild(parameters)}if(null==returnType){if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;returnType=node_1.createParseError()}for(var firstType=returnType;this.eat(scanner_1.TokenKind.BITWISE_OR);){var aliasType=this.parseType();if(this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;aliasType.appendChild(parameters)}if(null==aliasType){if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;aliasType=node_1.createParseError()}firstType.appendChild(aliasType),firstType=aliasType}}else{if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;returnType=node_1.createParseError()}node.appendChild(returnType);var block=null,semicolon=this.current;if(this.eat(scanner_1.TokenKind.SEMICOLON))block=node_1.createEmpty().withRange(semicolon.range);else if(null==(block=this.parseBlock()))return null;return null!=parent&&parent.appendChild(node),node.appendChild(block),node.withRange(log_1.spanRanges(token.range,block.range)).withInternalRange(nameRange)},ParserContext.prototype.parseVariables=function(firstFlag,parent){var token=this.current;null==parent&&(assert_1.assert(token.kind==scanner_1.TokenKind.CONST||token.kind==scanner_1.TokenKind.LET||token.kind==scanner_1.TokenKind.VAR),this.advance());var node=token.kind==scanner_1.TokenKind.CONST?node_1.createConstants():node_1.createVariables();for(node.firstFlag=firstFlag;;){var name=this.current;if(!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;var type=null;if(this.eat(scanner_1.TokenKind.COLON)){if(type=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;type.appendChild(parameters)}if(null==type)return null}var value=null;if(this.eat(scanner_1.TokenKind.ASSIGN)&&null==(value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION)))return null;var range=null!=value?log_1.spanRanges(name.range,value.range):null!=type?log_1.spanRanges(name.range,type.range):name.range,variable=node_1.createVariable(name.range.toString(),type,value);if(variable.firstFlag=firstFlag,variable.flags=node_1.allFlags(firstFlag),(null!=parent?parent:node).appendChild(variable.withRange(range).withInternalRange(name.range)),!this.eat(scanner_1.TokenKind.COMMA))break}var semicolon=this.current;return this.expect(scanner_1.TokenKind.SEMICOLON),node.withRange(log_1.spanRanges(token.range,semicolon.range))},ParserContext.prototype.parseLoopJump=function(kind){var token=this.current;this.advance(),this.expect(scanner_1.TokenKind.SEMICOLON);var node=new node_1.Node;return node.kind=kind,node.withRange(token.range)},ParserContext.prototype.parseFlags=function(){for(var firstFlag=null,lastFlag=null;;){var token=this.current,flag=void 0;if(this.eat(scanner_1.TokenKind.DECLARE))flag=node_1.NODE_FLAG_DECLARE;else if(this.eat(scanner_1.TokenKind.EXPORT))flag=node_1.NODE_FLAG_EXPORT;else if(this.eat(scanner_1.TokenKind.PRIVATE))flag=node_1.NODE_FLAG_PRIVATE;else if(this.eat(scanner_1.TokenKind.PROTECTED))flag=node_1.NODE_FLAG_PROTECTED;else if(this.eat(scanner_1.TokenKind.PUBLIC))flag=node_1.NODE_FLAG_PUBLIC;else if(this.eat(scanner_1.TokenKind.STATIC))flag=node_1.NODE_FLAG_STATIC;else if(this.eat(scanner_1.TokenKind.ANYFUNC))flag=node_1.NODE_FLAG_ANYFUNC;else if(this.eat(scanner_1.TokenKind.UNSAFE))flag=node_1.NODE_FLAG_UNSAFE;else if(this.eat(scanner_1.TokenKind.JAVASCRIPT))flag=node_1.NODE_FLAG_JAVASCRIPT;else if(this.eat(scanner_1.TokenKind.START))flag=node_1.NODE_FLAG_START;else{if(!this.eat(scanner_1.TokenKind.VIRTUAL))return firstFlag;flag=node_1.NODE_FLAG_VIRTUAL}var link=new node_1.NodeFlag;link.flag=flag,link.range=token.range,null==firstFlag?firstFlag=link:lastFlag.next=link,lastFlag=link}},ParserContext.prototype.parseUnsafe=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_UNSAFE,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseJavaScript=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_JAVASCRIPT,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseStart=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_START,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseVirtual=function(firstFlag){var token=this.current;this.advance();var node=this.parseFunction(firstFlag,null);return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_VIRTUAL,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseStatement=function(mode){var firstFlag=mode==StatementMode.FILE?this.parseFlags():null;if(this.peek(scanner_1.TokenKind.IMPORT)&&null==firstFlag)return this.parseImports();if(this.peek(scanner_1.TokenKind.JAVASCRIPT)&&null==firstFlag)return this.parseJavaScript();if(this.peek(scanner_1.TokenKind.START)&&null==firstFlag)return this.parseStart();if(this.peek(scanner_1.TokenKind.CONST)||this.peek(scanner_1.TokenKind.LET)||this.peek(scanner_1.TokenKind.VAR))return this.parseVariables(firstFlag,null);if(this.peek(scanner_1.TokenKind.FUNCTION))return this.parseFunction(firstFlag,null);if(this.peek(scanner_1.TokenKind.VIRTUAL))return this.parseVirtual(firstFlag);if(this.peek(scanner_1.TokenKind.MODULE))return this.parseModule(firstFlag);if(this.peek(scanner_1.TokenKind.CLASS))return this.parseClass(firstFlag);if(this.peek(scanner_1.TokenKind.ENUM))return this.parseEnum(firstFlag);if(null!=firstFlag)return this.unexpectedToken(),null;if(this.peek(scanner_1.TokenKind.LEFT_BRACE))return this.parseBlock();if(this.peek(scanner_1.TokenKind.BREAK))return this.parseLoopJump(node_1.NodeKind.BREAK);if(this.peek(scanner_1.TokenKind.CONTINUE))return this.parseLoopJump(node_1.NodeKind.CONTINUE);if(this.peek(scanner_1.TokenKind.IF))return this.parseIf();if(this.peek(scanner_1.TokenKind.WHILE))return this.parseWhile();if(this.peek(scanner_1.TokenKind.DELETE))return this.parseDelete();if(this.peek(scanner_1.TokenKind.RETURN))return this.parseReturn();if(this.peek(scanner_1.TokenKind.SEMICOLON))return this.parseEmpty();var value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION);if(null==value)return null;var semicolon=this.current;return this.expect(scanner_1.TokenKind.SEMICOLON),node_1.createExpression(value).withRange(log_1.spanRanges(value.range,semicolon.range))},ParserContext.prototype.parseStatements=function(parent){for(;!this.peek(scanner_1.TokenKind.END_OF_FILE)&&!this.peek(scanner_1.TokenKind.RIGHT_BRACE);){var child=this.parseStatement(parent.kind==node_1.NodeKind.FILE?StatementMode.FILE:StatementMode.NORMAL);if(null==child)return!1;child.kind===node_1.NodeKind.RETURN&&(parent.returnNode=child),parent.appendChild(child)}return!0},ParserContext.prototype.parseInt=function(range,node){var source=range.source,contents=source.contents;return node.intValue=parseInt(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext.prototype.parseFloat=function(range,node){var source=range.source,contents=source.contents;return node.floatValue=parseFloat(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext.prototype.parseDouble=function(range,node){var source=range.source,contents=source.contents;return node.doubleValue=parseFloat(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext}();exports.parse=parse},function(module,exports,__webpack_require__){"use strict";function isBinaryImport(name){var found=!1;return BinaryImporter.imports.some(function(_import){return found=_import.name===name}),found}Object.defineProperty(exports,"__esModule",{value:!0});var filesystem_1=__webpack_require__(15),wasm_binary_1=__webpack_require__(17),wasm_section_1=__webpack_require__(1),wasm_external_kind_1=__webpack_require__(11),terminal_1=__webpack_require__(2),wasm_binary_import_1=__webpack_require__(73),BinaryImporter=function(){function BinaryImporter(){}return BinaryImporter.reset=function(){BinaryImporter.binaries=[],BinaryImporter.imports=[]},BinaryImporter.resolveWasmBinaryImport=function(imports,from,importPath){var binary=filesystem_1.FileSystem.readBinaryFile(importPath);null!==binary&&void 0!==binary||(binary=filesystem_1.FileSystem.readBinaryFile(from));var wasmBinary=new wasm_binary_1.WasmBinary(binary),importSection=wasmBinary.getSection(wasm_section_1.WasmSection.Import),importCount=importSection.imports.length,exportSection=wasmBinary.getSection(wasm_section_1.WasmSection.Export),signatureSection=wasmBinary.getSection(wasm_section_1.WasmSection.Signature),functionSection=wasmBinary.getSection(wasm_section_1.WasmSection.Function),declarations="";if(null!==exportSection&&null!==signatureSection&&null!==functionSection){var exports_1=exportSection.exports;exports_1.length>0&&(imports.forEach(function(_import){var matchedExport=exports_1.find(function(_export){return _export.name===_import});if(void 0===matchedExport||matchedExport.kind!==wasm_external_kind_1.WasmExternalKind.Function){var error="Cannot find function "+_import+" in wasm binary "+from;throw terminal_1.Terminal.error(error),error}var _function=functionSection.functions[matchedExport.index-importCount],signature=signatureSection.signatures[_function.signatureIndex],binaryImport=new wasm_binary_import_1.WasmBinaryImport(_import,signature,matchedExport.index);declarations+=binaryImport.declaration+"\n",BinaryImporter.imports.push(binaryImport)}),BinaryImporter.binaries.push(wasmBinary))}return declarations},BinaryImporter}();BinaryImporter.binaries=[],BinaryImporter.imports=[],exports.BinaryImporter=BinaryImporter,exports.isBinaryImport=isBinaryImport},function(module,exports,__webpack_require__){"use strict";function main_addArgument(text){var argument=new CommandLineArgument;argument.text=text,null==firstArgument?firstArgument=argument:lastArgument.next=argument,lastArgument=argument}function main_reset(){firstArgument=null,lastArgument=null}function printUsage(){terminal_1.Terminal.write("\nUsage: tc [FLAGS] [INPUTS]\n\n --help Print this message.\n --out [PATH] Emit code to PATH (the target format is the file extension).\n --wasm Explicit webassembly output \n --define [NAME] Define the flag NAME in all input files.\n\nExamples:\n\n tc src/*.tbs --out main.wasm\n")}function main_entry(){var output,target=compile_target_1.CompileTarget.NONE,argument=firstArgument,inputCount=0;if(null==firstArgument)return printUsage(),1;for(;null!=argument;){var text=argument.text;if(text.startsWith("-")){if("-h"==text||"-help"==text||"--help"==text||"/?"==text)return printUsage(),0;if("--cpp"==text)target=compile_target_1.CompileTarget.CPP;else if("--js"==text)target=compile_target_1.CompileTarget.JAVASCRIPT;else if("--wasm"==text)target=compile_target_1.CompileTarget.WEBASSEMBLY;else if("--define"==text&&null!=argument.next)argument=argument.next;else if("--out"==text&&null!=argument.next)argument=argument.next,output=argument.text;else{if("--bundle"!=text&&"-b"!=text)return terminal_1.Terminal.error("Invalid flag: "+text),1;argument=argument.next,!0}}else inputCount+=1;argument=argument.next}if(0==inputCount)return terminal_1.Terminal.error("No input files"),1;if(null==output)return terminal_1.Terminal.error("Missing an output file (use the --out flag)"),1;if(target==compile_target_1.CompileTarget.NONE){if(!output.endsWith(".wasm"))return terminal_1.Terminal.error("Missing a target (use either --js or --wasm)"),1;target=compile_target_1.CompileTarget.WEBASSEMBLY}var compiler=new compiler_1.Compiler;for(compiler.initialize(target,output),argument=firstArgument;null!=argument;){var text=argument.text;if("--define"==text)argument=argument.next,compiler.preprocessor.define(argument.text,!0);else if("--out"==text)argument=argument.next;else if(!text.startsWith("-")){var contents=filesystem_1.FileSystem.readTextFile(text);if(null==contents)return terminal_1.Terminal.error("Cannot read from "+text),1;compiler.addInput(text,contents)}argument=argument.next}if(compiler.finish(),log_1.writeLogToTerminal(compiler.log),!compiler.log.hasErrors())try{switch(target){case compile_target_1.CompileTarget.CPP:filesystem_1.FileSystem.writeTextFile(output,compiler.outputCPP),filesystem_1.FileSystem.writeTextFile(compiler_1.replaceFileExtension(output,".h"),compiler.outputH);break;case compile_target_1.CompileTarget.JAVASCRIPT:filesystem_1.FileSystem.writeTextFile(output,compiler.outputJS);break;case compile_target_1.CompileTarget.WEBASSEMBLY:if(void 0===compiler.outputWASM)return terminal_1.Terminal.error("Compile error!"),1;filesystem_1.FileSystem.writeBinaryFile(output,compiler.outputWASM),filesystem_1.FileSystem.writeTextFile(compiler_1.replaceFileExtension(output,".wast"),compiler.outputWAST),filesystem_1.FileSystem.writeTextFile(output+".log",compiler.outputWASM.log)}return 0}catch(e){return terminal_1.Terminal.error("Cannot write to "+output),console.error(e),1}return terminal_1.Terminal.write("\n"),1}function compileString(source,options){void 0===options&&(options=compiler_options_1.defaultCompilerOptions),terminal_1.Terminal.silent=options.silent;var input="/virtual/inline.tbs";filesystem_1.FileSystem.writeTextFile(input,source,!0);var compiler=new compiler_1.Compiler;return compiler.initialize(options.target,"/virtual/inline.wasm"),compiler.addInput(input,source),compiler.finish(),terminal_1.Terminal.silent=!1,compiler.log.hasErrors()?(options.silent&&!options.logError||log_1.writeLogToTerminal(compiler.log),{success:!1,log:compiler.log}):{success:!0,wasm:compiler.outputWASM.array,wast:compiler.outputWAST}}Object.defineProperty(exports,"__esModule",{value:!0});var log_1=__webpack_require__(5),compiler_1=__webpack_require__(18),compile_target_1=__webpack_require__(9),terminal_1=__webpack_require__(2),filesystem_1=__webpack_require__(15),compiler_options_1=__webpack_require__(68),color_1=__webpack_require__(19),CommandLineArgument=function(){function CommandLineArgument(){}return CommandLineArgument}();exports.CommandLineArgument=CommandLineArgument;var firstArgument,lastArgument;exports.main_addArgument=main_addArgument,exports.main_reset=main_reset,exports.printUsage=printUsage,exports.main_entry=main_entry,exports.main={addArgument:main_addArgument,reset:main_reset,entry:main_entry},exports.compileString=compileString,exports.version="1.0.5-beta",terminal_1.Terminal.setTextColor(color_1.Color.MAGENTA),terminal_1.Terminal.write("~~~~~~~~~~~~~~~~~~~~~~~~~| TurboScript "+exports.version+" |~~~~~~~~~~~~~~~~~~~~~~~~~\n"),terminal_1.Terminal.clearColor(),exports.default={version:exports.version,main:exports.main,compileString:compileString}},function(module,exports){module.exports=new Uint8Array([0,97,115,109,1,0,0,0,1,175,128,128,128,0,7,96,3,127,127,127,1,127,96,2,127,127,1,127,96,1,127,1,127,96,2,127,127,0,96,4,127,127,127,127,1,127,96,5,127,127,127,127,127,1,127,96,3,127,127,127,0,3,135,128,128,128,0,6,0,0,0,1,3,2,4,132,128,128,128,0,1,112,0,0,5,131,128,128,128,0,1,0,1,7,209,128,128,128,0,7,6,109,101,109,111,114,121,2,0,6,109,101,109,99,109,112,0,0,6,109,101,109,99,112,121,0,1,6,109,101,109,115,101,116,0,2,13,109,115,112,97,99,101,95,109,97,108,108,111,99,0,3,11,109,115,112,97,99,101,95,102,114,101,101,0,4,11,109,115,112,97,99,101,95,105,110,105,116,0,5,9,129,128,128,128,0,0,10,151,219,128,128,0,6,183,130,128,128,0,1,5,127,2,127,2,64,2,64,2,64,2,64,2,64,32,0,65,7,113,34,3,32,1,65,7,113,71,13,0,65,8,32,3,107,34,6,4,64,65,0,33,3,3,64,32,0,32,3,106,34,7,45,0,0,32,1,32,3,106,34,4,45,0,0,71,13,3,32,3,65,1,106,34,3,32,6,73,13,0,11,32,1,32,3,106,33,1,32,0,32,3,106,33,0,32,2,32,3,107,33,2,11,32,2,65,4,73,13,0,65,0,33,3,3,64,32,0,32,3,106,40,2,0,32,1,32,3,106,40,2,0,71,13,4,32,3,65,4,106,33,3,32,2,65,124,106,34,2,65,3,75,13,0,11,32,0,32,3,106,33,0,32,1,32,3,106,33,1,11,65,1,32,2,107,33,3,2,64,2,64,3,64,32,3,34,2,65,1,70,13,1,32,2,65,1,106,33,3,32,1,45,0,0,33,6,32,0,45,0,0,33,7,32,1,65,1,106,34,4,33,1,32,0,65,1,106,34,5,33,0,32,7,32,6,70,13,0,12,2,11,0,11,32,1,33,4,32,0,33,5,11,65,0,32,2,107,69,13,1,12,3,11,32,4,65,1,106,33,4,32,7,65,1,106,33,5,32,2,32,3,107,13,2,11,65,0,15,11,32,0,33,5,32,1,33,4,11,32,5,45,0,0,32,4,45,0,0,107,11,11,151,140,128,128,0,1,8,127,2,127,2,64,2,64,2,64,32,2,69,32,1,65,3,113,69,114,69,4,64,32,0,33,5,2,64,3,64,32,5,32,1,45,0,0,58,0,0,32,2,65,127,106,33,3,32,5,65,1,106,33,5,32,1,65,1,106,33,1,32,2,65,1,70,13,1,32,3,33,2,32,1,65,3,113,13,0,11,11,32,5,65,3,113,69,13,1,12,2,11,32,2,33,3,32,0,34,5,65,3,113,13,1,11,2,64,32,3,65,16,79,4,64,32,5,32,3,65,112,106,34,6,65,112,113,34,7,65,16,106,34,8,106,33,4,32,1,33,2,3,64,32,5,32,2,40,2,0,54,2,0,32,5,65,4,106,32,2,65,4,106,40,2,0,54,2,0,32,5,65,8,106,32,2,65,8,106,40,2,0,54,2,0,32,5,65,12,106,32,2,65,12,106,40,2,0,54,2,0,32,5,65,16,106,33,5,32,2,65,16,106,33,2,32,3,65,112,106,34,3,65,15,75,13,0,11,32,6,32,7,107,33,3,32,1,32,8,106,33,1,12,1,11,32,5,33,4,11,32,3,65,8,113,4,64,32,4,32,1,40,2,0,54,2,0,32,4,32,1,40,2,4,54,2,4,32,1,65,8,106,33,1,32,4,65,8,106,33,4,11,32,3,65,4,113,4,64,32,4,32,1,40,2,0,54,2,0,32,1,65,4,106,33,1,32,4,65,4,106,33,4,11,32,3,65,2,113,4,64,32,4,32,1,45,0,0,58,0,0,32,4,32,1,45,0,1,58,0,1,32,4,65,2,106,33,4,32,1,65,2,106,33,1,11,32,3,65,1,113,69,13,1,32,4,32,1,45,0,0,58,0,0,32,0,15,11,2,64,2,64,2,64,2,64,2,64,2,64,2,64,32,3,65,32,73,13,0,32,5,65,3,113,34,2,65,3,70,13,1,32,2,65,2,70,13,2,32,2,65,1,71,13,0,32,5,32,1,45,0,1,58,0,1,32,5,32,1,40,2,0,34,7,58,0,0,32,5,32,1,45,0,2,58,0,2,32,5,65,3,106,33,2,32,3,65,125,106,34,4,65,17,73,13,3,32,1,65,16,106,33,6,32,3,65,109,106,33,8,32,1,32,3,65,108,106,65,112,113,34,9,65,19,106,34,10,106,33,1,3,64,32,2,32,6,65,116,106,40,2,0,34,3,65,8,116,32,7,65,24,118,114,54,2,0,32,2,65,4,106,32,6,65,120,106,40,2,0,34,7,65,8,116,32,3,65,24,118,114,54,2,0,32,2,65,8,106,32,6,65,124,106,40,2,0,34,3,65,8,116,32,7,65,24,118,114,54,2,0,32,2,65,12,106,32,6,40,2,0,34,7,65,8,116,32,3,65,24,118,114,54,2,0,32,2,65,16,106,33,2,32,6,65,16,106,33,6,32,4,65,112,106,34,4,65,16,75,13,0,11,32,8,32,9,107,33,4,32,5,32,10,106,33,2,12,6,11,32,3,33,4,32,5,33,2,12,5,11,32,5,32,1,40,2,0,34,7,58,0,0,32,5,65,1,106,33,2,32,3,65,127,106,34,4,65,19,73,13,2,32,1,65,16,106,33,6,32,3,65,111,106,33,8,32,1,32,3,65,108,106,65,112,113,34,9,65,17,106,34,10,106,33,1,3,64,32,2,32,6,65,116,106,40,2,0,34,3,65,24,116,32,7,65,8,118,114,54,2,0,32,2,65,4,106,32,6,65,120,106,40,2,0,34,7,65,24,116,32,3,65,8,118,114,54,2,0,32,2,65,8,106,32,6,65,124,106,40,2,0,34,3,65,24,116,32,7,65,8,118,114,54,2,0,32,2,65,12,106,32,6,40,2,0,34,7,65,24,116,32,3,65,8,118,114,54,2,0,32,2,65,16,106,33,2,32,6,65,16,106,33,6,32,4,65,112,106,34,4,65,18,75,13,0,11,32,8,32,9,107,33,4,32,5,32,10,106,33,2,12,4,11,32,5,32,1,40,2,0,34,7,58,0,0,32,5,32,1,45,0,1,58,0,1,32,5,65,2,106,33,2,32,3,65,126,106,34,4,65,18,73,13,2,32,1,65,16,106,33,6,32,3,65,110,106,33,8,32,1,32,3,65,108,106,65,112,113,34,9,65,18,106,34,10,106,33,1,3,64,32,2,32,6,65,116,106,40,2,0,34,3,65,16,116,32,7,65,16,118,114,54,2,0,32,2,65,4,106,32,6,65,120,106,40,2,0,34,7,65,16,116,32,3,65,16,118,114,54,2,0,32,2,65,8,106,32,6,65,124,106,40,2,0,34,3,65,16,116,32,7,65,16,118,114,54,2,0,32,2,65,12,106,32,6,40,2,0,34,7,65,16,116,32,3,65,16,118,114,54,2,0,32,2,65,16,106,33,2,32,6,65,16,106,33,6,32,4,65,112,106,34,4,65,17,75,13,0,11,32,8,32,9,107,33,4,32,5,32,10,106,33,2,12,3,11,32,1,65,3,106,33,1,12,2,11,32,1,65,1,106,33,1,12,1,11,32,1,65,2,106,33,1,11,32,4,65,16,113,4,64,32,2,32,1,45,0,1,58,0,1,32,2,32,1,45,0,2,58,0,2,32,2,32,1,45,0,3,58,0,3,32,2,32,1,45,0,4,58,0,4,32,2,32,1,45,0,5,58,0,5,32,2,32,1,45,0,6,58,0,6,32,2,32,1,45,0,7,58,0,7,32,2,32,1,45,0,8,58,0,8,32,2,32,1,45,0,9,58,0,9,32,2,32,1,45,0,10,58,0,10,32,2,32,1,45,0,11,58,0,11,32,2,32,1,45,0,12,58,0,12,32,2,32,1,45,0,13,58,0,13,32,2,32,1,45,0,14,58,0,14,32,2,32,1,45,0,0,58,0,0,32,2,32,1,45,0,15,58,0,15,32,2,65,16,106,33,2,32,1,65,16,106,33,1,11,32,4,65,8,113,4,64,32,2,32,1,45,0,0,58,0,0,32,2,32,1,45,0,1,58,0,1,32,2,32,1,45,0,2,58,0,2,32,2,32,1,45,0,3,58,0,3,32,2,32,1,45,0,4,58,0,4,32,2,32,1,45,0,5,58,0,5,32,2,32,1,45,0,6,58,0,6,32,2,32,1,45,0,7,58,0,7,32,2,65,8,106,33,2,32,1,65,8,106,33,1,11,32,4,65,4,113,4,64,32,2,32,1,45,0,0,58,0,0,32,2,32,1,45,0,1,58,0,1,32,2,32,1,45,0,2,58,0,2,32,2,32,1,45,0,3,58,0,3,32,2,65,4,106,33,2,32,1,65,4,106,33,1,11,32,4,65,2,113,4,64,32,2,32,1,45,0,0,58,0,0,32,2,32,1,45,0,1,58,0,1,32,2,65,2,106,33,2,32,1,65,2,106,33,1,11,32,4,65,1,113,69,13,0,32,2,32,1,45,0,0,58,0,0,32,0,15,11,32,0,11,11,255,130,128,128,0,2,2,127,1,126,2,127,2,64,32,2,69,13,0,32,0,32,2,106,34,3,65,127,106,32,1,58,0,0,32,0,32,1,58,0,0,32,2,65,3,73,13,0,32,3,65,126,106,32,1,58,0,0,32,0,32,1,58,0,1,32,3,65,125,106,32,1,58,0,0,32,0,32,1,58,0,2,32,2,65,7,73,13,0,32,3,65,124,106,32,1,58,0,0,32,0,32,1,58,0,3,32,2,65,9,73,13,0,32,0,65,0,32,0,107,65,3,113,34,4,106,34,3,32,1,65,255,1,113,65,129,130,132,8,108,34,1,54,2,0,32,3,32,2,32,4,107,65,124,113,34,4,106,34,2,65,124,106,32,1,54,2,0,32,4,65,9,73,13,0,32,3,32,1,54,2,8,32,3,32,1,54,2,4,32,2,65,120,106,32,1,54,2,0,32,2,65,116,106,32,1,54,2,0,32,4,65,25,73,13,0,32,3,32,1,54,2,16,32,3,32,1,54,2,12,32,3,32,1,54,2,20,32,3,32,1,54,2,24,32,2,65,104,106,32,1,54,2,0,32,2,65,100,106,32,1,54,2,0,32,2,65,108,106,32,1,54,2,0,32,2,65,112,106,32,1,54,2,0,32,4,32,3,65,4,113,65,24,114,34,4,107,34,2,65,32,73,13,0,32,1,173,34,5,66,32,134,32,5,132,33,5,32,3,32,4,106,33,1,3,64,32,1,32,5,55,3,0,32,1,65,8,106,32,5,55,3,0,32,1,65,16,106,32,5,55,3,0,32,1,65,24,106,32,5,55,3,0,32,1,65,32,106,33,1,32,2,65,96,106,34,2,65,31,75,13,0,11,11,32,0,11,11,162,181,128,128,0,1,10,127,2,127,65,192,0,40,2,0,65,16,107,33,7,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,32,1,65,244,1,77,4,64,32,0,40,2,0,34,4,65,16,32,1,65,11,106,65,120,113,32,1,65,11,73,27,34,5,65,3,118,34,2,118,34,1,65,3,113,69,13,1,32,0,32,1,65,127,115,65,1,113,32,2,106,34,3,65,3,116,106,34,5,65,48,106,40,2,0,34,1,65,8,106,33,6,32,1,40,2,8,34,2,32,5,65,40,106,34,5,70,13,2,32,0,40,2,16,32,2,75,32,2,40,2,12,32,1,71,114,13,3,32,5,65,8,106,32,2,54,2,0,32,2,65,12,106,32,5,54,2,0,12,3,11,65,127,33,5,32,1,65,191,127,75,13,17,32,1,65,11,106,34,2,65,120,113,33,5,32,0,40,2,4,34,10,69,13,17,2,127,65,0,32,2,65,8,118,34,2,69,13,0,26,65,31,32,5,65,255,255,255,7,75,13,0,26,32,5,65,14,32,2,32,2,65,128,254,63,106,65,16,118,65,8,113,34,3,116,34,2,65,128,224,31,106,65,16,118,65,4,113,34,4,32,3,114,32,2,32,4,116,34,2,65,128,128,15,106,65,16,118,65,2,113,34,3,114,107,32,2,32,3,116,65,15,118,106,34,2,65,7,106,118,65,1,113,32,2,65,1,116,114,11,33,9,65,0,32,5,107,33,3,32,0,32,9,65,2,116,106,65,176,2,106,40,2,0,34,2,69,13,4,32,5,65,0,65,25,32,9,65,1,118,107,32,9,65,31,70,27,116,33,6,65,0,33,1,65,0,33,4,3,64,32,2,40,2,4,65,120,113,32,5,107,34,8,32,3,73,4,64,32,8,33,3,32,2,33,4,32,8,69,13,8,11,32,1,32,2,65,20,106,40,2,0,34,8,32,8,32,2,32,6,65,29,118,65,4,113,106,65,16,106,40,2,0,34,2,70,27,32,1,32,8,27,33,1,32,6,32,2,65,0,71,116,33,6,32,2,13,0,11,32,1,32,4,114,69,13,4,12,14,11,32,5,32,0,40,2,8,34,3,77,13,16,32,1,69,13,4,32,0,65,40,106,34,7,32,1,32,2,116,65,2,32,2,116,34,1,65,0,32,1,107,114,113,34,1,65,0,32,1,107,113,65,127,106,34,1,32,1,65,12,118,65,16,113,34,1,118,34,2,65,5,118,65,8,113,34,6,32,1,114,32,2,32,6,118,34,1,65,2,118,65,4,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,2,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,1,113,34,2,114,32,1,32,2,118,106,34,8,65,3,116,106,34,2,40,2,8,34,1,40,2,8,34,6,32,2,70,13,6,32,0,40,2,16,32,6,75,32,6,40,2,12,32,1,71,114,13,7,32,2,65,8,106,32,6,54,2,0,32,6,65,12,106,32,2,54,2,0,32,0,65,8,106,40,2,0,33,3,12,7,11,32,0,32,4,65,126,32,3,119,113,54,2,0,11,32,1,32,3,65,3,116,34,2,65,3,114,54,2,4,32,1,32,2,106,34,1,32,1,40,2,4,65,1,114,54,2,4,32,6,15,11,11,65,0,33,4,32,10,65,2,32,9,116,34,1,65,0,32,1,107,114,113,34,1,69,13,12,32,0,32,1,65,0,32,1,107,113,65,127,106,34,1,32,1,65,12,118,65,16,113,34,1,118,34,2,65,5,118,65,8,113,34,6,32,1,114,32,2,32,6,118,34,1,65,2,118,65,4,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,2,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,1,113,34,2,114,32,1,32,2,118,106,65,2,116,106,65,176,2,106,40,2,0,34,1,13,10,12,11,11,32,0,40,2,4,34,1,69,13,11,32,0,32,1,65,0,32,1,107,113,65,127,106,34,1,32,1,65,12,118,65,16,113,34,1,118,34,2,65,5,118,65,8,113,34,3,32,1,114,32,2,32,3,118,34,1,65,2,118,65,4,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,2,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,1,113,34,2,114,32,1,32,2,118,106,65,2,116,106,65,176,2,106,40,2,0,34,3,40,2,4,65,120,113,32,5,107,33,2,32,3,65,16,106,32,3,40,2,16,69,65,2,116,106,40,2,0,34,1,4,64,3,64,32,1,40,2,4,65,120,113,32,5,107,34,4,32,2,32,4,32,2,73,34,4,27,33,2,32,1,32,3,32,4,27,33,3,32,1,65,16,106,32,1,40,2,16,69,65,2,116,106,40,2,0,34,4,33,1,32,4,13,0,11,11,32,0,40,2,16,34,10,32,3,75,13,11,32,3,32,5,106,34,9,32,3,77,13,11,32,3,40,2,24,33,7,32,3,40,2,12,34,6,32,3,70,13,3,32,10,32,3,40,2,8,34,1,75,32,1,40,2,12,32,3,71,114,32,6,40,2,8,32,3,71,114,13,4,32,6,65,8,106,32,1,54,2,0,32,1,65,12,106,32,6,54,2,0,32,7,13,6,12,7,11,65,0,33,3,32,2,33,4,32,2,33,1,12,8,11,32,0,32,4,65,126,32,8,119,113,54,2,0,11,32,1,65,8,106,33,4,32,1,32,5,65,3,114,54,2,4,32,1,32,5,106,34,6,32,8,65,3,116,34,8,32,5,107,34,2,65,1,114,54,2,4,32,1,32,8,106,32,2,54,2,0,32,3,4,64,32,7,32,3,65,3,118,34,5,65,3,116,106,33,3,32,0,65,20,106,40,2,0,33,1,2,127,32,0,40,2,0,34,8,65,1,32,5,116,34,5,113,4,64,32,3,32,3,40,2,8,34,5,32,0,40,2,16,32,5,75,27,12,1,11,32,0,32,8,32,5,114,54,2,0,32,3,11,34,5,32,1,54,2,12,32,3,65,8,106,32,1,54,2,0,32,1,32,3,54,2,12,32,1,32,5,54,2,8,11,32,0,65,20,106,32,6,54,2,0,32,0,65,8,106,32,2,54,2,0,32,4,15,11,32,3,65,20,106,34,4,40,2,0,34,1,69,4,64,32,3,40,2,16,34,1,69,13,2,32,3,65,16,106,33,4,11,3,64,32,4,33,8,32,1,34,6,65,20,106,34,4,40,2,0,34,1,13,0,32,6,65,16,106,33,4,32,6,40,2,16,34,1,13,0,11,32,10,32,8,75,13,0,32,8,65,0,54,2,0,11,32,7,69,13,2,12,1,11,65,0,33,6,32,7,69,13,1,11,2,64,2,64,32,3,32,0,32,3,40,2,28,34,4,65,2,116,106,65,176,2,106,34,1,40,2,0,71,4,64,32,0,65,16,106,40,2,0,32,7,77,4,64,32,7,65,16,106,32,7,40,2,16,32,3,71,65,2,116,106,32,6,54,2,0,11,32,6,13,1,12,3,11,32,1,32,6,54,2,0,32,6,69,13,1,11,32,0,65,16,106,40,2,0,34,4,32,6,75,13,1,32,6,32,7,54,2,24,32,3,40,2,16,34,1,69,32,4,32,1,75,114,69,4,64,32,6,32,1,54,2,16,32,1,32,6,54,2,24,11,32,3,65,20,106,40,2,0,34,1,69,32,0,65,16,106,40,2,0,32,1,75,114,13,1,32,6,65,20,106,32,1,54,2,0,32,1,32,6,54,2,24,12,1,11,32,0,65,4,106,34,1,32,1,40,2,0,65,126,32,4,119,113,54,2,0,11,2,64,32,2,65,15,77,4,64,32,3,32,2,32,5,106,34,1,65,3,114,54,2,4,32,3,32,1,106,34,1,32,1,40,2,4,65,1,114,54,2,4,12,1,11,32,3,32,5,65,3,114,54,2,4,32,9,32,2,65,1,114,54,2,4,32,9,32,2,106,32,2,54,2,0,32,0,65,8,106,34,4,40,2,0,34,1,4,64,32,0,32,1,65,3,118,34,6,65,3,116,106,65,40,106,33,5,32,0,65,20,106,40,2,0,33,1,2,127,32,0,40,2,0,34,8,65,1,32,6,116,34,6,113,4,64,32,5,32,5,40,2,8,34,6,32,0,65,16,106,40,2,0,32,6,75,27,12,1,11,32,0,32,8,32,6,114,54,2,0,32,5,11,34,6,32,1,54,2,12,32,5,65,8,106,32,1,54,2,0,32,1,32,5,54,2,12,32,1,32,6,54,2,8,11,32,0,65,20,106,32,9,54,2,0,32,4,32,2,54,2,0,11,32,3,65,8,106,15,11,32,1,69,13,1,11,3,64,32,1,40,2,4,65,120,113,32,5,107,34,2,32,3,32,2,32,3,73,34,2,27,33,3,32,1,32,4,32,2,27,33,4,32,1,65,16,106,32,1,40,2,16,69,65,2,116,106,40,2,0,34,2,33,1,32,2,13,0,11,11,32,4,69,32,3,32,0,40,2,8,32,5,107,79,114,13,0,32,0,40,2,16,34,10,32,4,75,13,0,32,4,32,5,106,34,9,32,4,77,13,0,32,4,40,2,24,33,7,32,4,40,2,12,34,6,32,4,70,13,1,32,10,32,4,40,2,8,34,1,75,32,1,40,2,12,32,4,71,114,32,6,40,2,8,32,4,71,114,13,2,32,6,65,8,106,32,1,54,2,0,32,1,65,12,106,32,6,54,2,0,32,7,13,20,12,21,11,2,127,2,64,2,64,2,64,2,64,32,0,40,2,8,34,1,32,5,73,4,64,32,0,40,2,12,34,4,32,5,77,13,1,32,0,40,2,24,34,1,32,5,106,34,2,32,4,32,5,107,34,3,65,1,114,54,2,4,32,0,65,12,106,32,3,54,2,0,32,0,32,2,54,2,24,32,1,32,5,65,3,114,54,2,4,32,1,65,8,106,15,11,32,0,40,2,20,33,2,32,1,32,5,107,34,3,65,16,73,13,1,32,2,32,5,106,34,4,32,3,65,1,114,54,2,4,32,2,32,1,106,32,3,54,2,0,32,0,65,8,106,32,3,54,2,0,32,0,65,20,106,32,4,54,2,0,32,2,32,5,65,3,114,54,2,4,12,2,11,65,200,0,40,2,0,69,13,2,65,208,0,40,2,0,12,3,11,32,2,32,1,65,3,114,54,2,4,32,0,65,20,106,65,0,54,2,0,32,0,65,8,106,65,0,54,2,0,32,2,32,1,106,34,1,32,1,40,2,4,65,1,114,54,2,4,11,32,2,65,8,106,15,11,65,204,0,66,128,128,132,128,128,128,192,0,55,2,0,65,212,0,66,127,55,2,0,65,200,0,32,7,65,12,106,65,112,113,65,216,170,213,170,5,115,54,2,0,65,220,0,65,0,54,2,0,65,128,128,4,11,33,1,65,0,33,8,32,1,32,5,65,47,106,34,10,106,34,7,65,0,32,1,107,34,9,113,34,6,32,5,77,13,10,32,0,40,2,184,3,34,11,4,64,32,0,40,2,176,3,34,1,32,6,106,34,2,32,1,77,32,2,32,11,75,114,13,11,11,32,0,65,188,3,106,45,0,0,65,4,113,13,8,32,0,40,2,24,34,2,4,64,32,0,65,192,3,106,33,1,3,64,32,1,40,2,0,34,3,32,2,77,4,64,32,3,32,1,40,2,4,106,32,2,75,13,5,11,32,1,40,2,8,34,1,13,0,11,11,63,0,33,1,32,6,33,7,65,204,0,40,2,0,34,2,65,127,106,34,3,32,1,65,16,116,34,4,113,4,64,32,6,32,4,107,32,3,32,4,106,65,0,32,2,107,113,106,33,7,11,32,7,32,5,77,32,7,65,254,255,255,255,7,75,114,13,7,32,11,4,64,32,0,40,2,176,3,34,1,32,7,106,34,2,32,1,77,32,2,32,11,75,114,13,8,11,63,0,65,16,116,65,127,32,7,65,127,106,65,16,117,65,1,106,64,0,27,34,1,32,4,70,13,9,32,1,33,4,12,3,11,32,4,65,20,106,34,2,40,2,0,34,1,69,4,64,32,4,40,2,16,34,1,69,13,4,32,4,65,16,106,33,2,11,3,64,32,2,33,8,32,1,34,6,65,20,106,34,2,40,2,0,34,1,13,0,32,6,65,16,106,33,2,32,6,40,2,16,34,1,13,0,11,32,10,32,8,75,13,0,32,8,65,0,54,2,0,11,32,7,69,13,18,12,17,11,32,7,32,4,107,32,9,113,34,7,65,254,255,255,255,7,75,13,4,63,0,33,2,2,127,32,7,4,64,65,127,32,7,65,127,106,65,16,117,65,1,106,64,0,69,13,1,26,11,32,2,65,16,116,11,34,4,32,1,40,2,0,32,1,65,4,106,40,2,0,106,70,13,2,11,32,5,65,48,106,32,7,77,32,7,65,254,255,255,255,7,75,114,32,4,65,127,70,114,69,4,64,32,10,32,7,107,65,208,0,40,2,0,34,1,106,65,0,32,1,107,113,34,1,65,254,255,255,255,7,75,13,6,32,1,4,64,32,1,65,127,106,65,16,117,65,1,106,64,0,69,13,4,11,32,1,32,7,106,33,7,12,6,11,32,4,65,127,71,13,5,12,3,11,65,0,33,6,32,7,13,14,12,15,11,32,4,65,127,71,13,3,12,1,11,65,0,32,7,107,65,1,72,13,0,32,7,65,127,115,65,16,117,65,1,106,64,0,26,11,32,0,65,188,3,106,34,1,32,1,40,2,0,65,4,114,54,2,0,11,32,6,65,254,255,255,255,7,75,13,1,63,0,33,1,2,127,32,6,4,64,65,127,32,6,65,127,106,65,16,117,65,1,106,64,0,69,13,1,26,11,32,1,65,16,116,11,33,4,63,0,33,1,32,4,65,127,70,13,1,32,4,32,1,65,16,116,34,1,79,13,1,32,1,32,4,107,34,7,32,5,65,40,106,77,13,1,11,32,0,32,0,40,2,176,3,32,7,106,34,1,54,2,176,3,32,1,32,0,40,2,180,3,75,4,64,32,0,65,180,3,106,32,1,54,2,0,11,2,64,2,64,2,64,32,0,40,2,24,34,2,4,64,32,0,65,192,3,106,34,9,33,1,3,64,32,4,32,1,40,2,0,34,3,32,1,40,2,4,34,6,106,70,13,2,32,1,40,2,8,34,1,13,0,12,3,11,0,11,2,64,32,0,40,2,16,34,1,4,64,32,4,32,1,79,13,1,11,32,0,65,16,106,32,4,54,2,0,11,32,0,32,7,54,2,196,3,32,0,32,4,54,2,192,3,65,0,33,1,32,0,65,0,54,2,204,3,32,0,65,127,54,2,32,32,0,65,200,0,40,2,0,54,2,36,3,64,32,0,32,1,106,34,2,65,48,106,32,2,65,40,106,34,3,54,2,0,32,2,65,52,106,32,3,54,2,0,32,1,65,8,106,34,1,65,128,2,71,13,0,11,32,0,65,24,106,32,0,32,0,65,124,106,40,2,0,65,120,113,106,34,1,65,120,106,34,2,65,0,32,1,107,65,7,113,65,0,32,1,65,7,113,27,34,1,106,34,3,54,2,0,32,0,65,12,106,32,4,32,7,106,34,4,32,2,107,65,88,106,32,1,107,34,1,54,2,0,32,3,32,1,65,1,114,54,2,4,32,4,65,92,106,65,40,54,2,0,32,0,65,216,0,40,2,0,54,2,28,12,2,11,32,1,45,0,12,65,8,113,32,4,32,2,77,114,32,3,32,2,75,114,13,0,32,2,65,120,32,2,107,65,7,113,65,0,32,2,65,8,106,65,7,113,27,34,3,106,34,4,32,0,65,12,106,34,9,40,2,0,32,7,106,34,10,32,3,107,34,3,65,1,114,54,2,4,32,1,65,4,106,32,6,32,7,106,54,2,0,32,0,65,216,0,40,2,0,54,2,28,32,9,32,3,54,2,0,32,0,65,24,106,32,4,54,2,0,32,2,32,10,106,65,40,54,2,4,12,1,11,32,4,32,0,40,2,16,34,6,73,4,64,32,0,65,16,106,32,4,54,2,0,32,4,33,6,11,32,4,32,7,106,33,3,32,9,33,1,2,127,2,64,2,127,2,64,2,64,2,64,2,64,3,64,32,1,40,2,0,32,3,70,13,1,32,1,40,2,8,34,1,13,0,12,2,11,0,11,32,1,45,0,12,65,8,113,13,0,32,1,32,4,54,2,0,32,1,32,1,40,2,4,32,7,106,54,2,4,32,4,65,120,32,4,107,65,7,113,65,0,32,4,65,8,106,65,7,113,27,106,34,7,32,5,65,3,114,54,2,4,32,3,65,120,32,3,107,65,7,113,65,0,32,3,65,8,106,65,7,113,27,106,34,4,32,7,107,32,5,107,33,1,32,7,32,5,106,33,3,32,2,32,4,70,13,1,32,0,40,2,20,32,4,70,13,8,32,4,40,2,4,34,2,65,3,113,65,1,71,13,14,32,2,65,120,113,33,10,32,2,65,255,1,75,13,9,32,4,40,2,12,33,8,32,4,40,2,8,34,5,32,0,32,2,65,3,118,34,9,65,3,116,106,65,40,106,34,2,71,4,64,32,6,32,5,75,32,5,40,2,12,32,4,71,114,13,14,11,32,8,32,5,70,13,10,32,8,32,2,71,4,64,32,6,32,8,75,32,8,40,2,8,32,4,71,114,13,14,11,32,5,32,8,54,2,12,32,8,65,8,106,32,5,54,2,0,12,13,11,32,9,33,1,2,64,3,64,32,1,40,2,0,34,3,32,2,77,4,64,32,3,32,1,40,2,4,106,34,3,32,2,75,13,2,11,32,1,40,2,8,33,1,12,0,11,0,11,32,4,65,120,32,4,107,65,7,113,65,0,32,4,65,8,106,65,7,113,27,34,1,106,34,10,32,7,65,88,106,34,6,32,1,107,34,1,65,1,114,54,2,4,32,4,32,6,106,65,40,54,2,4,32,2,32,3,65,39,32,3,107,65,7,113,65,0,32,3,65,89,106,65,7,113,27,106,65,81,106,34,6,32,6,32,2,65,16,106,73,27,34,6,65,27,54,2,4,32,0,65,216,0,40,2,0,54,2,28,32,0,65,12,106,32,1,54,2,0,32,0,65,24,106,32,10,54,2,0,32,6,32,9,40,2,0,54,2,8,32,6,65,20,106,32,9,65,12,106,40,2,0,54,2,0,32,6,65,16,106,32,9,65,8,106,40,2,0,54,2,0,32,6,65,12,106,32,9,65,4,106,40,2,0,54,2,0,32,0,32,7,54,2,196,3,32,0,65,192,3,106,32,4,54,2,0,32,0,65,0,54,2,204,3,32,0,32,6,65,8,106,54,2,200,3,32,6,65,28,106,33,1,3,64,32,1,65,7,54,2,0,32,1,65,4,106,34,1,32,3,73,13,0,11,32,6,32,2,70,13,5,32,6,65,4,106,34,1,32,1,40,2,0,65,126,113,54,2,0,32,6,32,6,32,2,107,34,7,54,2,0,32,2,32,7,65,1,114,54,2,4,32,7,65,255,1,77,4,64,32,0,32,7,65,3,118,34,3,65,3,116,106,65,40,106,33,1,32,0,40,2,0,34,4,65,1,32,3,116,34,3,113,69,13,2,32,1,32,1,40,2,8,34,3,32,0,65,16,106,40,2,0,32,3,75,27,12,3,11,32,7,65,8,118,34,3,69,13,3,65,31,32,7,65,255,255,255,7,75,13,4,26,32,7,65,14,32,3,32,3,65,128,254,63,106,65,16,118,65,8,113,34,1,116,34,3,65,128,224,31,106,65,16,118,65,4,113,34,4,32,1,114,32,3,32,4,116,34,1,65,128,128,15,106,65,16,118,65,2,113,34,3,114,107,32,1,32,3,116,65,15,118,106,34,1,65,7,106,118,65,1,113,32,1,65,1,116,114,12,4,11,32,0,65,24,106,32,3,54,2,0,32,0,65,12,106,34,2,32,2,40,2,0,32,1,106,34,1,54,2,0,32,3,32,1,65,1,114,54,2,4,12,13,11,32,0,32,4,32,3,114,54,2,0,32,1,11,34,3,32,2,54,2,12,32,1,65,8,106,32,2,54,2,0,32,2,32,1,54,2,12,32,2,32,3,54,2,8,12,2,11,65,0,11,33,1,32,2,66,0,55,2,16,32,2,65,28,106,32,1,54,2,0,32,0,32,1,65,2,116,106,65,176,2,106,33,3,2,64,2,64,32,0,40,2,4,34,4,65,1,32,1,116,34,6,113,4,64,32,7,65,0,65,25,32,1,65,1,118,107,32,1,65,31,70,27,116,33,1,32,3,40,2,0,33,4,3,64,32,4,34,3,40,2,4,65,120,113,32,7,70,13,3,32,1,65,29,118,33,4,32,1,65,1,116,33,1,32,3,32,4,65,4,113,106,65,16,106,34,6,40,2,0,34,4,13,0,11,32,0,65,16,106,40,2,0,32,6,75,13,3,32,6,32,2,54,2,0,32,2,65,24,106,32,3,54,2,0,12,1,11,32,0,65,4,106,32,4,32,6,114,54,2,0,32,3,32,2,54,2,0,32,2,65,24,106,32,3,54,2,0,11,32,2,32,2,54,2,12,32,2,32,2,54,2,8,12,1,11,32,0,65,16,106,40,2,0,34,4,32,3,40,2,8,34,1,75,32,4,32,3,75,114,13,0,32,1,32,2,54,2,12,32,3,65,8,106,32,2,54,2,0,32,2,32,3,54,2,12,32,2,65,24,106,65,0,54,2,0,32,2,32,1,54,2,8,11,32,0,65,12,106,34,1,40,2,0,34,2,32,5,77,13,0,32,0,65,24,106,34,4,40,2,0,34,3,32,5,106,34,6,32,2,32,5,107,34,2,65,1,114,54,2,4,32,1,32,2,54,2,0,32,4,32,6,54,2,0,32,3,32,5,65,3,114,54,2,4,32,3,65,8,106,33,8,11,32,8,15,11,32,3,32,0,65,8,106,34,2,40,2,0,32,1,106,34,1,65,1,114,54,2,4,32,0,65,20,106,32,3,54,2,0,32,2,32,1,54,2,0,32,3,32,1,106,32,1,54,2,0,12,6,11,32,4,40,2,24,33,11,2,64,32,4,40,2,12,34,8,32,4,71,4,64,32,6,32,4,40,2,8,34,2,75,32,2,40,2,12,32,4,71,114,32,8,40,2,8,32,4,71,114,13,1,32,8,65,8,106,32,2,54,2,0,32,2,65,12,106,32,8,54,2,0,32,11,13,4,12,5,11,32,4,65,20,106,34,2,40,2,0,34,5,69,4,64,32,4,65,16,106,34,2,40,2,0,34,5,69,13,3,11,3,64,32,2,33,9,32,5,34,8,65,20,106,34,2,40,2,0,34,5,13,0,32,8,65,16,106,33,2,32,8,40,2,16,34,5,13,0,11,32,6,32,9,75,13,0,32,9,65,0,54,2,0,11,32,11,69,13,3,12,2,11,32,0,32,0,40,2,0,65,126,32,9,119,113,54,2,0,12,2,11,65,0,33,8,32,11,69,13,1,11,2,64,2,64,32,0,32,4,40,2,28,34,5,65,2,116,106,65,176,2,106,34,2,40,2,0,32,4,71,4,64,32,0,65,16,106,40,2,0,32,11,77,4,64,32,11,65,16,106,32,11,40,2,16,32,4,71,65,2,116,106,32,8,54,2,0,11,32,8,13,1,12,3,11,32,2,32,8,54,2,0,32,8,69,13,1,11,32,0,65,16,106,40,2,0,34,5,32,8,75,13,1,32,8,32,11,54,2,24,32,4,40,2,16,34,2,69,32,5,32,2,75,114,69,4,64,32,8,32,2,54,2,16,32,2,32,8,54,2,24,11,32,4,65,20,106,40,2,0,34,2,69,32,0,65,16,106,40,2,0,32,2,75,114,13,1,32,8,65,20,106,32,2,54,2,0,32,2,32,8,54,2,24,12,1,11,32,0,32,0,40,2,4,65,126,32,5,119,113,54,2,4,11,32,10,32,1,106,33,1,32,4,32,10,106,33,4,11,32,4,32,4,40,2,4,65,126,113,54,2,4,32,3,32,1,65,1,114,54,2,4,32,3,32,1,106,32,1,54,2,0,2,127,2,64,2,127,2,64,32,1,65,255,1,77,4,64,32,0,32,1,65,3,118,34,2,65,3,116,106,65,40,106,33,1,32,0,40,2,0,34,5,65,1,32,2,116,34,2,113,69,13,1,32,1,65,8,106,33,5,32,1,32,1,40,2,8,34,2,32,0,65,16,106,40,2,0,32,2,75,27,12,2,11,32,1,65,8,118,34,5,69,13,2,65,31,32,1,65,255,255,255,7,75,13,3,26,32,1,65,14,32,5,32,5,65,128,254,63,106,65,16,118,65,8,113,34,2,116,34,5,65,128,224,31,106,65,16,118,65,4,113,34,4,32,2,114,32,5,32,4,116,34,2,65,128,128,15,106,65,16,118,65,2,113,34,5,114,107,32,2,32,5,116,65,15,118,106,34,2,65,7,106,118,65,1,113,32,2,65,1,116,114,12,3,11,32,0,32,5,32,2,114,54,2,0,32,1,65,8,106,33,5,32,1,11,34,2,32,3,54,2,12,32,5,32,3,54,2,0,32,3,32,1,54,2,12,32,3,32,2,54,2,8,12,2,11,65,0,11,33,2,32,3,32,2,54,2,28,32,3,66,0,55,2,16,32,0,32,2,65,2,116,106,65,176,2,106,33,5,2,64,2,64,32,0,40,2,4,34,4,65,1,32,2,116,34,6,113,4,64,32,1,65,0,65,25,32,2,65,1,118,107,32,2,65,31,70,27,116,33,2,32,5,40,2,0,33,4,3,64,32,4,34,5,40,2,4,65,120,113,32,1,70,13,3,32,2,65,29,118,33,4,32,2,65,1,116,33,2,32,5,32,4,65,4,113,106,65,16,106,34,6,40,2,0,34,4,13,0,11,32,0,65,16,106,40,2,0,32,6,75,13,3,32,6,32,3,54,2,0,32,3,32,5,54,2,24,12,1,11,32,0,65,4,106,32,4,32,6,114,54,2,0,32,5,32,3,54,2,0,32,3,32,5,54,2,24,11,32,3,32,3,54,2,12,32,3,32,3,54,2,8,12,1,11,32,0,65,16,106,40,2,0,34,2,32,5,40,2,8,34,1,75,32,2,32,5,75,114,13,0,32,1,32,3,54,2,12,32,5,65,8,106,32,3,54,2,0,32,3,65,0,54,2,24,32,3,32,5,54,2,12,32,3,32,1,54,2,8,11,32,7,65,8,106,15,11,2,64,2,64,32,4,32,0,32,4,40,2,28,34,2,65,2,116,106,65,176,2,106,34,1,40,2,0,71,4,64,32,0,65,16,106,40,2,0,32,7,77,4,64,32,7,65,16,106,32,7,40,2,16,32,4,71,65,2,116,106,32,6,54,2,0,11,32,6,13,1,12,3,11,32,1,32,6,54,2,0,32,6,69,13,1,11,32,0,65,16,106,40,2,0,34,2,32,6,75,13,1,32,6,32,7,54,2,24,32,4,40,2,16,34,1,69,32,2,32,1,75,114,69,4,64,32,6,32,1,54,2,16,32,1,32,6,54,2,24,11,32,4,65,20,106,40,2,0,34,1,69,32,0,65,16,106,40,2,0,32,1,75,114,13,1,32,6,65,20,106,32,1,54,2,0,32,1,32,6,54,2,24,12,1,11,32,0,65,4,106,34,1,32,1,40,2,0,65,126,32,2,119,113,54,2,0,11,2,64,32,3,65,15,77,4,64,32,4,32,3,32,5,106,34,1,65,3,114,54,2,4,32,4,32,1,106,34,1,32,1,40,2,4,65,1,114,54,2,4,12,1,11,32,4,32,5,65,3,114,54,2,4,32,9,32,3,65,1,114,54,2,4,32,9,32,3,106,32,3,54,2,0,2,127,2,64,2,127,2,64,32,3,65,255,1,77,4,64,32,0,32,3,65,3,118,34,2,65,3,116,106,65,40,106,33,1,32,0,40,2,0,34,3,65,1,32,2,116,34,2,113,69,13,1,32,1,65,8,106,33,3,32,1,32,1,40,2,8,34,2,32,0,65,16,106,40,2,0,32,2,75,27,12,2,11,32,3,65,8,118,34,2,69,13,2,65,31,32,3,65,255,255,255,7,75,13,3,26,32,3,65,14,32,2,32,2,65,128,254,63,106,65,16,118,65,8,113,34,1,116,34,2,65,128,224,31,106,65,16,118,65,4,113,34,5,32,1,114,32,2,32,5,116,34,1,65,128,128,15,106,65,16,118,65,2,113,34,2,114,107,32,1,32,2,116,65,15,118,106,34,1,65,7,106,118,65,1,113,32,1,65,1,116,114,12,3,11,32,0,32,3,32,2,114,54,2,0,32,1,65,8,106,33,3,32,1,11,34,2,32,9,54,2,12,32,3,32,9,54,2,0,32,9,32,1,54,2,12,32,9,32,2,54,2,8,12,2,11,65,0,11,33,1,32,9,32,1,54,2,28,32,9,66,0,55,2,16,32,0,32,1,65,2,116,106,65,176,2,106,33,2,2,64,2,64,32,0,65,4,106,34,5,40,2,0,34,6,65,1,32,1,116,34,8,113,4,64,32,3,65,0,65,25,32,1,65,1,118,107,32,1,65,31,70,27,116,33,1,32,2,40,2,0,33,5,3,64,32,5,34,2,40,2,4,65,120,113,32,3,70,13,3,32,1,65,29,118,33,5,32,1,65,1,116,33,1,32,2,32,5,65,4,113,106,65,16,106,34,6,40,2,0,34,5,13,0,11,32,0,65,16,106,40,2,0,32,6,75,13,3,32,6,32,9,54,2,0,32,9,32,2,54,2,24,12,1,11,32,5,32,6,32,8,114,54,2,0,32,2,32,9,54,2,0,32,9,32,2,54,2,24,11,32,9,32,9,54,2,12,32,9,32,9,54,2,8,12,1,11,32,0,65,16,106,40,2,0,34,3,32,2,40,2,8,34,1,75,32,3,32,2,75,114,13,0,32,1,32,9,54,2,12,32,2,65,8,106,32,9,54,2,0,32,9,65,0,54,2,24,32,9,32,2,54,2,12,32,9,32,1,54,2,8,11,32,4,65,8,106,11,11,171,144,128,128,0,1,8,127,2,64,32,1,69,13,0,32,1,65,120,106,34,2,32,0,40,2,16,34,8,73,13,0,32,1,65,124,106,40,2,0,34,1,65,3,113,34,4,65,1,70,13,0,32,2,32,1,65,120,113,34,6,106,33,5,2,64,2,64,32,1,65,1,113,13,0,32,4,69,13,2,32,2,32,2,40,2,0,34,1,107,34,2,32,8,73,13,2,32,1,32,6,106,33,6,2,64,2,64,2,64,2,64,32,0,40,2,20,32,2,71,4,64,32,1,65,255,1,75,13,1,32,2,40,2,12,33,3,32,2,40,2,8,34,4,32,0,32,1,65,3,118,34,7,65,3,116,106,65,40,106,34,1,71,4,64,32,8,32,4,75,32,4,40,2,12,32,2,71,114,13,6,11,32,3,32,4,70,13,2,32,3,32,1,71,4,64,32,8,32,3,75,32,3,40,2,8,32,2,71,114,13,6,11,32,4,32,3,54,2,12,32,3,65,8,106,32,4,54,2,0,32,2,32,5,73,13,6,12,7,11,32,5,40,2,4,34,1,65,3,113,65,3,71,13,4,32,5,65,4,106,32,1,65,126,113,54,2,0,32,2,32,6,65,1,114,54,2,4,32,0,32,6,54,2,8,32,2,32,6,106,32,6,54,2,0,15,11,32,2,40,2,24,33,9,2,64,32,2,40,2,12,34,3,32,2,71,4,64,32,8,32,2,40,2,8,34,1,75,32,1,40,2,12,32,2,71,114,32,3,40,2,8,32,2,71,114,13,1,32,3,65,8,106,32,1,54,2,0,32,1,65,12,106,32,3,54,2,0,32,9,13,4,12,5,11,32,2,65,20,106,34,1,40,2,0,34,4,69,4,64,32,2,65,16,106,34,1,40,2,0,34,4,69,13,3,11,3,64,32,1,33,7,32,4,34,3,65,20,106,34,1,40,2,0,34,4,13,0,32,3,65,16,106,33,1,32,3,40,2,16,34,4,13,0,11,32,8,32,7,75,13,0,32,7,65,0,54,2,0,11,32,9,69,13,3,12,2,11,32,0,32,0,40,2,0,65,126,32,7,119,113,54,2,0,32,2,32,5,73,13,3,12,4,11,65,0,33,3,32,9,69,13,1,11,2,64,2,64,32,0,32,2,40,2,28,34,4,65,2,116,106,65,176,2,106,34,1,40,2,0,32,2,71,4,64,32,0,65,16,106,40,2,0,32,9,77,4,64,32,9,65,16,106,32,9,40,2,16,32,2,71,65,2,116,106,32,3,54,2,0,11,32,3,13,1,12,3,11,32,1,32,3,54,2,0,32,3,69,13,1,11,32,0,65,16,106,40,2,0,34,4,32,3,75,13,1,32,3,32,9,54,2,24,32,2,40,2,16,34,1,69,32,4,32,1,75,114,69,4,64,32,3,32,1,54,2,16,32,1,32,3,54,2,24,11,32,2,65,20,106,40,2,0,34,1,69,32,0,65,16,106,40,2,0,32,1,75,114,13,1,32,3,65,20,106,32,1,54,2,0,32,1,32,3,54,2,24,32,2,32,5,73,13,2,12,3,11,32,0,32,0,40,2,4,65,126,32,4,119,113,54,2,4,11,32,2,32,5,79,13,1,11,32,5,40,2,4,34,1,65,1,113,69,13,0,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,32,1,65,2,113,69,4,64,32,0,40,2,24,32,5,70,13,1,32,0,40,2,20,32,5,70,13,2,32,1,65,120,113,32,6,106,33,6,32,1,65,255,1,75,13,3,32,5,40,2,12,33,3,32,5,40,2,8,34,4,32,0,32,1,65,3,118,34,8,65,3,116,106,65,40,106,34,1,71,4,64,32,0,65,16,106,40,2,0,32,4,75,32,4,40,2,12,32,5,71,114,13,8,11,32,3,32,4,70,13,4,32,3,32,1,71,4,64,32,0,65,16,106,40,2,0,32,3,75,32,3,40,2,8,32,5,71,114,13,8,11,32,4,32,3,54,2,12,32,3,65,8,106,32,4,54,2,0,12,7,11,32,5,65,4,106,32,1,65,126,113,54,2,0,32,2,32,6,106,32,6,54,2,0,32,2,32,6,65,1,114,54,2,4,12,7,11,32,0,65,24,106,32,2,54,2,0,32,0,32,0,40,2,12,32,6,106,34,1,54,2,12,32,2,32,1,65,1,114,54,2,4,32,2,32,0,40,2,20,71,13,7,32,0,65,0,54,2,8,32,0,65,20,106,65,0,54,2,0,15,11,32,0,65,20,106,32,2,54,2,0,32,0,32,0,40,2,8,32,6,106,34,1,54,2,8,32,2,32,1,65,1,114,54,2,4,32,2,32,1,106,32,1,54,2,0,15,11,32,5,40,2,24,33,7,2,64,32,5,40,2,12,34,3,32,5,71,4,64,32,0,65,16,106,40,2,0,32,5,40,2,8,34,1,75,32,1,40,2,12,32,5,71,114,32,3,40,2,8,32,5,71,114,13,1,32,3,65,8,106,32,1,54,2,0,32,1,65,12,106,32,3,54,2,0,32,7,13,4,12,5,11,32,5,65,20,106,34,1,40,2,0,34,4,69,4,64,32,5,65,16,106,34,1,40,2,0,34,4,69,13,3,11,3,64,32,1,33,8,32,4,34,3,65,20,106,34,1,40,2,0,34,4,13,0,32,3,65,16,106,33,1,32,3,40,2,16,34,4,13,0,11,32,0,65,16,106,40,2,0,32,8,75,13,0,32,8,65,0,54,2,0,11,32,7,69,13,3,12,2,11,32,0,32,0,40,2,0,65,126,32,8,119,113,54,2,0,12,2,11,65,0,33,3,32,7,69,13,1,11,2,64,2,64,32,0,32,5,40,2,28,34,4,65,2,116,106,65,176,2,106,34,1,40,2,0,32,5,71,4,64,32,0,65,16,106,40,2,0,32,7,77,4,64,32,7,65,16,106,32,7,40,2,16,32,5,71,65,2,116,106,32,3,54,2,0,11,32,3,13,1,12,3,11,32,1,32,3,54,2,0,32,3,69,13,1,11,32,0,65,16,106,40,2,0,34,4,32,3,75,13,1,32,3,32,7,54,2,24,32,5,40,2,16,34,1,69,32,4,32,1,75,114,69,4,64,32,3,32,1,54,2,16,32,1,32,3,54,2,24,11,32,5,65,20,106,40,2,0,34,1,69,32,0,65,16,106,40,2,0,32,1,75,114,13,1,32,3,65,20,106,32,1,54,2,0,32,1,32,3,54,2,24,12,1,11,32,0,32,0,40,2,4,65,126,32,4,119,113,54,2,4,11,32,2,32,6,106,32,6,54,2,0,32,2,32,6,65,1,114,54,2,4,32,2,32,0,65,20,106,40,2,0,71,13,0,32,0,32,6,54,2,8,15,11,2,127,2,64,2,127,2,64,32,6,65,255,1,77,4,64,32,0,32,6,65,3,118,34,4,65,3,116,106,65,40,106,33,1,32,0,40,2,0,34,6,65,1,32,4,116,34,4,113,69,13,1,32,1,32,1,40,2,8,34,4,32,0,65,16,106,40,2,0,32,4,75,27,12,2,11,32,6,65,8,118,34,4,69,13,2,65,31,32,6,65,255,255,255,7,75,13,3,26,32,6,65,14,32,4,32,4,65,128,254,63,106,65,16,118,65,8,113,34,1,116,34,4,65,128,224,31,106,65,16,118,65,4,113,34,3,32,1,114,32,4,32,3,116,34,1,65,128,128,15,106,65,16,118,65,2,113,34,4,114,107,32,1,32,4,116,65,15,118,106,34,1,65,7,106,118,65,1,113,32,1,65,1,116,114,12,3,11,32,0,32,6,32,4,114,54,2,0,32,1,11,34,0,32,2,54,2,12,32,1,65,8,106,32,2,54,2,0,32,2,32,1,54,2,12,32,2,32,0,54,2,8,15,11,65,0,11,33,1,32,2,66,0,55,2,16,32,2,65,28,106,32,1,54,2,0,32,0,32,1,65,2,116,106,65,176,2,106,33,4,2,64,2,64,2,64,32,0,40,2,4,34,3,65,1,32,1,116,34,5,113,4,64,32,6,65,0,65,25,32,1,65,1,118,107,32,1,65,31,70,27,116,33,1,32,4,40,2,0,33,3,3,64,32,3,34,4,40,2,4,65,120,113,32,6,70,13,3,32,1,65,29,118,33,3,32,1,65,1,116,33,1,32,4,32,3,65,4,113,106,65,16,106,34,5,40,2,0,34,3,13,0,11,32,0,65,16,106,40,2,0,32,5,75,13,3,32,5,32,2,54,2,0,32,2,65,24,106,32,4,54,2,0,12,1,11,32,0,65,4,106,32,3,32,5,114,54,2,0,32,4,32,2,54,2,0,32,2,65,24,106,32,4,54,2,0,11,32,2,32,2,54,2,12,32,2,32,2,54,2,8,12,1,11,32,0,65,16,106,40,2,0,34,6,32,4,40,2,8,34,1,75,32,6,32,4,75,114,13,0,32,1,32,2,54,2,12,32,4,65,8,106,32,2,54,2,0,32,2,32,4,54,2,12,32,2,65,24,106,65,0,54,2,0,32,2,32,1,54,2,8,11,32,0,32,0,40,2,32,65,127,106,34,1,54,2,32,32,1,13,0,32,0,65,200,3,106,33,1,3,64,32,1,40,2,0,34,2,65,8,106,33,1,32,2,13,0,11,32,0,65,32,106,65,127,54,2,0,11,11,222,131,128,128,0,1,9,127,2,127,32,0,33,4,63,0,65,16,116,32,0,107,33,5,32,0,33,1,65,192,0,65,192,0,40,2,0,65,16,107,34,9,54,2,0,65,0,33,7,65,200,0,40,2,0,34,3,69,4,64,65,204,0,66,128,128,132,128,128,128,192,0,55,2,0,65,212,0,66,127,55,2,0,65,200,0,32,9,65,12,106,65,112,113,65,216,170,213,170,5,115,34,3,54,2,0,65,220,0,65,0,54,2,0,11,2,64,32,5,65,137,4,73,13,0,65,0,33,7,65,248,123,65,204,0,40,2,0,107,32,5,77,13,0,65,0,33,2,32,4,65,120,32,4,107,65,7,113,65,0,32,4,65,8,106,65,7,113,27,106,34,1,65,8,106,34,7,65,0,65,224,3,16,2,33,6,32,1,65,227,3,54,2,4,32,1,65,188,3,106,32,5,54,2,0,32,1,65,184,3,106,32,5,54,2,0,32,1,65,204,3,106,32,5,54,2,0,32,1,65,44,106,32,3,54,2,0,32,1,65,40,106,65,127,54,2,0,32,1,65,24,106,32,4,54,2,0,32,1,65,200,3,106,32,4,54,2,0,32,1,65,216,3,106,65,0,54,2,0,65,220,0,40,2,0,33,3,32,1,65,220,3,106,65,0,54,2,0,32,1,65,196,3,106,32,3,65,4,114,54,2,0,3,64,32,1,32,2,106,34,3,65,56,106,32,3,65,48,106,34,8,54,2,0,32,3,65,60,106,32,8,54,2,0,32,2,65,8,106,34,2,65,128,2,71,13,0,11,32,6,32,6,65,124,106,40,2,0,65,120,113,106,34,2,65,120,106,34,3,65,0,32,2,107,65,7,113,65,0,32,2,65,7,113,27,34,2,106,34,8,32,4,32,5,106,34,1,32,3,107,65,88,106,32,2,107,34,2,65,1,114,54,2,4,32,6,65,8,54,2,204,3,32,6,65,216,0,40,2,0,54,2,28,32,6,32,8,54,2,24,32,6,32,2,54,2,12,32,1,65,92,106,65,40,54,2,0,11,65,192,0,32,9,65,16,106,54,2,0,32,7,11,11,0,205,128,128,128,0,4,110,97,109,101,1,194,128,128,128,0,6,0,6,109,101,109,99,109,112,1,6,109,101,109,99,112,121,2,6,109,101,109,115,101,116,3,13,109,115,112,97,99,101,95,109,97,108,108,111,99,4,11,109,115,112,97,99,101,95,102,114,101,101,5,11,109,115,112,97,99,101,95,105,110,105,116])},function(module,exports){module.exports="declare class Math {\n static abs(x: float32): float32;\n static acos(x: float64): float64;\n static asin(x: float64): float64;\n static atan(x: float64): float64;\n static atan2(y: float64, x: float64): float64;\n static ceil(x: float32): float32;\n static cos(x: float64): float64;\n static exp(x: float64): float64;\n static floor(x: float32): float32;\n static log(x: float64): float64;\n // static max(...values: float64[]): float64;\n static max(a: float64, b:float64): float64;\n // static min(...values: float64[]): float64;\n static min(a: float64, b:float64): float64;\n static pow(x: float64, y: float64): float64;\n static random(): float64; // 'random' is not a standard Math builtin\n // static round(x: float64): float64; //'round' is not a standard Math builtin\n static sin(x: float64): float64;\n static sqrt(x: float32): float32;\n static tan(x: float64): float64;\n static imul(a: int32, b:int32): int32;\n}\n\nfunction absf32(x:float32):float32{\n return Math.abs(x) as float32;\n}\n\nfunction sqrtf32(x:float32):float32{\n return Math.sqrt(x);\n}\n\nfunction powf32(x:float32, y:float32):float32{\n return Math.pow(x as float64, y as float64) as float32;\n}\n\nfunction minf32(x:float32, y:float32):float32{\n return Math.min(x as float64, y as float64) as float32;\n}\nfunction maxf32(x:float32, y:float32):float32{\n return Math.max(x as float64, y as float64) as float32;\n}\n\ndeclare function modf32(a:float32, b:float32):float32;\ndeclare function modf64(a:float64, b:float64):float64;\n"},function(module,exports){module.exports="class Array {\n\n bytesLength: int32;\n elementSize: int32;\n\n constructor(bytesLength: int32, elementSize: int32) {\n this.bytesLength = bytesLength;\n this.elementSize = elementSize;\n }\n\n operator [] (index: int32): T {\n let stripe = index * this.elementSize;\n if (stripe >= 0 && stripe < this.bytesLength) {\n return *((this as *uint8 + 8 + stripe) as *T);\n }\n return null as T;\n }\n\n operator []= (index: int32, value: T): void {\n let stripe = index * this.elementSize;\n if (stripe >= 0 && stripe < this.bytesLength) {\n *((this as *uint8 + 8 + stripe) as *T) = value;\n }\n }\n\n get length(): int32 {\n return this.bytesLength / this.elementSize;\n }\n}\n\n//declare type Int32Array = Array< int32 >\n//declare type Uint32Array = Array< uint32 >\n//declare type Int64Array = Array< int64 >\n//declare type Uint64Array = Array< uint64 >\n//declare type Float32Array = Array< float32 >\n//declare type Float64Array = Array< float64 >\n"},function(module,exports){module.exports='import {mspace_init, mspace_malloc, mspace_free} from "/library/dlmalloc.wasm";\n// declare function mspace_init(base:int32):int32;\n// declare function mspace_malloc(base:int32, size:int32):int32;\n// declare function mspace_free(base:int32, size:int32):void;\n\nlet originalHeapPointer: int32 = null;\nlet currentHeapPointer: int32 = null;\n\n// export function malloc_init(value:int32):int32 {\n// return mspace_init(value);\n// }\n\nexport function malloc(value:int32):int32 {\n return mspace_malloc(originalHeapPointer, value);\n}\nexport function free(value:int32):void {\n mspace_free(originalHeapPointer, value);\n}\n'},function(module,exports){module.exports="const PI:float64 = 3.141592653589793;\n\nconst MAX_UNSIGNED_INTEGER_32:uint32 = 4294967295;\n\nconst MIN_INTEGER_32:int32 = -2147483648;\nconst MAX_INTEGER_32:int32 = 2147483647;\n\nconst MAX_UNSIGNED_INTEGER_64:int32 = 18446744073709551615;\n\n// −(2^63) to 2^63 − 1\n// const MIN_INTEGER_64:int32 = -powi64(2, 63);\n// const MAX_INTEGER_64:int32 = powi64(2, 63) - 1;\n\n// float remainder\n\n // export function modf64(x:float64, y:float64):float64{\n //\n // let ir:int32,iy:int32;\n // let r:float64,w:float64;\n //\n // if (y == 0 || isNaN(y) || !isFinite(x)) {\n // return (x * y) / (x * y);\n // }\n //\n // r = abs(x);\n // y = abs(y);\n // (void)frexp(y,&iy);\n // while (r >= y) {\n // (void)frexp(r,&ir);\n // w = ldexp(y,ir-iy);\n // r -= w <= r ? w : w*(double)0.5;\n // }\n // return x >= (double)0 ? r : -r;\n // }\n // }"},function(module,exports){module.exports="// Native types\nconst NaN: float64 = 0.0 / 0.0;\nconst Infinity: float64 = 1.0 / 0.0;\n\nfunction isNaN(value: float32): boolean {\n return value != value;\n}\n\nfunction isFinite(value: float32): boolean {\n return !isNaN(value) && value != Infinity && value != -Infinity;\n}\n\ndeclare class boolean {\n toString(): string;\n}\n\ndeclare class int8 {\n toString(): string;\n}\n\ndeclare class uint8 {\n toString(): string;\n}\n\ndeclare class int16 {\n toString(): string;\n}\n\ndeclare class uint16 {\n toString(): string;\n}\n\ndeclare class int32 {\n toString(): string;\n}\n\ndeclare class uint32 {\n toString(): string;\n}\n\ndeclare class int64 {\n toString(): string;\n}\n\ndeclare class uint64 {\n toString(): string;\n}\n\ndeclare class float32 {\n toString(): string;\n}\n\ndeclare class float64 {\n toString(): string;\n}\n\ndeclare class string {\n charAt(index: int32): string;\n\n charCodeAt(index: int32): uint16;\n\n get length(): int32;\n\n indexOf(text: string): int32;\n\n lastIndexOf(text: string): int32;\n\n operator == (other: string):boolean;\n operator [] (index: int32): uint16 { return this.charCodeAt(index); }\n slice(start: int32, end: int32): string;\n\n // startsWith(text: string): boolean { return this.slice(0, text.length) == text; }\n // endsWith(text: string): boolean { return this.slice(-text.length, this.length) == text; }\n}\n"},function(module,exports){module.exports=""},function(module,exports){module.exports="declare class boolean {\n toString(): string;\n}\n\ndeclare class int8 {\n toString(): string;\n}\n\ndeclare class uint8 {\n toString(): string;\n}\n\ndeclare class int16 {\n toString(): string;\n}\n\ndeclare class uint16 {\n toString(): string;\n}\n\ndeclare class int32 {\n toString(): string;\n}\n\ndeclare class uint32 {\n toString(): string;\n}\n\ndeclare class int64 {\n toString(): string;\n}\n\ndeclare class uint64 {\n toString(): string;\n}\n\ndeclare class float32 {\n toString(): string;\n}\n\ndeclare class float64 {\n toString(): string;\n}\n\ndeclare class string {\n charAt(index: int32): string;\n charCodeAt(index: int32): uint16;\n get length(): int32;\n indexOf(text: string): int32;\n lastIndexOf(text: string): int32;\n operator == (other: string): boolean;\n operator [] (index: int32): uint16 { return this.charCodeAt(index); }\n slice(start: int32, end: int32): string;\n\n startsWith(text: string): boolean { return this.slice(0, text.length) == text; }\n endsWith(text: string): boolean { return this.slice(-text.length, this.length) == text; }\n}"},function(module,exports){module.exports="function TurboWrapper(exports, buffer) {\n\n var HEAP8 = new Int8Array(buffer);\n var HEAP16 = new Int16Array(buffer);\n var HEAP32 = new Int32Array(buffer);\n var HEAPU8 = new Uint8Array(buffer);\n var HEAPU16 = new Uint16Array(buffer);\n var HEAPU32 = new Uint32Array(buffer);\n var HEAPF32 = new Float32Array(buffer);\n var HEAPF64 = new Float64Array(buffer);\n\n return {\n exports: exports,\n RAW_MEMORY: buffer,\n\n getMemoryUsage: function () {\n const top = Atomics.load(HEAP32, 2);\n // top -= freeMemory;\n return Math.fround(top / (1024 * 1024));\n }\n }\n}\nfunction initTurbo(MB) {\n var buffer = new SharedArrayBuffer(MB * 1024 * 1024);\n\n if (buffer.byteLength < 16) {\n throw new Error(\"The memory is too small even for metadata\");\n }\n\n return TurboWrapper(TurboModule(\n typeof global !== 'undefined' ? global : window,\n typeof env !== 'undefined' ? env : {\n STACKTOP: 8,\n STACK_MAX: 8\n },\n buffer\n ), buffer);\n}\n"},function(module,exports){module.exports="// WebAssembly builtin functions\ndeclare function rotl(value: int64, shift: int64): int64;\ndeclare function rotl32(value: int32, shift: int32): int32;\ndeclare function rotr(value: int64, shift: int64): int64;\ndeclare function rotr32(value: int32, shift: int32): int32;\ndeclare function clz(value: int64): int64;\ndeclare function clz32(value: int32): int32;\ndeclare function ctz(value: int64): int64;\ndeclare function ctz32(value: int32): int32;\ndeclare function popcnt(value: int64): int64;\ndeclare function popcnt32(value: int32): int32;\ndeclare function abs(value: float64): float64;\ndeclare function abs32(value: float32): float32;\ndeclare function ceil(value: float64): float64;\ndeclare function ceil32(value: float32): float32;\ndeclare function floor(value: float64): float64;\ndeclare function floor32(value: float32): float32;\ndeclare function sqrt(value: float64): float64;\ndeclare function sqrt32(value: float32): float32;\ndeclare function trunc(value: float64): float64;\ndeclare function trunc32(value: float32): float32;\ndeclare function nearest(value: float64): float64;\ndeclare function nearest32(value: float32): float32;\ndeclare function min(left: float64, right: float64): float64;\ndeclare function min32(left: float32, right: float32): float32;\ndeclare function max(left: float64, right: float64): float64;\ndeclare function max32(left: float32, right: float32): float32;\ndeclare function copysign(left: float64, right: float64): float64;\ndeclare function copysign32(left: float32, right: float32): float32;\ndeclare function reinterpret_i32(value: float32): int32;\ndeclare function reinterpret_i64(value: float64): int64;\ndeclare function reinterpret_f32(value: int32): float32;\ndeclare function reinterpret_f64(value: int64): float64;\ndeclare function current_memory(): int32;\ndeclare function grow_memory(value: int32): int32;\n"},function(module,exports){module.exports="/**\n * Created by n.vinayakan on 30.05.17.\n * WebAssembly start function where global variable expressions initializer\n */\n@start\nfunction __WASM_INITIALIZER(): void {\n // 🔥 WARNING 🔥\n // DON'T RETURN ANYTHING FROM THIS FUNCTION\n // Global variable initialization expressions will be appended to this function\n // numFreeChunks = 0;\n // firstFree = 0;\n // lastFree = 0;\n originalHeapPointer = mspace_init(40); // size of null, originalHeapPointer & currentHeapPointer\n currentHeapPointer = originalHeapPointer;\n}\n"},function(module,exports,__webpack_require__){"use strict";function logOpcode(payload,offset,opcode,inline_value){void 0===offset&&(offset=0),payload.log+=utils_1.toHex(offset+payload.position)+": "+utils_1.toHex(opcode,2)+" ; "+opcode_1.WasmOpcode[opcode]+" "+(inline_value||"")+"\n"}Object.defineProperty(exports,"__esModule",{value:!0});var wasm_stack_tracer_1=__webpack_require__(52),utils_1=__webpack_require__(8),opcode_1=__webpack_require__(12),wasm_runtime_local_1=__webpack_require__(28),wasm_type_1=__webpack_require__(6),terminal_1=__webpack_require__(2),index_1=__webpack_require__(13),wasm_module_1=__webpack_require__(65),wasm_function_chunk_1=__webpack_require__(48),WasmAssembler=function(){function WasmAssembler(){this.sectionList=[],this.currentSection=null,this.currentFunction=null,this.module=new wasm_module_1.WasmModule,this.stackTracer=new wasm_stack_tracer_1.WasmStackTracer}return WasmAssembler.prototype.sealFunctions=function(){var runtimeFunctions=[];this.module.imports.forEach(function(_import){var fn=new wasm_stack_tracer_1.WasmRuntimeFunction;fn.module=_import.namespace,fn.name=_import.name,fn.signature=_import.signature,fn.isImport=!0,runtimeFunctions.push(fn)}),this.module.functions.forEach(function(_wasmFunc){var fn=new wasm_stack_tracer_1.WasmRuntimeFunction;fn.name=index_1.getWasmFunctionName(_wasmFunc.symbol),fn.signature=_wasmFunc.signature,fn.isImport=_wasmFunc.isExternal,_wasmFunc.isExternal||(fn.locals=[],_wasmFunc.locals.forEach(function(local){fn.locals.push(new wasm_runtime_local_1.WasmRuntimeProperty(local.type,local.name))})),runtimeFunctions.push(fn)}),this.stackTracer.functions=runtimeFunctions},WasmAssembler.prototype.startSection=function(id,name){var section=this.module.binary.getSection(id,name);return this.currentSection=section,this.activePayload=section.payload,this.activeCode=section.code,section},WasmAssembler.prototype.endSection=function(section){this.currentSection=null,this.activePayload=null,this.activeCode=null},WasmAssembler.prototype.startFunction=function(fn,index){this.currentFunction=fn,this.stackTracer.startFunction(this.module.importCount+index),this.activePayload=fn.body,this.activeCode=fn.code},WasmAssembler.prototype.endFunction=function(){this.activeCode.removeLastLinebreak(),this.stackTracer.endFunction(),this.currentSection.code.appendRaw(this.activeCode.finish()),this.activePayload=this.currentSection.payload,this.activeCode=this.currentSection.code},WasmAssembler.prototype.startFunctionChunk=function(fn,index){var chunk=new wasm_function_chunk_1.WasmFunctionChunk;return fn.chunks.push(chunk),this.prevPayload=this.activePayload,this.prevCode=this.activeCode,this.activePayload=chunk.payload,this.activeCode=chunk.code,this.stackTracer.startFunction(index),chunk},WasmAssembler.prototype.endFunctionChunk=function(){this.activePayload=this.prevPayload,this.activeCode=this.prevCode,this.stackTracer.endFunction(!0)},WasmAssembler.prototype.dropStack=function(max){if(void 0===max&&(max=1),this.stackTracer.context.stack.length>0){terminal_1.Terminal.warn("Dropping stack items, '"+this.stackTracer.context.fn.name+"' func stack contains "+this.stackTracer.context.stack.length+" items");for(var item=this.stackTracer.context.stack.pop(!0);void 0!==item&&max>0;)terminal_1.Terminal.warn(wasm_type_1.WasmType[item.type]),this.activePayload.append(opcode_1.WasmOpcode.DROP),this.activeCode.append("drop\n"),item=this.stackTracer.context.stack.pop(!0),max--}},WasmAssembler.prototype.append=function(offset,value,msg){void 0===offset&&(offset=0),void 0===value&&(value=null),void 0===msg&&(msg=null),this.activePayload.log+=(null!=value?utils_1.toHex(offset+this.activePayload.position)+": "+utils_1.toHex(value,2)+" ; ":"")+(null!=msg?msg+"\n":"\n"),value&&this.activePayload.append(value)},WasmAssembler.prototype.appendOpcode=function(offset,opcode,inline_value,skip){void 0===offset&&(offset=0),void 0===skip&&(skip=!1),logOpcode(this.activePayload,offset,opcode,inline_value),this.activePayload.append(opcode);var opcodeWithoutOperand=this.stackTracer.pushOpcode(opcode);if(null!==opcodeWithoutOperand&&!skip){var isEnd=opcode===opcode_1.WasmOpcode.END,indent=this.isBlock(opcode)?1:isEnd?-1:0;isEnd&&this.activeCode.clearIndent(1),this.activeCode.append(opcodeWithoutOperand+"\n",indent)}},WasmAssembler.prototype.isBlock=function(opcode){return opcode===opcode_1.WasmOpcode.BLOCK||opcode===opcode_1.WasmOpcode.LOOP||opcode===opcode_1.WasmOpcode.IF||opcode===opcode_1.WasmOpcode.IF_ELSE},WasmAssembler.prototype.writeUnsignedLEB128=function(value){this.activePayload.writeUnsignedLEB128(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.activeCode.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeLEB128=function(value){this.activePayload.writeLEB128(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.activeCode.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeFloat=function(value){this.activePayload.writeFloat(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.activeCode.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeDouble=function(value){this.activePayload.writeDouble(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.activeCode.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeWasmString=function(value){this.activePayload.writeWasmString(value)},WasmAssembler.prototype.mergeBinary=function(binary){this.module.binary.copySections(binary)},WasmAssembler.prototype.finish=function(){this.module.publish()},WasmAssembler}();exports.WasmAssembler=WasmAssembler,exports.logOpcode=logOpcode},function(module,exports,__webpack_require__){"use strict";function getBuiltinOpcode(name){switch(name){case"rotl":return opcode_1.WasmOpcode.I64_ROTL;case"rotl32":return opcode_1.WasmOpcode.I32_ROTL;case"rotr":return opcode_1.WasmOpcode.I64_ROTR;case"rotr32":return opcode_1.WasmOpcode.I32_ROTR;case"clz":return opcode_1.WasmOpcode.I64_CLZ;case"clz32":return opcode_1.WasmOpcode.I32_CLZ;case"ctz":return opcode_1.WasmOpcode.I64_CTZ;case"ctz32":return opcode_1.WasmOpcode.I32_CTZ;case"popcnt":return opcode_1.WasmOpcode.I64_POPCNT;case"popcnt32":return opcode_1.WasmOpcode.I32_POPCNT;case"abs":return opcode_1.WasmOpcode.F64_ABS;case"abs32":return opcode_1.WasmOpcode.F32_ABS;case"ceil":return opcode_1.WasmOpcode.F64_CEIL;case"ceil32":return opcode_1.WasmOpcode.F32_CEIL;case"floor":return opcode_1.WasmOpcode.F64_FLOOR;case"floor32":return opcode_1.WasmOpcode.F32_FLOOR;case"sqrt":return opcode_1.WasmOpcode.F64_SQRT;case"sqrt32":return opcode_1.WasmOpcode.F32_SQRT;case"trunc":return opcode_1.WasmOpcode.F64_TRUNC;case"trunc32":return opcode_1.WasmOpcode.F32_TRUNC;case"nearest":return opcode_1.WasmOpcode.F64_NEAREST;case"nearest32":return opcode_1.WasmOpcode.F32_NEAREST;case"min":return opcode_1.WasmOpcode.F64_MIN;case"min32":return opcode_1.WasmOpcode.F32_MIN;case"max":return opcode_1.WasmOpcode.F64_MAX;case"max32":return opcode_1.WasmOpcode.F32_MAX;case"copysign":return opcode_1.WasmOpcode.F64_COPYSIGN;case"copysign32":return opcode_1.WasmOpcode.F32_COPYSIGN;case"reinterpret_i32":return opcode_1.WasmOpcode.F32_REINTERPRET_I32;case"reinterpret_i64":return opcode_1.WasmOpcode.F64_REINTERPRET_I64;case"reinterpret_f32":return opcode_1.WasmOpcode.I32_REINTERPRET_F32;case"reinterpret_f64":return opcode_1.WasmOpcode.I64_REINTERPRET_F64;case"current_memory":return opcode_1.WasmOpcode.MEMORY_SIZE;case"grow_memory":return opcode_1.WasmOpcode.GROW_MEMORY;default:throw"No builtin function named '"+name+"'"}}function isBuiltin(name){return exports.builtins.indexOf(name)>-1}Object.defineProperty(exports,"__esModule",{value:!0});var opcode_1=__webpack_require__(12);exports.builtins=["rotl","rotl32","rotr","rotr32","clz","clz32","ctz","ctz32","popcnt","popcnt32","abs","abs32","ceil","ceil32","floor","floor32","sqrt","sqrt32","trunc","trunc32","nearest","nearest32","min","min32","max","max32","copysign","copysign32","reinterpret_i32","reinterpret_i64","reinterpret_f32","reinterpret_f64","current_memory","grow_memory"],exports.getBuiltinOpcode=getBuiltinOpcode,exports.isBuiltin=isBuiltin},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var bytearray_1=__webpack_require__(0),stringbuilder_1=__webpack_require__(21),WasmFunctionChunk=function(){function WasmFunctionChunk(payload,code){void 0===payload&&(payload=new bytearray_1.ByteArray),void 0===code&&(code=new stringbuilder_1.StringBuilder(2)),this.payload=payload,this.code=code,this.code.emitIndent(2)}return WasmFunctionChunk}();exports.WasmFunctionChunk=WasmFunctionChunk},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmLocal=function(){function WasmLocal(type,name,symbol,isArgument){void 0===isArgument&&(isArgument=!1),this.type=type,this.name=name,this.symbol=symbol,this.isArgument=isArgument}return WasmLocal}();exports.WasmLocal=WasmLocal},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmSharedOffset=function(){function WasmSharedOffset(){this.nextLocalOffset=0,this.localCount=0}return WasmSharedOffset}();exports.WasmSharedOffset=WasmSharedOffset},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var bytearray_1=__webpack_require__(0),WasmOptimizer=function(){function WasmOptimizer(){}return WasmOptimizer.optimize=function(inputWASM,level){switch(void 0===level&&(level=1),null===WasmOptimizer.instance&&(WasmOptimizer.instance=new WasmOptimizer),WasmOptimizer.instance.initialize(inputWASM),level){case 1:WasmOptimizer.instance.optimizeLevel_1();break;case 2:WasmOptimizer.instance.optimizeLevel_2();break;case 3:WasmOptimizer.instance.optimizeLevel_3()}},WasmOptimizer.prototype.initialize=function(inputWASM){this.inputWASM=inputWASM instanceof Uint8Array?new bytearray_1.ByteArray(inputWASM.buffer):inputWASM},WasmOptimizer.prototype.optimizeLevel_1=function(){},WasmOptimizer.prototype.optimizeLevel_2=function(){},WasmOptimizer.prototype.optimizeLevel_3=function(){},WasmOptimizer}();WasmOptimizer.instance=null,exports.WasmOptimizer=WasmOptimizer},function(module,exports,__webpack_require__){"use strict";function getOprandType(opcode){switch(opcode){case opcode_1.WasmOpcode.I32_CONST:case opcode_1.WasmOpcode.I32_ADD:case opcode_1.WasmOpcode.I32_MUL:case opcode_1.WasmOpcode.I32_SUB:case opcode_1.WasmOpcode.I32_DIV_S:case opcode_1.WasmOpcode.I32_DIV_U:case opcode_1.WasmOpcode.I32_REM_S:case opcode_1.WasmOpcode.I32_REM_U:case opcode_1.WasmOpcode.I32_GE_S:case opcode_1.WasmOpcode.I32_GE_U:case opcode_1.WasmOpcode.I32_LE_S:case opcode_1.WasmOpcode.I32_LE_U:case opcode_1.WasmOpcode.I32_GT_S:case opcode_1.WasmOpcode.I32_GT_U:case opcode_1.WasmOpcode.I32_LT_S:case opcode_1.WasmOpcode.I32_LT_U:case opcode_1.WasmOpcode.I32_EQ:case opcode_1.WasmOpcode.I32_NE:case opcode_1.WasmOpcode.I32_EQZ:case opcode_1.WasmOpcode.I32_AND:case opcode_1.WasmOpcode.I32_OR:case opcode_1.WasmOpcode.I32_XOR:case opcode_1.WasmOpcode.I32_CTZ:case opcode_1.WasmOpcode.I32_CLZ:case opcode_1.WasmOpcode.I32_ROTL:case opcode_1.WasmOpcode.I32_ROTR:case opcode_1.WasmOpcode.I32_SHL:case opcode_1.WasmOpcode.I32_SHR_S:case opcode_1.WasmOpcode.I32_SHR_U:case opcode_1.WasmOpcode.I32_POPCNT:case opcode_1.WasmOpcode.I32_LOAD:case opcode_1.WasmOpcode.I32_LOAD8_S:case opcode_1.WasmOpcode.I32_LOAD8_U:case opcode_1.WasmOpcode.I32_LOAD16_S:case opcode_1.WasmOpcode.I32_LOAD16_U:case opcode_1.WasmOpcode.I32_STORE16:case opcode_1.WasmOpcode.I32_STORE8:case opcode_1.WasmOpcode.I32_STORE:case opcode_1.WasmOpcode.I32_REINTERPRET_F32:case opcode_1.WasmOpcode.I32_TRUNC_S_F32:case opcode_1.WasmOpcode.I32_TRUNC_U_F32:case opcode_1.WasmOpcode.I32_TRUNC_S_F64:case opcode_1.WasmOpcode.I32_TRUNC_U_F64:case opcode_1.WasmOpcode.I32_WRAP_I64:return wasm_type_1.WasmType.I32;case opcode_1.WasmOpcode.I64_CONST:case opcode_1.WasmOpcode.I64_ADD:case opcode_1.WasmOpcode.I64_MUL:case opcode_1.WasmOpcode.I64_SUB:case opcode_1.WasmOpcode.I64_DIV_S:case opcode_1.WasmOpcode.I64_DIV_U:case opcode_1.WasmOpcode.I64_CLZ:case opcode_1.WasmOpcode.I64_ROTL:case opcode_1.WasmOpcode.I64_AND:case opcode_1.WasmOpcode.I64_CTZ:case opcode_1.WasmOpcode.I64_EQ:case opcode_1.WasmOpcode.I64_EQZ:case opcode_1.WasmOpcode.I64_GE_S:case opcode_1.WasmOpcode.I64_GE_U:case opcode_1.WasmOpcode.I64_LE_S:case opcode_1.WasmOpcode.I64_LE_U:case opcode_1.WasmOpcode.I64_GT_S:case opcode_1.WasmOpcode.I64_GT_U:case opcode_1.WasmOpcode.I64_LT_S:case opcode_1.WasmOpcode.I64_LT_U:case opcode_1.WasmOpcode.I64_LOAD:case opcode_1.WasmOpcode.I64_LOAD8_S:case opcode_1.WasmOpcode.I64_LOAD8_U:case opcode_1.WasmOpcode.I64_LOAD16_S:case opcode_1.WasmOpcode.I64_LOAD16_U:case opcode_1.WasmOpcode.I64_NE:case opcode_1.WasmOpcode.I64_XOR:case opcode_1.WasmOpcode.I64_STORE16:case opcode_1.WasmOpcode.I64_STORE8:case opcode_1.WasmOpcode.I64_STORE:case opcode_1.WasmOpcode.I64_SHR_S:case opcode_1.WasmOpcode.I64_SHR_U:case opcode_1.WasmOpcode.I64_SHL:case opcode_1.WasmOpcode.I64_ROTR:case opcode_1.WasmOpcode.I64_REM_S:case opcode_1.WasmOpcode.I64_REM_U:case opcode_1.WasmOpcode.I64_POPCNT:case opcode_1.WasmOpcode.I64_OR:case opcode_1.WasmOpcode.I64_REINTERPRET_F64:case opcode_1.WasmOpcode.I64_TRUNC_S_F32:case opcode_1.WasmOpcode.I64_TRUNC_U_F32:case opcode_1.WasmOpcode.I64_TRUNC_S_F64:case opcode_1.WasmOpcode.I64_TRUNC_U_F64:case opcode_1.WasmOpcode.I64_EXTEND_S_I32:case opcode_1.WasmOpcode.I64_EXTEND_U_I32:return wasm_type_1.WasmType.I64;case opcode_1.WasmOpcode.F32_CONST:case opcode_1.WasmOpcode.F32_ADD:case opcode_1.WasmOpcode.F32_SUB:case opcode_1.WasmOpcode.F32_MUL:case opcode_1.WasmOpcode.F32_DIV:case opcode_1.WasmOpcode.F32_SQRT:case opcode_1.WasmOpcode.F32_NEG:case opcode_1.WasmOpcode.F32_NE:case opcode_1.WasmOpcode.F32_ABS:case opcode_1.WasmOpcode.F32_CEIL:case opcode_1.WasmOpcode.F32_EQ:case opcode_1.WasmOpcode.F32_FLOOR:case opcode_1.WasmOpcode.F32_NEAREST:case opcode_1.WasmOpcode.F32_MIN:case opcode_1.WasmOpcode.F32_MAX:case opcode_1.WasmOpcode.F32_GE:case opcode_1.WasmOpcode.F32_GT:case opcode_1.WasmOpcode.F32_LT:case opcode_1.WasmOpcode.F32_LE:case opcode_1.WasmOpcode.F32_COPYSIGN:case opcode_1.WasmOpcode.F32_LOAD:case opcode_1.WasmOpcode.F32_STORE:case opcode_1.WasmOpcode.F32_TRUNC:case opcode_1.WasmOpcode.F32_DEMOTE_F64:case opcode_1.WasmOpcode.F32_CONVERT_S_I32:case opcode_1.WasmOpcode.F32_CONVERT_U_I32:case opcode_1.WasmOpcode.F32_CONVERT_S_I64:case opcode_1.WasmOpcode.F32_CONVERT_U_I64:case opcode_1.WasmOpcode.F32_REINTERPRET_I32:return wasm_type_1.WasmType.F32;case opcode_1.WasmOpcode.F64_CONST:case opcode_1.WasmOpcode.F64_ADD:case opcode_1.WasmOpcode.F64_SUB:case opcode_1.WasmOpcode.F64_MUL:case opcode_1.WasmOpcode.F64_DIV:case opcode_1.WasmOpcode.F64_SQRT:case opcode_1.WasmOpcode.F64_NEG:case opcode_1.WasmOpcode.F64_NE:case opcode_1.WasmOpcode.F64_ABS:case opcode_1.WasmOpcode.F64_CEIL:case opcode_1.WasmOpcode.F64_EQ:case opcode_1.WasmOpcode.F64_FLOOR:case opcode_1.WasmOpcode.F64_NEAREST:case opcode_1.WasmOpcode.F64_MIN:case opcode_1.WasmOpcode.F64_MAX:case opcode_1.WasmOpcode.F64_GE:case opcode_1.WasmOpcode.F64_GT:case opcode_1.WasmOpcode.F64_LT:case opcode_1.WasmOpcode.F64_LE:case opcode_1.WasmOpcode.F64_COPYSIGN:case opcode_1.WasmOpcode.F64_LOAD:case opcode_1.WasmOpcode.F64_STORE:case opcode_1.WasmOpcode.F64_TRUNC:case opcode_1.WasmOpcode.F64_PROMOTE_F32:case opcode_1.WasmOpcode.F64_CONVERT_S_I32:case opcode_1.WasmOpcode.F64_CONVERT_U_I32:case opcode_1.WasmOpcode.F64_CONVERT_S_I64:case opcode_1.WasmOpcode.F64_CONVERT_U_I64:case opcode_1.WasmOpcode.F64_REINTERPRET_I64:return wasm_type_1.WasmType.F64;case opcode_1.WasmOpcode.CALL:case opcode_1.WasmOpcode.END:case opcode_1.WasmOpcode.RETURN:case opcode_1.WasmOpcode.GET_GLOBAL:case opcode_1.WasmOpcode.GET_LOCAL:case opcode_1.WasmOpcode.SET_LOCAL:case opcode_1.WasmOpcode.SET_GLOBAL:case opcode_1.WasmOpcode.BLOCK:case opcode_1.WasmOpcode.LOOP:case opcode_1.WasmOpcode.IF:case opcode_1.WasmOpcode.IF_ELSE:case opcode_1.WasmOpcode.BR:case opcode_1.WasmOpcode.BR_IF:case opcode_1.WasmOpcode.BR_TABLE:case opcode_1.WasmOpcode.NOP:return null;default:terminal_1.Terminal.warn("Unhandled Opcode "+opcode+" => "+opcode_1.WasmOpcode[opcode])}return null}Object.defineProperty(exports,"__esModule",{value:!0});var wasm_type_1=__webpack_require__(6),opcode_1=__webpack_require__(12),wasm_runtime_local_1=__webpack_require__(28),bytearray_1=__webpack_require__(0),terminal_1=__webpack_require__(2),WasmStackItem=function(){function WasmStackItem(type,value){this.type=type,this.value=value}return WasmStackItem}();exports.WasmStackItem=WasmStackItem;var WasmStack=function(){function WasmStack(){this.list=[]}return Object.defineProperty(WasmStack.prototype,"length",{get:function(){return this.list.length},enumerable:!0,configurable:!0}),WasmStack.prototype.push=function(item){this.list.push(item)},WasmStack.prototype.pop=function(silent){if(void 0===silent&&(silent=!1),0===this.list.length&&!silent){terminal_1.Terminal.warn("Stack is empty")}return this.list.pop()},WasmStack.prototype.clear=function(){this.list=[]},WasmStack}();exports.WasmStack=WasmStack;var WasmRuntimeFunction=function(){function WasmRuntimeFunction(){}return Object.defineProperty(WasmRuntimeFunction.prototype,"returnType",{get:function(){return this.signature.returnType},enumerable:!0,configurable:!0}),WasmRuntimeFunction.prototype.execute=function(){for(var param=[],_i=0;_i0&&this.context.fn.returnType===wasm_type_1.WasmType.VOID){var error="Function '"+this.context.fn.name+"' does not return anything but stack is not empty. Stack contains "+this.context.stack.length+" items";terminal_1.Terminal.error(error)}this.context=null},WasmStackTracer.prototype.callFunction=function(index){var fn=this.functions[index];if(void 0===fn){var error="Function not defined at index "+index;throw terminal_1.Terminal.error(error),error}for(var returnType=fn.returnType,i=0;ib.value?1:0)),opcode_1.WasmOpcode[opcode];case opcode_1.WasmOpcode.I32_GE_S:case opcode_1.WasmOpcode.I32_GE_U:case opcode_1.WasmOpcode.I64_GE_S:case opcode_1.WasmOpcode.I64_GE_U:case opcode_1.WasmOpcode.F32_GE:case opcode_1.WasmOpcode.F64_GE:var a=this.context.stack.pop(),b=this.context.stack.pop();return this.context.stack.push(new WasmStackItem(type,a.value>=b.value?1:0)),opcode_1.WasmOpcode[opcode];case opcode_1.WasmOpcode.I32_LT_S:case opcode_1.WasmOpcode.I32_LT_U:case opcode_1.WasmOpcode.I64_LT_S:case opcode_1.WasmOpcode.I64_LT_U:case opcode_1.WasmOpcode.F32_LT:case opcode_1.WasmOpcode.F64_LT:var a=this.context.stack.pop(),b=this.context.stack.pop();return this.context.stack.push(new WasmStackItem(type,a.value "+opcode_1.WasmOpcode[opcode])}return null},WasmStackTracer}();exports.WasmStackTracer=WasmStackTracer},function(module,exports,__webpack_require__){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])};return function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wasm_binary_section_1=__webpack_require__(4),wasm_section_1=__webpack_require__(1),bytearray_1=__webpack_require__(0),wasm_function_1=__webpack_require__(16),CodeSection=function(_super){function CodeSection(payload){return void 0===payload&&(payload=new bytearray_1.ByteArray),_super.call(this,wasm_section_1.WasmSection.Code,payload.length,null,null,payload)||this}return __extends(CodeSection,_super),CodeSection.prototype.read=function(){void 0!==this.functions&&null!==this.functions||(this.functions=[]);for(var length=this.payload.readU32LEB(),i=0;i0?this.payload.readU32LEB():wasm_type_1.WasmType.VOID,this.signatures.push(signature)}},SignatureSection.prototype.publish=function(data){_super.prototype.publish.call(this,data)},SignatureSection}(wasm_binary_section_1.WasmSectionBinary);exports.SignatureSection=SignatureSection},function(module,exports,__webpack_require__){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])};return function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wasm_binary_section_1=__webpack_require__(4),wasm_section_1=__webpack_require__(1),bytearray_1=__webpack_require__(0),StartSection=function(_super){function StartSection(payload){void 0===payload&&(payload=new bytearray_1.ByteArray);var _this=_super.call(this,wasm_section_1.WasmSection.Start,payload.length,null,null,payload)||this;return _this.startFunctionIndex=-1,_this}return __extends(StartSection,_super),StartSection.prototype.read=function(){this.startFunctionIndex=this.payload.readU32LEB()},StartSection.prototype.publish=function(data){_super.prototype.publish.call(this,data)},StartSection}(wasm_binary_section_1.WasmSectionBinary);exports.StartSection=StartSection},function(module,exports,__webpack_require__){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])};return function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wasm_binary_section_1=__webpack_require__(4),wasm_section_1=__webpack_require__(1),bytearray_1=__webpack_require__(0),TableSection=function(_super){function TableSection(payload){void 0===payload&&(payload=new bytearray_1.ByteArray);var _this=_super.call(this,wasm_section_1.WasmSection.Table,payload.length,null,null,payload)||this;return _this.tables=[],_this}return __extends(TableSection,_super),TableSection.prototype.read=function(){},TableSection.prototype.publish=function(data){_super.prototype.publish.call(this,data)},TableSection}(wasm_binary_section_1.WasmSectionBinary);exports.TableSection=TableSection},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var wasm_binary_1=__webpack_require__(17),wasm_function_1=__webpack_require__(16),wasm_import_1=__webpack_require__(25),wasm_signature_1=__webpack_require__(26),wasm_global_1=__webpack_require__(24),index_1=__webpack_require__(13),assert_1=__webpack_require__(3),wasm_section_1=__webpack_require__(1),wasm_export_1=__webpack_require__(23),wasm_external_kind_1=__webpack_require__(11),WasmModule=function(){function WasmModule(binary){this.text=";; Experimental wast emitter\n(module\n",void 0!==binary?this.read(binary):(this.binary=new wasm_binary_1.WasmBinary,this.binary.initializeSections(),this.getReferences())}return Object.defineProperty(WasmModule.prototype,"imports",{get:function(){return this.importSection.imports},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"importCount",{get:function(){return this.imports.length},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"exports",{get:function(){return this.exportSection.exports},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"exportCount",{get:function(){return this.exports.length},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"globals",{get:function(){return this.globalSection.globals},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"globalCount",{get:function(){return this.globals.length},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"signatures",{get:function(){return this.signatureSection.signatures},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"signatureCount",{get:function(){return this.signatures.length},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"functions",{get:function(){return this.functionSection.functions},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"functionCount",{get:function(){return this.functions.length},enumerable:!0,configurable:!0}),WasmModule.prototype.getReferences=function(){this.importSection=this.binary.getSection(wasm_section_1.WasmSection.Import),this.exportSection=this.binary.getSection(wasm_section_1.WasmSection.Export),this.globalSection=this.binary.getSection(wasm_section_1.WasmSection.Global),this.signatureSection=this.binary.getSection(wasm_section_1.WasmSection.Signature),this.functionSection=this.binary.getSection(wasm_section_1.WasmSection.Function)},WasmModule.prototype.reset=function(){this.binary.reset()},WasmModule.prototype.read=function(binary){binary instanceof wasm_binary_1.WasmBinary?this.binary=binary:this.binary=new wasm_binary_1.WasmBinary(binary),this.getReferences()},WasmModule.prototype.publish=function(){var _this=this;this.text+=" ",this.binary.sections.forEach(function(section){section.payload.length>0&&(section.publish(_this.binary.data),_this.text+=section.code.finish())}),this.text=this.text.substring(0,this.text.lastIndexOf("\n")),this.text+=")\n"},WasmModule.prototype.allocateGlobal=function(symbol,bitness){var global=new wasm_global_1.WasmGlobal(index_1.symbolToWasmType(symbol,bitness),!0,symbol.internalName,symbol);return symbol.offset=this.globals.length,this.globals.push(global),global},WasmModule.prototype.allocateSignature=function(argumentTypes,returnType){assert_1.assert(null!=returnType);var signature=new wasm_signature_1.WasmSignature;signature.argumentTypes=argumentTypes,signature.returnType=returnType;var signatureIndex=-1;return this.signatures.some(function(check,index){return!!wasm_signature_1.wasmAreSignaturesEqual(signature,check)&&(signatureIndex=index,!0)}),signatureIndex>-1?[signatureIndex,this.signatures[signatureIndex]]:[this.signatures.push(signature)-1,signature]},WasmModule.prototype.allocateImport=function(signature,signatureIndex,namespace,name){var _import=new wasm_import_1.WasmImport(namespace,name,wasm_external_kind_1.WasmExternalKind.Function,signatureIndex,signature);return[_import,this.imports.push(_import)-1]},WasmModule.prototype.allocateFunction=function(name,signature,signatureIndex,symbol,isExported){void 0===isExported&&(isExported=!1);var _function=new wasm_function_1.WasmFunction(name,symbol),fnIndex=this.functions.push(_function)-1;return _function.isExported=isExported,isExported&&this.exports.push(new wasm_export_1.WasmExport(_function.name,wasm_external_kind_1.WasmExternalKind.Function,fnIndex)),_function.signature=signature,_function.signatureIndex=signatureIndex,_function},WasmModule}();exports.WasmModule=WasmModule},function(module,exports,__webpack_require__){"use strict";function wasmAssignLocalVariableOffsets(fn,node,shared,bitness){if(node.kind==node_1.NodeKind.VARIABLE){assert_1.assert(node.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL),shared.nextLocalOffset=shared.nextLocalOffset+1,shared.localCount=shared.localCount+1;var local=new wasm_local_1.WasmLocal(utils_2.symbolToWasmType(node.symbol,bitness),node.symbol.internalName,node.symbol,!1);node.symbol.offset=fn.argumentVariables.length+fn.localVariables.length,fn.localVariables.push(new wasm_local_1.WasmLocal(local.type,local.symbol.name))}for(var child=node.firstChild;null!=child;)wasmAssignLocalVariableOffsets(fn,child,shared,bitness),child=child.nextSibling}function wasmEmit(compiler,bitness,optimize){void 0===bitness&&(bitness=bitness_1.Bitness.x32),void 0===optimize&&(optimize=!0);var wasmEmitter=new WasmModuleEmitter(bitness);wasmEmitter.context=compiler.context,wasmEmitter.memoryInitializer=new bytearray_1.ByteArray,wasmEmitter.startFunctionIndex=-1,wasmEmitter.mallocFunctionIndex=-1,wasmEmitter.freeFunctionIndex=-1,wasmEmitter.currentHeapPointer=-1,wasmEmitter.originalHeapPointer=-1,wasmEmitter.prepareToEmit(compiler.global),wasmEmitter.assembler.sealFunctions(),compiler.outputWASM=wasmEmitter.assembler.module.binary.data,wasmEmitter.emitModule(),optimize&&wasm_optimizer_1.WasmOptimizer.optimize(compiler.outputWASM),compiler.outputWAST=wasmEmitter.assembler.module.text}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(7),bytearray_1=__webpack_require__(0),utils_1=__webpack_require__(8),node_1=__webpack_require__(10),opcode_1=__webpack_require__(12),builtins_helper_1=__webpack_require__(47),assert_1=__webpack_require__(3),wasm_type_1=__webpack_require__(6),logger_1=__webpack_require__(27),bitness_1=__webpack_require__(22),wasm_section_1=__webpack_require__(1),wasm_external_kind_1=__webpack_require__(11),wasm_local_1=__webpack_require__(49),wasm_shared_offset_1=__webpack_require__(50),wasm_assembler_1=__webpack_require__(46),terminal_1=__webpack_require__(2),utils_2=__webpack_require__(13),wasm_optimizer_1=__webpack_require__(51),wasm_binary_1=__webpack_require__(17),binary_importer_1=__webpack_require__(33),WasmModuleEmitter=function(){function WasmModuleEmitter(bitness){this.bitness=bitness,this.assembler=new wasm_assembler_1.WasmAssembler}return WasmModuleEmitter.prototype.growMemoryInitializer=function(){for(var array=this.memoryInitializer,current=array.length,length=this.context.nextGlobalVariableOffset;current0&&_this.assembler.activeCode.append(" (param"),signature.argumentTypes.forEach(function(type){logger_1.log(section.payload,0,type,wasm_type_1.WasmType[type]),_this.assembler.writeUnsignedLEB128(type),_this.assembler.activeCode.append(" "+wasm_type_1.WasmTypeToString[type])}),signature.argumentTypes.length>0&&_this.assembler.activeCode.append(")"),signature.returnType!==wasm_type_1.WasmType.VOID?(logger_1.log(section.payload,0,1,"num results"),_this.assembler.writeUnsignedLEB128(1),logger_1.log(section.payload,0,signature.returnType,wasm_type_1.WasmType[signature.returnType]),_this.assembler.writeUnsignedLEB128(signature.returnType),_this.assembler.activeCode.append(" (result "+wasm_type_1.WasmTypeToString[signature.returnType]+")")):_this.assembler.writeUnsignedLEB128(0),_this.assembler.activeCode.append("))\n")}),this.assembler.endSection(section)},WasmModuleEmitter.prototype.emitImportTable=function(){var _this=this;if(0!=this.assembler.module.importCount){var section=this.assembler.startSection(wasm_section_1.WasmSection.Import),imports=section.imports;logger_1.log(section.payload,0,imports.length,"num imports"),this.assembler.writeUnsignedLEB128(imports.length),imports.forEach(function(_import,index){logger_1.log(section.payload,0,null,"import func ("+index+") "+_import.namespace+" "+_import.name),_this.assembler.activeCode.append('(import "'+_import.namespace+'" "'+_import.name+'" (func (;'+index+";) (type "+_import.signatureIndex+")))\n"),_this.assembler.writeWasmString(_import.namespace),_this.assembler.writeWasmString(_import.name),_this.assembler.writeUnsignedLEB128(wasm_external_kind_1.WasmExternalKind.Function),_this.assembler.writeUnsignedLEB128(_import.signatureIndex)}),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.emitFunctionDeclarations=function(){var _this=this;if(0!==this.assembler.module.functionCount){var section=this.assembler.startSection(wasm_section_1.WasmSection.Function),functions=section.functions;logger_1.log(section.payload,0,functions.length,"num functions"),this.assembler.writeUnsignedLEB128(functions.length);var importCount=this.assembler.module.importCount;functions.forEach(function(fn,index){logger_1.log(section.payload,0,fn.signatureIndex,"func "+(importCount+index)+" sig "+utils_2.getWasmFunctionName(fn.symbol)),_this.assembler.writeUnsignedLEB128(fn.signatureIndex)}),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.emitTables=function(){},WasmModuleEmitter.prototype.emitMemory=function(){var section=this.assembler.startSection(wasm_section_1.WasmSection.Memory),memory=section.memory;memory.length>1&&terminal_1.Terminal.warn("More than 1 memory found, In the MVP, the number of memories must be no more than 1.");logger_1.log(section.payload,0,memory.length,"num memories"),this.assembler.writeUnsignedLEB128(1),logger_1.log(section.payload,0,0,"memory flags"),this.assembler.writeUnsignedLEB128(wasm_binary_1.WasmBinary.SET_MAX_MEMORY?1:0),logger_1.log(section.payload,0,wasm_binary_1.WasmBinary.SIZE_IN_PAGES,"memory initial pages"),this.assembler.writeUnsignedLEB128(wasm_binary_1.WasmBinary.SIZE_IN_PAGES),wasm_binary_1.WasmBinary.SET_MAX_MEMORY&&(logger_1.log(section.payload,0,wasm_binary_1.WasmBinary.MAX_MEMORY,"maximum memory"),this.assembler.writeUnsignedLEB128(wasm_binary_1.WasmBinary.MAX_MEMORY)),this.assembler.activeCode.append("(memory (;0;) 1)\n"),this.assembler.endSection(section)},WasmModuleEmitter.prototype.emitGlobalDeclarations=function(){var _this=this;if(0!==this.assembler.module.globalCount){var section=this.assembler.startSection(wasm_section_1.WasmSection.Global),globals=section.globals;this.assembler.writeUnsignedLEB128(globals.length),this.assembler.stackTracer.setGlobals(globals),globals.forEach(function(global,index){var wasmType=utils_2.symbolToWasmType(global.symbol,_this.bitness),value=global.symbol.node.variableValue();section.payload.append(wasmType),_this.assembler.writeUnsignedLEB128(global.mutable?1:0);var rawValue=0;switch(value&&(value.kind===node_1.NodeKind.NULL||value.kind===node_1.NodeKind.UNDEFINED?rawValue=0:void 0!==value.rawValue?rawValue=value.rawValue:_this.addGlobalToStartFunction(global)),_this.assembler.appendOpcode(0,opcode_1.WasmOpcode[wasm_type_1.WasmType[wasmType]+"_CONST"],rawValue),wasmType){case wasm_type_1.WasmType.I32:case wasm_type_1.WasmType.I64:_this.assembler.writeUnsignedLEB128(rawValue);break;case wasm_type_1.WasmType.F32:_this.assembler.writeFloat(rawValue);break;case wasm_type_1.WasmType.F64:_this.assembler.writeDouble(rawValue)}var wasmTypeStr=wasm_type_1.WasmTypeToString[wasmType];_this.assembler.activeCode.append("(global (;"+index+";) (mut "+wasmTypeStr+") ("+wasmTypeStr+".const "+rawValue+"))\n"),_this.assembler.appendOpcode(0,opcode_1.WasmOpcode.END)}),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.addGlobalToStartFunction=function(global){var value=global.symbol.node.variableValue();this.assembler.startFunctionChunk(this.startFunction,this.startFunctionIndex),this.emitNode(0,value),this.assembler.appendOpcode(0,opcode_1.WasmOpcode.SET_GLOBAL),this.assembler.writeUnsignedLEB128(global.symbol.offset),this.assembler.endFunctionChunk()},WasmModuleEmitter.prototype.emitExportTable=function(){var _this=this;if(0!==this.assembler.module.exportCount){var section=this.assembler.startSection(wasm_section_1.WasmSection.Export),importCount=this.assembler.module.importCount,exports=section.exports;logger_1.log(section.payload,0,exports.length,"num exports"),this.assembler.writeUnsignedLEB128(exports.length+1);logger_1.log(section.payload,0,"memory".length,"export name length"),logger_1.log(section.payload,null,null,utils_1.toHex(section.payload.position+0+4)+": memory // export name"),this.assembler.writeWasmString("memory"),logger_1.log(section.payload,0,wasm_external_kind_1.WasmExternalKind.Memory,"export kind"),this.assembler.activePayload.writeUnsignedByte(wasm_external_kind_1.WasmExternalKind.Memory),logger_1.log(section.payload,0,0,"export memory index"),this.assembler.writeUnsignedLEB128(0),this.assembler.activeCode.append('(export "memory" (memory 0))\n'),exports.forEach(function(_export){var fnIndex=importCount+_export.index;logger_1.log(section.payload,0,_export.as.length,"export name length"),logger_1.log(section.payload,null,null,utils_1.toHex(section.payload.position+0+4)+": "+_export.as+" // export name"),_this.assembler.writeWasmString(_export.as),logger_1.log(section.payload,0,wasm_external_kind_1.WasmExternalKind.Function,"export kind"),_this.assembler.writeUnsignedLEB128(wasm_external_kind_1.WasmExternalKind.Function),logger_1.log(section.payload,0,fnIndex,"export func index"),_this.assembler.writeUnsignedLEB128(fnIndex),_this.assembler.activeCode.append('(export "'+_export.as+'" (func $'+_export.name+"))\n")}),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.emitStart=function(){if(-1!=this.startFunctionIndex){var section=this.assembler.startSection(wasm_section_1.WasmSection.Start),importCount=this.assembler.module.importCount;logger_1.log(section.payload,0,this.startFunctionIndex,"start function index"),this.assembler.activeCode.append("(start "+(importCount+this.startFunctionIndex)+")\n"),this.assembler.writeUnsignedLEB128(importCount+this.startFunctionIndex),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.emitElements=function(){},WasmModuleEmitter.prototype.emitFunctionBodies=function(){var _this=this;if(0!==this.assembler.module.functionCount){var signatures=this.assembler.module.binary.getSection(wasm_section_1.WasmSection.Signature).signatures,functions=this.assembler.module.binary.getSection(wasm_section_1.WasmSection.Function).functions,section=this.assembler.startSection(wasm_section_1.WasmSection.Code);section.functions=functions,logger_1.log(section.payload,0,this.assembler.module.functionCount,"num functions"),this.assembler.writeUnsignedLEB128(this.assembler.module.functionCount),functions.forEach(function(fn,index){_this.currentFunction=fn;var sectionOffset=0+section.payload.position,wasmFunctionName=utils_2.getWasmFunctionName(fn.symbol);if(!fn.isExternal){var bodyData_1=new bytearray_1.ByteArray;fn.body=bodyData_1,logger_1.log(bodyData_1,sectionOffset,fn.locals.length,"local var count"),_this.assembler.startFunction(fn,index),_this.assembler.activeCode.emitIndent(),_this.assembler.activeCode.append("(func $"+wasmFunctionName+" (type "+fn.signatureIndex+") "),fn.argumentVariables.forEach(function(argumentEntry){_this.assembler.activeCode.append("(param $"+argumentEntry.name+" "+wasm_type_1.WasmTypeToString[argumentEntry.type]+") ")});var signature=signatures[fn.signatureIndex];signature.returnType!==wasm_type_1.WasmType.VOID&&_this.assembler.activeCode.append("(result "+wasm_type_1.WasmTypeToString[signature.returnType]+")"),_this.assembler.activeCode.append("\n",2),fn.localVariables.length>0?(bodyData_1.writeUnsignedLEB128(fn.localVariables.length),fn.localVariables.forEach(function(localVariableEntry){logger_1.log(bodyData_1,sectionOffset,1,"local index"),bodyData_1.writeUnsignedLEB128(1),logger_1.log(bodyData_1,sectionOffset,localVariableEntry.type,wasm_type_1.WasmType[localVariableEntry.type]),bodyData_1.append(localVariableEntry.type),_this.assembler.activeCode.append("(local $"+localVariableEntry.name+" "+wasm_type_1.WasmTypeToString[localVariableEntry.type]+") ")}),_this.assembler.activeCode.append("\n")):bodyData_1.writeUnsignedLEB128(0);var lastChild=void 0;fn.isConstructor&&_this.emitConstructor(sectionOffset,fn);for(var child=fn.symbol.node.functionBody().firstChild;null!=child;)lastChild=child,_this.emitNode(sectionOffset,child),child=child.nextSibling;fn.chunks.length>0?(_this.assembler.activeCode.clearIndent(2),fn.chunks.forEach(function(chunk,index){bodyData_1.copy(chunk.payload),bodyData_1.log+=chunk.payload.log,chunk.code.removeLastLinebreak(),_this.assembler.activeCode.appendRaw(chunk.code.finish())})):lastChild&&lastChild.kind!==node_1.NodeKind.RETURN&&fn.returnType!=wasm_type_1.WasmType.VOID&&_this.assembler.appendOpcode(sectionOffset,opcode_1.WasmOpcode.RETURN),fn.returnType===wasm_type_1.WasmType.VOID&&_this.assembler.dropStack(),_this.assembler.appendOpcode(sectionOffset,opcode_1.WasmOpcode.END,null,!0),_this.assembler.endFunction(),_this.assembler.activeCode.removeLastLinebreak(),_this.assembler.activeCode.append(")\n")}section.payload.writeUnsignedLEB128(fn.body.length),logger_1.log(section.payload,0,null," - func body "+(_this.assembler.module.importCount+index)+" ("+wasmFunctionName+")"),logger_1.log(section.payload,0,fn.body.length,"func body size"),section.payload.log+=fn.body.log,section.payload.copy(fn.body)}),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.emitDataSegments=function(){this.growMemoryInitializer();var memoryInitializer=this.memoryInitializer,initializerLength=memoryInitializer.length,initialHeapPointer=utils_1.alignToNextMultipleOf(wasm_binary_1.WasmBinary.MEMORY_INITIALIZER_BASE+initializerLength,8);memoryInitializer.writeUnsignedInt(initialHeapPointer,this.originalHeapPointer),memoryInitializer.writeUnsignedInt(initialHeapPointer,this.currentHeapPointer);var section=this.assembler.startSection(wasm_section_1.WasmSection.Data);logger_1.log(section.payload,0,1,"num data segments"),this.assembler.writeUnsignedLEB128(1),logger_1.log(section.payload,0,null," - data segment header 0"),logger_1.log(section.payload,0,0,"memory index"),this.assembler.writeUnsignedLEB128(0),this.assembler.appendOpcode(0,opcode_1.WasmOpcode.I32_CONST),logger_1.log(section.payload,0,wasm_binary_1.WasmBinary.MEMORY_INITIALIZER_BASE,"i32 literal"),this.assembler.writeUnsignedLEB128(wasm_binary_1.WasmBinary.MEMORY_INITIALIZER_BASE),this.assembler.appendOpcode(0,opcode_1.WasmOpcode.END),logger_1.log(section.payload,0,initializerLength,"data segment size"),this.assembler.writeUnsignedLEB128(initializerLength),logger_1.log(section.payload,0,null," - data segment data 0"),this.assembler.activeCode.append("(data (i32.const "+wasm_binary_1.WasmBinary.MEMORY_INITIALIZER_BASE+') " ');for(var value,i=0;i0);var lengthNode=node.arrayLength();if(lengthNode.kind==node_1.NodeKind.INT32){var length=size*lengthNode.intValue;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,length),this.assembler.writeLEB128(length)}else this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(size),this.emitNode(byteOffset,lengthNode),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_MUL);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(size);var callIndex=this.getWasmFunctionCallIndex(callSymbol);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.CALL),logger_1.log(this.assembler.activePayload,byteOffset,callIndex,"call func index ("+callIndex+")"),this.assembler.writeUnsignedLEB128(callIndex)}else if(type.resolvedType.isTypedArray());else{for(var child=node.firstChild.nextSibling;null!=child;)this.emitNode(byteOffset,child),child=child.nextSibling;var callIndex=this.getWasmFunctionCallIndex(callSymbol);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.CALL,callIndex),this.assembler.writeUnsignedLEB128(callIndex)}},WasmModuleEmitter.prototype.emitConstructor=function(byteOffset,fn){var constructorNode=fn.symbol.node,type=constructorNode.parent.symbol,size=type.resolvedType.allocationSizeOf(this.context);if(assert_1.assert(size>0),type.resolvedType.isArray())this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.GET_LOCAL,0),this.assembler.writeUnsignedLEB128(0),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(size),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_ADD);else if(type.resolvedType.isTypedArray()){var elementSize=utils_2.getTypedArrayElementSize(type.resolvedType.symbol.name);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.GET_LOCAL,0),this.assembler.writeUnsignedLEB128(0),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,elementSize),this.assembler.writeLEB128(elementSize),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_SHL),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(size),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_ADD)}else this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(size);var mallocIndex=this.calculateWasmFunctionIndex(this.mallocFunctionIndex);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.CALL,mallocIndex),this.assembler.writeUnsignedLEB128(mallocIndex),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,fn.signature.argumentTypes.length),this.assembler.writeUnsignedLEB128(fn.signature.argumentTypes.length)},WasmModuleEmitter.prototype.emitNode=function(byteOffset,node){if(assert_1.assert(!node_1.isExpression(node)||null!=node.resolvedType),node.kind==node_1.NodeKind.BLOCK){var skipBlock=node.parent.kind===node_1.NodeKind.IF;skipBlock||(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.BLOCK),void 0!==node.returnNode?(this.assembler.append(byteOffset,this.currentFunction.returnType),this.assembler.activeCode.removeLastLinebreak(),this.assembler.activeCode.append(" (result "+wasm_type_1.WasmTypeToString[this.currentFunction.returnType]+")\n",1)):this.assembler.append(byteOffset,wasm_type_1.WasmType.block_type));for(var child=node.firstChild;null!=child;)this.emitNode(byteOffset,child),child=child.nextSibling;skipBlock||(this.assembler.activeCode.clearIndent(1),this.assembler.activeCode.indent-=1,this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.END))}else if(node.kind==node_1.NodeKind.WHILE){var value=node.whileValue(),body=node.whileBody();if(value.kind==node_1.NodeKind.BOOLEAN&&0==value.intValue)return 0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.BLOCK),this.assembler.append(byteOffset,wasm_type_1.WasmType.block_type),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.LOOP),this.assembler.append(byteOffset,wasm_type_1.WasmType.block_type),value.kind!=node_1.NodeKind.BOOLEAN&&(this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_EQZ),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.BR_IF),this.assembler.writeUnsignedLEB128(1));for(var child=body.firstChild;null!=child;)this.emitNode(byteOffset,child),child=child.nextSibling;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.BR),this.assembler.writeUnsignedLEB128(0),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.END),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.BREAK||node.kind==node_1.NodeKind.CONTINUE){for(var label=0,parent=node.parent;null!=parent&&parent.kind!=node_1.NodeKind.WHILE;)parent.kind==node_1.NodeKind.BLOCK&&(label+=1),parent=parent.parent;assert_1.assert(label>0),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.BR),this.assembler.writeUnsignedLEB128(label-(node.kind==node_1.NodeKind.BREAK?0:1))}else{if(node.kind==node_1.NodeKind.EMPTY)return 0;if(node.kind==node_1.NodeKind.EXPRESSION)this.emitNode(byteOffset,node.expressionValue());else if(node.kind==node_1.NodeKind.RETURN){var value=node.returnValue();null!=value&&this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.RETURN)}else{if(node.kind==node_1.NodeKind.VARIABLES){for(var count=0,child=node.firstChild;null!=child;)assert_1.assert(child.kind==node_1.NodeKind.VARIABLE),count+=this.emitNode(byteOffset,child),child=child.nextSibling;return count}if(node.kind==node_1.NodeKind.IF){var branch=node.ifFalse();this.emitNode(byteOffset,node.ifValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.IF);var returnNode=node.ifReturnNode(),needEmptyElse=!1;if(null==returnNode&&null===branch)this.assembler.append(0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]);else if(null!==returnNode){var returnType=utils_2.symbolToWasmType(returnNode.resolvedType.symbol);this.assembler.append(0,returnType,wasm_type_1.WasmType[returnType]),this.assembler.activeCode.removeLastLinebreak(),this.assembler.activeCode.append(" (result "+wasm_type_1.WasmTypeToString[returnType]+")\n"),null==branch&&(needEmptyElse=!0)}else this.assembler.append(0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]);if(this.emitNode(byteOffset,node.ifTrue()),null!=branch)this.assembler.activeCode.indent-=1,this.assembler.activeCode.clearIndent(1),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.IF_ELSE),this.emitNode(byteOffset,branch);else if(needEmptyElse){this.assembler.activeCode.indent-=1,this.assembler.activeCode.clearIndent(1),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.IF_ELSE);var dataType=utils_2.typeToDataType(returnNode.resolvedType,this.bitness);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode[dataType+"_CONST"]),"I32"===dataType||"I64"===dataType?this.assembler.writeUnsignedLEB128(0):"F32"===dataType?this.assembler.writeFloat(0):"F64"===dataType&&this.assembler.writeDouble(0)}this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.HOOK){this.emitNode(byteOffset,node.hookValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.IF);var trueValue=node.hookTrue(),trueValueType=utils_2.symbolToWasmType(trueValue.resolvedType.symbol);this.assembler.append(0,trueValueType,wasm_type_1.WasmType[trueValueType]),this.emitNode(byteOffset,trueValue),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.IF_ELSE),this.emitNode(byteOffset,node.hookFalse()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.VARIABLE){var value=node.variableValue();if("this"==node.symbol.name&&"constructor"==this.currentFunction.symbol.name);else if(node.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL){value&&value.kind!=node_1.NodeKind.NAME&&value.kind!=node_1.NodeKind.CALL&&value.kind!=node_1.NodeKind.NEW&&value.kind!=node_1.NodeKind.DOT&&value.rawValue?node.symbol.resolvedType.isFloat()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,value.floatValue),this.assembler.writeFloat(value.floatValue)):node.symbol.resolvedType.isDouble()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,value.doubleValue),this.assembler.writeDouble(value.doubleValue)):node.symbol.resolvedType.isLong()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,value.longValue),this.assembler.writeLEB128(value.longValue)):(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,value.intValue),this.assembler.writeLEB128(value.intValue)):null!=value?this.emitNode(byteOffset,value):node.symbol.resolvedType.isFloat()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,0),this.assembler.writeFloat(0)):node.symbol.resolvedType.isDouble()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,0),this.assembler.writeDouble(0)):node.symbol.resolvedType.isLong()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(0)):(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(0));var skipSetLocal=value&&node_1.isUnaryPostfix(value.kind);0==skipSetLocal&&(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,node.symbol.offset),this.assembler.writeUnsignedLEB128(node.symbol.offset))}else assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.NAME){var symbol=node.symbol;symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT||symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL?"this"===symbol.name&&"constructor"===this.currentFunction.symbol.name?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.GET_LOCAL,this.currentFunction.signature.argumentTypes.length),this.assembler.writeUnsignedLEB128(this.currentFunction.signature.argumentTypes.length)):(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.GET_LOCAL,symbol.offset),this.assembler.writeUnsignedLEB128(symbol.offset)):symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.GET_GLOBAL,symbol.offset),this.assembler.writeUnsignedLEB128(symbol.offset)):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.DEREFERENCE)this.emitLoadFromMemory(byteOffset,node.resolvedType.underlyingType(this.context),node.unaryValue(),0);else if(node.kind==node_1.NodeKind.POINTER_INDEX)this.emitLoadFromMemory(byteOffset,node.resolvedType.underlyingType(this.context),node.pointer(),node.pointerOffset());else if(node.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(0);else if(node.kind==node_1.NodeKind.INT32||node.kind==node_1.NodeKind.BOOLEAN)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,node.intValue),this.assembler.writeLEB128(node.intValue||0);else if(node.kind==node_1.NodeKind.INT64)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,node.longValue),this.assembler.writeLEB128(node.longValue);else if(node.kind==node_1.NodeKind.FLOAT32)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,node.floatValue),this.assembler.writeFloat(node.floatValue);else if(node.kind==node_1.NodeKind.FLOAT64)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,node.doubleValue),this.assembler.writeDouble(node.doubleValue);else if(node.kind==node_1.NodeKind.STRING){var value=wasm_binary_1.WasmBinary.MEMORY_INITIALIZER_BASE+node.intValue;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,value),this.assembler.writeLEB128(value)}else if(node.kind==node_1.NodeKind.CALL){var value=node.callValue(),symbol=value.symbol;if(assert_1.assert(symbol_1.isFunction(symbol.kind)),!symbol.node.isExternalImport()&&symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var dotTarget=value.dotTarget();this.emitNode(byteOffset,dotTarget),dotTarget.kind==node_1.NodeKind.NEW&&this.emitInstance(byteOffset,dotTarget)}for(var child=value.nextSibling;null!=child;)this.emitNode(byteOffset,child),child=child.nextSibling;var wasmFunctionName=utils_2.getWasmFunctionName(symbol);if(builtins_helper_1.isBuiltin(wasmFunctionName))this.assembler.appendOpcode(byteOffset,builtins_helper_1.getBuiltinOpcode(symbol.name));else{var callIndex=this.getWasmFunctionCallIndex(symbol);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.CALL,callIndex),this.assembler.writeUnsignedLEB128(callIndex)}}else if(node.kind==node_1.NodeKind.NEW)this.emitInstance(byteOffset,node);else if(node.kind==node_1.NodeKind.DELETE){var value=node.deleteValue();this.emitNode(byteOffset,value);var freeIndex=this.calculateWasmFunctionIndex(this.freeFunctionIndex);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.CALL,freeIndex),this.assembler.writeUnsignedLEB128(freeIndex)}else if(node.kind==node_1.NodeKind.POSITIVE)this.emitNode(byteOffset,node.unaryValue());else if(node.kind==node_1.NodeKind.NEGATIVE){var resolvedType=node.unaryValue().resolvedType;resolvedType.isFloat()?(this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_NEG)):resolvedType.isDouble()?(this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_NEG)):resolvedType.isInteger()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(0),this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_SUB)):resolvedType.isLong()&&(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(0),this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_SUB))}else if(node.kind==node_1.NodeKind.COMPLEMENT)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,-1),this.assembler.writeLEB128(-1),this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_XOR);else if(node.kind==node_1.NodeKind.NOT)this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_EQZ);else if(node.kind==node_1.NodeKind.CAST){var value=node.castValue(),context=this.context,from=value.resolvedType.underlyingType(context),type=node.resolvedType.underlyingType(context);from.variableSizeOf(context),type.variableSizeOf(context);if(from!=context.nullType&&from!=context.booleanType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.int64Type&&type!=context.uint64Type)if(from!=context.nullType&&from!=context.booleanType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.float32Type)if(from!=context.nullType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.float64Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.int32Type&&type!=context.uint32Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.float32Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.float64Type)if(from!=context.float32Type||type!=context.uint8Type&&type!=context.int8Type&&type!=context.uint16Type&&type!=context.int16Type&&type!=context.uint32Type&&type!=context.int32Type)if(from!=context.float32Type||type!=context.int64Type&&type!=context.uint64Type)if(from==context.float32Type&&type==context.float64Type)if(value.kind==node_1.NodeKind.FLOAT32){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(doubleValue)}else this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_PROMOTE_F32);else if(from!=context.float64Type||type!=context.uint8Type&&type!=context.int8Type&&type!=context.uint16Type&&type!=context.int16Type&&type!=context.uint32Type&&type!=context.int32Type)if(from!=context.float64Type||type!=context.int64Type&&type!=context.uint64Type)if(from==context.float64Type&&type==context.float32Type)if(value.kind==node_1.NodeKind.FLOAT64){var floatValue=value.floatValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(floatValue)}else this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_DEMOTE_F64);else this.emitNode(byteOffset,value);else if(value.kind==node_1.NodeKind.FLOAT64){var longValue=value.longValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,longValue),this.assembler.writeLEB128(longValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_TRUNC_U_F64:opcode_1.WasmOpcode.I64_TRUNC_S_F64)}else if(value.kind==node_1.NodeKind.FLOAT64){var intValue=value.intValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(intValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.I32_TRUNC_U_F64:opcode_1.WasmOpcode.I32_TRUNC_S_F64)}else if(value.kind==node_1.NodeKind.FLOAT32){var longValue=value.longValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,longValue),this.assembler.writeLEB128(longValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_TRUNC_U_F32:opcode_1.WasmOpcode.I64_TRUNC_S_F32)}else if(value.kind==node_1.NodeKind.FLOAT32){var intValue=value.intValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(intValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.I32_TRUNC_U_F32:opcode_1.WasmOpcode.I32_TRUNC_S_F32)}else if(value.kind==node_1.NodeKind.INT64){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(doubleValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.F64_CONVERT_U_I64:opcode_1.WasmOpcode.F64_CONVERT_S_I64)}else if(value.kind==node_1.NodeKind.INT32){var floatValue=value.floatValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(floatValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.F32_CONVERT_U_I64:opcode_1.WasmOpcode.F32_CONVERT_S_I64)}else if(value.kind==node_1.NodeKind.INT64){var intValue=value.intValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(intValue)}else this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_WRAP_I64);else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,0),this.assembler.writeDouble(0);else if(value.kind==node_1.NodeKind.BOOLEAN){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(doubleValue)}else if(value.kind==node_1.NodeKind.INT32){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(doubleValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.F64_CONVERT_U_I32:opcode_1.WasmOpcode.F64_CONVERT_S_I32)}else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,0),this.assembler.writeFloat(0);else if(value.kind==node_1.NodeKind.BOOLEAN){var floatValue=value.intValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(floatValue)}else if(value.kind==node_1.NodeKind.INT32){var floatValue=value.floatValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(floatValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.F32_CONVERT_U_I32:opcode_1.WasmOpcode.F32_CONVERT_S_I32)}else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(0);else if(value.kind==node_1.NodeKind.BOOLEAN){var intValue=value.intValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,intValue),this.assembler.writeLEB128(intValue)}else if(value.kind==node_1.NodeKind.INT32)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,value.longValue),this.assembler.writeLEB128(value.longValue);else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_EXTEND_U_I32:opcode_1.WasmOpcode.I64_EXTEND_S_I32)}}else if(node.kind==node_1.NodeKind.DOT){var symbol=node.symbol;symbol.kind==symbol_1.SymbolKind.VARIABLE_INSTANCE?this.emitLoadFromMemory(byteOffset,symbol.resolvedType,node.dotTarget(),symbol.offset):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.ASSIGN){var left=node.binaryLeft(),right=node.binaryRight(),symbol=left.symbol;left.kind==node_1.NodeKind.DEREFERENCE?this.emitStoreToMemory(byteOffset,left.resolvedType.underlyingType(this.context),left.unaryValue(),0,right):left.kind==node_1.NodeKind.POINTER_INDEX?this.emitStoreToMemory(byteOffset,left.resolvedType.underlyingType(this.context),left.pointer(),left.pointerOffset(),right):symbol.kind==symbol_1.SymbolKind.VARIABLE_INSTANCE?this.emitStoreToMemory(byteOffset,symbol.resolvedType,left.dotTarget(),symbol.offset,right):symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.emitNode(byteOffset,right),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_GLOBAL),this.assembler.writeUnsignedLEB128(symbol.offset)):symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT||symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL?(this.emitNode(byteOffset,right),node_1.isUnaryPostfix(right.kind)||(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,symbol.offset),this.assembler.writeUnsignedLEB128(symbol.offset))):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.LOGICAL_AND)this.emitNode(byteOffset,node.binaryLeft()),this.emitNode(byteOffset,node.binaryRight()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_AND),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(1),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_EQ);else if(node.kind==node_1.NodeKind.LOGICAL_OR)this.emitNode(byteOffset,node.binaryLeft()),this.emitNode(byteOffset,node.binaryRight()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_OR),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST),logger_1.log(this.assembler.activePayload,byteOffset,1,"i32 literal"),this.assembler.writeLEB128(1),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_EQ);else if(node_1.isUnary(node.kind)){var kind=node.kind;if(kind==node_1.NodeKind.POSTFIX_INCREMENT||kind==node_1.NodeKind.POSTFIX_DECREMENT){var value=node.unaryValue(),dataType=utils_2.typeToDataType(value.resolvedType,this.bitness);if(node.parent.kind==node_1.NodeKind.VARIABLE)this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,node.parent.symbol.offset),this.assembler.writeUnsignedLEB128(node.parent.symbol.offset);else if(node.parent.kind==node_1.NodeKind.ASSIGN){this.emitNode(byteOffset,value);var left=node.parent.binaryLeft();this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,left.symbol.offset),this.assembler.writeUnsignedLEB128(left.symbol.offset)}if(this.emitNode(byteOffset,value),node.parent.kind!=node_1.NodeKind.RETURN){assert_1.assert(value.resolvedType.isInteger()||value.resolvedType.isLong()||value.resolvedType.isFloat()||value.resolvedType.isDouble());var size=value.resolvedType.pointerTo?value.resolvedType.pointerTo.allocationSizeOf(this.context):value.resolvedType.allocationSizeOf(this.context);1==size||2==size?value.kind==node_1.NodeKind.INT32||value.resolvedType.isInteger()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(1)):terminal_1.Terminal.error("Wrong type"):4==size?value.kind==node_1.NodeKind.INT32||value.resolvedType.isInteger()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(1)):value.kind==node_1.NodeKind.FLOAT32||value.resolvedType.isFloat()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,1),this.assembler.writeFloat(1)):terminal_1.Terminal.error("Wrong type"):8==size&&(value.kind==node_1.NodeKind.INT64||value.resolvedType.isLong()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,1),this.assembler.writeLEB128(1)):value.kind==node_1.NodeKind.FLOAT64||value.resolvedType.isDouble()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,1),this.assembler.writeDouble(1)):terminal_1.Terminal.error("Wrong type"));var operation=kind==node_1.NodeKind.POSTFIX_INCREMENT?"ADD":"SUB";this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode[dataType+"_"+operation]),value.symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_GLOBAL,value.symbol.offset),this.assembler.writeLEB128(value.symbol.offset)):value.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL||value.symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,value.symbol.offset),this.assembler.writeLEB128(value.symbol.offset)):(value.symbol.kind,symbol_1.SymbolKind.VARIABLE_INSTANCE)}}}else{var isUnsigned=node.isUnsignedOperator(),left=node.binaryLeft(),right=node.binaryRight(),isFloat=left.resolvedType.isFloat()||right.resolvedType.isFloat(),isDouble=left.resolvedType.isDouble()||right.resolvedType.isDouble(),dataTypeLeft=utils_2.typeToDataType(left.resolvedType,this.bitness);utils_2.typeToDataType(right.resolvedType,this.bitness);if(node.kind==node_1.NodeKind.ADD){if(this.emitNode(byteOffset,left),null==left.resolvedType.pointerTo)this.emitNode(byteOffset,right);else{assert_1.assert(right.resolvedType.isInteger()||right.resolvedType.isLong()||right.resolvedType.isFloat()||right.resolvedType.isDouble());var size=left.resolvedType.pointerTo.allocationSizeOf(this.context);if(2==size)if(right.kind==node_1.NodeKind.INT32){var _value=right.intValue<<1;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,_value),this.assembler.writeLEB128(_value)}else this.emitNode(byteOffset,right),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(1),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_SHL);else if(4==size)if(right.kind==node_1.NodeKind.INT32){var _value=right.intValue<<2;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,_value),this.assembler.writeLEB128(_value)}else right.kind==node_1.NodeKind.FLOAT32?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,right.floatValue),this.assembler.writeFloat(right.floatValue)):(this.emitNode(byteOffset,right),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,2),this.assembler.writeLEB128(2),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_SHL));else 8==size?right.kind==node_1.NodeKind.INT64?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,right.longValue),this.assembler.writeLEB128(right.longValue)):right.kind==node_1.NodeKind.FLOAT64&&(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,right.doubleValue),this.assembler.writeDouble(right.doubleValue)):this.emitNode(byteOffset,right)}this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode[dataTypeLeft+"_ADD"])}else if(node.kind==node_1.NodeKind.BITWISE_AND){if(isFloat||isDouble){var error="Cannot do bitwise operations on floating point number";throw terminal_1.Terminal.error(error),error}this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_AND"])}else if(node.kind==node_1.NodeKind.BITWISE_OR){if(isFloat||isDouble){var error="Cannot do bitwise operations on floating point number";throw terminal_1.Terminal.error(error),error}this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_OR"])}else if(node.kind==node_1.NodeKind.BITWISE_XOR)this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_XOR"]);else if(node.kind==node_1.NodeKind.EQUAL)this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_EQ"]);else if(node.kind==node_1.NodeKind.MULTIPLY)this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_MUL"]);else if(node.kind==node_1.NodeKind.NOT_EQUAL)this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_NE"]);else if(node.kind==node_1.NodeKind.SHIFT_LEFT){if(isFloat||isDouble){var error="Cannot do bitwise operations on floating point number";throw terminal_1.Terminal.error(error),error}this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_SHL"])}else if(node.kind==node_1.NodeKind.SUBTRACT)this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_SUB"]);else if(node.kind==node_1.NodeKind.DIVIDE){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_DIV"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_DIV_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_DIV_S"];this.emitBinaryExpression(byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.GREATER_THAN){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_GT"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_GT_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_GT_S"];this.emitBinaryExpression(byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.GREATER_THAN_EQUAL){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_GE"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_GE_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_GE_S"];this.emitBinaryExpression(byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.LESS_THAN){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_LT"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_LT_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_LT_S"];this.emitBinaryExpression(byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.LESS_THAN_EQUAL){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_LE"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_LE_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_LE_S"];this.emitBinaryExpression(byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.REMAINDER){if(isFloat||isDouble){var error="Floating point remainder is not yet supported in WebAssembly. Please import javascript function to handle this";throw terminal_1.Terminal.error(error),error}this.emitBinaryExpression(byteOffset,node,isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_REM_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_REM_S"])}else if(node.kind==node_1.NodeKind.SHIFT_RIGHT){if(isFloat||isDouble){var error="Cannot do bitwise operations on floating point number";throw terminal_1.Terminal.error(error),error}this.emitBinaryExpression(byteOffset,node,isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_SHR_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_SHR_S"])}else assert_1.assert(!1)}}}return 1},WasmModuleEmitter.prototype.calculateWasmFunctionIndex=function(index){return this.assembler.module.importCount+index},WasmModuleEmitter.prototype.getWasmFunctionCallIndex=function(symbol){return symbol.node.isImport()||symbol.node.isExternalImport()?symbol.offset:this.assembler.module.importCount+symbol.offset},WasmModuleEmitter.prototype.getWasmType=function(type){var context=this.context;return type==context.booleanType||type.isClass()||type.isInteger()||this.bitness==bitness_1.Bitness.x32&&type.isReference()?wasm_type_1.WasmType.I32:type.isLong()||this.bitness==bitness_1.Bitness.x64&&type.isReference()?wasm_type_1.WasmType.I64:type.isDouble()?wasm_type_1.WasmType.F64:type.isFloat()?wasm_type_1.WasmType.F32:type==context.voidType?wasm_type_1.WasmType.VOID:(assert_1.assert(!1),wasm_type_1.WasmType.VOID)},WasmModuleEmitter}();exports.wasmEmit=wasmEmit},function(module,exports,__webpack_require__){"use strict";function addScopeToSymbol(symbol,parentScope){var scope=new scope_1.Scope;scope.parent=parentScope,scope.symbol=symbol,symbol.scope=scope}function linkSymbolToNode(symbol,node){node.symbol=symbol,node.scope=symbol.scope,symbol.range=null!=node.internalRange?node.internalRange:node.range,symbol.node=node}function initialize(context,node,parentScope,mode){var kind=node.kind;if(null!=node.parent){var parentKind=node.parent.kind;kind==node_1.NodeKind.IMPORTS||kind==node_1.NodeKind.VARIABLE||kind==node_1.NodeKind.VARIABLES||kind==node_1.NodeKind.FUNCTION&&parentKind==node_1.NodeKind.CLASS||(parentKind==node_1.NodeKind.FILE||parentKind==node_1.NodeKind.GLOBAL)==(parentKind==node_1.NodeKind.MODULE||kind==node_1.NodeKind.MODULE||kind==node_1.NodeKind.CLASS||kind==node_1.NodeKind.ENUM||kind==node_1.NodeKind.FUNCTION||kind==node_1.NodeKind.CONSTANTS)||context.log.error(node.range,"This statement is not allowed here")}if(kind==node_1.NodeKind.MODULE){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;symbol.kind=symbol_1.SymbolKind.TYPE_MODULE,symbol.name=node.stringValue,symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.flags=symbol_1.SYMBOL_FLAG_IS_REFERENCE,addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL),parentScope=symbol.scope}if(kind==node_1.NodeKind.CLASS||kind==node_1.NodeKind.ENUM){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;if(symbol.kind=kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.TYPE_CLASS:symbol_1.SymbolKind.TYPE_ENUM,symbol.name=node.stringValue,symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.flags=symbol_1.SYMBOL_FLAG_IS_REFERENCE,addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL),parentScope=symbol.scope,node.parameterCount()>0){symbol.kind=symbol_1.SymbolKind.TYPE_TEMPLATE,symbol.flags|=symbol_1.SYMBOL_FLAG_IS_TEMPLATE;var genericType=node.firstGenericType(),genericSymbol=new symbol_1.Symbol;genericSymbol.kind=symbol_1.SymbolKind.TYPE_GENERIC,genericSymbol.name=genericType.stringValue,genericSymbol.resolvedType=new type_1.Type,genericSymbol.resolvedType.symbol=genericSymbol,genericSymbol.flags=symbol_1.SYMBOL_FLAG_IS_GENERIC,genericType.flags=node_1.NODE_FLAG_GENERIC,addScopeToSymbol(genericSymbol,parentScope),linkSymbolToNode(genericSymbol,genericType),parentScope.define(context.log,genericSymbol,scope_1.ScopeHint.NORMAL)}}else if(kind==node_1.NodeKind.FUNCTION){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;if(symbol.kind=node.parent.kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.FUNCTION_INSTANCE:symbol_1.SymbolKind.FUNCTION_GLOBAL,symbol.name=node.stringValue,node.isOperator()&&("+"==symbol.name||"-"==symbol.name?node.functionFirstArgument()==node.functionReturnType()?(symbol.flags=symbol_1.SYMBOL_FLAG_IS_UNARY_OPERATOR,symbol.rename="+"==symbol.name?"op_positive":"op_negative"):(symbol.flags=symbol_1.SYMBOL_FLAG_IS_BINARY_OPERATOR,symbol.rename="+"==symbol.name?"op_add":"op_subtract"):symbol.rename="%"==symbol.name?"op_remainder":"&"==symbol.name?"op_and":"*"==symbol.name?"op_multiply":"**"==symbol.name?"op_exponent":"++"==symbol.name?"op_increment":"--"==symbol.name?"op_decrement":"/"==symbol.name?"op_divide":"<"==symbol.name?"op_lessThan":"<<"==symbol.name?"op_shiftLeft":"=="==symbol.name?"op_equals":">"==symbol.name?"op_greaterThan":">>"==symbol.name?"op_shiftRight":"[]"==symbol.name?"op_get":"[]="==symbol.name?"op_set":"^"==symbol.name?"op_xor":"|"==symbol.name?"op_or":"~"==symbol.name?"op_complement":null),"constructor"==symbol.name&&(symbol.rename="_ctr"),addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,symbol.isSetter()?scope_1.ScopeHint.NOT_GETTER:symbol.isGetter()?scope_1.ScopeHint.NOT_SETTER:symbol.isBinaryOperator()?scope_1.ScopeHint.NOT_UNARY:symbol.isUnaryOperator()?scope_1.ScopeHint.NOT_BINARY:scope_1.ScopeHint.NORMAL),parentScope=symbol.scope,symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var parent=symbol.parent();if(initializeSymbol(context,parent),"constructor"==symbol.name){var body=node.functionBody();if(null!==body){var variablesNode=body.firstChild;if(variablesNode.kind!==node_1.NodeKind.VARIABLES){var _variablesNode=node_1.createVariables();body.insertChildBefore(variablesNode,_variablesNode),variablesNode=_variablesNode}var firstVariable=variablesNode.firstChild;void 0!==firstVariable?"this"!==firstVariable.stringValue?variablesNode.insertChildBefore(firstVariable,node_1.createVariable("this",node_1.createType(parent.resolvedType),null)):"this"===firstVariable.stringValue&&void 0===firstVariable.firstChild.resolvedType&&(firstVariable.firstChild.resolvedType=parent.resolvedType):variablesNode.appendChild(node_1.createVariable("this",node_1.createType(parent.resolvedType),null));var returnNode=node_1.createReturn(node_1.createName("this"));node.lastChild.lastChild&&node.lastChild.lastChild.kind==node_1.NodeKind.RETURN&&node.lastChild.lastChild.remove(),node.lastChild.appendChild(returnNode)}}else{var firstArgument=node.functionFirstArgument();"this"!==firstArgument.stringValue?node.insertChildBefore(firstArgument,node_1.createVariable("this",node_1.createType(parent.resolvedType),null)):"this"===firstArgument.stringValue&&void 0===firstArgument.firstChild.resolvedType&&(firstArgument.firstChild.resolvedType=parent.resolvedType)}}}else if(kind==node_1.NodeKind.VARIABLE){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;symbol.kind=node.parent.kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.VARIABLE_INSTANCE:node.parent.kind==node_1.NodeKind.FUNCTION?symbol_1.SymbolKind.VARIABLE_ARGUMENT:node.parent.kind==node_1.NodeKind.CONSTANTS||node.parent.kind==node_1.NodeKind.ENUM?symbol_1.SymbolKind.VARIABLE_CONSTANT:node.parent.kind==node_1.NodeKind.VARIABLES&&node.parent.parent.kind==node_1.NodeKind.FILE?symbol_1.SymbolKind.VARIABLE_GLOBAL:symbol_1.SymbolKind.VARIABLE_LOCAL,symbol.name=node.stringValue,symbol.scope=parentScope,linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL)}else if(kind==node_1.NodeKind.BLOCK){if(node.parent.kind!=node_1.NodeKind.FUNCTION){var scope=new scope_1.Scope;scope.parent=parentScope,parentScope=scope}node.scope=parentScope}for(var child=node.firstChild;null!=child;)mode==CheckMode.INITIALIZE&&(child.flags|=node_1.NODE_FLAG_LIBRARY),initialize(context,child,parentScope,mode),child=child.nextSibling;kind==node_1.NodeKind.FILE&&mode==CheckMode.INITIALIZE&&(context.booleanType=parentScope.findLocal("boolean",scope_1.ScopeHint.NORMAL).resolvedType,context.uint8Type=parentScope.findLocal("uint8",scope_1.ScopeHint.NORMAL).resolvedType,context.int32Type=parentScope.findLocal("int32",scope_1.ScopeHint.NORMAL).resolvedType,context.int64Type=parentScope.findLocal("int64",scope_1.ScopeHint.NORMAL).resolvedType,context.int8Type=parentScope.findLocal("int8",scope_1.ScopeHint.NORMAL).resolvedType,context.int16Type=parentScope.findLocal("int16",scope_1.ScopeHint.NORMAL).resolvedType,context.stringType=parentScope.findLocal("string",scope_1.ScopeHint.NORMAL).resolvedType,context.uint32Type=parentScope.findLocal("uint32",scope_1.ScopeHint.NORMAL).resolvedType,context.uint64Type=parentScope.findLocal("uint64",scope_1.ScopeHint.NORMAL).resolvedType,context.uint16Type=parentScope.findLocal("uint16",scope_1.ScopeHint.NORMAL).resolvedType,context.float32Type=parentScope.findLocal("float32",scope_1.ScopeHint.NORMAL).resolvedType,context.float64Type=parentScope.findLocal("float64",scope_1.ScopeHint.NORMAL).resolvedType,prepareNativeType(context.booleanType,1,0),prepareNativeType(context.uint8Type,1,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.int8Type,1,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.int16Type,2,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.uint16Type,2,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.int32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.int64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_LONG),prepareNativeType(context.uint32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.uint64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_LONG|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.stringType,4,symbol_1.SYMBOL_FLAG_IS_REFERENCE),prepareNativeType(context.float32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_FLOAT),prepareNativeType(context.float64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_DOUBLE))}function prepareNativeType(type,byteSizeAndMaxAlignment,flags){var symbol=type.symbol;symbol.kind=symbol_1.SymbolKind.TYPE_NATIVE,symbol.byteSize=byteSizeAndMaxAlignment,symbol.maxAlignment=byteSizeAndMaxAlignment,symbol.flags=flags}function forbidFlag(context,node,flag,text){if(0!=(node.flags&flag)){var range=node_1.rangeForFlag(node.firstFlag,flag);null!=range&&(node.flags=node.flags&~flag,context.log.error(range,text))}}function requireFlag(context,node,flag,text){0==(node.flags&flag)&&(node.flags=node.flags|flag,context.log.error(node.range,text))}function initializeSymbol(context,symbol){if(symbol.state==symbol_1.SymbolState.INITIALIZED)return void assert_1.assert(null!=symbol.resolvedType);assert_1.assert(symbol.state==symbol_1.SymbolState.UNINITIALIZED),symbol.state=symbol_1.SymbolState.INITIALIZING;var node=symbol.node;if(forbidFlag(context,node,node_1.NODE_FLAG_PROTECTED,"Unsupported flag 'protected'"),symbol.kind==symbol_1.SymbolKind.TYPE_MODULE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a namespace"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a namespace"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a namespace"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a namespace");else if(symbol.kind==symbol_1.SymbolKind.TYPE_CLASS||symbol.kind==symbol_1.SymbolKind.TYPE_NATIVE||symbol.kind==symbol_1.SymbolKind.TYPE_GENERIC||symbol.kind==symbol_1.SymbolKind.TYPE_TEMPLATE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a class");else if(symbol.kind==symbol_1.SymbolKind.TYPE_INTERFACE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a interface");else if(symbol.kind==symbol_1.SymbolKind.TYPE_ENUM){forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on an enum"),symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol;var underlyingSymbol=symbol.resolvedType.underlyingType(context).symbol;symbol.byteSize=underlyingSymbol.byteSize,symbol.maxAlignment=underlyingSymbol.maxAlignment}else if(symbol_1.isFunction(symbol.kind)){var body=node.functionBody(),returnType=node.functionReturnType(),oldUnsafeAllowed=context.isUnsafeAllowed;context.isUnsafeAllowed=node.isUnsafe(),resolveAsType(context,returnType,symbol.scope.parent),returnType.resolvedType.isClass()&&returnType.hasParameters()&&node.parent!=returnType.resolvedType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],returnType.resolvedType.symbol.scope);for(var argumentCount=0,child=node.functionFirstArgument();child!=returnType;)assert_1.assert(child.kind==node_1.NodeKind.VARIABLE),assert_1.assert(child.symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT),initializeSymbol(context,child.symbol),child.symbol.offset=argumentCount,argumentCount+=1,child=child.nextSibling;if(symbol.kind!=symbol_1.SymbolKind.FUNCTION_INSTANCE?(forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' here"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' here"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' here"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' here")):node.isGet()?(forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use both 'get' and 'set'"),1!=argumentCount&&context.log.error(symbol.range,"Getters must not have any argumentVariables")):node.isSet()?(symbol.rename="set_"+symbol.name,2!=argumentCount&&context.log.error(symbol.range,"Setters must have exactly one argument")):node.isOperator()&&("~"==symbol.name||"++"==symbol.name||"--"==symbol.name?1!=argumentCount&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must not have any arguments"):"+"==symbol.name||"-"==symbol.name?argumentCount>2&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must have at most one argument"):"[]="==symbol.name?argumentCount<2&&context.log.error(symbol.range,"Operator '[]=' must have at least one argument"):2!=argumentCount&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must have exactly one argument")),symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var parent=symbol.parent(),shouldConvertInstanceToGlobal=!1;if(forbidFlag(context,node,node_1.NODE_FLAG_EXPORT,"Cannot use 'export' on an instance function"),forbidFlag(context,node,node_1.NODE_FLAG_DECLARE,"Cannot use 'declare' on an instance function"),parent.node.isDeclare()?null==body?node.flags=node.flags|node_1.NODE_FLAG_DECLARE:shouldConvertInstanceToGlobal=!0:(null==body&&context.log.error(node.lastChild.range,"Must implement this function"),parent.node.isExport()&&(node.flags=node.flags|node_1.NODE_FLAG_EXPORT)),shouldConvertInstanceToGlobal){symbol.kind=symbol_1.SymbolKind.FUNCTION_GLOBAL,symbol.flags=symbol.flags|symbol_1.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL,symbol.rename=parent.name+"_"+(null!=symbol.rename?symbol.rename:symbol.name);var argument=node.functionFirstArgument();assert_1.assert("this"==argument.symbol.name),argument.symbol.rename="__this"}}else null==body?(forbidFlag(context,node,node_1.NODE_FLAG_EXPORT,"Cannot use 'export' on an unimplemented function"),node.parent&&node.parent.isDeclare()||requireFlag(context,node,node_1.NODE_FLAG_DECLARE,"Declared functions must be prefixed with 'declare'")):forbidFlag(context,node,node_1.NODE_FLAG_DECLARE,"Cannot use 'declare' on a function with an implementation");context.isUnsafeAllowed=oldUnsafeAllowed}else if(symbol_1.isVariable(symbol.kind)){forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a variable"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a variable");var type=node.variableType(),value=node.variableValue(),oldUnsafeAllowed=context.isUnsafeAllowed;if(context.isUnsafeAllowed=context.isUnsafeAllowed||node.isUnsafe(),symbol.kind!=symbol_1.SymbolKind.VARIABLE_INSTANCE&&(forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' here"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' here")),null!=type?(resolveAsType(context,type,symbol.scope),type.resolvedType.isTemplate()&&type.hasParameters()&&node.parent!=type.resolvedType.symbol.node&&deriveConcreteClass(context,type,[type.firstChild.firstChild],type.resolvedType.symbol.scope),symbol.resolvedType=type.resolvedType):null!=value?(resolveAsExpression(context,value,symbol.scope),value.resolvedType.isTemplate()&&value.hasParameters()&&node.parent!=value.resolvedType.symbol.node&&deriveConcreteClass(context,value,[value.firstChild.firstChild],value.resolvedType.symbol.scope),symbol.resolvedType=value.resolvedType):(context.log.error(node.internalRange,"Cannot create untyped variables"),symbol.resolvedType=context.errorType),symbol.resolvedType!=context.voidType&&symbol.resolvedType!=context.nullType||(context.log.error(node.internalRange,"Cannot create a variable with type '"+symbol.resolvedType.toString()+"'"),symbol.resolvedType=context.errorType),symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT)if(null!=value)resolveAsExpression(context,value,symbol.scope),checkConversion(context,value,symbol.resolvedTypeUnderlyingIfEnumValue(context),type_1.ConversionKind.IMPLICIT),value.kind==node_1.NodeKind.INT32||value.kind==node_1.NodeKind.INT64||value.kind==node_1.NodeKind.BOOLEAN?symbol.offset=value.intValue:value.kind==node_1.NodeKind.FLOAT32||value.kind==node_1.NodeKind.FLOAT64?symbol.offset=value.floatValue:value.resolvedType!=context.errorType&&(context.log.error(value.range,"Invalid constant initializer"),symbol.resolvedType=context.errorType);else if(symbol.isEnumValue())if(null!=node.previousSibling){var previousSymbol=node.previousSibling.symbol;initializeSymbol(context,previousSymbol),symbol.offset=previousSymbol.offset+1}else symbol.offset=0;else context.log.error(node.internalRange,"Constants must be initialized");if(null==symbol.scope.symbol)for(var scope=symbol.scope.parent;null!=scope;){var shadowed=scope.findLocal(symbol.name,scope_1.ScopeHint.NORMAL);if(null!=shadowed){context.log.error(node.internalRange,"The symbol '"+symbol.name+"' shadows another symbol with the same name in a parent scope");break}if(null!=scope.symbol)break;scope=scope.parent}context.isUnsafeAllowed=oldUnsafeAllowed}else assert_1.assert(!1);assert_1.assert(null!=symbol.resolvedType),symbol.state=symbol_1.SymbolState.INITIALIZED}function deriveConcreteClass(context,type,parameters,scope){var templateNode=type.resolvedType.pointerTo?type.resolvedType.pointerTo.symbol.node:type.resolvedType.symbol.node,templateName=templateNode.stringValue,typeName=templateNode.stringValue+"<"+parameters[0].stringValue+">",rename=templateNode.stringValue+"_"+parameters[0].stringValue,symbol=scope.parent.findNested(typeName,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);if(symbol){var genericSymbol=scope.parent.findNested(type.firstChild.firstChild.stringValue,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);return type.firstChild.firstChild.symbol=genericSymbol,genericSymbol.resolvedType.pointerTo?type.firstChild.firstChild.resolvedType=genericSymbol.resolvedType.pointerType():type.firstChild.firstChild.resolvedType=genericSymbol.resolvedType,type.symbol=symbol,void(type.resolvedType.pointerTo?type.resolvedType=symbol.resolvedType.pointerType():type.resolvedType=symbol.resolvedType)}var node=templateNode.clone();if(node.stringValue=typeName,cloneChildren(templateNode.firstChild.nextSibling,node,parameters,templateName,typeName),node.offset=null,initialize(context,node,scope.parent,CheckMode.NORMAL),resolve(context,node,scope.parent),node.symbol.flags|=symbol_1.SYMBOL_FLAG_USED,type.symbol=node.symbol,node.symbol.rename=rename,type.resolvedType.pointerTo?type.resolvedType=node.symbol.resolvedType.pointerType():type.resolvedType=node.symbol.resolvedType,templateNode.parent)templateNode.replaceWith(node);else{var prevNode=templateNode.derivedNodes[templateNode.derivedNodes.length-1];prevNode.parent.insertChildAfter(prevNode,node)}void 0===templateNode.derivedNodes&&(templateNode.derivedNodes=[]),templateNode.derivedNodes.push(node),type.firstChild.firstChild.kind=node_1.NodeKind.NAME,resolve(context,type.firstChild.firstChild,scope.parent),type.stringValue=node.symbol.name}function cloneChildren(child,parentNode,parameters,templateName,typeName){for(var firstChildNode=null,lastChildNode=null;child;)if("this"==child.stringValue&&child.parent.symbol&&child.parent.symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE&&child.kind==node_1.NodeKind.TYPE)child=child.nextSibling;else{var childNode=void 0;if(child.kind!=node_1.NodeKind.PARAMETERS&&child.kind!=node_1.NodeKind.PARAMETER){if(child.isGeneric()){var offset=child.offset;child.resolvedType&&(offset=child.resolvedType.pointerTo?child.resolvedType.pointerTo.symbol.node.offset:child.resolvedType.symbol.node.offset),childNode=child.symbol&&symbol_1.isVariable(child.symbol.kind)?child.clone():parameters[offset].clone(),childNode.kind=node_1.NodeKind.NAME}else"T"==child.stringValue&&(terminal_1.Terminal.write("Generic type escaped!"),terminal_1.Terminal.write(child)),childNode=child.clone(),childNode.stringValue==templateName&&(childNode.stringValue=typeName);childNode.parent=parentNode,"constructor"==childNode.stringValue&&childNode.parent.kind==node_1.NodeKind.CLASS&&(childNode.parent.constructorFunctionNode=childNode),firstChildNode||(firstChildNode=childNode),lastChildNode&&(lastChildNode.nextSibling=childNode,childNode.previousSibling=lastChildNode),child.firstChild&&cloneChildren(child.firstChild,childNode,parameters,templateName,typeName),lastChildNode=childNode,child=child.nextSibling}else child=child.nextSibling}null!=firstChildNode&&(parentNode.firstChild=firstChildNode),null!=lastChildNode&&(parentNode.lastChild=lastChildNode)}function resolveChildren(context,node,parentScope){for(var child=node.firstChild;null!=child;)resolve(context,child,parentScope),assert_1.assert(null!=child.resolvedType),child=child.nextSibling}function resolveChildrenAsExpressions(context,node,parentScope){for(var child=node.firstChild;null!=child;)resolveAsExpression(context,child,parentScope),child=child.nextSibling}function resolveAsExpression(context,node,parentScope){assert_1.assert(node_1.isExpression(node)),resolve(context,node,parentScope),assert_1.assert(null!=node.resolvedType),node.resolvedType!=context.errorType&&(node.isType()?(context.log.error(node.range,"Expected expression but found type"),node.resolvedType=context.errorType):node.resolvedType==context.voidType&&node.parent.kind!=node_1.NodeKind.EXPRESSION&&(context.log.error(node.range,"This expression does not return a value"),node.resolvedType=context.errorType))}function resolveAsType(context,node,parentScope){assert_1.assert(node_1.isExpression(node)),resolve(context,node,parentScope),assert_1.assert(null!=node.resolvedType),node.resolvedType==context.errorType||node.isType()||(context.log.error(node.range,"Expected type but found expression"),node.resolvedType=context.errorType)}function canConvert(context,node,to,kind){var from=node.resolvedType;if(assert_1.assert(node_1.isExpression(node)),assert_1.assert(null!=from),assert_1.assert(null!=to),from.isGeneric()||to.isGeneric())return!0;if(from==to||from==context.errorType||to==context.errorType)return!0;if(from==context.nullType)return!0;if(from.isReference()||to.isReference()){if(kind==type_1.ConversionKind.EXPLICIT)return!0}else{if(from==context.booleanType)return!0;if(from.isInteger()&&to.isInteger()){to.integerBitMask(context);return!(!from.isUnsigned()||!to.isUnsigned())||(!(!from.isEnum()||to!=from.underlyingType(context))||(!node.intValue||(kind==type_1.ConversionKind.EXPLICIT||from.symbol.byteSize=0&&node.intValue<=const_1.MAX_UINT32_VALUE:node.intValue>=const_1.MIN_INT32_VALUE&&node.intValue<=const_1.MAX_INT32_VALUE))))}if(from.isInteger()&&to.isFloat()||from.isInteger()&&to.isDouble()||from.isLong()&&to.isInteger()||from.isLong()&&to.isFloat()||from.isLong()&&to.isDouble()||from.isFloat()&&to.isInteger()||from.isFloat()&&to.isLong()||from.isDouble()&&to.isInteger()||from.isDouble()&&to.isLong()||from.isDouble()&&to.isFloat())return kind!=type_1.ConversionKind.IMPLICIT;if(from.isInteger()&&to.isLong()||from.isFloat()&&to.isDouble()||from.isFloat()&&to.isFloat()||from.isDouble()&&to.isDouble())return!0}return!1}function checkConversion(context,node,to,kind){canConvert(context,node,to,kind)||(context.log.error(node.range,"Cannot convert from type '"+node.resolvedType.toString()+"' to type '"+to.toString()+"' "+(kind==type_1.ConversionKind.IMPLICIT&&canConvert(context,node,to,type_1.ConversionKind.EXPLICIT)?"without a cast":"")),node.resolvedType=context.errorType)}function checkStorage(context,target){assert_1.assert(node_1.isExpression(target)),target.resolvedType==context.errorType||target.kind==node_1.NodeKind.INDEX||target.kind==node_1.NodeKind.POINTER_INDEX||target.kind==node_1.NodeKind.DEREFERENCE||(target.kind==node_1.NodeKind.NAME||target.kind==node_1.NodeKind.DOT)&&(null==target.symbol||symbol_1.isVariable(target.symbol.kind)&&target.symbol.kind!=symbol_1.SymbolKind.VARIABLE_CONSTANT)||(context.log.error(target.range,"Cannot store to this location"),target.resolvedType=context.errorType)}function createDefaultValueForType(context,type){return type.isLong()?node_1.createLong(0):type.isInteger()?node_1.createInt(0):type.isDouble()?node_1.createDouble(0):type.isFloat()?node_1.createFloat(0):type==context.booleanType?node_1.createboolean(!1):type.isClass()?node_1.createNull():type.isGeneric()?node_1.createNull():(assert_1.assert(type.isReference()),node_1.createNull())}function simplifyBinary(node){var left=node.binaryLeft(),right=node.binaryRight();if(node.kind!=node_1.NodeKind.ADD&&node.kind!=node_1.NodeKind.MULTIPLY&&node.kind!=node_1.NodeKind.BITWISE_AND&&node.kind!=node_1.NodeKind.BITWISE_OR&&node.kind!=node_1.NodeKind.BITWISE_XOR||left.kind!=node_1.NodeKind.INT32||right.kind==node_1.NodeKind.INT32||(node.appendChild(left.remove()),left=node.binaryLeft(),right=node.binaryRight()),(node.kind==node_1.NodeKind.MULTIPLY||(node.kind==node_1.NodeKind.DIVIDE||node.kind==node_1.NodeKind.REMAINDER)&&node.resolvedType.isUnsigned())&&right.kind==node_1.NodeKind.INT32&&utils_1.isPositivePowerOf2(right.intValue)){for(var shift=-1,value=right.intValue;0!=value;)value>>=1,shift+=1;node.kind==node_1.NodeKind.MULTIPLY?(node.kind=node_1.NodeKind.SHIFT_LEFT,right.intValue=shift):node.kind==node_1.NodeKind.DIVIDE?(node.kind=node_1.NodeKind.SHIFT_RIGHT,right.intValue=shift):node.kind==node_1.NodeKind.REMAINDER?(node.kind=node_1.NodeKind.BITWISE_AND,right.intValue=right.intValue-1):assert_1.assert(!1)}else node.kind==node_1.NodeKind.ADD&&right.kind==node_1.NodeKind.NEGATIVE?(node.kind=node_1.NodeKind.SUBTRACT,right.replaceWith(right.unaryValue().remove())):node.kind==node_1.NodeKind.ADD&&right.isNegativeInteger()&&(node.kind=node_1.NodeKind.SUBTRACT,right.intValue=-right.intValue)}function binaryHasUnsignedArguments(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isUnsigned()&&rightType.isUnsigned()||leftType.isUnsigned()&&right.isNonNegativeInteger()||left.isNonNegativeInteger()&&rightType.isUnsigned()}function isBinaryLong(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isLong()||rightType.isLong()}function isBinaryDouble(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isDouble()||rightType.isDouble()}function isSymbolAccessAllowed(context,symbol,node,range){if(symbol.isUnsafe()&&!context.isUnsafeAllowed)return context.log.error(range,"Cannot use symbol '"+symbol.name+"' outside an 'unsafe' block"),!1;if(null!=symbol.node&&symbol.node.isPrivate()){var parent=symbol.parent();if(null!=parent&&context.enclosingClass!=parent)return context.log.error(range,"Cannot access private symbol '"+symbol.name+"' here"),!1}return!(symbol_1.isFunction(symbol.kind)&&(symbol.isSetter()?!node.isAssignTarget():!node.isCallValue()))||(symbol.isSetter()?context.log.error(range,"Cannot use setter '"+symbol.name+"' here"):context.log.error(range,"Must call function '"+symbol.name+"'"),!1)}function resolve(context,node,parentScope){var kind=node.kind;if(assert_1.assert(kind==node_1.NodeKind.FILE||null!=parentScope),null==node.resolvedType)if(node.resolvedType=context.errorType,kind==node_1.NodeKind.FILE||kind==node_1.NodeKind.GLOBAL)resolveChildren(context,node,parentScope);else if(kind==node_1.NodeKind.MODULE){var oldEnclosingModule=context.enclosingModule;initializeSymbol(context,node.symbol),context.enclosingModule=node.symbol,resolveChildren(context,node,node.scope),context.enclosingModule=oldEnclosingModule}else if(kind==node_1.NodeKind.IMPORT||kind==node_1.NodeKind.IMPORT_FROM);else if(kind==node_1.NodeKind.CLASS){var oldEnclosingClass=context.enclosingClass;initializeSymbol(context,node.symbol),context.enclosingClass=node.symbol,resolveChildren(context,node,node.scope),node.symbol.kind==symbol_1.SymbolKind.TYPE_CLASS&&node.symbol.determineClassLayout(context),context.enclosingClass=oldEnclosingClass}else if(kind==node_1.NodeKind.ENUM)initializeSymbol(context,node.symbol),resolveChildren(context,node,node.scope);else if(kind==node_1.NodeKind.FUNCTION){var body=node.functionBody();if(initializeSymbol(context,node.symbol),"constructor"==node.stringValue&&node.parent.kind==node_1.NodeKind.CLASS&&(node.parent.constructorFunctionNode=node),null!=body){var oldReturnType=context.currentReturnType,oldUnsafeAllowed=context.isUnsafeAllowed,returnType=node.functionReturnType();returnType.resolvedType.isTemplate()&&returnType.hasParameters()&&node.parent!=returnType.resolvedType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],returnType.resolvedType.symbol.scope),context.currentReturnType=returnType.resolvedType,context.isUnsafeAllowed=node.isUnsafe(),resolveChildren(context,body,node.scope),oldReturnType&&oldReturnType.isTemplate()&&returnType.hasParameters()&&node.parent!=oldReturnType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],oldReturnType.symbol.scope),context.currentReturnType=oldReturnType,context.isUnsafeAllowed=oldUnsafeAllowed}}else if(kind==node_1.NodeKind.PARAMETER)var symbol=node.symbol;else if(kind==node_1.NodeKind.VARIABLE){var symbol=node.symbol;initializeSymbol(context,symbol);var oldUnsafeAllowed=context.isUnsafeAllowed;context.isUnsafeAllowed=context.isUnsafeAllowed||node.isUnsafe();var value=node.variableValue();null!=value?(resolveAsExpression(context,value,parentScope),checkConversion(context,value,symbol.resolvedTypeUnderlyingIfEnumValue(context),type_1.ConversionKind.IMPLICIT),symbol.resolvedType!=value.resolvedType&&value.becomeValueTypeOf(symbol,context),symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL&&value.kind!=node_1.NodeKind.INT32&&value.kind!=node_1.NodeKind.BOOLEAN&&(value.kind,node_1.NodeKind.NULL)):symbol.resolvedType!=context.errorType&&(value=createDefaultValueForType(context,symbol.resolvedType),resolveAsExpression(context,value,parentScope),node.appendChild(value)),symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL&&symbol.resolvedType!=context.errorType&&(symbol.offset=context.allocateGlobalVariableOffset(symbol.resolvedType.variableSizeOf(context),symbol.resolvedType.variableAlignmentOf(context))),context.isUnsafeAllowed=oldUnsafeAllowed}else if(kind==node_1.NodeKind.BREAK||kind==node_1.NodeKind.CONTINUE){for(var found=!1,n=node;null!=n;){if(n.kind==node_1.NodeKind.WHILE){found=!0;break}n=n.parent}found||context.log.error(node.range,"Cannot use this statement outside of a loop")}else if(kind==node_1.NodeKind.BLOCK){var oldUnsafeAllowed=context.isUnsafeAllowed;node.isUnsafe()&&(context.isUnsafeAllowed=!0),resolveChildren(context,node,node.scope),context.isUnsafeAllowed=oldUnsafeAllowed}else if(kind==node_1.NodeKind.IMPORTS||kind==node_1.NodeKind.CONSTANTS||kind==node_1.NodeKind.VARIABLES)resolveChildren(context,node,parentScope);else if(kind==node_1.NodeKind.ANY)node.kind=node_1.NodeKind.TYPE,node.resolvedType=context.anyType;else if(kind==node_1.NodeKind.INT32)node.resolvedType=node.intValue<0&&!node.isPositive()?context.uint32Type:context.int32Type;else if(kind==node_1.NodeKind.INT64)node.resolvedType=node.intValue<0&&!node.isPositive()?context.uint64Type:context.int64Type;else if(kind==node_1.NodeKind.FLOAT32)node.resolvedType=context.float32Type;else if(kind==node_1.NodeKind.FLOAT64)node.resolvedType=context.float64Type;else if(kind==node_1.NodeKind.STRING)node.resolvedType=context.stringType;else if(kind==node_1.NodeKind.BOOLEAN)node.resolvedType=context.booleanType;else if(kind==node_1.NodeKind.NULL)node.resolvedType=context.nullType;else if(kind==node_1.NodeKind.INDEX){resolveChildrenAsExpressions(context,node,parentScope);var target=node.indexTarget(),type=target.resolvedType;if(type!=context.errorType){var symbol=type.hasInstanceMembers()?type.findMember("[]",scope_1.ScopeHint.NORMAL):null;null==symbol?void 0!==target.resolvedType.pointerTo?(node.kind=node_1.NodeKind.POINTER_INDEX,node.resolvedType=target.resolvedType.pointerTo.symbol.resolvedType):context.log.error(node.internalRange,"Cannot index into type '"+target.resolvedType.toString()+"'"):(assert_1.assert(symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE||symbol.kind==symbol_1.SymbolKind.FUNCTION_GLOBAL&&symbol.shouldConvertInstanceToGlobal()),node.kind=node_1.NodeKind.CALL,target.remove(),node.insertChildBefore(node.firstChild,node_1.createMemberReference(target,symbol)),node.resolvedType=null,resolveAsExpression(context,node,parentScope))}}else if(kind==node_1.NodeKind.ALIGN_OF){var type=node.alignOfType();resolveAsType(context,type,parentScope),node.resolvedType=context.int32Type,type.resolvedType!=context.errorType&&node.becomeIntegerConstant(type.resolvedType.allocationAlignmentOf(context))}else if(kind==node_1.NodeKind.SIZE_OF){var type=node.sizeOfType();resolveAsType(context,type,parentScope),node.resolvedType=context.int32Type,type.resolvedType!=context.errorType&&node.becomeIntegerConstant(type.resolvedType.allocationSizeOf(context))}else if(kind==node_1.NodeKind.THIS){var symbol=parentScope.findNested("this",scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);null==symbol?context.log.error(node.range,"Cannot use 'this' here"):node.becomeSymbolReference(symbol)}else if(kind==node_1.NodeKind.PARSE_ERROR)node.resolvedType=context.errorType;else if(kind==node_1.NodeKind.NAME){var name=node.stringValue,symbol=parentScope.findNested(name,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);if(null==symbol){var errorMessage="No symbol named '"+name+"' here";symbol=parentScope.findNested(name,scope_1.ScopeHint.NORMAL,scope_1.FindNested.ALLOW_INSTANCE_ERRORS),null!=symbol?errorMessage+=", did you mean 'this."+symbol.name+"'?":"number"==name?errorMessage+=", you cannot use generic number type from TypeScript!":"bool"==name&&(errorMessage+=", did you mean 'boolean'?"),context.log.error(node.range,errorMessage)}else symbol.state==symbol_1.SymbolState.INITIALIZING?context.log.error(node.range,"Cyclic reference to symbol '"+name+"' here"):isSymbolAccessAllowed(context,symbol,node,node.range)&&(initializeSymbol(context,symbol),node.symbol=symbol,node.resolvedType=symbol.resolvedType,node.resolvedType.isGeneric()&&(node.flags|=node_1.NODE_FLAG_GENERIC),symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT&&(symbol.resolvedType==context.booleanType?node.becomeBooleanConstant(0!=symbol.offset):symbol.resolvedType==context.float32Type?node.becomeFloatConstant(symbol.offset):symbol.resolvedType==context.float64Type?node.becomeDoubleConstant(symbol.offset):symbol.resolvedType==context.int64Type?node.becomeLongConstant(symbol.offset):node.becomeIntegerConstant(symbol.offset)))}else if(kind==node_1.NodeKind.CAST){var value=node.castValue(),type=node.castType();resolveAsExpression(context,value,parentScope),resolveAsType(context,type,parentScope);var castedType=type.resolvedType;if(checkConversion(context,value,castedType,type_1.ConversionKind.EXPLICIT),node.resolvedType=castedType,value.kind==node_1.NodeKind.INT32&&castedType.isInteger()){var result=value.intValue,shift=32-castedType.integerBitCount(context);node.becomeIntegerConstant(castedType.isUnsigned()?castedType.integerBitMask(context)&result:result<>shift)}else value.kind==node_1.NodeKind.INT32&&castedType.isFloat()?node.becomeFloatConstant(value.intValue):value.kind==node_1.NodeKind.INT32&&castedType.isDouble()?node.becomeDoubleConstant(value.intValue):value.kind==node_1.NodeKind.FLOAT32&&castedType.isInteger()&&node.becomeIntegerConstant(Math.round(value.floatValue))}else if(kind==node_1.NodeKind.DOT){var target=node.dotTarget();if(resolve(context,target,parentScope),target.resolvedType!=context.errorType)if(target.isType()&&(target.resolvedType.isEnum()||target.resolvedType.hasInstanceMembers())||!target.isType()&&target.resolvedType.hasInstanceMembers()){var name=node.stringValue;if(name.length>0){var symbol=target.resolvedType.findMember(name,node.isAssignTarget()?scope_1.ScopeHint.PREFER_SETTER:scope_1.ScopeHint.PREFER_GETTER);if(null==symbol)context.log.error(node.internalRange,"No member named '"+name+"' on type '"+target.resolvedType.toString()+"'");else{if(symbol.isGetter())return void(node.parent.stringValue===node.stringValue&&node.parent.kind===node_1.NodeKind.CALL?(node.parent.resolvedType=null,node.symbol=symbol,node.resolvedType=symbol.resolvedType,resolveAsExpression(context,node.parent,parentScope)):(node.kind=node_1.NodeKind.CALL,node.appendChild(node_1.createMemberReference(target.remove(),symbol)),node.resolvedType=null,resolveAsExpression(context,node,parentScope)));isSymbolAccessAllowed(context,symbol,node,node.internalRange)&&(initializeSymbol(context,symbol),node.symbol=symbol,node.resolvedType=symbol.resolvedType,symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT&&node.becomeIntegerConstant(symbol.offset))}}}else context.log.error(node.internalRange,"The type '"+target.resolvedType.toString()+"' has no members")}else if(kind==node_1.NodeKind.CALL){var value=node.callValue();if(resolveAsExpression(context,value,parentScope),value.resolvedType!=context.errorType){var symbol=value.symbol;if(null!=symbol&&symbol_1.isFunction(symbol.kind)){if(initializeSymbol(context,symbol),symbol.shouldConvertInstanceToGlobal()){var name=node_1.createSymbolReference(symbol);node.insertChildBefore(value,name.withRange(value.internalRange)),node.insertChildBefore(value,value.dotTarget().remove()),value.remove(),value=name}for(var returnType=symbol.node.functionReturnType(),argumentVariable=symbol.node.functionFirstArgumentIgnoringThis(),argumentValue=value.nextSibling;argumentVariable!=returnType&&null!=argumentValue;)resolveAsExpression(context,argumentValue,parentScope),checkConversion(context,argumentValue,argumentVariable.symbol.resolvedType,type_1.ConversionKind.IMPLICIT),argumentVariable=argumentVariable.nextSibling,argumentValue=argumentValue.nextSibling;if(returnType.resolvedType!=context.anyType)if(argumentVariable==returnType||argumentVariable.hasVariableValue()){if(null!=argumentValue){for(;null!=argumentValue;)resolveAsExpression(context,argumentValue,parentScope),argumentValue=argumentValue.nextSibling;context.log.error(node.internalRange,"Too many arguments for function '"+symbol.name+"'")}}else context.log.error(node.internalRange,"Not enough arguments for function '"+symbol.name+"'");returnType.resolvedType.isArray()&&terminal_1.Terminal.write(returnType),node.resolvedType=returnType.resolvedType}else context.log.error(value.range,"Cannot call value of type '"+value.resolvedType.toString()+"'")}}else if(kind==node_1.NodeKind.DELETE){var value=node.deleteType();null!=value?(resolveAsExpression(context,value,parentScope),null!=value.resolvedType&&value.resolvedType!=context.voidType||context.log.error(value.range,"Unexpected delete value 'void'")):context.log.error(node.range,"Expected delete value '"+context.currentReturnType.toString()+"'")}else if(kind==node_1.NodeKind.RETURN){var value=node.returnValue();null!=value?(resolveAsExpression(context,value,parentScope),null!=context.currentReturnType&&(context.currentReturnType!=context.voidType?(value.resolvedType.isTemplate()&&value.hasParameters()&&node.parent!=value.resolvedType.symbol.node&&deriveConcreteClass(context,value,[value.firstChild.firstChild],value.resolvedType.symbol.scope),checkConversion(context,value,context.currentReturnType,type_1.ConversionKind.IMPLICIT)):context.log.error(value.range,"Unexpected return value in function returning 'void'")),node.parent.returnNode=node):null!=context.currentReturnType&&context.currentReturnType!=context.voidType&&context.log.error(node.range,"Expected return value in function returning '"+context.currentReturnType.toString()+"'")}else if(kind==node_1.NodeKind.EMPTY);else if(kind==node_1.NodeKind.PARAMETERS);else if(kind==node_1.NodeKind.EXTENDS)resolveAsType(context,node.extendsType(),parentScope);else if(kind==node_1.NodeKind.IMPLEMENTS){for(var child=node.firstChild;null!=child;)resolveAsType(context,child,parentScope),child=child.nextSibling;context.log.error(node.range,"Interfaces are not implemented yet")}else if(kind==node_1.NodeKind.EXPRESSION)resolveAsExpression(context,node.expressionValue(),parentScope);else if(kind==node_1.NodeKind.WHILE){var value=node.whileValue(),body=node.whileBody();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,body,parentScope)}else if(kind==node_1.NodeKind.IF){var value=node.ifValue(),yes=node.ifTrue(),no=node.ifFalse();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,yes,parentScope),null!=no&&resolve(context,no,parentScope)}else if(kind==node_1.NodeKind.HOOK){var value=node.hookValue(),yes=node.hookTrue(),no=node.hookFalse();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,yes,parentScope),resolve(context,no,parentScope),checkConversion(context,yes,no.resolvedType,type_1.ConversionKind.IMPLICIT);var commonType=(yes.resolvedType==context.nullType?no:yes).resolvedType;yes.resolvedType==commonType||yes.resolvedType==context.nullType&&commonType.isReference()||no.resolvedType==commonType||no.resolvedType==context.nullType&&commonType.isReference()||context.log.error(log_1.spanRanges(yes.range,no.range),"Type '"+yes.resolvedType.toString()+"' is not the same as type '"+no.resolvedType.toString()+"'"),node.resolvedType=commonType}else if(kind==node_1.NodeKind.ASSIGN){var left=node.binaryLeft(),right=node.binaryRight();if(left.kind==node_1.NodeKind.INDEX){resolveChildrenAsExpressions(context,left,parentScope);var target=left.indexTarget(),type=target.resolvedType;if(type!=context.errorType){var symbol=type.hasInstanceMembers()?type.findMember("[]=",scope_1.ScopeHint.NORMAL):null;if(null!=symbol){for(assert_1.assert(symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE),node.kind=node_1.NodeKind.CALL,target.remove(),left.remove();null!=left.lastChild;)node.insertChildBefore(node.firstChild,left.lastChild.remove());return node.insertChildBefore(node.firstChild,node_1.createMemberReference(target,symbol)),node.internalRange=log_1.spanRanges(left.internalRange,right.range),node.resolvedType=null,void resolveAsExpression(context,node,parentScope)}void 0!=target.resolvedType.pointerTo?(left.kind=node_1.NodeKind.POINTER_INDEX,left.resolvedType=target.resolvedType.pointerTo.symbol.resolvedType):context.log.error(left.internalRange,"Cannot index into type '"+target.resolvedType.toString()+"'")}}if(left.resolvedType||resolveAsExpression(context,left,parentScope),null!=left.symbol&&left.symbol.isSetter())return node.kind=node_1.NodeKind.CALL,node.internalRange=left.internalRange,node.resolvedType=null,void resolveAsExpression(context,node,parentScope);resolveAsExpression(context,right,parentScope),checkConversion(context,right,left.resolvedType,type_1.ConversionKind.IMPLICIT),checkStorage(context,left),node.resolvedType=left.resolvedType}else if(kind==node_1.NodeKind.NEW){compiler_1.Compiler.mallocRequired=!0;var type=node.newType();resolveAsType(context,type,parentScope),type.resolvedType.isTemplate()&&type.hasParameters()&&node.parent!=type.resolvedType.symbol.node&&deriveConcreteClass(context,type,[type.firstChild.firstChild],type.resolvedType.symbol.scope),type.resolvedType!=context.errorType&&(type.resolvedType.isClass()?node.resolvedType=type.resolvedType:context.log.error(type.range,"Cannot construct type '"+type.resolvedType.toString()+"'"));for(var child=type.nextSibling,constructorNode=node.constructorNode(),argumentVariable=constructorNode.functionFirstArgument();null!=child;)resolveAsExpression(context,child,parentScope),checkConversion(context,child,argumentVariable.symbol.resolvedType,type_1.ConversionKind.IMPLICIT),child=child.nextSibling,argumentVariable=argumentVariable.nextSibling}else if(kind==node_1.NodeKind.POINTER_TYPE){var value=node.unaryValue();if(resolveAsType(context,value,parentScope),context.target==compile_target_1.CompileTarget.JAVASCRIPT)context.log.error(node.internalRange,"Cannot use pointers when compiling to JavaScript");else{var type=value.resolvedType;type!=context.errorType&&(node.resolvedType=type.pointerType())}}else if(kind==node_1.NodeKind.POINTER_INDEX);else if(kind==node_1.NodeKind.DEREFERENCE){var value=node.unaryValue();resolveAsExpression(context,value,parentScope);var type=value.resolvedType;type!=context.errorType&&(null==type.pointerTo?context.log.error(node.internalRange,"Cannot dereference type '"+type.toString()+"'"):node.resolvedType=type.pointerTo)}else if(kind==node_1.NodeKind.ADDRESS_OF){var value=node.unaryValue();resolveAsExpression(context,value,parentScope),context.log.error(node.internalRange,"The address-of operator is not supported")}else if(node_1.isUnary(kind)){var value=node.unaryValue();if(resolveAsExpression(context,value,parentScope),kind==node_1.NodeKind.NOT)checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),node.resolvedType=context.booleanType;else if(value.resolvedType.isLong()){if(value.resolvedType.isUnsigned()?(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR,node.resolvedType=context.uint64Type):node.resolvedType=context.int64Type,value.kind==node_1.NodeKind.INT64){var input=value.longValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeLongConstant(output)}}else if(value.resolvedType.isInteger()){if(value.resolvedType.isUnsigned()?(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR,node.resolvedType=context.uint32Type):node.resolvedType=context.int32Type,value.kind==node_1.NodeKind.INT32){var input=value.intValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeIntegerConstant(output)}}else if(value.resolvedType.isDouble()){if(node.resolvedType=context.float64Type,value.kind==node_1.NodeKind.FLOAT64){var input=value.doubleValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeDoubleConstant(output)}}else if(value.resolvedType.isFloat()){if(node.resolvedType=context.float32Type,value.kind==node_1.NodeKind.FLOAT32){var input=value.floatValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeFloatConstant(output)}}else if(value.resolvedType!=context.errorType){var name=node.internalRange.toString(),symbol=value.resolvedType.findMember(name,scope_1.ScopeHint.NOT_BINARY);null!=symbol?(node.appendChild(node_1.createMemberReference(value.remove(),symbol).withRange(node.range).withInternalRange(node.internalRange)),node.kind=node_1.NodeKind.CALL,node.resolvedType=null,resolveAsExpression(context,node,parentScope)):context.log.error(node.internalRange,"Cannot use unary operator '"+name+"' with type '"+value.resolvedType.toString()+"'")}}else if(node_1.isBinary(kind)){var left=node.binaryLeft(),right=node.binaryRight();resolveAsExpression(context,left,parentScope),resolveAsExpression(context,right,parentScope);var leftType=left.resolvedType;(leftType.isDouble()&&right.resolvedType.isFloat()||leftType.isLong()&&right.resolvedType.isInteger())&&right.becomeTypeOf(left,context);var rightType=right.resolvedType;if(kind==node_1.NodeKind.LOGICAL_OR||kind==node_1.NodeKind.LOGICAL_AND)checkConversion(context,left,context.booleanType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,context.booleanType,type_1.ConversionKind.IMPLICIT),node.resolvedType=context.booleanType;else if(kind==node_1.NodeKind.ADD&&null!=leftType.pointerTo&&rightType.isInteger())node.resolvedType=leftType;else if(kind!=node_1.NodeKind.LESS_THAN&&kind!=node_1.NodeKind.LESS_THAN_EQUAL&&kind!=node_1.NodeKind.GREATER_THAN&&kind!=node_1.NodeKind.GREATER_THAN_EQUAL||null==leftType.pointerTo&&null==rightType.pointerTo){if((leftType.isInteger()||leftType.isLong()||leftType.isFloat()||leftType.isDouble()||leftType.isGeneric()&&rightType.isGeneric())&&kind!=node_1.NodeKind.EQUAL&&kind!=node_1.NodeKind.NOT_EQUAL){var isFloat=!1,isFloat64=!1;(leftType.isFloat()||leftType.isDouble())&&(isFloat=!0,isFloat64=leftType.isDouble());var isUnsigned=binaryHasUnsignedArguments(node);if(kind==node_1.NodeKind.ADD||kind==node_1.NodeKind.SUBTRACT||kind==node_1.NodeKind.MULTIPLY||kind==node_1.NodeKind.DIVIDE||kind==node_1.NodeKind.REMAINDER||kind==node_1.NodeKind.BITWISE_AND||kind==node_1.NodeKind.BITWISE_OR||kind==node_1.NodeKind.BITWISE_XOR||kind==node_1.NodeKind.SHIFT_LEFT||kind==node_1.NodeKind.SHIFT_RIGHT){var isLong=isBinaryLong(node),commonType=void 0;if(commonType=isFloat?isBinaryDouble(node)?context.float64Type:context.float32Type:isUnsigned?isLong?context.uint64Type:context.uint32Type:isLong?context.int64Type:context.int32Type,isUnsigned&&(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR),checkConversion(context,left,commonType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,commonType,type_1.ConversionKind.IMPLICIT),node.resolvedType=commonType,commonType==context.int64Type&&(left.kind==node_1.NodeKind.INT32?(left.kind=node_1.NodeKind.INT64,left.resolvedType=context.int64Type):right.kind==node_1.NodeKind.INT32&&(right.kind=node_1.NodeKind.INT64,right.resolvedType=context.int64Type)),left.kind!=node_1.NodeKind.INT32&&left.kind!=node_1.NodeKind.INT64||right.kind!=node_1.NodeKind.INT32&&right.kind!=node_1.NodeKind.INT64)if(left.kind!=node_1.NodeKind.FLOAT32&&left.kind!=node_1.NodeKind.FLOAT64||right.kind!=node_1.NodeKind.FLOAT32&&right.kind!=node_1.NodeKind.FLOAT64)simplifyBinary(node);else{var inputLeft=left.floatValue,inputRight=right.floatValue,output=0;if(kind==node_1.NodeKind.ADD)output=inputLeft+inputRight;else if(kind==node_1.NodeKind.BITWISE_AND)output=inputLeft&inputRight;else if(kind==node_1.NodeKind.BITWISE_OR)output=inputLeft|inputRight;else if(kind==node_1.NodeKind.BITWISE_XOR)output=inputLeft^inputRight;else if(kind==node_1.NodeKind.DIVIDE)output=inputLeft/inputRight;else if(kind==node_1.NodeKind.MULTIPLY)output=inputLeft*inputRight;else if(kind==node_1.NodeKind.REMAINDER)output=inputLeft%inputRight;else if(kind==node_1.NodeKind.SHIFT_LEFT)output=inputLeft<>inputRight;else{if(kind!=node_1.NodeKind.SUBTRACT)return;output=inputLeft-inputRight}left.kind==node_1.NodeKind.FLOAT32?node.becomeFloatConstant(output):node.becomeDoubleConstant(output)}else{var inputLeft=left.intValue,inputRight=right.intValue,output=0;if(kind==node_1.NodeKind.ADD)output=inputLeft+inputRight;else if(kind==node_1.NodeKind.BITWISE_AND)output=inputLeft&inputRight;else if(kind==node_1.NodeKind.BITWISE_OR)output=inputLeft|inputRight;else if(kind==node_1.NodeKind.BITWISE_XOR)output=inputLeft^inputRight;else if(kind==node_1.NodeKind.DIVIDE)output=inputLeft/inputRight;else if(kind==node_1.NodeKind.MULTIPLY)output=inputLeft*inputRight;else if(kind==node_1.NodeKind.REMAINDER)output=inputLeft%inputRight;else if(kind==node_1.NodeKind.SHIFT_LEFT)output=inputLeft<>inputRight;else{if(kind!=node_1.NodeKind.SUBTRACT)return;output=inputLeft-inputRight}left.kind==node_1.NodeKind.INT32?node.becomeIntegerConstant(output):node.becomeLongConstant(output)}}else if(kind==node_1.NodeKind.LESS_THAN||kind==node_1.NodeKind.LESS_THAN_EQUAL||kind==node_1.NodeKind.GREATER_THAN||kind==node_1.NodeKind.GREATER_THAN_EQUAL){var expectedType=isFloat?isFloat64?context.float64Type:context.float32Type:isUnsigned?context.uint32Type:context.int32Type;isUnsigned&&(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR),leftType!=rightType&&(checkConversion(context,left,expectedType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,expectedType,type_1.ConversionKind.IMPLICIT)),node.resolvedType=context.booleanType}else context.log.error(node.internalRange,"This operator is not currently supported")}else if(leftType!=context.errorType){var name=node.internalRange.toString(),symbol=leftType.findMember(kind==node_1.NodeKind.NOT_EQUAL?"==":kind==node_1.NodeKind.LESS_THAN_EQUAL?">":kind==node_1.NodeKind.GREATER_THAN_EQUAL?"<":name,scope_1.ScopeHint.NOT_UNARY);if(null!=symbol){if(left=node_1.createMemberReference(left.remove(),symbol).withRange(node.range).withInternalRange(node.internalRange),right.remove(),kind==node_1.NodeKind.NOT_EQUAL||kind==node_1.NodeKind.LESS_THAN_EQUAL||kind==node_1.NodeKind.GREATER_THAN_EQUAL){var call=node_1.createCall(left);call.appendChild(right),node.kind=node_1.NodeKind.NOT,node.appendChild(call.withRange(node.range).withInternalRange(node.range))}else node.appendChild(left),node.appendChild(right),node.kind=node_1.NodeKind.CALL;node.resolvedType=null,resolveAsExpression(context,node,parentScope)}else kind==node_1.NodeKind.EQUAL||kind==node_1.NodeKind.NOT_EQUAL?(node.resolvedType=context.booleanType,leftType==context.errorType||rightType==context.errorType||leftType==rightType||canConvert(context,right,leftType,type_1.ConversionKind.IMPLICIT)||canConvert(context,left,rightType,type_1.ConversionKind.IMPLICIT)||context.log.error(node.internalRange,"Cannot compare type '"+leftType.toString()+"' with type '"+rightType.toString()+"'")):context.log.error(node.internalRange,"Cannot use binary operator '"+name+"' with type '"+leftType.toString()+"'")}}else node.resolvedType=context.booleanType,leftType!=rightType&&context.log.error(node.internalRange,"Cannot compare type '"+leftType.toString()+"' with type '"+rightType.toString()+"'")}else kind==node_1.NodeKind.TYPE||(terminal_1.Terminal.error("Unexpected kind: "+node_1.NodeKind[kind]),assert_1.assert(!1))}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(7),type_1=__webpack_require__(31),node_1=__webpack_require__(10),compile_target_1=__webpack_require__(9),log_1=__webpack_require__(5),scope_1=__webpack_require__(30),utils_1=__webpack_require__(8),const_1=__webpack_require__(69),assert_1=__webpack_require__(3),compiler_1=__webpack_require__(18),terminal_1=__webpack_require__(2),CheckContext=function(){function CheckContext(){}return CheckContext.prototype.allocateGlobalVariableOffset=function(sizeOf,alignmentOf){var offset=utils_1.alignToNextMultipleOf(this.nextGlobalVariableOffset,alignmentOf);return this.nextGlobalVariableOffset=offset+sizeOf,offset},CheckContext}();exports.CheckContext=CheckContext,exports.addScopeToSymbol=addScopeToSymbol,exports.linkSymbolToNode=linkSymbolToNode;var CheckMode;!function(CheckMode){CheckMode[CheckMode.NORMAL=0]="NORMAL",CheckMode[CheckMode.INITIALIZE=1]="INITIALIZE"}(CheckMode=exports.CheckMode||(exports.CheckMode={})),exports.initialize=initialize,exports.forbidFlag=forbidFlag,exports.requireFlag=requireFlag,exports.initializeSymbol=initializeSymbol,exports.resolveChildren=resolveChildren,exports.resolveChildrenAsExpressions=resolveChildrenAsExpressions,exports.resolveAsExpression=resolveAsExpression,exports.resolveAsType=resolveAsType,exports.canConvert=canConvert,exports.checkConversion=checkConversion,exports.checkStorage=checkStorage,exports.createDefaultValueForType=createDefaultValueForType,exports.simplifyBinary=simplifyBinary,exports.binaryHasUnsignedArguments=binaryHasUnsignedArguments,exports.isBinaryLong=isBinaryLong,exports.isBinaryDouble=isBinaryDouble,exports.isSymbolAccessAllowed=isSymbolAccessAllowed,exports.resolve=resolve},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var compile_target_1=__webpack_require__(9);exports.defaultCompilerOptions={target:compile_target_1.CompileTarget.WEBASSEMBLY,silent:!0,logError:!0}},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MIN_INT32_VALUE=-Math.pow(2,31),exports.MAX_INT32_VALUE=Math.pow(2,31)-1,exports.MIN_UINT32_VALUE=0,exports.MAX_UINT32_VALUE=Math.pow(2,32)-1,exports.MIN_INT64_VALUE=-Math.pow(2,63),exports.MAX_INT64_VALUE=Math.pow(2,63)-1,exports.MIN_UINT64_VALUE=0,exports.MAX_UINT64_VALUE=Math.pow(2,64)-1},function(module,exports,__webpack_require__){"use strict";function treeShakingMarkAllUsed(node){var symbol=node.symbol;if(null==symbol||symbol.isUsed()||!symbol_1.isFunction(symbol.kind)||null==symbol.node||(symbol.flags=symbol.flags|symbol_1.SYMBOL_FLAG_USED,treeShakingMarkAllUsed(symbol.node),node!=symbol.node)){if(node.kind==node_1.NodeKind.NEW){var type=node.newType().resolvedType;null!=type.symbol&&(type.symbol.flags|=symbol_1.SYMBOL_FLAG_USED,type.symbol.node.constructorFunctionNode.symbol.flags=symbol_1.SYMBOL_FLAG_USED)}for(var child=node.firstChild;null!=child;)treeShakingMarkAllUsed(child),child=child.nextSibling}}function treeShakingSearchForUsed(node){if(node.kind==node_1.NodeKind.FUNCTION&&(node.isExport()||node.isStart())){if(("malloc"===node.symbol.name||"free"===node.symbol.name)&&!compiler_1.Compiler.mallocRequired)return;treeShakingMarkAllUsed(node)}else if(node.kind==node_1.NodeKind.GLOBAL||node.kind==node_1.NodeKind.CLASS){for(var child=node.firstChild;null!=child;)treeShakingSearchForUsed(child),child=child.nextSibling;node.kind==node_1.NodeKind.CLASS&&node.isExport()&&(node.symbol.flags=node.symbol.flags|symbol_1.SYMBOL_FLAG_USED)}}function treeShakingRemoveUnused(node){if(node.kind==node_1.NodeKind.FUNCTION&&!node.symbol.isUsed()&&node.range.source.isLibrary)node.remove();else if(node.kind==node_1.NodeKind.GLOBAL||node.kind==node_1.NodeKind.CLASS){for(var child=node.firstChild;null!=child;){var next=child.nextSibling;treeShakingRemoveUnused(child),child=next}node.kind!=node_1.NodeKind.CLASS||node.symbol.isUsed()||node.isDeclare()||!node.range.source.isLibrary||node.remove()}}function treeShaking(node){treeShakingSearchForUsed(node),treeShakingRemoveUnused(node)}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(7),node_1=__webpack_require__(10),compiler_1=__webpack_require__(18);exports.treeShakingMarkAllUsed=treeShakingMarkAllUsed,exports.treeShakingSearchForUsed=treeShakingSearchForUsed,exports.treeShakingRemoveUnused=treeShakingRemoveUnused,exports.treeShaking=treeShaking},function(module,exports,__webpack_require__){"use strict";function preparse(source,compiler,log){env_1.isNode&&(source.name=path.resolve(source.name));for(var imports,contents=source.contents,limit=contents.length,pathSeparator=source.name.indexOf("/")>-1?"/":source.name.indexOf("\\")>-1?"\\":"/",basePath=source.name.substring(0,source.name.lastIndexOf(pathSeparator)),wantNewline=!1,captureImports=!1,captureImportFrom=!1,captureImportPath=!1,i=0;i=2&&length<=10){var text=contents.slice(start,i);"import"==text?(captureImports=!0,captureImportFrom=!0):"from"==text&&captureImportFrom&&(captureImportFrom=!1,captureImportPath=!0)}}else if(captureImports&&"{"==c){captureImports=!1,imports=[];for(var nextImportIndex=start;i0?",":"",_this.declaration+="param"+i+":"+index_1.wasmToTurboType(type)}),this.declaration+="):"+index_1.wasmToTurboType(signature.returnType)+";"}return WasmBinaryImport}();exports.WasmBinaryImport=WasmBinaryImport},function(module,exports,__webpack_require__){"use strict";function __export(m){for(var p in m)exports.hasOwnProperty(p)||(exports[p]=m[p])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(__webpack_require__(34)),__export(__webpack_require__(9)),__export(__webpack_require__(5))},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var compile_target_1=__webpack_require__(9),filesystem_1=__webpack_require__(15),math=__webpack_require__(39),types=__webpack_require__(40),array=__webpack_require__(37),jstypes=__webpack_require__(42),runtime=__webpack_require__(41),wrapper=__webpack_require__(43),malloc=__webpack_require__(38),dlmallocBin=__webpack_require__(35),builtins=__webpack_require__(44),initializer=__webpack_require__(45);filesystem_1.FileSystem.writeBinaryFile("/library/dlmalloc.wasm",dlmallocBin,!0);var Library=function(){function Library(){}return Library.get=function(target){var lib;switch(target){case compile_target_1.CompileTarget.JAVASCRIPT:lib=jstypes+"\n";break;case compile_target_1.CompileTarget.WEBASSEMBLY:lib=[types,initializer,builtins,math,malloc,array].join("\n")}return lib},Library.getRuntime=function(target){switch(target){case compile_target_1.CompileTarget.JAVASCRIPT:return runtime+"\n";default:return""}},Library.getWrapper=function(target){switch(target){case compile_target_1.CompileTarget.JAVASCRIPT:return wrapper+"\n";default:return""}},Library}();exports.Library=Library},function(module,exports){module.exports=require("fs")},function(module,exports){module.exports=require("path")}])}); \ No newline at end of file +!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory(require("fs"),require("path")):"function"==typeof define&&define.amd?define(["fs","path"],factory):"object"==typeof exports?exports.turboscript=factory(require("fs"),require("path")):root.turboscript=factory(root.fs,root.path)}(this,function(__WEBPACK_EXTERNAL_MODULE_76__,__WEBPACK_EXTERNAL_MODULE_77__){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=74)}([function(module,exports,__webpack_require__){"use strict";function ByteArray_set16(array,index,value){array.set(index,value),array.set(index+1,value>>8)}function ByteArray_set32(array,index,value){array.set(index,value),array.set(index+1,value>>8),array.set(index+2,value>>16),array.set(index+3,value>>24)}function ByteArray_append32(array,value){array.append(value),array.append(value>>8),array.append(value>>16),array.append(value>>24)}function ByteArray_setString(data,index,text){var length=text.length;assert_1.assert(index>=0&&index+2*length<=data.length);for(var array=data.array,i=0;i>8,index+=2,i+=1}}Object.defineProperty(exports,"__esModule",{value:!0});var assert_1=__webpack_require__(3),utils_1=__webpack_require__(8);exports.ByteArray_set16=ByteArray_set16,exports.ByteArray_set32=ByteArray_set32,exports.ByteArray_append32=ByteArray_append32,exports.ByteArray_setString=ByteArray_setString;var ByteArray=function(){function ByteArray(buffer,byteOffset,byteLength){void 0===byteOffset&&(byteOffset=0),void 0===byteLength&&(byteLength=0),this.BUFFER_EXT_SIZE=1024,this._array=null,this.log="",this.EOF_byte=-1,this.EOF_code_point=-1,void 0==buffer?(buffer=new ArrayBuffer(this.BUFFER_EXT_SIZE),this.write_position=0):this.write_position=null==buffer?0:byteLength>0?byteLength:buffer.byteLength,buffer&&(this.data=new DataView(buffer,byteOffset,byteLength>0?byteLength:buffer.byteLength),this._array=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength)),this._position=0,this.endian=ByteArray.LITTLE_ENDIAN}return Object.defineProperty(ByteArray.prototype,"array",{get:function(){return this._array.subarray(0,this.length)},enumerable:!0,configurable:!0}),ByteArray.prototype.get=function(index){return this._array[index]},ByteArray.prototype.set=function(index,value){this._array[index]=value},ByteArray.prototype.append=function(value){var index=this.position;return this.resize(index+1),this._array[index]=value,this.position++,index},ByteArray.prototype.resize=function(length){if(length>this.data.byteLength){var pos=this.position,len=this.length,capacity=2*length,data=new Uint8Array(capacity);data.set(this.array),this.setArray(data),this._position=pos,this.write_position=len}return this},ByteArray.prototype.copy=function(source,offset,length){return void 0===offset&&(offset=0),void 0===length&&(length=0),offset=offset>0?offset:this.length,offset+source.length>this._array.length&&this.resize(offset+source.length),this._array.set(source.array,offset),this.position=offset+source.length,this},Object.defineProperty(ByteArray.prototype,"buffer",{get:function(){return this.data.buffer},set:function(value){this.data=new DataView(value)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"dataView",{get:function(){return this.data},set:function(value){this.data=value,this.write_position=value.byteLength},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"phyPosition",{get:function(){return this._position+this.data.byteOffset},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"byteOffset",{get:function(){return this.data.byteOffset},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"byteLength",{get:function(){return this.data.byteLength},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"position",{get:function(){return this._position},set:function(value){this._positionthis.write_position?value:this.write_position)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"length",{get:function(){return this.write_position},set:function(value){this.validateBuffer(value)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"bytesAvailable",{get:function(){return this.data.byteLength-this._position},enumerable:!0,configurable:!0}),ByteArray.prototype.clear=function(){this._position=0},ByteArray.prototype.setArray=function(array){this._array=array,this.setBuffer(array.buffer,array.byteOffset,array.byteLength)},ByteArray.prototype.setBuffer=function(buffer,offset,length){void 0===offset&&(offset=0),void 0===length&&(length=0),buffer&&(this.data=new DataView(buffer,offset,length>0?length:buffer.byteLength))},ByteArray.prototype.readU8LEB=function(){return this.readUnsignedLEB128(1)},ByteArray.prototype.readU16LEB=function(){return this.readUnsignedLEB128(2)},ByteArray.prototype.readU32LEB=function(){return this.readUnsignedLEB128(4)},ByteArray.prototype.readU64LEB=function(){return this.readUnsignedLEB128(8)},ByteArray.prototype.readS8LEB=function(){return this.readLEB128(1)},ByteArray.prototype.readS16LEB=function(){return this.readLEB128(2)},ByteArray.prototype.readS32LEB=function(){return this.readLEB128(4)},ByteArray.prototype.readS64LEB=function(){return this.readLEB128(8)},ByteArray.prototype.readUnsignedLEB128=function(size){for(var byte,value=0,shift=0;;){byte=this.readUnsignedByte();var last=!(128&byte),payload=127&byte,shift_mask=0==shift?-1:(1<<8*size-shift)-1,significant_payload=payload&shift_mask;if(significant_payload!=payload&&!(value<0&&last))throw"LEB dropped bits only valid for signed LEB";if(value|=significant_payload<=8*size)throw"LEB overflow"}return value},ByteArray.prototype.readLEB128=function(size){for(var byte,value=0,shift=0,sizeOfShift=0;;){byte=this.readByte();var last=!(128&byte),payload=127&byte,shift_mask=0==shift?-1:(1<<8*size-shift)-1,significant_payload=payload&shift_mask;if(!(significant_payload==payload||utils_1.isSigned(value)&&last))throw"LEB dropped bits only valid for signed LEB";if(value|=significant_payload<=8*size)throw"LEB overflow"}if(utils_1.isSigned(value)&&(shift+=7,sizeOfShift=utils_1.sizeOfNumber(shift),64&byte&&sizeOfShift<8*size)){var sext_bits=8*size-sizeOfShift;if(value<<=sext_bits,(value>>=sext_bits)>=0)throw"LEB sign-extend should produce a negative value"}return value},ByteArray.prototype.writeUnsignedLEB128=function(value){var b=0;value|=0;do{b=127&value,value>>>=7,value&&(b|=128),this.append(b)}while(value)},ByteArray.prototype.writeLEB128=function(value){var b;for(value|=0;;){b=127&value,value>>=7;var signBit=0!=(64&b);if(0===value&&!signBit||-1===value&&signBit){this.append(b);break}b|=128,this.append(b)}},ByteArray.prototype.readWasmString=function(){var length=this.readUnsignedLEB128(4);return this.readUTFBytes(length)},ByteArray.prototype.writeWasmString=function(value){var length=value.length;this.writeUnsignedLEB128(length);var index=this.length;this.resize(index+length);for(var i=0;i0?this.readUTFBytes(length):""},ByteArray.prototype.readUTFBytes=function(length){if(!this.validate(length))return null;var _bytes=new Uint8Array(this.buffer,this.byteOffset+this.position,length);return this.position+=length,this.decodeUTF8(_bytes)},ByteArray.prototype.readStandardString=function(length){if(!this.validate(length))return null;for(var str="",i=0;i0;){var _byte=this.data.getUint8(this.position++);if(num++,0==_byte){keepEvenByte&&num%2!=0&&this.position++;break}str+=String.fromCharCode(_byte)}return str},ByteArray.prototype.writeBoolean=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_BOOLEAN,offset),this.data.setUint8(offset,value?1:0)},ByteArray.prototype.writeByte=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_INT8,offset),this.data.setInt8(offset,value)},ByteArray.prototype.writeUnsignedByte=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_UINT8,offset),this.data.setUint8(offset,value)},ByteArray.prototype.writeBytes=function(_bytes,offset,length){void 0===offset&&(offset=0),void 0===length&&(length=0),this.copy(_bytes)},ByteArray.prototype.writeDouble=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_FLOAT64,position),this.data.setFloat64(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_FLOAT64)},ByteArray.prototype.writeFloat=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_FLOAT32,position),this.data.setFloat32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_FLOAT32)},ByteArray.prototype.writeInt=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_INT32,position),this.data.setInt32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_INT32)},ByteArray.prototype.writeMultiByte=function(value,charSet){},ByteArray.prototype.writeShort=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_INT16,position),this.data.setInt16(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_INT16)},ByteArray.prototype.writeUnsignedShort=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT16,position),this.data.setUint16(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_UINT16)},ByteArray.prototype.writeUnsignedInt=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT32,position),this.data.setUint32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_UINT32)},ByteArray.prototype.writeUTF=function(value,offset){void 0===offset&&(offset=null);var utf8bytes=this.encodeUTF8(value),length=utf8bytes.length,position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT16+length,position),this.data.setUint16(position,length,this.endian===ByteArray.LITTLE_ENDIAN),offset?(offset+=ByteArray.SIZE_OF_UINT16,this.writeUint8Array(utf8bytes,offset)):(this.position+=ByteArray.SIZE_OF_UINT16,this.writeUint8Array(utf8bytes))},ByteArray.prototype.writeUTFBytes=function(value,offset){void 0===offset&&(offset=null),this.writeUint8Array(this.encodeUTF8(value),offset)},ByteArray.prototype.toString=function(){return"[ByteArray] length:"+this.length+", bytesAvailable:"+this.bytesAvailable},ByteArray.prototype.writeUint8Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;return this.validateBuffer(_bytes.length,position),this._array.set(_bytes,position),offset||(this.position+=_bytes.length),this},ByteArray.prototype.writeUint16Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_UINT16,position);for(var i=0;i<_bytes.length;i++)this.data.setUint16(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_UINT16;offset||(this.position=position)},ByteArray.prototype.writeUint32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_UINT32,position);for(var i=0;i<_bytes.length;i++)this.data.setUint32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_UINT32;offset||(this.position=position)},ByteArray.prototype.writeInt8Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length,position);for(var i=0;i<_bytes.length;i++)this.data.setInt8(position++,_bytes[i]);offset||(this.position=position)},ByteArray.prototype.writeInt16Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_INT16,position);for(var i=0;i<_bytes.length;i++)this.data.setInt16(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_INT16;offset||(this.position=position)},ByteArray.prototype.writeInt32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_INT32,position);for(var i=0;i<_bytes.length;i++)this.data.setInt32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_INT32;offset||(this.position=position)},ByteArray.prototype.writeFloat32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_FLOAT32,position);for(var i=0;i<_bytes.length;i++)this.data.setFloat32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_FLOAT32;offset||(this.position=position)},ByteArray.prototype.writeFloat64Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length,position);for(var i=0;i<_bytes.length;i++)this.data.setFloat64(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_FLOAT64;offset||(this.position=position)},ByteArray.prototype.readUint8Array=function(length,createNewBuffer){if(void 0===createNewBuffer&&(createNewBuffer=!0),!this.validate(length))return null;if(createNewBuffer){result=new Uint8Array(new ArrayBuffer(length));for(var i=0;i0&&this._position+len<=this.data.byteLength)return!0;throw"Error #2030: End of file was encountered."},ByteArray.prototype.validateBuffer=function(size,offset){void 0===offset&&(offset=0);var length=offset+size;this.resize(length)},ByteArray.prototype.encodeUTF8=function(str){for(var pos=0,codePoints=this.stringToCodePoints(str),outputBytes=[];codePoints.length>pos;){var code_point=codePoints[pos++];if(this.inRange(code_point,55296,57343))this.encoderError(code_point);else if(this.inRange(code_point,0,127))outputBytes.push(code_point);else{var count,offset;for(this.inRange(code_point,128,2047)?(count=1,offset=192):this.inRange(code_point,2048,65535)?(count=2,offset=224):this.inRange(code_point,65536,1114111)&&(count=3,offset=240),outputBytes.push(this.div(code_point,Math.pow(64,count))+offset);count>0;){var temp=this.div(code_point,Math.pow(64,count-1));outputBytes.push(128+temp%64),count-=1}}}return new Uint8Array(outputBytes)},ByteArray.prototype.decodeUTF8=function(data){for(var code_point,pos=0,result="",utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0;data.length>pos;){var _byte=data[pos++];if(_byte===this.EOF_byte)code_point=0!==utf8_bytes_needed?this.decoderError(!1):this.EOF_code_point;else if(0===utf8_bytes_needed)this.inRange(_byte,0,127)?code_point=_byte:(this.inRange(_byte,194,223)?(utf8_bytes_needed=1,utf8_lower_boundary=128,utf8_code_point=_byte-192):this.inRange(_byte,224,239)?(utf8_bytes_needed=2,utf8_lower_boundary=2048,utf8_code_point=_byte-224):this.inRange(_byte,240,244)?(utf8_bytes_needed=3,utf8_lower_boundary=65536,utf8_code_point=_byte-240):this.decoderError(!1),utf8_code_point*=Math.pow(64,utf8_bytes_needed),code_point=null);else if(this.inRange(_byte,128,191))if(utf8_bytes_seen+=1,utf8_code_point+=(_byte-128)*Math.pow(64,utf8_bytes_needed-utf8_bytes_seen),utf8_bytes_seen!==utf8_bytes_needed)code_point=null;else{var cp=utf8_code_point,lower_boundary=utf8_lower_boundary;utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0,code_point=this.inRange(cp,lower_boundary,1114111)&&!this.inRange(cp,55296,57343)?cp:this.decoderError(!1,_byte)}else utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0,pos--,code_point=this.decoderError(!1,_byte);null!==code_point&&code_point!==this.EOF_code_point&&(code_point<=65535?code_point>0&&(result+=String.fromCharCode(code_point)):(code_point-=65536,result+=String.fromCharCode(55296+(code_point>>10&1023)),result+=String.fromCharCode(56320+(1023&code_point))))}return result},ByteArray.prototype.encoderError=function(code_point){throw"EncodingError! The code point "+code_point+" could not be encoded."},ByteArray.prototype.decoderError=function(fatal,opt_code_point){if(fatal)throw"DecodingError";return opt_code_point||65533},ByteArray.prototype.inRange=function(a,min,max){return min<=a&&a<=max},ByteArray.prototype.div=function(n,d){return Math.floor(n/d)},ByteArray.prototype.stringToCodePoints=function(string){for(var cps=[],i=0,n=string.length;i57343)&&(column+=1),i+=1}var location=new LineColumn;return location.line=line,location.column=column,location},Source}();exports.Source=Source;var SourceRange=function(){function SourceRange(){}return SourceRange.prototype.toString=function(){return this.source.contents.slice(this.start,this.end)},SourceRange.prototype.equals=function(other){return this.source==other.source&&this.start==other.start&&this.end==other.end},SourceRange.prototype.enclosingLine=function(){for(var contents=this.source.contents,start=this.start,end=this.start;start>0&&"\n"!=contents[start-1];)start-=1;for(var length=contents.length;end0;)rangeStr+=" ",column-=1;if(range.end-range.start<=1)rangeStr+="^";else for(var i=range.start;i=SymbolKind.TYPE_CLASS&&kind<=SymbolKind.TYPE_NATIVE}function isFunction(kind){return kind>=SymbolKind.FUNCTION_INSTANCE&&kind<=SymbolKind.FUNCTION_GLOBAL}function isVariable(kind){return kind>=SymbolKind.VARIABLE_ARGUMENT&&kind<=SymbolKind.VARIABLE_LOCAL}Object.defineProperty(exports,"__esModule",{value:!0});var SymbolKind,node_1=__webpack_require__(10),utils_1=__webpack_require__(8),assert_1=__webpack_require__(3);!function(SymbolKind){SymbolKind[SymbolKind.TYPE_MODULE=0]="TYPE_MODULE",SymbolKind[SymbolKind.TYPE_INTERFACE=1]="TYPE_INTERFACE",SymbolKind[SymbolKind.TYPE_CLASS=2]="TYPE_CLASS",SymbolKind[SymbolKind.TYPE_GENERIC=3]="TYPE_GENERIC",SymbolKind[SymbolKind.TYPE_TEMPLATE=4]="TYPE_TEMPLATE",SymbolKind[SymbolKind.TYPE_ENUM=5]="TYPE_ENUM",SymbolKind[SymbolKind.TYPE_GLOBAL=6]="TYPE_GLOBAL",SymbolKind[SymbolKind.TYPE_NATIVE=7]="TYPE_NATIVE",SymbolKind[SymbolKind.FUNCTION_INSTANCE=8]="FUNCTION_INSTANCE",SymbolKind[SymbolKind.FUNCTION_GLOBAL=9]="FUNCTION_GLOBAL",SymbolKind[SymbolKind.VARIABLE_ARGUMENT=10]="VARIABLE_ARGUMENT",SymbolKind[SymbolKind.VARIABLE_CONSTANT=11]="VARIABLE_CONSTANT",SymbolKind[SymbolKind.VARIABLE_GLOBAL=12]="VARIABLE_GLOBAL",SymbolKind[SymbolKind.VARIABLE_INSTANCE=13]="VARIABLE_INSTANCE",SymbolKind[SymbolKind.VARIABLE_LOCAL=14]="VARIABLE_LOCAL"}(SymbolKind=exports.SymbolKind||(exports.SymbolKind={})),exports.isModule=isModule,exports.isType=isType,exports.isFunction=isFunction,exports.isVariable=isVariable;var SymbolState;!function(SymbolState){SymbolState[SymbolState.UNINITIALIZED=0]="UNINITIALIZED",SymbolState[SymbolState.INITIALIZING=1]="INITIALIZING",SymbolState[SymbolState.INITIALIZED=2]="INITIALIZED"}(SymbolState=exports.SymbolState||(exports.SymbolState={})),exports.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL=1,exports.SYMBOL_FLAG_IS_BINARY_OPERATOR=2,exports.SYMBOL_FLAG_IS_REFERENCE=4,exports.SYMBOL_FLAG_IS_UNARY_OPERATOR=8,exports.SYMBOL_FLAG_IS_UNSIGNED=16,exports.SYMBOL_FLAG_NATIVE_INTEGER=32,exports.SYMBOL_FLAG_NATIVE_LONG=64,exports.SYMBOL_FLAG_NATIVE_FLOAT=128,exports.SYMBOL_FLAG_NATIVE_DOUBLE=256,exports.SYMBOL_FLAG_USED=512,exports.SYMBOL_FLAG_IS_ARRAY=1024,exports.SYMBOL_FLAG_IS_GENERIC=2048,exports.SYMBOL_FLAG_IS_TEMPLATE=4096;var Symbol=function(){function Symbol(){this.state=SymbolState.UNINITIALIZED,this.byteSize=0,this.maxAlignment=0}return Object.defineProperty(Symbol.prototype,"internalName",{get:function(){return null!=this.rename?this.rename:this.name},enumerable:!0,configurable:!0}),Symbol.prototype.clone=function(){var symbol=new Symbol;return symbol.kind=this.kind,symbol.name=this.name,symbol.node=this.node,symbol.range=this.range,symbol.scope=this.scope,symbol.resolvedType=this.resolvedType,symbol.byteSize=this.byteSize,symbol.state=this.state,symbol.maxAlignment=this.maxAlignment,symbol.flags=this.flags,symbol.rename=this.rename,symbol},Symbol.prototype.isEnumValue=function(){return this.node.parent.kind==node_1.NodeKind.ENUM},Symbol.prototype.isUnsafe=function(){return null!=this.node&&this.node.isUnsafe()},Symbol.prototype.isGetter=function(){return this.node.isGet()},Symbol.prototype.isSetter=function(){return this.node.isSet()},Symbol.prototype.isBinaryOperator=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_IS_BINARY_OPERATOR)},Symbol.prototype.isUnaryOperator=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_IS_UNARY_OPERATOR)},Symbol.prototype.shouldConvertInstanceToGlobal=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL)},Symbol.prototype.isUsed=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_USED)},Symbol.prototype.parent=function(){var parent=this.node.parent;return parent.kind==node_1.NodeKind.CLASS?parent.symbol:null},Symbol.prototype.resolvedTypeUnderlyingIfEnumValue=function(context){return this.isEnumValue()?this.resolvedType.underlyingType(context):this.resolvedType},Symbol.prototype.determineClassLayout=function(context){if(assert_1.assert(this.kind==SymbolKind.TYPE_CLASS),0==this.byteSize){for(var offset=0,child=this.node.firstChild,maxAlignment=1;null!=child;){if(child.kind==node_1.NodeKind.VARIABLE){var type=child.symbol.resolvedType;if(type!=context.errorType){var alignmentOf=type.variableAlignmentOf(context);offset=utils_1.alignToNextMultipleOf(offset,alignmentOf),alignmentOf>maxAlignment&&(maxAlignment=alignmentOf),child.symbol.offset=offset,offset+=type.variableSizeOf(context)}}child=child.nextSibling}0==offset&&(offset=1),offset=utils_1.alignToNextMultipleOf(offset,maxAlignment),this.byteSize=offset,this.maxAlignment=maxAlignment}},Symbol}();exports.Symbol=Symbol},function(module,exports,__webpack_require__){"use strict";function toHex(value,size){if(void 0===size&&(size=7),void 0==value||null==value)return"";for(var hex=value.toString(16),zero=[],i=0;i0&&0==(value&value-1)}function alignToNextMultipleOf(offset,alignment){return assert_1.assert(isPositivePowerOf2(alignment)),offset+alignment-1&-alignment}function sizeOfNumber(value){return value.toString(2).length/8}function isSigned(value){return value<0}Object.defineProperty(exports,"__esModule",{value:!0});var assert_1=__webpack_require__(3);exports.toHex=toHex,exports.isPositivePowerOf2=isPositivePowerOf2,exports.alignToNextMultipleOf=alignToNextMultipleOf,exports.sizeOfNumber=sizeOfNumber,exports.isSigned=isSigned},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});!function(CompileTarget){CompileTarget[CompileTarget.NONE=0]="NONE",CompileTarget[CompileTarget.AUTO=1]="AUTO",CompileTarget[CompileTarget.CPP=2]="CPP",CompileTarget[CompileTarget.JAVASCRIPT=3]="JAVASCRIPT",CompileTarget[CompileTarget.WEBASSEMBLY=4]="WEBASSEMBLY"}(exports.CompileTarget||(exports.CompileTarget={}))},function(module,exports,__webpack_require__){"use strict";function isUnary(kind){return kind>=NodeKind.ADDRESS_OF&&kind<=NodeKind.PREFIX_INCREMENT}function isUnaryPostfix(kind){return kind>=NodeKind.POSTFIX_DECREMENT&&kind<=NodeKind.POSTFIX_INCREMENT}function isBinary(kind){return kind>=NodeKind.ADD&&kind<=NodeKind.SUBTRACT}function invertedBinaryKind(kind){return kind==NodeKind.EQUAL?NodeKind.NOT_EQUAL:kind==NodeKind.NOT_EQUAL?NodeKind.EQUAL:kind==NodeKind.GREATER_THAN?NodeKind.LESS_THAN_EQUAL:kind==NodeKind.GREATER_THAN_EQUAL?NodeKind.LESS_THAN:kind==NodeKind.LESS_THAN?NodeKind.GREATER_THAN_EQUAL:kind==NodeKind.LESS_THAN_EQUAL?NodeKind.GREATER_THAN:kind}function isExpression(node){return node.kind>=NodeKind.ALIGN_OF&&node.kind<=NodeKind.SUBTRACT}function isCompactNodeKind(kind){return kind==NodeKind.CONSTANTS||kind==NodeKind.EXPRESSION||kind==NodeKind.VARIABLES}function appendFlag(first,flag,range){var link=new NodeFlag;if(link.flag=flag,link.range=range,null==first)return link;for(var secondToLast=first;null!=secondToLast.next;)secondToLast=secondToLast.next;return secondToLast.next=link,first}function allFlags(link){for(var all=0;null!=link;)all|=link.flag,link=link.next;return all}function rangeForFlag(link,flag){for(;null!=link;){if(link.flag==flag)return link.range;link=link.next}return null}function createNew(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.NEW,node.appendChild(type),node}function createDelete(value){assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.DELETE,null!=value&&node.appendChild(value),node}function createHook(test,primary,secondary){assert_1.assert(isExpression(test)),assert_1.assert(isExpression(primary)),assert_1.assert(isExpression(secondary));var node=new Node;return node.kind=NodeKind.HOOK,node.appendChild(test),node.appendChild(primary),node.appendChild(secondary),node}function createIndex(target){assert_1.assert(isExpression(target));var node=new Node;return node.kind=NodeKind.INDEX,node.appendChild(target),node}function createNull(){var node=new Node;return node.kind=NodeKind.NULL,node}function createUndefined(){var node=new Node;return node.kind=NodeKind.UNDEFINED,node}function createThis(){var node=new Node;return node.kind=NodeKind.THIS,node}function createAddressOf(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.ADDRESS_OF,node.appendChild(value),node}function createDereference(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.DEREFERENCE,node.appendChild(value),node}function createAlignOf(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.ALIGN_OF,node.appendChild(type),node}function createSizeOf(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.SIZE_OF,node.appendChild(type),node}function createboolean(value){var node=new Node;return node.kind=NodeKind.BOOLEAN,node.intValue=value?1:0,node}function createInt(value){var node=new Node;return node.kind=NodeKind.INT32,node.intValue=value,node}function createLong(value){var node=new Node;return node.kind=NodeKind.INT64,node.longValue=value,node}function createFloat(value){var node=new Node;return node.kind=NodeKind.FLOAT32,node.floatValue=value,node}function createDouble(value){var node=new Node;return node.kind=NodeKind.FLOAT64,node.doubleValue=value,node}function createString(value){var node=new Node;return node.kind=NodeKind.STRING,node.stringValue=value,node}function createArray(type){var node=new Node;return node.kind=NodeKind.ARRAY,node.resolvedType=type,node}function createName(value){var node=new Node;return node.kind=NodeKind.NAME,node.referenceValue=value,node}function createType(type){assert_1.assert(null!=type);var node=new Node;return node.kind=NodeKind.TYPE,node.resolvedType=type,node}function createAny(){var node=new Node;return node.kind=NodeKind.ANY,node}function createEmpty(){var node=new Node;return node.kind=NodeKind.EMPTY,node}function createExpression(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.EXPRESSION,node.appendChild(value),node}function createBlock(){var node=new Node;return node.kind=NodeKind.BLOCK,node}function createModule(name){var node=new Node;return node.kind=NodeKind.MODULE,node.stringValue=name,node}function createClass(name){var node=new Node;return node.kind=NodeKind.CLASS,node.stringValue=name,node}function createEnum(name){var node=new Node;return node.kind=NodeKind.ENUM,node.stringValue=name,node}function createIf(value,trueBranch,falseBranch){assert_1.assert(isExpression(value)),assert_1.assert(trueBranch.kind==NodeKind.BLOCK),assert_1.assert(null==falseBranch||falseBranch.kind==NodeKind.BLOCK);var node=new Node;return node.kind=NodeKind.IF,node.appendChild(value),node.appendChild(trueBranch),null!=falseBranch&&node.appendChild(falseBranch),node}function createWhile(value,body){assert_1.assert(isExpression(value)),assert_1.assert(body.kind==NodeKind.BLOCK);var node=new Node;return node.kind=NodeKind.WHILE,node.appendChild(value),node.appendChild(body),node}function createReturn(value){assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.RETURN,null!=value&&node.appendChild(value),node}function createImports(){var node=new Node;return node.kind=NodeKind.IMPORTS,node}function createImport(name){var node=new Node;return node.kind=NodeKind.IMPORT,node.stringValue=name,node}function createImportFrom(name){var node=new Node;return node.kind=NodeKind.IMPORT_FROM,node.stringValue=name,node}function createVariables(){var node=new Node;return node.kind=NodeKind.VARIABLES,node}function createConstants(){var node=new Node;return node.kind=NodeKind.CONSTANTS,node}function createParameters(){var node=new Node;return node.kind=NodeKind.PARAMETERS,node}function createExtends(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.EXTENDS,node.appendChild(type),node}function createImplements(){var node=new Node;return node.kind=NodeKind.IMPLEMENTS,node}function createParameter(name){var node=new Node;return node.kind=NodeKind.PARAMETER,node.stringValue=name,node}function createVariable(name,type,value){assert_1.assert(null==type||isExpression(type)),assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.VARIABLE,node.stringValue=name,node.appendChild(null!=type?type:createEmpty()),null!=value&&node.appendChild(value),node}function createFunction(name){var node=new Node;return node.kind=NodeKind.FUNCTION,node.stringValue=name,node}function createUnary(kind,value){assert_1.assert(isUnary(kind)),assert_1.assert(isExpression(value));var node=new Node;return node.kind=kind,node.appendChild(value),node}function createBinary(kind,left,right){assert_1.assert(isBinary(kind)),assert_1.assert(isExpression(left)),assert_1.assert(isExpression(right));var node=new Node;return node.kind=kind,node.appendChild(left),node.appendChild(right),node}function createCall(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.CALL,node.appendChild(value),node}function createCast(value,type){assert_1.assert(isExpression(value)),assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.CAST,node.appendChild(value),node.appendChild(type),node}function createDot(value,name){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.DOT,node.stringValue=name,node.appendChild(value),node}function createSymbolReference(symbol){var node=createName(symbol.name);return node.symbol=symbol,node.resolvedType=symbol.resolvedType,node}function createMemberReference(value,symbol){var node=createDot(value,symbol.name);return node.symbol=symbol,node.resolvedType=symbol.resolvedType,node}function createParseError(){var node=new Node;return node.kind=NodeKind.PARSE_ERROR,node}function createJSNumber(){var node=new Node;return node.kind=NodeKind.JS_NUMBER,node}function createJSObject(){var node=new Node;return node.kind=NodeKind.JS_OBJECT,node}function createJSString(){var node=new Node;return node.kind=NodeKind.JS_STRING,node}function createJSArray(){var node=new Node;return node.kind=NodeKind.JS_ARRAY,node}Object.defineProperty(exports,"__esModule",{value:!0});var NodeKind,symbol_1=__webpack_require__(7),assert_1=__webpack_require__(3);!function(NodeKind){NodeKind[NodeKind.EXTENDS=0]="EXTENDS",NodeKind[NodeKind.FILE=1]="FILE",NodeKind[NodeKind.GLOBAL=2]="GLOBAL",NodeKind[NodeKind.IMPLEMENTS=3]="IMPLEMENTS",NodeKind[NodeKind.PARAMETER=4]="PARAMETER",NodeKind[NodeKind.PARAMETERS=5]="PARAMETERS",NodeKind[NodeKind.VARIABLE=6]="VARIABLE",NodeKind[NodeKind.IMPORT=7]="IMPORT",NodeKind[NodeKind.IMPORT_FROM=8]="IMPORT_FROM",NodeKind[NodeKind.BLOCK=9]="BLOCK",NodeKind[NodeKind.BREAK=10]="BREAK",NodeKind[NodeKind.MODULE=11]="MODULE",NodeKind[NodeKind.IMPORTS=12]="IMPORTS",NodeKind[NodeKind.CLASS=13]="CLASS",NodeKind[NodeKind.CONSTANTS=14]="CONSTANTS",NodeKind[NodeKind.CONTINUE=15]="CONTINUE",NodeKind[NodeKind.EMPTY=16]="EMPTY",NodeKind[NodeKind.ENUM=17]="ENUM",NodeKind[NodeKind.EXPRESSION=18]="EXPRESSION",NodeKind[NodeKind.FUNCTION=19]="FUNCTION",NodeKind[NodeKind.IF=20]="IF",NodeKind[NodeKind.RETURN=21]="RETURN",NodeKind[NodeKind.UNSAFE=22]="UNSAFE",NodeKind[NodeKind.JAVASCRIPT=23]="JAVASCRIPT",NodeKind[NodeKind.START=24]="START",NodeKind[NodeKind.VARIABLES=25]="VARIABLES",NodeKind[NodeKind.WHILE=26]="WHILE",NodeKind[NodeKind.ALIGN_OF=27]="ALIGN_OF",NodeKind[NodeKind.BOOLEAN=28]="BOOLEAN",NodeKind[NodeKind.CALL=29]="CALL",NodeKind[NodeKind.CAST=30]="CAST",NodeKind[NodeKind.DOT=31]="DOT",NodeKind[NodeKind.HOOK=32]="HOOK",NodeKind[NodeKind.INDEX=33]="INDEX",NodeKind[NodeKind.POINTER_INDEX=34]="POINTER_INDEX",NodeKind[NodeKind.ANY=35]="ANY",NodeKind[NodeKind.INT32=36]="INT32",NodeKind[NodeKind.INT64=37]="INT64",NodeKind[NodeKind.FLOAT32=38]="FLOAT32",NodeKind[NodeKind.FLOAT64=39]="FLOAT64",NodeKind[NodeKind.ARRAY=40]="ARRAY",NodeKind[NodeKind.GENERIC=41]="GENERIC",NodeKind[NodeKind.NAME=42]="NAME",NodeKind[NodeKind.NEW=43]="NEW",NodeKind[NodeKind.DELETE=44]="DELETE",NodeKind[NodeKind.NULL=45]="NULL",NodeKind[NodeKind.UNDEFINED=46]="UNDEFINED",NodeKind[NodeKind.PARSE_ERROR=47]="PARSE_ERROR",NodeKind[NodeKind.SIZE_OF=48]="SIZE_OF",NodeKind[NodeKind.STRING=49]="STRING",NodeKind[NodeKind.THIS=50]="THIS",NodeKind[NodeKind.TYPE=51]="TYPE",NodeKind[NodeKind.ADDRESS_OF=52]="ADDRESS_OF",NodeKind[NodeKind.COMPLEMENT=53]="COMPLEMENT",NodeKind[NodeKind.DEREFERENCE=54]="DEREFERENCE",NodeKind[NodeKind.NEGATIVE=55]="NEGATIVE",NodeKind[NodeKind.NOT=56]="NOT",NodeKind[NodeKind.POINTER_TYPE=57]="POINTER_TYPE",NodeKind[NodeKind.POSITIVE=58]="POSITIVE",NodeKind[NodeKind.POSTFIX_DECREMENT=59]="POSTFIX_DECREMENT",NodeKind[NodeKind.POSTFIX_INCREMENT=60]="POSTFIX_INCREMENT",NodeKind[NodeKind.PREFIX_DECREMENT=61]="PREFIX_DECREMENT",NodeKind[NodeKind.PREFIX_INCREMENT=62]="PREFIX_INCREMENT",NodeKind[NodeKind.ADD=63]="ADD",NodeKind[NodeKind.ASSIGN=64]="ASSIGN",NodeKind[NodeKind.BITWISE_AND=65]="BITWISE_AND",NodeKind[NodeKind.BITWISE_OR=66]="BITWISE_OR",NodeKind[NodeKind.BITWISE_XOR=67]="BITWISE_XOR",NodeKind[NodeKind.DIVIDE=68]="DIVIDE",NodeKind[NodeKind.EQUAL=69]="EQUAL",NodeKind[NodeKind.EXPONENT=70]="EXPONENT",NodeKind[NodeKind.GREATER_THAN=71]="GREATER_THAN",NodeKind[NodeKind.GREATER_THAN_EQUAL=72]="GREATER_THAN_EQUAL",NodeKind[NodeKind.LESS_THAN=73]="LESS_THAN",NodeKind[NodeKind.LESS_THAN_EQUAL=74]="LESS_THAN_EQUAL",NodeKind[NodeKind.LOGICAL_AND=75]="LOGICAL_AND",NodeKind[NodeKind.LOGICAL_OR=76]="LOGICAL_OR",NodeKind[NodeKind.MULTIPLY=77]="MULTIPLY",NodeKind[NodeKind.NOT_EQUAL=78]="NOT_EQUAL",NodeKind[NodeKind.REMAINDER=79]="REMAINDER",NodeKind[NodeKind.SHIFT_LEFT=80]="SHIFT_LEFT",NodeKind[NodeKind.SHIFT_RIGHT=81]="SHIFT_RIGHT",NodeKind[NodeKind.SUBTRACT=82]="SUBTRACT",NodeKind[NodeKind.JS_NUMBER=83]="JS_NUMBER",NodeKind[NodeKind.JS_OBJECT=84]="JS_OBJECT",NodeKind[NodeKind.JS_STRING=85]="JS_STRING",NodeKind[NodeKind.JS_ARRAY=86]="JS_ARRAY"}(NodeKind=exports.NodeKind||(exports.NodeKind={})),exports.isUnary=isUnary,exports.isUnaryPostfix=isUnaryPostfix,exports.isBinary=isBinary,exports.invertedBinaryKind=invertedBinaryKind,exports.isExpression=isExpression,exports.isCompactNodeKind=isCompactNodeKind,exports.NODE_FLAG_DECLARE=1,exports.NODE_FLAG_EXPORT=2,exports.NODE_FLAG_IMPORT=4,exports.NODE_FLAG_LIBRARY=8,exports.NODE_FLAG_GET=16,exports.NODE_FLAG_OPERATOR=32,exports.NODE_FLAG_POSITIVE=64,exports.NODE_FLAG_PRIVATE=128,exports.NODE_FLAG_PROTECTED=256,exports.NODE_FLAG_PUBLIC=512,exports.NODE_FLAG_SET=1024,exports.NODE_FLAG_STATIC=2048,exports.NODE_FLAG_UNSAFE=4096,exports.NODE_FLAG_JAVASCRIPT=8192,exports.NODE_FLAG_UNSIGNED_OPERATOR=16384,exports.NODE_FLAG_VIRTUAL=32768,exports.NODE_FLAG_START=65536,exports.NODE_FLAG_ANYFUNC=1<<17,exports.NODE_FLAG_GENERIC=1<<18;var NodeFlag=function(){function NodeFlag(){}return NodeFlag}();exports.NodeFlag=NodeFlag,exports.appendFlag=appendFlag,exports.allFlags=allFlags,exports.rangeForFlag=rangeForFlag;var Node=function(){function Node(){}return Object.defineProperty(Node.prototype,"hasValue",{get:function(){return this._hasValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"rawValue",{get:function(){return this._hasStringValue?'"'+this._rawValue+'"':this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"__internal_rawValue",{get:function(){return this._rawValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"intValue",{get:function(){var n=this._rawValue;return Number(n)===n&&n%1==0?this._rawValue:null},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"longValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"floatValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"doubleValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"stringValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._hasStringValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"referenceValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Node.prototype.becomeTypeOf=function(node,context){switch(node.resolvedType){case context.int64Type:this.kind!=NodeKind.NAME&&(this.kind=NodeKind.INT64),this.resolvedType=context.int64Type;break;case context.float64Type:this.kind!=NodeKind.NAME&&(this.kind=NodeKind.FLOAT64),this.resolvedType=context.float64Type}node.flags&&(this.flags=node.flags)},Node.prototype.becomeValueTypeOf=function(symbol,context){if(symbol.resolvedType.symbol)switch(symbol.resolvedType){case context.int64Type:this.resolvedType=context.int64Type,this.kind==NodeKind.NULL&&(this.longValue=0),this.kind!=NodeKind.NAME&&(this.kind=NodeKind.INT64);break;case context.float64Type:this.resolvedType=context.float64Type,this.kind==NodeKind.NULL&&(this.doubleValue=0),this.kind!=NodeKind.NAME&&(this.kind=NodeKind.FLOAT64)}},Node.prototype.clone=function(){var node=new Node;return node.kind=this.kind,void 0!==this.offset&&(node.offset=this.offset),void 0!==this.flags&&(node.flags=this.flags),void 0!==this.firstFlag&&(node.firstFlag=this.firstFlag),void 0!==this.range&&(node.range=this.range),void 0!==this.internalRange&&(node.internalRange=this.internalRange),this.hasValue&&(node.rawValue=this.__internal_rawValue),node},Node.prototype.becomeSymbolReference=function(symbol){this.kind=NodeKind.NAME,this.symbol=symbol,this.referenceValue=symbol.name,this.resolvedType=symbol.resolvedType,this.removeChildren()},Node.prototype.becomeIntegerConstant=function(value){this.kind=NodeKind.INT32,this.symbol=null,this.intValue=value,this.removeChildren()},Node.prototype.becomeLongConstant=function(value){this.kind=NodeKind.INT64,this.symbol=null,this.longValue=value,this.removeChildren()},Node.prototype.becomeFloatConstant=function(value){this.kind=NodeKind.FLOAT32,this.symbol=null,this.floatValue=value,this.removeChildren()},Node.prototype.becomeDoubleConstant=function(value){this.kind=NodeKind.FLOAT64,this.symbol=null,this.doubleValue=value,this.removeChildren()},Node.prototype.becomeBooleanConstant=function(value){this.kind=NodeKind.BOOLEAN,this.symbol=null,this.intValue=value?1:0,this.removeChildren()},Node.prototype.isNegativeInteger=function(){return this.kind==NodeKind.INT32&&this.intValue<0},Node.prototype.isNonNegativeInteger=function(){return this.kind==NodeKind.INT32&&this.intValue>=0},Node.prototype.isDeclare=function(){return 0!=(this.flags&exports.NODE_FLAG_DECLARE)},Node.prototype.isLibrary=function(){return 0!=(this.flags&exports.NODE_FLAG_LIBRARY)},Node.prototype.isVirtual=function(){return 0!=(this.flags&exports.NODE_FLAG_VIRTUAL)},Node.prototype.isExport=function(){return 0!=(this.flags&exports.NODE_FLAG_EXPORT)},Node.prototype.isImport=function(){return 0!=(this.flags&exports.NODE_FLAG_IMPORT)},Node.prototype.isExternalImport=function(){return this.isDeclare()&&!this.isLibrary()},Node.prototype.isStart=function(){return 0!=(this.flags&exports.NODE_FLAG_START)},Node.prototype.isJavaScript=function(){return 0!=(this.flags&exports.NODE_FLAG_JAVASCRIPT)},Node.prototype.isStatic=function(){return 0!=(this.flags&exports.NODE_FLAG_STATIC)},Node.prototype.isAnyfunc=function(){return 0!=(this.flags&exports.NODE_FLAG_ANYFUNC)},Node.prototype.isDeclareOrJavaScript=function(){return 0!=(this.flags&(exports.NODE_FLAG_DECLARE|exports.NODE_FLAG_JAVASCRIPT))},Node.prototype.isDeclareOrExport=function(){return 0!=(this.flags&(exports.NODE_FLAG_DECLARE|exports.NODE_FLAG_EXPORT))},Node.prototype.isGet=function(){return 0!=(this.flags&exports.NODE_FLAG_GET)},Node.prototype.isSet=function(){return 0!=(this.flags&exports.NODE_FLAG_SET)},Node.prototype.isOperator=function(){return 0!=(this.flags&exports.NODE_FLAG_OPERATOR)},Node.prototype.isPositive=function(){return 0!=(this.flags&exports.NODE_FLAG_POSITIVE)},Node.prototype.isPrivate=function(){return 0!=(this.flags&exports.NODE_FLAG_PRIVATE)},Node.prototype.isUnsafe=function(){return 0!=(this.flags&exports.NODE_FLAG_UNSAFE)},Node.prototype.isGeneric=function(){return 0!=(this.flags&exports.NODE_FLAG_GENERIC)},Node.prototype.isTemplate=function(){return this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_IS_TEMPLATE)},Node.prototype.isUnsignedOperator=function(){return 0!=(this.flags&exports.NODE_FLAG_UNSIGNED_OPERATOR)},Node.prototype.childCount=function(){for(var count=0,child=this.firstChild;null!=child;)count+=1,child=child.nextSibling;return count},Node.prototype.parameterCount=function(){var count=0,child=this.firstChild;if(child.kind==NodeKind.PARAMETERS)for(child=child.firstChild;null!=child;)count+=1,child=child.nextSibling;return count},Node.prototype.hasParameters=function(){if(this.firstChild){var child=this.firstChild;if(child.kind==NodeKind.PARAMETERS)return child.childCount()>0}return!1},Node.prototype.appendChild=function(child){child.parent=this,null==this.firstChild?(this.firstChild=child,this.firstChild.offset=0):(child.previousSibling=this.lastChild,this.lastChild.nextSibling=child,child.offset=this.lastChild.offset+1),this.lastChild=child},Node.prototype.insertChildBefore=function(after,before){if(null!=before){if(assert_1.assert(before!=after),assert_1.assert(null==before.parent),assert_1.assert(null==before.previousSibling),assert_1.assert(null==before.nextSibling),assert_1.assert(null==after||after.parent==this),null==after)return void this.appendChild(before);before.parent=this,before.previousSibling=after.previousSibling,before.nextSibling=after,null!=after.previousSibling?(assert_1.assert(after==after.previousSibling.nextSibling),after.previousSibling.nextSibling=before):(assert_1.assert(after==this.firstChild),this.firstChild=before),after.previousSibling=before}},Node.prototype.insertChildAfter=function(before,after){if(null!=after){if(assert_1.assert(before!=after),assert_1.assert(null==after.parent),assert_1.assert(null==after.previousSibling),assert_1.assert(null==after.nextSibling),assert_1.assert(null==before||before.parent==this),null==before)return void this.appendChild(after);after.parent=this,after.previousSibling=before,after.nextSibling=before.nextSibling,null!=before.nextSibling&&(assert_1.assert(before==before.nextSibling.previousSibling),before.nextSibling.previousSibling=after),before.nextSibling=after}},Node.prototype.remove=function(){return assert_1.assert(null!=this.parent),null!=this.previousSibling?(assert_1.assert(this.previousSibling.nextSibling==this),this.previousSibling.nextSibling=this.nextSibling):(assert_1.assert(this.parent.firstChild==this),this.parent.firstChild=this.nextSibling),null!=this.nextSibling?(assert_1.assert(this.nextSibling.previousSibling==this),this.nextSibling.previousSibling=this.previousSibling):(assert_1.assert(this.parent.lastChild==this),this.parent.lastChild=this.previousSibling),this.parent=null,this.previousSibling=null,this.nextSibling=null,this},Node.prototype.removeChildren=function(){for(;null!=this.lastChild;)this.lastChild.remove()},Node.prototype.replaceWith=function(node){assert_1.assert(node!=this),assert_1.assert(null!=this.parent),assert_1.assert(null==node.parent),assert_1.assert(null==node.previousSibling),assert_1.assert(null==node.nextSibling),node.parent=this.parent,node.previousSibling=this.previousSibling,node.nextSibling=this.nextSibling,null!=this.previousSibling?(assert_1.assert(this.previousSibling.nextSibling==this),this.previousSibling.nextSibling=node):(assert_1.assert(this.parent.firstChild==this),this.parent.firstChild=node),null!=this.nextSibling?(assert_1.assert(this.nextSibling.previousSibling==this),this.nextSibling.previousSibling=node):(assert_1.assert(this.parent.lastChild==this),this.parent.lastChild=node),this.parent=null,this.previousSibling=null,this.nextSibling=null},Node.prototype.isType=function(){return this.kind==NodeKind.TYPE||this.kind==NodeKind.POINTER_TYPE||null!=this.symbol&&symbol_1.isType(this.symbol.kind)},Node.prototype.isCallValue=function(){return this.parent.kind==NodeKind.CALL&&this==this.parent.callValue()},Node.prototype.isAssignTarget=function(){return this.parent.kind==NodeKind.ASSIGN&&this==this.parent.binaryLeft()},Node.prototype.withRange=function(range){return this.range=range,this},Node.prototype.withInternalRange=function(range){return this.internalRange=range,this},Node.prototype.functionFirstArgument=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2);var child=this.firstChild;return child.kind==NodeKind.PARAMETERS&&(child=child.nextSibling),child},Node.prototype.functionLastArgument=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2);var child=this.firstChild;child.kind==NodeKind.PARAMETERS&&(child=child.nextSibling);for(var lastArgument=null;null!=child;){var nextChild=child.nextSibling;nextChild.kind!==NodeKind.VARIABLE?(lastArgument=child,child=null):child=nextChild}return lastArgument},Node.prototype.functionFirstArgumentIgnoringThis=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(null!=this.symbol);var child=this.functionFirstArgument();return this.symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE&&(child=child.nextSibling),child},Node.prototype.functionReturnType=function(){return assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(isExpression(this.lastChild.previousSibling)),this.lastChild.previousSibling},Node.prototype.constructorNode=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>0),assert_1.assert(this.resolvedType.symbol.node.kind==NodeKind.CLASS),this.resolvedType.symbol.node.constructorFunctionNode},Node.prototype.functionBody=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(this.lastChild.kind==NodeKind.BLOCK||this.lastChild.kind==NodeKind.EMPTY);var body=this.lastChild;return body.kind==NodeKind.BLOCK?body:null},Node.prototype.newType=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.deleteType=function(){return assert_1.assert(this.kind==NodeKind.DELETE),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.callValue=function(){return assert_1.assert(this.kind==NodeKind.CALL),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.castValue=function(){return assert_1.assert(this.kind==NodeKind.CAST),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.castType=function(){return assert_1.assert(this.kind==NodeKind.CAST),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.alignOfType=function(){return assert_1.assert(this.kind==NodeKind.ALIGN_OF),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.sizeOfType=function(){return assert_1.assert(this.kind==NodeKind.SIZE_OF),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.dotTarget=function(){return assert_1.assert(this.kind==NodeKind.DOT),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.returnValue=function(){return assert_1.assert(this.kind==NodeKind.RETURN),assert_1.assert(this.childCount()<=1),assert_1.assert(null==this.firstChild||isExpression(this.firstChild)),this.firstChild},Node.prototype.ifReturnNode=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(null!==this.firstChild),assert_1.assert(null!==this.firstChild.nextSibling),this.firstChild.nextSibling.returnNode||null},Node.prototype.deleteValue=function(){return assert_1.assert(this.kind==NodeKind.DELETE),assert_1.assert(this.childCount()<=1),assert_1.assert(null==this.firstChild||isExpression(this.firstChild)),this.firstChild},Node.prototype.extendsType=function(){return assert_1.assert(this.kind==NodeKind.EXTENDS),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.firstGenericType=function(){return assert_1.assert(this.firstChild.kind==NodeKind.PARAMETERS),assert_1.assert(this.firstChild.childCount()>0),this.firstChild.firstChild},Node.prototype.variableType=function(){assert_1.assert(this.kind==NodeKind.VARIABLE),assert_1.assert(this.childCount()<=2),assert_1.assert(isExpression(this.firstChild)||this.firstChild.kind==NodeKind.EMPTY);var type=this.firstChild;return type.kind!=NodeKind.EMPTY?type:null},Node.prototype.variableValue=function(){return assert_1.assert(this.kind==NodeKind.VARIABLE),assert_1.assert(this.childCount()<=2),assert_1.assert(null==this.firstChild.nextSibling||isExpression(this.firstChild.nextSibling)),this.firstChild.nextSibling},Node.prototype.hasVariableValue=function(){return assert_1.assert(this.kind==NodeKind.VARIABLE),void 0!=this.firstChild&&void 0!=this.firstChild.nextSibling},Node.prototype.expressionValue=function(){return assert_1.assert(this.kind==NodeKind.EXPRESSION),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.binaryLeft=function(){return assert_1.assert(isBinary(this.kind)),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.binaryRight=function(){return assert_1.assert(isBinary(this.kind)),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.unaryValue=function(){return assert_1.assert(isUnary(this.kind)),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.pointer=function(){return assert_1.assert(this.kind==NodeKind.POINTER_INDEX),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.pointerOffset=function(){return assert_1.assert(this.firstChild),assert_1.assert(this.firstChild.nextSibling),this.firstChild.nextSibling.intValue},Node.prototype.whileValue=function(){return assert_1.assert(this.kind==NodeKind.WHILE),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.whileBody=function(){return assert_1.assert(this.kind==NodeKind.WHILE),assert_1.assert(2==this.childCount()),assert_1.assert(this.lastChild.kind==NodeKind.BLOCK),this.lastChild},Node.prototype.hookValue=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.hookTrue=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.firstChild.nextSibling)),this.firstChild.nextSibling},Node.prototype.hookFalse=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.indexTarget=function(){return assert_1.assert(this.kind==NodeKind.INDEX),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.ifValue=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.ifTrue=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(this.firstChild.nextSibling.kind==NodeKind.BLOCK),this.firstChild.nextSibling},Node.prototype.ifFalse=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(null==this.firstChild.nextSibling.nextSibling||this.firstChild.nextSibling.nextSibling.kind==NodeKind.BLOCK),this.firstChild.nextSibling.nextSibling||null},Node.prototype.expandCallIntoOperatorTree=function(){if(this.kind!=NodeKind.CALL)return!1;var value=this.callValue(),symbol=value.symbol;if(value.kind==NodeKind.DOT&&symbol.node.isOperator()&&symbol.node.isDeclare()){var binaryKind=NodeKind.NULL;if("%"==symbol.name?binaryKind=NodeKind.REMAINDER:"&"==symbol.name?binaryKind=NodeKind.BITWISE_AND:"*"==symbol.name?binaryKind=NodeKind.MULTIPLY:"**"==symbol.name?binaryKind=NodeKind.EXPONENT:"/"==symbol.name?binaryKind=NodeKind.DIVIDE:"<"==symbol.name?binaryKind=NodeKind.LESS_THAN:"<<"==symbol.name?binaryKind=NodeKind.SHIFT_LEFT:"=="==symbol.name?binaryKind=NodeKind.EQUAL:">"==symbol.name?binaryKind=NodeKind.GREATER_THAN:">>"==symbol.name?binaryKind=NodeKind.SHIFT_RIGHT:"[]"==symbol.name?binaryKind=NodeKind.INDEX:"^"==symbol.name?binaryKind=NodeKind.BITWISE_XOR:"|"==symbol.name&&(binaryKind=NodeKind.BITWISE_OR),binaryKind!=NodeKind.NULL)return this.kind=binaryKind,value.remove(),this.insertChildBefore(this.firstChild,value.dotTarget().remove()),!0;if("[]="==symbol.name){this.kind=NodeKind.ASSIGN;var target=createIndex(value.remove().dotTarget().remove());return target.appendChild(this.firstChild.remove()),this.insertChildBefore(this.firstChild,target),!0}}return!1},Node.prototype.arrayLength=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),assert_1.assert(this.firstChild.resolvedType.isArray()),this.firstChild.nextSibling},Node}();exports.Node=Node,exports.createNew=createNew,exports.createDelete=createDelete,exports.createHook=createHook,exports.createIndex=createIndex,exports.createNull=createNull,exports.createUndefined=createUndefined,exports.createThis=createThis,exports.createAddressOf=createAddressOf,exports.createDereference=createDereference,exports.createAlignOf=createAlignOf,exports.createSizeOf=createSizeOf,exports.createboolean=createboolean,exports.createInt=createInt,exports.createLong=createLong,exports.createFloat=createFloat,exports.createDouble=createDouble,exports.createString=createString,exports.createArray=createArray,exports.createName=createName,exports.createType=createType,exports.createAny=createAny,exports.createEmpty=createEmpty,exports.createExpression=createExpression,exports.createBlock=createBlock,exports.createModule=createModule,exports.createClass=createClass,exports.createEnum=createEnum,exports.createIf=createIf,exports.createWhile=createWhile,exports.createReturn=createReturn,exports.createImports=createImports,exports.createImport=createImport,exports.createImportFrom=createImportFrom,exports.createVariables=createVariables,exports.createConstants=createConstants,exports.createParameters=createParameters,exports.createExtends=createExtends,exports.createImplements=createImplements,exports.createParameter=createParameter,exports.createVariable=createVariable,exports.createFunction=createFunction,exports.createUnary=createUnary,exports.createBinary=createBinary,exports.createCall=createCall,exports.createCast=createCast,exports.createDot=createDot,exports.createSymbolReference=createSymbolReference,exports.createMemberReference=createMemberReference,exports.createParseError=createParseError,exports.createJSNumber=createJSNumber,exports.createJSObject=createJSObject,exports.createJSString=createJSString,exports.createJSArray=createJSArray},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});!function(WasmExternalKind){WasmExternalKind[WasmExternalKind.Function=0]="Function",WasmExternalKind[WasmExternalKind.Table=1]="Table",WasmExternalKind[WasmExternalKind.Memory=2]="Memory",WasmExternalKind[WasmExternalKind.Global=3]="Global"}(exports.WasmExternalKind||(exports.WasmExternalKind={}))},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WasmOpcode={UNREACHABLE:0,NOP:1,BLOCK:2,LOOP:3,IF:4,IF_ELSE:5,END:11,BR:12,BR_IF:13,BR_TABLE:14,RETURN:15,CALL:16,CALL_INDIRECT:17,DROP:26,SELECT:27,GET_LOCAL:32,SET_LOCAL:33,TEE_LOCAL:34,GET_GLOBAL:35,SET_GLOBAL:36,I32_LOAD:40,I64_LOAD:41,F32_LOAD:42,F64_LOAD:43,I32_LOAD8_S:44,I32_LOAD8_U:45,I32_LOAD16_S:46,I32_LOAD16_U:47,I64_LOAD8_S:48,I64_LOAD8_U:49,I64_LOAD16_S:50,I64_LOAD16_U:51,I64_LOAD32_S:52,I64_LOAD32_U:53,I32_STORE:54,I64_STORE:55,F32_STORE:56,F64_STORE:57,I32_STORE8:58,I32_STORE16:59,I64_STORE8:60,I64_STORE16:61,I64_STORE32:62,MEMORY_SIZE:63,GROW_MEMORY:64,I32_CONST:65,I64_CONST:66,F32_CONST:67,F64_CONST:68,I32_EQZ:69,I32_EQ:70,I32_NE:71,I32_LT_S:72,I32_LT_U:73,I32_GT_S:74,I32_GT_U:75,I32_LE_S:76,I32_LE_U:77,I32_GE_S:78,I32_GE_U:79,I64_EQZ:80,I64_EQ:81,I64_NE:82,I64_LT_S:83,I64_LT_U:84,I64_GT_S:85,I64_GT_U:86,I64_LE_S:87,I64_LE_U:88,I64_GE_S:89,I64_GE_U:90,F32_EQ:91,F32_NE:92,F32_LT:93,F32_GT:94,F32_LE:95,F32_GE:96,F64_EQ:97,F64_NE:98,F64_LT:99,F64_GT:100,F64_LE:101,F64_GE:102,I32_CLZ:103,I32_CTZ:104,I32_POPCNT:105,I32_ADD:106,I32_SUB:107,I32_MUL:108,I32_DIV_S:109,I32_DIV_U:110,I32_REM_S:111,I32_REM_U:112,I32_AND:113,I32_OR:114,I32_XOR:115,I32_SHL:116,I32_SHR_S:117,I32_SHR_U:118,I32_ROTL:119,I32_ROTR:120,I64_CLZ:121,I64_CTZ:122,I64_POPCNT:123,I64_ADD:124,I64_SUB:125,I64_MUL:126,I64_DIV_S:127,I64_DIV_U:128,I64_REM_S:129,I64_REM_U:130,I64_AND:131,I64_OR:132,I64_XOR:133,I64_SHL:134,I64_SHR_S:135,I64_SHR_U:136,I64_ROTL:137,I64_ROTR:138,F32_ABS:139,F32_NEG:140,F32_CEIL:141,F32_FLOOR:142,F32_TRUNC:143,F32_NEAREST:144,F32_SQRT:145,F32_ADD:146,F32_SUB:147,F32_MUL:148,F32_DIV:149,F32_MIN:150,F32_MAX:151,F32_COPYSIGN:152,F64_ABS:153,F64_NEG:154,F64_CEIL:155,F64_FLOOR:156,F64_TRUNC:157,F64_NEAREST:158,F64_SQRT:159,F64_ADD:160,F64_SUB:161,F64_MUL:162,F64_DIV:163,F64_MIN:164,F64_MAX:165,F64_COPYSIGN:166,I32_WRAP_I64:167,I32_TRUNC_S_F32:168,I32_TRUNC_U_F32:169,I32_TRUNC_S_F64:170,I32_TRUNC_U_F64:171,I64_EXTEND_S_I32:172,I64_EXTEND_U_I32:173,I64_TRUNC_S_F32:174,I64_TRUNC_U_F32:175,I64_TRUNC_S_F64:176,I64_TRUNC_U_F64:177,F32_CONVERT_S_I32:178,F32_CONVERT_U_I32:179,F32_CONVERT_S_I64:180,F32_CONVERT_U_I64:181,F32_DEMOTE_F64:182,F64_CONVERT_S_I32:183,F64_CONVERT_U_I32:184,F64_CONVERT_S_I64:185,F64_CONVERT_U_I64:186,F64_PROMOTE_F32:187,I32_REINTERPRET_F32:188,I64_REINTERPRET_F64:189,F32_REINTERPRET_I32:190,F64_REINTERPRET_I64:191},exports.WasmOpcode[exports.WasmOpcode.UNREACHABLE]="unreachable",exports.WasmOpcode[exports.WasmOpcode.NOP]="nop",exports.WasmOpcode[exports.WasmOpcode.BLOCK]="block",exports.WasmOpcode[exports.WasmOpcode.LOOP]="loop",exports.WasmOpcode[exports.WasmOpcode.IF]="if",exports.WasmOpcode[exports.WasmOpcode.IF_ELSE]="else",exports.WasmOpcode[exports.WasmOpcode.END]="end",exports.WasmOpcode[exports.WasmOpcode.BR]="br",exports.WasmOpcode[exports.WasmOpcode.BR_IF]="br_if",exports.WasmOpcode[exports.WasmOpcode.BR_TABLE]="br_table",exports.WasmOpcode[exports.WasmOpcode.RETURN]="return",exports.WasmOpcode[exports.WasmOpcode.CALL]="call",exports.WasmOpcode[exports.WasmOpcode.CALL_INDIRECT]="call_indirect",exports.WasmOpcode[exports.WasmOpcode.DROP]="drop",exports.WasmOpcode[exports.WasmOpcode.SELECT]="select",exports.WasmOpcode[exports.WasmOpcode.GET_LOCAL]="get_local",exports.WasmOpcode[exports.WasmOpcode.SET_LOCAL]="set_local",exports.WasmOpcode[exports.WasmOpcode.TEE_LOCAL]="tee_local",exports.WasmOpcode[exports.WasmOpcode.GET_GLOBAL]="get_global",exports.WasmOpcode[exports.WasmOpcode.SET_GLOBAL]="set_global",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD]="i32.load",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD]="i64.load",exports.WasmOpcode[exports.WasmOpcode.F32_LOAD]="f32.load",exports.WasmOpcode[exports.WasmOpcode.F64_LOAD]="f64.load",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD8_S]="i32.load8_s",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD8_U]="i32_load8_u",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD16_S]="i32_load16_s",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD16_U]="i32_load16_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD8_S]="i64.load8_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD8_U]="i64.load8_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD16_S]="i64.load16_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD16_U]="i64.load16_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD32_S]="i64.load32_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD32_U]="i64.load32_u",exports.WasmOpcode[exports.WasmOpcode.I32_STORE]="i32.store",exports.WasmOpcode[exports.WasmOpcode.I64_STORE]="i64.store",exports.WasmOpcode[exports.WasmOpcode.F32_STORE]="f32.store",exports.WasmOpcode[exports.WasmOpcode.F64_STORE]="f64.store",exports.WasmOpcode[exports.WasmOpcode.I32_STORE8]="i32.store8",exports.WasmOpcode[exports.WasmOpcode.I32_STORE16]="i32.store16",exports.WasmOpcode[exports.WasmOpcode.I64_STORE8]="i64.store8",exports.WasmOpcode[exports.WasmOpcode.I64_STORE16]="i64.store16",exports.WasmOpcode[exports.WasmOpcode.I64_STORE32]="i64.store32",exports.WasmOpcode[exports.WasmOpcode.MEMORY_SIZE]="current_memory",exports.WasmOpcode[exports.WasmOpcode.GROW_MEMORY]="grow_memory",exports.WasmOpcode[exports.WasmOpcode.I32_CONST]="i32.const",exports.WasmOpcode[exports.WasmOpcode.I64_CONST]="i64.const",exports.WasmOpcode[exports.WasmOpcode.F32_CONST]="f32.const",exports.WasmOpcode[exports.WasmOpcode.F64_CONST]="f64.const",exports.WasmOpcode[exports.WasmOpcode.I32_EQZ]="i32.eqz",exports.WasmOpcode[exports.WasmOpcode.I32_EQ]="i32.eq",exports.WasmOpcode[exports.WasmOpcode.I32_NE]="i32.ne",exports.WasmOpcode[exports.WasmOpcode.I32_LT_S]="i32.lt_s",exports.WasmOpcode[exports.WasmOpcode.I32_LT_U]="i32.lt_u",exports.WasmOpcode[exports.WasmOpcode.I32_GT_S]="i32.gt_s",exports.WasmOpcode[exports.WasmOpcode.I32_GT_U]="i32.gt_u",exports.WasmOpcode[exports.WasmOpcode.I32_LE_S]="i32.le_s",exports.WasmOpcode[exports.WasmOpcode.I32_LE_U]="i32.le_u",exports.WasmOpcode[exports.WasmOpcode.I32_GE_S]="i32.ge_s",exports.WasmOpcode[exports.WasmOpcode.I32_GE_U]="i32.ge_u",exports.WasmOpcode[exports.WasmOpcode.I64_EQZ]="i64.eqz",exports.WasmOpcode[exports.WasmOpcode.I64_EQ]="i64.eq",exports.WasmOpcode[exports.WasmOpcode.I64_NE]="i64.ne",exports.WasmOpcode[exports.WasmOpcode.I64_LT_S]="i64.lt_s",exports.WasmOpcode[exports.WasmOpcode.I64_LT_U]="i64.lt_u",exports.WasmOpcode[exports.WasmOpcode.I64_GT_S]="i64.gt_s",exports.WasmOpcode[exports.WasmOpcode.I64_GT_U]="i64.gt_u",exports.WasmOpcode[exports.WasmOpcode.I64_LE_S]="i64.le_s",exports.WasmOpcode[exports.WasmOpcode.I64_LE_U]="i64.le_u",exports.WasmOpcode[exports.WasmOpcode.I64_GE_S]="i64.ge_s",exports.WasmOpcode[exports.WasmOpcode.I64_GE_U]="i64.ge_u",exports.WasmOpcode[exports.WasmOpcode.F32_EQ]="f32.eq",exports.WasmOpcode[exports.WasmOpcode.F32_NE]="f32.ne",exports.WasmOpcode[exports.WasmOpcode.F32_LT]="f32.lt",exports.WasmOpcode[exports.WasmOpcode.F32_GT]="f32.gt",exports.WasmOpcode[exports.WasmOpcode.F32_LE]="f32.le",exports.WasmOpcode[exports.WasmOpcode.F32_GE]="f32.ge",exports.WasmOpcode[exports.WasmOpcode.F64_EQ]="f64.eq",exports.WasmOpcode[exports.WasmOpcode.F64_NE]="f64.ne",exports.WasmOpcode[exports.WasmOpcode.F64_LT]="f64.lt",exports.WasmOpcode[exports.WasmOpcode.F64_GT]="f64.gt",exports.WasmOpcode[exports.WasmOpcode.F64_LE]="f64.le",exports.WasmOpcode[exports.WasmOpcode.F64_GE]="f64.ge",exports.WasmOpcode[exports.WasmOpcode.I32_CLZ]="i32.clz",exports.WasmOpcode[exports.WasmOpcode.I32_CTZ]="i32.ctz",exports.WasmOpcode[exports.WasmOpcode.I32_POPCNT]="i32.popcnt",exports.WasmOpcode[exports.WasmOpcode.I32_ADD]="i32.add",exports.WasmOpcode[exports.WasmOpcode.I32_SUB]="i32.sub",exports.WasmOpcode[exports.WasmOpcode.I32_MUL]="i32.mul",exports.WasmOpcode[exports.WasmOpcode.I32_DIV_S]="i32.div_s",exports.WasmOpcode[exports.WasmOpcode.I32_DIV_U]="i32.div_u",exports.WasmOpcode[exports.WasmOpcode.I32_REM_S]="i32.rem_s",exports.WasmOpcode[exports.WasmOpcode.I32_REM_U]="i32.rem_u",exports.WasmOpcode[exports.WasmOpcode.I32_AND]="i32.and",exports.WasmOpcode[exports.WasmOpcode.I32_OR]="i32.or",exports.WasmOpcode[exports.WasmOpcode.I32_XOR]="i32.xor",exports.WasmOpcode[exports.WasmOpcode.I32_SHL]="i32.shl",exports.WasmOpcode[exports.WasmOpcode.I32_SHR_S]="i32.shr_s",exports.WasmOpcode[exports.WasmOpcode.I32_SHR_U]="i32.shr_u",exports.WasmOpcode[exports.WasmOpcode.I32_ROTL]="i32.rotl",exports.WasmOpcode[exports.WasmOpcode.I32_ROTR]="i32.rotr",exports.WasmOpcode[exports.WasmOpcode.I64_CLZ]="i64.clz",exports.WasmOpcode[exports.WasmOpcode.I64_CTZ]="i64.ctz",exports.WasmOpcode[exports.WasmOpcode.I64_POPCNT]="i64.popcnt",exports.WasmOpcode[exports.WasmOpcode.I64_ADD]="i64.add",exports.WasmOpcode[exports.WasmOpcode.I64_SUB]="i64.sub",exports.WasmOpcode[exports.WasmOpcode.I64_MUL]="i64.mul",exports.WasmOpcode[exports.WasmOpcode.I64_DIV_S]="i64.div_s",exports.WasmOpcode[exports.WasmOpcode.I64_DIV_U]="i64.div_u",exports.WasmOpcode[exports.WasmOpcode.I64_REM_S]="i64.rem_s",exports.WasmOpcode[exports.WasmOpcode.I64_REM_U]="i64.rem_u",exports.WasmOpcode[exports.WasmOpcode.I64_AND]="i64.and",exports.WasmOpcode[exports.WasmOpcode.I64_OR]="i64.or",exports.WasmOpcode[exports.WasmOpcode.I64_XOR]="i64.xor",exports.WasmOpcode[exports.WasmOpcode.I64_SHL]="i64.shl",exports.WasmOpcode[exports.WasmOpcode.I64_SHR_S]="i64.shr_s",exports.WasmOpcode[exports.WasmOpcode.I64_SHR_U]="i64.shr_u",exports.WasmOpcode[exports.WasmOpcode.I64_ROTL]="i64.rotl",exports.WasmOpcode[exports.WasmOpcode.I64_ROTR]="i64.rotr",exports.WasmOpcode[exports.WasmOpcode.F32_ABS]="f32.abs",exports.WasmOpcode[exports.WasmOpcode.F32_NEG]="f32.neg",exports.WasmOpcode[exports.WasmOpcode.F32_CEIL]="f32.ceil",exports.WasmOpcode[exports.WasmOpcode.F32_FLOOR]="f32.floor",exports.WasmOpcode[exports.WasmOpcode.F32_TRUNC]="f32.trunc",exports.WasmOpcode[exports.WasmOpcode.F32_NEAREST]="f32.nearest",exports.WasmOpcode[exports.WasmOpcode.F32_SQRT]="f32.sqrt",exports.WasmOpcode[exports.WasmOpcode.F32_ADD]="f32.add",exports.WasmOpcode[exports.WasmOpcode.F32_SUB]="f32.sub",exports.WasmOpcode[exports.WasmOpcode.F32_MUL]="f32.mul",exports.WasmOpcode[exports.WasmOpcode.F32_DIV]="f32.div",exports.WasmOpcode[exports.WasmOpcode.F32_MIN]="f32.min",exports.WasmOpcode[exports.WasmOpcode.F32_MAX]="f32.max",exports.WasmOpcode[exports.WasmOpcode.F32_COPYSIGN]="f32.copysign",exports.WasmOpcode[exports.WasmOpcode.F64_ABS]="f64.abs",exports.WasmOpcode[exports.WasmOpcode.F64_NEG]="f64.neg",exports.WasmOpcode[exports.WasmOpcode.F64_CEIL]="f64.ceil",exports.WasmOpcode[exports.WasmOpcode.F64_FLOOR]="f64.floor",exports.WasmOpcode[exports.WasmOpcode.F64_TRUNC]="f64.trunc",exports.WasmOpcode[exports.WasmOpcode.F64_NEAREST]="f64.nearest",exports.WasmOpcode[exports.WasmOpcode.F64_SQRT]="f64.sqrt",exports.WasmOpcode[exports.WasmOpcode.F64_ADD]="f64.add",exports.WasmOpcode[exports.WasmOpcode.F64_SUB]="f64.sub",exports.WasmOpcode[exports.WasmOpcode.F64_MUL]="f64.mul",exports.WasmOpcode[exports.WasmOpcode.F64_DIV]="f64.div",exports.WasmOpcode[exports.WasmOpcode.F64_MIN]="f64.min",exports.WasmOpcode[exports.WasmOpcode.F64_MAX]="f64.max",exports.WasmOpcode[exports.WasmOpcode.F64_COPYSIGN]="f64.copysign",exports.WasmOpcode[exports.WasmOpcode.I32_WRAP_I64]="i32.wrap/i64",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_S_F32]="i32.trunc_s/f32",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_U_F32]="i32.trunc_u/f32",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_S_F64]="i32.trunc_s/f64",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_U_F64]="i32.trunc_u/f64",exports.WasmOpcode[exports.WasmOpcode.I64_EXTEND_S_I32]="i64.extend_s/i32",exports.WasmOpcode[exports.WasmOpcode.I64_EXTEND_U_I32]="i64.extend_u/i32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_S_F32]="i64.trunc_s/f32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_U_F32]="i64.trunc_u/f32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_S_F64]="i64.trunc_s/f64",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_U_F64]="i64.trunc_u/f64",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_S_I32]="f32.convert_s/i32",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_U_I32]="f32.convert_u/i32",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_S_I64]="f32.convert_s/i64",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_U_I64]="f32.convert_u/i64",exports.WasmOpcode[exports.WasmOpcode.F32_DEMOTE_F64]="f32.demote/f64",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_S_I32]="f64.convert_s/i32",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_U_I32]="f64.convert_u/i32",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_S_I64]="f64.convert_s/i64",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_U_I64]="f64.convert_u/i64",exports.WasmOpcode[exports.WasmOpcode.F64_PROMOTE_F32]="f64.promote/f32",exports.WasmOpcode[exports.WasmOpcode.I32_REINTERPRET_F32]="i32.reinterpret/f32",exports.WasmOpcode[exports.WasmOpcode.I64_REINTERPRET_F64]="i64.reinterpret/f64",exports.WasmOpcode[exports.WasmOpcode.F32_REINTERPRET_I32]="f32.reinterpret/i32",exports.WasmOpcode[exports.WasmOpcode.F64_REINTERPRET_I64]="f64.reinterpret/i64",Object.freeze(exports.WasmOpcode)},function(module,exports,__webpack_require__){"use strict";function getWasmFunctionName(symbol){if(void 0===symbol||null===symbol)return"";var moduleName=symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE?symbol.parent().internalName:"";return(""==moduleName?"":moduleName+"_")+symbol.internalName}function symbolToWasmType(symbol,bitness){var type=symbol.resolvedType;return type.isFloat()?wasm_type_1.WasmType.F32:type.isDouble()?wasm_type_1.WasmType.F64:type.isInteger()||bitness==bitness_1.Bitness.x32&&type.pointerTo?wasm_type_1.WasmType.I32:type.isLong()||bitness==bitness_1.Bitness.x64&&type.pointerTo?wasm_type_1.WasmType.I64:wasm_type_1.WasmType.I32}function wasmToTurboType(type){switch(type){case wasm_type_1.WasmType.VOID:return"void";case wasm_type_1.WasmType.I32:return"int32";case wasm_type_1.WasmType.I64:return"int64";case wasm_type_1.WasmType.F32:return"float32";case wasm_type_1.WasmType.F64:return"float64"}}function typeToDataType(type,bitness){return type.isFloat()?"F32":type.isDouble()?"F64":type.isInteger()||bitness==bitness_1.Bitness.x32&&type.pointerTo?"I32":type.isLong()||bitness==bitness_1.Bitness.x64&&type.pointerTo?"I64":"I32"}function getTypedArrayElementSize(name){switch(name){case"Uint8ClampedArray":case"Uint8Array":case"Int8Array":return 1;case"Uint16Array":case"Int16Array":return 2;case"Uint32Array":case"Int32Array":case"Float32Array":return 4;case"Float64Array":return 8;default:throw"unknown typed array"}}Object.defineProperty(exports,"__esModule",{value:!0});var bitness_1=__webpack_require__(16),wasm_type_1=__webpack_require__(6),symbol_1=__webpack_require__(7);exports.getWasmFunctionName=getWasmFunctionName,exports.symbolToWasmType=symbolToWasmType,exports.wasmToTurboType=wasmToTurboType,exports.typeToDataType=typeToDataType,exports.getTypedArrayElementSize=getTypedArrayElementSize},function(module,exports,__webpack_require__){"use strict";function isKeyword(kind){return kind>=TokenKind.ALIGNOF&&kind<=TokenKind.WHILE}function splitToken(first,firstKind,secondKind){var range=first.range;assert_1.assert(range.end-range.start>=2);var second=new Token;second.kind=secondKind,second.range=log_1.createRange(range.source,range.start+1,range.end),second.next=first.next,first.kind=firstKind,first.next=second,range.end=range.start+1}function tokenToString(token){return token==TokenKind.END_OF_FILE?"end of file":token==TokenKind.CHARACTER?"character literal":token==TokenKind.IDENTIFIER?"identifier":token==TokenKind.INT32?"integer32 literal":token==TokenKind.INT64?"integer64 literal":token==TokenKind.FLOAT32?"float32 literal":token==TokenKind.FLOAT64?"float64 literal":token==TokenKind.STRING?"string literal":token==TokenKind.ARRAY?"array literal":token==TokenKind.ASSIGN?"'='":token==TokenKind.BITWISE_AND?"'&'":token==TokenKind.BITWISE_OR?"'|'":token==TokenKind.BITWISE_XOR?"'^'":token==TokenKind.COLON?"':'":token==TokenKind.COMMA?"','":token==TokenKind.COMPLEMENT?"'~'":token==TokenKind.DIVIDE?"'/'":token==TokenKind.DOT?"'.'":token==TokenKind.EQUAL?"'=='":token==TokenKind.EXPONENT?"'**'":token==TokenKind.GREATER_THAN?"'>'":token==TokenKind.GREATER_THAN_EQUAL?"'>='":token==TokenKind.LEFT_BRACE?"'{'":token==TokenKind.LEFT_BRACKET?"'['":token==TokenKind.LEFT_PARENTHESIS?"'('":token==TokenKind.LESS_THAN?"'<'":token==TokenKind.LESS_THAN_EQUAL?"'<='":token==TokenKind.LOGICAL_AND?"'&&'":token==TokenKind.LOGICAL_OR?"'||'":token==TokenKind.MINUS?"'-'":token==TokenKind.MINUS_MINUS?"'--'":token==TokenKind.MULTIPLY?"'*'":token==TokenKind.NOT?"'!'":token==TokenKind.NOT_EQUAL?"'!='":token==TokenKind.PLUS?"'+'":token==TokenKind.PLUS_PLUS?"'++'":token==TokenKind.QUESTION_MARK?"'?'":token==TokenKind.REMAINDER?"'%'":token==TokenKind.RIGHT_BRACE?"'}'":token==TokenKind.RIGHT_BRACKET?"']'":token==TokenKind.RIGHT_PARENTHESIS?"')'":token==TokenKind.SEMICOLON?"';'":token==TokenKind.SHIFT_LEFT?"'<<'":token==TokenKind.SHIFT_RIGHT?"'>>'":token==TokenKind.FROM?"'from'":token==TokenKind.ALIGNOF?"'alignof'":token==TokenKind.AS?"'as'":token==TokenKind.BREAK?"'break'":token==TokenKind.MODULE?"'namespace'":token==TokenKind.CLASS?"'class'":token==TokenKind.CONST?"'const'":token==TokenKind.CONTINUE?"'continue'":token==TokenKind.DECLARE?"'declare'":token==TokenKind.ELSE?"'else'":token==TokenKind.ENUM?"'enum'":token==TokenKind.EXPORT?"'export'":token==TokenKind.EXTENDS?"'extends'":token==TokenKind.FALSE?"'false'":token==TokenKind.FUNCTION?"'function'":token==TokenKind.ANYFUNC?"'anyfunc'":token==TokenKind.IF?"'if'":token==TokenKind.IMPLEMENTS?"'implements'":token==TokenKind.IMPORT?"'import'":token==TokenKind.LET?"'let'":token==TokenKind.NEW?"'new'":token==TokenKind.DELETE?"'delete'":token==TokenKind.NULL?"'null'":token==TokenKind.UNDEFINED?"'undefined'":token==TokenKind.OPERATOR?"'operator'":token==TokenKind.PRIVATE?"'private'":token==TokenKind.PROTECTED?"'protected'":token==TokenKind.PUBLIC?"'public'":token==TokenKind.RETURN?"'return'":token==TokenKind.SIZEOF?"'sizeof'":token==TokenKind.STATIC?"'static'":token==TokenKind.THIS?"'this'":token==TokenKind.TRUE?"'true'":token==TokenKind.UNSAFE?"'unsafe'":token==TokenKind.JAVASCRIPT?"'@JS'":token==TokenKind.START?"'@start'":token==TokenKind.VIRTUAL?"'@virtual'":token==TokenKind.VAR?"'var'":token==TokenKind.WHILE?"'while'":token==TokenKind.PREPROCESSOR_DEFINE?"'#define'":token==TokenKind.PREPROCESSOR_ELIF?"'#elif'":token==TokenKind.PREPROCESSOR_ELSE?"'#else'":token==TokenKind.PREPROCESSOR_ENDIF?"'#endif'":token==TokenKind.PREPROCESSOR_ERROR?"'#error'":token==TokenKind.PREPROCESSOR_IF?"'#if'":token==TokenKind.PREPROCESSOR_NEWLINE?"newline":token==TokenKind.PREPROCESSOR_UNDEF?"'#undef'":token==TokenKind.PREPROCESSOR_WARNING?"'#warning'":(assert_1.assert(!1),null)}function isAlpha(c){return c>="a"&&c<="z"||c>="A"&&c<="Z"||"_"==c}function isASCII(c){return c>=32&&c<=126}function isNumber(c){return c>="0"&&c<="9"}function isDigit(c,base){return""!=c.trim()&&(16==base?isNumber(c)||c>="A"&&c<="F"||c>="a"&&c<="f":!isNaN(c))}function tokenize(source,log){for(var first=null,last=null,contents=source.contents,limit=contents.length,needsPreprocessor=!1,wantNewline=!1,i=0;i=2&&length<=10){var text=contents.slice(start,i);2==length?"as"==text?kind=TokenKind.AS:"if"==text&&(kind=TokenKind.IF):3==length?"let"==text?kind=TokenKind.LET:"new"==text?kind=TokenKind.NEW:"var"==text?kind=TokenKind.VAR:"@JS"==text&&(kind=TokenKind.JAVASCRIPT):4==length?"else"==text?kind=TokenKind.ELSE:"enum"==text?kind=TokenKind.ENUM:"null"==text?kind=TokenKind.NULL:"this"==text?kind=TokenKind.THIS:"true"==text?kind=TokenKind.TRUE:"from"==text&&(kind=TokenKind.FROM):5==length?"break"==text?kind=TokenKind.BREAK:"class"==text?kind=TokenKind.CLASS:"const"==text?kind=TokenKind.CONST:"false"==text?kind=TokenKind.FALSE:"while"==text&&(kind=TokenKind.WHILE):6==length?"export"==text?kind=TokenKind.EXPORT:"module"==text?kind=TokenKind.MODULE:"import"==text?kind=TokenKind.IMPORT:"public"==text?kind=TokenKind.PUBLIC:"return"==text?kind=TokenKind.RETURN:"sizeof"==text?kind=TokenKind.SIZEOF:"static"==text?kind=TokenKind.STATIC:"unsafe"==text?kind=TokenKind.UNSAFE:"@start"==text?kind=TokenKind.START:"delete"==text&&(kind=TokenKind.DELETE):7==length?"alignof"==text?kind=TokenKind.ALIGNOF:"declare"==text?kind=TokenKind.DECLARE:"extends"==text?kind=TokenKind.EXTENDS:"private"==text?kind=TokenKind.PRIVATE:"anyfunc"==text&&(kind=TokenKind.ANYFUNC):"continue"==text?kind=TokenKind.CONTINUE:"@virtual"==text?kind=TokenKind.VIRTUAL:"function"==text?kind=TokenKind.FUNCTION:"implements"==text?kind=TokenKind.IMPLEMENTS:"protected"==text&&(kind=TokenKind.PROTECTED)}}else if(isNumber(c)){var isFloat=!1;if(i"==c)kind=TokenKind.GREATER_THAN,i"==c?(kind=TokenKind.SHIFT_RIGHT,i+=1):"="==c&&(kind=TokenKind.GREATER_THAN_EQUAL,i+=1));else if("#"==c){for(;i=end&&"\n"!=contents[j];)j-=1;j"),this.name=name,this.symbol=symbol,this.isExternal=!1,this.isExported=!1,this.localVariables=[],this.returnType=wasm_type_1.WasmType.VOID,this.code=new stringbuilder_1.StringBuilder(2),this.chunks=[]}return WasmFunction.prototype.toString=function(){return"[WasmFunction]:: "+this.name+"()["+this.signatureIndex+"]"},WasmFunction}();exports.WasmFunction=WasmFunction},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var bytearray_1=__webpack_require__(0),terminal_1=__webpack_require__(2),wasm_section_1=__webpack_require__(1),wasm_parser_1=__webpack_require__(29),WasmBinary=function(){function WasmBinary(data){this.sections=[],this.sectionMap=new Map,void 0!==data?this.read(data):(this.data=new bytearray_1.ByteArray,this.data.log="",this.data.writeUnsignedInt(WasmBinary.MAGIC),this.data.writeUnsignedInt(WasmBinary.VERSION),this.data.log+="0000000: 0061 736d ; WASM_BINARY_MAGIC\n",this.data.log+="0000004: 0100 0000 ; WASM_BINARY_VERSION\n")}return WasmBinary.prototype.read=function(data){if(null!==data&&void 0!==data){this.data=new bytearray_1.ByteArray(data.buffer,data.byteOffset,data.byteLength),this.data.endian=bytearray_1.ByteArray.LITTLE_ENDIAN;var magic=this.data.readUnsignedInt();this.data.readUnsignedInt();magic!==WasmBinary.MAGIC&&terminal_1.Terminal.error("Found unknown WASM magic number "+magic+" instead of "+WasmBinary.MAGIC),this.readNextSection()}},WasmBinary.prototype.readNextSection=function(){if(this.data.bytesAvailable>0){var section=wasm_parser_1.parseSection(this.data);null!==section&&this.sectionMap.set(section.id,this.sections.push(section)-1),this.readNextSection()}else terminal_1.Terminal.log(this.sections.length+" Sections parsed!")},WasmBinary.prototype.reset=function(){this.sections=null,this.sections=[],this.sectionMap=null,this.sectionMap=new Map,this.data=new bytearray_1.ByteArray,this.data.log="",this.data.writeUnsignedInt(WasmBinary.MAGIC),this.data.writeUnsignedInt(WasmBinary.VERSION),this.data.log+="0000000: 0061 736d ; WASM_BINARY_MAGIC\n",this.data.log+="0000004: 0100 0000 ; WASM_BINARY_VERSION\n"},WasmBinary.prototype.appendSection=function(section){this.sectionMap.set(section.id,this.sections.push(section)-1)},WasmBinary.prototype.getSection=function(id,name){var index=this.sectionMap.get(id);if(void 0!==index)return this.sections[index];var section=wasm_parser_1.createSection(id,name);this.appendSection(section);var warn="Section "+wasm_section_1.WasmSection[id]+" created! Reason: Requested section not found in the imported wasm module";return terminal_1.Terminal.warn(warn),section},WasmBinary.prototype.initializeSections=function(){this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Signature)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Import)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Function)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Table)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Memory)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Global)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Export)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Start)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Element)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Code)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Data)),this.appendSection(wasm_parser_1.createSection(wasm_section_1.WasmSection.Custom,"name"))},WasmBinary.prototype.copySections=function(binary){var _this=this;binary.sections.forEach(function(importedSection){switch(importedSection.id){case wasm_section_1.WasmSection.Signature:var section=_this.getSection(importedSection.id);section.signatures=section.signatures.concat(importedSection.signatures);break;case wasm_section_1.WasmSection.Import:var section=_this.getSection(importedSection.id);section.imports=section.imports.concat(importedSection.imports);break;case wasm_section_1.WasmSection.Function:var section=_this.getSection(importedSection.id);section.functions=section.functions.concat(importedSection.functions);break;case wasm_section_1.WasmSection.Table:var section=_this.getSection(importedSection.id);section.tables=section.tables.concat(importedSection.tables);break;case wasm_section_1.WasmSection.Memory:var section=_this.getSection(importedSection.id);section.memory=section.memory.concat(importedSection.memory);break;case wasm_section_1.WasmSection.Global:var section=_this.getSection(importedSection.id);section.globals=section.globals.concat(importedSection.globals);break;case wasm_section_1.WasmSection.Export:var section=_this.getSection(importedSection.id);section.exports=section.exports.concat(importedSection.exports);break;case wasm_section_1.WasmSection.Start:var section=_this.getSection(importedSection.id);-1===section.startFunctionIndex&&(section.startFunctionIndex=importedSection.startFunctionIndex);break;case wasm_section_1.WasmSection.Element:var section=_this.getSection(importedSection.id);section.elements=section.elements.concat(importedSection.elements);break;case wasm_section_1.WasmSection.Code:var section=_this.getSection(importedSection.id);section.functions=section.functions.concat(importedSection.functions);break;case wasm_section_1.WasmSection.Data:var section=_this.getSection(importedSection.id);section.data=section.data.concat(importedSection.data);break;case wasm_section_1.WasmSection.Custom:var section=_this.getSection(importedSection.id);section.names=section.names.concat(importedSection.names)}})},WasmBinary}();WasmBinary.MAGIC=1836278016,WasmBinary.VERSION=1,WasmBinary.SIZE_IN_PAGES=1,WasmBinary.SET_MAX_MEMORY=!1,WasmBinary.MAX_MEMORY=1073741824,WasmBinary.MEMORY_INITIALIZER_BASE=8,exports.WasmBinary=WasmBinary},function(module,exports,__webpack_require__){"use strict";function replaceFileExtension(path,extension){var dot=path.lastIndexOf("."),forward=path.lastIndexOf("/"),backward=path.lastIndexOf("\\");return dot>0&&dot>forward&&dot>backward&&(path=path.slice(0,dot)),path+extension}Object.defineProperty(exports,"__esModule",{value:!0});var type_checker_1=__webpack_require__(67),node_1=__webpack_require__(10),log_1=__webpack_require__(5),preprocessor_1=__webpack_require__(72),scope_1=__webpack_require__(30),scanner_1=__webpack_require__(14),parser_1=__webpack_require__(32),shaking_1=__webpack_require__(70),webassembly_1=__webpack_require__(66),bitness_1=__webpack_require__(16),library_1=__webpack_require__(75),preparser_1=__webpack_require__(71),compile_target_1=__webpack_require__(9),assert_1=__webpack_require__(3),terminal_1=__webpack_require__(2),Compiler=function(){function Compiler(){}return Compiler.prototype.initialize=function(target,outputName,options){void 0===options&&(options={}),assert_1.assert(null==this.log),this.log=new log_1.Log,this.preprocessor=new preprocessor_1.Preprocessor,Compiler.binaryImports=[],this.target=target,this.options=options,this.outputName=outputName,this.librarySource=this.addInput("",library_1.Library.get(target)),this.librarySource.isLibrary=!0,this.runtimeSource=library_1.Library.getRuntime(target),this.wrapperSource=library_1.Library.getWrapper(target),this.createGlobals(),target==compile_target_1.CompileTarget.CPP?this.preprocessor.define("CPP",!0):target==compile_target_1.CompileTarget.JAVASCRIPT?this.preprocessor.define("JS",!0):target==compile_target_1.CompileTarget.WEBASSEMBLY&&this.preprocessor.define("WASM",!0)},Compiler.prototype.createGlobals=function(){var context=new type_checker_1.CheckContext;context.log=this.log,context.target=this.target,context.pointerByteSize=4;var global=new node_1.Node;global.kind=node_1.NodeKind.GLOBAL;var scope=new scope_1.Scope;global.scope=scope,context.anyType=scope.defineNativeType(context.log,"any"),context.errorType=scope.defineNativeType(context.log,""),context.nullType=scope.defineNativeType(context.log,"null"),context.undefinedType=scope.defineNativeType(context.log,"undefined"),context.voidType=scope.defineNativeType(context.log,"void"),this.context=context,this.global=global},Compiler.prototype.addInput=function(name,contents){var source=new log_1.Source;return source.name=name,source.contents=contents,null==this.firstSource?this.firstSource=source:(source.prev=this.lastSource,this.lastSource.next=source),this.lastSource=source,source},Compiler.prototype.addInputBefore=function(name,contents,nextSource){var source=new log_1.Source;return source.name=name,source.contents=contents,nextSource.prev.next=source,source.prev=nextSource.prev,nextSource.prev=source,source.next=nextSource,source},Compiler.prototype.finish=function(){terminal_1.Terminal.time("pre-parsing");for(var source=this.firstSource;null!=source;){if(!preparser_1.preparse(source,this,this.log))return!1;source=source.next}for(terminal_1.Terminal.timeEnd("pre-parsing"),terminal_1.Terminal.time("scanning"),source=this.firstSource;null!=source;)source.firstToken=scanner_1.tokenize(source,this.log),source=source.next;for(terminal_1.Terminal.timeEnd("scanning"),terminal_1.Terminal.time("pre-processing"),source=this.firstSource;null!=source;)this.preprocessor.run(source,this.log),source=source.next;for(terminal_1.Terminal.timeEnd("pre-processing"),terminal_1.Terminal.time("parsing"),source=this.firstSource;null!=source;)null!=source.firstToken&&(source.file=parser_1.parse(source.firstToken,this.log)),source=source.next;terminal_1.Terminal.timeEnd("parsing"),terminal_1.Terminal.time("type-checking");var global=this.global,context=this.context,fullResolve=!0;for(source=this.firstSource;null!=source;){var file=source.file;if(null!=file)for(source.isLibrary?(file.flags|=node_1.NODE_FLAG_LIBRARY,type_checker_1.initialize(context,file,global.scope,type_checker_1.CheckMode.INITIALIZE),type_checker_1.resolve(context,file,global.scope)):type_checker_1.initialize(context,file,global.scope,type_checker_1.CheckMode.NORMAL);null!=file.firstChild;){var child=file.firstChild;child.remove(),global.appendChild(child)}if(source.isLibrary&&this.log.hasErrors()){fullResolve=!1;break}source=source.next}if(fullResolve&&type_checker_1.resolve(context,global,global.scope),terminal_1.Terminal.timeEnd("type-checking"),this.log.hasErrors())return!1;if(terminal_1.Terminal.time("optimizing"),shaking_1.treeShaking(global),terminal_1.Terminal.timeEnd("optimizing"),terminal_1.Terminal.time("emitting"),this.target==compile_target_1.CompileTarget.WEBASSEMBLY){var _a=this.options,longPtr=_a.longPtr,optimize=_a.optimize;webassembly_1.wasmEmit(this,longPtr?bitness_1.Bitness.x64:bitness_1.Bitness.x32,optimize)}return terminal_1.Terminal.timeEnd("emitting"),terminal_1.Terminal.write("Done!"),!0},Compiler}();Compiler.mallocRequired=!1,Compiler.debug=!1,exports.Compiler=Compiler,exports.replaceFileExtension=replaceFileExtension},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Color={DEFAULT_TEXT:12,DEFAULT_BG:8,BLACK:0,WHITE:255,BOLD:1,RED:1,GREEN:2,YELLOW:3,BLUE:4,MAGENTA:5,ORANGE:208};var hexColor={};hexColor[exports.Color.DEFAULT_TEXT]="#000000",hexColor[exports.Color.DEFAULT_BG]="#FFFFFF",hexColor[exports.Color.BLACK]="#000000",hexColor[exports.Color.WHITE]="#FFFFFF",hexColor[exports.Color.BOLD]="",hexColor[exports.Color.RED]="#FF0000",hexColor[exports.Color.GREEN]="#00FF00",hexColor[exports.Color.BLUE]="#0000FF",hexColor[exports.Color.YELLOW]="#FFF600",hexColor[exports.Color.MAGENTA]="#FF00FF",hexColor[exports.Color.ORANGE]="#FF8C00",exports.HexColor=hexColor},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isBrowser=new Function("try {return this===window;}catch(e){ return false;}")(),exports.isWorker=new Function("try {return this===self && typeof importScripts !== 'undefined';}catch(e){return false;}")(),exports.isNode="undefined"!=typeof global&&"undefined"!=typeof process&&void 0!==process.stdout},function(module,exports,__webpack_require__){"use strict";function StringBuilder_new(){var sb=stringBuilderPool;return null!=sb?stringBuilderPool=sb.next:sb=new StringBuilder,sb.clear(),sb}function StringBuilder_appendQuoted(sb,text){var end=0,limit=text.length,start=end;for(sb.appendChar('"');end0;)this._text+=this.indentStr,i-=1},StringBuilder.prototype.appendChar=function(c){return this._text+=c,this},StringBuilder.prototype.appendSlice=function(text,start,end){return this._text+=text.slice(start,end),this},StringBuilder.prototype.breakChunk=function(){return this.chunks.push(this._text),this._text="",this.chunks.length-1},StringBuilder.prototype.appendLine=function(text,indent){return void 0===indent&&(indent=0),this.indent+=indent,this.emitIndent(),this._text+=text+"\n",this},StringBuilder.prototype.appendRaw=function(text){return this._text+=text+"\n",this},StringBuilder.prototype.append=function(text,indent){var _this=this;return void 0===indent&&(indent=0),this.indent+=indent,text.split("\n").forEach(function(line,i){i>0&&(_this._text+="\n",_this.emitIndent()),_this._text+=line}),this},StringBuilder.prototype.removeLastChar=function(){this._text=this._text.substring(0,this._text.length-1)},StringBuilder.prototype.removeLastLinebreak=function(){this._text=this._text.substring(0,this._text.lastIndexOf("\n"))},StringBuilder.prototype.finish=function(){if(this.next=stringBuilderPool,stringBuilderPool=this,this.chunks.length>0){var code_1="";return this.chunks.forEach(function(chunk){code_1+=chunk}),code_1+this._text}return this._text},StringBuilder}();exports.StringBuilder=StringBuilder},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmExport=function(){function WasmExport(name,kind,index){this.name=name,this.kind=kind,this.index=index,this.as=name}return WasmExport}();exports.WasmExport=WasmExport},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmGlobal=function(){function WasmGlobal(type,mutable,name,symbol){this.type=type,this.mutable=mutable,this.name=name,this.symbol=symbol}return WasmGlobal}();exports.WasmGlobal=WasmGlobal},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmImport=function(){function WasmImport(namespace,name,type,signatureIndex,signature){this.namespace=namespace,this.name=name,this.type=type,this.signatureIndex=signatureIndex,this.signature=signature}return WasmImport}();exports.WasmImport=WasmImport},function(module,exports,__webpack_require__){"use strict";function wasmAreSignaturesEqual(a,b){assert_1.assert(null!=a.returnType),assert_1.assert(null!=b.returnType);var x=a.argumentTypes,y=b.argumentTypes;if(x.length!==y.length)return!1;var equal=!0;return x.some(function(x_id,index){return x_id!==y[index]&&(equal=!1,!0)}),a.returnType==b.returnType&&equal}Object.defineProperty(exports,"__esModule",{value:!0});var wasm_type_1=__webpack_require__(6),assert_1=__webpack_require__(3),WasmSignature=function(){function WasmSignature(){this.argumentTypes=[],this.returnType=wasm_type_1.WasmType.VOID}return WasmSignature}();exports.WasmSignature=WasmSignature,exports.wasmAreSignaturesEqual=wasmAreSignaturesEqual},function(module,exports,__webpack_require__){"use strict";function log(array,offset,value,msg){void 0===offset&&(offset=0),void 0===msg&&(msg=""),array.log+=(null!=value?utils_1.toHex(offset+array.position)+": "+utils_1.toHex(value,2)+" ; ":"")+(null!=msg?msg+"\n":"\n")}function logData(array,offset,value,addPosition){void 0===offset&&(offset=0),void 0===addPosition&&(addPosition=!0),array.log+=addPosition?utils_1.toHex(offset+array.position)+": "+utils_1.toHex(value,2):" "+utils_1.toHex(value,2)}Object.defineProperty(exports,"__esModule",{value:!0});var utils_1=__webpack_require__(8);exports.log=log,exports.logData=logData},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmRuntimeProperty=function(){function WasmRuntimeProperty(type,name){this.type=type,this.name=name}return WasmRuntimeProperty}();exports.WasmRuntimeProperty=WasmRuntimeProperty},function(module,exports,__webpack_require__){"use strict";function createSection(id,name){var sectionBinary=null;switch(id){case wasm_section_1.WasmSection.Signature:sectionBinary=new signature_section_1.SignatureSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Import:sectionBinary=new import_section_1.ImportSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Function:sectionBinary=new function_section_1.FunctionSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Table:sectionBinary=new table_section_1.TableSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Memory:sectionBinary=new memory_section_1.MemorySection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Global:sectionBinary=new global_section_1.GlobalSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Export:sectionBinary=new export_section_1.ExportSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Start:sectionBinary=new start_section_1.StartSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Element:sectionBinary=new element_section_1.ElementSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Code:sectionBinary=new code_section_1.CodeSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Data:sectionBinary=new data_section_1.DataSection(new bytearray_1.ByteArray);break;case wasm_section_1.WasmSection.Custom:if(void 0===name){var error="Cannot create custom section without name";throw terminal_1.Terminal.error(error),error}sectionBinary=new name_section_1.CustomSection(name,new bytearray_1.ByteArray)}if(null===sectionBinary){var error="Unknown section id:"+id+" "+(void 0!==name?", "+name:"");throw terminal_1.Terminal.error(error),error}return sectionBinary}function parseSection(data){var id=data.readS32LEB(),name_len=0;0==this.id&&(name_len=data.readU32LEB(),data.readUTFBytes(name_len));var sectionBinary,payload_len=data.readU32LEB(),payload=data.readBytes(new bytearray_1.ByteArray,0,payload_len);switch(id){case wasm_section_1.WasmSection.Signature:sectionBinary=new signature_section_1.SignatureSection(payload),WasmParser.currentSignatures=sectionBinary.signatures;break;case wasm_section_1.WasmSection.Import:sectionBinary=new import_section_1.ImportSection(payload);break;case wasm_section_1.WasmSection.Function:sectionBinary=new function_section_1.FunctionSection(payload),WasmParser.currentFunctions=sectionBinary.functions;break;case wasm_section_1.WasmSection.Table:sectionBinary=new table_section_1.TableSection(payload);break;case wasm_section_1.WasmSection.Memory:sectionBinary=new memory_section_1.MemorySection(payload);break;case wasm_section_1.WasmSection.Global:sectionBinary=new global_section_1.GlobalSection(payload);break;case wasm_section_1.WasmSection.Export:sectionBinary=new export_section_1.ExportSection(payload);break;case wasm_section_1.WasmSection.Start:sectionBinary=new start_section_1.StartSection(payload);break;case wasm_section_1.WasmSection.Element:sectionBinary=new element_section_1.ElementSection(payload);break;case wasm_section_1.WasmSection.Code:sectionBinary=new code_section_1.CodeSection(payload),sectionBinary.functions=WasmParser.currentFunctions;break;case wasm_section_1.WasmSection.Data:sectionBinary=new data_section_1.DataSection(payload)}return void 0!==sectionBinary?(sectionBinary.read(),sectionBinary):null}Object.defineProperty(exports,"__esModule",{value:!0});var bytearray_1=__webpack_require__(0),wasm_section_1=__webpack_require__(1),signature_section_1=__webpack_require__(62),import_section_1=__webpack_require__(59),function_section_1=__webpack_require__(57),table_section_1=__webpack_require__(64),memory_section_1=__webpack_require__(60),global_section_1=__webpack_require__(58),export_section_1=__webpack_require__(56),start_section_1=__webpack_require__(63),element_section_1=__webpack_require__(55),code_section_1=__webpack_require__(53),data_section_1=__webpack_require__(54),name_section_1=__webpack_require__(61),terminal_1=__webpack_require__(2),WasmParser=function(){function WasmParser(){}return WasmParser}();exports.WasmParser=WasmParser,exports.createSection=createSection,exports.parseSection=parseSection},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var FindNested,symbol_1=__webpack_require__(7),type_1=__webpack_require__(31);!function(FindNested){FindNested[FindNested.NORMAL=0]="NORMAL",FindNested[FindNested.ALLOW_INSTANCE_ERRORS=1]="ALLOW_INSTANCE_ERRORS"}(FindNested=exports.FindNested||(exports.FindNested={}));var ScopeHint;!function(ScopeHint){ScopeHint[ScopeHint.NORMAL=0]="NORMAL",ScopeHint[ScopeHint.NOT_BINARY=1]="NOT_BINARY",ScopeHint[ScopeHint.NOT_GETTER=2]="NOT_GETTER",ScopeHint[ScopeHint.NOT_SETTER=3]="NOT_SETTER",ScopeHint[ScopeHint.NOT_UNARY=4]="NOT_UNARY",ScopeHint[ScopeHint.PREFER_GETTER=5]="PREFER_GETTER",ScopeHint[ScopeHint.PREFER_SETTER=6]="PREFER_SETTER"}(ScopeHint=exports.ScopeHint||(exports.ScopeHint={}));var Scope=function(){function Scope(){}return Scope.prototype.findLocal=function(name,hint){for(var symbol=this.firstSymbol,fallback=null;null!=symbol;){if(symbol.name==name)if(hint==ScopeHint.PREFER_GETTER&&symbol.isSetter()||hint==ScopeHint.PREFER_SETTER&&symbol.isGetter())fallback=symbol;else if(!(hint==ScopeHint.NOT_GETTER&&symbol.isGetter()||hint==ScopeHint.NOT_SETTER&&symbol.isSetter()||hint==ScopeHint.NOT_BINARY&&symbol.isBinaryOperator()||hint==ScopeHint.NOT_UNARY&&symbol.isUnaryOperator()))return symbol;symbol=symbol.next}return fallback},Scope.prototype.findNested=function(name,hint,mode){for(var scope=this;null!=scope;){if(null==scope.symbol||scope.symbol.kind!=symbol_1.SymbolKind.TYPE_CLASS||mode==FindNested.ALLOW_INSTANCE_ERRORS||scope.symbol.node.hasParameters()){var local=scope.findLocal(name,hint);if(null!=local)return local}scope=scope.parent}return null},Scope.prototype.define=function(log,symbol,hint){return null!=this.findLocal(symbol.name,hint)?"this"==symbol.name?(log.warning(symbol.range,"Duplicate 'this' symbol"),!0):(log.error(symbol.range,"Duplicate symbol '"+symbol.name+"'"),!1):(null==this.firstSymbol?this.firstSymbol=symbol:this.lastSymbol.next=symbol,this.lastSymbol=symbol,!0)},Scope.prototype.defineNativeType=function(log,name){var symbol=new symbol_1.Symbol;return symbol.kind=symbol_1.SymbolKind.TYPE_NATIVE,symbol.name=name,symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.state=symbol_1.SymbolState.INITIALIZED,this.define(log,symbol,ScopeHint.NORMAL),symbol.resolvedType},Scope}();exports.Scope=Scope},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(7);!function(ConversionKind){ConversionKind[ConversionKind.IMPLICIT=0]="IMPLICIT",ConversionKind[ConversionKind.EXPLICIT=1]="EXPLICIT"}(exports.ConversionKind||(exports.ConversionKind={}));var Type=function(){function Type(){}return Type.prototype.isClass=function(){return null!=this.symbol&&this.symbol.kind==symbol_1.SymbolKind.TYPE_CLASS},Type.prototype.isGeneric=function(){var symbol=this.symbol||this.pointerTo.symbol;return null!=symbol&&symbol.kind==symbol_1.SymbolKind.TYPE_GENERIC},Type.prototype.isTemplate=function(){var symbol=this.symbol||this.pointerTo.symbol;return null!=symbol&&symbol.kind==symbol_1.SymbolKind.TYPE_TEMPLATE},Type.prototype.isEnum=function(){return null!=this.symbol&&this.symbol.kind==symbol_1.SymbolKind.TYPE_ENUM},Type.prototype.isInteger=function(){return null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_NATIVE_INTEGER)||this.isEnum()},Type.prototype.isLong=function(){return null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_NATIVE_LONG)},Type.prototype.isUnsigned=function(){return null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_IS_UNSIGNED)},Type.prototype.isFloat=function(){return null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_NATIVE_FLOAT)},Type.prototype.isDouble=function(){return null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_NATIVE_DOUBLE)},Type.prototype.isArray=function(){return null!=this.symbol&&this.symbol.name.indexOf("Array<")>=0},Type.prototype.isTypedArray=function(){return null!=this.symbol&&("Float32Array"==this.symbol.name||"Float64Array"==this.symbol.name||"Int8Array"==this.symbol.name||"Int16Array"==this.symbol.name||"Int32Array"==this.symbol.name||"Uint8Array"==this.symbol.name||"Uint16Array"==this.symbol.name||"Uint32Array"==this.symbol.name)},Type.prototype.isReference=function(){return null!=this.pointerTo||null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_IS_REFERENCE)},Type.prototype.underlyingType=function(context){return this.isEnum()?context.int32Type:null!=this.pointerTo?context.uint32Type:this},Type.prototype.integerBitCount=function(context){return null!=this.symbol?8*this.symbol.byteSize:0},Type.prototype.integerBitMask=function(context){return-1>>32-this.integerBitCount(context)},Type.prototype.allocationSizeOf=function(context){return null==this.symbol?context.pointerByteSize:this.symbol.byteSize},Type.prototype.allocationAlignmentOf=function(context){return this.allocationSizeOf(context)},Type.prototype.variableSizeOf=function(context){return this.isReference()?context.pointerByteSize:this.symbol.byteSize},Type.prototype.variableAlignmentOf=function(context){return this.variableSizeOf(context)},Type.prototype.pointerType=function(){var type=this.cachedPointerType;return null==type&&(type=new Type,type.pointerTo=this,this.cachedPointerType=type),type},Type.prototype.toString=function(){return null==this.cachedToString&&(this.cachedToString=null!=this.pointerTo?"*"+this.pointerTo.toString():this.symbol.name),this.cachedToString},Type.prototype.findMember=function(name,hint){var symbol=this.symbol;return null!=symbol&&null!=symbol.scope?symbol.scope.findLocal(name,hint):null},Type.prototype.hasInstanceMembers=function(){var symbol=this.symbol;return null!=symbol&&(symbol.kind==symbol_1.SymbolKind.TYPE_TEMPLATE||symbol.kind==symbol_1.SymbolKind.TYPE_CLASS||symbol.kind==symbol_1.SymbolKind.TYPE_NATIVE)},Type}();exports.Type=Type},function(module,exports,__webpack_require__){"use strict";function isRightAssociative(precedence){return precedence==Precedence.ASSIGN||precedence==Precedence.EXPONENT}function parse(firstToken,log){var context=new ParserContext;context.current=firstToken,context.log=log;var file=new node_1.Node;return file.kind=node_1.NodeKind.FILE,context.parseStatements(file)?file:null}Object.defineProperty(exports,"__esModule",{value:!0});var Precedence,scanner_1=__webpack_require__(14),log_1=__webpack_require__(5),node_1=__webpack_require__(10),assert_1=__webpack_require__(3),terminal_1=__webpack_require__(2);!function(Precedence){Precedence[Precedence.LOWEST=0]="LOWEST",Precedence[Precedence.ASSIGN=1]="ASSIGN",Precedence[Precedence.LOGICAL_OR=2]="LOGICAL_OR",Precedence[Precedence.LOGICAL_AND=3]="LOGICAL_AND",Precedence[Precedence.BITWISE_OR=4]="BITWISE_OR",Precedence[Precedence.BITWISE_XOR=5]="BITWISE_XOR",Precedence[Precedence.BITWISE_AND=6]="BITWISE_AND",Precedence[Precedence.EQUAL=7]="EQUAL",Precedence[Precedence.COMPARE=8]="COMPARE",Precedence[Precedence.SHIFT=9]="SHIFT",Precedence[Precedence.ADD=10]="ADD",Precedence[Precedence.MULTIPLY=11]="MULTIPLY",Precedence[Precedence.EXPONENT=12]="EXPONENT",Precedence[Precedence.UNARY_PREFIX=13]="UNARY_PREFIX",Precedence[Precedence.UNARY_POSTFIX=14]="UNARY_POSTFIX",Precedence[Precedence.MEMBER=15]="MEMBER"}(Precedence=exports.Precedence||(exports.Precedence={}));var ParseKind;!function(ParseKind){ParseKind[ParseKind.EXPRESSION=0]="EXPRESSION",ParseKind[ParseKind.TYPE=1]="TYPE"}(ParseKind||(ParseKind={}));var StatementMode;!function(StatementMode){StatementMode[StatementMode.NORMAL=0]="NORMAL",StatementMode[StatementMode.FILE=1]="FILE"}(StatementMode||(StatementMode={}));var ParserContext=function(){function ParserContext(){}return ParserContext.prototype.peek=function(kind){return this.current.kind==kind},ParserContext.prototype.eat=function(kind){return!!this.peek(kind)&&(this.advance(),!0)},ParserContext.prototype.advance=function(){this.peek(scanner_1.TokenKind.END_OF_FILE)||(this.previous=this.current,this.current=this.current.next)},ParserContext.prototype.unexpectedToken=function(){this.lastError!=this.current&&(this.lastError=this.current,this.log.error(this.current.range,"Unexpected "+scanner_1.tokenToString(this.current.kind)))},ParserContext.prototype.expect=function(kind){if(!this.peek(kind)){if(this.lastError!=this.current){this.lastError=this.current;var previousLine=this.previous.range.enclosingLine(),currentLine=this.current.range.enclosingLine();kind==scanner_1.TokenKind.IDENTIFIER||previousLine.equals(currentLine)?this.log.error(this.current.range,"Expected "+scanner_1.tokenToString(kind)+" but found "+scanner_1.tokenToString(this.current.kind)):this.log.error(previousLine.rangeAtEnd(),"Expected "+scanner_1.tokenToString(kind))}return!1}return this.advance(),!0},ParserContext.prototype.parseUnaryPrefix=function(kind,mode){assert_1.assert(node_1.isUnary(kind));var token=this.current;this.advance();var value=this.parseExpression(Precedence.UNARY_PREFIX,mode);return null==value?null:node_1.createUnary(kind,value).withRange(log_1.spanRanges(token.range,value.range)).withInternalRange(token.range)},ParserContext.prototype.parseBinary=function(kind,left,localPrecedence,operatorPrecedence){if(localPrecedence>=operatorPrecedence)return left;var token=this.current;this.advance();var precedence=isRightAssociative(operatorPrecedence)?operatorPrecedence-1:operatorPrecedence,right=this.parseExpression(precedence,ParseKind.EXPRESSION);return null==right?null:node_1.createBinary(kind,left,right).withRange(log_1.spanRanges(left.range,right.range)).withInternalRange(token.range)},ParserContext.prototype.parseUnaryPostfix=function(kind,value,localPrecedence){if(localPrecedence>=Precedence.UNARY_POSTFIX)return value;var token=this.current;return this.advance(),node_1.createUnary(kind,value).withRange(log_1.spanRanges(value.range,token.range)).withInternalRange(token.range)},ParserContext.prototype.parseQuotedString=function(range){assert_1.assert(range.end-range.start>=2);for(var text=range.source.contents,end=range.start+1,limit=range.end-1,start=end,quotedString="";end')":end.kind==scanner_1.TokenKind.GREATER_THAN_EQUAL?"(it is automatically derived from '<')":""))):this.unexpectedToken()}else{if(null==parent&&(assert_1.assert(token.kind==scanner_1.TokenKind.FUNCTION),this.advance()),nameRange=this.current.range,!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;name=nameRange.toString()}var node=node_1.createFunction(name);if(node.firstFlag=firstFlag,node.flags=node_1.allFlags(firstFlag),isOperator&&(node.flags=node.flags|node_1.NODE_FLAG_OPERATOR),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;node.appendChild(parameters)}if(!this.expect(scanner_1.TokenKind.LEFT_PARENTHESIS))return null;if(!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))for(;;){var firstArgumentFlag=this.parseFlags(),argument=this.current;if(!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;var type=void 0,value=null,range=argument.range;if(this.expect(scanner_1.TokenKind.COLON)){if(type=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;type.appendChild(parameters)}if(null!=type)range=log_1.spanRanges(range,type.range);else{if(!this.peek(scanner_1.TokenKind.COMMA)&&!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;type=node_1.createParseError()}}else(this.peek(scanner_1.TokenKind.COMMA)||this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))&&(type=node_1.createParseError());for(var firstType=type;this.eat(scanner_1.TokenKind.BITWISE_OR);){var aliasType=this.parseType();if(this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;aliasType.appendChild(parameters)}if(null!=aliasType)range=log_1.spanRanges(range,aliasType.range);else{if(!this.peek(scanner_1.TokenKind.COMMA)&&!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;aliasType=node_1.createParseError()}type.appendChild(aliasType),type=aliasType}this.eat(scanner_1.TokenKind.ASSIGN)&&(value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION));var variable=node_1.createVariable(argument.range.toString(),firstType,value);if(variable.firstFlag=firstArgumentFlag,variable.flags=node_1.allFlags(firstArgumentFlag),node.appendChild(variable.withRange(range).withInternalRange(argument.range)),!this.eat(scanner_1.TokenKind.COMMA))break}if(!this.expect(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;var returnType;if(node.isAnyfunc())returnType=node_1.createAny();else if("constructor"==node.stringValue)returnType=new node_1.Node,returnType.kind=node_1.NodeKind.NAME,returnType.stringValue=parent.stringValue;else if(this.expect(scanner_1.TokenKind.COLON)){if(returnType=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;returnType.appendChild(parameters)}if(null==returnType){if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;returnType=node_1.createParseError()}for(var firstType=returnType;this.eat(scanner_1.TokenKind.BITWISE_OR);){var aliasType=this.parseType();if(this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;aliasType.appendChild(parameters)}if(null==aliasType){if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;aliasType=node_1.createParseError()}firstType.appendChild(aliasType),firstType=aliasType}}else{if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;returnType=node_1.createParseError()}node.appendChild(returnType);var block=null,semicolon=this.current;if(this.eat(scanner_1.TokenKind.SEMICOLON))block=node_1.createEmpty().withRange(semicolon.range);else if(null==(block=this.parseBlock()))return null;return null!=parent&&parent.appendChild(node),node.appendChild(block),node.withRange(log_1.spanRanges(token.range,block.range)).withInternalRange(nameRange)},ParserContext.prototype.parseVariables=function(firstFlag,parent){var token=this.current;null==parent&&(assert_1.assert(token.kind==scanner_1.TokenKind.CONST||token.kind==scanner_1.TokenKind.LET||token.kind==scanner_1.TokenKind.VAR),this.advance());var node=token.kind==scanner_1.TokenKind.CONST?node_1.createConstants():node_1.createVariables();for(node.firstFlag=firstFlag;;){var name=this.current;if(!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;var type=null;if(this.eat(scanner_1.TokenKind.COLON)){if(type=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;type.appendChild(parameters)}if(null==type)return null}var value=null;if(this.eat(scanner_1.TokenKind.ASSIGN)&&null==(value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION)))return null;var range=null!=value?log_1.spanRanges(name.range,value.range):null!=type?log_1.spanRanges(name.range,type.range):name.range,variable=node_1.createVariable(name.range.toString(),type,value);if(variable.firstFlag=firstFlag,variable.flags=node_1.allFlags(firstFlag),(null!=parent?parent:node).appendChild(variable.withRange(range).withInternalRange(name.range)),!this.eat(scanner_1.TokenKind.COMMA))break}var semicolon=this.current;return this.expect(scanner_1.TokenKind.SEMICOLON),node.withRange(log_1.spanRanges(token.range,semicolon.range))},ParserContext.prototype.parseLoopJump=function(kind){var token=this.current;this.advance(),this.expect(scanner_1.TokenKind.SEMICOLON);var node=new node_1.Node;return node.kind=kind,node.withRange(token.range)},ParserContext.prototype.parseFlags=function(){for(var firstFlag=null,lastFlag=null;;){var token=this.current,flag=void 0;if(this.eat(scanner_1.TokenKind.DECLARE))flag=node_1.NODE_FLAG_DECLARE;else if(this.eat(scanner_1.TokenKind.EXPORT))flag=node_1.NODE_FLAG_EXPORT;else if(this.eat(scanner_1.TokenKind.PRIVATE))flag=node_1.NODE_FLAG_PRIVATE;else if(this.eat(scanner_1.TokenKind.PROTECTED))flag=node_1.NODE_FLAG_PROTECTED;else if(this.eat(scanner_1.TokenKind.PUBLIC))flag=node_1.NODE_FLAG_PUBLIC;else if(this.eat(scanner_1.TokenKind.STATIC))flag=node_1.NODE_FLAG_STATIC;else if(this.eat(scanner_1.TokenKind.ANYFUNC))flag=node_1.NODE_FLAG_ANYFUNC;else if(this.eat(scanner_1.TokenKind.UNSAFE))flag=node_1.NODE_FLAG_UNSAFE;else if(this.eat(scanner_1.TokenKind.JAVASCRIPT))flag=node_1.NODE_FLAG_JAVASCRIPT;else if(this.eat(scanner_1.TokenKind.START))flag=node_1.NODE_FLAG_START;else{if(!this.eat(scanner_1.TokenKind.VIRTUAL))return firstFlag;flag=node_1.NODE_FLAG_VIRTUAL}var link=new node_1.NodeFlag;link.flag=flag,link.range=token.range,null==firstFlag?firstFlag=link:lastFlag.next=link,lastFlag=link}},ParserContext.prototype.parseUnsafe=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_UNSAFE,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseJavaScript=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_JAVASCRIPT,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseStart=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_START,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseVirtual=function(firstFlag){var token=this.current;this.advance();var node=this.parseFunction(firstFlag,null);return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_VIRTUAL,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseStatement=function(mode){var firstFlag=mode==StatementMode.FILE?this.parseFlags():null;if(this.peek(scanner_1.TokenKind.IMPORT)&&null==firstFlag)return this.parseImports();if(this.peek(scanner_1.TokenKind.JAVASCRIPT)&&null==firstFlag)return this.parseJavaScript();if(this.peek(scanner_1.TokenKind.START)&&null==firstFlag)return this.parseStart();if(this.peek(scanner_1.TokenKind.CONST)||this.peek(scanner_1.TokenKind.LET)||this.peek(scanner_1.TokenKind.VAR))return this.parseVariables(firstFlag,null);if(this.peek(scanner_1.TokenKind.FUNCTION))return this.parseFunction(firstFlag,null);if(this.peek(scanner_1.TokenKind.VIRTUAL))return this.parseVirtual(firstFlag);if(this.peek(scanner_1.TokenKind.MODULE))return this.parseModule(firstFlag);if(this.peek(scanner_1.TokenKind.CLASS))return this.parseClass(firstFlag);if(this.peek(scanner_1.TokenKind.ENUM))return this.parseEnum(firstFlag);if(null!=firstFlag)return this.unexpectedToken(),null;if(this.peek(scanner_1.TokenKind.LEFT_BRACE))return this.parseBlock();if(this.peek(scanner_1.TokenKind.BREAK))return this.parseLoopJump(node_1.NodeKind.BREAK);if(this.peek(scanner_1.TokenKind.CONTINUE))return this.parseLoopJump(node_1.NodeKind.CONTINUE);if(this.peek(scanner_1.TokenKind.IF))return this.parseIf();if(this.peek(scanner_1.TokenKind.WHILE))return this.parseWhile();if(this.peek(scanner_1.TokenKind.DELETE))return this.parseDelete();if(this.peek(scanner_1.TokenKind.RETURN))return this.parseReturn();if(this.peek(scanner_1.TokenKind.SEMICOLON))return this.parseEmpty();var value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION);if(null==value)return null;var semicolon=this.current;return this.expect(scanner_1.TokenKind.SEMICOLON),node_1.createExpression(value).withRange(log_1.spanRanges(value.range,semicolon.range))},ParserContext.prototype.parseStatements=function(parent){for(;!this.peek(scanner_1.TokenKind.END_OF_FILE)&&!this.peek(scanner_1.TokenKind.RIGHT_BRACE);){var child=this.parseStatement(parent.kind==node_1.NodeKind.FILE?StatementMode.FILE:StatementMode.NORMAL);if(null==child)return!1;child.kind===node_1.NodeKind.RETURN&&(parent.returnNode=child),parent.appendChild(child)}return!0},ParserContext.prototype.parseInt=function(range,node){var source=range.source,contents=source.contents;return node.intValue=parseInt(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext.prototype.parseFloat=function(range,node){var source=range.source,contents=source.contents;return node.floatValue=parseFloat(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext.prototype.parseDouble=function(range,node){var source=range.source,contents=source.contents;return node.doubleValue=parseFloat(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext}();exports.parse=parse},function(module,exports,__webpack_require__){"use strict";function isBinaryImport(name){var found=!1;return BinaryImporter.imports.some(function(_import){return found=_import.name===name}),found}Object.defineProperty(exports,"__esModule",{value:!0});var filesystem_1=__webpack_require__(15),wasm_binary_1=__webpack_require__(18),wasm_section_1=__webpack_require__(1),wasm_external_kind_1=__webpack_require__(11),terminal_1=__webpack_require__(2),wasm_binary_import_1=__webpack_require__(73),BinaryImporter=function(){function BinaryImporter(){}return BinaryImporter.reset=function(){BinaryImporter.binaries=[],BinaryImporter.imports=[]},BinaryImporter.resolveWasmBinaryImport=function(imports,from,importPath){var binary=filesystem_1.FileSystem.readBinaryFile(importPath);null!==binary&&void 0!==binary||(binary=filesystem_1.FileSystem.readBinaryFile(from));var wasmBinary=new wasm_binary_1.WasmBinary(binary),importSection=wasmBinary.getSection(wasm_section_1.WasmSection.Import),importCount=importSection.imports.length,exportSection=wasmBinary.getSection(wasm_section_1.WasmSection.Export),signatureSection=wasmBinary.getSection(wasm_section_1.WasmSection.Signature),functionSection=wasmBinary.getSection(wasm_section_1.WasmSection.Function),declarations="";if(null!==exportSection&&null!==signatureSection&&null!==functionSection){var exports_1=exportSection.exports;exports_1.length>0&&(imports.forEach(function(_import){var matchedExport=exports_1.find(function(_export){return _export.name===_import});if(void 0===matchedExport||matchedExport.kind!==wasm_external_kind_1.WasmExternalKind.Function){var error="Cannot find function "+_import+" in wasm binary "+from;throw terminal_1.Terminal.error(error),error}var _function=functionSection.functions[matchedExport.index-importCount],signature=signatureSection.signatures[_function.signatureIndex],binaryImport=new wasm_binary_import_1.WasmBinaryImport(_import,signature,matchedExport.index);declarations+=binaryImport.declaration+"\n",BinaryImporter.imports.push(binaryImport)}),BinaryImporter.binaries.push(wasmBinary))}return declarations},BinaryImporter}();BinaryImporter.binaries=[],BinaryImporter.imports=[],exports.BinaryImporter=BinaryImporter,exports.isBinaryImport=isBinaryImport},function(module,exports,__webpack_require__){"use strict";function main_addArgument(text){var argument=new CommandLineArgument;argument.text=text,null==firstArgument?firstArgument=argument:lastArgument.next=argument,lastArgument=argument}function main_reset(){firstArgument=null,lastArgument=null}function printUsage(){terminal_1.Terminal.write("\nUsage: tc [FLAGS] [INPUTS]\n\n --help Print this message.\n --out [PATH] Emit code to PATH (the target format is the file extension).\n --wasm Explicit webassembly output\n --define [NAME] Define the flag NAME in all input files.\n\nExamples:\n\n tc src/*.tbs --out main.wasm\n")}function main_entry(){var output,target=compile_target_1.CompileTarget.NONE,argument=firstArgument,inputCount=0;if(null==firstArgument)return printUsage(),1;for(;null!=argument;){var text=argument.text;if(text.startsWith("-")){if("-h"==text||"-help"==text||"--help"==text||"/?"==text)return printUsage(),0;if("--cpp"==text)target=compile_target_1.CompileTarget.CPP;else if("--js"==text)target=compile_target_1.CompileTarget.JAVASCRIPT;else if("--wasm"==text)target=compile_target_1.CompileTarget.WEBASSEMBLY;else if("--define"==text&&null!=argument.next)argument=argument.next;else if("--out"==text&&null!=argument.next)argument=argument.next,output=argument.text;else{if("--bundle"!=text&&"-b"!=text)return terminal_1.Terminal.error("Invalid flag: "+text),1;argument=argument.next,!0}}else inputCount+=1;argument=argument.next}if(0==inputCount)return terminal_1.Terminal.error("No input files"),1;if(null==output)return terminal_1.Terminal.error("Missing an output file (use the --out flag)"),1;if(target==compile_target_1.CompileTarget.NONE){if(!output.endsWith(".wasm"))return terminal_1.Terminal.error("Missing a target (use either --js or --wasm)"),1;target=compile_target_1.CompileTarget.WEBASSEMBLY}var compiler=new compiler_1.Compiler;for(compiler.initialize(target,output),argument=firstArgument;null!=argument;){var text=argument.text;if("--define"==text)argument=argument.next,compiler.preprocessor.define(argument.text,!0);else if("--out"==text)argument=argument.next;else if(!text.startsWith("-")){var contents=filesystem_1.FileSystem.readTextFile(text);if(null==contents)return terminal_1.Terminal.error("Cannot read from "+text),1;compiler.addInput(text,contents)}argument=argument.next}if(compiler.finish(),log_1.writeLogToTerminal(compiler.log),!compiler.log.hasErrors())try{switch(target){case compile_target_1.CompileTarget.CPP:filesystem_1.FileSystem.writeTextFile(output,compiler.outputCPP),filesystem_1.FileSystem.writeTextFile(compiler_1.replaceFileExtension(output,".h"),compiler.outputH);break;case compile_target_1.CompileTarget.JAVASCRIPT:filesystem_1.FileSystem.writeTextFile(output,compiler.outputJS);break;case compile_target_1.CompileTarget.WEBASSEMBLY:if(void 0===compiler.outputWASM)return terminal_1.Terminal.error("Compile error!"),1;filesystem_1.FileSystem.writeBinaryFile(output,compiler.outputWASM),filesystem_1.FileSystem.writeTextFile(compiler_1.replaceFileExtension(output,".wast"),compiler.outputWAST),filesystem_1.FileSystem.writeTextFile(output+".log",compiler.outputWASM.log)}return 0}catch(e){return terminal_1.Terminal.error("Cannot write to "+output),console.error(e),1}return terminal_1.Terminal.write("\n"),1}function compileString(source,options){void 0===options&&(options=compiler_options_1.defaultCompilerOptions),terminal_1.Terminal.silent=options.silent;var input="/virtual/inline.tbs";filesystem_1.FileSystem.writeTextFile(input,source,!0);var compiler=new compiler_1.Compiler;return compiler.initialize(options.target,"/virtual/inline.wasm",options),compiler.addInput(input,source),compiler.finish(),terminal_1.Terminal.silent=!1,compiler.log.hasErrors()?(options.silent&&!options.logError||log_1.writeLogToTerminal(compiler.log),{success:!1,log:compiler.log}):{success:!0,wasm:compiler.outputWASM.array,wast:compiler.outputWAST}}Object.defineProperty(exports,"__esModule",{value:!0});var log_1=__webpack_require__(5),compiler_1=__webpack_require__(19),compile_target_1=__webpack_require__(9),terminal_1=__webpack_require__(2),filesystem_1=__webpack_require__(15),compiler_options_1=__webpack_require__(68),color_1=__webpack_require__(20),CommandLineArgument=function(){function CommandLineArgument(){}return CommandLineArgument}();exports.CommandLineArgument=CommandLineArgument;var firstArgument,lastArgument;exports.main_addArgument=main_addArgument,exports.main_reset=main_reset,exports.printUsage=printUsage,exports.main_entry=main_entry,exports.main={addArgument:main_addArgument,reset:main_reset,entry:main_entry},exports.compileString=compileString,exports.version="1.0.6-beta",terminal_1.Terminal.setTextColor(color_1.Color.MAGENTA),terminal_1.Terminal.write("~~~~~~~~~~~~~~~~~~~~~~~~~| TurboScript "+exports.version+" |~~~~~~~~~~~~~~~~~~~~~~~~~\n"),terminal_1.Terminal.clearColor(),exports.default={version:exports.version,main:exports.main,compileString:compileString}},function(module,exports){module.exports=new Uint8Array([0,97,115,109,1,0,0,0,1,175,128,128,128,0,7,96,3,127,127,127,1,127,96,2,127,127,1,127,96,1,127,1,127,96,2,127,127,0,96,4,127,127,127,127,1,127,96,5,127,127,127,127,127,1,127,96,3,127,127,127,0,3,135,128,128,128,0,6,0,0,0,1,3,2,4,132,128,128,128,0,1,112,0,0,5,131,128,128,128,0,1,0,1,7,209,128,128,128,0,7,6,109,101,109,111,114,121,2,0,6,109,101,109,99,109,112,0,0,6,109,101,109,99,112,121,0,1,6,109,101,109,115,101,116,0,2,13,109,115,112,97,99,101,95,109,97,108,108,111,99,0,3,11,109,115,112,97,99,101,95,102,114,101,101,0,4,11,109,115,112,97,99,101,95,105,110,105,116,0,5,9,129,128,128,128,0,0,10,151,219,128,128,0,6,183,130,128,128,0,1,5,127,2,127,2,64,2,64,2,64,2,64,2,64,32,0,65,7,113,34,3,32,1,65,7,113,71,13,0,65,8,32,3,107,34,6,4,64,65,0,33,3,3,64,32,0,32,3,106,34,7,45,0,0,32,1,32,3,106,34,4,45,0,0,71,13,3,32,3,65,1,106,34,3,32,6,73,13,0,11,32,1,32,3,106,33,1,32,0,32,3,106,33,0,32,2,32,3,107,33,2,11,32,2,65,4,73,13,0,65,0,33,3,3,64,32,0,32,3,106,40,2,0,32,1,32,3,106,40,2,0,71,13,4,32,3,65,4,106,33,3,32,2,65,124,106,34,2,65,3,75,13,0,11,32,0,32,3,106,33,0,32,1,32,3,106,33,1,11,65,1,32,2,107,33,3,2,64,2,64,3,64,32,3,34,2,65,1,70,13,1,32,2,65,1,106,33,3,32,1,45,0,0,33,6,32,0,45,0,0,33,7,32,1,65,1,106,34,4,33,1,32,0,65,1,106,34,5,33,0,32,7,32,6,70,13,0,12,2,11,0,11,32,1,33,4,32,0,33,5,11,65,0,32,2,107,69,13,1,12,3,11,32,4,65,1,106,33,4,32,7,65,1,106,33,5,32,2,32,3,107,13,2,11,65,0,15,11,32,0,33,5,32,1,33,4,11,32,5,45,0,0,32,4,45,0,0,107,11,11,151,140,128,128,0,1,8,127,2,127,2,64,2,64,2,64,32,2,69,32,1,65,3,113,69,114,69,4,64,32,0,33,5,2,64,3,64,32,5,32,1,45,0,0,58,0,0,32,2,65,127,106,33,3,32,5,65,1,106,33,5,32,1,65,1,106,33,1,32,2,65,1,70,13,1,32,3,33,2,32,1,65,3,113,13,0,11,11,32,5,65,3,113,69,13,1,12,2,11,32,2,33,3,32,0,34,5,65,3,113,13,1,11,2,64,32,3,65,16,79,4,64,32,5,32,3,65,112,106,34,6,65,112,113,34,7,65,16,106,34,8,106,33,4,32,1,33,2,3,64,32,5,32,2,40,2,0,54,2,0,32,5,65,4,106,32,2,65,4,106,40,2,0,54,2,0,32,5,65,8,106,32,2,65,8,106,40,2,0,54,2,0,32,5,65,12,106,32,2,65,12,106,40,2,0,54,2,0,32,5,65,16,106,33,5,32,2,65,16,106,33,2,32,3,65,112,106,34,3,65,15,75,13,0,11,32,6,32,7,107,33,3,32,1,32,8,106,33,1,12,1,11,32,5,33,4,11,32,3,65,8,113,4,64,32,4,32,1,40,2,0,54,2,0,32,4,32,1,40,2,4,54,2,4,32,1,65,8,106,33,1,32,4,65,8,106,33,4,11,32,3,65,4,113,4,64,32,4,32,1,40,2,0,54,2,0,32,1,65,4,106,33,1,32,4,65,4,106,33,4,11,32,3,65,2,113,4,64,32,4,32,1,45,0,0,58,0,0,32,4,32,1,45,0,1,58,0,1,32,4,65,2,106,33,4,32,1,65,2,106,33,1,11,32,3,65,1,113,69,13,1,32,4,32,1,45,0,0,58,0,0,32,0,15,11,2,64,2,64,2,64,2,64,2,64,2,64,2,64,32,3,65,32,73,13,0,32,5,65,3,113,34,2,65,3,70,13,1,32,2,65,2,70,13,2,32,2,65,1,71,13,0,32,5,32,1,45,0,1,58,0,1,32,5,32,1,40,2,0,34,7,58,0,0,32,5,32,1,45,0,2,58,0,2,32,5,65,3,106,33,2,32,3,65,125,106,34,4,65,17,73,13,3,32,1,65,16,106,33,6,32,3,65,109,106,33,8,32,1,32,3,65,108,106,65,112,113,34,9,65,19,106,34,10,106,33,1,3,64,32,2,32,6,65,116,106,40,2,0,34,3,65,8,116,32,7,65,24,118,114,54,2,0,32,2,65,4,106,32,6,65,120,106,40,2,0,34,7,65,8,116,32,3,65,24,118,114,54,2,0,32,2,65,8,106,32,6,65,124,106,40,2,0,34,3,65,8,116,32,7,65,24,118,114,54,2,0,32,2,65,12,106,32,6,40,2,0,34,7,65,8,116,32,3,65,24,118,114,54,2,0,32,2,65,16,106,33,2,32,6,65,16,106,33,6,32,4,65,112,106,34,4,65,16,75,13,0,11,32,8,32,9,107,33,4,32,5,32,10,106,33,2,12,6,11,32,3,33,4,32,5,33,2,12,5,11,32,5,32,1,40,2,0,34,7,58,0,0,32,5,65,1,106,33,2,32,3,65,127,106,34,4,65,19,73,13,2,32,1,65,16,106,33,6,32,3,65,111,106,33,8,32,1,32,3,65,108,106,65,112,113,34,9,65,17,106,34,10,106,33,1,3,64,32,2,32,6,65,116,106,40,2,0,34,3,65,24,116,32,7,65,8,118,114,54,2,0,32,2,65,4,106,32,6,65,120,106,40,2,0,34,7,65,24,116,32,3,65,8,118,114,54,2,0,32,2,65,8,106,32,6,65,124,106,40,2,0,34,3,65,24,116,32,7,65,8,118,114,54,2,0,32,2,65,12,106,32,6,40,2,0,34,7,65,24,116,32,3,65,8,118,114,54,2,0,32,2,65,16,106,33,2,32,6,65,16,106,33,6,32,4,65,112,106,34,4,65,18,75,13,0,11,32,8,32,9,107,33,4,32,5,32,10,106,33,2,12,4,11,32,5,32,1,40,2,0,34,7,58,0,0,32,5,32,1,45,0,1,58,0,1,32,5,65,2,106,33,2,32,3,65,126,106,34,4,65,18,73,13,2,32,1,65,16,106,33,6,32,3,65,110,106,33,8,32,1,32,3,65,108,106,65,112,113,34,9,65,18,106,34,10,106,33,1,3,64,32,2,32,6,65,116,106,40,2,0,34,3,65,16,116,32,7,65,16,118,114,54,2,0,32,2,65,4,106,32,6,65,120,106,40,2,0,34,7,65,16,116,32,3,65,16,118,114,54,2,0,32,2,65,8,106,32,6,65,124,106,40,2,0,34,3,65,16,116,32,7,65,16,118,114,54,2,0,32,2,65,12,106,32,6,40,2,0,34,7,65,16,116,32,3,65,16,118,114,54,2,0,32,2,65,16,106,33,2,32,6,65,16,106,33,6,32,4,65,112,106,34,4,65,17,75,13,0,11,32,8,32,9,107,33,4,32,5,32,10,106,33,2,12,3,11,32,1,65,3,106,33,1,12,2,11,32,1,65,1,106,33,1,12,1,11,32,1,65,2,106,33,1,11,32,4,65,16,113,4,64,32,2,32,1,45,0,1,58,0,1,32,2,32,1,45,0,2,58,0,2,32,2,32,1,45,0,3,58,0,3,32,2,32,1,45,0,4,58,0,4,32,2,32,1,45,0,5,58,0,5,32,2,32,1,45,0,6,58,0,6,32,2,32,1,45,0,7,58,0,7,32,2,32,1,45,0,8,58,0,8,32,2,32,1,45,0,9,58,0,9,32,2,32,1,45,0,10,58,0,10,32,2,32,1,45,0,11,58,0,11,32,2,32,1,45,0,12,58,0,12,32,2,32,1,45,0,13,58,0,13,32,2,32,1,45,0,14,58,0,14,32,2,32,1,45,0,0,58,0,0,32,2,32,1,45,0,15,58,0,15,32,2,65,16,106,33,2,32,1,65,16,106,33,1,11,32,4,65,8,113,4,64,32,2,32,1,45,0,0,58,0,0,32,2,32,1,45,0,1,58,0,1,32,2,32,1,45,0,2,58,0,2,32,2,32,1,45,0,3,58,0,3,32,2,32,1,45,0,4,58,0,4,32,2,32,1,45,0,5,58,0,5,32,2,32,1,45,0,6,58,0,6,32,2,32,1,45,0,7,58,0,7,32,2,65,8,106,33,2,32,1,65,8,106,33,1,11,32,4,65,4,113,4,64,32,2,32,1,45,0,0,58,0,0,32,2,32,1,45,0,1,58,0,1,32,2,32,1,45,0,2,58,0,2,32,2,32,1,45,0,3,58,0,3,32,2,65,4,106,33,2,32,1,65,4,106,33,1,11,32,4,65,2,113,4,64,32,2,32,1,45,0,0,58,0,0,32,2,32,1,45,0,1,58,0,1,32,2,65,2,106,33,2,32,1,65,2,106,33,1,11,32,4,65,1,113,69,13,0,32,2,32,1,45,0,0,58,0,0,32,0,15,11,32,0,11,11,255,130,128,128,0,2,2,127,1,126,2,127,2,64,32,2,69,13,0,32,0,32,2,106,34,3,65,127,106,32,1,58,0,0,32,0,32,1,58,0,0,32,2,65,3,73,13,0,32,3,65,126,106,32,1,58,0,0,32,0,32,1,58,0,1,32,3,65,125,106,32,1,58,0,0,32,0,32,1,58,0,2,32,2,65,7,73,13,0,32,3,65,124,106,32,1,58,0,0,32,0,32,1,58,0,3,32,2,65,9,73,13,0,32,0,65,0,32,0,107,65,3,113,34,4,106,34,3,32,1,65,255,1,113,65,129,130,132,8,108,34,1,54,2,0,32,3,32,2,32,4,107,65,124,113,34,4,106,34,2,65,124,106,32,1,54,2,0,32,4,65,9,73,13,0,32,3,32,1,54,2,8,32,3,32,1,54,2,4,32,2,65,120,106,32,1,54,2,0,32,2,65,116,106,32,1,54,2,0,32,4,65,25,73,13,0,32,3,32,1,54,2,16,32,3,32,1,54,2,12,32,3,32,1,54,2,20,32,3,32,1,54,2,24,32,2,65,104,106,32,1,54,2,0,32,2,65,100,106,32,1,54,2,0,32,2,65,108,106,32,1,54,2,0,32,2,65,112,106,32,1,54,2,0,32,4,32,3,65,4,113,65,24,114,34,4,107,34,2,65,32,73,13,0,32,1,173,34,5,66,32,134,32,5,132,33,5,32,3,32,4,106,33,1,3,64,32,1,32,5,55,3,0,32,1,65,8,106,32,5,55,3,0,32,1,65,16,106,32,5,55,3,0,32,1,65,24,106,32,5,55,3,0,32,1,65,32,106,33,1,32,2,65,96,106,34,2,65,31,75,13,0,11,11,32,0,11,11,162,181,128,128,0,1,10,127,2,127,65,192,0,40,2,0,65,16,107,33,7,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,32,1,65,244,1,77,4,64,32,0,40,2,0,34,4,65,16,32,1,65,11,106,65,120,113,32,1,65,11,73,27,34,5,65,3,118,34,2,118,34,1,65,3,113,69,13,1,32,0,32,1,65,127,115,65,1,113,32,2,106,34,3,65,3,116,106,34,5,65,48,106,40,2,0,34,1,65,8,106,33,6,32,1,40,2,8,34,2,32,5,65,40,106,34,5,70,13,2,32,0,40,2,16,32,2,75,32,2,40,2,12,32,1,71,114,13,3,32,5,65,8,106,32,2,54,2,0,32,2,65,12,106,32,5,54,2,0,12,3,11,65,127,33,5,32,1,65,191,127,75,13,17,32,1,65,11,106,34,2,65,120,113,33,5,32,0,40,2,4,34,10,69,13,17,2,127,65,0,32,2,65,8,118,34,2,69,13,0,26,65,31,32,5,65,255,255,255,7,75,13,0,26,32,5,65,14,32,2,32,2,65,128,254,63,106,65,16,118,65,8,113,34,3,116,34,2,65,128,224,31,106,65,16,118,65,4,113,34,4,32,3,114,32,2,32,4,116,34,2,65,128,128,15,106,65,16,118,65,2,113,34,3,114,107,32,2,32,3,116,65,15,118,106,34,2,65,7,106,118,65,1,113,32,2,65,1,116,114,11,33,9,65,0,32,5,107,33,3,32,0,32,9,65,2,116,106,65,176,2,106,40,2,0,34,2,69,13,4,32,5,65,0,65,25,32,9,65,1,118,107,32,9,65,31,70,27,116,33,6,65,0,33,1,65,0,33,4,3,64,32,2,40,2,4,65,120,113,32,5,107,34,8,32,3,73,4,64,32,8,33,3,32,2,33,4,32,8,69,13,8,11,32,1,32,2,65,20,106,40,2,0,34,8,32,8,32,2,32,6,65,29,118,65,4,113,106,65,16,106,40,2,0,34,2,70,27,32,1,32,8,27,33,1,32,6,32,2,65,0,71,116,33,6,32,2,13,0,11,32,1,32,4,114,69,13,4,12,14,11,32,5,32,0,40,2,8,34,3,77,13,16,32,1,69,13,4,32,0,65,40,106,34,7,32,1,32,2,116,65,2,32,2,116,34,1,65,0,32,1,107,114,113,34,1,65,0,32,1,107,113,65,127,106,34,1,32,1,65,12,118,65,16,113,34,1,118,34,2,65,5,118,65,8,113,34,6,32,1,114,32,2,32,6,118,34,1,65,2,118,65,4,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,2,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,1,113,34,2,114,32,1,32,2,118,106,34,8,65,3,116,106,34,2,40,2,8,34,1,40,2,8,34,6,32,2,70,13,6,32,0,40,2,16,32,6,75,32,6,40,2,12,32,1,71,114,13,7,32,2,65,8,106,32,6,54,2,0,32,6,65,12,106,32,2,54,2,0,32,0,65,8,106,40,2,0,33,3,12,7,11,32,0,32,4,65,126,32,3,119,113,54,2,0,11,32,1,32,3,65,3,116,34,2,65,3,114,54,2,4,32,1,32,2,106,34,1,32,1,40,2,4,65,1,114,54,2,4,32,6,15,11,11,65,0,33,4,32,10,65,2,32,9,116,34,1,65,0,32,1,107,114,113,34,1,69,13,12,32,0,32,1,65,0,32,1,107,113,65,127,106,34,1,32,1,65,12,118,65,16,113,34,1,118,34,2,65,5,118,65,8,113,34,6,32,1,114,32,2,32,6,118,34,1,65,2,118,65,4,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,2,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,1,113,34,2,114,32,1,32,2,118,106,65,2,116,106,65,176,2,106,40,2,0,34,1,13,10,12,11,11,32,0,40,2,4,34,1,69,13,11,32,0,32,1,65,0,32,1,107,113,65,127,106,34,1,32,1,65,12,118,65,16,113,34,1,118,34,2,65,5,118,65,8,113,34,3,32,1,114,32,2,32,3,118,34,1,65,2,118,65,4,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,2,113,34,2,114,32,1,32,2,118,34,1,65,1,118,65,1,113,34,2,114,32,1,32,2,118,106,65,2,116,106,65,176,2,106,40,2,0,34,3,40,2,4,65,120,113,32,5,107,33,2,32,3,65,16,106,32,3,40,2,16,69,65,2,116,106,40,2,0,34,1,4,64,3,64,32,1,40,2,4,65,120,113,32,5,107,34,4,32,2,32,4,32,2,73,34,4,27,33,2,32,1,32,3,32,4,27,33,3,32,1,65,16,106,32,1,40,2,16,69,65,2,116,106,40,2,0,34,4,33,1,32,4,13,0,11,11,32,0,40,2,16,34,10,32,3,75,13,11,32,3,32,5,106,34,9,32,3,77,13,11,32,3,40,2,24,33,7,32,3,40,2,12,34,6,32,3,70,13,3,32,10,32,3,40,2,8,34,1,75,32,1,40,2,12,32,3,71,114,32,6,40,2,8,32,3,71,114,13,4,32,6,65,8,106,32,1,54,2,0,32,1,65,12,106,32,6,54,2,0,32,7,13,6,12,7,11,65,0,33,3,32,2,33,4,32,2,33,1,12,8,11,32,0,32,4,65,126,32,8,119,113,54,2,0,11,32,1,65,8,106,33,4,32,1,32,5,65,3,114,54,2,4,32,1,32,5,106,34,6,32,8,65,3,116,34,8,32,5,107,34,2,65,1,114,54,2,4,32,1,32,8,106,32,2,54,2,0,32,3,4,64,32,7,32,3,65,3,118,34,5,65,3,116,106,33,3,32,0,65,20,106,40,2,0,33,1,2,127,32,0,40,2,0,34,8,65,1,32,5,116,34,5,113,4,64,32,3,32,3,40,2,8,34,5,32,0,40,2,16,32,5,75,27,12,1,11,32,0,32,8,32,5,114,54,2,0,32,3,11,34,5,32,1,54,2,12,32,3,65,8,106,32,1,54,2,0,32,1,32,3,54,2,12,32,1,32,5,54,2,8,11,32,0,65,20,106,32,6,54,2,0,32,0,65,8,106,32,2,54,2,0,32,4,15,11,32,3,65,20,106,34,4,40,2,0,34,1,69,4,64,32,3,40,2,16,34,1,69,13,2,32,3,65,16,106,33,4,11,3,64,32,4,33,8,32,1,34,6,65,20,106,34,4,40,2,0,34,1,13,0,32,6,65,16,106,33,4,32,6,40,2,16,34,1,13,0,11,32,10,32,8,75,13,0,32,8,65,0,54,2,0,11,32,7,69,13,2,12,1,11,65,0,33,6,32,7,69,13,1,11,2,64,2,64,32,3,32,0,32,3,40,2,28,34,4,65,2,116,106,65,176,2,106,34,1,40,2,0,71,4,64,32,0,65,16,106,40,2,0,32,7,77,4,64,32,7,65,16,106,32,7,40,2,16,32,3,71,65,2,116,106,32,6,54,2,0,11,32,6,13,1,12,3,11,32,1,32,6,54,2,0,32,6,69,13,1,11,32,0,65,16,106,40,2,0,34,4,32,6,75,13,1,32,6,32,7,54,2,24,32,3,40,2,16,34,1,69,32,4,32,1,75,114,69,4,64,32,6,32,1,54,2,16,32,1,32,6,54,2,24,11,32,3,65,20,106,40,2,0,34,1,69,32,0,65,16,106,40,2,0,32,1,75,114,13,1,32,6,65,20,106,32,1,54,2,0,32,1,32,6,54,2,24,12,1,11,32,0,65,4,106,34,1,32,1,40,2,0,65,126,32,4,119,113,54,2,0,11,2,64,32,2,65,15,77,4,64,32,3,32,2,32,5,106,34,1,65,3,114,54,2,4,32,3,32,1,106,34,1,32,1,40,2,4,65,1,114,54,2,4,12,1,11,32,3,32,5,65,3,114,54,2,4,32,9,32,2,65,1,114,54,2,4,32,9,32,2,106,32,2,54,2,0,32,0,65,8,106,34,4,40,2,0,34,1,4,64,32,0,32,1,65,3,118,34,6,65,3,116,106,65,40,106,33,5,32,0,65,20,106,40,2,0,33,1,2,127,32,0,40,2,0,34,8,65,1,32,6,116,34,6,113,4,64,32,5,32,5,40,2,8,34,6,32,0,65,16,106,40,2,0,32,6,75,27,12,1,11,32,0,32,8,32,6,114,54,2,0,32,5,11,34,6,32,1,54,2,12,32,5,65,8,106,32,1,54,2,0,32,1,32,5,54,2,12,32,1,32,6,54,2,8,11,32,0,65,20,106,32,9,54,2,0,32,4,32,2,54,2,0,11,32,3,65,8,106,15,11,32,1,69,13,1,11,3,64,32,1,40,2,4,65,120,113,32,5,107,34,2,32,3,32,2,32,3,73,34,2,27,33,3,32,1,32,4,32,2,27,33,4,32,1,65,16,106,32,1,40,2,16,69,65,2,116,106,40,2,0,34,2,33,1,32,2,13,0,11,11,32,4,69,32,3,32,0,40,2,8,32,5,107,79,114,13,0,32,0,40,2,16,34,10,32,4,75,13,0,32,4,32,5,106,34,9,32,4,77,13,0,32,4,40,2,24,33,7,32,4,40,2,12,34,6,32,4,70,13,1,32,10,32,4,40,2,8,34,1,75,32,1,40,2,12,32,4,71,114,32,6,40,2,8,32,4,71,114,13,2,32,6,65,8,106,32,1,54,2,0,32,1,65,12,106,32,6,54,2,0,32,7,13,20,12,21,11,2,127,2,64,2,64,2,64,2,64,32,0,40,2,8,34,1,32,5,73,4,64,32,0,40,2,12,34,4,32,5,77,13,1,32,0,40,2,24,34,1,32,5,106,34,2,32,4,32,5,107,34,3,65,1,114,54,2,4,32,0,65,12,106,32,3,54,2,0,32,0,32,2,54,2,24,32,1,32,5,65,3,114,54,2,4,32,1,65,8,106,15,11,32,0,40,2,20,33,2,32,1,32,5,107,34,3,65,16,73,13,1,32,2,32,5,106,34,4,32,3,65,1,114,54,2,4,32,2,32,1,106,32,3,54,2,0,32,0,65,8,106,32,3,54,2,0,32,0,65,20,106,32,4,54,2,0,32,2,32,5,65,3,114,54,2,4,12,2,11,65,200,0,40,2,0,69,13,2,65,208,0,40,2,0,12,3,11,32,2,32,1,65,3,114,54,2,4,32,0,65,20,106,65,0,54,2,0,32,0,65,8,106,65,0,54,2,0,32,2,32,1,106,34,1,32,1,40,2,4,65,1,114,54,2,4,11,32,2,65,8,106,15,11,65,204,0,66,128,128,132,128,128,128,192,0,55,2,0,65,212,0,66,127,55,2,0,65,200,0,32,7,65,12,106,65,112,113,65,216,170,213,170,5,115,54,2,0,65,220,0,65,0,54,2,0,65,128,128,4,11,33,1,65,0,33,8,32,1,32,5,65,47,106,34,10,106,34,7,65,0,32,1,107,34,9,113,34,6,32,5,77,13,10,32,0,40,2,184,3,34,11,4,64,32,0,40,2,176,3,34,1,32,6,106,34,2,32,1,77,32,2,32,11,75,114,13,11,11,32,0,65,188,3,106,45,0,0,65,4,113,13,8,32,0,40,2,24,34,2,4,64,32,0,65,192,3,106,33,1,3,64,32,1,40,2,0,34,3,32,2,77,4,64,32,3,32,1,40,2,4,106,32,2,75,13,5,11,32,1,40,2,8,34,1,13,0,11,11,63,0,33,1,32,6,33,7,65,204,0,40,2,0,34,2,65,127,106,34,3,32,1,65,16,116,34,4,113,4,64,32,6,32,4,107,32,3,32,4,106,65,0,32,2,107,113,106,33,7,11,32,7,32,5,77,32,7,65,254,255,255,255,7,75,114,13,7,32,11,4,64,32,0,40,2,176,3,34,1,32,7,106,34,2,32,1,77,32,2,32,11,75,114,13,8,11,63,0,65,16,116,65,127,32,7,65,127,106,65,16,117,65,1,106,64,0,27,34,1,32,4,70,13,9,32,1,33,4,12,3,11,32,4,65,20,106,34,2,40,2,0,34,1,69,4,64,32,4,40,2,16,34,1,69,13,4,32,4,65,16,106,33,2,11,3,64,32,2,33,8,32,1,34,6,65,20,106,34,2,40,2,0,34,1,13,0,32,6,65,16,106,33,2,32,6,40,2,16,34,1,13,0,11,32,10,32,8,75,13,0,32,8,65,0,54,2,0,11,32,7,69,13,18,12,17,11,32,7,32,4,107,32,9,113,34,7,65,254,255,255,255,7,75,13,4,63,0,33,2,2,127,32,7,4,64,65,127,32,7,65,127,106,65,16,117,65,1,106,64,0,69,13,1,26,11,32,2,65,16,116,11,34,4,32,1,40,2,0,32,1,65,4,106,40,2,0,106,70,13,2,11,32,5,65,48,106,32,7,77,32,7,65,254,255,255,255,7,75,114,32,4,65,127,70,114,69,4,64,32,10,32,7,107,65,208,0,40,2,0,34,1,106,65,0,32,1,107,113,34,1,65,254,255,255,255,7,75,13,6,32,1,4,64,32,1,65,127,106,65,16,117,65,1,106,64,0,69,13,4,11,32,1,32,7,106,33,7,12,6,11,32,4,65,127,71,13,5,12,3,11,65,0,33,6,32,7,13,14,12,15,11,32,4,65,127,71,13,3,12,1,11,65,0,32,7,107,65,1,72,13,0,32,7,65,127,115,65,16,117,65,1,106,64,0,26,11,32,0,65,188,3,106,34,1,32,1,40,2,0,65,4,114,54,2,0,11,32,6,65,254,255,255,255,7,75,13,1,63,0,33,1,2,127,32,6,4,64,65,127,32,6,65,127,106,65,16,117,65,1,106,64,0,69,13,1,26,11,32,1,65,16,116,11,33,4,63,0,33,1,32,4,65,127,70,13,1,32,4,32,1,65,16,116,34,1,79,13,1,32,1,32,4,107,34,7,32,5,65,40,106,77,13,1,11,32,0,32,0,40,2,176,3,32,7,106,34,1,54,2,176,3,32,1,32,0,40,2,180,3,75,4,64,32,0,65,180,3,106,32,1,54,2,0,11,2,64,2,64,2,64,32,0,40,2,24,34,2,4,64,32,0,65,192,3,106,34,9,33,1,3,64,32,4,32,1,40,2,0,34,3,32,1,40,2,4,34,6,106,70,13,2,32,1,40,2,8,34,1,13,0,12,3,11,0,11,2,64,32,0,40,2,16,34,1,4,64,32,4,32,1,79,13,1,11,32,0,65,16,106,32,4,54,2,0,11,32,0,32,7,54,2,196,3,32,0,32,4,54,2,192,3,65,0,33,1,32,0,65,0,54,2,204,3,32,0,65,127,54,2,32,32,0,65,200,0,40,2,0,54,2,36,3,64,32,0,32,1,106,34,2,65,48,106,32,2,65,40,106,34,3,54,2,0,32,2,65,52,106,32,3,54,2,0,32,1,65,8,106,34,1,65,128,2,71,13,0,11,32,0,65,24,106,32,0,32,0,65,124,106,40,2,0,65,120,113,106,34,1,65,120,106,34,2,65,0,32,1,107,65,7,113,65,0,32,1,65,7,113,27,34,1,106,34,3,54,2,0,32,0,65,12,106,32,4,32,7,106,34,4,32,2,107,65,88,106,32,1,107,34,1,54,2,0,32,3,32,1,65,1,114,54,2,4,32,4,65,92,106,65,40,54,2,0,32,0,65,216,0,40,2,0,54,2,28,12,2,11,32,1,45,0,12,65,8,113,32,4,32,2,77,114,32,3,32,2,75,114,13,0,32,2,65,120,32,2,107,65,7,113,65,0,32,2,65,8,106,65,7,113,27,34,3,106,34,4,32,0,65,12,106,34,9,40,2,0,32,7,106,34,10,32,3,107,34,3,65,1,114,54,2,4,32,1,65,4,106,32,6,32,7,106,54,2,0,32,0,65,216,0,40,2,0,54,2,28,32,9,32,3,54,2,0,32,0,65,24,106,32,4,54,2,0,32,2,32,10,106,65,40,54,2,4,12,1,11,32,4,32,0,40,2,16,34,6,73,4,64,32,0,65,16,106,32,4,54,2,0,32,4,33,6,11,32,4,32,7,106,33,3,32,9,33,1,2,127,2,64,2,127,2,64,2,64,2,64,2,64,3,64,32,1,40,2,0,32,3,70,13,1,32,1,40,2,8,34,1,13,0,12,2,11,0,11,32,1,45,0,12,65,8,113,13,0,32,1,32,4,54,2,0,32,1,32,1,40,2,4,32,7,106,54,2,4,32,4,65,120,32,4,107,65,7,113,65,0,32,4,65,8,106,65,7,113,27,106,34,7,32,5,65,3,114,54,2,4,32,3,65,120,32,3,107,65,7,113,65,0,32,3,65,8,106,65,7,113,27,106,34,4,32,7,107,32,5,107,33,1,32,7,32,5,106,33,3,32,2,32,4,70,13,1,32,0,40,2,20,32,4,70,13,8,32,4,40,2,4,34,2,65,3,113,65,1,71,13,14,32,2,65,120,113,33,10,32,2,65,255,1,75,13,9,32,4,40,2,12,33,8,32,4,40,2,8,34,5,32,0,32,2,65,3,118,34,9,65,3,116,106,65,40,106,34,2,71,4,64,32,6,32,5,75,32,5,40,2,12,32,4,71,114,13,14,11,32,8,32,5,70,13,10,32,8,32,2,71,4,64,32,6,32,8,75,32,8,40,2,8,32,4,71,114,13,14,11,32,5,32,8,54,2,12,32,8,65,8,106,32,5,54,2,0,12,13,11,32,9,33,1,2,64,3,64,32,1,40,2,0,34,3,32,2,77,4,64,32,3,32,1,40,2,4,106,34,3,32,2,75,13,2,11,32,1,40,2,8,33,1,12,0,11,0,11,32,4,65,120,32,4,107,65,7,113,65,0,32,4,65,8,106,65,7,113,27,34,1,106,34,10,32,7,65,88,106,34,6,32,1,107,34,1,65,1,114,54,2,4,32,4,32,6,106,65,40,54,2,4,32,2,32,3,65,39,32,3,107,65,7,113,65,0,32,3,65,89,106,65,7,113,27,106,65,81,106,34,6,32,6,32,2,65,16,106,73,27,34,6,65,27,54,2,4,32,0,65,216,0,40,2,0,54,2,28,32,0,65,12,106,32,1,54,2,0,32,0,65,24,106,32,10,54,2,0,32,6,32,9,40,2,0,54,2,8,32,6,65,20,106,32,9,65,12,106,40,2,0,54,2,0,32,6,65,16,106,32,9,65,8,106,40,2,0,54,2,0,32,6,65,12,106,32,9,65,4,106,40,2,0,54,2,0,32,0,32,7,54,2,196,3,32,0,65,192,3,106,32,4,54,2,0,32,0,65,0,54,2,204,3,32,0,32,6,65,8,106,54,2,200,3,32,6,65,28,106,33,1,3,64,32,1,65,7,54,2,0,32,1,65,4,106,34,1,32,3,73,13,0,11,32,6,32,2,70,13,5,32,6,65,4,106,34,1,32,1,40,2,0,65,126,113,54,2,0,32,6,32,6,32,2,107,34,7,54,2,0,32,2,32,7,65,1,114,54,2,4,32,7,65,255,1,77,4,64,32,0,32,7,65,3,118,34,3,65,3,116,106,65,40,106,33,1,32,0,40,2,0,34,4,65,1,32,3,116,34,3,113,69,13,2,32,1,32,1,40,2,8,34,3,32,0,65,16,106,40,2,0,32,3,75,27,12,3,11,32,7,65,8,118,34,3,69,13,3,65,31,32,7,65,255,255,255,7,75,13,4,26,32,7,65,14,32,3,32,3,65,128,254,63,106,65,16,118,65,8,113,34,1,116,34,3,65,128,224,31,106,65,16,118,65,4,113,34,4,32,1,114,32,3,32,4,116,34,1,65,128,128,15,106,65,16,118,65,2,113,34,3,114,107,32,1,32,3,116,65,15,118,106,34,1,65,7,106,118,65,1,113,32,1,65,1,116,114,12,4,11,32,0,65,24,106,32,3,54,2,0,32,0,65,12,106,34,2,32,2,40,2,0,32,1,106,34,1,54,2,0,32,3,32,1,65,1,114,54,2,4,12,13,11,32,0,32,4,32,3,114,54,2,0,32,1,11,34,3,32,2,54,2,12,32,1,65,8,106,32,2,54,2,0,32,2,32,1,54,2,12,32,2,32,3,54,2,8,12,2,11,65,0,11,33,1,32,2,66,0,55,2,16,32,2,65,28,106,32,1,54,2,0,32,0,32,1,65,2,116,106,65,176,2,106,33,3,2,64,2,64,32,0,40,2,4,34,4,65,1,32,1,116,34,6,113,4,64,32,7,65,0,65,25,32,1,65,1,118,107,32,1,65,31,70,27,116,33,1,32,3,40,2,0,33,4,3,64,32,4,34,3,40,2,4,65,120,113,32,7,70,13,3,32,1,65,29,118,33,4,32,1,65,1,116,33,1,32,3,32,4,65,4,113,106,65,16,106,34,6,40,2,0,34,4,13,0,11,32,0,65,16,106,40,2,0,32,6,75,13,3,32,6,32,2,54,2,0,32,2,65,24,106,32,3,54,2,0,12,1,11,32,0,65,4,106,32,4,32,6,114,54,2,0,32,3,32,2,54,2,0,32,2,65,24,106,32,3,54,2,0,11,32,2,32,2,54,2,12,32,2,32,2,54,2,8,12,1,11,32,0,65,16,106,40,2,0,34,4,32,3,40,2,8,34,1,75,32,4,32,3,75,114,13,0,32,1,32,2,54,2,12,32,3,65,8,106,32,2,54,2,0,32,2,32,3,54,2,12,32,2,65,24,106,65,0,54,2,0,32,2,32,1,54,2,8,11,32,0,65,12,106,34,1,40,2,0,34,2,32,5,77,13,0,32,0,65,24,106,34,4,40,2,0,34,3,32,5,106,34,6,32,2,32,5,107,34,2,65,1,114,54,2,4,32,1,32,2,54,2,0,32,4,32,6,54,2,0,32,3,32,5,65,3,114,54,2,4,32,3,65,8,106,33,8,11,32,8,15,11,32,3,32,0,65,8,106,34,2,40,2,0,32,1,106,34,1,65,1,114,54,2,4,32,0,65,20,106,32,3,54,2,0,32,2,32,1,54,2,0,32,3,32,1,106,32,1,54,2,0,12,6,11,32,4,40,2,24,33,11,2,64,32,4,40,2,12,34,8,32,4,71,4,64,32,6,32,4,40,2,8,34,2,75,32,2,40,2,12,32,4,71,114,32,8,40,2,8,32,4,71,114,13,1,32,8,65,8,106,32,2,54,2,0,32,2,65,12,106,32,8,54,2,0,32,11,13,4,12,5,11,32,4,65,20,106,34,2,40,2,0,34,5,69,4,64,32,4,65,16,106,34,2,40,2,0,34,5,69,13,3,11,3,64,32,2,33,9,32,5,34,8,65,20,106,34,2,40,2,0,34,5,13,0,32,8,65,16,106,33,2,32,8,40,2,16,34,5,13,0,11,32,6,32,9,75,13,0,32,9,65,0,54,2,0,11,32,11,69,13,3,12,2,11,32,0,32,0,40,2,0,65,126,32,9,119,113,54,2,0,12,2,11,65,0,33,8,32,11,69,13,1,11,2,64,2,64,32,0,32,4,40,2,28,34,5,65,2,116,106,65,176,2,106,34,2,40,2,0,32,4,71,4,64,32,0,65,16,106,40,2,0,32,11,77,4,64,32,11,65,16,106,32,11,40,2,16,32,4,71,65,2,116,106,32,8,54,2,0,11,32,8,13,1,12,3,11,32,2,32,8,54,2,0,32,8,69,13,1,11,32,0,65,16,106,40,2,0,34,5,32,8,75,13,1,32,8,32,11,54,2,24,32,4,40,2,16,34,2,69,32,5,32,2,75,114,69,4,64,32,8,32,2,54,2,16,32,2,32,8,54,2,24,11,32,4,65,20,106,40,2,0,34,2,69,32,0,65,16,106,40,2,0,32,2,75,114,13,1,32,8,65,20,106,32,2,54,2,0,32,2,32,8,54,2,24,12,1,11,32,0,32,0,40,2,4,65,126,32,5,119,113,54,2,4,11,32,10,32,1,106,33,1,32,4,32,10,106,33,4,11,32,4,32,4,40,2,4,65,126,113,54,2,4,32,3,32,1,65,1,114,54,2,4,32,3,32,1,106,32,1,54,2,0,2,127,2,64,2,127,2,64,32,1,65,255,1,77,4,64,32,0,32,1,65,3,118,34,2,65,3,116,106,65,40,106,33,1,32,0,40,2,0,34,5,65,1,32,2,116,34,2,113,69,13,1,32,1,65,8,106,33,5,32,1,32,1,40,2,8,34,2,32,0,65,16,106,40,2,0,32,2,75,27,12,2,11,32,1,65,8,118,34,5,69,13,2,65,31,32,1,65,255,255,255,7,75,13,3,26,32,1,65,14,32,5,32,5,65,128,254,63,106,65,16,118,65,8,113,34,2,116,34,5,65,128,224,31,106,65,16,118,65,4,113,34,4,32,2,114,32,5,32,4,116,34,2,65,128,128,15,106,65,16,118,65,2,113,34,5,114,107,32,2,32,5,116,65,15,118,106,34,2,65,7,106,118,65,1,113,32,2,65,1,116,114,12,3,11,32,0,32,5,32,2,114,54,2,0,32,1,65,8,106,33,5,32,1,11,34,2,32,3,54,2,12,32,5,32,3,54,2,0,32,3,32,1,54,2,12,32,3,32,2,54,2,8,12,2,11,65,0,11,33,2,32,3,32,2,54,2,28,32,3,66,0,55,2,16,32,0,32,2,65,2,116,106,65,176,2,106,33,5,2,64,2,64,32,0,40,2,4,34,4,65,1,32,2,116,34,6,113,4,64,32,1,65,0,65,25,32,2,65,1,118,107,32,2,65,31,70,27,116,33,2,32,5,40,2,0,33,4,3,64,32,4,34,5,40,2,4,65,120,113,32,1,70,13,3,32,2,65,29,118,33,4,32,2,65,1,116,33,2,32,5,32,4,65,4,113,106,65,16,106,34,6,40,2,0,34,4,13,0,11,32,0,65,16,106,40,2,0,32,6,75,13,3,32,6,32,3,54,2,0,32,3,32,5,54,2,24,12,1,11,32,0,65,4,106,32,4,32,6,114,54,2,0,32,5,32,3,54,2,0,32,3,32,5,54,2,24,11,32,3,32,3,54,2,12,32,3,32,3,54,2,8,12,1,11,32,0,65,16,106,40,2,0,34,2,32,5,40,2,8,34,1,75,32,2,32,5,75,114,13,0,32,1,32,3,54,2,12,32,5,65,8,106,32,3,54,2,0,32,3,65,0,54,2,24,32,3,32,5,54,2,12,32,3,32,1,54,2,8,11,32,7,65,8,106,15,11,2,64,2,64,32,4,32,0,32,4,40,2,28,34,2,65,2,116,106,65,176,2,106,34,1,40,2,0,71,4,64,32,0,65,16,106,40,2,0,32,7,77,4,64,32,7,65,16,106,32,7,40,2,16,32,4,71,65,2,116,106,32,6,54,2,0,11,32,6,13,1,12,3,11,32,1,32,6,54,2,0,32,6,69,13,1,11,32,0,65,16,106,40,2,0,34,2,32,6,75,13,1,32,6,32,7,54,2,24,32,4,40,2,16,34,1,69,32,2,32,1,75,114,69,4,64,32,6,32,1,54,2,16,32,1,32,6,54,2,24,11,32,4,65,20,106,40,2,0,34,1,69,32,0,65,16,106,40,2,0,32,1,75,114,13,1,32,6,65,20,106,32,1,54,2,0,32,1,32,6,54,2,24,12,1,11,32,0,65,4,106,34,1,32,1,40,2,0,65,126,32,2,119,113,54,2,0,11,2,64,32,3,65,15,77,4,64,32,4,32,3,32,5,106,34,1,65,3,114,54,2,4,32,4,32,1,106,34,1,32,1,40,2,4,65,1,114,54,2,4,12,1,11,32,4,32,5,65,3,114,54,2,4,32,9,32,3,65,1,114,54,2,4,32,9,32,3,106,32,3,54,2,0,2,127,2,64,2,127,2,64,32,3,65,255,1,77,4,64,32,0,32,3,65,3,118,34,2,65,3,116,106,65,40,106,33,1,32,0,40,2,0,34,3,65,1,32,2,116,34,2,113,69,13,1,32,1,65,8,106,33,3,32,1,32,1,40,2,8,34,2,32,0,65,16,106,40,2,0,32,2,75,27,12,2,11,32,3,65,8,118,34,2,69,13,2,65,31,32,3,65,255,255,255,7,75,13,3,26,32,3,65,14,32,2,32,2,65,128,254,63,106,65,16,118,65,8,113,34,1,116,34,2,65,128,224,31,106,65,16,118,65,4,113,34,5,32,1,114,32,2,32,5,116,34,1,65,128,128,15,106,65,16,118,65,2,113,34,2,114,107,32,1,32,2,116,65,15,118,106,34,1,65,7,106,118,65,1,113,32,1,65,1,116,114,12,3,11,32,0,32,3,32,2,114,54,2,0,32,1,65,8,106,33,3,32,1,11,34,2,32,9,54,2,12,32,3,32,9,54,2,0,32,9,32,1,54,2,12,32,9,32,2,54,2,8,12,2,11,65,0,11,33,1,32,9,32,1,54,2,28,32,9,66,0,55,2,16,32,0,32,1,65,2,116,106,65,176,2,106,33,2,2,64,2,64,32,0,65,4,106,34,5,40,2,0,34,6,65,1,32,1,116,34,8,113,4,64,32,3,65,0,65,25,32,1,65,1,118,107,32,1,65,31,70,27,116,33,1,32,2,40,2,0,33,5,3,64,32,5,34,2,40,2,4,65,120,113,32,3,70,13,3,32,1,65,29,118,33,5,32,1,65,1,116,33,1,32,2,32,5,65,4,113,106,65,16,106,34,6,40,2,0,34,5,13,0,11,32,0,65,16,106,40,2,0,32,6,75,13,3,32,6,32,9,54,2,0,32,9,32,2,54,2,24,12,1,11,32,5,32,6,32,8,114,54,2,0,32,2,32,9,54,2,0,32,9,32,2,54,2,24,11,32,9,32,9,54,2,12,32,9,32,9,54,2,8,12,1,11,32,0,65,16,106,40,2,0,34,3,32,2,40,2,8,34,1,75,32,3,32,2,75,114,13,0,32,1,32,9,54,2,12,32,2,65,8,106,32,9,54,2,0,32,9,65,0,54,2,24,32,9,32,2,54,2,12,32,9,32,1,54,2,8,11,32,4,65,8,106,11,11,171,144,128,128,0,1,8,127,2,64,32,1,69,13,0,32,1,65,120,106,34,2,32,0,40,2,16,34,8,73,13,0,32,1,65,124,106,40,2,0,34,1,65,3,113,34,4,65,1,70,13,0,32,2,32,1,65,120,113,34,6,106,33,5,2,64,2,64,32,1,65,1,113,13,0,32,4,69,13,2,32,2,32,2,40,2,0,34,1,107,34,2,32,8,73,13,2,32,1,32,6,106,33,6,2,64,2,64,2,64,2,64,32,0,40,2,20,32,2,71,4,64,32,1,65,255,1,75,13,1,32,2,40,2,12,33,3,32,2,40,2,8,34,4,32,0,32,1,65,3,118,34,7,65,3,116,106,65,40,106,34,1,71,4,64,32,8,32,4,75,32,4,40,2,12,32,2,71,114,13,6,11,32,3,32,4,70,13,2,32,3,32,1,71,4,64,32,8,32,3,75,32,3,40,2,8,32,2,71,114,13,6,11,32,4,32,3,54,2,12,32,3,65,8,106,32,4,54,2,0,32,2,32,5,73,13,6,12,7,11,32,5,40,2,4,34,1,65,3,113,65,3,71,13,4,32,5,65,4,106,32,1,65,126,113,54,2,0,32,2,32,6,65,1,114,54,2,4,32,0,32,6,54,2,8,32,2,32,6,106,32,6,54,2,0,15,11,32,2,40,2,24,33,9,2,64,32,2,40,2,12,34,3,32,2,71,4,64,32,8,32,2,40,2,8,34,1,75,32,1,40,2,12,32,2,71,114,32,3,40,2,8,32,2,71,114,13,1,32,3,65,8,106,32,1,54,2,0,32,1,65,12,106,32,3,54,2,0,32,9,13,4,12,5,11,32,2,65,20,106,34,1,40,2,0,34,4,69,4,64,32,2,65,16,106,34,1,40,2,0,34,4,69,13,3,11,3,64,32,1,33,7,32,4,34,3,65,20,106,34,1,40,2,0,34,4,13,0,32,3,65,16,106,33,1,32,3,40,2,16,34,4,13,0,11,32,8,32,7,75,13,0,32,7,65,0,54,2,0,11,32,9,69,13,3,12,2,11,32,0,32,0,40,2,0,65,126,32,7,119,113,54,2,0,32,2,32,5,73,13,3,12,4,11,65,0,33,3,32,9,69,13,1,11,2,64,2,64,32,0,32,2,40,2,28,34,4,65,2,116,106,65,176,2,106,34,1,40,2,0,32,2,71,4,64,32,0,65,16,106,40,2,0,32,9,77,4,64,32,9,65,16,106,32,9,40,2,16,32,2,71,65,2,116,106,32,3,54,2,0,11,32,3,13,1,12,3,11,32,1,32,3,54,2,0,32,3,69,13,1,11,32,0,65,16,106,40,2,0,34,4,32,3,75,13,1,32,3,32,9,54,2,24,32,2,40,2,16,34,1,69,32,4,32,1,75,114,69,4,64,32,3,32,1,54,2,16,32,1,32,3,54,2,24,11,32,2,65,20,106,40,2,0,34,1,69,32,0,65,16,106,40,2,0,32,1,75,114,13,1,32,3,65,20,106,32,1,54,2,0,32,1,32,3,54,2,24,32,2,32,5,73,13,2,12,3,11,32,0,32,0,40,2,4,65,126,32,4,119,113,54,2,4,11,32,2,32,5,79,13,1,11,32,5,40,2,4,34,1,65,1,113,69,13,0,2,64,2,64,2,64,2,64,2,64,2,64,2,64,2,64,32,1,65,2,113,69,4,64,32,0,40,2,24,32,5,70,13,1,32,0,40,2,20,32,5,70,13,2,32,1,65,120,113,32,6,106,33,6,32,1,65,255,1,75,13,3,32,5,40,2,12,33,3,32,5,40,2,8,34,4,32,0,32,1,65,3,118,34,8,65,3,116,106,65,40,106,34,1,71,4,64,32,0,65,16,106,40,2,0,32,4,75,32,4,40,2,12,32,5,71,114,13,8,11,32,3,32,4,70,13,4,32,3,32,1,71,4,64,32,0,65,16,106,40,2,0,32,3,75,32,3,40,2,8,32,5,71,114,13,8,11,32,4,32,3,54,2,12,32,3,65,8,106,32,4,54,2,0,12,7,11,32,5,65,4,106,32,1,65,126,113,54,2,0,32,2,32,6,106,32,6,54,2,0,32,2,32,6,65,1,114,54,2,4,12,7,11,32,0,65,24,106,32,2,54,2,0,32,0,32,0,40,2,12,32,6,106,34,1,54,2,12,32,2,32,1,65,1,114,54,2,4,32,2,32,0,40,2,20,71,13,7,32,0,65,0,54,2,8,32,0,65,20,106,65,0,54,2,0,15,11,32,0,65,20,106,32,2,54,2,0,32,0,32,0,40,2,8,32,6,106,34,1,54,2,8,32,2,32,1,65,1,114,54,2,4,32,2,32,1,106,32,1,54,2,0,15,11,32,5,40,2,24,33,7,2,64,32,5,40,2,12,34,3,32,5,71,4,64,32,0,65,16,106,40,2,0,32,5,40,2,8,34,1,75,32,1,40,2,12,32,5,71,114,32,3,40,2,8,32,5,71,114,13,1,32,3,65,8,106,32,1,54,2,0,32,1,65,12,106,32,3,54,2,0,32,7,13,4,12,5,11,32,5,65,20,106,34,1,40,2,0,34,4,69,4,64,32,5,65,16,106,34,1,40,2,0,34,4,69,13,3,11,3,64,32,1,33,8,32,4,34,3,65,20,106,34,1,40,2,0,34,4,13,0,32,3,65,16,106,33,1,32,3,40,2,16,34,4,13,0,11,32,0,65,16,106,40,2,0,32,8,75,13,0,32,8,65,0,54,2,0,11,32,7,69,13,3,12,2,11,32,0,32,0,40,2,0,65,126,32,8,119,113,54,2,0,12,2,11,65,0,33,3,32,7,69,13,1,11,2,64,2,64,32,0,32,5,40,2,28,34,4,65,2,116,106,65,176,2,106,34,1,40,2,0,32,5,71,4,64,32,0,65,16,106,40,2,0,32,7,77,4,64,32,7,65,16,106,32,7,40,2,16,32,5,71,65,2,116,106,32,3,54,2,0,11,32,3,13,1,12,3,11,32,1,32,3,54,2,0,32,3,69,13,1,11,32,0,65,16,106,40,2,0,34,4,32,3,75,13,1,32,3,32,7,54,2,24,32,5,40,2,16,34,1,69,32,4,32,1,75,114,69,4,64,32,3,32,1,54,2,16,32,1,32,3,54,2,24,11,32,5,65,20,106,40,2,0,34,1,69,32,0,65,16,106,40,2,0,32,1,75,114,13,1,32,3,65,20,106,32,1,54,2,0,32,1,32,3,54,2,24,12,1,11,32,0,32,0,40,2,4,65,126,32,4,119,113,54,2,4,11,32,2,32,6,106,32,6,54,2,0,32,2,32,6,65,1,114,54,2,4,32,2,32,0,65,20,106,40,2,0,71,13,0,32,0,32,6,54,2,8,15,11,2,127,2,64,2,127,2,64,32,6,65,255,1,77,4,64,32,0,32,6,65,3,118,34,4,65,3,116,106,65,40,106,33,1,32,0,40,2,0,34,6,65,1,32,4,116,34,4,113,69,13,1,32,1,32,1,40,2,8,34,4,32,0,65,16,106,40,2,0,32,4,75,27,12,2,11,32,6,65,8,118,34,4,69,13,2,65,31,32,6,65,255,255,255,7,75,13,3,26,32,6,65,14,32,4,32,4,65,128,254,63,106,65,16,118,65,8,113,34,1,116,34,4,65,128,224,31,106,65,16,118,65,4,113,34,3,32,1,114,32,4,32,3,116,34,1,65,128,128,15,106,65,16,118,65,2,113,34,4,114,107,32,1,32,4,116,65,15,118,106,34,1,65,7,106,118,65,1,113,32,1,65,1,116,114,12,3,11,32,0,32,6,32,4,114,54,2,0,32,1,11,34,0,32,2,54,2,12,32,1,65,8,106,32,2,54,2,0,32,2,32,1,54,2,12,32,2,32,0,54,2,8,15,11,65,0,11,33,1,32,2,66,0,55,2,16,32,2,65,28,106,32,1,54,2,0,32,0,32,1,65,2,116,106,65,176,2,106,33,4,2,64,2,64,2,64,32,0,40,2,4,34,3,65,1,32,1,116,34,5,113,4,64,32,6,65,0,65,25,32,1,65,1,118,107,32,1,65,31,70,27,116,33,1,32,4,40,2,0,33,3,3,64,32,3,34,4,40,2,4,65,120,113,32,6,70,13,3,32,1,65,29,118,33,3,32,1,65,1,116,33,1,32,4,32,3,65,4,113,106,65,16,106,34,5,40,2,0,34,3,13,0,11,32,0,65,16,106,40,2,0,32,5,75,13,3,32,5,32,2,54,2,0,32,2,65,24,106,32,4,54,2,0,12,1,11,32,0,65,4,106,32,3,32,5,114,54,2,0,32,4,32,2,54,2,0,32,2,65,24,106,32,4,54,2,0,11,32,2,32,2,54,2,12,32,2,32,2,54,2,8,12,1,11,32,0,65,16,106,40,2,0,34,6,32,4,40,2,8,34,1,75,32,6,32,4,75,114,13,0,32,1,32,2,54,2,12,32,4,65,8,106,32,2,54,2,0,32,2,32,4,54,2,12,32,2,65,24,106,65,0,54,2,0,32,2,32,1,54,2,8,11,32,0,32,0,40,2,32,65,127,106,34,1,54,2,32,32,1,13,0,32,0,65,200,3,106,33,1,3,64,32,1,40,2,0,34,2,65,8,106,33,1,32,2,13,0,11,32,0,65,32,106,65,127,54,2,0,11,11,222,131,128,128,0,1,9,127,2,127,32,0,33,4,63,0,65,16,116,32,0,107,33,5,32,0,33,1,65,192,0,65,192,0,40,2,0,65,16,107,34,9,54,2,0,65,0,33,7,65,200,0,40,2,0,34,3,69,4,64,65,204,0,66,128,128,132,128,128,128,192,0,55,2,0,65,212,0,66,127,55,2,0,65,200,0,32,9,65,12,106,65,112,113,65,216,170,213,170,5,115,34,3,54,2,0,65,220,0,65,0,54,2,0,11,2,64,32,5,65,137,4,73,13,0,65,0,33,7,65,248,123,65,204,0,40,2,0,107,32,5,77,13,0,65,0,33,2,32,4,65,120,32,4,107,65,7,113,65,0,32,4,65,8,106,65,7,113,27,106,34,1,65,8,106,34,7,65,0,65,224,3,16,2,33,6,32,1,65,227,3,54,2,4,32,1,65,188,3,106,32,5,54,2,0,32,1,65,184,3,106,32,5,54,2,0,32,1,65,204,3,106,32,5,54,2,0,32,1,65,44,106,32,3,54,2,0,32,1,65,40,106,65,127,54,2,0,32,1,65,24,106,32,4,54,2,0,32,1,65,200,3,106,32,4,54,2,0,32,1,65,216,3,106,65,0,54,2,0,65,220,0,40,2,0,33,3,32,1,65,220,3,106,65,0,54,2,0,32,1,65,196,3,106,32,3,65,4,114,54,2,0,3,64,32,1,32,2,106,34,3,65,56,106,32,3,65,48,106,34,8,54,2,0,32,3,65,60,106,32,8,54,2,0,32,2,65,8,106,34,2,65,128,2,71,13,0,11,32,6,32,6,65,124,106,40,2,0,65,120,113,106,34,2,65,120,106,34,3,65,0,32,2,107,65,7,113,65,0,32,2,65,7,113,27,34,2,106,34,8,32,4,32,5,106,34,1,32,3,107,65,88,106,32,2,107,34,2,65,1,114,54,2,4,32,6,65,8,54,2,204,3,32,6,65,216,0,40,2,0,54,2,28,32,6,32,8,54,2,24,32,6,32,2,54,2,12,32,1,65,92,106,65,40,54,2,0,11,65,192,0,32,9,65,16,106,54,2,0,32,7,11,11,0,205,128,128,128,0,4,110,97,109,101,1,194,128,128,128,0,6,0,6,109,101,109,99,109,112,1,6,109,101,109,99,112,121,2,6,109,101,109,115,101,116,3,13,109,115,112,97,99,101,95,109,97,108,108,111,99,4,11,109,115,112,97,99,101,95,102,114,101,101,5,11,109,115,112,97,99,101,95,105,110,105,116])},function(module,exports){module.exports="declare class Math {\n static abs(x: float32): float32;\n static acos(x: float64): float64;\n static asin(x: float64): float64;\n static atan(x: float64): float64;\n static atan2(y: float64, x: float64): float64;\n static ceil(x: float32): float32;\n static cos(x: float64): float64;\n static exp(x: float64): float64;\n static floor(x: float32): float32;\n static log(x: float64): float64;\n // static max(...values: float64[]): float64;\n static max(a: float64, b:float64): float64;\n // static min(...values: float64[]): float64;\n static min(a: float64, b:float64): float64;\n static pow(x: float64, y: float64): float64;\n static random(): float64; // 'random' is not a standard Math builtin\n // static round(x: float64): float64; //'round' is not a standard Math builtin\n static sin(x: float64): float64;\n static sqrt(x: float32): float32;\n static tan(x: float64): float64;\n static imul(a: int32, b:int32): int32;\n}\n\nfunction absf32(x:float32):float32{\n return Math.abs(x) as float32;\n}\n\nfunction sqrtf32(x:float32):float32{\n return Math.sqrt(x);\n}\n\nfunction powf32(x:float32, y:float32):float32{\n return Math.pow(x as float64, y as float64) as float32;\n}\n\nfunction minf32(x:float32, y:float32):float32{\n return Math.min(x as float64, y as float64) as float32;\n}\nfunction maxf32(x:float32, y:float32):float32{\n return Math.max(x as float64, y as float64) as float32;\n}\n\ndeclare function modf32(a:float32, b:float32):float32;\ndeclare function modf64(a:float64, b:float64):float64;\n"},function(module,exports){module.exports="class Array {\n\n bytesLength: int32;\n elementSize: int32;\n\n constructor(bytesLength: int32, elementSize: int32) {\n this.bytesLength = bytesLength;\n this.elementSize = elementSize;\n }\n\n operator [] (index: int32): T {\n let stripe = index * this.elementSize;\n if (stripe >= 0 && stripe < this.bytesLength) {\n return *((this as *uint8 + 8 + stripe) as *T);\n }\n return null as T;\n }\n\n operator []= (index: int32, value: T): void {\n let stripe = index * this.elementSize;\n if (stripe >= 0 && stripe < this.bytesLength) {\n *((this as *uint8 + 8 + stripe) as *T) = value;\n }\n }\n\n get length(): int32 {\n return this.bytesLength / this.elementSize;\n }\n}\n\n//declare type Int32Array = Array< int32 >\n//declare type Uint32Array = Array< uint32 >\n//declare type Int64Array = Array< int64 >\n//declare type Uint64Array = Array< uint64 >\n//declare type Float32Array = Array< float32 >\n//declare type Float64Array = Array< float64 >\n"},function(module,exports){module.exports='import {mspace_init, mspace_malloc, mspace_free} from "/library/dlmalloc.wasm";\n// declare function mspace_init(base:int32):int32;\n// declare function mspace_malloc(base:int32, size:int32):int32;\n// declare function mspace_free(base:int32, size:int32):void;\n\nlet originalHeapPointer: int32 = null;\nlet currentHeapPointer: int32 = null;\n\n// export function malloc_init(value:int32):int32 {\n// return mspace_init(value);\n// }\n\nexport function malloc(value:int32):int32 {\n return mspace_malloc(originalHeapPointer, value);\n}\nexport function free(value:int32):void {\n mspace_free(originalHeapPointer, value);\n}\n'},function(module,exports){module.exports="const PI:float64 = 3.141592653589793;\n\nconst MAX_UNSIGNED_INTEGER_32:uint32 = 4294967295;\n\nconst MIN_INTEGER_32:int32 = -2147483648;\nconst MAX_INTEGER_32:int32 = 2147483647;\n\nconst MAX_UNSIGNED_INTEGER_64:int32 = 18446744073709551615;\n\n// −(2^63) to 2^63 − 1\n// const MIN_INTEGER_64:int32 = -powi64(2, 63);\n// const MAX_INTEGER_64:int32 = powi64(2, 63) - 1;\n\n// float remainder\n\n // export function modf64(x:float64, y:float64):float64{\n //\n // let ir:int32,iy:int32;\n // let r:float64,w:float64;\n //\n // if (y == 0 || isNaN(y) || !isFinite(x)) {\n // return (x * y) / (x * y);\n // }\n //\n // r = abs(x);\n // y = abs(y);\n // (void)frexp(y,&iy);\n // while (r >= y) {\n // (void)frexp(r,&ir);\n // w = ldexp(y,ir-iy);\n // r -= w <= r ? w : w*(double)0.5;\n // }\n // return x >= (double)0 ? r : -r;\n // }\n // }"},function(module,exports){module.exports="// Native types\nconst NaN: float64 = 0.0 / 0.0;\nconst Infinity: float64 = 1.0 / 0.0;\n\nfunction isNaN(value: float32): boolean {\n return value != value;\n}\n\nfunction isFinite(value: float32): boolean {\n return !isNaN(value) && value != Infinity && value != -Infinity;\n}\n\ndeclare class boolean {\n toString(): string;\n}\n\ndeclare class int8 {\n toString(): string;\n}\n\ndeclare class uint8 {\n toString(): string;\n}\n\ndeclare class int16 {\n toString(): string;\n}\n\ndeclare class uint16 {\n toString(): string;\n}\n\ndeclare class int32 {\n toString(): string;\n}\n\ndeclare class uint32 {\n toString(): string;\n}\n\ndeclare class int64 {\n toString(): string;\n}\n\ndeclare class uint64 {\n toString(): string;\n}\n\ndeclare class float32 {\n toString(): string;\n}\n\ndeclare class float64 {\n toString(): string;\n}\n\ndeclare class string {\n charAt(index: int32): string;\n\n charCodeAt(index: int32): uint16;\n\n get length(): int32;\n\n indexOf(text: string): int32;\n\n lastIndexOf(text: string): int32;\n\n operator == (other: string):boolean;\n operator [] (index: int32): uint16 { return this.charCodeAt(index); }\n slice(start: int32, end: int32): string;\n\n // startsWith(text: string): boolean { return this.slice(0, text.length) == text; }\n // endsWith(text: string): boolean { return this.slice(-text.length, this.length) == text; }\n}\n"},function(module,exports){module.exports=""},function(module,exports){module.exports="declare class boolean {\n toString(): string;\n}\n\ndeclare class int8 {\n toString(): string;\n}\n\ndeclare class uint8 {\n toString(): string;\n}\n\ndeclare class int16 {\n toString(): string;\n}\n\ndeclare class uint16 {\n toString(): string;\n}\n\ndeclare class int32 {\n toString(): string;\n}\n\ndeclare class uint32 {\n toString(): string;\n}\n\ndeclare class int64 {\n toString(): string;\n}\n\ndeclare class uint64 {\n toString(): string;\n}\n\ndeclare class float32 {\n toString(): string;\n}\n\ndeclare class float64 {\n toString(): string;\n}\n\ndeclare class string {\n charAt(index: int32): string;\n charCodeAt(index: int32): uint16;\n get length(): int32;\n indexOf(text: string): int32;\n lastIndexOf(text: string): int32;\n operator == (other: string): boolean;\n operator [] (index: int32): uint16 { return this.charCodeAt(index); }\n slice(start: int32, end: int32): string;\n\n startsWith(text: string): boolean { return this.slice(0, text.length) == text; }\n endsWith(text: string): boolean { return this.slice(-text.length, this.length) == text; }\n}"},function(module,exports){module.exports="function TurboWrapper(exports, buffer) {\n\n var HEAP8 = new Int8Array(buffer);\n var HEAP16 = new Int16Array(buffer);\n var HEAP32 = new Int32Array(buffer);\n var HEAPU8 = new Uint8Array(buffer);\n var HEAPU16 = new Uint16Array(buffer);\n var HEAPU32 = new Uint32Array(buffer);\n var HEAPF32 = new Float32Array(buffer);\n var HEAPF64 = new Float64Array(buffer);\n\n return {\n exports: exports,\n RAW_MEMORY: buffer,\n\n getMemoryUsage: function () {\n const top = Atomics.load(HEAP32, 2);\n // top -= freeMemory;\n return Math.fround(top / (1024 * 1024));\n }\n }\n}\nfunction initTurbo(MB) {\n var buffer = new SharedArrayBuffer(MB * 1024 * 1024);\n\n if (buffer.byteLength < 16) {\n throw new Error(\"The memory is too small even for metadata\");\n }\n\n return TurboWrapper(TurboModule(\n typeof global !== 'undefined' ? global : window,\n typeof env !== 'undefined' ? env : {\n STACKTOP: 8,\n STACK_MAX: 8\n },\n buffer\n ), buffer);\n}\n"},function(module,exports){module.exports="// WebAssembly builtin functions\ndeclare function rotl(value: int64, shift: int64): int64;\ndeclare function rotl32(value: int32, shift: int32): int32;\ndeclare function rotr(value: int64, shift: int64): int64;\ndeclare function rotr32(value: int32, shift: int32): int32;\ndeclare function clz(value: int64): int64;\ndeclare function clz32(value: int32): int32;\ndeclare function ctz(value: int64): int64;\ndeclare function ctz32(value: int32): int32;\ndeclare function popcnt(value: int64): int64;\ndeclare function popcnt32(value: int32): int32;\ndeclare function abs(value: float64): float64;\ndeclare function abs32(value: float32): float32;\ndeclare function ceil(value: float64): float64;\ndeclare function ceil32(value: float32): float32;\ndeclare function floor(value: float64): float64;\ndeclare function floor32(value: float32): float32;\ndeclare function sqrt(value: float64): float64;\ndeclare function sqrt32(value: float32): float32;\ndeclare function trunc(value: float64): float64;\ndeclare function trunc32(value: float32): float32;\ndeclare function nearest(value: float64): float64;\ndeclare function nearest32(value: float32): float32;\ndeclare function min(left: float64, right: float64): float64;\ndeclare function min32(left: float32, right: float32): float32;\ndeclare function max(left: float64, right: float64): float64;\ndeclare function max32(left: float32, right: float32): float32;\ndeclare function copysign(left: float64, right: float64): float64;\ndeclare function copysign32(left: float32, right: float32): float32;\ndeclare function reinterpret_i32(value: float32): int32;\ndeclare function reinterpret_i64(value: float64): int64;\ndeclare function reinterpret_f32(value: int32): float32;\ndeclare function reinterpret_f64(value: int64): float64;\ndeclare function current_memory(): int32;\ndeclare function grow_memory(value: int32): int32;\n"},function(module,exports){module.exports="/**\n * Created by n.vinayakan on 30.05.17.\n * WebAssembly start function where global variable expressions initializer\n */\n@start\nfunction __WASM_INITIALIZER(): void {\n // 🔥 WARNING 🔥\n // DON'T RETURN ANYTHING FROM THIS FUNCTION\n // Global variable initialization expressions will be appended to this function\n // numFreeChunks = 0;\n // firstFree = 0;\n // lastFree = 0;\n originalHeapPointer = mspace_init(40); // size of null, originalHeapPointer & currentHeapPointer\n currentHeapPointer = originalHeapPointer;\n}\n"},function(module,exports,__webpack_require__){"use strict";function logOpcode(payload,offset,opcode,inline_value){void 0===offset&&(offset=0),payload.log+=utils_1.toHex(offset+payload.position)+": "+utils_1.toHex(opcode,2)+" ; "+opcode_1.WasmOpcode[opcode]+" "+(inline_value||"")+"\n"}Object.defineProperty(exports,"__esModule",{value:!0});var wasm_stack_tracer_1=__webpack_require__(52),utils_1=__webpack_require__(8),opcode_1=__webpack_require__(12),wasm_runtime_local_1=__webpack_require__(28),wasm_type_1=__webpack_require__(6),terminal_1=__webpack_require__(2),index_1=__webpack_require__(13),wasm_module_1=__webpack_require__(65),wasm_function_chunk_1=__webpack_require__(48),WasmAssembler=function(){function WasmAssembler(){this.sectionList=[],this.currentSection=null,this.currentFunction=null,this.module=new wasm_module_1.WasmModule,this.stackTracer=new wasm_stack_tracer_1.WasmStackTracer}return WasmAssembler.prototype.sealFunctions=function(){var runtimeFunctions=[];this.module.imports.forEach(function(_import){var fn=new wasm_stack_tracer_1.WasmRuntimeFunction;fn.module=_import.namespace,fn.name=_import.name,fn.signature=_import.signature,fn.isImport=!0,runtimeFunctions.push(fn)}),this.module.functions.forEach(function(_wasmFunc){var fn=new wasm_stack_tracer_1.WasmRuntimeFunction;fn.name=index_1.getWasmFunctionName(_wasmFunc.symbol),fn.signature=_wasmFunc.signature,fn.isImport=_wasmFunc.isExternal,_wasmFunc.isExternal||(fn.locals=[],_wasmFunc.locals.forEach(function(local){fn.locals.push(new wasm_runtime_local_1.WasmRuntimeProperty(local.type,local.name))})),runtimeFunctions.push(fn)}),this.stackTracer.functions=runtimeFunctions},WasmAssembler.prototype.startSection=function(id,name){var section=this.module.binary.getSection(id,name);return this.currentSection=section,this.activePayload=section.payload,this.activeCode=section.code,section},WasmAssembler.prototype.endSection=function(section){this.currentSection=null,this.activePayload=null,this.activeCode=null},WasmAssembler.prototype.startFunction=function(fn,index){this.currentFunction=fn,this.stackTracer.startFunction(this.module.importCount+index),this.activePayload=fn.body,this.activeCode=fn.code},WasmAssembler.prototype.endFunction=function(){this.activeCode.removeLastLinebreak(),this.stackTracer.endFunction(),this.currentSection.code.appendRaw(this.activeCode.finish()),this.activePayload=this.currentSection.payload,this.activeCode=this.currentSection.code},WasmAssembler.prototype.startFunctionChunk=function(fn,index){var chunk=new wasm_function_chunk_1.WasmFunctionChunk;return fn.chunks.push(chunk),this.prevPayload=this.activePayload,this.prevCode=this.activeCode,this.activePayload=chunk.payload,this.activeCode=chunk.code,this.stackTracer.startFunction(index),chunk},WasmAssembler.prototype.endFunctionChunk=function(){this.activePayload=this.prevPayload,this.activeCode=this.prevCode,this.stackTracer.endFunction(!0)},WasmAssembler.prototype.dropStack=function(max){if(void 0===max&&(max=1),this.stackTracer.context.stack.length>0){terminal_1.Terminal.warn("Dropping stack items, '"+this.stackTracer.context.fn.name+"' func stack contains "+this.stackTracer.context.stack.length+" items");for(var item=this.stackTracer.context.stack.pop(!0);void 0!==item&&max>0;)terminal_1.Terminal.warn(wasm_type_1.WasmType[item.type]),this.activePayload.append(opcode_1.WasmOpcode.DROP),this.activeCode.append("drop\n"),item=this.stackTracer.context.stack.pop(!0),max--}},WasmAssembler.prototype.append=function(offset,value,msg){void 0===offset&&(offset=0),void 0===value&&(value=null),void 0===msg&&(msg=null),this.activePayload.log+=(null!=value?utils_1.toHex(offset+this.activePayload.position)+": "+utils_1.toHex(value,2)+" ; ":"")+(null!=msg?msg+"\n":"\n"),value&&this.activePayload.append(value)},WasmAssembler.prototype.appendOpcode=function(offset,opcode,inline_value,skip){void 0===offset&&(offset=0),void 0===skip&&(skip=!1),logOpcode(this.activePayload,offset,opcode,inline_value),this.activePayload.append(opcode);var opcodeWithoutOperand=this.stackTracer.pushOpcode(opcode);if(null!==opcodeWithoutOperand&&!skip){var isEnd=opcode===opcode_1.WasmOpcode.END,indent=this.isBlock(opcode)?1:isEnd?-1:0;isEnd&&this.activeCode.clearIndent(1),this.activeCode.append(opcodeWithoutOperand+"\n",indent)}},WasmAssembler.prototype.isBlock=function(opcode){return opcode===opcode_1.WasmOpcode.BLOCK||opcode===opcode_1.WasmOpcode.LOOP||opcode===opcode_1.WasmOpcode.IF||opcode===opcode_1.WasmOpcode.IF_ELSE},WasmAssembler.prototype.writeUnsignedLEB128=function(value){this.activePayload.writeUnsignedLEB128(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.activeCode.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeLEB128=function(value){this.activePayload.writeLEB128(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.activeCode.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeFloat=function(value){this.activePayload.writeFloat(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.activeCode.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeDouble=function(value){this.activePayload.writeDouble(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.activeCode.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeWasmString=function(value){this.activePayload.writeWasmString(value)},WasmAssembler.prototype.mergeBinary=function(binary){this.module.binary.copySections(binary)},WasmAssembler.prototype.finish=function(){this.module.publish()},WasmAssembler}();exports.WasmAssembler=WasmAssembler,exports.logOpcode=logOpcode},function(module,exports,__webpack_require__){"use strict";function getBuiltinOpcode(name){switch(name){case"rotl":return opcode_1.WasmOpcode.I64_ROTL;case"rotl32":return opcode_1.WasmOpcode.I32_ROTL;case"rotr":return opcode_1.WasmOpcode.I64_ROTR;case"rotr32":return opcode_1.WasmOpcode.I32_ROTR;case"clz":return opcode_1.WasmOpcode.I64_CLZ;case"clz32":return opcode_1.WasmOpcode.I32_CLZ;case"ctz":return opcode_1.WasmOpcode.I64_CTZ;case"ctz32":return opcode_1.WasmOpcode.I32_CTZ;case"popcnt":return opcode_1.WasmOpcode.I64_POPCNT;case"popcnt32":return opcode_1.WasmOpcode.I32_POPCNT;case"abs":return opcode_1.WasmOpcode.F64_ABS;case"abs32":return opcode_1.WasmOpcode.F32_ABS;case"ceil":return opcode_1.WasmOpcode.F64_CEIL;case"ceil32":return opcode_1.WasmOpcode.F32_CEIL;case"floor":return opcode_1.WasmOpcode.F64_FLOOR;case"floor32":return opcode_1.WasmOpcode.F32_FLOOR;case"sqrt":return opcode_1.WasmOpcode.F64_SQRT;case"sqrt32":return opcode_1.WasmOpcode.F32_SQRT;case"trunc":return opcode_1.WasmOpcode.F64_TRUNC;case"trunc32":return opcode_1.WasmOpcode.F32_TRUNC;case"nearest":return opcode_1.WasmOpcode.F64_NEAREST;case"nearest32":return opcode_1.WasmOpcode.F32_NEAREST;case"min":return opcode_1.WasmOpcode.F64_MIN;case"min32":return opcode_1.WasmOpcode.F32_MIN;case"max":return opcode_1.WasmOpcode.F64_MAX;case"max32":return opcode_1.WasmOpcode.F32_MAX;case"copysign":return opcode_1.WasmOpcode.F64_COPYSIGN;case"copysign32":return opcode_1.WasmOpcode.F32_COPYSIGN;case"reinterpret_i32":return opcode_1.WasmOpcode.F32_REINTERPRET_I32;case"reinterpret_i64":return opcode_1.WasmOpcode.F64_REINTERPRET_I64;case"reinterpret_f32":return opcode_1.WasmOpcode.I32_REINTERPRET_F32;case"reinterpret_f64":return opcode_1.WasmOpcode.I64_REINTERPRET_F64;case"current_memory":return opcode_1.WasmOpcode.MEMORY_SIZE;case"grow_memory":return opcode_1.WasmOpcode.GROW_MEMORY;default:throw"No builtin function named '"+name+"'"}}function isBuiltin(name){return exports.builtins.indexOf(name)>-1}Object.defineProperty(exports,"__esModule",{value:!0});var opcode_1=__webpack_require__(12);exports.builtins=["rotl","rotl32","rotr","rotr32","clz","clz32","ctz","ctz32","popcnt","popcnt32","abs","abs32","ceil","ceil32","floor","floor32","sqrt","sqrt32","trunc","trunc32","nearest","nearest32","min","min32","max","max32","copysign","copysign32","reinterpret_i32","reinterpret_i64","reinterpret_f32","reinterpret_f64","current_memory","grow_memory"],exports.getBuiltinOpcode=getBuiltinOpcode,exports.isBuiltin=isBuiltin},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var bytearray_1=__webpack_require__(0),stringbuilder_1=__webpack_require__(22),WasmFunctionChunk=function(){function WasmFunctionChunk(payload,code){void 0===payload&&(payload=new bytearray_1.ByteArray),void 0===code&&(code=new stringbuilder_1.StringBuilder(2)),this.payload=payload,this.code=code,this.code.emitIndent(2)}return WasmFunctionChunk}();exports.WasmFunctionChunk=WasmFunctionChunk},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmLocal=function(){function WasmLocal(type,name,symbol,isArgument){void 0===isArgument&&(isArgument=!1),this.type=type,this.name=name,this.symbol=symbol,this.isArgument=isArgument}return WasmLocal}();exports.WasmLocal=WasmLocal},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmSharedOffset=function(){function WasmSharedOffset(){this.nextLocalOffset=0,this.localCount=0}return WasmSharedOffset}();exports.WasmSharedOffset=WasmSharedOffset},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var bytearray_1=__webpack_require__(0),WasmOptimizer=function(){function WasmOptimizer(){}return WasmOptimizer.optimize=function(inputWASM,level){switch(void 0===level&&(level=1),null===WasmOptimizer.instance&&(WasmOptimizer.instance=new WasmOptimizer),WasmOptimizer.instance.initialize(inputWASM),level){case 1:WasmOptimizer.instance.optimizeLevel_1();break;case 2:WasmOptimizer.instance.optimizeLevel_2();break;case 3:WasmOptimizer.instance.optimizeLevel_3()}},WasmOptimizer.prototype.initialize=function(inputWASM){this.inputWASM=inputWASM instanceof Uint8Array?new bytearray_1.ByteArray(inputWASM.buffer):inputWASM},WasmOptimizer.prototype.optimizeLevel_1=function(){},WasmOptimizer.prototype.optimizeLevel_2=function(){},WasmOptimizer.prototype.optimizeLevel_3=function(){},WasmOptimizer}();WasmOptimizer.instance=null,exports.WasmOptimizer=WasmOptimizer},function(module,exports,__webpack_require__){"use strict";function getOprandType(opcode){switch(opcode){case opcode_1.WasmOpcode.I32_CONST:case opcode_1.WasmOpcode.I32_ADD:case opcode_1.WasmOpcode.I32_MUL:case opcode_1.WasmOpcode.I32_SUB:case opcode_1.WasmOpcode.I32_DIV_S:case opcode_1.WasmOpcode.I32_DIV_U:case opcode_1.WasmOpcode.I32_REM_S:case opcode_1.WasmOpcode.I32_REM_U:case opcode_1.WasmOpcode.I32_GE_S:case opcode_1.WasmOpcode.I32_GE_U:case opcode_1.WasmOpcode.I32_LE_S:case opcode_1.WasmOpcode.I32_LE_U:case opcode_1.WasmOpcode.I32_GT_S:case opcode_1.WasmOpcode.I32_GT_U:case opcode_1.WasmOpcode.I32_LT_S:case opcode_1.WasmOpcode.I32_LT_U:case opcode_1.WasmOpcode.I32_EQ:case opcode_1.WasmOpcode.I32_NE:case opcode_1.WasmOpcode.I32_EQZ:case opcode_1.WasmOpcode.I32_AND:case opcode_1.WasmOpcode.I32_OR:case opcode_1.WasmOpcode.I32_XOR:case opcode_1.WasmOpcode.I32_CTZ:case opcode_1.WasmOpcode.I32_CLZ:case opcode_1.WasmOpcode.I32_ROTL:case opcode_1.WasmOpcode.I32_ROTR:case opcode_1.WasmOpcode.I32_SHL:case opcode_1.WasmOpcode.I32_SHR_S:case opcode_1.WasmOpcode.I32_SHR_U:case opcode_1.WasmOpcode.I32_POPCNT:case opcode_1.WasmOpcode.I32_LOAD:case opcode_1.WasmOpcode.I32_LOAD8_S:case opcode_1.WasmOpcode.I32_LOAD8_U:case opcode_1.WasmOpcode.I32_LOAD16_S:case opcode_1.WasmOpcode.I32_LOAD16_U:case opcode_1.WasmOpcode.I32_STORE16:case opcode_1.WasmOpcode.I32_STORE8:case opcode_1.WasmOpcode.I32_STORE:case opcode_1.WasmOpcode.I32_REINTERPRET_F32:case opcode_1.WasmOpcode.I32_TRUNC_S_F32:case opcode_1.WasmOpcode.I32_TRUNC_U_F32:case opcode_1.WasmOpcode.I32_TRUNC_S_F64:case opcode_1.WasmOpcode.I32_TRUNC_U_F64:case opcode_1.WasmOpcode.I32_WRAP_I64:return wasm_type_1.WasmType.I32;case opcode_1.WasmOpcode.I64_CONST:case opcode_1.WasmOpcode.I64_ADD:case opcode_1.WasmOpcode.I64_MUL:case opcode_1.WasmOpcode.I64_SUB:case opcode_1.WasmOpcode.I64_DIV_S:case opcode_1.WasmOpcode.I64_DIV_U:case opcode_1.WasmOpcode.I64_CLZ:case opcode_1.WasmOpcode.I64_ROTL:case opcode_1.WasmOpcode.I64_AND:case opcode_1.WasmOpcode.I64_CTZ:case opcode_1.WasmOpcode.I64_EQ:case opcode_1.WasmOpcode.I64_EQZ:case opcode_1.WasmOpcode.I64_GE_S:case opcode_1.WasmOpcode.I64_GE_U:case opcode_1.WasmOpcode.I64_LE_S:case opcode_1.WasmOpcode.I64_LE_U:case opcode_1.WasmOpcode.I64_GT_S:case opcode_1.WasmOpcode.I64_GT_U:case opcode_1.WasmOpcode.I64_LT_S:case opcode_1.WasmOpcode.I64_LT_U:case opcode_1.WasmOpcode.I64_LOAD:case opcode_1.WasmOpcode.I64_LOAD8_S:case opcode_1.WasmOpcode.I64_LOAD8_U:case opcode_1.WasmOpcode.I64_LOAD16_S:case opcode_1.WasmOpcode.I64_LOAD16_U:case opcode_1.WasmOpcode.I64_NE:case opcode_1.WasmOpcode.I64_XOR:case opcode_1.WasmOpcode.I64_STORE16:case opcode_1.WasmOpcode.I64_STORE8:case opcode_1.WasmOpcode.I64_STORE:case opcode_1.WasmOpcode.I64_SHR_S:case opcode_1.WasmOpcode.I64_SHR_U:case opcode_1.WasmOpcode.I64_SHL:case opcode_1.WasmOpcode.I64_ROTR:case opcode_1.WasmOpcode.I64_REM_S:case opcode_1.WasmOpcode.I64_REM_U:case opcode_1.WasmOpcode.I64_POPCNT:case opcode_1.WasmOpcode.I64_OR:case opcode_1.WasmOpcode.I64_REINTERPRET_F64:case opcode_1.WasmOpcode.I64_TRUNC_S_F32:case opcode_1.WasmOpcode.I64_TRUNC_U_F32:case opcode_1.WasmOpcode.I64_TRUNC_S_F64:case opcode_1.WasmOpcode.I64_TRUNC_U_F64:case opcode_1.WasmOpcode.I64_EXTEND_S_I32:case opcode_1.WasmOpcode.I64_EXTEND_U_I32:return wasm_type_1.WasmType.I64;case opcode_1.WasmOpcode.F32_CONST:case opcode_1.WasmOpcode.F32_ADD:case opcode_1.WasmOpcode.F32_SUB:case opcode_1.WasmOpcode.F32_MUL:case opcode_1.WasmOpcode.F32_DIV:case opcode_1.WasmOpcode.F32_SQRT:case opcode_1.WasmOpcode.F32_NEG:case opcode_1.WasmOpcode.F32_NE:case opcode_1.WasmOpcode.F32_ABS:case opcode_1.WasmOpcode.F32_CEIL:case opcode_1.WasmOpcode.F32_EQ:case opcode_1.WasmOpcode.F32_FLOOR:case opcode_1.WasmOpcode.F32_NEAREST:case opcode_1.WasmOpcode.F32_MIN:case opcode_1.WasmOpcode.F32_MAX:case opcode_1.WasmOpcode.F32_GE:case opcode_1.WasmOpcode.F32_GT:case opcode_1.WasmOpcode.F32_LT:case opcode_1.WasmOpcode.F32_LE:case opcode_1.WasmOpcode.F32_COPYSIGN:case opcode_1.WasmOpcode.F32_LOAD:case opcode_1.WasmOpcode.F32_STORE:case opcode_1.WasmOpcode.F32_TRUNC:case opcode_1.WasmOpcode.F32_DEMOTE_F64:case opcode_1.WasmOpcode.F32_CONVERT_S_I32:case opcode_1.WasmOpcode.F32_CONVERT_U_I32:case opcode_1.WasmOpcode.F32_CONVERT_S_I64:case opcode_1.WasmOpcode.F32_CONVERT_U_I64:case opcode_1.WasmOpcode.F32_REINTERPRET_I32:return wasm_type_1.WasmType.F32;case opcode_1.WasmOpcode.F64_CONST:case opcode_1.WasmOpcode.F64_ADD:case opcode_1.WasmOpcode.F64_SUB:case opcode_1.WasmOpcode.F64_MUL:case opcode_1.WasmOpcode.F64_DIV:case opcode_1.WasmOpcode.F64_SQRT:case opcode_1.WasmOpcode.F64_NEG:case opcode_1.WasmOpcode.F64_NE:case opcode_1.WasmOpcode.F64_ABS:case opcode_1.WasmOpcode.F64_CEIL:case opcode_1.WasmOpcode.F64_EQ:case opcode_1.WasmOpcode.F64_FLOOR:case opcode_1.WasmOpcode.F64_NEAREST:case opcode_1.WasmOpcode.F64_MIN:case opcode_1.WasmOpcode.F64_MAX:case opcode_1.WasmOpcode.F64_GE:case opcode_1.WasmOpcode.F64_GT:case opcode_1.WasmOpcode.F64_LT:case opcode_1.WasmOpcode.F64_LE:case opcode_1.WasmOpcode.F64_COPYSIGN:case opcode_1.WasmOpcode.F64_LOAD:case opcode_1.WasmOpcode.F64_STORE:case opcode_1.WasmOpcode.F64_TRUNC:case opcode_1.WasmOpcode.F64_PROMOTE_F32:case opcode_1.WasmOpcode.F64_CONVERT_S_I32:case opcode_1.WasmOpcode.F64_CONVERT_U_I32:case opcode_1.WasmOpcode.F64_CONVERT_S_I64:case opcode_1.WasmOpcode.F64_CONVERT_U_I64:case opcode_1.WasmOpcode.F64_REINTERPRET_I64:return wasm_type_1.WasmType.F64;case opcode_1.WasmOpcode.CALL:case opcode_1.WasmOpcode.END:case opcode_1.WasmOpcode.RETURN:case opcode_1.WasmOpcode.GET_GLOBAL:case opcode_1.WasmOpcode.GET_LOCAL:case opcode_1.WasmOpcode.SET_LOCAL:case opcode_1.WasmOpcode.SET_GLOBAL:case opcode_1.WasmOpcode.BLOCK:case opcode_1.WasmOpcode.LOOP:case opcode_1.WasmOpcode.IF:case opcode_1.WasmOpcode.IF_ELSE:case opcode_1.WasmOpcode.BR:case opcode_1.WasmOpcode.BR_IF:case opcode_1.WasmOpcode.BR_TABLE:case opcode_1.WasmOpcode.NOP:return null;default:terminal_1.Terminal.warn("Unhandled Opcode "+opcode+" => "+opcode_1.WasmOpcode[opcode])}return null}Object.defineProperty(exports,"__esModule",{value:!0});var wasm_type_1=__webpack_require__(6),opcode_1=__webpack_require__(12),wasm_runtime_local_1=__webpack_require__(28),bytearray_1=__webpack_require__(0),terminal_1=__webpack_require__(2),WasmStackItem=function(){function WasmStackItem(type,value){this.type=type,this.value=value}return WasmStackItem}();exports.WasmStackItem=WasmStackItem;var WasmStack=function(){function WasmStack(){this.list=[]}return Object.defineProperty(WasmStack.prototype,"length",{get:function(){return this.list.length},enumerable:!0,configurable:!0}),WasmStack.prototype.push=function(item){this.list.push(item)},WasmStack.prototype.pop=function(silent){if(void 0===silent&&(silent=!1),0===this.list.length&&!silent){terminal_1.Terminal.warn("Stack is empty")}return this.list.pop()},WasmStack.prototype.clear=function(){this.list=[]},WasmStack}();exports.WasmStack=WasmStack;var WasmRuntimeFunction=function(){function WasmRuntimeFunction(){}return Object.defineProperty(WasmRuntimeFunction.prototype,"returnType",{get:function(){return this.signature.returnType},enumerable:!0,configurable:!0}),WasmRuntimeFunction.prototype.execute=function(){for(var param=[],_i=0;_i0&&this.context.fn.returnType===wasm_type_1.WasmType.VOID){var error="Function '"+this.context.fn.name+"' does not return anything but stack is not empty. Stack contains "+this.context.stack.length+" items";terminal_1.Terminal.error(error)}this.context=null},WasmStackTracer.prototype.callFunction=function(index){var fn=this.functions[index];if(void 0===fn){var error="Function not defined at index "+index;throw terminal_1.Terminal.error(error),error}for(var returnType=fn.returnType,i=0;ib.value?1:0)),opcode_1.WasmOpcode[opcode];case opcode_1.WasmOpcode.I32_GE_S:case opcode_1.WasmOpcode.I32_GE_U:case opcode_1.WasmOpcode.I64_GE_S:case opcode_1.WasmOpcode.I64_GE_U:case opcode_1.WasmOpcode.F32_GE:case opcode_1.WasmOpcode.F64_GE:var a=this.context.stack.pop(),b=this.context.stack.pop();return this.context.stack.push(new WasmStackItem(type,a.value>=b.value?1:0)),opcode_1.WasmOpcode[opcode];case opcode_1.WasmOpcode.I32_LT_S:case opcode_1.WasmOpcode.I32_LT_U:case opcode_1.WasmOpcode.I64_LT_S:case opcode_1.WasmOpcode.I64_LT_U:case opcode_1.WasmOpcode.F32_LT:case opcode_1.WasmOpcode.F64_LT:var a=this.context.stack.pop(),b=this.context.stack.pop();return this.context.stack.push(new WasmStackItem(type,a.value "+opcode_1.WasmOpcode[opcode])}return null},WasmStackTracer}();exports.WasmStackTracer=WasmStackTracer},function(module,exports,__webpack_require__){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])};return function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wasm_binary_section_1=__webpack_require__(4),wasm_section_1=__webpack_require__(1),bytearray_1=__webpack_require__(0),wasm_function_1=__webpack_require__(17),CodeSection=function(_super){function CodeSection(payload){return void 0===payload&&(payload=new bytearray_1.ByteArray),_super.call(this,wasm_section_1.WasmSection.Code,payload.length,null,null,payload)||this}return __extends(CodeSection,_super),CodeSection.prototype.read=function(){void 0!==this.functions&&null!==this.functions||(this.functions=[]);for(var length=this.payload.readU32LEB(),i=0;i0?this.payload.readU32LEB():wasm_type_1.WasmType.VOID,this.signatures.push(signature)}},SignatureSection.prototype.publish=function(data){_super.prototype.publish.call(this,data)},SignatureSection}(wasm_binary_section_1.WasmSectionBinary);exports.SignatureSection=SignatureSection},function(module,exports,__webpack_require__){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])};return function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wasm_binary_section_1=__webpack_require__(4),wasm_section_1=__webpack_require__(1),bytearray_1=__webpack_require__(0),StartSection=function(_super){function StartSection(payload){void 0===payload&&(payload=new bytearray_1.ByteArray);var _this=_super.call(this,wasm_section_1.WasmSection.Start,payload.length,null,null,payload)||this;return _this.startFunctionIndex=-1,_this}return __extends(StartSection,_super),StartSection.prototype.read=function(){this.startFunctionIndex=this.payload.readU32LEB()},StartSection.prototype.publish=function(data){_super.prototype.publish.call(this,data)},StartSection}(wasm_binary_section_1.WasmSectionBinary);exports.StartSection=StartSection},function(module,exports,__webpack_require__){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])};return function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wasm_binary_section_1=__webpack_require__(4),wasm_section_1=__webpack_require__(1),bytearray_1=__webpack_require__(0),TableSection=function(_super){function TableSection(payload){void 0===payload&&(payload=new bytearray_1.ByteArray);var _this=_super.call(this,wasm_section_1.WasmSection.Table,payload.length,null,null,payload)||this;return _this.tables=[],_this}return __extends(TableSection,_super),TableSection.prototype.read=function(){},TableSection.prototype.publish=function(data){_super.prototype.publish.call(this,data)},TableSection}(wasm_binary_section_1.WasmSectionBinary);exports.TableSection=TableSection},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var wasm_binary_1=__webpack_require__(18),wasm_function_1=__webpack_require__(17),wasm_import_1=__webpack_require__(25),wasm_signature_1=__webpack_require__(26),wasm_global_1=__webpack_require__(24),index_1=__webpack_require__(13),assert_1=__webpack_require__(3),wasm_section_1=__webpack_require__(1),wasm_export_1=__webpack_require__(23),wasm_external_kind_1=__webpack_require__(11),WasmModule=function(){function WasmModule(binary){this.text=";; Experimental wast emitter\n(module\n",void 0!==binary?this.read(binary):(this.binary=new wasm_binary_1.WasmBinary,this.binary.initializeSections(),this.getReferences())}return Object.defineProperty(WasmModule.prototype,"imports",{get:function(){return this.importSection.imports},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"importCount",{get:function(){return this.imports.length},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"exports",{get:function(){return this.exportSection.exports},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"exportCount",{get:function(){return this.exports.length},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"globals",{get:function(){return this.globalSection.globals},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"globalCount",{get:function(){return this.globals.length},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"signatures",{get:function(){return this.signatureSection.signatures},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"signatureCount",{get:function(){return this.signatures.length},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"functions",{get:function(){return this.functionSection.functions},enumerable:!0,configurable:!0}),Object.defineProperty(WasmModule.prototype,"functionCount",{get:function(){return this.functions.length},enumerable:!0,configurable:!0}),WasmModule.prototype.getReferences=function(){this.importSection=this.binary.getSection(wasm_section_1.WasmSection.Import),this.exportSection=this.binary.getSection(wasm_section_1.WasmSection.Export),this.globalSection=this.binary.getSection(wasm_section_1.WasmSection.Global),this.signatureSection=this.binary.getSection(wasm_section_1.WasmSection.Signature),this.functionSection=this.binary.getSection(wasm_section_1.WasmSection.Function)},WasmModule.prototype.reset=function(){this.binary.reset()},WasmModule.prototype.read=function(binary){binary instanceof wasm_binary_1.WasmBinary?this.binary=binary:this.binary=new wasm_binary_1.WasmBinary(binary),this.getReferences()},WasmModule.prototype.publish=function(){var _this=this;this.text+=" ",this.binary.sections.forEach(function(section){section.payload.length>0&&(section.publish(_this.binary.data),_this.text+=section.code.finish())}),this.text=this.text.substring(0,this.text.lastIndexOf("\n")),this.text+=")\n"},WasmModule.prototype.allocateGlobal=function(symbol,bitness){var global=new wasm_global_1.WasmGlobal(index_1.symbolToWasmType(symbol,bitness),!0,symbol.internalName,symbol);return symbol.offset=this.globals.length,this.globals.push(global),global},WasmModule.prototype.allocateSignature=function(argumentTypes,returnType){assert_1.assert(null!=returnType);var signature=new wasm_signature_1.WasmSignature;signature.argumentTypes=argumentTypes,signature.returnType=returnType;var signatureIndex=-1;return this.signatures.some(function(check,index){return!!wasm_signature_1.wasmAreSignaturesEqual(signature,check)&&(signatureIndex=index,!0)}),signatureIndex>-1?[signatureIndex,this.signatures[signatureIndex]]:[this.signatures.push(signature)-1,signature]},WasmModule.prototype.allocateImport=function(signature,signatureIndex,namespace,name){var _import=new wasm_import_1.WasmImport(namespace,name,wasm_external_kind_1.WasmExternalKind.Function,signatureIndex,signature);return[_import,this.imports.push(_import)-1]},WasmModule.prototype.allocateFunction=function(name,signature,signatureIndex,symbol,isExported){void 0===isExported&&(isExported=!1);var _function=new wasm_function_1.WasmFunction(name,symbol),fnIndex=this.functions.push(_function)-1;return _function.isExported=isExported,isExported&&this.exports.push(new wasm_export_1.WasmExport(_function.name,wasm_external_kind_1.WasmExternalKind.Function,fnIndex)),_function.signature=signature,_function.signatureIndex=signatureIndex,_function},WasmModule}();exports.WasmModule=WasmModule},function(module,exports,__webpack_require__){"use strict";function wasmAssignLocalVariableOffsets(fn,node,shared,bitness){if(node.kind==node_1.NodeKind.VARIABLE){assert_1.assert(node.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL),shared.nextLocalOffset=shared.nextLocalOffset+1,shared.localCount=shared.localCount+1;var local=new wasm_local_1.WasmLocal(utils_2.symbolToWasmType(node.symbol,bitness),node.symbol.internalName,node.symbol,!1);node.symbol.offset=fn.argumentVariables.length+fn.localVariables.length,fn.localVariables.push(new wasm_local_1.WasmLocal(local.type,local.symbol.name))}for(var child=node.firstChild;null!=child;)wasmAssignLocalVariableOffsets(fn,child,shared,bitness),child=child.nextSibling}function wasmEmit(compiler,bitness,optimize){void 0===bitness&&(bitness=bitness_1.Bitness.x32),void 0===optimize&&(optimize=!0);var wasmEmitter=new WasmModuleEmitter(bitness);wasmEmitter.context=compiler.context,wasmEmitter.memoryInitializer=new bytearray_1.ByteArray,wasmEmitter.startFunctionIndex=-1,wasmEmitter.mallocFunctionIndex=-1,wasmEmitter.freeFunctionIndex=-1,wasmEmitter.currentHeapPointer=-1,wasmEmitter.originalHeapPointer=-1,wasmEmitter.prepareToEmit(compiler.global),wasmEmitter.assembler.sealFunctions(),compiler.outputWASM=wasmEmitter.assembler.module.binary.data,wasmEmitter.emitModule(),optimize&&wasm_optimizer_1.WasmOptimizer.optimize(compiler.outputWASM),compiler.outputWAST=wasmEmitter.assembler.module.text}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(7),bytearray_1=__webpack_require__(0),utils_1=__webpack_require__(8),node_1=__webpack_require__(10),opcode_1=__webpack_require__(12),builtins_helper_1=__webpack_require__(47),assert_1=__webpack_require__(3),wasm_type_1=__webpack_require__(6),logger_1=__webpack_require__(27),bitness_1=__webpack_require__(16),wasm_section_1=__webpack_require__(1),wasm_external_kind_1=__webpack_require__(11),wasm_local_1=__webpack_require__(49),wasm_shared_offset_1=__webpack_require__(50),wasm_assembler_1=__webpack_require__(46),terminal_1=__webpack_require__(2),utils_2=__webpack_require__(13),wasm_optimizer_1=__webpack_require__(51),wasm_binary_1=__webpack_require__(18),binary_importer_1=__webpack_require__(33),WasmModuleEmitter=function(){function WasmModuleEmitter(bitness){this.bitness=bitness,this.assembler=new wasm_assembler_1.WasmAssembler}return WasmModuleEmitter.prototype.growMemoryInitializer=function(){for(var array=this.memoryInitializer,current=array.length,length=this.context.nextGlobalVariableOffset;current0&&_this.assembler.activeCode.append(" (param"),signature.argumentTypes.forEach(function(type){logger_1.log(section.payload,0,type,wasm_type_1.WasmType[type]),_this.assembler.writeUnsignedLEB128(type),_this.assembler.activeCode.append(" "+wasm_type_1.WasmTypeToString[type])}),signature.argumentTypes.length>0&&_this.assembler.activeCode.append(")"),signature.returnType!==wasm_type_1.WasmType.VOID?(logger_1.log(section.payload,0,1,"num results"),_this.assembler.writeUnsignedLEB128(1),logger_1.log(section.payload,0,signature.returnType,wasm_type_1.WasmType[signature.returnType]),_this.assembler.writeUnsignedLEB128(signature.returnType),_this.assembler.activeCode.append(" (result "+wasm_type_1.WasmTypeToString[signature.returnType]+")")):_this.assembler.writeUnsignedLEB128(0),_this.assembler.activeCode.append("))\n")}),this.assembler.endSection(section)},WasmModuleEmitter.prototype.emitImportTable=function(){var _this=this;if(0!=this.assembler.module.importCount){var section=this.assembler.startSection(wasm_section_1.WasmSection.Import),imports=section.imports;logger_1.log(section.payload,0,imports.length,"num imports"),this.assembler.writeUnsignedLEB128(imports.length),imports.forEach(function(_import,index){logger_1.log(section.payload,0,null,"import func ("+index+") "+_import.namespace+" "+_import.name),_this.assembler.activeCode.append('(import "'+_import.namespace+'" "'+_import.name+'" (func (;'+index+";) (type "+_import.signatureIndex+")))\n"),_this.assembler.writeWasmString(_import.namespace),_this.assembler.writeWasmString(_import.name),_this.assembler.writeUnsignedLEB128(wasm_external_kind_1.WasmExternalKind.Function),_this.assembler.writeUnsignedLEB128(_import.signatureIndex)}),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.emitFunctionDeclarations=function(){var _this=this;if(0!==this.assembler.module.functionCount){var section=this.assembler.startSection(wasm_section_1.WasmSection.Function),functions=section.functions;logger_1.log(section.payload,0,functions.length,"num functions"),this.assembler.writeUnsignedLEB128(functions.length);var importCount=this.assembler.module.importCount;functions.forEach(function(fn,index){logger_1.log(section.payload,0,fn.signatureIndex,"func "+(importCount+index)+" sig "+utils_2.getWasmFunctionName(fn.symbol)),_this.assembler.writeUnsignedLEB128(fn.signatureIndex)}),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.emitTables=function(){},WasmModuleEmitter.prototype.emitMemory=function(){var section=this.assembler.startSection(wasm_section_1.WasmSection.Memory),memory=section.memory;memory.length>1&&terminal_1.Terminal.warn("More than 1 memory found, In the MVP, the number of memories must be no more than 1.");logger_1.log(section.payload,0,memory.length,"num memories"),this.assembler.writeUnsignedLEB128(1),logger_1.log(section.payload,0,0,"memory flags"),this.assembler.writeUnsignedLEB128(wasm_binary_1.WasmBinary.SET_MAX_MEMORY?1:0),logger_1.log(section.payload,0,wasm_binary_1.WasmBinary.SIZE_IN_PAGES,"memory initial pages"),this.assembler.writeUnsignedLEB128(wasm_binary_1.WasmBinary.SIZE_IN_PAGES),wasm_binary_1.WasmBinary.SET_MAX_MEMORY&&(logger_1.log(section.payload,0,wasm_binary_1.WasmBinary.MAX_MEMORY,"maximum memory"),this.assembler.writeUnsignedLEB128(wasm_binary_1.WasmBinary.MAX_MEMORY)),this.assembler.activeCode.append("(memory (;0;) 1)\n"),this.assembler.endSection(section)},WasmModuleEmitter.prototype.emitGlobalDeclarations=function(){var _this=this;if(0!==this.assembler.module.globalCount){var section=this.assembler.startSection(wasm_section_1.WasmSection.Global),globals=section.globals;this.assembler.writeUnsignedLEB128(globals.length),this.assembler.stackTracer.setGlobals(globals),globals.forEach(function(global,index){var wasmType=utils_2.symbolToWasmType(global.symbol,_this.bitness),value=global.symbol.node.variableValue();section.payload.append(wasmType),_this.assembler.writeUnsignedLEB128(global.mutable?1:0);var rawValue=0;switch(value&&(value.kind===node_1.NodeKind.NULL||value.kind===node_1.NodeKind.UNDEFINED?rawValue=0:void 0!==value.rawValue?rawValue=value.rawValue:_this.addGlobalToStartFunction(global)),_this.assembler.appendOpcode(0,opcode_1.WasmOpcode[wasm_type_1.WasmType[wasmType]+"_CONST"],rawValue),wasmType){case wasm_type_1.WasmType.I32:case wasm_type_1.WasmType.I64:_this.assembler.writeUnsignedLEB128(rawValue);break;case wasm_type_1.WasmType.F32:_this.assembler.writeFloat(rawValue);break;case wasm_type_1.WasmType.F64:_this.assembler.writeDouble(rawValue)}var wasmTypeStr=wasm_type_1.WasmTypeToString[wasmType];_this.assembler.activeCode.append("(global (;"+index+";) (mut "+wasmTypeStr+") ("+wasmTypeStr+".const "+rawValue+"))\n"),_this.assembler.appendOpcode(0,opcode_1.WasmOpcode.END)}),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.addGlobalToStartFunction=function(global){var value=global.symbol.node.variableValue();this.assembler.startFunctionChunk(this.startFunction,this.startFunctionIndex),this.emitNode(0,value),this.assembler.appendOpcode(0,opcode_1.WasmOpcode.SET_GLOBAL),this.assembler.writeUnsignedLEB128(global.symbol.offset),this.assembler.endFunctionChunk()},WasmModuleEmitter.prototype.emitExportTable=function(){var _this=this;if(0!==this.assembler.module.exportCount){var section=this.assembler.startSection(wasm_section_1.WasmSection.Export),importCount=this.assembler.module.importCount,exports=section.exports;logger_1.log(section.payload,0,exports.length,"num exports"),this.assembler.writeUnsignedLEB128(exports.length+1);logger_1.log(section.payload,0,"memory".length,"export name length"),logger_1.log(section.payload,null,null,utils_1.toHex(section.payload.position+0+4)+": memory // export name"),this.assembler.writeWasmString("memory"),logger_1.log(section.payload,0,wasm_external_kind_1.WasmExternalKind.Memory,"export kind"),this.assembler.activePayload.writeUnsignedByte(wasm_external_kind_1.WasmExternalKind.Memory),logger_1.log(section.payload,0,0,"export memory index"),this.assembler.writeUnsignedLEB128(0),this.assembler.activeCode.append('(export "memory" (memory 0))\n'),exports.forEach(function(_export){var fnIndex=importCount+_export.index;logger_1.log(section.payload,0,_export.as.length,"export name length"),logger_1.log(section.payload,null,null,utils_1.toHex(section.payload.position+0+4)+": "+_export.as+" // export name"),_this.assembler.writeWasmString(_export.as),logger_1.log(section.payload,0,wasm_external_kind_1.WasmExternalKind.Function,"export kind"),_this.assembler.writeUnsignedLEB128(wasm_external_kind_1.WasmExternalKind.Function),logger_1.log(section.payload,0,fnIndex,"export func index"),_this.assembler.writeUnsignedLEB128(fnIndex),_this.assembler.activeCode.append('(export "'+_export.as+'" (func $'+_export.name+"))\n")}),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.emitStart=function(){if(-1!=this.startFunctionIndex){var section=this.assembler.startSection(wasm_section_1.WasmSection.Start),importCount=this.assembler.module.importCount;logger_1.log(section.payload,0,this.startFunctionIndex,"start function index"),this.assembler.activeCode.append("(start "+(importCount+this.startFunctionIndex)+")\n"),this.assembler.writeUnsignedLEB128(importCount+this.startFunctionIndex),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.emitElements=function(){},WasmModuleEmitter.prototype.emitFunctionBodies=function(){var _this=this;if(0!==this.assembler.module.functionCount){var signatures=this.assembler.module.binary.getSection(wasm_section_1.WasmSection.Signature).signatures,functions=this.assembler.module.binary.getSection(wasm_section_1.WasmSection.Function).functions,section=this.assembler.startSection(wasm_section_1.WasmSection.Code);section.functions=functions,logger_1.log(section.payload,0,this.assembler.module.functionCount,"num functions"),this.assembler.writeUnsignedLEB128(this.assembler.module.functionCount),functions.forEach(function(fn,index){_this.currentFunction=fn;var sectionOffset=0+section.payload.position,wasmFunctionName=utils_2.getWasmFunctionName(fn.symbol);if(!fn.isExternal){var bodyData_1=new bytearray_1.ByteArray;fn.body=bodyData_1,logger_1.log(bodyData_1,sectionOffset,fn.locals.length,"local var count"),_this.assembler.startFunction(fn,index),_this.assembler.activeCode.emitIndent(),_this.assembler.activeCode.append("(func $"+wasmFunctionName+" (type "+fn.signatureIndex+") "),fn.argumentVariables.forEach(function(argumentEntry){_this.assembler.activeCode.append("(param $"+argumentEntry.name+" "+wasm_type_1.WasmTypeToString[argumentEntry.type]+") ")});var signature=signatures[fn.signatureIndex];signature.returnType!==wasm_type_1.WasmType.VOID&&_this.assembler.activeCode.append("(result "+wasm_type_1.WasmTypeToString[signature.returnType]+")"),_this.assembler.activeCode.append("\n",2),fn.localVariables.length>0?(bodyData_1.writeUnsignedLEB128(fn.localVariables.length),fn.localVariables.forEach(function(localVariableEntry){logger_1.log(bodyData_1,sectionOffset,1,"local index"),bodyData_1.writeUnsignedLEB128(1),logger_1.log(bodyData_1,sectionOffset,localVariableEntry.type,wasm_type_1.WasmType[localVariableEntry.type]),bodyData_1.append(localVariableEntry.type),_this.assembler.activeCode.append("(local $"+localVariableEntry.name+" "+wasm_type_1.WasmTypeToString[localVariableEntry.type]+") ")}),_this.assembler.activeCode.append("\n")):bodyData_1.writeUnsignedLEB128(0);var lastChild=void 0;fn.isConstructor&&_this.emitConstructor(sectionOffset,fn);for(var child=fn.symbol.node.functionBody().firstChild;null!=child;)lastChild=child,_this.emitNode(sectionOffset,child),child=child.nextSibling;fn.chunks.length>0?(_this.assembler.activeCode.clearIndent(2),fn.chunks.forEach(function(chunk,index){bodyData_1.copy(chunk.payload),bodyData_1.log+=chunk.payload.log,chunk.code.removeLastLinebreak(),_this.assembler.activeCode.appendRaw(chunk.code.finish())})):lastChild&&lastChild.kind!==node_1.NodeKind.RETURN&&fn.returnType!=wasm_type_1.WasmType.VOID&&_this.assembler.appendOpcode(sectionOffset,opcode_1.WasmOpcode.RETURN),fn.returnType===wasm_type_1.WasmType.VOID&&_this.assembler.dropStack(),_this.assembler.appendOpcode(sectionOffset,opcode_1.WasmOpcode.END,null,!0),_this.assembler.endFunction(),_this.assembler.activeCode.removeLastLinebreak(),_this.assembler.activeCode.append(")\n")}section.payload.writeUnsignedLEB128(fn.body.length),logger_1.log(section.payload,0,null," - func body "+(_this.assembler.module.importCount+index)+" ("+wasmFunctionName+")"),logger_1.log(section.payload,0,fn.body.length,"func body size"),section.payload.log+=fn.body.log,section.payload.copy(fn.body)}),this.assembler.endSection(section)}},WasmModuleEmitter.prototype.emitDataSegments=function(){this.growMemoryInitializer();var memoryInitializer=this.memoryInitializer,initializerLength=memoryInitializer.length,initialHeapPointer=utils_1.alignToNextMultipleOf(wasm_binary_1.WasmBinary.MEMORY_INITIALIZER_BASE+initializerLength,8);memoryInitializer.writeUnsignedInt(initialHeapPointer,this.originalHeapPointer),memoryInitializer.writeUnsignedInt(initialHeapPointer,this.currentHeapPointer);var section=this.assembler.startSection(wasm_section_1.WasmSection.Data);logger_1.log(section.payload,0,1,"num data segments"),this.assembler.writeUnsignedLEB128(1),logger_1.log(section.payload,0,null," - data segment header 0"),logger_1.log(section.payload,0,0,"memory index"),this.assembler.writeUnsignedLEB128(0),this.assembler.appendOpcode(0,opcode_1.WasmOpcode.I32_CONST),logger_1.log(section.payload,0,wasm_binary_1.WasmBinary.MEMORY_INITIALIZER_BASE,"i32 literal"),this.assembler.writeUnsignedLEB128(wasm_binary_1.WasmBinary.MEMORY_INITIALIZER_BASE),this.assembler.appendOpcode(0,opcode_1.WasmOpcode.END),logger_1.log(section.payload,0,initializerLength,"data segment size"),this.assembler.writeUnsignedLEB128(initializerLength),logger_1.log(section.payload,0,null," - data segment data 0"),this.assembler.activeCode.append("(data (i32.const "+wasm_binary_1.WasmBinary.MEMORY_INITIALIZER_BASE+') " ');for(var value,i=0;i0);var lengthNode=node.arrayLength();if(lengthNode.kind==node_1.NodeKind.INT32){var length=size*lengthNode.intValue;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,length),this.assembler.writeLEB128(length)}else this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(size),this.emitNode(byteOffset,lengthNode),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_MUL);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(size);var callIndex=this.getWasmFunctionCallIndex(callSymbol);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.CALL),logger_1.log(this.assembler.activePayload,byteOffset,callIndex,"call func index ("+callIndex+")"),this.assembler.writeUnsignedLEB128(callIndex)}else if(type.resolvedType.isTypedArray());else{for(var child=node.firstChild.nextSibling;null!=child;)this.emitNode(byteOffset,child),child=child.nextSibling;var callIndex=this.getWasmFunctionCallIndex(callSymbol);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.CALL,callIndex),this.assembler.writeUnsignedLEB128(callIndex)}},WasmModuleEmitter.prototype.emitConstructor=function(byteOffset,fn){var constructorNode=fn.symbol.node,type=constructorNode.parent.symbol,size=type.resolvedType.allocationSizeOf(this.context);if(assert_1.assert(size>0),type.resolvedType.isArray())this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.GET_LOCAL,0),this.assembler.writeUnsignedLEB128(0),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(size),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_ADD);else if(type.resolvedType.isTypedArray()){var elementSize=utils_2.getTypedArrayElementSize(type.resolvedType.symbol.name);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.GET_LOCAL,0),this.assembler.writeUnsignedLEB128(0),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,elementSize),this.assembler.writeLEB128(elementSize),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_SHL),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(size),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_ADD)}else this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(size);var mallocIndex=this.calculateWasmFunctionIndex(this.mallocFunctionIndex);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.CALL,mallocIndex),this.assembler.writeUnsignedLEB128(mallocIndex),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,fn.signature.argumentTypes.length),this.assembler.writeUnsignedLEB128(fn.signature.argumentTypes.length)},WasmModuleEmitter.prototype.emitNode=function(byteOffset,node){if(assert_1.assert(!node_1.isExpression(node)||null!=node.resolvedType),node.kind==node_1.NodeKind.BLOCK){var skipBlock=node.parent.kind===node_1.NodeKind.IF;skipBlock||(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.BLOCK),void 0!==node.returnNode?(this.assembler.append(byteOffset,this.currentFunction.returnType),this.assembler.activeCode.removeLastLinebreak(),this.assembler.activeCode.append(" (result "+wasm_type_1.WasmTypeToString[this.currentFunction.returnType]+")\n",1)):this.assembler.append(byteOffset,wasm_type_1.WasmType.block_type));for(var child=node.firstChild;null!=child;)this.emitNode(byteOffset,child),child=child.nextSibling;skipBlock||(this.assembler.activeCode.clearIndent(1),this.assembler.activeCode.indent-=1,this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.END))}else if(node.kind==node_1.NodeKind.WHILE){var value=node.whileValue(),body=node.whileBody();if(value.kind==node_1.NodeKind.BOOLEAN&&0==value.intValue)return 0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.BLOCK),this.assembler.append(byteOffset,wasm_type_1.WasmType.block_type),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.LOOP),this.assembler.append(byteOffset,wasm_type_1.WasmType.block_type),value.kind!=node_1.NodeKind.BOOLEAN&&(this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_EQZ),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.BR_IF),this.assembler.writeUnsignedLEB128(1));for(var child=body.firstChild;null!=child;)this.emitNode(byteOffset,child),child=child.nextSibling;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.BR),this.assembler.writeUnsignedLEB128(0),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.END),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.BREAK||node.kind==node_1.NodeKind.CONTINUE){for(var label=0,parent=node.parent;null!=parent&&parent.kind!=node_1.NodeKind.WHILE;)parent.kind==node_1.NodeKind.BLOCK&&(label+=1),parent=parent.parent;assert_1.assert(label>0),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.BR),this.assembler.writeUnsignedLEB128(label-(node.kind==node_1.NodeKind.BREAK?0:1))}else{if(node.kind==node_1.NodeKind.EMPTY)return 0;if(node.kind==node_1.NodeKind.EXPRESSION)this.emitNode(byteOffset,node.expressionValue());else if(node.kind==node_1.NodeKind.RETURN){var value=node.returnValue();null!=value&&this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.RETURN)}else{if(node.kind==node_1.NodeKind.VARIABLES){for(var count=0,child=node.firstChild;null!=child;)assert_1.assert(child.kind==node_1.NodeKind.VARIABLE),count+=this.emitNode(byteOffset,child),child=child.nextSibling;return count}if(node.kind==node_1.NodeKind.IF){var branch=node.ifFalse();this.emitNode(byteOffset,node.ifValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.IF);var returnNode=node.ifReturnNode(),needEmptyElse=!1;if(null==returnNode&&null===branch)this.assembler.append(0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]);else if(null!==returnNode){var returnType=utils_2.symbolToWasmType(returnNode.resolvedType.symbol);this.assembler.append(0,returnType,wasm_type_1.WasmType[returnType]),this.assembler.activeCode.removeLastLinebreak(),this.assembler.activeCode.append(" (result "+wasm_type_1.WasmTypeToString[returnType]+")\n"),null==branch&&(needEmptyElse=!0)}else this.assembler.append(0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]);if(this.emitNode(byteOffset,node.ifTrue()),null!=branch)this.assembler.activeCode.indent-=1,this.assembler.activeCode.clearIndent(1),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.IF_ELSE),this.emitNode(byteOffset,branch);else if(needEmptyElse){this.assembler.activeCode.indent-=1,this.assembler.activeCode.clearIndent(1),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.IF_ELSE);var dataType=utils_2.typeToDataType(returnNode.resolvedType,this.bitness);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode[dataType+"_CONST"]),"I32"===dataType||"I64"===dataType?this.assembler.writeUnsignedLEB128(0):"F32"===dataType?this.assembler.writeFloat(0):"F64"===dataType&&this.assembler.writeDouble(0)}this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.HOOK){this.emitNode(byteOffset,node.hookValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.IF);var trueValue=node.hookTrue(),trueValueType=utils_2.symbolToWasmType(trueValue.resolvedType.symbol);this.assembler.append(0,trueValueType,wasm_type_1.WasmType[trueValueType]),this.emitNode(byteOffset,trueValue),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.IF_ELSE),this.emitNode(byteOffset,node.hookFalse()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.VARIABLE){var value=node.variableValue();if("this"==node.symbol.name&&"constructor"==this.currentFunction.symbol.name);else if(node.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL){value&&value.kind!=node_1.NodeKind.NAME&&value.kind!=node_1.NodeKind.CALL&&value.kind!=node_1.NodeKind.NEW&&value.kind!=node_1.NodeKind.DOT&&value.rawValue?node.symbol.resolvedType.isFloat()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,value.floatValue),this.assembler.writeFloat(value.floatValue)):node.symbol.resolvedType.isDouble()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,value.doubleValue),this.assembler.writeDouble(value.doubleValue)):node.symbol.resolvedType.isLong()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,value.longValue),this.assembler.writeLEB128(value.longValue)):(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,value.intValue),this.assembler.writeLEB128(value.intValue)):null!=value?this.emitNode(byteOffset,value):node.symbol.resolvedType.isFloat()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,0),this.assembler.writeFloat(0)):node.symbol.resolvedType.isDouble()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,0),this.assembler.writeDouble(0)):node.symbol.resolvedType.isLong()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(0)):(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(0));var skipSetLocal=value&&node_1.isUnaryPostfix(value.kind);0==skipSetLocal&&(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,node.symbol.offset),this.assembler.writeUnsignedLEB128(node.symbol.offset))}else assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.NAME){var symbol=node.symbol;symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT||symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL?"this"===symbol.name&&"constructor"===this.currentFunction.symbol.name?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.GET_LOCAL,this.currentFunction.signature.argumentTypes.length),this.assembler.writeUnsignedLEB128(this.currentFunction.signature.argumentTypes.length)):(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.GET_LOCAL,symbol.offset),this.assembler.writeUnsignedLEB128(symbol.offset)):symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.GET_GLOBAL,symbol.offset),this.assembler.writeUnsignedLEB128(symbol.offset)):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.DEREFERENCE)this.emitLoadFromMemory(byteOffset,node.resolvedType.underlyingType(this.context),node.unaryValue(),0);else if(node.kind==node_1.NodeKind.POINTER_INDEX)this.emitLoadFromMemory(byteOffset,node.resolvedType.underlyingType(this.context),node.pointer(),node.pointerOffset());else if(node.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(0);else if(node.kind==node_1.NodeKind.INT32||node.kind==node_1.NodeKind.BOOLEAN)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,node.intValue),this.assembler.writeLEB128(node.intValue||0);else if(node.kind==node_1.NodeKind.INT64)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,node.longValue),this.assembler.writeLEB128(node.longValue);else if(node.kind==node_1.NodeKind.FLOAT32)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,node.floatValue),this.assembler.writeFloat(node.floatValue);else if(node.kind==node_1.NodeKind.FLOAT64)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,node.doubleValue),this.assembler.writeDouble(node.doubleValue);else if(node.kind==node_1.NodeKind.STRING){var value=wasm_binary_1.WasmBinary.MEMORY_INITIALIZER_BASE+node.intValue;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,value),this.assembler.writeLEB128(value)}else if(node.kind==node_1.NodeKind.CALL){var value=node.callValue(),symbol=value.symbol;if(assert_1.assert(symbol_1.isFunction(symbol.kind)),!symbol.node.isExternalImport()&&symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var dotTarget=value.dotTarget();this.emitNode(byteOffset,dotTarget),dotTarget.kind==node_1.NodeKind.NEW&&this.emitInstance(byteOffset,dotTarget)}for(var child=value.nextSibling;null!=child;)this.emitNode(byteOffset,child),child=child.nextSibling;var wasmFunctionName=utils_2.getWasmFunctionName(symbol);if(builtins_helper_1.isBuiltin(wasmFunctionName))this.assembler.appendOpcode(byteOffset,builtins_helper_1.getBuiltinOpcode(symbol.name));else{var callIndex=this.getWasmFunctionCallIndex(symbol);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.CALL,callIndex),this.assembler.writeUnsignedLEB128(callIndex)}}else if(node.kind==node_1.NodeKind.NEW)this.emitInstance(byteOffset,node);else if(node.kind==node_1.NodeKind.DELETE){var value=node.deleteValue();this.emitNode(byteOffset,value);var freeIndex=this.calculateWasmFunctionIndex(this.freeFunctionIndex);this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.CALL,freeIndex),this.assembler.writeUnsignedLEB128(freeIndex)}else if(node.kind==node_1.NodeKind.POSITIVE)this.emitNode(byteOffset,node.unaryValue());else if(node.kind==node_1.NodeKind.NEGATIVE){var resolvedType=node.unaryValue().resolvedType;resolvedType.isFloat()?(this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_NEG)):resolvedType.isDouble()?(this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_NEG)):resolvedType.isInteger()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(0),this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_SUB)):resolvedType.isLong()&&(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(0),this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_SUB))}else if(node.kind==node_1.NodeKind.COMPLEMENT)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,-1),this.assembler.writeLEB128(-1),this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_XOR);else if(node.kind==node_1.NodeKind.NOT)this.emitNode(byteOffset,node.unaryValue()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_EQZ);else if(node.kind==node_1.NodeKind.CAST){var value=node.castValue(),context=this.context,from=value.resolvedType.underlyingType(context),type=node.resolvedType.underlyingType(context);from.variableSizeOf(context),type.variableSizeOf(context);if(from!=context.nullType&&from!=context.booleanType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.int64Type&&type!=context.uint64Type)if(from!=context.nullType&&from!=context.booleanType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.float32Type)if(from!=context.nullType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.float64Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.int32Type&&type!=context.uint32Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.float32Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.float64Type)if(from!=context.float32Type||type!=context.uint8Type&&type!=context.int8Type&&type!=context.uint16Type&&type!=context.int16Type&&type!=context.uint32Type&&type!=context.int32Type)if(from!=context.float32Type||type!=context.int64Type&&type!=context.uint64Type)if(from==context.float32Type&&type==context.float64Type)if(value.kind==node_1.NodeKind.FLOAT32){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(doubleValue)}else this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_PROMOTE_F32);else if(from!=context.float64Type||type!=context.uint8Type&&type!=context.int8Type&&type!=context.uint16Type&&type!=context.int16Type&&type!=context.uint32Type&&type!=context.int32Type)if(from!=context.float64Type||type!=context.int64Type&&type!=context.uint64Type)if(from==context.float64Type&&type==context.float32Type)if(value.kind==node_1.NodeKind.FLOAT64){var floatValue=value.floatValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(floatValue)}else this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_DEMOTE_F64);else this.emitNode(byteOffset,value);else if(value.kind==node_1.NodeKind.FLOAT64){var longValue=value.longValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,longValue),this.assembler.writeLEB128(longValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_TRUNC_U_F64:opcode_1.WasmOpcode.I64_TRUNC_S_F64)}else if(value.kind==node_1.NodeKind.FLOAT64){var intValue=value.intValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(intValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.I32_TRUNC_U_F64:opcode_1.WasmOpcode.I32_TRUNC_S_F64)}else if(value.kind==node_1.NodeKind.FLOAT32){var longValue=value.longValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,longValue),this.assembler.writeLEB128(longValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_TRUNC_U_F32:opcode_1.WasmOpcode.I64_TRUNC_S_F32)}else if(value.kind==node_1.NodeKind.FLOAT32){var intValue=value.intValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(intValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.I32_TRUNC_U_F32:opcode_1.WasmOpcode.I32_TRUNC_S_F32)}else if(value.kind==node_1.NodeKind.INT64){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(doubleValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.F64_CONVERT_U_I64:opcode_1.WasmOpcode.F64_CONVERT_S_I64)}else if(value.kind==node_1.NodeKind.INT32){var floatValue=value.floatValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(floatValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.F32_CONVERT_U_I64:opcode_1.WasmOpcode.F32_CONVERT_S_I64)}else if(value.kind==node_1.NodeKind.INT64){var intValue=value.intValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(intValue)}else this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_WRAP_I64);else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,0),this.assembler.writeDouble(0);else if(value.kind==node_1.NodeKind.BOOLEAN){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(doubleValue)}else if(value.kind==node_1.NodeKind.INT32){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(doubleValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.F64_CONVERT_U_I32:opcode_1.WasmOpcode.F64_CONVERT_S_I32)}else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,0),this.assembler.writeFloat(0);else if(value.kind==node_1.NodeKind.BOOLEAN){var floatValue=value.intValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(floatValue)}else if(value.kind==node_1.NodeKind.INT32){var floatValue=value.floatValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(floatValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.F32_CONVERT_U_I32:opcode_1.WasmOpcode.F32_CONVERT_S_I32)}else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(0);else if(value.kind==node_1.NodeKind.BOOLEAN){var intValue=value.intValue||0;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,intValue),this.assembler.writeLEB128(intValue)}else if(value.kind==node_1.NodeKind.INT32)this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,value.longValue),this.assembler.writeLEB128(value.longValue);else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_EXTEND_U_I32:opcode_1.WasmOpcode.I64_EXTEND_S_I32)}}else if(node.kind==node_1.NodeKind.DOT){var symbol=node.symbol;symbol.kind==symbol_1.SymbolKind.VARIABLE_INSTANCE?this.emitLoadFromMemory(byteOffset,symbol.resolvedType,node.dotTarget(),symbol.offset):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.ASSIGN){var left=node.binaryLeft(),right=node.binaryRight(),symbol=left.symbol;left.kind==node_1.NodeKind.DEREFERENCE?this.emitStoreToMemory(byteOffset,left.resolvedType.underlyingType(this.context),left.unaryValue(),0,right):left.kind==node_1.NodeKind.POINTER_INDEX?this.emitStoreToMemory(byteOffset,left.resolvedType.underlyingType(this.context),left.pointer(),left.pointerOffset(),right):symbol.kind==symbol_1.SymbolKind.VARIABLE_INSTANCE?this.emitStoreToMemory(byteOffset,symbol.resolvedType,left.dotTarget(),symbol.offset,right):symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.emitNode(byteOffset,right),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_GLOBAL),this.assembler.writeUnsignedLEB128(symbol.offset)):symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT||symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL?(this.emitNode(byteOffset,right),node_1.isUnaryPostfix(right.kind)||(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,symbol.offset),this.assembler.writeUnsignedLEB128(symbol.offset))):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.LOGICAL_AND)this.emitNode(byteOffset,node.binaryLeft()),this.emitNode(byteOffset,node.binaryRight()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_AND),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(1),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_EQ);else if(node.kind==node_1.NodeKind.LOGICAL_OR)this.emitNode(byteOffset,node.binaryLeft()),this.emitNode(byteOffset,node.binaryRight()),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_OR),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST),logger_1.log(this.assembler.activePayload,byteOffset,1,"i32 literal"),this.assembler.writeLEB128(1),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_EQ);else if(node_1.isUnary(node.kind)){var kind=node.kind;if(kind==node_1.NodeKind.POSTFIX_INCREMENT||kind==node_1.NodeKind.POSTFIX_DECREMENT){var value=node.unaryValue(),dataType=utils_2.typeToDataType(value.resolvedType,this.bitness);if(node.parent.kind==node_1.NodeKind.VARIABLE)this.emitNode(byteOffset,value),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,node.parent.symbol.offset),this.assembler.writeUnsignedLEB128(node.parent.symbol.offset);else if(node.parent.kind==node_1.NodeKind.ASSIGN){this.emitNode(byteOffset,value);var left=node.parent.binaryLeft();this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,left.symbol.offset),this.assembler.writeUnsignedLEB128(left.symbol.offset)}if(this.emitNode(byteOffset,value),node.parent.kind!=node_1.NodeKind.RETURN){assert_1.assert(value.resolvedType.isInteger()||value.resolvedType.isLong()||value.resolvedType.isFloat()||value.resolvedType.isDouble());var size=value.resolvedType.pointerTo?value.resolvedType.pointerTo.allocationSizeOf(this.context):value.resolvedType.allocationSizeOf(this.context);1==size||2==size?value.kind==node_1.NodeKind.INT32||value.resolvedType.isInteger()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(1)):terminal_1.Terminal.error("Wrong type"):4==size?value.kind==node_1.NodeKind.INT32||value.resolvedType.isInteger()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(1)):value.kind==node_1.NodeKind.FLOAT32||value.resolvedType.isFloat()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,1),this.assembler.writeFloat(1)):terminal_1.Terminal.error("Wrong type"):8==size&&(value.kind==node_1.NodeKind.INT64||value.resolvedType.isLong()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,1),this.assembler.writeLEB128(1)):value.kind==node_1.NodeKind.FLOAT64||value.resolvedType.isDouble()?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,1),this.assembler.writeDouble(1)):terminal_1.Terminal.error("Wrong type"));var operation=kind==node_1.NodeKind.POSTFIX_INCREMENT?"ADD":"SUB";this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode[dataType+"_"+operation]),value.symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_GLOBAL,value.symbol.offset),this.assembler.writeLEB128(value.symbol.offset)):value.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL||value.symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.SET_LOCAL,value.symbol.offset),this.assembler.writeLEB128(value.symbol.offset)):(value.symbol.kind,symbol_1.SymbolKind.VARIABLE_INSTANCE)}}}else{var isUnsigned=node.isUnsignedOperator(),left=node.binaryLeft(),right=node.binaryRight(),isFloat=left.resolvedType.isFloat()||right.resolvedType.isFloat(),isDouble=left.resolvedType.isDouble()||right.resolvedType.isDouble(),dataTypeLeft=utils_2.typeToDataType(left.resolvedType,this.bitness);utils_2.typeToDataType(right.resolvedType,this.bitness);if(node.kind==node_1.NodeKind.ADD){if(this.emitNode(byteOffset,left),null==left.resolvedType.pointerTo)this.emitNode(byteOffset,right);else{assert_1.assert(right.resolvedType.isInteger()||right.resolvedType.isLong()||right.resolvedType.isFloat()||right.resolvedType.isDouble());var size=left.resolvedType.pointerTo.allocationSizeOf(this.context);if(2==size)if(right.kind==node_1.NodeKind.INT32){var _value=right.intValue<<1;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,_value),this.assembler.writeLEB128(_value)}else this.emitNode(byteOffset,right),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(1),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_SHL);else if(4==size)if(right.kind==node_1.NodeKind.INT32){var _value=right.intValue<<2;this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,_value),this.assembler.writeLEB128(_value)}else right.kind==node_1.NodeKind.FLOAT32?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F32_CONST,right.floatValue),this.assembler.writeFloat(right.floatValue)):(this.emitNode(byteOffset,right),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_CONST,2),this.assembler.writeLEB128(2),this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I32_SHL));else 8==size?right.kind==node_1.NodeKind.INT64?(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.I64_CONST,right.longValue),this.assembler.writeLEB128(right.longValue)):right.kind==node_1.NodeKind.FLOAT64&&(this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode.F64_CONST,right.doubleValue),this.assembler.writeDouble(right.doubleValue)):this.emitNode(byteOffset,right)}this.assembler.appendOpcode(byteOffset,opcode_1.WasmOpcode[dataTypeLeft+"_ADD"])}else if(node.kind==node_1.NodeKind.BITWISE_AND){if(isFloat||isDouble){var error="Cannot do bitwise operations on floating point number";throw terminal_1.Terminal.error(error),error}this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_AND"])}else if(node.kind==node_1.NodeKind.BITWISE_OR){if(isFloat||isDouble){var error="Cannot do bitwise operations on floating point number";throw terminal_1.Terminal.error(error),error}this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_OR"])}else if(node.kind==node_1.NodeKind.BITWISE_XOR)this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_XOR"]);else if(node.kind==node_1.NodeKind.EQUAL)this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_EQ"]);else if(node.kind==node_1.NodeKind.MULTIPLY)this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_MUL"]);else if(node.kind==node_1.NodeKind.NOT_EQUAL)this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_NE"]);else if(node.kind==node_1.NodeKind.SHIFT_LEFT){if(isFloat||isDouble){var error="Cannot do bitwise operations on floating point number";throw terminal_1.Terminal.error(error),error}this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_SHL"])}else if(node.kind==node_1.NodeKind.SUBTRACT)this.emitBinaryExpression(byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_SUB"]);else if(node.kind==node_1.NodeKind.DIVIDE){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_DIV"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_DIV_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_DIV_S"];this.emitBinaryExpression(byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.GREATER_THAN){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_GT"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_GT_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_GT_S"];this.emitBinaryExpression(byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.GREATER_THAN_EQUAL){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_GE"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_GE_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_GE_S"];this.emitBinaryExpression(byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.LESS_THAN){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_LT"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_LT_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_LT_S"];this.emitBinaryExpression(byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.LESS_THAN_EQUAL){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_LE"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_LE_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_LE_S"];this.emitBinaryExpression(byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.REMAINDER){if(isFloat||isDouble){var error="Floating point remainder is not yet supported in WebAssembly. Please import javascript function to handle this";throw terminal_1.Terminal.error(error),error}this.emitBinaryExpression(byteOffset,node,isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_REM_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_REM_S"])}else if(node.kind==node_1.NodeKind.SHIFT_RIGHT){if(isFloat||isDouble){var error="Cannot do bitwise operations on floating point number";throw terminal_1.Terminal.error(error),error}this.emitBinaryExpression(byteOffset,node,isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_SHR_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_SHR_S"])}else assert_1.assert(!1)}}}return 1},WasmModuleEmitter.prototype.calculateWasmFunctionIndex=function(index){return this.assembler.module.importCount+index},WasmModuleEmitter.prototype.getWasmFunctionCallIndex=function(symbol){return symbol.node.isImport()||symbol.node.isExternalImport()?symbol.offset:this.assembler.module.importCount+symbol.offset},WasmModuleEmitter.prototype.getWasmType=function(type){var context=this.context;return type==context.booleanType||type.isClass()||type.isInteger()||this.bitness==bitness_1.Bitness.x32&&type.isReference()?wasm_type_1.WasmType.I32:type.isLong()||this.bitness==bitness_1.Bitness.x64&&type.isReference()?wasm_type_1.WasmType.I64:type.isDouble()?wasm_type_1.WasmType.F64:type.isFloat()?wasm_type_1.WasmType.F32:type==context.voidType?wasm_type_1.WasmType.VOID:(assert_1.assert(!1),wasm_type_1.WasmType.VOID)},WasmModuleEmitter}();exports.wasmEmit=wasmEmit},function(module,exports,__webpack_require__){"use strict";function addScopeToSymbol(symbol,parentScope){var scope=new scope_1.Scope;scope.parent=parentScope,scope.symbol=symbol,symbol.scope=scope}function linkSymbolToNode(symbol,node){node.symbol=symbol,node.scope=symbol.scope,symbol.range=null!=node.internalRange?node.internalRange:node.range,symbol.node=node}function initialize(context,node,parentScope,mode){var kind=node.kind;if(null!=node.parent){var parentKind=node.parent.kind;kind==node_1.NodeKind.IMPORTS||kind==node_1.NodeKind.VARIABLE||kind==node_1.NodeKind.VARIABLES||kind==node_1.NodeKind.FUNCTION&&parentKind==node_1.NodeKind.CLASS||(parentKind==node_1.NodeKind.FILE||parentKind==node_1.NodeKind.GLOBAL)==(parentKind==node_1.NodeKind.MODULE||kind==node_1.NodeKind.MODULE||kind==node_1.NodeKind.CLASS||kind==node_1.NodeKind.ENUM||kind==node_1.NodeKind.FUNCTION||kind==node_1.NodeKind.CONSTANTS)||context.log.error(node.range,"This statement is not allowed here")}if(kind==node_1.NodeKind.MODULE){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;symbol.kind=symbol_1.SymbolKind.TYPE_MODULE,symbol.name=node.stringValue,symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.flags=symbol_1.SYMBOL_FLAG_IS_REFERENCE,addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL),parentScope=symbol.scope}if(kind==node_1.NodeKind.CLASS||kind==node_1.NodeKind.ENUM){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;if(symbol.kind=kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.TYPE_CLASS:symbol_1.SymbolKind.TYPE_ENUM,symbol.name=node.stringValue,symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.flags=symbol_1.SYMBOL_FLAG_IS_REFERENCE,addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL),parentScope=symbol.scope,node.parameterCount()>0){symbol.kind=symbol_1.SymbolKind.TYPE_TEMPLATE,symbol.flags|=symbol_1.SYMBOL_FLAG_IS_TEMPLATE;var genericType=node.firstGenericType(),genericSymbol=new symbol_1.Symbol;genericSymbol.kind=symbol_1.SymbolKind.TYPE_GENERIC,genericSymbol.name=genericType.stringValue,genericSymbol.resolvedType=new type_1.Type,genericSymbol.resolvedType.symbol=genericSymbol,genericSymbol.flags=symbol_1.SYMBOL_FLAG_IS_GENERIC,genericType.flags=node_1.NODE_FLAG_GENERIC,addScopeToSymbol(genericSymbol,parentScope),linkSymbolToNode(genericSymbol,genericType),parentScope.define(context.log,genericSymbol,scope_1.ScopeHint.NORMAL)}}else if(kind==node_1.NodeKind.FUNCTION){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;if(symbol.kind=node.parent.kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.FUNCTION_INSTANCE:symbol_1.SymbolKind.FUNCTION_GLOBAL,symbol.name=node.stringValue,node.isOperator()&&("+"==symbol.name||"-"==symbol.name?node.functionFirstArgument()==node.functionReturnType()?(symbol.flags=symbol_1.SYMBOL_FLAG_IS_UNARY_OPERATOR,symbol.rename="+"==symbol.name?"op_positive":"op_negative"):(symbol.flags=symbol_1.SYMBOL_FLAG_IS_BINARY_OPERATOR,symbol.rename="+"==symbol.name?"op_add":"op_subtract"):symbol.rename="%"==symbol.name?"op_remainder":"&"==symbol.name?"op_and":"*"==symbol.name?"op_multiply":"**"==symbol.name?"op_exponent":"++"==symbol.name?"op_increment":"--"==symbol.name?"op_decrement":"/"==symbol.name?"op_divide":"<"==symbol.name?"op_lessThan":"<<"==symbol.name?"op_shiftLeft":"=="==symbol.name?"op_equals":">"==symbol.name?"op_greaterThan":">>"==symbol.name?"op_shiftRight":"[]"==symbol.name?"op_get":"[]="==symbol.name?"op_set":"^"==symbol.name?"op_xor":"|"==symbol.name?"op_or":"~"==symbol.name?"op_complement":null),"constructor"==symbol.name&&(symbol.rename="_ctr"),addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,symbol.isSetter()?scope_1.ScopeHint.NOT_GETTER:symbol.isGetter()?scope_1.ScopeHint.NOT_SETTER:symbol.isBinaryOperator()?scope_1.ScopeHint.NOT_UNARY:symbol.isUnaryOperator()?scope_1.ScopeHint.NOT_BINARY:scope_1.ScopeHint.NORMAL),parentScope=symbol.scope,symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var parent=symbol.parent();if(initializeSymbol(context,parent),"constructor"==symbol.name){var body=node.functionBody();if(null!==body){var variablesNode=body.firstChild;if(variablesNode.kind!==node_1.NodeKind.VARIABLES){var _variablesNode=node_1.createVariables();body.insertChildBefore(variablesNode,_variablesNode),variablesNode=_variablesNode}var firstVariable=variablesNode.firstChild;void 0!==firstVariable?"this"!==firstVariable.stringValue?variablesNode.insertChildBefore(firstVariable,node_1.createVariable("this",node_1.createType(parent.resolvedType),null)):"this"===firstVariable.stringValue&&void 0===firstVariable.firstChild.resolvedType&&(firstVariable.firstChild.resolvedType=parent.resolvedType):variablesNode.appendChild(node_1.createVariable("this",node_1.createType(parent.resolvedType),null));var returnNode=node_1.createReturn(node_1.createName("this"));node.lastChild.lastChild&&node.lastChild.lastChild.kind==node_1.NodeKind.RETURN&&node.lastChild.lastChild.remove(),node.lastChild.appendChild(returnNode)}}else{var firstArgument=node.functionFirstArgument();"this"!==firstArgument.stringValue?node.insertChildBefore(firstArgument,node_1.createVariable("this",node_1.createType(parent.resolvedType),null)):"this"===firstArgument.stringValue&&void 0===firstArgument.firstChild.resolvedType&&(firstArgument.firstChild.resolvedType=parent.resolvedType)}}}else if(kind==node_1.NodeKind.VARIABLE){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;symbol.kind=node.parent.kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.VARIABLE_INSTANCE:node.parent.kind==node_1.NodeKind.FUNCTION?symbol_1.SymbolKind.VARIABLE_ARGUMENT:node.parent.kind==node_1.NodeKind.CONSTANTS||node.parent.kind==node_1.NodeKind.ENUM?symbol_1.SymbolKind.VARIABLE_CONSTANT:node.parent.kind==node_1.NodeKind.VARIABLES&&node.parent.parent.kind==node_1.NodeKind.FILE?symbol_1.SymbolKind.VARIABLE_GLOBAL:symbol_1.SymbolKind.VARIABLE_LOCAL,symbol.name=node.stringValue,symbol.scope=parentScope,linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL)}else if(kind==node_1.NodeKind.BLOCK){if(node.parent.kind!=node_1.NodeKind.FUNCTION){var scope=new scope_1.Scope;scope.parent=parentScope,parentScope=scope}node.scope=parentScope}for(var child=node.firstChild;null!=child;)mode==CheckMode.INITIALIZE&&(child.flags|=node_1.NODE_FLAG_LIBRARY),initialize(context,child,parentScope,mode),child=child.nextSibling;kind==node_1.NodeKind.FILE&&mode==CheckMode.INITIALIZE&&(context.booleanType=parentScope.findLocal("boolean",scope_1.ScopeHint.NORMAL).resolvedType,context.uint8Type=parentScope.findLocal("uint8",scope_1.ScopeHint.NORMAL).resolvedType,context.int32Type=parentScope.findLocal("int32",scope_1.ScopeHint.NORMAL).resolvedType,context.int64Type=parentScope.findLocal("int64",scope_1.ScopeHint.NORMAL).resolvedType,context.int8Type=parentScope.findLocal("int8",scope_1.ScopeHint.NORMAL).resolvedType,context.int16Type=parentScope.findLocal("int16",scope_1.ScopeHint.NORMAL).resolvedType,context.stringType=parentScope.findLocal("string",scope_1.ScopeHint.NORMAL).resolvedType,context.uint32Type=parentScope.findLocal("uint32",scope_1.ScopeHint.NORMAL).resolvedType,context.uint64Type=parentScope.findLocal("uint64",scope_1.ScopeHint.NORMAL).resolvedType,context.uint16Type=parentScope.findLocal("uint16",scope_1.ScopeHint.NORMAL).resolvedType,context.float32Type=parentScope.findLocal("float32",scope_1.ScopeHint.NORMAL).resolvedType,context.float64Type=parentScope.findLocal("float64",scope_1.ScopeHint.NORMAL).resolvedType,prepareNativeType(context.booleanType,1,0),prepareNativeType(context.uint8Type,1,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.int8Type,1,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.int16Type,2,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.uint16Type,2,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.int32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.int64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_LONG),prepareNativeType(context.uint32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.uint64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_LONG|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.stringType,4,symbol_1.SYMBOL_FLAG_IS_REFERENCE),prepareNativeType(context.float32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_FLOAT),prepareNativeType(context.float64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_DOUBLE))}function prepareNativeType(type,byteSizeAndMaxAlignment,flags){var symbol=type.symbol;symbol.kind=symbol_1.SymbolKind.TYPE_NATIVE,symbol.byteSize=byteSizeAndMaxAlignment,symbol.maxAlignment=byteSizeAndMaxAlignment,symbol.flags=flags}function forbidFlag(context,node,flag,text){if(0!=(node.flags&flag)){var range=node_1.rangeForFlag(node.firstFlag,flag);null!=range&&(node.flags=node.flags&~flag,context.log.error(range,text))}}function requireFlag(context,node,flag,text){0==(node.flags&flag)&&(node.flags=node.flags|flag,context.log.error(node.range,text))}function initializeSymbol(context,symbol){if(symbol.state==symbol_1.SymbolState.INITIALIZED)return void assert_1.assert(null!=symbol.resolvedType);assert_1.assert(symbol.state==symbol_1.SymbolState.UNINITIALIZED),symbol.state=symbol_1.SymbolState.INITIALIZING;var node=symbol.node;if(forbidFlag(context,node,node_1.NODE_FLAG_PROTECTED,"Unsupported flag 'protected'"),symbol.kind==symbol_1.SymbolKind.TYPE_MODULE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a namespace"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a namespace"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a namespace"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a namespace");else if(symbol.kind==symbol_1.SymbolKind.TYPE_CLASS||symbol.kind==symbol_1.SymbolKind.TYPE_NATIVE||symbol.kind==symbol_1.SymbolKind.TYPE_GENERIC||symbol.kind==symbol_1.SymbolKind.TYPE_TEMPLATE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a class");else if(symbol.kind==symbol_1.SymbolKind.TYPE_INTERFACE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a interface");else if(symbol.kind==symbol_1.SymbolKind.TYPE_ENUM){forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on an enum"),symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol;var underlyingSymbol=symbol.resolvedType.underlyingType(context).symbol;symbol.byteSize=underlyingSymbol.byteSize,symbol.maxAlignment=underlyingSymbol.maxAlignment}else if(symbol_1.isFunction(symbol.kind)){var body=node.functionBody(),returnType=node.functionReturnType(),oldUnsafeAllowed=context.isUnsafeAllowed;context.isUnsafeAllowed=node.isUnsafe(),resolveAsType(context,returnType,symbol.scope.parent),returnType.resolvedType.isClass()&&returnType.hasParameters()&&node.parent!=returnType.resolvedType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],returnType.resolvedType.symbol.scope);for(var argumentCount=0,child=node.functionFirstArgument();child!=returnType;)assert_1.assert(child.kind==node_1.NodeKind.VARIABLE),assert_1.assert(child.symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT),initializeSymbol(context,child.symbol),child.symbol.offset=argumentCount,argumentCount+=1,child=child.nextSibling;if(symbol.kind!=symbol_1.SymbolKind.FUNCTION_INSTANCE?(forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' here"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' here"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' here"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' here")):node.isGet()?(forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use both 'get' and 'set'"),1!=argumentCount&&context.log.error(symbol.range,"Getters must not have any argumentVariables")):node.isSet()?(symbol.rename="set_"+symbol.name,2!=argumentCount&&context.log.error(symbol.range,"Setters must have exactly one argument")):node.isOperator()&&("~"==symbol.name||"++"==symbol.name||"--"==symbol.name?1!=argumentCount&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must not have any arguments"):"+"==symbol.name||"-"==symbol.name?argumentCount>2&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must have at most one argument"):"[]="==symbol.name?argumentCount<2&&context.log.error(symbol.range,"Operator '[]=' must have at least one argument"):2!=argumentCount&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must have exactly one argument")),symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var parent=symbol.parent(),shouldConvertInstanceToGlobal=!1;if(forbidFlag(context,node,node_1.NODE_FLAG_EXPORT,"Cannot use 'export' on an instance function"),forbidFlag(context,node,node_1.NODE_FLAG_DECLARE,"Cannot use 'declare' on an instance function"),parent.node.isDeclare()?null==body?node.flags=node.flags|node_1.NODE_FLAG_DECLARE:shouldConvertInstanceToGlobal=!0:(null==body&&context.log.error(node.lastChild.range,"Must implement this function"),parent.node.isExport()&&(node.flags=node.flags|node_1.NODE_FLAG_EXPORT)),shouldConvertInstanceToGlobal){symbol.kind=symbol_1.SymbolKind.FUNCTION_GLOBAL,symbol.flags=symbol.flags|symbol_1.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL,symbol.rename=parent.name+"_"+(null!=symbol.rename?symbol.rename:symbol.name);var argument=node.functionFirstArgument();assert_1.assert("this"==argument.symbol.name),argument.symbol.rename="__this"}}else null==body?(forbidFlag(context,node,node_1.NODE_FLAG_EXPORT,"Cannot use 'export' on an unimplemented function"),node.parent&&node.parent.isDeclare()||requireFlag(context,node,node_1.NODE_FLAG_DECLARE,"Declared functions must be prefixed with 'declare'")):forbidFlag(context,node,node_1.NODE_FLAG_DECLARE,"Cannot use 'declare' on a function with an implementation");context.isUnsafeAllowed=oldUnsafeAllowed}else if(symbol_1.isVariable(symbol.kind)){forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a variable"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a variable");var type=node.variableType(),value=node.variableValue(),oldUnsafeAllowed=context.isUnsafeAllowed;if(context.isUnsafeAllowed=context.isUnsafeAllowed||node.isUnsafe(),symbol.kind!=symbol_1.SymbolKind.VARIABLE_INSTANCE&&(forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' here"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' here")),null!=type?(resolveAsType(context,type,symbol.scope),type.resolvedType.isTemplate()&&type.hasParameters()&&node.parent!=type.resolvedType.symbol.node&&deriveConcreteClass(context,type,[type.firstChild.firstChild],type.resolvedType.symbol.scope),symbol.resolvedType=type.resolvedType):null!=value?(resolveAsExpression(context,value,symbol.scope),value.resolvedType.isTemplate()&&value.hasParameters()&&node.parent!=value.resolvedType.symbol.node&&deriveConcreteClass(context,value,[value.firstChild.firstChild],value.resolvedType.symbol.scope),symbol.resolvedType=value.resolvedType):(context.log.error(node.internalRange,"Cannot create untyped variables"),symbol.resolvedType=context.errorType),symbol.resolvedType!=context.voidType&&symbol.resolvedType!=context.nullType||(context.log.error(node.internalRange,"Cannot create a variable with type '"+symbol.resolvedType.toString()+"'"),symbol.resolvedType=context.errorType),symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT)if(null!=value)resolveAsExpression(context,value,symbol.scope),checkConversion(context,value,symbol.resolvedTypeUnderlyingIfEnumValue(context),type_1.ConversionKind.IMPLICIT),value.kind==node_1.NodeKind.INT32||value.kind==node_1.NodeKind.INT64||value.kind==node_1.NodeKind.BOOLEAN?symbol.offset=value.intValue:value.kind==node_1.NodeKind.FLOAT32||value.kind==node_1.NodeKind.FLOAT64?symbol.offset=value.floatValue:value.resolvedType!=context.errorType&&(context.log.error(value.range,"Invalid constant initializer"),symbol.resolvedType=context.errorType);else if(symbol.isEnumValue())if(null!=node.previousSibling){var previousSymbol=node.previousSibling.symbol;initializeSymbol(context,previousSymbol),symbol.offset=previousSymbol.offset+1}else symbol.offset=0;else context.log.error(node.internalRange,"Constants must be initialized");if(null==symbol.scope.symbol)for(var scope=symbol.scope.parent;null!=scope;){var shadowed=scope.findLocal(symbol.name,scope_1.ScopeHint.NORMAL);if(null!=shadowed){context.log.error(node.internalRange,"The symbol '"+symbol.name+"' shadows another symbol with the same name in a parent scope");break}if(null!=scope.symbol)break;scope=scope.parent}context.isUnsafeAllowed=oldUnsafeAllowed}else assert_1.assert(!1);assert_1.assert(null!=symbol.resolvedType),symbol.state=symbol_1.SymbolState.INITIALIZED}function deriveConcreteClass(context,type,parameters,scope){var templateNode=type.resolvedType.pointerTo?type.resolvedType.pointerTo.symbol.node:type.resolvedType.symbol.node,templateName=templateNode.stringValue,typeName=templateNode.stringValue+"<"+parameters[0].stringValue+">",rename=templateNode.stringValue+"_"+parameters[0].stringValue,symbol=scope.parent.findNested(typeName,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);if(symbol){var genericSymbol=scope.parent.findNested(type.firstChild.firstChild.stringValue,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);return type.firstChild.firstChild.symbol=genericSymbol,genericSymbol.resolvedType.pointerTo?type.firstChild.firstChild.resolvedType=genericSymbol.resolvedType.pointerType():type.firstChild.firstChild.resolvedType=genericSymbol.resolvedType,type.symbol=symbol,void(type.resolvedType.pointerTo?type.resolvedType=symbol.resolvedType.pointerType():type.resolvedType=symbol.resolvedType)}var node=templateNode.clone();if(node.stringValue=typeName,cloneChildren(templateNode.firstChild.nextSibling,node,parameters,templateName,typeName),node.offset=null,initialize(context,node,scope.parent,CheckMode.NORMAL),resolve(context,node,scope.parent),node.symbol.flags|=symbol_1.SYMBOL_FLAG_USED,type.symbol=node.symbol,node.symbol.rename=rename,type.resolvedType.pointerTo?type.resolvedType=node.symbol.resolvedType.pointerType():type.resolvedType=node.symbol.resolvedType,templateNode.parent)templateNode.replaceWith(node);else{var prevNode=templateNode.derivedNodes[templateNode.derivedNodes.length-1];prevNode.parent.insertChildAfter(prevNode,node)}void 0===templateNode.derivedNodes&&(templateNode.derivedNodes=[]),templateNode.derivedNodes.push(node),type.firstChild.firstChild.kind=node_1.NodeKind.NAME,resolve(context,type.firstChild.firstChild,scope.parent),type.stringValue=node.symbol.name}function cloneChildren(child,parentNode,parameters,templateName,typeName){for(var firstChildNode=null,lastChildNode=null;child;)if("this"==child.stringValue&&child.parent.symbol&&child.parent.symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE&&child.kind==node_1.NodeKind.TYPE)child=child.nextSibling;else{var childNode=void 0;if(child.kind!=node_1.NodeKind.PARAMETERS&&child.kind!=node_1.NodeKind.PARAMETER){if(child.isGeneric()){var offset=child.offset;child.resolvedType&&(offset=child.resolvedType.pointerTo?child.resolvedType.pointerTo.symbol.node.offset:child.resolvedType.symbol.node.offset),childNode=child.symbol&&symbol_1.isVariable(child.symbol.kind)?child.clone():parameters[offset].clone(),childNode.kind=node_1.NodeKind.NAME}else"T"==child.stringValue&&(terminal_1.Terminal.write("Generic type escaped!"),terminal_1.Terminal.write(child)),childNode=child.clone(),childNode.stringValue==templateName&&(childNode.stringValue=typeName);childNode.parent=parentNode,"constructor"==childNode.stringValue&&childNode.parent.kind==node_1.NodeKind.CLASS&&(childNode.parent.constructorFunctionNode=childNode),firstChildNode||(firstChildNode=childNode),lastChildNode&&(lastChildNode.nextSibling=childNode,childNode.previousSibling=lastChildNode),child.firstChild&&cloneChildren(child.firstChild,childNode,parameters,templateName,typeName),lastChildNode=childNode,child=child.nextSibling}else child=child.nextSibling}null!=firstChildNode&&(parentNode.firstChild=firstChildNode),null!=lastChildNode&&(parentNode.lastChild=lastChildNode)}function resolveChildren(context,node,parentScope){for(var child=node.firstChild;null!=child;)resolve(context,child,parentScope),assert_1.assert(null!=child.resolvedType),child=child.nextSibling}function resolveChildrenAsExpressions(context,node,parentScope){for(var child=node.firstChild;null!=child;)resolveAsExpression(context,child,parentScope),child=child.nextSibling}function resolveAsExpression(context,node,parentScope){assert_1.assert(node_1.isExpression(node)),resolve(context,node,parentScope),assert_1.assert(null!=node.resolvedType),node.resolvedType!=context.errorType&&(node.isType()?(context.log.error(node.range,"Expected expression but found type"),node.resolvedType=context.errorType):node.resolvedType==context.voidType&&node.parent.kind!=node_1.NodeKind.EXPRESSION&&(context.log.error(node.range,"This expression does not return a value"),node.resolvedType=context.errorType))}function resolveAsType(context,node,parentScope){assert_1.assert(node_1.isExpression(node)),resolve(context,node,parentScope),assert_1.assert(null!=node.resolvedType),node.resolvedType==context.errorType||node.isType()||(context.log.error(node.range,"Expected type but found expression"),node.resolvedType=context.errorType)}function canConvert(context,node,to,kind){var from=node.resolvedType;if(assert_1.assert(node_1.isExpression(node)),assert_1.assert(null!=from),assert_1.assert(null!=to),from.isGeneric()||to.isGeneric())return!0;if(from==to||from==context.errorType||to==context.errorType)return!0;if(from==context.nullType)return!0;if(from.isReference()||to.isReference()){if(kind==type_1.ConversionKind.EXPLICIT)return!0}else{if(from==context.booleanType)return!0;if(from.isInteger()&&to.isInteger()){to.integerBitMask(context);return!(!from.isUnsigned()||!to.isUnsigned())||(!(!from.isEnum()||to!=from.underlyingType(context))||(!node.intValue||(kind==type_1.ConversionKind.EXPLICIT||from.symbol.byteSize=0&&node.intValue<=const_1.MAX_UINT32_VALUE:node.intValue>=const_1.MIN_INT32_VALUE&&node.intValue<=const_1.MAX_INT32_VALUE))))}if(from.isInteger()&&to.isFloat()||from.isInteger()&&to.isDouble()||from.isLong()&&to.isInteger()||from.isLong()&&to.isFloat()||from.isLong()&&to.isDouble()||from.isFloat()&&to.isInteger()||from.isFloat()&&to.isLong()||from.isDouble()&&to.isInteger()||from.isDouble()&&to.isLong()||from.isDouble()&&to.isFloat())return kind!=type_1.ConversionKind.IMPLICIT;if(from.isInteger()&&to.isLong()||from.isFloat()&&to.isDouble()||from.isFloat()&&to.isFloat()||from.isDouble()&&to.isDouble())return!0}return!1}function checkConversion(context,node,to,kind){canConvert(context,node,to,kind)||(context.log.error(node.range,"Cannot convert from type '"+node.resolvedType.toString()+"' to type '"+to.toString()+"' "+(kind==type_1.ConversionKind.IMPLICIT&&canConvert(context,node,to,type_1.ConversionKind.EXPLICIT)?"without a cast":"")),node.resolvedType=context.errorType)}function checkStorage(context,target){assert_1.assert(node_1.isExpression(target)),target.resolvedType==context.errorType||target.kind==node_1.NodeKind.INDEX||target.kind==node_1.NodeKind.POINTER_INDEX||target.kind==node_1.NodeKind.DEREFERENCE||(target.kind==node_1.NodeKind.NAME||target.kind==node_1.NodeKind.DOT)&&(null==target.symbol||symbol_1.isVariable(target.symbol.kind)&&target.symbol.kind!=symbol_1.SymbolKind.VARIABLE_CONSTANT)||(context.log.error(target.range,"Cannot store to this location"),target.resolvedType=context.errorType)}function createDefaultValueForType(context,type){return type.isLong()?node_1.createLong(0):type.isInteger()?node_1.createInt(0):type.isDouble()?node_1.createDouble(0):type.isFloat()?node_1.createFloat(0):type==context.booleanType?node_1.createboolean(!1):type.isClass()?node_1.createNull():type.isGeneric()?node_1.createNull():(assert_1.assert(type.isReference()),node_1.createNull())}function simplifyBinary(node){var left=node.binaryLeft(),right=node.binaryRight();if(node.kind!=node_1.NodeKind.ADD&&node.kind!=node_1.NodeKind.MULTIPLY&&node.kind!=node_1.NodeKind.BITWISE_AND&&node.kind!=node_1.NodeKind.BITWISE_OR&&node.kind!=node_1.NodeKind.BITWISE_XOR||left.kind!=node_1.NodeKind.INT32||right.kind==node_1.NodeKind.INT32||(node.appendChild(left.remove()),left=node.binaryLeft(),right=node.binaryRight()),(node.kind==node_1.NodeKind.MULTIPLY||(node.kind==node_1.NodeKind.DIVIDE||node.kind==node_1.NodeKind.REMAINDER)&&node.resolvedType.isUnsigned())&&right.kind==node_1.NodeKind.INT32&&utils_1.isPositivePowerOf2(right.intValue)){for(var shift=-1,value=right.intValue;0!=value;)value>>=1,shift+=1;node.kind==node_1.NodeKind.MULTIPLY?(node.kind=node_1.NodeKind.SHIFT_LEFT,right.intValue=shift):node.kind==node_1.NodeKind.DIVIDE?(node.kind=node_1.NodeKind.SHIFT_RIGHT,right.intValue=shift):node.kind==node_1.NodeKind.REMAINDER?(node.kind=node_1.NodeKind.BITWISE_AND,right.intValue=right.intValue-1):assert_1.assert(!1)}else node.kind==node_1.NodeKind.ADD&&right.kind==node_1.NodeKind.NEGATIVE?(node.kind=node_1.NodeKind.SUBTRACT,right.replaceWith(right.unaryValue().remove())):node.kind==node_1.NodeKind.ADD&&right.isNegativeInteger()&&(node.kind=node_1.NodeKind.SUBTRACT,right.intValue=-right.intValue)}function binaryHasUnsignedArguments(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isUnsigned()&&rightType.isUnsigned()||leftType.isUnsigned()&&right.isNonNegativeInteger()||left.isNonNegativeInteger()&&rightType.isUnsigned()}function isBinaryLong(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isLong()||rightType.isLong()}function isBinaryDouble(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isDouble()||rightType.isDouble()}function isSymbolAccessAllowed(context,symbol,node,range){if(symbol.isUnsafe()&&!context.isUnsafeAllowed)return context.log.error(range,"Cannot use symbol '"+symbol.name+"' outside an 'unsafe' block"),!1;if(null!=symbol.node&&symbol.node.isPrivate()){var parent=symbol.parent();if(null!=parent&&context.enclosingClass!=parent)return context.log.error(range,"Cannot access private symbol '"+symbol.name+"' here"),!1}return!(symbol_1.isFunction(symbol.kind)&&(symbol.isSetter()?!node.isAssignTarget():!node.isCallValue()))||(symbol.isSetter()?context.log.error(range,"Cannot use setter '"+symbol.name+"' here"):context.log.error(range,"Must call function '"+symbol.name+"'"),!1)}function resolve(context,node,parentScope){var kind=node.kind;if(assert_1.assert(kind==node_1.NodeKind.FILE||null!=parentScope),null==node.resolvedType)if(node.resolvedType=context.errorType,kind==node_1.NodeKind.FILE||kind==node_1.NodeKind.GLOBAL)resolveChildren(context,node,parentScope);else if(kind==node_1.NodeKind.MODULE){var oldEnclosingModule=context.enclosingModule;initializeSymbol(context,node.symbol),context.enclosingModule=node.symbol,resolveChildren(context,node,node.scope),context.enclosingModule=oldEnclosingModule}else if(kind==node_1.NodeKind.IMPORT||kind==node_1.NodeKind.IMPORT_FROM);else if(kind==node_1.NodeKind.CLASS){var oldEnclosingClass=context.enclosingClass;initializeSymbol(context,node.symbol),context.enclosingClass=node.symbol,resolveChildren(context,node,node.scope),node.symbol.kind==symbol_1.SymbolKind.TYPE_CLASS&&node.symbol.determineClassLayout(context),context.enclosingClass=oldEnclosingClass}else if(kind==node_1.NodeKind.ENUM)initializeSymbol(context,node.symbol),resolveChildren(context,node,node.scope);else if(kind==node_1.NodeKind.FUNCTION){var body=node.functionBody();if(initializeSymbol(context,node.symbol),"constructor"==node.stringValue&&node.parent.kind==node_1.NodeKind.CLASS&&(node.parent.constructorFunctionNode=node),null!=body){var oldReturnType=context.currentReturnType,oldUnsafeAllowed=context.isUnsafeAllowed,returnType=node.functionReturnType();returnType.resolvedType.isTemplate()&&returnType.hasParameters()&&node.parent!=returnType.resolvedType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],returnType.resolvedType.symbol.scope),context.currentReturnType=returnType.resolvedType,context.isUnsafeAllowed=node.isUnsafe(),resolveChildren(context,body,node.scope),oldReturnType&&oldReturnType.isTemplate()&&returnType.hasParameters()&&node.parent!=oldReturnType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],oldReturnType.symbol.scope),context.currentReturnType=oldReturnType,context.isUnsafeAllowed=oldUnsafeAllowed}}else if(kind==node_1.NodeKind.PARAMETER)var symbol=node.symbol;else if(kind==node_1.NodeKind.VARIABLE){var symbol=node.symbol;initializeSymbol(context,symbol);var oldUnsafeAllowed=context.isUnsafeAllowed;context.isUnsafeAllowed=context.isUnsafeAllowed||node.isUnsafe();var value=node.variableValue();null!=value?(resolveAsExpression(context,value,parentScope),checkConversion(context,value,symbol.resolvedTypeUnderlyingIfEnumValue(context),type_1.ConversionKind.IMPLICIT),symbol.resolvedType!=value.resolvedType&&value.becomeValueTypeOf(symbol,context),symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL&&value.kind!=node_1.NodeKind.INT32&&value.kind!=node_1.NodeKind.BOOLEAN&&(value.kind,node_1.NodeKind.NULL)):symbol.resolvedType!=context.errorType&&(value=createDefaultValueForType(context,symbol.resolvedType),resolveAsExpression(context,value,parentScope),node.appendChild(value)),symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL&&symbol.resolvedType!=context.errorType&&(symbol.offset=context.allocateGlobalVariableOffset(symbol.resolvedType.variableSizeOf(context),symbol.resolvedType.variableAlignmentOf(context))),context.isUnsafeAllowed=oldUnsafeAllowed}else if(kind==node_1.NodeKind.BREAK||kind==node_1.NodeKind.CONTINUE){for(var found=!1,n=node;null!=n;){if(n.kind==node_1.NodeKind.WHILE){found=!0;break}n=n.parent}found||context.log.error(node.range,"Cannot use this statement outside of a loop")}else if(kind==node_1.NodeKind.BLOCK){var oldUnsafeAllowed=context.isUnsafeAllowed;node.isUnsafe()&&(context.isUnsafeAllowed=!0),resolveChildren(context,node,node.scope),context.isUnsafeAllowed=oldUnsafeAllowed}else if(kind==node_1.NodeKind.IMPORTS||kind==node_1.NodeKind.CONSTANTS||kind==node_1.NodeKind.VARIABLES)resolveChildren(context,node,parentScope);else if(kind==node_1.NodeKind.ANY)node.kind=node_1.NodeKind.TYPE,node.resolvedType=context.anyType;else if(kind==node_1.NodeKind.INT32)node.resolvedType=node.intValue<0&&!node.isPositive()?context.uint32Type:context.int32Type;else if(kind==node_1.NodeKind.INT64)node.resolvedType=node.intValue<0&&!node.isPositive()?context.uint64Type:context.int64Type;else if(kind==node_1.NodeKind.FLOAT32)node.resolvedType=context.float32Type;else if(kind==node_1.NodeKind.FLOAT64)node.resolvedType=context.float64Type;else if(kind==node_1.NodeKind.STRING)node.resolvedType=context.stringType;else if(kind==node_1.NodeKind.BOOLEAN)node.resolvedType=context.booleanType;else if(kind==node_1.NodeKind.NULL)node.resolvedType=context.nullType;else if(kind==node_1.NodeKind.INDEX){resolveChildrenAsExpressions(context,node,parentScope);var target=node.indexTarget(),type=target.resolvedType;if(type!=context.errorType){var symbol=type.hasInstanceMembers()?type.findMember("[]",scope_1.ScopeHint.NORMAL):null;null==symbol?void 0!==target.resolvedType.pointerTo?(node.kind=node_1.NodeKind.POINTER_INDEX,node.resolvedType=target.resolvedType.pointerTo.symbol.resolvedType):context.log.error(node.internalRange,"Cannot index into type '"+target.resolvedType.toString()+"'"):(assert_1.assert(symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE||symbol.kind==symbol_1.SymbolKind.FUNCTION_GLOBAL&&symbol.shouldConvertInstanceToGlobal()),node.kind=node_1.NodeKind.CALL,target.remove(),node.insertChildBefore(node.firstChild,node_1.createMemberReference(target,symbol)),node.resolvedType=null,resolveAsExpression(context,node,parentScope))}}else if(kind==node_1.NodeKind.ALIGN_OF){var type=node.alignOfType();resolveAsType(context,type,parentScope),node.resolvedType=context.int32Type,type.resolvedType!=context.errorType&&node.becomeIntegerConstant(type.resolvedType.allocationAlignmentOf(context))}else if(kind==node_1.NodeKind.SIZE_OF){var type=node.sizeOfType();resolveAsType(context,type,parentScope),node.resolvedType=context.int32Type,type.resolvedType!=context.errorType&&node.becomeIntegerConstant(type.resolvedType.allocationSizeOf(context))}else if(kind==node_1.NodeKind.THIS){var symbol=parentScope.findNested("this",scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);null==symbol?context.log.error(node.range,"Cannot use 'this' here"):node.becomeSymbolReference(symbol)}else if(kind==node_1.NodeKind.PARSE_ERROR)node.resolvedType=context.errorType;else if(kind==node_1.NodeKind.NAME){var name=node.stringValue,symbol=parentScope.findNested(name,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);if(null==symbol){var errorMessage="No symbol named '"+name+"' here";symbol=parentScope.findNested(name,scope_1.ScopeHint.NORMAL,scope_1.FindNested.ALLOW_INSTANCE_ERRORS),null!=symbol?errorMessage+=", did you mean 'this."+symbol.name+"'?":"number"==name?errorMessage+=", you cannot use generic number type from TypeScript!":"bool"==name&&(errorMessage+=", did you mean 'boolean'?"),context.log.error(node.range,errorMessage)}else symbol.state==symbol_1.SymbolState.INITIALIZING?context.log.error(node.range,"Cyclic reference to symbol '"+name+"' here"):isSymbolAccessAllowed(context,symbol,node,node.range)&&(initializeSymbol(context,symbol),node.symbol=symbol,node.resolvedType=symbol.resolvedType,node.resolvedType.isGeneric()&&(node.flags|=node_1.NODE_FLAG_GENERIC),symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT&&(symbol.resolvedType==context.booleanType?node.becomeBooleanConstant(0!=symbol.offset):symbol.resolvedType==context.float32Type?node.becomeFloatConstant(symbol.offset):symbol.resolvedType==context.float64Type?node.becomeDoubleConstant(symbol.offset):symbol.resolvedType==context.int64Type?node.becomeLongConstant(symbol.offset):node.becomeIntegerConstant(symbol.offset)))}else if(kind==node_1.NodeKind.CAST){var value=node.castValue(),type=node.castType();resolveAsExpression(context,value,parentScope),resolveAsType(context,type,parentScope);var castedType=type.resolvedType;if(checkConversion(context,value,castedType,type_1.ConversionKind.EXPLICIT),node.resolvedType=castedType,value.kind==node_1.NodeKind.INT32&&castedType.isInteger()){var result=value.intValue,shift=32-castedType.integerBitCount(context);node.becomeIntegerConstant(castedType.isUnsigned()?castedType.integerBitMask(context)&result:result<>shift)}else value.kind==node_1.NodeKind.INT32&&castedType.isFloat()?node.becomeFloatConstant(value.intValue):value.kind==node_1.NodeKind.INT32&&castedType.isDouble()?node.becomeDoubleConstant(value.intValue):value.kind==node_1.NodeKind.FLOAT32&&castedType.isInteger()&&node.becomeIntegerConstant(Math.round(value.floatValue))}else if(kind==node_1.NodeKind.DOT){var target=node.dotTarget();if(resolve(context,target,parentScope),target.resolvedType!=context.errorType)if(target.isType()&&(target.resolvedType.isEnum()||target.resolvedType.hasInstanceMembers())||!target.isType()&&target.resolvedType.hasInstanceMembers()){var name=node.stringValue;if(name.length>0){var symbol=target.resolvedType.findMember(name,node.isAssignTarget()?scope_1.ScopeHint.PREFER_SETTER:scope_1.ScopeHint.PREFER_GETTER);if(null==symbol)context.log.error(node.internalRange,"No member named '"+name+"' on type '"+target.resolvedType.toString()+"'");else{if(symbol.isGetter())return void(node.parent.stringValue===node.stringValue&&node.parent.kind===node_1.NodeKind.CALL?(node.parent.resolvedType=null,node.symbol=symbol,node.resolvedType=symbol.resolvedType,resolveAsExpression(context,node.parent,parentScope)):(node.kind=node_1.NodeKind.CALL,node.appendChild(node_1.createMemberReference(target.remove(),symbol)),node.resolvedType=null,resolveAsExpression(context,node,parentScope)));isSymbolAccessAllowed(context,symbol,node,node.internalRange)&&(initializeSymbol(context,symbol),node.symbol=symbol,node.resolvedType=symbol.resolvedType,symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT&&node.becomeIntegerConstant(symbol.offset))}}}else context.log.error(node.internalRange,"The type '"+target.resolvedType.toString()+"' has no members")}else if(kind==node_1.NodeKind.CALL){var value=node.callValue();if(resolveAsExpression(context,value,parentScope),value.resolvedType!=context.errorType){var symbol=value.symbol;if(null!=symbol&&symbol_1.isFunction(symbol.kind)){if(initializeSymbol(context,symbol),symbol.shouldConvertInstanceToGlobal()){var name=node_1.createSymbolReference(symbol);node.insertChildBefore(value,name.withRange(value.internalRange)),node.insertChildBefore(value,value.dotTarget().remove()),value.remove(),value=name}for(var returnType=symbol.node.functionReturnType(),argumentVariable=symbol.node.functionFirstArgumentIgnoringThis(),argumentValue=value.nextSibling;argumentVariable!=returnType&&null!=argumentValue;)resolveAsExpression(context,argumentValue,parentScope),checkConversion(context,argumentValue,argumentVariable.symbol.resolvedType,type_1.ConversionKind.IMPLICIT),argumentVariable=argumentVariable.nextSibling,argumentValue=argumentValue.nextSibling;if(returnType.resolvedType!=context.anyType)if(argumentVariable==returnType||argumentVariable.hasVariableValue()){if(null!=argumentValue){for(;null!=argumentValue;)resolveAsExpression(context,argumentValue,parentScope),argumentValue=argumentValue.nextSibling;context.log.error(node.internalRange,"Too many arguments for function '"+symbol.name+"'")}}else context.log.error(node.internalRange,"Not enough arguments for function '"+symbol.name+"'");returnType.resolvedType.isArray()&&terminal_1.Terminal.write(returnType),node.resolvedType=returnType.resolvedType}else context.log.error(value.range,"Cannot call value of type '"+value.resolvedType.toString()+"'")}}else if(kind==node_1.NodeKind.DELETE){var value=node.deleteType();null!=value?(resolveAsExpression(context,value,parentScope),null!=value.resolvedType&&value.resolvedType!=context.voidType||context.log.error(value.range,"Unexpected delete value 'void'")):context.log.error(node.range,"Expected delete value '"+context.currentReturnType.toString()+"'")}else if(kind==node_1.NodeKind.RETURN){var value=node.returnValue();null!=value?(resolveAsExpression(context,value,parentScope),null!=context.currentReturnType&&(context.currentReturnType!=context.voidType?(value.resolvedType.isTemplate()&&value.hasParameters()&&node.parent!=value.resolvedType.symbol.node&&deriveConcreteClass(context,value,[value.firstChild.firstChild],value.resolvedType.symbol.scope),checkConversion(context,value,context.currentReturnType,type_1.ConversionKind.IMPLICIT)):context.log.error(value.range,"Unexpected return value in function returning 'void'")),node.parent.returnNode=node):null!=context.currentReturnType&&context.currentReturnType!=context.voidType&&context.log.error(node.range,"Expected return value in function returning '"+context.currentReturnType.toString()+"'")}else if(kind==node_1.NodeKind.EMPTY);else if(kind==node_1.NodeKind.PARAMETERS);else if(kind==node_1.NodeKind.EXTENDS)resolveAsType(context,node.extendsType(),parentScope);else if(kind==node_1.NodeKind.IMPLEMENTS){for(var child=node.firstChild;null!=child;)resolveAsType(context,child,parentScope),child=child.nextSibling;context.log.error(node.range,"Interfaces are not implemented yet")}else if(kind==node_1.NodeKind.EXPRESSION)resolveAsExpression(context,node.expressionValue(),parentScope);else if(kind==node_1.NodeKind.WHILE){var value=node.whileValue(),body=node.whileBody();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,body,parentScope)}else if(kind==node_1.NodeKind.IF){var value=node.ifValue(),yes=node.ifTrue(),no=node.ifFalse();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,yes,parentScope),null!=no&&resolve(context,no,parentScope)}else if(kind==node_1.NodeKind.HOOK){var value=node.hookValue(),yes=node.hookTrue(),no=node.hookFalse();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,yes,parentScope),resolve(context,no,parentScope),checkConversion(context,yes,no.resolvedType,type_1.ConversionKind.IMPLICIT);var commonType=(yes.resolvedType==context.nullType?no:yes).resolvedType;yes.resolvedType==commonType||yes.resolvedType==context.nullType&&commonType.isReference()||no.resolvedType==commonType||no.resolvedType==context.nullType&&commonType.isReference()||context.log.error(log_1.spanRanges(yes.range,no.range),"Type '"+yes.resolvedType.toString()+"' is not the same as type '"+no.resolvedType.toString()+"'"),node.resolvedType=commonType}else if(kind==node_1.NodeKind.ASSIGN){var left=node.binaryLeft(),right=node.binaryRight();if(left.kind==node_1.NodeKind.INDEX){resolveChildrenAsExpressions(context,left,parentScope);var target=left.indexTarget(),type=target.resolvedType;if(type!=context.errorType){var symbol=type.hasInstanceMembers()?type.findMember("[]=",scope_1.ScopeHint.NORMAL):null;if(null!=symbol){for(assert_1.assert(symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE),node.kind=node_1.NodeKind.CALL,target.remove(),left.remove();null!=left.lastChild;)node.insertChildBefore(node.firstChild,left.lastChild.remove());return node.insertChildBefore(node.firstChild,node_1.createMemberReference(target,symbol)),node.internalRange=log_1.spanRanges(left.internalRange,right.range),node.resolvedType=null,void resolveAsExpression(context,node,parentScope)}void 0!=target.resolvedType.pointerTo?(left.kind=node_1.NodeKind.POINTER_INDEX,left.resolvedType=target.resolvedType.pointerTo.symbol.resolvedType):context.log.error(left.internalRange,"Cannot index into type '"+target.resolvedType.toString()+"'")}}if(left.resolvedType||resolveAsExpression(context,left,parentScope),null!=left.symbol&&left.symbol.isSetter())return node.kind=node_1.NodeKind.CALL,node.internalRange=left.internalRange,node.resolvedType=null,void resolveAsExpression(context,node,parentScope);resolveAsExpression(context,right,parentScope),checkConversion(context,right,left.resolvedType,type_1.ConversionKind.IMPLICIT),checkStorage(context,left),node.resolvedType=left.resolvedType}else if(kind==node_1.NodeKind.NEW){compiler_1.Compiler.mallocRequired=!0;var type=node.newType();resolveAsType(context,type,parentScope),type.resolvedType.isTemplate()&&type.hasParameters()&&node.parent!=type.resolvedType.symbol.node&&deriveConcreteClass(context,type,[type.firstChild.firstChild],type.resolvedType.symbol.scope),type.resolvedType!=context.errorType&&(type.resolvedType.isClass()?node.resolvedType=type.resolvedType:context.log.error(type.range,"Cannot construct type '"+type.resolvedType.toString()+"'"));for(var child=type.nextSibling,constructorNode=node.constructorNode(),argumentVariable=constructorNode.functionFirstArgument();null!=child;)resolveAsExpression(context,child,parentScope),checkConversion(context,child,argumentVariable.symbol.resolvedType,type_1.ConversionKind.IMPLICIT),child=child.nextSibling,argumentVariable=argumentVariable.nextSibling}else if(kind==node_1.NodeKind.POINTER_TYPE){var value=node.unaryValue();if(resolveAsType(context,value,parentScope),context.target==compile_target_1.CompileTarget.JAVASCRIPT)context.log.error(node.internalRange,"Cannot use pointers when compiling to JavaScript");else{var type=value.resolvedType;type!=context.errorType&&(node.resolvedType=type.pointerType())}}else if(kind==node_1.NodeKind.POINTER_INDEX);else if(kind==node_1.NodeKind.DEREFERENCE){var value=node.unaryValue();resolveAsExpression(context,value,parentScope);var type=value.resolvedType;type!=context.errorType&&(null==type.pointerTo?context.log.error(node.internalRange,"Cannot dereference type '"+type.toString()+"'"):node.resolvedType=type.pointerTo)}else if(kind==node_1.NodeKind.ADDRESS_OF){var value=node.unaryValue();resolveAsExpression(context,value,parentScope),context.log.error(node.internalRange,"The address-of operator is not supported")}else if(node_1.isUnary(kind)){var value=node.unaryValue();if(resolveAsExpression(context,value,parentScope),kind==node_1.NodeKind.NOT)checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),node.resolvedType=context.booleanType;else if(value.resolvedType.isLong()){if(value.resolvedType.isUnsigned()?(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR,node.resolvedType=context.uint64Type):node.resolvedType=context.int64Type,value.kind==node_1.NodeKind.INT64){var input=value.longValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeLongConstant(output)}}else if(value.resolvedType.isInteger()){if(value.resolvedType.isUnsigned()?(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR,node.resolvedType=context.uint32Type):node.resolvedType=context.int32Type,value.kind==node_1.NodeKind.INT32){var input=value.intValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeIntegerConstant(output)}}else if(value.resolvedType.isDouble()){if(node.resolvedType=context.float64Type,value.kind==node_1.NodeKind.FLOAT64){var input=value.doubleValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeDoubleConstant(output)}}else if(value.resolvedType.isFloat()){if(node.resolvedType=context.float32Type,value.kind==node_1.NodeKind.FLOAT32){var input=value.floatValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeFloatConstant(output)}}else if(value.resolvedType!=context.errorType){var name=node.internalRange.toString(),symbol=value.resolvedType.findMember(name,scope_1.ScopeHint.NOT_BINARY);null!=symbol?(node.appendChild(node_1.createMemberReference(value.remove(),symbol).withRange(node.range).withInternalRange(node.internalRange)),node.kind=node_1.NodeKind.CALL,node.resolvedType=null,resolveAsExpression(context,node,parentScope)):context.log.error(node.internalRange,"Cannot use unary operator '"+name+"' with type '"+value.resolvedType.toString()+"'")}}else if(node_1.isBinary(kind)){var left=node.binaryLeft(),right=node.binaryRight();resolveAsExpression(context,left,parentScope),resolveAsExpression(context,right,parentScope);var leftType=left.resolvedType;(leftType.isDouble()&&right.resolvedType.isFloat()||leftType.isLong()&&right.resolvedType.isInteger())&&right.becomeTypeOf(left,context);var rightType=right.resolvedType;if(kind==node_1.NodeKind.LOGICAL_OR||kind==node_1.NodeKind.LOGICAL_AND)checkConversion(context,left,context.booleanType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,context.booleanType,type_1.ConversionKind.IMPLICIT),node.resolvedType=context.booleanType;else if(kind==node_1.NodeKind.ADD&&null!=leftType.pointerTo&&rightType.isInteger())node.resolvedType=leftType;else if(kind!=node_1.NodeKind.LESS_THAN&&kind!=node_1.NodeKind.LESS_THAN_EQUAL&&kind!=node_1.NodeKind.GREATER_THAN&&kind!=node_1.NodeKind.GREATER_THAN_EQUAL||null==leftType.pointerTo&&null==rightType.pointerTo){if((leftType.isInteger()||leftType.isLong()||leftType.isFloat()||leftType.isDouble()||leftType.isGeneric()&&rightType.isGeneric())&&kind!=node_1.NodeKind.EQUAL&&kind!=node_1.NodeKind.NOT_EQUAL){var isFloat=!1,isFloat64=!1;(leftType.isFloat()||leftType.isDouble())&&(isFloat=!0,isFloat64=leftType.isDouble());var isUnsigned=binaryHasUnsignedArguments(node);if(kind==node_1.NodeKind.ADD||kind==node_1.NodeKind.SUBTRACT||kind==node_1.NodeKind.MULTIPLY||kind==node_1.NodeKind.DIVIDE||kind==node_1.NodeKind.REMAINDER||kind==node_1.NodeKind.BITWISE_AND||kind==node_1.NodeKind.BITWISE_OR||kind==node_1.NodeKind.BITWISE_XOR||kind==node_1.NodeKind.SHIFT_LEFT||kind==node_1.NodeKind.SHIFT_RIGHT){var isLong=isBinaryLong(node),commonType=void 0;if(commonType=isFloat?isBinaryDouble(node)?context.float64Type:context.float32Type:isUnsigned?isLong?context.uint64Type:context.uint32Type:isLong?context.int64Type:context.int32Type,isUnsigned&&(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR),checkConversion(context,left,commonType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,commonType,type_1.ConversionKind.IMPLICIT),node.resolvedType=commonType,commonType==context.int64Type&&(left.kind==node_1.NodeKind.INT32?(left.kind=node_1.NodeKind.INT64,left.resolvedType=context.int64Type):right.kind==node_1.NodeKind.INT32&&(right.kind=node_1.NodeKind.INT64,right.resolvedType=context.int64Type)),left.kind!=node_1.NodeKind.INT32&&left.kind!=node_1.NodeKind.INT64||right.kind!=node_1.NodeKind.INT32&&right.kind!=node_1.NodeKind.INT64)if(left.kind!=node_1.NodeKind.FLOAT32&&left.kind!=node_1.NodeKind.FLOAT64||right.kind!=node_1.NodeKind.FLOAT32&&right.kind!=node_1.NodeKind.FLOAT64)simplifyBinary(node);else{var inputLeft=left.floatValue,inputRight=right.floatValue,output=0;if(kind==node_1.NodeKind.ADD)output=inputLeft+inputRight;else if(kind==node_1.NodeKind.BITWISE_AND)output=inputLeft&inputRight;else if(kind==node_1.NodeKind.BITWISE_OR)output=inputLeft|inputRight;else if(kind==node_1.NodeKind.BITWISE_XOR)output=inputLeft^inputRight;else if(kind==node_1.NodeKind.DIVIDE)output=inputLeft/inputRight;else if(kind==node_1.NodeKind.MULTIPLY)output=inputLeft*inputRight;else if(kind==node_1.NodeKind.REMAINDER)output=inputLeft%inputRight;else if(kind==node_1.NodeKind.SHIFT_LEFT)output=inputLeft<>inputRight;else{if(kind!=node_1.NodeKind.SUBTRACT)return;output=inputLeft-inputRight}left.kind==node_1.NodeKind.FLOAT32?node.becomeFloatConstant(output):node.becomeDoubleConstant(output)}else{var inputLeft=left.intValue,inputRight=right.intValue,output=0;if(kind==node_1.NodeKind.ADD)output=inputLeft+inputRight;else if(kind==node_1.NodeKind.BITWISE_AND)output=inputLeft&inputRight;else if(kind==node_1.NodeKind.BITWISE_OR)output=inputLeft|inputRight;else if(kind==node_1.NodeKind.BITWISE_XOR)output=inputLeft^inputRight;else if(kind==node_1.NodeKind.DIVIDE)output=inputLeft/inputRight;else if(kind==node_1.NodeKind.MULTIPLY)output=inputLeft*inputRight;else if(kind==node_1.NodeKind.REMAINDER)output=inputLeft%inputRight;else if(kind==node_1.NodeKind.SHIFT_LEFT)output=inputLeft<>inputRight;else{if(kind!=node_1.NodeKind.SUBTRACT)return;output=inputLeft-inputRight}left.kind==node_1.NodeKind.INT32?node.becomeIntegerConstant(output):node.becomeLongConstant(output)}}else if(kind==node_1.NodeKind.LESS_THAN||kind==node_1.NodeKind.LESS_THAN_EQUAL||kind==node_1.NodeKind.GREATER_THAN||kind==node_1.NodeKind.GREATER_THAN_EQUAL){var expectedType=isFloat?isFloat64?context.float64Type:context.float32Type:isUnsigned?context.uint32Type:context.int32Type;isUnsigned&&(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR),leftType!=rightType&&(checkConversion(context,left,expectedType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,expectedType,type_1.ConversionKind.IMPLICIT)),node.resolvedType=context.booleanType}else context.log.error(node.internalRange,"This operator is not currently supported")}else if(leftType!=context.errorType){var name=node.internalRange.toString(),symbol=leftType.findMember(kind==node_1.NodeKind.NOT_EQUAL?"==":kind==node_1.NodeKind.LESS_THAN_EQUAL?">":kind==node_1.NodeKind.GREATER_THAN_EQUAL?"<":name,scope_1.ScopeHint.NOT_UNARY);if(null!=symbol){if(left=node_1.createMemberReference(left.remove(),symbol).withRange(node.range).withInternalRange(node.internalRange),right.remove(),kind==node_1.NodeKind.NOT_EQUAL||kind==node_1.NodeKind.LESS_THAN_EQUAL||kind==node_1.NodeKind.GREATER_THAN_EQUAL){var call=node_1.createCall(left);call.appendChild(right),node.kind=node_1.NodeKind.NOT,node.appendChild(call.withRange(node.range).withInternalRange(node.range))}else node.appendChild(left),node.appendChild(right),node.kind=node_1.NodeKind.CALL;node.resolvedType=null,resolveAsExpression(context,node,parentScope)}else kind==node_1.NodeKind.EQUAL||kind==node_1.NodeKind.NOT_EQUAL?(node.resolvedType=context.booleanType,leftType==context.errorType||rightType==context.errorType||leftType==rightType||canConvert(context,right,leftType,type_1.ConversionKind.IMPLICIT)||canConvert(context,left,rightType,type_1.ConversionKind.IMPLICIT)||context.log.error(node.internalRange,"Cannot compare type '"+leftType.toString()+"' with type '"+rightType.toString()+"'")):context.log.error(node.internalRange,"Cannot use binary operator '"+name+"' with type '"+leftType.toString()+"'")}}else node.resolvedType=context.booleanType,leftType!=rightType&&context.log.error(node.internalRange,"Cannot compare type '"+leftType.toString()+"' with type '"+rightType.toString()+"'")}else kind==node_1.NodeKind.TYPE||(terminal_1.Terminal.error("Unexpected kind: "+node_1.NodeKind[kind]),assert_1.assert(!1))}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(7),type_1=__webpack_require__(31),node_1=__webpack_require__(10),compile_target_1=__webpack_require__(9),log_1=__webpack_require__(5),scope_1=__webpack_require__(30),utils_1=__webpack_require__(8),const_1=__webpack_require__(69),assert_1=__webpack_require__(3),compiler_1=__webpack_require__(19),terminal_1=__webpack_require__(2),CheckContext=function(){function CheckContext(){}return CheckContext.prototype.allocateGlobalVariableOffset=function(sizeOf,alignmentOf){var offset=utils_1.alignToNextMultipleOf(this.nextGlobalVariableOffset,alignmentOf);return this.nextGlobalVariableOffset=offset+sizeOf,offset},CheckContext}();exports.CheckContext=CheckContext,exports.addScopeToSymbol=addScopeToSymbol,exports.linkSymbolToNode=linkSymbolToNode;var CheckMode;!function(CheckMode){CheckMode[CheckMode.NORMAL=0]="NORMAL",CheckMode[CheckMode.INITIALIZE=1]="INITIALIZE"}(CheckMode=exports.CheckMode||(exports.CheckMode={})),exports.initialize=initialize,exports.forbidFlag=forbidFlag,exports.requireFlag=requireFlag,exports.initializeSymbol=initializeSymbol,exports.resolveChildren=resolveChildren,exports.resolveChildrenAsExpressions=resolveChildrenAsExpressions,exports.resolveAsExpression=resolveAsExpression,exports.resolveAsType=resolveAsType,exports.canConvert=canConvert,exports.checkConversion=checkConversion,exports.checkStorage=checkStorage,exports.createDefaultValueForType=createDefaultValueForType,exports.simplifyBinary=simplifyBinary,exports.binaryHasUnsignedArguments=binaryHasUnsignedArguments,exports.isBinaryLong=isBinaryLong,exports.isBinaryDouble=isBinaryDouble,exports.isSymbolAccessAllowed=isSymbolAccessAllowed,exports.resolve=resolve},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var compile_target_1=__webpack_require__(9);exports.defaultCompilerOptions={target:compile_target_1.CompileTarget.WEBASSEMBLY,silent:!0,logError:!0,optimize:!0,longPtr:!1}},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MIN_INT32_VALUE=-Math.pow(2,31),exports.MAX_INT32_VALUE=Math.pow(2,31)-1,exports.MIN_UINT32_VALUE=0,exports.MAX_UINT32_VALUE=Math.pow(2,32)-1,exports.MIN_INT64_VALUE=-Math.pow(2,63),exports.MAX_INT64_VALUE=Math.pow(2,63)-1,exports.MIN_UINT64_VALUE=0,exports.MAX_UINT64_VALUE=Math.pow(2,64)-1},function(module,exports,__webpack_require__){"use strict";function treeShakingMarkAllUsed(node){var symbol=node.symbol;if(null==symbol||symbol.isUsed()||!symbol_1.isFunction(symbol.kind)||null==symbol.node||(symbol.flags=symbol.flags|symbol_1.SYMBOL_FLAG_USED,treeShakingMarkAllUsed(symbol.node),node!=symbol.node)){if(node.kind==node_1.NodeKind.NEW){var type=node.newType().resolvedType;null!=type.symbol&&(type.symbol.flags|=symbol_1.SYMBOL_FLAG_USED,type.symbol.node.constructorFunctionNode.symbol.flags=symbol_1.SYMBOL_FLAG_USED)}for(var child=node.firstChild;null!=child;)treeShakingMarkAllUsed(child),child=child.nextSibling}}function treeShakingSearchForUsed(node){if(node.kind==node_1.NodeKind.FUNCTION&&(node.isExport()||node.isStart())){if(("malloc"===node.symbol.name||"free"===node.symbol.name)&&!compiler_1.Compiler.mallocRequired)return;treeShakingMarkAllUsed(node)}else if(node.kind==node_1.NodeKind.GLOBAL||node.kind==node_1.NodeKind.CLASS){for(var child=node.firstChild;null!=child;)treeShakingSearchForUsed(child),child=child.nextSibling;node.kind==node_1.NodeKind.CLASS&&node.isExport()&&(node.symbol.flags=node.symbol.flags|symbol_1.SYMBOL_FLAG_USED)}}function treeShakingRemoveUnused(node){if(node.kind==node_1.NodeKind.FUNCTION&&!node.symbol.isUsed()&&node.range.source.isLibrary)node.remove();else if(node.kind==node_1.NodeKind.GLOBAL||node.kind==node_1.NodeKind.CLASS){for(var child=node.firstChild;null!=child;){var next=child.nextSibling;treeShakingRemoveUnused(child),child=next}node.kind!=node_1.NodeKind.CLASS||node.symbol.isUsed()||node.isDeclare()||!node.range.source.isLibrary||node.remove()}}function treeShaking(node){treeShakingSearchForUsed(node),treeShakingRemoveUnused(node)}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(7),node_1=__webpack_require__(10),compiler_1=__webpack_require__(19);exports.treeShakingMarkAllUsed=treeShakingMarkAllUsed,exports.treeShakingSearchForUsed=treeShakingSearchForUsed,exports.treeShakingRemoveUnused=treeShakingRemoveUnused,exports.treeShaking=treeShaking},function(module,exports,__webpack_require__){"use strict";function preparse(source,compiler,log){env_1.isNode&&(source.name=path.resolve(source.name));for(var imports,contents=source.contents,limit=contents.length,pathSeparator=source.name.indexOf("/")>-1?"/":source.name.indexOf("\\")>-1?"\\":"/",basePath=source.name.substring(0,source.name.lastIndexOf(pathSeparator)),wantNewline=!1,captureImports=!1,captureImportFrom=!1,captureImportPath=!1,i=0;i=2&&length<=10){var text=contents.slice(start,i);"import"==text?(captureImports=!0,captureImportFrom=!0):"from"==text&&captureImportFrom&&(captureImportFrom=!1,captureImportPath=!0)}}else if(captureImports&&"{"==c){captureImports=!1,imports=[];for(var nextImportIndex=start;i0?",":"",_this.declaration+="param"+i+":"+index_1.wasmToTurboType(type)}),this.declaration+="):"+index_1.wasmToTurboType(signature.returnType)+";"}return WasmBinaryImport}();exports.WasmBinaryImport=WasmBinaryImport},function(module,exports,__webpack_require__){"use strict";function __export(m){for(var p in m)exports.hasOwnProperty(p)||(exports[p]=m[p])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(__webpack_require__(34)),__export(__webpack_require__(9)),__export(__webpack_require__(5))},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var compile_target_1=__webpack_require__(9),filesystem_1=__webpack_require__(15),math=__webpack_require__(39),types=__webpack_require__(40),array=__webpack_require__(37),jstypes=__webpack_require__(42),runtime=__webpack_require__(41),wrapper=__webpack_require__(43),malloc=__webpack_require__(38),dlmallocBin=__webpack_require__(35),builtins=__webpack_require__(44),initializer=__webpack_require__(45);filesystem_1.FileSystem.writeBinaryFile("/library/dlmalloc.wasm",dlmallocBin,!0);var Library=function(){function Library(){}return Library.get=function(target){var lib;switch(target){case compile_target_1.CompileTarget.JAVASCRIPT:lib=jstypes+"\n";break;case compile_target_1.CompileTarget.WEBASSEMBLY:lib=[types,initializer,builtins,math,malloc,array].join("\n")}return lib},Library.getRuntime=function(target){switch(target){case compile_target_1.CompileTarget.JAVASCRIPT:return runtime+"\n";default:return""}},Library.getWrapper=function(target){switch(target){case compile_target_1.CompileTarget.JAVASCRIPT:return wrapper+"\n";default:return""}},Library}();exports.Library=Library},function(module,exports){module.exports=require("fs")},function(module,exports){module.exports=require("path")}])}); \ No newline at end of file diff --git a/src/compiler/compiler-options.ts b/src/compiler/compiler-options.ts index 4e8f694..eea8dfc 100644 --- a/src/compiler/compiler-options.ts +++ b/src/compiler/compiler-options.ts @@ -6,10 +6,14 @@ export interface CompilerOptions { target: CompileTarget, silent: boolean; logError: boolean; + optimize: boolean; + longPtr: boolean; } export const defaultCompilerOptions: CompilerOptions = { target: CompileTarget.WEBASSEMBLY, silent: true, - logError: true + logError: true, + optimize: true, + longPtr: false }; diff --git a/src/compiler/compiler.ts b/src/compiler/compiler.ts index 23c155c..ff36f5d 100644 --- a/src/compiler/compiler.ts +++ b/src/compiler/compiler.ts @@ -9,6 +9,7 @@ import {tokenize} from "./scanner/scanner"; import {parse} from "./parser/parser"; import {treeShaking} from "./optimizer/shaking"; import {wasmEmit} from "../backends/webassembly/webassembly"; +import {Bitness} from "../backends/bitness"; import {Library} from "../library/library"; import {preparse} from "./parser/preparser"; import {CompileTarget} from "./compile-target"; @@ -36,17 +37,19 @@ export class Compiler { outputJS: string; outputCPP: string; outputH: string; + options: {[key: string]: any}; static mallocRequired: boolean = false; static debug:boolean = false; static binaryImports: WasmBinary[]; - initialize(target: CompileTarget, outputName: string): void { + initialize(target: CompileTarget, outputName: string, options: {[key: string]: any} = {}): void { assert(this.log == null); this.log = new Log(); this.preprocessor = new Preprocessor(); Compiler.binaryImports = []; this.target = target; + this.options = options; this.outputName = outputName; this.librarySource = this.addInput("", Library.get(target)); this.librarySource.isLibrary = true; @@ -220,7 +223,8 @@ export class Compiler { // } else if (this.target == CompileTarget.WEBASSEMBLY) { - wasmEmit(this); + const { longPtr, optimize } = this.options; + wasmEmit(this, longPtr ? Bitness.x64 : Bitness.x32, optimize); } Terminal.timeEnd("emitting"); diff --git a/src/turboscript.ts b/src/turboscript.ts index 58ea0b2..ae2b04e 100644 --- a/src/turboscript.ts +++ b/src/turboscript.ts @@ -38,7 +38,7 @@ Usage: tc [FLAGS] [INPUTS] --help Print this message. --out [PATH] Emit code to PATH (the target format is the file extension). - --wasm Explicit webassembly output + --wasm Explicit webassembly output --define [NAME] Define the flag NAME in all input files. Examples: @@ -202,6 +202,8 @@ export interface CompileResult { wasm?: Uint8Array; wast?: string; log?: Log; + optimize?: boolean; + longPtr?: boolean; } export function compileString(source: string, options: CompilerOptions = defaultCompilerOptions): CompileResult { @@ -210,7 +212,7 @@ export function compileString(source: string, options: CompilerOptions = default let output = "/virtual/inline.wasm"; FileSystem.writeTextFile(input, source, true); let compiler = new Compiler(); - compiler.initialize(options.target, output); + compiler.initialize(options.target, output, options); compiler.addInput(input, source); compiler.finish(); Terminal.silent = false; @@ -241,4 +243,4 @@ export default { version: version, main: main, compileString: compileString -} \ No newline at end of file +}