mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 07:02:13 +00:00
2 lines
317 KiB
JavaScript
2 lines
317 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("binaryen")):"function"==typeof define&&define.amd?define(["binaryen"],t):"object"==typeof exports?exports.assemblyscript=t(require("binaryen")):e.assemblyscript=t(e.binaryen)}("undefined"!=typeof self?self:this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=11)}([function(e,t,r){"use strict";function n(e){if(!e)return 0;for(var t=allocate_memory(e.length),r=t,n=0,i=e.length;n<i;++n)store(r++,e[n]);return t}function i(e){if(!e)return 0;for(var t=allocate_memory(e.length<<2),r=t,n=0,i=e.length;n<i;++n){var a=e[n];store(r,255&a),store(r+1,a>>8&255),store(r+2,a>>16&255),store(r+3,a>>>24),r+=4}return t}function a(e){for(var t=0,r=0,n=e.length;r<n;++r){var i=e.charCodeAt(r);i>=55296&&i<=57343&&r+1<n&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++r)),i<=127?++t:t+=i<=2047?2:i<=65535?3:i<=2097151?4:i<=67108863?5:6}return t}function o(e){if(null==e)return 0;for(var t=allocate_memory(a(e)+1),r=t,n=0,i=e.length;n<i;++n){var o=e.charCodeAt(n);o>=55296&&o<=57343&&n+1<i&&(o=65536+((1023&o)<<10)|1023&e.charCodeAt(++n)),o<=127?store(r++,o):o<=2047?(store(r++,192|o>>>6),store(r++,128|63&o)):o<=65535?(store(r++,224|o>>>12),store(r++,128|o>>>6&63),store(r++,128|63&o)):o<=2097151?(store(r++,240|o>>>18),store(r++,128|o>>>12&63),store(r++,128|o>>>6&63),store(r++,128|63&o)):o<=67108863?(store(r++,248|o>>>24),store(r++,128|o>>>18&63),store(r++,128|o>>>12&63),store(r++,128|o>>>6&63),store(r++,128|63&o)):(store(r++,252|o>>>30),store(r++,128|o>>>24&63),store(r++,128|o>>>18&63),store(r++,128|o>>>12&63),store(r++,128|o>>>6&63),store(r++,128|63&o))}return store(r,0),t}function s(e){return load(e)|load(e+1)<<8|load(e+2)<<16|load(e+3)<<24}function c(e,t){for(var r=new Uint8Array(t),n=0;n<t;++n)r[n]=load(e+n);return r}function p(e){if(!e)return null;for(var t,r,n,i,a,o,s=new Array;t=load(e++);)128&t?(r=63&load(e++),192!=(224&t)?(n=63&load(e++),224==(240&t)?t=(15&t)<<12|r<<6|n:(i=63&load(e++),240==(248&t)?t=(7&t)<<18|r<<12|n<<6|i:(a=63&load(e++),248==(252&t)?t=(3&t)<<24|r<<18|n<<12|i<<6|a:(o=63&load(e++),t=(1&t)<<30|r<<24|n<<18|i<<12|a<<6|o)))):s.push((31&t)<<6|r)):s.push(t);return String.fromCodePoints(s)}Object.defineProperty(t,"__esModule",{value:!0});var u,l=r(4);!function(e){e[e.None=_BinaryenTypeNone()]="None",e[e.I32=_BinaryenTypeInt32()]="I32",e[e.I64=_BinaryenTypeInt64()]="I64",e[e.F32=_BinaryenTypeFloat32()]="F32",e[e.F64=_BinaryenTypeFloat64()]="F64",e[e.Unreachable=_BinaryenTypeUnreachable()]="Unreachable",e[e.Auto=_BinaryenTypeAuto()]="Auto"}(u=t.NativeType||(t.NativeType={}));var h;!function(e){e[e.Invalid=_BinaryenInvalidId()]="Invalid",e[e.Block=_BinaryenBlockId()]="Block",e[e.If=_BinaryenIfId()]="If",e[e.Loop=_BinaryenLoopId()]="Loop",e[e.Break=_BinaryenBreakId()]="Break",e[e.Switch=_BinaryenSwitchId()]="Switch",e[e.Call=_BinaryenCallId()]="Call",e[e.CallImport=_BinaryenCallImportId()]="CallImport",e[e.CallIndirect=_BinaryenCallIndirectId()]="CallIndirect",e[e.GetLocal=_BinaryenGetLocalId()]="GetLocal",e[e.SetLocal=_BinaryenSetLocalId()]="SetLocal",e[e.GetGlobal=_BinaryenGetGlobalId()]="GetGlobal",e[e.SetGlobal=_BinaryenSetGlobalId()]="SetGlobal",e[e.Load=_BinaryenLoadId()]="Load",e[e.Store=_BinaryenStoreId()]="Store",e[e.Const=_BinaryenConstId()]="Const",e[e.Unary=_BinaryenUnaryId()]="Unary",e[e.Binary=_BinaryenBinaryId()]="Binary",e[e.Select=_BinaryenSelectId()]="Select",e[e.Drop=_BinaryenDropId()]="Drop",e[e.Return=_BinaryenReturnId()]="Return",e[e.Host=_BinaryenHostId()]="Host",e[e.Nop=_BinaryenNopId()]="Nop",e[e.Unreachable=_BinaryenUnreachableId()]="Unreachable",e[e.AtomicCmpxchg=_BinaryenAtomicCmpxchgId()]="AtomicCmpxchg",e[e.AtomicRMW=_BinaryenAtomicRMWId()]="AtomicRMW",e[e.AtomicWait=_BinaryenAtomicWaitId()]="AtomicWait",e[e.AtomicWake=_BinaryenAtomicWakeId()]="AtomicWake"}(h=t.ExpressionId||(t.ExpressionId={}));!function(e){e[e.ClzI32=_BinaryenClzInt32()]="ClzI32",e[e.CtzI32=_BinaryenCtzInt32()]="CtzI32",e[e.PopcntI32=_BinaryenPopcntInt32()]="PopcntI32",e[e.NegF32=_BinaryenNegFloat32()]="NegF32",e[e.AbsF32=_BinaryenAbsFloat32()]="AbsF32",e[e.CeilF32=_BinaryenCeilFloat32()]="CeilF32",e[e.FloorF32=_BinaryenFloorFloat32()]="FloorF32",e[e.TruncF32=_BinaryenTruncFloat32()]="TruncF32",e[e.NearestF32=_BinaryenNearestFloat32()]="NearestF32",e[e.SqrtF32=_BinaryenSqrtFloat32()]="SqrtF32",e[e.EqzI32=_BinaryenEqZInt32()]="EqzI32",e[e.ClzI64=_BinaryenClzInt64()]="ClzI64",e[e.CtzI64=_BinaryenCtzInt64()]="CtzI64",e[e.PopcntI64=_BinaryenPopcntInt64()]="PopcntI64",e[e.NegF64=_BinaryenNegFloat64()]="NegF64",e[e.AbsF64=_BinaryenAbsFloat64()]="AbsF64",e[e.CeilF64=_BinaryenCeilFloat64()]="CeilF64",e[e.FloorF64=_BinaryenFloorFloat64()]="FloorF64",e[e.TruncF64=_BinaryenTruncFloat64()]="TruncF64",e[e.NearestF64=_BinaryenNearestFloat64()]="NearestF64",e[e.SqrtF64=_BinaryenSqrtFloat64()]="SqrtF64",e[e.EqzI64=_BinaryenEqZInt64()]="EqzI64",e[e.ExtendI32=_BinaryenExtendSInt32()]="ExtendI32",e[e.ExtendU32=_BinaryenExtendUInt32()]="ExtendU32",e[e.WrapI64=_BinaryenWrapInt64()]="WrapI64",e[e.TruncF32ToI32=_BinaryenTruncSFloat32ToInt32()]="TruncF32ToI32",e[e.TruncF32ToI64=_BinaryenTruncSFloat32ToInt64()]="TruncF32ToI64",e[e.TruncF32ToU32=_BinaryenTruncUFloat32ToInt32()]="TruncF32ToU32",e[e.TruncF32ToU64=_BinaryenTruncUFloat32ToInt64()]="TruncF32ToU64",e[e.TruncF64ToI32=_BinaryenTruncSFloat64ToInt32()]="TruncF64ToI32",e[e.TruncF64ToI64=_BinaryenTruncSFloat64ToInt64()]="TruncF64ToI64",e[e.TruncF64ToU32=_BinaryenTruncUFloat64ToInt32()]="TruncF64ToU32",e[e.TruncF64ToU64=_BinaryenTruncUFloat64ToInt64()]="TruncF64ToU64",e[e.ReinterpretF32=_BinaryenReinterpretFloat32()]="ReinterpretF32",e[e.ReinterpretF64=_BinaryenReinterpretFloat64()]="ReinterpretF64",e[e.ConvertI32ToF32=_BinaryenConvertSInt32ToFloat32()]="ConvertI32ToF32",e[e.ConvertI32ToF64=_BinaryenConvertSInt32ToFloat64()]="ConvertI32ToF64",e[e.ConvertU32ToF32=_BinaryenConvertUInt32ToFloat32()]="ConvertU32ToF32",e[e.ConvertU32ToF64=_BinaryenConvertUInt32ToFloat64()]="ConvertU32ToF64",e[e.ConvertI64ToF32=_BinaryenConvertSInt64ToFloat32()]="ConvertI64ToF32",e[e.ConvertI64ToF64=_BinaryenConvertSInt64ToFloat64()]="ConvertI64ToF64",e[e.ConvertU64ToF32=_BinaryenConvertUInt64ToFloat32()]="ConvertU64ToF32",e[e.ConvertU64ToF64=_BinaryenConvertUInt64ToFloat64()]="ConvertU64ToF64",e[e.PromoteF32=_BinaryenPromoteFloat32()]="PromoteF32",e[e.DemoteF64=_BinaryenDemoteFloat64()]="DemoteF64",e[e.ReinterpretI32=_BinaryenReinterpretInt32()]="ReinterpretI32",e[e.ReinterpretI64=_BinaryenReinterpretInt64()]="ReinterpretI64"}(t.UnaryOp||(t.UnaryOp={}));!function(e){e[e.AddI32=_BinaryenAddInt32()]="AddI32",e[e.SubI32=_BinaryenSubInt32()]="SubI32",e[e.MulI32=_BinaryenMulInt32()]="MulI32",e[e.DivI32=_BinaryenDivSInt32()]="DivI32",e[e.DivU32=_BinaryenDivUInt32()]="DivU32",e[e.RemI32=_BinaryenRemSInt32()]="RemI32",e[e.RemU32=_BinaryenRemUInt32()]="RemU32",e[e.AndI32=_BinaryenAndInt32()]="AndI32",e[e.OrI32=_BinaryenOrInt32()]="OrI32",e[e.XorI32=_BinaryenXorInt32()]="XorI32",e[e.ShlI32=_BinaryenShlInt32()]="ShlI32",e[e.ShrU32=_BinaryenShrUInt32()]="ShrU32",e[e.ShrI32=_BinaryenShrSInt32()]="ShrI32",e[e.RotlI32=_BinaryenRotLInt32()]="RotlI32",e[e.RotrI32=_BinaryenRotRInt32()]="RotrI32",e[e.EqI32=_BinaryenEqInt32()]="EqI32",e[e.NeI32=_BinaryenNeInt32()]="NeI32",e[e.LtI32=_BinaryenLtSInt32()]="LtI32",e[e.LtU32=_BinaryenLtUInt32()]="LtU32",e[e.LeI32=_BinaryenLeSInt32()]="LeI32",e[e.LeU32=_BinaryenLeUInt32()]="LeU32",e[e.GtI32=_BinaryenGtSInt32()]="GtI32",e[e.GtU32=_BinaryenGtUInt32()]="GtU32",e[e.GeI32=_BinaryenGeSInt32()]="GeI32",e[e.GeU32=_BinaryenGeUInt32()]="GeU32",e[e.AddI64=_BinaryenAddInt64()]="AddI64",e[e.SubI64=_BinaryenSubInt64()]="SubI64",e[e.MulI64=_BinaryenMulInt64()]="MulI64",e[e.DivI64=_BinaryenDivSInt64()]="DivI64",e[e.DivU64=_BinaryenDivUInt64()]="DivU64",e[e.RemI64=_BinaryenRemSInt64()]="RemI64",e[e.RemU64=_BinaryenRemUInt64()]="RemU64",e[e.AndI64=_BinaryenAndInt64()]="AndI64",e[e.OrI64=_BinaryenOrInt64()]="OrI64",e[e.XorI64=_BinaryenXorInt64()]="XorI64",e[e.ShlI64=_BinaryenShlInt64()]="ShlI64",e[e.ShrU64=_BinaryenShrUInt64()]="ShrU64",e[e.ShrI64=_BinaryenShrSInt64()]="ShrI64",e[e.RotlI64=_BinaryenRotLInt64()]="RotlI64",e[e.RotrI64=_BinaryenRotRInt64()]="RotrI64",e[e.EqI64=_BinaryenEqInt64()]="EqI64",e[e.NeI64=_BinaryenNeInt64()]="NeI64",e[e.LtI64=_BinaryenLtSInt64()]="LtI64",e[e.LtU64=_BinaryenLtUInt64()]="LtU64",e[e.LeI64=_BinaryenLeSInt64()]="LeI64",e[e.LeU64=_BinaryenLeUInt64()]="LeU64",e[e.GtI64=_BinaryenGtSInt64()]="GtI64",e[e.GtU64=_BinaryenGtUInt64()]="GtU64",e[e.GeI64=_BinaryenGeSInt64()]="GeI64",e[e.GeU64=_BinaryenGeUInt64()]="GeU64",e[e.AddF32=_BinaryenAddFloat32()]="AddF32",e[e.SubF32=_BinaryenSubFloat32()]="SubF32",e[e.MulF32=_BinaryenMulFloat32()]="MulF32",e[e.DivF32=_BinaryenDivFloat32()]="DivF32",e[e.CopysignF32=_BinaryenCopySignFloat32()]="CopysignF32",e[e.MinF32=_BinaryenMinFloat32()]="MinF32",e[e.MaxF32=_BinaryenMaxFloat32()]="MaxF32",e[e.EqF32=_BinaryenEqFloat32()]="EqF32",e[e.NeF32=_BinaryenNeFloat32()]="NeF32",e[e.LtF32=_BinaryenLtFloat32()]="LtF32",e[e.LeF32=_BinaryenLeFloat32()]="LeF32",e[e.GtF32=_BinaryenGtFloat32()]="GtF32",e[e.GeF32=_BinaryenGeFloat32()]="GeF32",e[e.AddF64=_BinaryenAddFloat64()]="AddF64",e[e.SubF64=_BinaryenSubFloat64()]="SubF64",e[e.MulF64=_BinaryenMulFloat64()]="MulF64",e[e.DivF64=_BinaryenDivFloat64()]="DivF64",e[e.CopysignF64=_BinaryenCopySignFloat64()]="CopysignF64",e[e.MinF64=_BinaryenMinFloat64()]="MinF64",e[e.MaxF64=_BinaryenMaxFloat64()]="MaxF64",e[e.EqF64=_BinaryenEqFloat64()]="EqF64",e[e.NeF64=_BinaryenNeFloat64()]="NeF64",e[e.LtF64=_BinaryenLtFloat64()]="LtF64",e[e.LeF64=_BinaryenLeFloat64()]="LeF64",e[e.GtF64=_BinaryenGtFloat64()]="GtF64",e[e.GeF64=_BinaryenGeFloat64()]="GeF64"}(t.BinaryOp||(t.BinaryOp={}));!function(e){e[e.PageSize=_BinaryenPageSize()]="PageSize",e[e.CurrentMemory=_BinaryenCurrentMemory()]="CurrentMemory",e[e.GrowMemory=_BinaryenGrowMemory()]="GrowMemory",e[e.HasFeature=_BinaryenHasFeature()]="HasFeature"}(t.HostOp||(t.HostOp={}));!function(e){e[e.Add=_BinaryenAtomicRMWAdd()]="Add",e[e.Sub=_BinaryenAtomicRMWSub()]="Sub",e[e.And=_BinaryenAtomicRMWAnd()]="And",e[e.Or=_BinaryenAtomicRMWOr()]="Or",e[e.Xor=_BinaryenAtomicRMWXor()]="Xor",e[e.Xchg=_BinaryenAtomicRMWXchg()]="Xchg"}(t.AtomicRMWOp||(t.AtomicRMWOp={}));var d=function(){function e(){}return e.create=function(t,r){var n=new e;return n.buffer=t,n.offset=r,n},e}();t.MemorySegment=d;var _=function(){function e(){}return e.create=function(){var t=new e;return t.ref=_BinaryenModuleCreate(),t.out=allocate_memory(16),t},e.createFrom=function(t){var r=n(t);try{var i=new e;return i.ref=_BinaryenModuleRead(r,t.length),i.out=allocate_memory(24),i}finally{free_memory(changetype(r))}},e.prototype.addFunctionType=function(e,t,r){var n=o(e),a=i(r);try{return _BinaryenAddFunctionType(this.ref,n,t,a,r.length)}finally{free_memory(a),free_memory(n)}},e.prototype.getFunctionTypeBySignature=function(e,t){var r=i(t);try{return _BinaryenGetFunctionTypeBySignature(this.ref,e,r,t.length)}finally{free_memory(r)}},e.prototype.createI32=function(e){var t=this.out;return _BinaryenLiteralInt32(t,e),_BinaryenConst(this.ref,t)},e.prototype.createI64=function(e,t){void 0===t&&(t=0);var r=this.out;return _BinaryenLiteralInt64(r,e,t),_BinaryenConst(this.ref,r)},e.prototype.createF32=function(e){var t=this.out;return _BinaryenLiteralFloat32(t,e),_BinaryenConst(this.ref,t)},e.prototype.createF64=function(e){var t=this.out;return _BinaryenLiteralFloat64(t,e),_BinaryenConst(this.ref,t)},e.prototype.createUnary=function(e,t){return _BinaryenUnary(this.ref,e,t)},e.prototype.createBinary=function(e,t,r){return _BinaryenBinary(this.ref,e,t,r)},e.prototype.createHost=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r=null);var n=o(t),a=i(r);try{return _BinaryenHost(this.ref,e,n,a,r?r.length:0)}finally{free_memory(a),free_memory(n)}},e.prototype.createGetLocal=function(e,t){return _BinaryenGetLocal(this.ref,e,t)},e.prototype.createTeeLocal=function(e,t){return _BinaryenTeeLocal(this.ref,e,t)},e.prototype.createGetGlobal=function(e,t){var r=o(e);try{return _BinaryenGetGlobal(this.ref,r,t)}finally{free_memory(r)}},e.prototype.createLoad=function(e,t,r,n,i){return void 0===i&&(i=0),_BinaryenLoad(this.ref,e,t?1:0,i,e,n,r)},e.prototype.createStore=function(e,t,r,n,i){return void 0===i&&(i=0),_BinaryenStore(this.ref,e,i,e,t,r,n)},e.prototype.createAtomicLoad=function(e,t,r,n){return void 0===n&&(n=0),_BinaryenAtomicLoad(this.ref,e,n,r,t)},e.prototype.createAtomicStore=function(e,t,r,n,i){return void 0===i&&(i=0),_BinaryenAtomicStore(this.ref,e,i,t,r,n)},e.prototype.createAtomicRMW=function(e,t,r,n,i,a){return _BinaryenAtomicRMW(this.ref,e,t,r,n,i,a)},e.prototype.createAtomicCmpxchg=function(e,t,r,n,i,a){return _BinaryenAtomicCmpxchg(this.ref,e,t,r,n,i,a)},e.prototype.createAtomicWait=function(e,t,r,n){return _BinaryenAtomicWait(this.ref,e,t,r,n)},e.prototype.createAtomicWake=function(e,t){return _BinaryenAtomicWake(this.ref,e,t)},e.prototype.createSetLocal=function(e,t){return _BinaryenSetLocal(this.ref,e,t)},e.prototype.createSetGlobal=function(e,t){var r=o(e);try{return _BinaryenSetGlobal(this.ref,r,t)}finally{free_memory(r)}},e.prototype.createBlock=function(e,t,r){void 0===r&&(r=u.None);var n=o(e),a=i(t);try{return _BinaryenBlock(this.ref,n,a,t.length,r)}finally{free_memory(a),free_memory(n)}},e.prototype.createBreak=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=o(e);try{return _BinaryenBreak(this.ref,n,t,r)}finally{free_memory(n)}},e.prototype.createDrop=function(e){return _BinaryenDrop(this.ref,e)},e.prototype.createLoop=function(e,t){var r=o(e);try{return _BinaryenLoop(this.ref,r,t)}finally{free_memory(r)}},e.prototype.createIf=function(e,t,r){return void 0===r&&(r=0),_BinaryenIf(this.ref,e,t,r)},e.prototype.createNop=function(){return _BinaryenNop(this.ref)},e.prototype.createReturn=function(e){return void 0===e&&(e=0),_BinaryenReturn(this.ref,e)},e.prototype.createSelect=function(e,t,r){return _BinaryenSelect(this.ref,r,e,t)},e.prototype.createSwitch=function(e,t,r,n){void 0===n&&(n=0);for(var a=new Array(e.length),s=0,c=e.length;s<c;++s)a[s]=o(e[s]);var p=i(a),u=o(t);try{return _BinaryenSwitch(this.ref,p,c,u,r,n)}finally{for(free_memory(u),free_memory(p),s=c-1;s>=0;--s)free_memory(a[s])}},e.prototype.createCall=function(e,t,r){var n=o(e),a=i(t);try{return _BinaryenCall(this.ref,n,a,t&&t.length||0,r)}finally{free_memory(a),free_memory(n)}},e.prototype.createCallImport=function(e,t,r){var n=o(e),a=i(t);try{return _BinaryenCallImport(this.ref,n,a,t&&t.length||0,r)}finally{free_memory(a),free_memory(n)}},e.prototype.createUnreachable=function(){return _BinaryenUnreachable(this.ref)},e.prototype.addGlobal=function(e,t,r,n){var i=o(e);try{return _BinaryenAddGlobal(this.ref,i,t,r?1:0,n)}finally{free_memory(i)}},e.prototype.addFunction=function(e,t,r,n){var a=o(e),s=i(r);try{return _BinaryenAddFunction(this.ref,a,t,s,r.length,n)}finally{free_memory(s),free_memory(a)}},e.prototype.removeFunction=function(e){var t=o(e);try{_BinaryenRemoveFunction(this.ref,t)}finally{free_memory(t)}},e.prototype.addFunctionExport=function(e,t){var r=o(e),n=o(t);try{return _BinaryenAddFunctionExport(this.ref,r,n)}finally{free_memory(n),free_memory(r)}},e.prototype.addTableExport=function(e,t){var r=o(e),n=o(t);try{return _BinaryenAddTableExport(this.ref,r,n)}finally{free_memory(n),free_memory(r)}},e.prototype.addMemoryExport=function(e,t){var r=o(e),n=o(t);try{return _BinaryenAddMemoryExport(this.ref,r,n)}finally{free_memory(n),free_memory(r)}},e.prototype.addGlobalExport=function(e,t){var r=o(e),n=o(t);try{return _BinaryenAddGlobalExport(this.ref,r,n)}finally{free_memory(n),free_memory(r)}},e.prototype.removeExport=function(e){var t=o(e);try{_BinaryenRemoveExport(this.ref,t)}finally{free_memory(t)}},e.prototype.addFunctionImport=function(e,t,r,n){var i=o(e),a=o(t),s=o(r);try{return _BinaryenAddFunctionImport(this.ref,i,a,s,n)}finally{free_memory(s),free_memory(a),free_memory(i)}},e.prototype.addTableImport=function(e,t,r){var n=o(e),i=o(t),a=o(r);try{return _BinaryenAddTableImport(this.ref,n,i,a)}finally{free_memory(a),free_memory(i),free_memory(n)}},e.prototype.addMemoryImport=function(e,t,r){var n=o(e),i=o(t),a=o(r);try{return _BinaryenAddMemoryImport(this.ref,n,i,a)}finally{free_memory(a),free_memory(i),free_memory(n)}},e.prototype.addGlobalImport=function(e,t,r,n){var i=o(e),a=o(t),s=o(r);try{return _BinaryenAddGlobalImport(this.ref,i,a,s,n)}finally{free_memory(s),free_memory(a),free_memory(i)}},e.prototype.removeImport=function(e){var t=o(e);try{_BinaryenRemoveImport(this.ref,t)}finally{free_memory(t)}},e.prototype.setMemory=function(e,t,r,a,s){void 0===s&&(s=null);for(var c=o(s),p=r.length,u=new Array(p),h=new Array(p),d=new Array(p),_=0;_<p;++_){var y=r[_].buffer,m=r[_].offset;u[_]=n(y),h[_]=a==l.Target.WASM64?this.createI64(i64_low(m),i64_high(m)):this.createI32(i64_low(m)),d[_]=y.length}var f=i(u),E=i(h),g=i(d);try{_BinaryenSetMemory(this.ref,e,t,c,f,E,g,p)}finally{for(free_memory(g),free_memory(E),free_memory(f),_=p-1;_>=0;--_)free_memory(u[_]);free_memory(c)}},e.prototype.setFunctionTable=function(e){var t=i(e);try{_BinaryenSetFunctionTable(this.ref,t,e.length)}finally{free_memory(t)}},e.prototype.setStart=function(e){_BinaryenSetStart(this.ref,e)},e.prototype.setOptimizeLevel=function(e){void 0===e&&(e=2),_BinaryenSetOptimizeLevel(e)},e.prototype.setShrinkLevel=function(e){void 0===e&&(e=1),_BinaryenSetShrinkLevel(e)},e.prototype.setDebugInfo=function(e){void 0===e&&(e=!1),_BinaryenSetDebugInfo(e)},e.prototype.optimize=function(e){void 0===e&&(e=0),e?_BinaryenFunctionOptimize(e,this.ref):_BinaryenModuleOptimize(this.ref)},e.prototype.runPasses=function(e,t){void 0===t&&(t=0);for(var r=e.length,n=new Array(r),a=0;a<r;++a)n[a]=o(e[a]);var s=i(n);try{t?_BinaryenFunctionRunPasses(t,this.ref,s,r):_BinaryenModuleRunPasses(this.ref,s,r)}finally{for(free_memory(s);a>=0;--a)free_memory(n[a])}},e.prototype.validate=function(){return 1==_BinaryenModuleValidate(this.ref)},e.prototype.interpret=function(){_BinaryenModuleInterpret(this.ref)},e.prototype.toBinary=function(e){var t=this.out,r=o(e),n=0,i=0;try{_BinaryenModuleAllocateAndWrite(t,this.ref,r),n=s(t);var a=s(t+4);i=s(t+8);var u=new m;return u.output=c(n,a),u.sourceMap=p(i),u}finally{r&&free_memory(r),n&&free_memory(n),i&&free_memory(i)}},e.prototype.toText=function(){throw new Error("not implemented")},e.prototype.toAsmjs=function(){throw new Error("not implemented")},e.prototype.dispose=function(){this.ref&&(_BinaryenModuleDispose(this.ref),free_memory(this.out))},e.prototype.createRelooper=function(){return y.create(this)},e.prototype.cloneExpression=function(e,t,r){if(void 0===t&&(t=!1),void 0===r&&(r=i32.MAX_VALUE),r<0)return 0;r-=1;var n,i;switch(_BinaryenExpressionGetId(e)){case h.Const:switch(_BinaryenExpressionGetType(e)){case u.I32:return this.createI32(_BinaryenConstGetValueI32(e));case u.I64:return this.createI64(_BinaryenConstGetValueI64Low(e),_BinaryenConstGetValueI64High(e));case u.F32:return this.createF32(_BinaryenConstGetValueF32(e));case u.F64:return this.createF64(_BinaryenConstGetValueF64(e));default:throw new Error("concrete type expected")}case h.GetLocal:return _BinaryenGetLocal(this.ref,_BinaryenGetLocalGetIndex(e),_BinaryenExpressionGetType(e));case h.GetGlobal:var a=_BinaryenGetGlobalGetName(e);if(!a)break;return _BinaryenGetGlobal(this.ref,a,_BinaryenExpressionGetType(e));case h.Load:if(!(n=this.cloneExpression(_BinaryenLoadGetPtr(e),t,r)))break;return _BinaryenLoadIsAtomic(e)?_BinaryenAtomicLoad(this.ref,_BinaryenLoadGetBytes(e),_BinaryenLoadGetOffset(e),_BinaryenExpressionGetType(e),n):_BinaryenLoad(this.ref,_BinaryenLoadGetBytes(e),_BinaryenLoadIsSigned(e)?1:0,_BinaryenLoadGetOffset(e),_BinaryenLoadGetAlign(e),_BinaryenExpressionGetType(e),n);case h.Unary:if(!(n=this.cloneExpression(_BinaryenUnaryGetValue(e),t,r)))break;return _BinaryenUnary(this.ref,_BinaryenUnaryGetOp(e),n);case h.Binary:if(!(n=this.cloneExpression(_BinaryenBinaryGetLeft(e),t,r)))break;if(!(i=this.cloneExpression(_BinaryenBinaryGetRight(e),t,r)))break;return _BinaryenBinary(this.ref,_BinaryenBinaryGetOp(e),n,i)}return 0},e.prototype.addDebugInfoFile=function(e){var t=o(e);try{return _BinaryenModuleAddDebugInfoFileName(this.ref,t)}finally{free_memory(t)}},e.prototype.getDebugInfoFile=function(e){return p(_BinaryenModuleGetDebugInfoFileName(this.ref,e))},e.prototype.setDebugLocation=function(e,t,r,n,i){_BinaryenFunctionSetDebugLocation(e,t,r,n,i)},e.MAX_MEMORY_WASM32=65535,e}();t.Module=_;var y=function(){function e(){}return e.create=function(t){var r=new e;return r.module=t,r.ref=_RelooperCreate(),r},e.createStub=function(t){var r=new e;return r.module=t,r.ref=0,r},e.prototype.addBlock=function(e){return _RelooperAddBlock(this.ref,e)},e.prototype.addBranch=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0),_RelooperAddBranch(e,t,r,n)},e.prototype.addBlockWithSwitch=function(e,t){return _RelooperAddBlockWithSwitch(this.ref,e,t)},e.prototype.addBranchForSwitch=function(e,t,r,n){void 0===n&&(n=0);var a=i(r);try{_RelooperAddBranchForSwitch(e,t,a,r.length,n)}finally{free_memory(a)}},e.prototype.renderAndDispose=function(e,t){return _RelooperRenderAndDispose(this.ref,e,t,this.module.ref)},e}();t.Relooper=y,t.readInt=s,t.readBuffer=c,t.readString=p;var m=function(){function e(){}return e}()},function(e,t,r){"use strict";function n(e){switch(e){case u.INFO:return"INFO";case u.WARNING:return"WARNING";case u.ERROR:return"ERROR";default:return""}}function i(e){switch(e){case u.INFO:return l;case u.WARNING:return h;case u.ERROR:return d;default:return""}}function a(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=!1);var a="";e.range&&r&&(a=o(e.range,t));var s=[];if(t&&s.push(i(e.category)),s.push(n(e.category)),t&&s.push(_),s.push(e.code<1e3?" AS":" TS"),s.push(e.code.toString(10)),s.push(": "),s.push(e.message),e.range){var c=e.range;r&&(s.push("\n"),s.push(a)),s.push("\n"),s.push(" in "),s.push(c.source.normalizedPath),s.push("("),s.push(c.line.toString(10)),s.push(","),s.push(c.column.toString(10)),s.push(")")}return s.join("")}function o(e,t){void 0===t&&(t=!1);for(var r=e.source.text,n=r.length,i=e.start,a=e.end;i>0&&!c.isLineBreak(r.charCodeAt(i-1));)i--;for(;a<n&&!c.isLineBreak(r.charCodeAt(a));)a++;for(var o=["\n ",r.substring(i,a),"\n "];i<e.start;)o.push(" "),i++;if(t&&o.push(d),e.start==e.end)o.push("^");else for(;i++<e.end;)o.push("~");return t&&o.push(_),o.join("")}Object.defineProperty(t,"__esModule",{value:!0});var s=r(8),c=r(9),p=r(8);t.DiagnosticCode=p.DiagnosticCode,t.diagnosticCodeToString=p.diagnosticCodeToString;var u;!function(e){e[e.INFO=0]="INFO",e[e.WARNING=1]="WARNING",e[e.ERROR=2]="ERROR"}(u=t.DiagnosticCategory||(t.DiagnosticCategory={})),t.diagnosticCategoryToString=n;var l="[93m",h="[93m",d="[91m",_="[0m";t.diagnosticCategoryToColor=i;var y=function(){function e(e,t,r){this.range=null,this.code=e,this.category=t,this.message=r}return e.create=function(t,r,n,i){void 0===n&&(n=null),void 0===i&&(i=null);var a=s.diagnosticCodeToString(t);return null!=n&&(a=a.replace("{0}",n)),null!=i&&(a=a.replace("{1}",i)),new e(t,r,a)},e.createInfo=function(t,r,n){return void 0===r&&(r=null),void 0===n&&(n=null),e.create(t,u.INFO,r,n)},e.createWarning=function(t,r,n){return void 0===r&&(r=null),void 0===n&&(n=null),e.create(t,u.WARNING,r,n)},e.createError=function(t,r,n){return void 0===r&&(r=null),void 0===n&&(n=null),e.create(t,u.ERROR,r,n)},e.prototype.withRange=function(e){return this.range=e,this},e.prototype.toString=function(){return this.range?n(this.category)+" "+this.code.toString(10)+': "'+this.message+'" in '+this.range.source.normalizedPath+" @ "+this.range.start.toString(10)+","+this.range.end.toString(10):n(this.category)+" "+this.code.toString(10)+": "+this.message},e}();t.DiagnosticMessage=y,t.formatDiagnosticMessage=a,t.formatDiagnosticContext=o;var m=function(){function e(e){void 0===e&&(e=null),this.diagnostics=e||new Array}return e.prototype.emitDiagnostic=function(e,t,r,n,i){void 0===n&&(n=null),void 0===i&&(i=null);var a=y.create(e,t,n,i).withRange(r);this.diagnostics.push(a)},e.prototype.error=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null),this.emitDiagnostic(e,u.ERROR,t,r,n)},e.prototype.info=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null),this.emitDiagnostic(e,u.INFO,t,r,n)},e.prototype.warning=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null),this.emitDiagnostic(e,u.WARNING,t,r,n)},e}();t.DiagnosticEmitter=m},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),i=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}},a=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o};Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=r(5),c=r(6),p=r(0);t.PATH_DELIMITER="/",t.PARENT_SUBST="..",t.GETTER_PREFIX="get:",t.SETTER_PREFIX="set:",t.INSTANCE_DELIMITER="#",t.STATIC_DELIMITER=".",t.LIBRARY_SUBST="(lib)",t.LIBRARY_PREFIX=t.LIBRARY_SUBST+t.PATH_DELIMITER;var u=function(){function e(){}return e}(),l=function(){function e(){}return e}(),h=new Map,d=function(e){function r(t){void 0===t&&(t=null);var r=e.call(this,t)||this;return r.diagnosticsOffset=0,r.elements=new Map,r.types=h,r.typeAliases=new Map,r.exports=new Map,r.sources=[],r}return n(r,e),r.prototype.initialize=function(e){this.options=e,this.types=new Map([["i8",s.Type.i8],["i16",s.Type.i16],["i32",s.Type.i32],["i64",s.Type.i64],["isize",e.isizeType],["u8",s.Type.u8],["u16",s.Type.u16],["u32",s.Type.u32],["u64",s.Type.u64],["usize",e.usizeType],["bool",s.Type.bool],["f32",s.Type.f32],["f64",s.Type.f64],["void",s.Type.void],["number",s.Type.f64],["boolean",s.Type.bool]]);for(var t=new Map,r=new Array,n=new Array,p=0,u=this.sources.length;p<u;++p)for(var l=this.sources[p],h=l.statements,d=0,_=h.length;d<_;++d){var y=h[d];switch(y.kind){case c.NodeKind.CLASSDECLARATION:this.initializeClass(y,n);break;case c.NodeKind.ENUMDECLARATION:this.initializeEnum(y);break;case c.NodeKind.EXPORT:this.initializeExports(y,t);break;case c.NodeKind.FUNCTIONDECLARATION:this.initializeFunction(y);break;case c.NodeKind.IMPORT:this.initializeImports(y,t,r);break;case c.NodeKind.INTERFACEDECLARATION:this.initializeInterface(y);break;case c.NodeKind.NAMESPACEDECLARATION:this.initializeNamespace(y,n);break;case c.NodeKind.TYPEDECLARATION:this.initializeTypeAlias(y);break;case c.NodeKind.VARIABLE:this.initializeVariables(y)}}var f;for(p=0;p<r.length;){var E=r[p];f=this.tryResolveImport(E.referencedName,t),f?(this.elements.set(E.internalName,f),r.splice(p,1)):(f=this.tryResolveImport(E.referencedNameAlt,t),f?(this.elements.set(E.internalName,f),r.splice(p,1)):(this.error(o.DiagnosticCode.Module_0_has_no_exported_member_1,E.declaration.range,E.declaration.parent.path.value,E.declaration.externalName.text),++p))}try{for(var g=i(t),T=g.next();!T.done;T=g.next()){var A=a(T.value,2),I=A[0],v=A[1],N=v;do{if(!N.isReExport){(f=this.elements.get(N.referencedName))||(f=this.elements.get(N.member.name.text))?this.setExportAndCheckLibrary(I,f,N.member.externalName):this.error(o.DiagnosticCode.Cannot_find_name_0,v.member.range,v.member.name.text);break}if(f=this.exports.get(N.referencedName)){this.setExportAndCheckLibrary(I,f,N.member.externalName);break}(N=t.get(N.referencedName))||this.error(o.DiagnosticCode.Module_0_has_no_exported_member_1,v.member.externalName.range,v.member.parent.path.value,v.member.externalName.text)}while(N)}}catch(e){b={error:e}}finally{try{T&&!T.done&&(k=g.return)&&k.call(g)}finally{if(b)throw b.error}}for(p=0,u=n.length;p<u;++p){var S=n[p].declaration,C=assert(S.extendsType),O=this.resolveIdentifier(C.name,null);if(O){if(O.element.kind!=m.CLASS_PROTOTYPE){this.error(o.DiagnosticCode.A_class_may_only_extend_another_class,C.range);continue}n[p].basePrototype=O.element}}var b,k},r.prototype.tryResolveImport=function(e,t){for(var r;;){if(r=this.exports.get(e))return r;var n=t.get(e);if(!n)return null;{if(!n.isReExport)return this.elements.get(n.referencedName);e=n.referencedName}}},r.prototype.checkInternalDecorators=function(e,t){var r=c.hasDecorator("builtin",t.decorators);r&&e.set(f.BUILTIN),(c.hasDecorator("global",t.decorators)||t.range.source.isLibrary&&e.is(f.EXPORTED)&&(assert(t.parent).kind==c.NodeKind.SOURCE||t.parent.kind==c.NodeKind.VARIABLE&&assert(t.parent.parent).kind==c.NodeKind.SOURCE))&&(e.set(f.GLOBAL),this.elements.has(t.name.text)?this.error(o.DiagnosticCode.Duplicate_identifier_0,t.name.range,e.internalName):(this.elements.set(t.name.text,e),this.exports.set(t.name.text,e),r&&(e.internalName=t.name.text)))},r.prototype.initializeClass=function(e,t,r){void 0===r&&(r=null);var n=e.fileLevelInternalName;if(this.elements.has(n))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,n);var i=new L(this,e.name.text,n,e);if(i.namespace=r,this.elements.set(n,i),this.checkInternalDecorators(i,e),c.hasDecorator("unmanaged",e.decorators))i.isUnmanaged=!0,e.implementsTypes&&e.implementsTypes.length&&this.error(o.DiagnosticCode.Structs_cannot_implement_interfaces,c.Range.join(e.name.range,e.implementsTypes[e.implementsTypes.length-1].range));else if(e.implementsTypes.length)throw new Error("not implemented");if(e.extendsType&&t.push(i),r){if(r.members){if(r.members.has(e.name.text))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else r.members=new Map;r.members.set(e.name.text,i)}else if(i.is(f.EXPORTED)){if(this.exports.has(n))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,n);this.exports.set(n,i)}for(var a=e.members,s=0,p=a.length;s<p;++s){var u=a[s];switch(u.kind){case c.NodeKind.FIELDDECLARATION:this.initializeField(u,i);break;case c.NodeKind.METHODDECLARATION:var l=c.hasModifier(c.ModifierKind.GET,u.modifiers);l||c.hasModifier(c.ModifierKind.SET,u.modifiers)?this.initializeAccessor(u,i,l):this.initializeMethod(u,i);break;default:throw new Error("class member expected")}}if(i.is(f.GLOBAL)&&"String"===e.name.text&&!this.types.has("string")){var h=i.resolve(null);h&&this.types.set("string",h.type)}},r.prototype.initializeField=function(e,t){var r=e.name.text,n=e.fileLevelInternalName;if(c.hasModifier(c.ModifierKind.STATIC,e.modifiers)){if(this.elements.has(n))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,n);if(t.members){if(t.members.has(r))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else t.members=new Map;var i=new v(this,r,n,e,s.Type.void);t.members.set(r,i),this.elements.set(n,i)}else{if(t.instanceMembers){if(t.instanceMembers.has(r))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else t.instanceMembers=new Map;var a=new b(t,r,n,e);t.instanceMembers.set(r,a)}},r.prototype.initializeMethod=function(e,t){var r=e.name.text,n=e.fileLevelInternalName,i=null;if(c.hasModifier(c.ModifierKind.STATIC,e.modifiers)){if(assert(e.name.kind!=c.NodeKind.CONSTRUCTOR),this.elements.has(n))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,n);if(t.members){if(t.members.has(r))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else t.members=new Map;i=new C(this,r,n,e,null),t.members.set(r,i),this.elements.set(n,i)}else{if(t.instanceMembers){if(t.instanceMembers.has(r))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else t.instanceMembers=new Map;i=new C(this,r,n,e,t),e.name.kind==c.NodeKind.CONSTRUCTOR?t.constructorPrototype?this.error(o.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed,e.name.range):(i.set(f.CONSTRUCTOR),t.constructorPrototype=i):t.instanceMembers.set(r,i)}this.checkOperators(e.decorators,i,t)},r.prototype.checkOperators=function(e,t,r){if(e)for(var n=0,i=e.length;n<i;++n){var a=e[n];if(2==a.decoratorKind){if(!t){this.error(o.DiagnosticCode.Operation_not_supported,a.range);continue}var s=a.arguments&&a.arguments.length||0;if(1==s){var p=a.arguments[0];if(p.kind==c.NodeKind.LITERAL&&2==p.literalKind)switch(p.value){case"[]":r.fnIndexedGet=t.simpleName;break;case"[]=":r.fnIndexedSet=t.simpleName;break;case"+":r.fnConcat=t.simpleName;break;case"==":r.fnEquals=t.simpleName;break;default:this.error(o.DiagnosticCode.Operation_not_supported,p.range)}else this.error(o.DiagnosticCode.String_literal_expected,p.range)}else this.error(o.DiagnosticCode.Expected_0_arguments_but_got_1,a.range,"1",s.toString(0))}else 0!=a.decoratorKind&&this.error(o.DiagnosticCode.Operation_not_supported,a.range)}},r.prototype.initializeAccessor=function(e,r,n){var i=e.name.text,a=e.fileLevelInternalName,s=this.elements.get(a);if(s){if(s.kind!=m.PROPERTY||(n?s.getterPrototype:s.setterPrototype))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,a)}else s=new x(this,i,a,r);var p=(n?t.GETTER_PREFIX:t.SETTER_PREFIX)+i;if(c.hasModifier(c.ModifierKind.STATIC,e.modifiers)){var u=r.internalName+t.STATIC_DELIMITER+p;if(this.elements.has(u))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,u);var l=new C(this,p,u,e,null);n?s.getterPrototype=l:s.setterPrototype=l,r.members||(r.members=new Map),r.members.set(i,s),this.elements.set(a,s)}else{var h=r.internalName+t.INSTANCE_DELIMITER+p;if(r.instanceMembers){if(r.instanceMembers.has(p))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,a)}else r.instanceMembers=new Map;var d=new C(this,p,h,e,r);n?s.getterPrototype=d:s.setterPrototype=d,r.instanceMembers.set(p,s),this.elements.set(a,s)}},r.prototype.initializeEnum=function(e,t){void 0===t&&(t=null);var r=e.fileLevelInternalName;if(this.elements.has(r))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);var n=new T(this,e.name.text,r,e);if(n.namespace=t,this.elements.set(r,n),this.checkInternalDecorators(n,e),t){if(t.members){if(t.members.has(e.name.text))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r)}else t.members=new Map;t.members.set(e.name.text,n)}else if(n.is(f.EXPORTED)){if(this.exports.has(r))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,r);this.exports.set(r,n)}for(var i=e.values,a=0,s=i.length;a<s;++a)this.initializeEnumValue(i[a],n)},r.prototype.initializeEnumValue=function(e,t){var r=e.name.text,n=e.fileLevelInternalName;if(t.members){if(t.members.has(r))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else t.members=new Map;var i=new A(t,this,r,n,e);t.members.set(r,i)},r.prototype.initializeExports=function(e,t){for(var r=e.members,n=0,i=r.length;n<i;++n)this.initializeExport(r[n],e.internalPath,t)},r.prototype.setExportAndCheckLibrary=function(e,t,r){this.exports.set(e,t),r.range.source.isLibrary&&(this.elements.has(r.text)?this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,r.range,r.text):(t.internalName=r.text,this.elements.set(r.text,t)))},r.prototype.initializeExport=function(e,r,n){var i=e.range.source.internalPath+t.PATH_DELIMITER+e.externalName.text;if(this.exports.has(i))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.externalName.range,i);var a,s,c;if(null==r){if(a=e.range.source.internalPath+t.PATH_DELIMITER+e.name.text,s=this.elements.get(a))return void this.setExportAndCheckLibrary(i,s,e.externalName);if(n.has(i))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.externalName.range,i);c=new u,c.isReExport=!1,c.referencedName=a,c.member=e,n.set(i,c)}else{if(a=r+t.PATH_DELIMITER+e.name.text,s=this.elements.get(a))return void this.setExportAndCheckLibrary(i,s,e.externalName);for(var p=new Set;c=n.get(a);){if(!c.isReExport){if(s=this.elements.get(c.referencedName))return void this.setExportAndCheckLibrary(i,s,e.externalName);break}if(s=this.exports.get(c.referencedName))return void this.setExportAndCheckLibrary(i,s,e.externalName);if(a=c.referencedName,p.has(c))break;p.add(c)}if(n.has(i))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.externalName.range,i);c=new u,c.isReExport=!0,c.referencedName=a,c.member=e,n.set(i,c)}},r.prototype.initializeFunction=function(e,t){void 0===t&&(t=null);var r=e.fileLevelInternalName;if(this.elements.has(r))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);var n=new C(this,e.name.text,r,e,null);if(n.namespace=t,this.elements.set(r,n),this.checkInternalDecorators(n,e),t){if(t.members){if(t.members.has(e.name.text))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r)}else t.members=new Map;t.members.set(e.name.text,n)}else if(n.is(f.EXPORTED)){if(this.exports.has(r))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,r);this.exports.set(r,n)}},r.prototype.initializeImports=function(e,r,n){var i=e.declarations;if(i)for(var a=0,s=i.length;a<s;++a)this.initializeImport(i[a],e.internalPath,r,n);else if(e.namespaceName){var c=e.range.source.internalPath+t.PATH_DELIMITER+e.namespaceName.text;if(this.elements.has(c))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.namespaceName.range,c);this.error(o.DiagnosticCode.Operation_not_supported,e.range)}},r.prototype.initializeImport=function(e,r,n,i){var a=e.fileLevelInternalName;if(this.elements.has(a))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,a);var s,c=r+t.PATH_DELIMITER+e.externalName.text;if(s=this.exports.get(c))return void this.elements.set(a,s);var p=t.PATH_DELIMITER+"index",u=new l;u.internalName=a,r.endsWith(p)?(u.referencedName=c,u.referencedNameAlt=r.substring(0,r.length-p.length+1)+e.externalName.text):(u.referencedName=c,u.referencedNameAlt=r+p+t.PATH_DELIMITER+e.externalName.text),u.declaration=e,i.push(u)},r.prototype.initializeInterface=function(e,t){void 0===t&&(t=null);var r=e.fileLevelInternalName;if(this.elements.has(r))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);var n=new B(this,e.name.text,r,e);if(n.namespace=t,this.elements.set(r,n),this.checkInternalDecorators(n,e),t){if(t.members){if(t.members.has(n.internalName))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r)}else t.members=new Map;t.members.set(n.internalName,n)}else if(n.is(f.EXPORTED)){if(this.exports.has(r))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,r);this.exports.set(r,n)}for(var i=e.members,a=0,s=i.length;a<s;++a){var p=i[a];switch(p.kind){case c.NodeKind.FIELDDECLARATION:this.initializeField(p,n);break;case c.NodeKind.METHODDECLARATION:var u=c.hasModifier(c.ModifierKind.GET,p.modifiers);u||c.hasModifier(c.ModifierKind.SET,p.modifiers)?this.initializeAccessor(p,n,u):this.initializeMethod(p,n);break;default:throw new Error("interface member expected")}}},r.prototype.initializeNamespace=function(e,t,r){void 0===r&&(r=null);var n=e.fileLevelInternalName,i=this.elements.get(n);if(i||(i=new g(this,e.name.text,n,e),i.namespace=r,this.elements.set(n,i),this.checkInternalDecorators(i,e)),r){if(r.members){if(r.members.has(e.name.text))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else r.members=new Map;r.members.set(e.name.text,i)}else if(i.is(f.EXPORTED)){if(this.exports.has(n))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,n);this.exports.set(n,i)}for(var a=e.members,s=0,p=a.length;s<p;++s)switch(a[s].kind){case c.NodeKind.CLASSDECLARATION:this.initializeClass(a[s],t,i);break;case c.NodeKind.ENUMDECLARATION:this.initializeEnum(a[s],i);break;case c.NodeKind.FUNCTIONDECLARATION:this.initializeFunction(a[s],i);break;case c.NodeKind.INTERFACEDECLARATION:this.initializeInterface(a[s],i);break;case c.NodeKind.NAMESPACEDECLARATION:this.initializeNamespace(a[s],t,i);break;case c.NodeKind.TYPEDECLARATION:this.error(o.DiagnosticCode.Operation_not_supported,a[s].range);break;case c.NodeKind.VARIABLE:this.initializeVariables(a[s],i);break;default:throw new Error("namespace member expected")}},r.prototype.initializeTypeAlias=function(e,t){void 0===t&&(t=null);var r=e.name.text;if(this.types.has(r)||this.typeAliases.has(r))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);this.typeAliases.set(r,e.alias)},r.prototype.initializeVariables=function(e,t){void 0===t&&(t=null);for(var r=e.declarations,n=0,i=r.length;n<i;++n){var a=r[n],c=a.fileLevelInternalName;if(this.elements.has(c))this.error(o.DiagnosticCode.Duplicate_identifier_0,a.name.range,c);else{var p=new v(this,a.name.text,c,a,s.Type.void);if(p.namespace=t,this.elements.set(c,p),this.checkInternalDecorators(p,a),t){if(t.members){if(t.members.has(a.name.text)){this.error(o.DiagnosticCode.Duplicate_identifier_0,a.name.range,c);continue}}else t.members=new Map;t.members.set(a.name.text,p)}else p.is(f.EXPORTED)&&(this.exports.has(c)?this.error(o.DiagnosticCode.Duplicate_identifier_0,a.name.range,c):this.exports.set(c,p))}}},r.prototype.resolveType=function(e,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var i,a=e.name.text,c=e.range.source.internalPath+t.PATH_DELIMITER+e.name.text;if((i=this.elements.get(c))||(i=this.elements.get(a)))switch(i.kind){case m.CLASS_PROTOTYPE:var p=i.resolveInclTypeArguments(e.typeArguments,r,null);return p?p.type:null}for(var u=e.typeArguments.length,l=new Array(u),h=0;h<u;++h){var d=this.resolveType(e.typeArguments[h],r,n);if(!d)return null;l[h]=d}if(u){var _=s.typesToString(l);_.length&&(c+="<"+_+">",a+="<"+_+">")}else if(r){var y=r.get(a);if(y)return y}var f;if((f=this.types.get(c))||(f=this.types.get(a)))return f;var E=this.typeAliases.get(a);return E&&(f=this.resolveType(E,null,n))?f:(n&&this.error(o.DiagnosticCode.Cannot_find_name_0,e.name.range,a),null)},r.prototype.resolveTypeArguments=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null);var i=e.length,a=t?t.length:0;if(i!=a)return a?this.error(o.DiagnosticCode.Expected_0_type_arguments_but_got_1,c.Range.join(t[0].range,t[a-1].range),i.toString(10),a.toString(10)):n&&this.error(o.DiagnosticCode.Expected_0_type_arguments_but_got_1,n.range.atEnd,i.toString(10),"0"),null;for(var s=new Array(i),p=0;p<i;++p){var u=this.resolveType(t[p],r,!0);if(!u)return null;s[p]=u}return s},r.prototype.resolveIdentifier=function(e,r,n){void 0===n&&(n=null);var i,a,s=e.text;if(n){if(n.members&&(i=n.members.get(s))&&i.kind==m.ENUMVALUE)return y||(y=new _),y.set(i)}else if(r){if(i=r.flow.getScopedLocal(s))return y||(y=new _),y.set(i);if(a=r.prototype.namespace)do{if(i=this.elements.get(a.internalName+t.STATIC_DELIMITER+s))return y||(y=new _),y.set(i)}while(a=a.namespace)}return(i=this.elements.get(e.range.source.internalPath+t.PATH_DELIMITER+s))?(y||(y=new _),y.set(i)):(i=this.elements.get(s))?(y||(y=new _),y.set(i)):(this.error(o.DiagnosticCode.Cannot_find_name_0,e.range,s),null)},r.prototype.resolvePropertyAccess=function(e,t){var r=e.expression;if(!(y=this.resolveExpression(r,t)))return null;var n,i,a=y.element,s=e.property.text;switch(a.kind){case m.GLOBAL:case m.LOCAL:case m.FIELD:if(!(n=a.type).classType)return this.error(o.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.property.range,s,n.toString()),null;a=n.classType;break;case m.PROPERTY:var c=assert(a.getterPrototype).resolve();if(!c)return null;if(!(n=c.returnType).classType)return this.error(o.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.property.range,s,n.toString()),null;a=n.classType}switch(a.kind){case m.CLASS_PROTOTYPE:case m.CLASS:for(;;){if(a.members&&(i=a.members.get(s)))return y.set(i).withTarget(a,r);if(a.kind==m.CLASS_PROTOTYPE){if(!a.basePrototype)break;a=a.basePrototype}else{if(a.kind!=m.CLASS)break;if(!a.base)break;a=a.base}}break;default:if(a.members&&(i=a.members.get(s)))return y.set(i).withTarget(a,r)}return this.error(o.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.property.range,s,a.internalName),null},r.prototype.resolveElementAccess=function(e,t){var r=e.expression;if(!(y=this.resolveExpression(r,t)))return null;var n=y.element;switch(n.kind){case m.GLOBAL:case m.LOCAL:case m.FIELD:var i=n.type;if(i.classType){var a,s=(n=i.classType).prototype.fnIndexedGet;if(null!=s&&n.members&&(a=n.members.get(s))&&a.kind==m.FUNCTION_PROTOTYPE)return y.set(a).withTarget(i.classType,r)}}return this.error(o.DiagnosticCode.Index_signature_is_missing_in_type_0,r.range,n.internalName),null},r.prototype.resolveExpression=function(e,t){for(var r;e.kind==c.NodeKind.PARENTHESIZED;)e=e.expression;switch(e.kind){case c.NodeKind.ASSERTION:var n=this.resolveType(e.toType);return n&&(r=n.classType)?(y||(y=new _),y.set(r)):null;case c.NodeKind.BINARY:throw new Error("not implemented");case c.NodeKind.THIS:return(r=t.instanceMethodOf)?(y||(y=new _),y.set(r)):(this.error(o.DiagnosticCode._this_cannot_be_referenced_in_current_location,e.range),null);case c.NodeKind.SUPER:return(r=t.instanceMethodOf)&&(r=r.base)?(y||(y=new _),y.set(r)):(this.error(o.DiagnosticCode._super_can_only_be_referenced_in_a_derived_class,e.range),null);case c.NodeKind.IDENTIFIER:return this.resolveIdentifier(e,t);case c.NodeKind.PROPERTYACCESS:return this.resolvePropertyAccess(e,t);case c.NodeKind.ELEMENTACCESS:return this.resolveElementAccess(e,t);case c.NodeKind.CALL:var i=this.resolveExpression(e.expression,t);if(i){var a=i.element;if(a&&a.kind==m.FUNCTION_PROTOTYPE){var s=a.resolveInclTypeArguments(e.typeArguments,null,e);if(s&&s.returnType.classType)return y||(y=new _),y.set(s.returnType.classType)}}}return this.error(o.DiagnosticCode.Operation_not_supported,e.range),null},r}(o.DiagnosticEmitter);t.Program=d;var _=function(){function e(){}return e.prototype.set=function(e){return this.target=null,this.targetExpression=null,this.element=e,this},e.prototype.withTarget=function(e,t){return this.target=e,this.targetExpression=t,this},e}();t.ResolvedElement=_;var y,m;!function(e){e[e.GLOBAL=0]="GLOBAL",e[e.LOCAL=1]="LOCAL",e[e.ENUM=2]="ENUM",e[e.ENUMVALUE=3]="ENUMVALUE",e[e.FUNCTION_PROTOTYPE=4]="FUNCTION_PROTOTYPE",e[e.FUNCTION=5]="FUNCTION",e[e.CLASS_PROTOTYPE=6]="CLASS_PROTOTYPE",e[e.CLASS=7]="CLASS",e[e.INTERFACE_PROTOTYPE=8]="INTERFACE_PROTOTYPE",e[e.INTERFACE=9]="INTERFACE",e[e.FIELD_PROTOTYPE=10]="FIELD_PROTOTYPE",e[e.FIELD=11]="FIELD",e[e.PROPERTY=12]="PROPERTY",e[e.NAMESPACE=13]="NAMESPACE"}(m=t.ElementKind||(t.ElementKind={}));var f;!function(e){e[e.NONE=0]="NONE",e[e.COMPILED=1]="COMPILED",e[e.IMPORTED=2]="IMPORTED",e[e.EXPORTED=4]="EXPORTED",e[e.BUILTIN=8]="BUILTIN",e[e.DECLARED=16]="DECLARED",e[e.GENERIC=32]="GENERIC",e[e.CONSTANT=64]="CONSTANT",e[e.INLINED=128]="INLINED",e[e.INSTANCE=256]="INSTANCE",e[e.GETTER=512]="GETTER",e[e.SETTER=1024]="SETTER",e[e.GLOBAL=2048]="GLOBAL",e[e.READONLY=4096]="READONLY",e[e.PUBLIC=8192]="PUBLIC",e[e.PROTECTED=16384]="PROTECTED",e[e.PRIVATE=32768]="PRIVATE",e[e.ABSTRACT=65536]="ABSTRACT",e[e.CONSTRUCTOR=131072]="CONSTRUCTOR",e[e.UNMANAGED=262144]="UNMANAGED",e[e.SCOPED=524288]="SCOPED",e[e.START=1048576]="START"}(f=t.ElementFlags||(t.ElementFlags={}));var E=function(){function e(e,t,r){this.flags=f.NONE,this.members=null,this.namespace=null,this.program=e,this.simpleName=t,this.internalName=r}return e.prototype.is=function(e){return(this.flags&e)==e},e.prototype.set=function(e){this.flags|=e},e}();t.Element=E;var g=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n)||this;if(a.kind=m.NAMESPACE,a.declaration=i,a.declaration.modifiers)for(var o=0,s=a.declaration.modifiers.length;o<s;++o)switch(a.declaration.modifiers[o].modifierKind){case c.ModifierKind.IMPORT:a.set(f.IMPORTED);break;case c.ModifierKind.EXPORT:a.set(f.EXPORTED);break;case c.ModifierKind.DECLARE:a.set(f.DECLARED);break;default:throw new Error("unexpected modifier")}return a}return n(t,e),t}(E);t.Namespace=g;var T=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n)||this;if(a.kind=m.ENUM,a.declaration=i,a.declaration.modifiers)for(var o=0,s=a.declaration.modifiers.length;o<s;++o)switch(a.declaration.modifiers[o].modifierKind){case c.ModifierKind.EXPORT:a.set(f.EXPORTED);break;case c.ModifierKind.IMPORT:a.set(f.IMPORTED);break;case c.ModifierKind.DECLARE:a.set(f.DECLARED);break;case c.ModifierKind.CONST:a.set(f.CONSTANT);break;default:throw new Error("unexpected modifier")}return a}return n(t,e),t}(E);t.Enum=T;var A=function(e){function t(t,r,n,i,a){var o=e.call(this,r,n,i)||this;return o.kind=m.ENUMVALUE,o.constantValue=0,o.enum=t,o.declaration=a,o}return n(t,e),t}(E);t.EnumValue=A;!function(e){e[e.NONE=0]="NONE",e[e.INTEGER=1]="INTEGER",e[e.FLOAT=2]="FLOAT"}(t.ConstantValueKind||(t.ConstantValueKind={}));var I=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.constantValueKind=0,t}return n(t,e),t.prototype.withConstantIntegerValue=function(e,t){return this.constantValueKind=1,this.constantIntegerValue=i64_new(e,t),this.set(f.CONSTANT|f.INLINED),this},t.prototype.withConstantFloatValue=function(e){return this.constantValueKind=2,this.constantFloatValue=e,this.set(f.CONSTANT|f.INLINED),this},t}(E);t.VariableLikeElement=I;var v=function(e){function t(t,r,n,i,a){var o=e.call(this,t,r,n)||this;if(o.kind=m.GLOBAL,o.declaration=i,o.declaration.modifiers)for(var s=0,p=o.declaration.modifiers.length;s<p;++s)switch(o.declaration.modifiers[s].modifierKind){case c.ModifierKind.IMPORT:o.set(f.IMPORTED);break;case c.ModifierKind.EXPORT:o.set(f.EXPORTED);break;case c.ModifierKind.CONST:o.set(f.CONSTANT);break;case c.ModifierKind.LET:o.set(f.SCOPED);break;case c.ModifierKind.DECLARE:o.set(f.DECLARED);break;case c.ModifierKind.READONLY:o.set(o.declaration.initializer?f.CONSTANT|f.READONLY:f.READONLY);break;case c.ModifierKind.PUBLIC:case c.ModifierKind.PRIVATE:case c.ModifierKind.PROTECTED:case c.ModifierKind.STATIC:break;default:throw new Error("unexpected modifier")}return o.type=a,o}return n(t,e),t}(I);t.Global=v;var N=function(){function e(e,t,r){void 0===r&&(r=null),this.name=e,this.type=t,this.initializer=r}return e}();t.Parameter=N;var S=function(e){function t(t,r,n,i){var a=e.call(this,t,r,r)||this;return a.kind=m.LOCAL,a.index=n,a.type=i,a}return n(t,e),t}(I);t.Local=S;var C=function(e){function t(t,r,n,i,a){void 0===a&&(a=null);var o=e.call(this,t,r,n)||this;if(o.kind=m.FUNCTION_PROTOTYPE,o.instances=new Map,o.classTypeArguments=null,o.declaration=i,o.declaration.modifiers)for(var s=0,p=o.declaration.modifiers.length;s<p;++s)switch(o.declaration.modifiers[s].modifierKind){case c.ModifierKind.IMPORT:o.set(f.IMPORTED);break;case c.ModifierKind.EXPORT:o.set(f.EXPORTED);break;case c.ModifierKind.DECLARE:o.set(f.DECLARED);break;case c.ModifierKind.GET:o.set(f.GETTER);break;case c.ModifierKind.SET:o.set(f.SETTER);break;case c.ModifierKind.STATIC:case c.ModifierKind.ABSTRACT:case c.ModifierKind.PRIVATE:case c.ModifierKind.PROTECTED:case c.ModifierKind.PUBLIC:break;default:throw new Error("unexpected modifier")}return o.declaration.typeParameters.length&&o.set(f.GENERIC),(o.classPrototype=a)&&o.set(f.INSTANCE),o}return n(t,e),t.prototype.resolve=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var r=e?s.typesToString(e):"",n=this.instances.get(r);if(n)return n;var o=this.declaration,c=t;if(t=new Map,c)try{for(var p=i(c),u=p.next();!u.done;u=p.next()){var l=a(u.value,2),h=l[0],d=l[1];t.set(h,d)}}catch(e){L={error:e}}finally{try{u&&!u.done&&(R=p.return)&&R.call(p)}finally{if(L)throw L.error}}var _,y;if(this.classTypeArguments){if(!this.classPrototype)throw new Error("partially resolved instance method must reference its class prototype");var m=this.classPrototype.declaration,E=m.typeParameters;if((y=this.classTypeArguments.length)!=E.length)throw new Error("type argument count mismatch");for(_=0;_<y;++_)t.set(E[_].name.text,this.classTypeArguments[_])}var g=o.typeParameters;if(e&&(y=e.length)){if(y!=g.length)throw new Error("type argument count mismatch");for(_=0;_<y;++_)t.set(g[_].name.text,e[_])}y=o.parameters.length;var T,A=new Array(y),I=new Array(y);for(_=0;_<y;++_){var v=o.parameters[_];T=assert(v.type);var S=this.program.resolveType(T,t,!0);if(!S)return null;A[_]=new N(v.name.text,S,v.initializer),I[_]=S}var C=this.internalName;r.length&&(C+="<"+r+">");var b=null;if(this.classPrototype&&!(b=this.classPrototype.resolve(this.classTypeArguments,t)))return null;var k;if(this.is(f.SETTER)||this.is(f.CONSTRUCTOR))k=s.Type.void;else{T=assert(o.returnType);var x=this.program.resolveType(T,t,!0);if(!x)return null;k=x}return n=new O(this,C,e,A,k,b),n.contextualTypeArguments=t,this.instances.set(r,n),n;var L,R},t.prototype.resolveInclTypeArguments=function(e,t,r){var n=null;return!this.is(f.GENERIC)||(assert(null!=e&&0!=e.length),n=this.program.resolveTypeArguments(this.declaration.typeParameters,e,t,r))?this.resolve(n,t):null},t.prototype.resolvePartial=function(e){if(!this.classPrototype)throw new Error("partially resolved instance method must reference its class prototype");if(e&&e.length){var r=new t(this.program,this.simpleName,this.internalName,this.declaration,this.classPrototype);return r.flags=this.flags,r.classTypeArguments=e,r}return this},t.prototype.toString=function(){return this.simpleName},t}(E);t.FunctionPrototype=C;var O=function(e){function t(t,r,n,o,s,c){void 0===c&&(c=null);var p=e.call(this,t.program,t.simpleName,r)||this;if(p.kind=m.FUNCTION,p.locals=new Map,p.additionalLocals=[],p.breakContext=null,p.debugLocations=null,p.nextBreakId=0,p.breakStack=null,p.tempI32s=null,p.tempI64s=null,p.tempF32s=null,p.tempF64s=null,p.prototype=t,p.typeArguments=n,p.parameters=o||[],p.returnType=s,p.instanceMethodOf=c,p.flags=t.flags,!t.is(f.BUILTIN)&&!t.is(f.DECLARED)){var u=0;if(c){if(assert(p.is(f.INSTANCE)),p.locals.set("this",new S(t.program,"this",u++,c.type)),c.contextualTypeArguments){p.contextualTypeArguments||(p.contextualTypeArguments=new Map);try{for(var l=i(c.contextualTypeArguments),h=l.next();!h.done;h=l.next()){var d=a(h.value,2),_=d[0],y=d[1];p.contextualTypeArguments.set(_,y)}}catch(e){I={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(I)throw I.error}}}}else assert(!p.is(f.INSTANCE));for(var E=0,g=p.parameters.length;E<g;++E){var T=p.parameters[E],A=assert(T.name,"parameter must be named");p.locals.set(A,new S(t.program,A,u++,T.type))}}return p.flow=U.create(p),p;var I,v}return n(t,e),t.prototype.addLocal=function(e,t){void 0===t&&(t=null);var r=(this.parameters?this.parameters.length:0)+this.additionalLocals.length;this.is(f.INSTANCE)&&r++;var n=new S(this.prototype.program,t||"var$"+r.toString(10),r,e);if(t){if(this.locals.has(t))throw new Error("duplicate local name");this.locals.set(t,n)}return this.additionalLocals.push(e),n},t.prototype.getTempLocal=function(e){var t;switch(e.toNativeType()){case p.NativeType.I32:t=this.tempI32s;break;case p.NativeType.I64:t=this.tempI64s;break;case p.NativeType.F32:t=this.tempF32s;break;case p.NativeType.F64:t=this.tempF64s;break;default:throw new Error("concrete type expected")}if(t&&t.length){var r=t.pop();return r.type=e,r}return this.addLocal(e)},t.prototype.freeTempLocal=function(e){var t;switch(assert(null!=e.type),e.type.toNativeType()){case p.NativeType.I32:t=this.tempI32s||(this.tempI32s=[]);break;case p.NativeType.I64:t=this.tempI64s||(this.tempI64s=[]);break;case p.NativeType.F32:t=this.tempF32s||(this.tempF32s=[]);break;case p.NativeType.F64:t=this.tempF64s||(this.tempF64s=[]);break;default:throw new Error("concrete type expected")}t.push(e)},t.prototype.getAndFreeTempLocal=function(e){var t;switch(e.toNativeType()){case p.NativeType.I32:t=this.tempI32s||(this.tempI32s=[]);break;case p.NativeType.I64:t=this.tempI64s||(this.tempI64s=[]);break;case p.NativeType.F32:t=this.tempF32s||(this.tempF32s=[]);break;case p.NativeType.F64:t=this.tempF64s||(this.tempF64s=[]);break;default:throw new Error("concrete type expected")}if(t.length>0)return t[t.length-1];var r=this.addLocal(e);return t.push(r),r},t.prototype.enterBreakContext=function(){var e=this.nextBreakId++;return this.breakStack?this.breakStack.push(e):this.breakStack=[e],this.breakContext=e.toString(10)},t.prototype.leaveBreakContext=function(){assert(null!=this.breakStack);var e=this.breakStack.length;assert(e>0),this.breakStack.pop(),e>1?this.breakContext=this.breakStack[e-2].toString(10):(this.breakContext=null,this.breakStack=null)},t.prototype.finalize=function(e,t){if(assert(!this.breakStack||!this.breakStack.length),this.breakStack=null,this.breakContext=null,this.tempI32s=this.tempI64s=this.tempF32s=this.tempF64s=null,this.program.options.sourceMap){var r=this.debugLocations;if(r)for(var n=0,i=r.length;n<i;++n){var a=r[n];e.setDebugLocation(t,a.debugInfoRef,a.source.debugInfoIndex,a.line,a.column)}}this.debugLocations=null},t.prototype.toString=function(){return this.prototype.simpleName},t.prototype.toTypeString=function(){throw new Error("not implemented")},t}(E);t.Function=O;var b=function(e){function t(t,r,n,i){var a=e.call(this,t.program,r,n)||this;if(a.kind=m.FIELD_PROTOTYPE,a.classPrototype=t,a.declaration=i,a.declaration.modifiers)for(var o=0,s=a.declaration.modifiers.length;o<s;++o)switch(a.declaration.modifiers[o].modifierKind){case c.ModifierKind.EXPORT:a.set(f.EXPORTED);break;case c.ModifierKind.READONLY:a.set(f.READONLY);break;case c.ModifierKind.PRIVATE:case c.ModifierKind.PROTECTED:case c.ModifierKind.PUBLIC:case c.ModifierKind.STATIC:break;default:throw new Error("unexpected modifier")}return a}return n(t,e),Object.defineProperty(t.prototype,"isReadonly",{get:function(){return 0!=(this.flags&f.READONLY)},set:function(e){e?this.flags|=f.READONLY:this.flags&=~f.READONLY},enumerable:!0,configurable:!0}),t}(E);t.FieldPrototype=b;var k=function(e){function t(t,r,n){var i=e.call(this,t.program,t.simpleName,r)||this;return i.kind=m.FIELD,i.memoryOffset=-1,i.prototype=t,i.flags=t.flags,i.type=n,i}return n(t,e),t}(I);t.Field=k;var x=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n)||this;return a.kind=m.PROPERTY,a.getterPrototype=null,a.setterPrototype=null,a.parent=i,a}return n(t,e),t}(E);t.Property=x;var L=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n)||this;if(a.kind=m.CLASS_PROTOTYPE,a.instances=new Map,a.instanceMembers=null,a.basePrototype=null,a.constructorPrototype=null,a.fnIndexedGet=null,a.fnIndexedSet=null,a.fnConcat=null,a.fnEquals=null,a.declaration=i,a.declaration.modifiers)for(var o=0,s=a.declaration.modifiers.length;o<s;++o)switch(a.declaration.modifiers[o].modifierKind){case c.ModifierKind.IMPORT:a.set(f.IMPORTED);break;case c.ModifierKind.EXPORT:a.set(f.EXPORTED);break;case c.ModifierKind.DECLARE:a.set(f.DECLARED);break;default:throw new Error("unexpected modifier")}return a.declaration.typeParameters.length&&a.set(f.GENERIC),a}return n(t,e),Object.defineProperty(t.prototype,"isUnmanaged",{get:function(){return 0!=(this.flags&f.UNMANAGED)},set:function(e){e?this.flags|=f.UNMANAGED:this.flags&=~f.UNMANAGED},enumerable:!0,configurable:!0}),t.prototype.resolve=function(e,t){void 0===t&&(t=null);var r=e?s.typesToString(e):"",n=this.instances.get(r);if(n)return n;var p=t;if(t=new Map,p)try{for(var u=i(p),l=u.next();!l.done;l=u.next()){var h=a(l.value,2),d=h[0],_=h[1];t.set(d,_)}}catch(e){P={error:e}}finally{try{l&&!l.done&&(M=u.return)&&M.call(u)}finally{if(P)throw P.error}}var y=this.declaration,f=null;if(y.extendsType){var E=this.program.resolveType(y.extendsType,null);if(!E)return null;if(!(f=E.classType))return this.program.error(o.DiagnosticCode.A_class_may_only_extend_another_class,y.extendsType.range),null;if(f.prototype.isUnmanaged!=this.isUnmanaged)return this.program.error(o.DiagnosticCode.Structs_cannot_extend_classes_and_vice_versa,c.Range.join(y.name.range,y.extendsType.range)),null}var g,T;if(e){if((T=e.length)!=y.typeParameters.length)throw new Error("type argument count mismatch");for(g=0;g<T;++g)t.set(y.typeParameters[g].name.text,e[g])}else if(y.typeParameters.length)throw new Error("type argument count mismatch");var A=this.internalName;r.length&&(A+="<"+r+">"),n=new R(this,A,e,f),n.contextualTypeArguments=t,this.instances.set(r,n);var I=0;if(f&&(I=f.currentMemoryOffset,f.members)){n.members||(n.members=new Map);try{for(var v=i(f.members.values()),N=v.next();!N.done;N=v.next()){var S=N.value;n.members.set(S.simpleName,S)}}catch(e){G={error:e}}finally{try{N&&!N.done&&(K=v.return)&&K.call(v)}finally{if(G)throw G.error}}}if(this.constructorPrototype){var C=this.constructorPrototype.resolvePartial(e);C&&(n.constructorInstance=C.resolve())}if(this.instanceMembers)try{for(var O=i(this.instanceMembers.values()),b=O.next();!b.done;b=O.next()){var L=b.value;switch(L.kind){case m.FIELD_PROTOTYPE:n.members||(n.members=new Map);var B=L.declaration;if(!B.type)throw new Error("type expected");var F=this.program.resolveType(B.type,n.contextualTypeArguments);if(F){var U=new k(L,L.internalName,F);switch(F.byteSize){case 1:break;case 2:1&I&&++I;break;case 4:3&I&&(I=1+(3|I));break;case 8:7&I&&(I=1+(7|I));break;default:assert(!1)}U.memoryOffset=I,I+=F.byteSize,n.members.set(L.simpleName,U)}break;case m.FUNCTION_PROTOTYPE:n.members||(n.members=new Map);var D=L.resolvePartial(e);D&&n.members.set(L.simpleName,D);break;case m.PROPERTY:n.members||(n.members=new Map),assert(L.getterPrototype);var w=new x(this.program,L.simpleName,L.internalName,this);w.getterPrototype=L.getterPrototype.resolvePartial(e),L.setterPrototype&&(w.setterPrototype=L.setterPrototype.resolvePartial(e)),n.members.set(L.simpleName,w);break;default:throw new Error("instance member expected")}}}catch(e){z={error:e}}finally{try{b&&!b.done&&(H=O.return)&&H.call(O)}finally{if(z)throw z.error}}return n.currentMemoryOffset=I,n;var P,M,G,K,z,H},t.prototype.resolveInclTypeArguments=function(e,t,r){var n=null;if(this.is(f.GENERIC)){if(assert(null!=e&&0!=e.length),!(n=this.program.resolveTypeArguments(this.declaration.typeParameters,e,t,r)))return null}else assert(null==e||!e.length);return this.resolve(n,t)},t.prototype.toString=function(){return this.simpleName},t}(E);t.ClassPrototype=L;var R=function(e){function t(t,r,n,o){void 0===n&&(n=null),void 0===o&&(o=null);var s=e.call(this,t.program,t.simpleName,r)||this;if(s.kind=m.CLASS,s.contextualTypeArguments=null,s.currentMemoryOffset=0,s.constructorInstance=null,s.prototype=t,s.flags=t.flags,s.typeArguments=n,s.type=t.program.options.usizeType.asClass(s),s.base=o,o&&o.contextualTypeArguments){s.contextualTypeArguments||(s.contextualTypeArguments=new Map);try{for(var c=i(o.contextualTypeArguments),p=c.next();!p.done;p=c.next()){var u=a(p.value,2),l=u[0],h=u[1];s.contextualTypeArguments.set(l,h)}}catch(e){E={error:e}}finally{try{p&&!p.done&&(g=c.return)&&g.call(c)}finally{if(E)throw E.error}}}var d,_,y=s.prototype.declaration;if(y){var f=y.typeParameters;if(n){if((_=n.length)!=f.length)throw new Error("type argument count mismatch");if(_)for(s.contextualTypeArguments||(s.contextualTypeArguments=new Map),d=0;d<_;++d)s.contextualTypeArguments.set(f[d].name.text,n[d])}else if(f.length)throw new Error("type argument count mismatch")}return s;var E,g}return n(t,e),t.prototype.toString=function(){return this.prototype.simpleName},t}(E);t.Class=R;var B=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n,i)||this;return a.kind=m.INTERFACE_PROTOTYPE,a}return n(t,e),t}(L);t.InterfacePrototype=B;var F=function(e){function t(t,r,n,i){void 0===n&&(n=[]),void 0===i&&(i=null);var a=e.call(this,t,r,n,i)||this;return a.kind=m.INTERFACE,a}return n(t,e),t}(R);t.Interface=F;!function(e){e[e.NONE=0]="NONE",e[e.RETURNS=1]="RETURNS",e[e.POSSIBLY_THROWS=2]="POSSIBLY_THROWS",e[e.POSSIBLY_BREAKS=4]="POSSIBLY_BREAKS",e[e.POSSIBLY_CONTINUES=8]="POSSIBLY_CONTINUES"}(t.FlowFlags||(t.FlowFlags={}));var U=function(){function e(){this.scopedLocals=null}return e.create=function(t){var r=new e;return r.parent=null,r.flags=0,r.currentFunction=t,r.continueLabel=null,r.breakLabel=null,r},e.prototype.is=function(e){return(this.flags&e)==e},e.prototype.set=function(e){this.flags|=e},e.prototype.enterBranchOrScope=function(){var t=new e;return t.parent=this,t.flags=this.flags,t.currentFunction=this.currentFunction,t.continueLabel=this.continueLabel,t.breakLabel=this.breakLabel,t},e.prototype.leaveBranchOrScope=function(){var e=assert(this.parent);if(this.scopedLocals){try{for(var t=i(this.scopedLocals.values()),r=t.next();!r.done;r=t.next()){var n=r.value;this.currentFunction.freeTempLocal(n)}}catch(e){a={error:e}}finally{try{r&&!r.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}this.scopedLocals=null}return this.is(2)&&e.set(2),this.is(4)&&e.breakLabel==this.breakLabel&&e.set(4),this.is(8)&&e.continueLabel==this.continueLabel&&e.set(8),e;var a,o},e.prototype.addScopedLocal=function(e,t,r){var n=this.currentFunction.getTempLocal(t);if(this.scopedLocals){if(this.scopedLocals.has(e))return void this.currentFunction.program.error(o.DiagnosticCode.Duplicate_identifier_0,r.range)}else this.scopedLocals=new Map;this.scopedLocals.set(e,n)},e.prototype.getScopedLocal=function(e){var t,r=this;do{if(r.scopedLocals&&(t=r.scopedLocals.get(e)))return t}while(r=r.parent);return this.currentFunction.locals.get(e)},e.prototype.finalize=function(){return assert(null==this.parent,"must be the topmost parent flow"),this.continueLabel=null,this.breakLabel=null,this.is(1)},e}();t.Flow=U},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";function n(e,t,r){switch(t.kind){case 0:e=r.createBinary(l.BinaryOp.ShrI32,r.createBinary(l.BinaryOp.ShlI32,e,r.createI32(24)),r.createI32(24));break;case 1:e=r.createBinary(l.BinaryOp.ShrI32,r.createBinary(l.BinaryOp.ShlI32,e,r.createI32(16)),r.createI32(16));break;case 5:e=r.createBinary(l.BinaryOp.AndI32,e,r.createI32(255));break;case 6:e=r.createBinary(l.BinaryOp.AndI32,e,r.createI32(65535));break;case 10:e=r.createBinary(l.BinaryOp.AndI32,e,r.createI32(1));break;case 13:throw new Error("concrete type expected")}return e}function i(e,t,r){switch(t.kind){default:e=r.createUnary(l.UnaryOp.EqzI32,e);break;case 3:case 8:e=r.createUnary(l.UnaryOp.EqzI64,e);break;case 9:case 4:e=r.createUnary(64==t.size?l.UnaryOp.EqzI64:l.UnaryOp.EqzI32,e);break;case 11:e=r.createBinary(l.BinaryOp.EqF32,e,r.createF32(0));break;case 12:e=r.createBinary(l.BinaryOp.EqF64,e,r.createF64(0));break;case 13:throw new Error("concrete type expected")}return e}function a(e,t,r){switch(t.kind){default:e=r.createBinary(l.BinaryOp.NeI32,e,r.createI32(0));break;case 3:case 8:e=r.createBinary(l.BinaryOp.NeI64,e,r.createI64(0));break;case 9:case 4:e=64==t.size?r.createBinary(l.BinaryOp.NeI64,e,r.createI64(0)):r.createBinary(l.BinaryOp.NeI32,e,r.createI32(0));break;case 11:e=r.createBinary(l.BinaryOp.NeF32,e,r.createF32(0));break;case 12:e=r.createBinary(l.BinaryOp.NeF64,e,r.createF64(0));break;case 13:throw new Error("concrete type expected")}return e}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),s=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};Object.defineProperty(t,"__esModule",{value:!0});var c,p=r(16),u=r(1),l=r(0),h=r(2),d=r(7),_=r(6),y=r(5);!function(e){e[e.WASM32=0]="WASM32",e[e.WASM64=1]="WASM64"}(c=t.Target||(t.Target={}));var m=function(){function e(){this.target=c.WASM32,this.noTreeShaking=!1,this.noAssert=!1,this.noMemory=!1,this.memoryBase=0,this.allocateImpl="allocate_memory",this.freeImpl="free_memory",this.sourceMap=!1}return Object.defineProperty(e.prototype,"isWasm64",{get:function(){return this.target==c.WASM64},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usizeType",{get:function(){return this.target==c.WASM64?y.Type.usize64:y.Type.usize32},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isizeType",{get:function(){return this.target==c.WASM64?y.Type.isize64:y.Type.isize32},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nativeSizeType",{get:function(){return this.target==c.WASM64?l.NativeType.I64:l.NativeType.I32},enumerable:!0,configurable:!0}),e}();t.Options=m;!function(e){e[e.NONE=0]="NONE",e[e.IMPLICIT=1]="IMPLICIT",e[e.EXPLICIT=2]="EXPLICIT"}(t.ConversionKind||(t.ConversionKind={}));var f=function(e){function t(t,r){void 0===r&&(r=null);var n=e.call(this,t.diagnostics)||this;return n.startFunctionBody=new Array,n.currentEnum=null,n.currentType=y.Type.void,n.memorySegments=new Array,n.stringSegments=new Map,n.files=new Set,n.program=t,n.options=r||new m,n.memoryOffset=i64_new(max(n.options.memoryBase,n.options.usizeType.byteSize)),n.module=l.Module.create(),n}return o(t,e),t.compile=function(e,r){return void 0===r&&(r=null),new t(e,r).compile()},t.prototype.compile=function(){this.program.initialize(this.options);var e=assert(this.program.elements.get("start"));assert(e.kind==h.ElementKind.FUNCTION_PROTOTYPE);var t=new h.Function(e,e.internalName,null,null,y.Type.void);t.set(h.ElementFlags.START),this.currentFunction=this.startFunction=t;for(var r=this.program.sources,n=0,i=r.length;n<i;++n)r[n].isEntry&&this.compileSource(r[n]);if(this.startFunctionBody.length){var a=this.module.getFunctionTypeBySignature(l.NativeType.None,[]);a||(a=this.module.addFunctionType("v",l.NativeType.None,[]));var o;this.module.setStart(o=this.module.addFunction(this.startFunction.prototype.internalName,a,y.typesToNativeTypes(this.startFunction.additionalLocals),this.module.createBlock(null,this.startFunctionBody))),this.startFunction.finalize(this.module,o)}if(!this.options.noMemory){var s=this.memoryOffset;s=i64_align(s,this.options.usizeType.byteSize),this.memoryOffset=s,this.options.isWasm64?this.module.addGlobal("HEAP_BASE",l.NativeType.I64,!1,this.module.createI64(i64_low(s),i64_high(s))):this.module.addGlobal("HEAP_BASE",l.NativeType.I32,!1,this.module.createI32(i64_low(s)));var c=i64_shr_u(i64_align(s,65536),i64_new(16,0));this.module.setMemory(i64_low(c),l.Module.MAX_MEMORY_WASM32,this.memorySegments,this.options.target,"memory")}return this.module},t.prototype.compileSourceByPath=function(e,t){for(var r,n=this.program.sources,i=e+".ts",a=0,o=n.length;a<o;++a)if(r=n[a],r.normalizedPath==i)return void this.compileSource(r);for(i=e+"/index.ts",a=0,o=n.length;a<o;++a)if(r=n[a],r.normalizedPath==i)return void this.compileSource(r);for(i=h.LIBRARY_PREFIX+e+".ts",a=0,o=n.length;a<o;++a)if(r=n[a],r.normalizedPath==i)return void this.compileSource(r);this.error(u.DiagnosticCode.File_0_not_found,t.range,e)},t.prototype.compileSource=function(e){var t=this.files;if(!t.has(e.normalizedPath)){t.add(e.normalizedPath);for(var r=this.options.noTreeShaking,n=e.isEntry,i=this.startFunctionBody,a=e.statements,o=0,s=a.length;o<s;++o){var c=a[o];switch(c.kind){case _.NodeKind.CLASSDECLARATION:(r||n&&_.hasModifier(_.ModifierKind.EXPORT,c.modifiers))&&!c.typeParameters.length&&this.compileClassDeclaration(c,[]);break;case _.NodeKind.ENUMDECLARATION:(r||n&&_.hasModifier(_.ModifierKind.EXPORT,c.modifiers))&&this.compileEnumDeclaration(c);break;case _.NodeKind.FUNCTIONDECLARATION:(r||n&&_.hasModifier(_.ModifierKind.EXPORT,c.modifiers))&&!c.typeParameters.length&&this.compileFunctionDeclaration(c,[]);break;case _.NodeKind.IMPORT:this.compileSourceByPath(c.normalizedPath,c.path);break;case _.NodeKind.NAMESPACEDECLARATION:(r||n&&_.hasModifier(_.ModifierKind.EXPORT,c.modifiers))&&this.compileNamespaceDeclaration(c);break;case _.NodeKind.VARIABLE:var p=this.compileVariableStatement(c);p&&i.push(p);break;case _.NodeKind.EXPORT:null!=c.normalizedPath&&this.compileSourceByPath(c.normalizedPath,c.path),(r||n)&&this.compileExportStatement(c);break;default:var u=this.currentFunction;this.currentFunction=this.startFunction;var l=this.compileStatement(c);this.startFunctionBody.push(l),this.currentFunction=u}}}},t.prototype.compileGlobalDeclaration=function(e){var t=this.program.elements.get(e.fileLevelInternalName);if(!t||t.kind!=h.ElementKind.GLOBAL)throw new Error("global expected");return this.compileGlobal(t)?t:null},t.prototype.compileGlobal=function(e){if(e.is(h.ElementFlags.COMPILED)||e.is(h.ElementFlags.BUILTIN))return!0;var t=e.declaration,r=0;if(e.type==y.Type.void)if(t.type){var n=this.program.resolveType(t.type);if(!n)return!1;if(n==y.Type.void)return this.error(u.DiagnosticCode.Type_0_is_not_assignable_to_type_1,t.type.range,"*",n.toString()),!1;e.type=n}else{if(!t.initializer)return this.error(u.DiagnosticCode.Type_expected,t.name.range.atEnd),!1;if(r=this.compileExpression(t.initializer,y.Type.void,0),this.currentType==y.Type.void)return this.error(u.DiagnosticCode.Type_0_is_not_assignable_to_type_1,t.initializer.range,this.currentType.toString(),"<auto>"),!1;e.type=this.currentType}var i=e.type.toNativeType();if(e.is(h.ElementFlags.DECLARED))return e.is(h.ElementFlags.CONSTANT)?(this.module.addGlobalImport(e.internalName,e.namespace?e.namespace.simpleName:"env",e.simpleName,i),e.set(h.ElementFlags.COMPILED),!0):(this.error(u.DiagnosticCode.Operation_not_supported,t.range),!1);var a=!1;e.is(h.ElementFlags.INLINED)?r=this.compileInlineConstant(e,e.type):t.initializer?(r||(r=this.compileExpression(t.initializer,e.type)),_BinaryenExpressionGetId(r)!=l.ExpressionId.Const&&(e.is(h.ElementFlags.CONSTANT)?(r=this.precomputeExpressionRef(r),_BinaryenExpressionGetId(r)!=l.ExpressionId.Const&&(this.warning(u.DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable,t.range),a=!0)):a=!0)):r=e.type.toNativeZero(this.module);var o=e.internalName;if(a){this.module.addGlobal(o,i,!0,e.type.toNativeZero(this.module));var s=this.module.createSetGlobal(o,r);this.startFunctionBody.push(s)}else if(e.is(h.ElementFlags.CONSTANT)){var c=_BinaryenExpressionGetType(r);switch(c){case l.NativeType.I32:e.constantValueKind=1,e.constantIntegerValue=i64_new(_BinaryenConstGetValueI32(r),0);break;case l.NativeType.I64:e.constantValueKind=1,e.constantIntegerValue=i64_new(_BinaryenConstGetValueI64Low(r),_BinaryenConstGetValueI64High(r));break;case l.NativeType.F32:e.constantValueKind=2,e.constantFloatValue=_BinaryenConstGetValueF32(r);break;case l.NativeType.F64:e.constantValueKind=2,e.constantFloatValue=_BinaryenConstGetValueF64(r);break;default:throw new Error("concrete type expected")}e.set(h.ElementFlags.INLINED),t.isTopLevel&&this.module.addGlobal(o,i,!e.is(h.ElementFlags.CONSTANT),r),t.range.source.isEntry&&t.isTopLevelExport&&this.module.addGlobalExport(e.internalName,t.programLevelInternalName)}else this.module.addGlobal(o,i,!e.is(h.ElementFlags.CONSTANT),r);return e.set(h.ElementFlags.COMPILED),!0},t.prototype.compileEnumDeclaration=function(e){var t=this.program.elements.get(e.fileLevelInternalName);if(!t||t.kind!=h.ElementKind.ENUM)throw new Error("enum expected");return this.compileEnum(t)?t:null},t.prototype.compileEnum=function(e){if(e.is(h.ElementFlags.COMPILED))return!0;e.set(h.ElementFlags.COMPILED),this.currentEnum=e;var t=null;if(e.members)try{for(var r=s(e.members.values()),n=r.next();!n.done;n=r.next()){var i=n.value;if(i.kind==h.ElementKind.ENUMVALUE){var a=!1,o=i,c=o.declaration;if(o.set(h.ElementFlags.COMPILED),o.is(h.ElementFlags.INLINED))e.declaration.isTopLevelExport&&this.module.addGlobal(o.internalName,l.NativeType.I32,!1,this.module.createI32(o.constantValue));else{var p;if(c.value?(p=this.compileExpression(c.value,y.Type.i32),_BinaryenExpressionGetId(p)!=l.ExpressionId.Const&&(p=this.precomputeExpressionRef(p),_BinaryenExpressionGetId(p)!=l.ExpressionId.Const&&(e.is(h.ElementFlags.CONSTANT)&&this.warning(u.DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable,c.range),a=!0))):null==t?p=this.module.createI32(0):t.is(h.ElementFlags.INLINED)?p=this.module.createI32(t.constantValue+1):(p=this.module.createBinary(l.BinaryOp.AddI32,this.module.createGetGlobal(t.internalName,l.NativeType.I32),this.module.createI32(1)),e.is(h.ElementFlags.CONSTANT)&&this.warning(u.DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable,c.range),a=!0),a){this.module.addGlobal(o.internalName,l.NativeType.I32,!0,this.module.createI32(0));var d=this.module.createSetGlobal(o.internalName,p);this.startFunctionBody.push(d)}else{if(this.module.addGlobal(o.internalName,l.NativeType.I32,!1,p),_BinaryenExpressionGetType(p)!=l.NativeType.I32)throw new Error("i32 expected");o.constantValue=_BinaryenConstGetValueI32(p),o.set(h.ElementFlags.INLINED)}}t=o,e.declaration.range.source.isEntry&&e.declaration.isTopLevelExport&&(i.is(h.ElementFlags.INLINED)?this.module.addGlobalExport(i.internalName,i.internalName):c&&this.warning(u.DiagnosticCode.Cannot_export_a_mutable_global,c.range))}}}catch(e){_={error:e}}finally{try{n&&!n.done&&(m=r.return)&&m.call(r)}finally{if(_)throw _.error}}return this.currentEnum=null,!0;var _,m},t.prototype.compileFunctionDeclaration=function(e,t,r){void 0===r&&(r=null);var n=this.program.elements.get(e.fileLevelInternalName);if(!n||n.kind!=h.ElementKind.FUNCTION_PROTOTYPE)throw new Error("function expected");return this.compileFunctionUsingTypeArguments(n,t,r,n.declaration.name)},t.prototype.compileFunctionUsingTypeArguments=function(e,t,r,n){var i=e.resolveInclTypeArguments(t,r,n);return i&&this.compileFunction(i)?i:null},t.prototype.compileFunction=function(e){if(e.is(h.ElementFlags.COMPILED))return!0;assert(!e.is(h.ElementFlags.BUILTIN)||"abort"==e.simpleName);var t=e.prototype.declaration;if(e.is(h.ElementFlags.DECLARED)){if(t.statements)return this.error(u.DiagnosticCode.An_implementation_cannot_be_declared_in_ambient_contexts,t.name.range),!1}else if(!t.statements)return this.error(u.DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration,t.name.range),!1;e.set(h.ElementFlags.COMPILED);var r=null;if(!e.is(h.ElementFlags.DECLARED)){var n=this.currentFunction;this.currentFunction=e;var i=assert(t.statements,"implementation expected");r=this.compileStatements(i);var a=this.currentFunction.flow.finalize();e.returnType==y.Type.void||a||this.error(u.DiagnosticCode.A_function_whose_declared_type_is_not_void_must_return_a_value,assert(t.returnType,"return type expected").range),this.currentFunction=n}var o=e.parameters?e.parameters.length:0,s=e.instanceMethodOf?o+1:o,c=0,p=e.returnType.toNativeType(),d=new Array(s),_=new Array(s+1);if(e.instanceMethodOf&&(d[c]=this.options.isWasm64?l.NativeType.I64:l.NativeType.I32,_[c++]=e.instanceMethodOf.type.toSignatureString()),e.parameters)for(var m=0;m<o;++m)d[c]=e.parameters[m].type.toNativeType(),_[c++]=e.parameters[m].type.toSignatureString();_[c]=e.returnType.toSignatureString();var f=this.module.getFunctionTypeBySignature(p,d);f||(f=this.module.addFunctionType(_.join(""),p,d));var E;return E=e.is(h.ElementFlags.DECLARED)?this.module.addFunctionImport(e.internalName,e.prototype.namespace?e.prototype.namespace.simpleName:"env",e.simpleName,f):this.module.addFunction(e.internalName,f,y.typesToNativeTypes(e.additionalLocals),this.module.createBlock(null,r,l.NativeType.None)),t.range.source.isEntry&&t.isTopLevelExport&&this.module.addFunctionExport(e.internalName,t.name.text),e.finalize(this.module,E),!0},t.prototype.compileNamespaceDeclaration=function(e){for(var t=e.members,r=this.options.noTreeShaking,n=0,i=t.length;n<i;++n){var a=t[n];switch(a.kind){case _.NodeKind.CLASSDECLARATION:!r&&!_.hasModifier(_.ModifierKind.EXPORT,a.modifiers)||a.typeParameters.length||this.compileClassDeclaration(a,[]);break;case _.NodeKind.INTERFACEDECLARATION:!r&&!_.hasModifier(_.ModifierKind.EXPORT,a.modifiers)||a.typeParameters.length||this.compileInterfaceDeclaration(a,[]);break;case _.NodeKind.ENUMDECLARATION:(r||_.hasModifier(_.ModifierKind.EXPORT,a.modifiers))&&this.compileEnumDeclaration(a);break;case _.NodeKind.FUNCTIONDECLARATION:!r&&!_.hasModifier(_.ModifierKind.EXPORT,a.modifiers)||a.typeParameters.length||this.compileFunctionDeclaration(a,[]);break;case _.NodeKind.NAMESPACEDECLARATION:(r||_.hasModifier(_.ModifierKind.EXPORT,a.modifiers))&&this.compileNamespaceDeclaration(a);break;case _.NodeKind.VARIABLE:if(r||_.hasModifier(_.ModifierKind.EXPORT,a.modifiers)){var o=this.compileVariableStatement(a,!0);o&&this.startFunctionBody.push(o)}break;default:throw new Error("namespace member expected")}}},t.prototype.compileNamespace=function(e){if(e.members){var t=this.options.noTreeShaking;try{for(var r=s(e.members.values()),n=r.next();!n.done;n=r.next()){var i=n.value;switch(i.kind){case h.ElementKind.CLASS_PROTOTYPE:!t&&!i.is(h.ElementFlags.EXPORTED)||i.is(h.ElementFlags.GENERIC)||this.compileClassUsingTypeArguments(i,[]);break;case h.ElementKind.ENUM:this.compileEnum(i);break;case h.ElementKind.FUNCTION_PROTOTYPE:!t&&!i.is(h.ElementFlags.EXPORTED)||i.is(h.ElementFlags.GENERIC)||this.compileFunctionUsingTypeArguments(i,[],null,i.declaration.name);break;case h.ElementKind.GLOBAL:this.compileGlobal(i);break;case h.ElementKind.NAMESPACE:this.compileNamespace(i)}}}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(a)throw a.error}}var a,o}},t.prototype.compileExportStatement=function(e){for(var t=e.members,r=0,n=t.length;r<n;++r){var i=t[r],a=e.range.source.internalPath+h.PATH_DELIMITER+i.externalName.text,o=this.program.exports.get(a);if(o)switch(o.kind){case h.ElementKind.CLASS_PROTOTYPE:o.is(h.ElementFlags.GENERIC)||this.compileClassUsingTypeArguments(o,[]);break;case h.ElementKind.ENUM:this.compileEnum(o);break;case h.ElementKind.FUNCTION_PROTOTYPE:if(!o.is(h.ElementFlags.GENERIC)&&e.range.source.isEntry){var s=this.compileFunctionUsingTypeArguments(o,[],null,o.declaration.name);if(s){var c=s.prototype.declaration;c&&c.needsExplicitExport(i)&&this.module.addFunctionExport(s.internalName,i.externalName.text)}}break;case h.ElementKind.GLOBAL:if(this.compileGlobal(o)&&e.range.source.isEntry){var p=o.declaration;p&&p.needsExplicitExport(i)&&(o.is(h.ElementFlags.INLINED)?this.module.addGlobalExport(o.internalName,i.externalName.text):this.warning(u.DiagnosticCode.Cannot_export_a_mutable_global,i.range))}break;case h.ElementKind.NAMESPACE:this.compileNamespace(o)}}},t.prototype.compileClassDeclaration=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null);var i=this.program.elements.get(e.fileLevelInternalName);if(!i||i.kind!=h.ElementKind.CLASS_PROTOTYPE)throw new Error("class expected");this.compileClassUsingTypeArguments(i,t,r,n)},t.prototype.compileClassUsingTypeArguments=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null);var i=e.resolveInclTypeArguments(t,r,n);i&&this.compileClass(i)},t.prototype.compileClass=function(e){return!!e.is(h.ElementFlags.COMPILED)||(e.set(h.ElementFlags.COMPILED),!0)},t.prototype.compileInterfaceDeclaration=function(e,t,r,n){throw void 0===r&&(r=null),void 0===n&&(n=null),new Error("not implemented")},t.prototype.addMemorySegment=function(e,t){void 0===t&&(t=8);var r=i64_align(this.memoryOffset,t),n=l.MemorySegment.create(e,r);return this.memorySegments.push(n),this.memoryOffset=i64_add(r,i64_new(e.length,0)),n},t.prototype.compileStatement=function(e){var t;switch(e.kind){case _.NodeKind.BLOCK:t=this.compileBlockStatement(e);break;case _.NodeKind.BREAK:t=this.compileBreakStatement(e);break;case _.NodeKind.CONTINUE:t=this.compileContinueStatement(e);break;case _.NodeKind.DO:t=this.compileDoStatement(e);break;case _.NodeKind.EMPTY:t=this.compileEmptyStatement(e);break;case _.NodeKind.EXPRESSION:t=this.compileExpressionStatement(e);break;case _.NodeKind.FOR:t=this.compileForStatement(e);break;case _.NodeKind.IF:t=this.compileIfStatement(e);break;case _.NodeKind.RETURN:t=this.compileReturnStatement(e);break;case _.NodeKind.SWITCH:t=this.compileSwitchStatement(e);break;case _.NodeKind.THROW:t=this.compileThrowStatement(e);break;case _.NodeKind.TRY:t=this.compileTryStatement(e);break;case _.NodeKind.VARIABLE:var r=this.compileVariableStatement(e);t=r||this.module.createNop();break;case _.NodeKind.WHILE:t=this.compileWhileStatement(e);break;case _.NodeKind.TYPEDECLARATION:if(this.currentFunction==this.startFunction)return this.module.createNop();default:throw new Error("statement expected")}return this.addDebugLocation(t,e.range),t},t.prototype.compileStatements=function(e){for(var t=e.length,r=new Array(t),n=0;n<t;++n)r[n]=this.compileStatement(e[n]);return r},t.prototype.compileBlockStatement=function(e){var t=e.statements;this.currentFunction.flow=this.currentFunction.flow.enterBranchOrScope();var r=this.module.createBlock(null,this.compileStatements(t),l.NativeType.None),n=this.currentFunction.flow.is(1);return this.currentFunction.flow=this.currentFunction.flow.leaveBranchOrScope(),n&&this.currentFunction.flow.set(1),r},t.prototype.compileBreakStatement=function(e){if(e.label)return this.error(u.DiagnosticCode.Operation_not_supported,e.label.range),this.module.createUnreachable();var t=this.currentFunction.flow.breakLabel;return null==t?(this.error(u.DiagnosticCode.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement,e.range),this.module.createUnreachable()):(this.currentFunction.flow.set(4),this.module.createBreak(t))},t.prototype.compileContinueStatement=function(e){if(e.label)return this.error(u.DiagnosticCode.Operation_not_supported,e.label.range),this.module.createUnreachable();var t=this.currentFunction.flow.continueLabel;return null==t?(this.error(u.DiagnosticCode.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement,e.range),this.module.createUnreachable()):(this.currentFunction.flow.set(8),this.module.createBreak(t))},t.prototype.compileDoStatement=function(e){var t=this.currentFunction.enterBreakContext(),r=this.currentFunction.flow.breakLabel,n=this.currentFunction.flow.continueLabel,i=this.currentFunction.flow.breakLabel="break|"+t,a=this.currentFunction.flow.continueLabel="continue|"+t,o=this.compileStatement(e.statement);this.currentFunction.flow.breakLabel=r,this.currentFunction.flow.continueLabel=n;var s=this.compileExpression(e.condition,y.Type.i32);return this.currentFunction.leaveBreakContext(),this.module.createBlock(i,[this.module.createLoop(a,this.module.createBlock(null,[o,this.module.createBreak(a,s)],l.NativeType.None))],l.NativeType.None)},t.prototype.compileEmptyStatement=function(e){return this.module.createNop()},t.prototype.compileExpressionStatement=function(e){var t=this.compileExpression(e.expression,y.Type.void,0);return this.currentType!=y.Type.void&&(t=this.module.createDrop(t),this.currentType=y.Type.void),t},t.prototype.compileForStatement=function(e){var t=this.currentFunction.enterBreakContext();this.currentFunction.flow=this.currentFunction.flow.enterBranchOrScope();var r=this.currentFunction.flow.breakLabel="break|"+t,n=this.currentFunction.flow.continueLabel="continue|"+t,i=e.initializer?this.compileStatement(e.initializer):this.module.createNop(),a=e.condition?this.compileExpression(e.condition,y.Type.i32):this.module.createI32(1),o=e.incrementor?this.compileExpression(e.incrementor,y.Type.void):this.module.createNop(),s=this.compileStatement(e.statement),c=!e.condition&&this.currentFunction.flow.is(1);this.currentFunction.flow=this.currentFunction.flow.leaveBranchOrScope(),this.currentFunction.leaveBreakContext();var p=this.module.createBlock(r,[i,this.module.createLoop(n,this.module.createBlock(null,[this.module.createIf(a,this.module.createBlock(null,[s,o,this.module.createBreak(n)],l.NativeType.None))],l.NativeType.None))],l.NativeType.None);return c&&(this.currentFunction.flow.set(1),p=this.module.createBlock(null,[p,this.module.createUnreachable()])),p},t.prototype.compileIfStatement=function(e){var t=this.compileExpression(e.condition,y.Type.i32);this.currentFunction.flow=this.currentFunction.flow.enterBranchOrScope();var r=this.compileStatement(e.ifTrue),n=this.currentFunction.flow.is(1);this.currentFunction.flow=this.currentFunction.flow.leaveBranchOrScope();var i=0,a=!1;return e.ifFalse&&(this.currentFunction.flow=this.currentFunction.flow.enterBranchOrScope(),i=this.compileStatement(e.ifFalse),a=this.currentFunction.flow.is(1),this.currentFunction.flow=this.currentFunction.flow.leaveBranchOrScope()),n&&a&&this.currentFunction.flow.set(1),this.module.createIf(t,r,i)},t.prototype.compileReturnStatement=function(e){var t=0;return e.value&&(t=this.compileExpression(e.value,this.currentFunction.returnType)),this.currentFunction.flow.set(1),this.module.createReturn(t)},t.prototype.compileSwitchStatement=function(e){var t=this.currentFunction.enterBreakContext(),r=this.currentFunction.getTempLocal(y.Type.i32),n=e.cases.length,i=new Array(1+n);i[0]=this.module.createSetLocal(r.index,this.compileExpression(e.condition,y.Type.i32));for(var a=1,o=-1,s=0;s<n;++s){var c=e.cases[s];c.label?i[a++]=this.module.createBreak("case"+s.toString(10)+"|"+t,this.module.createBinary(l.BinaryOp.EqI32,this.module.createGetLocal(r.index,l.NativeType.I32),this.compileExpression(c.label,y.Type.i32))):o=s}this.currentFunction.freeTempLocal(r),i[a]=this.module.createBreak((o>=0?"case"+o.toString(10):"break")+"|"+t);var p=this.module.createBlock("case0|"+t,i,l.NativeType.None),u=!0;for(s=0;s<n;++s){c=e.cases[s];var h=c.statements.length,d=new Array(1+h);d[0]=p,this.currentFunction.flow=this.currentFunction.flow.enterBranchOrScope();for(var _=this.currentFunction.flow.breakLabel="break|"+t,m=s!=n-1,f=m?"case"+(s+1).toString(10)+"|"+t:_,E=0;E<h;++E)d[E+1]=this.compileStatement(c.statements[E]);m||this.currentFunction.flow.is(1)||(u=!1),this.currentFunction.flow=this.currentFunction.flow.leaveBranchOrScope(),p=this.module.createBlock(f,d,l.NativeType.None)}return this.currentFunction.leaveBreakContext(),o>=0&&u&&this.currentFunction.flow.set(1),p},t.prototype.compileThrowStatement=function(e){return this.currentFunction.flow.set(2),this.currentFunction.flow.set(1),this.module.createUnreachable()},t.prototype.compileTryStatement=function(e){throw new Error("not implemented")},t.prototype.compileVariableStatement=function(e,t){void 0===t&&(t=!1);var r=e.declarations;if(t||this.currentFunction==this.startFunction&&e.parent&&e.parent.kind==_.NodeKind.SOURCE){for(var n=0,i=r.length;n<i;++n)this.compileGlobalDeclaration(r[n]);return 0}var a=new Array;for(n=0,i=r.length;n<i;++n){var o=r[n],s=o.name.text,c=null,p=0;if(o.type){if(!(c=this.program.resolveType(o.type,this.currentFunction.contextualTypeArguments)))continue;o.initializer&&(p=this.compileExpression(o.initializer,c))}else{if(!o.initializer){this.error(u.DiagnosticCode.Type_expected,o.name.range.atEnd);continue}if(p=this.compileExpression(o.initializer,y.Type.void,0),this.currentType==y.Type.void){this.error(u.DiagnosticCode.Type_0_is_not_assignable_to_type_1,o.range,this.currentType.toString(),"<auto>");continue}c=this.currentType}if(_.hasModifier(_.ModifierKind.CONST,o.modifiers))if(p){if(p=this.precomputeExpressionRef(p),_BinaryenExpressionGetId(p)==l.ExpressionId.Const){var d=new h.Local(this.program,s,-1,c);switch(_BinaryenExpressionGetType(p)){case l.NativeType.I32:d=d.withConstantIntegerValue(_BinaryenConstGetValueI32(p),0);break;case l.NativeType.I64:d=d.withConstantIntegerValue(_BinaryenConstGetValueI64Low(p),_BinaryenConstGetValueI64High(p));break;case l.NativeType.F32:d=d.withConstantFloatValue(_BinaryenConstGetValueF32(p));break;case l.NativeType.F64:d=d.withConstantFloatValue(_BinaryenConstGetValueF64(p));break;default:throw new Error("concrete type expected")}var m=this.currentFunction.flow.scopedLocals;if(m){if(m.has(s))return this.error(u.DiagnosticCode.Duplicate_identifier_0,o.name.range,s),0}else m=this.currentFunction.flow.scopedLocals=new Map;return m.set(s,d),0}this.warning(u.DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable,o.range)}else this.error(u.DiagnosticCode._const_declarations_must_be_initialized,o.range);_.hasModifier(_.ModifierKind.LET,o.modifiers)?this.currentFunction.flow.addScopedLocal(s,c,o.name):this.currentFunction.addLocal(c,s),p&&a.push(this.compileAssignmentWithValue(o.name,p))}return a.length?1==a.length?a[0]:this.module.createBlock(null,a,l.NativeType.None):0},t.prototype.compileWhileStatement=function(e){var t=this.compileExpression(e.condition,y.Type.i32),r=this.currentFunction.enterBreakContext();this.currentFunction.flow=this.currentFunction.flow.enterBranchOrScope();var n=this.currentFunction.flow.breakLabel="break|"+r,i=this.currentFunction.flow.continueLabel="continue|"+r,a=this.compileStatement(e.statement);this.currentFunction.flow=this.currentFunction.flow.leaveBranchOrScope(),this.currentFunction.leaveBreakContext();var o=this.module.createBlock(n,[this.module.createLoop(i,this.module.createIf(t,this.module.createBlock(null,[a,this.module.createBreak(i)],l.NativeType.None)))],l.NativeType.None);return o},t.prototype.compileInlineConstant=function(e,t){switch(assert(e.is(h.ElementFlags.INLINED)),e.type.is(4)&&t.is(4)&&e.type.size<t.size?(this.currentType=t).kind:(this.currentType=e.type).kind){case 0:case 1:var r=e.type.computeSmallIntegerShift(y.Type.i32);return this.module.createI32(1==e.constantValueKind?i64_low(e.constantIntegerValue)<<r>>r:0);case 5:case 6:case 10:var n=e.type.computeSmallIntegerMask(y.Type.i32);return this.module.createI32(1==e.constantValueKind?i64_low(e.constantIntegerValue)&n:0);case 2:case 7:return this.module.createI32(1==e.constantValueKind?i64_low(e.constantIntegerValue):0);case 4:case 9:if(!e.program.options.isWasm64)return this.module.createI32(1==e.constantValueKind?i64_low(e.constantIntegerValue):0);case 3:case 8:return 1==e.constantValueKind?this.module.createI64(i64_low(e.constantIntegerValue),i64_high(e.constantIntegerValue)):this.module.createI64(0);case 11:return this.module.createF32(e.constantFloatValue);case 12:return this.module.createF64(e.constantFloatValue);default:throw new Error("concrete type expected")}},t.prototype.compileExpression=function(e,t,r,n){void 0===r&&(r=1),void 0===n&&(n=!0),this.currentType=t;var i;switch(e.kind){case _.NodeKind.ASSERTION:i=this.compileAssertionExpression(e,t);break;case _.NodeKind.BINARY:i=this.compileBinaryExpression(e,t,n);break;case _.NodeKind.CALL:i=this.compileCallExpression(e,t);break;case _.NodeKind.COMMA:i=this.compileCommaExpression(e,t);break;case _.NodeKind.ELEMENTACCESS:i=this.compileElementAccessExpression(e,t);break;case _.NodeKind.IDENTIFIER:case _.NodeKind.FALSE:case _.NodeKind.NULL:case _.NodeKind.THIS:case _.NodeKind.TRUE:i=this.compileIdentifierExpression(e,t);break;case _.NodeKind.LITERAL:i=this.compileLiteralExpression(e,t);break;case _.NodeKind.NEW:i=this.compileNewExpression(e,t);break;case _.NodeKind.PARENTHESIZED:i=this.compileParenthesizedExpression(e,t);break;case _.NodeKind.PROPERTYACCESS:i=this.compilePropertyAccessExpression(e,t);break;case _.NodeKind.TERNARY:i=this.compileTernaryExpression(e,t);break;case _.NodeKind.UNARYPOSTFIX:i=this.compileUnaryPostfixExpression(e,t);break;case _.NodeKind.UNARYPREFIX:i=this.compileUnaryPrefixExpression(e,t,n);break;default:throw new Error("expression expected")}return 0!=r&&this.currentType!=t&&(i=this.convertExpression(i,this.currentType,t,r,e),this.currentType=t),this.addDebugLocation(i,e.range),i},t.prototype.precomputeExpression=function(e,t,r){return void 0===r&&(r=1),this.precomputeExpressionRef(this.compileExpression(e,t,r))},t.prototype.precomputeExpressionRef=function(e){var t=this.currentType.toNativeType(),r=this.module.getFunctionTypeBySignature(t,[]);r||(r=this.module.addFunctionType(this.currentType.toSignatureString(),t,[]));var n=this.module.addFunction("__precompute",r,[],e);this.module.runPasses(["precompute"],n);var i=_BinaryenFunctionGetBody(n);return this.module.removeFunction("__precompute"),i},t.prototype.convertExpression=function(e,t,r,i,a){if(0==i)return assert(!1,"concrete type expected"),e;if(13==t.kind)return this.error(u.DiagnosticCode.Type_0_is_not_assignable_to_type_1,a.range,t.toString(),r.toString()),this.module.createUnreachable();if(13==r.kind)return this.module.createDrop(e);var o=this.module,s=!1;return t.is(8)?r.is(8)?11==t.kind?12==r.kind&&(e=o.createUnary(l.UnaryOp.PromoteF32,e)):11==r.kind&&(s=!0,e=o.createUnary(l.UnaryOp.DemoteF64,e)):r.is(4)?(s=!0,11==t.kind?r.is(1)?r.is(64)?e=o.createUnary(l.UnaryOp.TruncF32ToI64,e):(e=o.createUnary(l.UnaryOp.TruncF32ToI32,e),r.is(32)&&(e=n(e,r,this.module))):r.is(64)?e=o.createUnary(l.UnaryOp.TruncF32ToU64,e):(e=o.createUnary(l.UnaryOp.TruncF32ToU32,e),r.is(32)&&(e=n(e,r,this.module))):r.is(1)?r.is(64)?e=o.createUnary(l.UnaryOp.TruncF64ToI64,e):(e=o.createUnary(l.UnaryOp.TruncF64ToI32,e),r.is(32)&&(e=n(e,r,this.module))):r.is(64)?e=o.createUnary(l.UnaryOp.TruncF64ToU64,e):(e=o.createUnary(l.UnaryOp.TruncF64ToU32,e),r.is(32)&&(e=n(e,r,this.module)))):(assert(0==r.flags,"void type expected"),e=this.module.createDrop(e)):t.is(4)&&r.is(8)?11==r.kind?t.is(64)?(s=!0,e=o.createUnary(t.is(1)?l.UnaryOp.ConvertI64ToF32:l.UnaryOp.ConvertU64ToF32,e)):(s=!t.is(32),e=o.createUnary(t.is(1)?l.UnaryOp.ConvertI32ToF32:l.UnaryOp.ConvertU32ToF32,e)):t.is(64)?(s=!0,e=o.createUnary(t.is(1)?l.UnaryOp.ConvertI64ToF64:l.UnaryOp.ConvertU64ToF64,e)):e=o.createUnary(t.is(1)?l.UnaryOp.ConvertI32ToF64:l.UnaryOp.ConvertU32ToF64,e):t.is(64)?r.is(64)||(s=!0,e=o.createUnary(l.UnaryOp.WrapI64,e),r.is(32)&&(e=n(e,r,this.module))):r.is(64)?e=o.createUnary(r.is(1)?l.UnaryOp.ExtendI32:l.UnaryOp.ExtendU32,e):r.is(32)&&(t.size>r.size||t.size==r.size&&t.is(1)!=r.is(1))&&(s=!0,e=n(e,r,this.module)),s&&1==i&&this.error(u.DiagnosticCode.Conversion_from_type_0_to_1_possibly_loses_information_and_thus_requires_an_explicit_cast,a.range,t.toString(),r.toString()),e},t.prototype.compileAssertionExpression=function(e,t){var r=this.program.resolveType(e.toType,this.currentFunction.contextualTypeArguments);return r?this.compileExpression(e.expression,r,2):this.module.createUnreachable()},t.prototype.compileBinaryExpression=function(e,t,r){void 0===r&&(r=!0);var i,o,s,c,p=!1,h=!1,_=null;switch(e.operator){case d.Token.LESSTHAN:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0),o=this.compileExpression(e.right,this.currentType),this.currentType.kind){case 0:case 1:case 2:c=this.module.createBinary(l.BinaryOp.LtI32,i,o);break;case 3:c=this.module.createBinary(l.BinaryOp.LtI64,i,o);break;case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.LtI64:l.BinaryOp.LtI32,i,o);break;case 5:case 6:case 7:case 10:c=this.module.createBinary(l.BinaryOp.LtU32,i,o);break;case 9:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.LtU64:l.BinaryOp.LtU32,i,o);break;case 8:c=this.module.createBinary(l.BinaryOp.LtU64,i,o);break;case 11:c=this.module.createBinary(l.BinaryOp.LtF32,i,o);break;case 12:c=this.module.createBinary(l.BinaryOp.LtF64,i,o);break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}this.currentType=y.Type.bool;break;case d.Token.GREATERTHAN:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0),o=this.compileExpression(e.right,this.currentType),this.currentType.kind){case 0:case 1:case 2:c=this.module.createBinary(l.BinaryOp.GtI32,i,o);break;case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.GtI64:l.BinaryOp.GtI32,i,o);break;case 3:c=this.module.createBinary(l.BinaryOp.GtI64,i,o);break;case 5:case 6:case 7:case 10:c=this.module.createBinary(l.BinaryOp.GtU32,i,o);break;case 9:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.GtU64:l.BinaryOp.GtU32,i,o);break;case 8:c=this.module.createBinary(l.BinaryOp.GtU64,i,o);break;case 11:c=this.module.createBinary(l.BinaryOp.GtF32,i,o);break;case 12:c=this.module.createBinary(l.BinaryOp.GtF64,i,o);break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}this.currentType=y.Type.bool;break;case d.Token.LESSTHAN_EQUALS:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0),o=this.compileExpression(e.right,this.currentType),this.currentType.kind){case 0:case 1:case 2:c=this.module.createBinary(l.BinaryOp.LeI32,i,o);break;case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.LeI64:l.BinaryOp.LeI32,i,o);break;case 3:c=this.module.createBinary(l.BinaryOp.LeI64,i,o);break;case 5:case 6:case 7:case 10:c=this.module.createBinary(l.BinaryOp.LeU32,i,o);break;case 9:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.LeU64:l.BinaryOp.LeU32,i,o);break;case 8:c=this.module.createBinary(l.BinaryOp.LeU64,i,o);break;case 11:c=this.module.createBinary(l.BinaryOp.LeF32,i,o);break;case 12:c=this.module.createBinary(l.BinaryOp.LeF64,i,o);break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}this.currentType=y.Type.bool;break;case d.Token.GREATERTHAN_EQUALS:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0),o=this.compileExpression(e.right,this.currentType),this.currentType.kind){case 0:case 1:case 2:c=this.module.createBinary(l.BinaryOp.GeI32,i,o);break;case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.GeI64:l.BinaryOp.GeI32,i,o);break;case 3:c=this.module.createBinary(l.BinaryOp.GeI64,i,o);break;case 5:case 6:case 7:case 10:c=this.module.createBinary(l.BinaryOp.GeU32,i,o);break;case 9:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.GeU64:l.BinaryOp.GeU32,i,o);break;case 8:c=this.module.createBinary(l.BinaryOp.GeU64,i,o);break;case 11:c=this.module.createBinary(l.BinaryOp.GeF32,i,o);break;case 12:c=this.module.createBinary(l.BinaryOp.GeF64,i,o);break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}this.currentType=y.Type.bool;break;case d.Token.EQUALS_EQUALS_EQUALS:case d.Token.EQUALS_EQUALS:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0),o=this.compileExpression(e.right,this.currentType),this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:c=this.module.createBinary(l.BinaryOp.EqI32,i,o);break;case 9:case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.EqI64:l.BinaryOp.EqI32,i,o);break;case 3:case 8:c=this.module.createBinary(l.BinaryOp.EqI64,i,o);break;case 11:c=this.module.createBinary(l.BinaryOp.EqF32,i,o);break;case 12:c=this.module.createBinary(l.BinaryOp.EqF64,i,o);break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}this.currentType=y.Type.bool;break;case d.Token.EXCLAMATION_EQUALS_EQUALS:case d.Token.EXCLAMATION_EQUALS:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0),o=this.compileExpression(e.right,this.currentType),this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:c=this.module.createBinary(l.BinaryOp.NeI32,i,o);break;case 9:case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.NeI64:l.BinaryOp.NeI32,i,o);break;case 3:case 8:c=this.module.createBinary(l.BinaryOp.NeI64,i,o);break;case 11:c=this.module.createBinary(l.BinaryOp.NeF32,i,o);break;case 12:c=this.module.createBinary(l.BinaryOp.NeF64,i,o);break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}this.currentType=y.Type.bool;break;case d.Token.EQUALS:return this.compileAssignment(e.left,e.right,t);case d.Token.PLUS_EQUALS:p=!0;case d.Token.PLUS:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0,!1),o=this.compileExpression(e.right,this.currentType,1,!1),this.currentType.kind){case 0:case 1:case 5:case 6:case 10:h=!0;case 2:case 7:c=this.module.createBinary(l.BinaryOp.AddI32,i,o);break;case 9:case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.AddI64:l.BinaryOp.AddI32,i,o);break;case 3:case 8:c=this.module.createBinary(l.BinaryOp.AddI64,i,o);break;case 11:c=this.module.createBinary(l.BinaryOp.AddF32,i,o);break;case 12:c=this.module.createBinary(l.BinaryOp.AddF64,i,o);break;default:throw new Error("concrete type expected")}break;case d.Token.MINUS_EQUALS:p=!0;case d.Token.MINUS:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0,!1),o=this.compileExpression(e.right,this.currentType,1,!1),this.currentType.kind){case 0:case 1:case 5:case 6:case 10:h=!0;case 2:case 7:c=this.module.createBinary(l.BinaryOp.SubI32,i,o);break;case 9:case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.SubI64:l.BinaryOp.SubI32,i,o);break;case 3:case 8:c=this.module.createBinary(l.BinaryOp.SubI64,i,o);break;case 11:c=this.module.createBinary(l.BinaryOp.SubF32,i,o);break;case 12:c=this.module.createBinary(l.BinaryOp.SubF64,i,o);break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;case d.Token.ASTERISK_EQUALS:p=!0;case d.Token.ASTERISK:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0,!1),o=this.compileExpression(e.right,this.currentType,1,!1),this.currentType.kind){case 0:case 1:case 5:case 6:case 10:h=!0;case 2:case 7:c=this.module.createBinary(l.BinaryOp.MulI32,i,o);break;case 9:case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.MulI64:l.BinaryOp.MulI32,i,o);break;case 3:case 8:c=this.module.createBinary(l.BinaryOp.MulI64,i,o);break;case 11:c=this.module.createBinary(l.BinaryOp.MulF32,i,o);break;case 12:c=this.module.createBinary(l.BinaryOp.MulF64,i,o);break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;case d.Token.SLASH_EQUALS:p=!0;case d.Token.SLASH:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0,!0),o=this.compileExpression(e.right,this.currentType,1,!0),this.currentType.kind){case 0:case 1:h=!0;case 2:c=this.module.createBinary(l.BinaryOp.DivI32,i,o);break;case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.DivI64:l.BinaryOp.DivI32,i,o);break;case 3:c=this.module.createBinary(l.BinaryOp.DivI64,i,o);break;case 5:case 6:case 10:h=!0;case 7:c=this.module.createBinary(l.BinaryOp.DivU32,i,o);break;case 9:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.DivU64:l.BinaryOp.DivU32,i,o);break;case 8:c=this.module.createBinary(l.BinaryOp.DivU64,i,o);break;case 11:c=this.module.createBinary(l.BinaryOp.DivF32,i,o);break;case 12:c=this.module.createBinary(l.BinaryOp.DivF64,i,o);break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;case d.Token.PERCENT_EQUALS:p=!0;case d.Token.PERCENT:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0,!0),o=this.compileExpression(e.right,this.currentType,1,!0),this.currentType.kind){case 0:case 1:case 2:c=this.module.createBinary(l.BinaryOp.RemI32,i,o);break;case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.RemI64:l.BinaryOp.RemI32,i,o);break;case 3:c=this.module.createBinary(l.BinaryOp.RemI64,i,o);break;case 5:case 6:case 7:case 10:c=this.module.createBinary(l.BinaryOp.RemU32,i,o);break;case 9:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.RemU64:l.BinaryOp.RemU32,i,o);break;case 8:c=this.module.createBinary(l.BinaryOp.RemU64,i,o);break;case 11:case 12:this.error(u.DiagnosticCode.Operation_not_supported,e.range),c=this.module.createUnreachable();break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;case d.Token.LESSTHAN_LESSTHAN_EQUALS:p=!0;case d.Token.LESSTHAN_LESSTHAN:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t.is(8)?y.Type.i64:t,0,!1),o=this.compileExpression(e.right,this.currentType,1,!1),this.currentType.kind){case 0:case 1:case 5:case 6:case 10:h=!0;default:c=this.module.createBinary(l.BinaryOp.ShlI32,i,o);break;case 3:case 8:c=this.module.createBinary(l.BinaryOp.ShlI64,i,o);break;case 9:case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.ShlI64:l.BinaryOp.ShlI32,i,o);break;case 13:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;case d.Token.GREATERTHAN_GREATERTHAN_EQUALS:p=!0;case d.Token.GREATERTHAN_GREATERTHAN:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t.is(8)?y.Type.i64:t,0,!0),o=this.compileExpression(e.right,this.currentType,1,!0),this.currentType.kind){default:c=this.module.createBinary(l.BinaryOp.ShrI32,i,o);break;case 3:c=this.module.createBinary(l.BinaryOp.ShrI64,i,o);break;case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.ShrI64:l.BinaryOp.ShrI32,i,o);break;case 5:case 6:case 10:case 7:c=this.module.createBinary(l.BinaryOp.ShrU32,i,o);break;case 8:c=this.module.createBinary(l.BinaryOp.ShrU64,i,o);break;case 9:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.ShrU64:l.BinaryOp.ShrU32,i,o);break;case 13:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;case d.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS:p=!0;case d.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t==y.Type.void?y.Type.u64:t,0,!0),o=this.compileExpression(e.right,this.currentType,1,!0),this.currentType.kind){case 0:case 1:h=!0;default:c=this.module.createBinary(l.BinaryOp.ShrU32,i,o);break;case 3:case 8:c=this.module.createBinary(l.BinaryOp.ShrU64,i,o);break;case 9:case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.ShrU64:l.BinaryOp.ShrU32,i,o);break;case 13:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;case d.Token.AMPERSAND_EQUALS:p=!0;case d.Token.AMPERSAND:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t.is(8)?y.Type.i64:t,0,!1),o=this.compileExpression(e.right,this.currentType,1,!1),this.currentType.kind){case 0:case 1:case 5:case 6:case 10:h=!0;default:c=this.module.createBinary(l.BinaryOp.AndI32,i,o);break;case 3:case 8:c=this.module.createBinary(l.BinaryOp.AndI64,i,o);break;case 9:case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.AndI64:l.BinaryOp.AndI32,i,o);break;case 13:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;case d.Token.BAR_EQUALS:p=!0;case d.Token.BAR:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t.is(8)?y.Type.i64:t,0,!1),o=this.compileExpression(e.right,this.currentType,1,!1),this.currentType.kind){case 0:case 1:case 5:case 6:case 10:h=!0;default:c=this.module.createBinary(l.BinaryOp.OrI32,i,o);break;case 3:case 8:c=this.module.createBinary(l.BinaryOp.OrI64,i,o);break;case 9:case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.OrI64:l.BinaryOp.OrI32,i,o);break;case 13:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;case d.Token.CARET_EQUALS:p=!0;case d.Token.CARET:switch(i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t.is(8)?y.Type.i64:t,0,!1),o=this.compileExpression(e.right,this.currentType,1,!1),this.currentType.kind){case 0:case 1:case 5:case 6:case 10:h=!0;default:c=this.module.createBinary(l.BinaryOp.XorI32,i,o);break;case 3:case 8:c=this.module.createBinary(l.BinaryOp.XorI64,i,o);break;case 9:case 4:c=this.module.createBinary(this.options.isWasm64?l.BinaryOp.XorI64:l.BinaryOp.XorI32,i,o);break;case 13:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;case d.Token.AMPERSAND_AMPERSAND:i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0),o=this.compileExpression(e.right,this.currentType,1,!1),c=this.module.cloneExpression(i,!0,0),c||(_=this.currentFunction.getAndFreeTempLocal(this.currentType),i=this.module.createTeeLocal(_.index,i)),h=this.currentType.is(36),s=a(i,this.currentType,this.module),c=c?this.module.createIf(s,o,c):this.module.createIf(s,o,this.module.createGetLocal(assert(_,"tempLocal must be set").index,this.currentType.toNativeType()));break;case d.Token.BAR_BAR:i=this.compileExpression(e.left,t==y.Type.void?y.Type.i32:t,0),o=this.compileExpression(e.right,this.currentType,1,!1),c=this.module.cloneExpression(i,!0,0),c||(_=this.currentFunction.getAndFreeTempLocal(this.currentType),i=this.module.createTeeLocal(_.index,i)),h=this.currentType.is(36),s=a(i,this.currentType,this.module),c=c?this.module.createIf(s,c,o):this.module.createIf(s,this.module.createGetLocal(assert(_,"tempLocal must be set").index,this.currentType.toNativeType()),o);break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("not implemented")}return h&&r&&(assert(this.currentType.is(36),"small integer type expected"),c=n(c,this.currentType,this.module)),p?this.compileAssignmentWithValue(e.left,c,t!=y.Type.void):c},t.prototype.compileAssignment=function(e,t,r){var n=this.program.resolveExpression(e,this.currentFunction);if(!n)return this.module.createUnreachable();var i,a=n.element;switch(a.kind){case h.ElementKind.GLOBAL:if(!this.compileGlobal(a))return this.module.createUnreachable();assert(a.type!=y.Type.void,"concrete type expected");case h.ElementKind.LOCAL:case h.ElementKind.FIELD:i=a.type;break;case h.ElementKind.PROPERTY:var o=a.setterPrototype;if(o){var s=o.resolve();if(!s)return this.module.createUnreachable();assert(s.parameters&&1==s.parameters.length),i=s.parameters[0].type;break}return this.error(u.DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property,e.range,a.internalName),this.module.createUnreachable();case h.ElementKind.FUNCTION_PROTOTYPE:if(e.kind==_.NodeKind.ELEMENTACCESS){assert(n.target&&n.target.kind==h.ElementKind.CLASS&&a.simpleName==n.target.prototype.fnIndexedGet);var c=a.resolve(null);if(c){i=c.returnType;break}}default:return this.error(u.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}return this.currentType=i,this.compileAssignmentWithValue(e,this.compileExpression(t,i),r!=y.Type.void)},t.prototype.compileAssignmentWithValue=function(e,t,r){void 0===r&&(r=!1);var n=this.program.resolveExpression(e,this.currentFunction);if(!n)return this.module.createUnreachable();var i,a,o=n.element;switch(o.kind){case h.ElementKind.LOCAL:return this.currentType=r?o.type:y.Type.void,o.is(h.ElementFlags.CONSTANT)?(this.error(u.DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property,e.range,o.internalName),this.module.createUnreachable()):r?this.module.createTeeLocal(o.index,t):this.module.createSetLocal(o.index,t);case h.ElementKind.GLOBAL:if(!this.compileGlobal(o))return this.module.createUnreachable();if(assert(o.type!=y.Type.void,"concrete type expected"),this.currentType=r?o.type:y.Type.void,o.is(h.ElementFlags.CONSTANT))return this.error(u.DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property,e.range,o.internalName),this.module.createUnreachable();if(!r)return this.module.createSetGlobal(o.internalName,t);var s=o.type.toNativeType();return this.module.createBlock(null,[this.module.createSetGlobal(o.internalName,t),this.module.createGetGlobal(o.internalName,s)],s);case h.ElementKind.FIELD:if(o.prototype.isReadonly)return this.error(u.DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property,e.range,o.internalName),this.module.createUnreachable();assert(null!=n.targetExpression,"target expression expected"),a=this.compileExpression(n.targetExpression,this.options.isWasm64?y.Type.usize64:y.Type.usize32,0),assert(this.currentType.classType,"class type expected"),this.currentType=r?o.type:y.Type.void;var c=o.type.toNativeType();return r?(i=this.currentFunction.getAndFreeTempLocal(o.type),this.module.createBlock(null,[this.module.createSetLocal(i.index,t),this.module.createStore(o.type.size>>3,a,this.module.createGetLocal(i.index,c),c,o.memoryOffset),this.module.createGetLocal(i.index,c)],c)):this.module.createStore(o.type.size>>3,a,t,c,o.memoryOffset);case h.ElementKind.PROPERTY:var p=o.setterPrototype;if(p){var l=p.resolve();if(l){if(assert(l.parameters&&1==l.parameters.length),!r)return l.is(h.ElementFlags.INSTANCE)?(assert(null!=n.targetExpression),a=this.compileExpression(n.targetExpression,this.options.isWasm64?y.Type.usize64:y.Type.usize32,0),assert(this.currentType.classType),this.currentType=y.Type.void,this.makeCall(l,[a,t])):(this.currentType=y.Type.void,this.makeCall(l,[t]));var d=o.getterPrototype;assert(null!=d);var m=d.resolve();if(m)return assert(!m.parameters||!m.parameters.length),l.is(h.ElementFlags.INSTANCE)?(assert(null!=n.targetExpression),a=this.compileExpression(n.targetExpression,this.options.isWasm64?y.Type.usize64:y.Type.usize32,0),assert(this.currentType.classType),i=this.currentFunction.getAndFreeTempLocal(m.returnType),this.module.createBlock(null,[this.makeCall(l,[this.module.createTeeLocal(i.index,a),t]),this.makeCall(m,[this.module.createGetLocal(i.index,i.type.toNativeType())])],(this.currentType=m.returnType).toNativeType())):this.module.createBlock(null,[this.makeCall(l,[t]),this.makeCall(m)],(this.currentType=m.returnType).toNativeType())}}else this.error(u.DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property,e.range,o.internalName);return this.module.createUnreachable();case h.ElementKind.FUNCTION_PROTOTYPE:if(e.kind==_.NodeKind.ELEMENTACCESS){assert(n.target&&n.target.kind==h.ElementKind.CLASS);var f=o.resolve();if(!f)return this.module.createUnreachable();var E,g=n.target.prototype.fnIndexedSet;if(null!=g&&n.target.members&&(E=n.target.members.get(g))&&E.kind==h.ElementKind.FUNCTION_PROTOTYPE){var T=E.resolve();if(!T)return this.module.createUnreachable();a=this.compileExpression(n.targetExpression,this.options.isWasm64?y.Type.usize64:y.Type.usize32,0),assert(this.currentType.classType);var A=this.compileExpression(e.elementExpression,y.Type.i32);return r?(this.currentType=f.returnType,i=this.currentFunction.getAndFreeTempLocal(this.currentType),this.module.createBlock(null,[this.makeCall(T,[a,A,this.module.createTeeLocal(i.index,t)]),this.module.createGetLocal(i.index,i.type.toNativeType())],this.currentType.toNativeType())):(this.currentType=T.returnType,this.makeCall(T,[a,A,t]))}return this.error(u.DiagnosticCode.Index_signature_in_type_0_only_permits_reading,e.range,n.target.internalName),this.module.createUnreachable()}}return this.error(u.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()},t.prototype.compileCallExpression=function(e,t){var r=this.program.resolveExpression(e.expression,this.currentFunction);if(!r)return this.module.createUnreachable();var n=r.element;if(n.kind!=h.ElementKind.FUNCTION_PROTOTYPE)return this.error(u.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures,e.range,n.internalName),this.module.createUnreachable();var i=n,a=null;if(i.is(h.ElementFlags.BUILTIN)){var o=null;if(e.typeArguments){var s=e.typeArguments.length;o=new Array(s);for(var c=0;c<s;++c){var l=this.program.resolveType(e.typeArguments[c],this.currentFunction.contextualTypeArguments,!0);if(!l)return this.module.createUnreachable();o[c]=l}}var d=p.compileCall(this,i,o,e.arguments,t,e);return d||(this.error(u.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable())}if(!(a=i.resolveInclTypeArguments(e.typeArguments,this.currentFunction.contextualTypeArguments,e)))return this.module.createUnreachable();var _=e.arguments.length,y=a.instanceMethodOf?_+1:_,m=0,f=new Array(y);for(a.instanceMethodOf&&(assert(null!=r.targetExpression),f[m++]=r.targetExpression),c=0;c<_;++c)f[m++]=e.arguments[c];return this.compileCall(a,f,e)},t.prototype.compileCall=function(e,t,r,n){void 0===n&&(n=0);var i=e.parameters,a=i?i.length:0,o=null!=e.instanceMethodOf?a+1:a,s=t.length,c=null!=e.instanceMethodOf?s-1:s;if(n&&s++,s>o)return this.error(u.DiagnosticCode.Expected_0_arguments_but_got_1,r.range,a.toString(10),c.toString(10)),this.module.createUnreachable();var p=new Array(o),l=0,h=0;if(e.instanceMethodOf&&(p[l++]=n||this.compileExpression(t[h++],e.instanceMethodOf.type)),i)for(;l<o;++l)if(s>l)p[l]=this.compileExpression(t[h++],i[l+a-o].type);else{var d=i[l+a-o].initializer;if(!d)return this.error(u.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,r.range,(l+a-o).toString(10),c.toString(10)),this.module.createUnreachable();p[l]=this.compileExpression(d,i[l+a-o].type)}return this.currentType=e.returnType,this.makeCall(e,p)},t.prototype.makeCall=function(e,t){return void 0===t&&(t=null),e.is(h.ElementFlags.COMPILED)||this.compileFunction(e)?e.is(h.ElementFlags.DECLARED)?this.module.createCallImport(e.internalName,t,e.returnType.toNativeType()):this.module.createCall(e.internalName,t,e.returnType.toNativeType()):this.module.createUnreachable()},t.prototype.compileCommaExpression=function(e,t){for(var r=e.expressions,n=r.length,i=new Array(n--),a=0;a<n;++a)i[a]=this.compileExpression(r[a],y.Type.void);return i[a]=this.compileExpression(r[a],t),this.module.createBlock(null,i,this.currentType.toNativeType())},t.prototype.compileElementAccessExpression=function(e,t){var r=this.program.resolveElementAccess(e,this.currentFunction);if(!r)return this.module.createUnreachable();assert(r.element.kind==h.ElementKind.FUNCTION_PROTOTYPE&&r.target&&r.target.kind==h.ElementKind.CLASS);var n=r.element.resolve(null,r.target.contextualTypeArguments);return n?this.compileCall(n,[e.expression,e.elementExpression],e):this.module.createUnreachable()},t.prototype.compileIdentifierExpression=function(e,t){switch(e.kind){case _.NodeKind.NULL:return this.options.isWasm64?(t.classType||(assert(9==t.kind),this.currentType=y.Type.usize64),this.module.createI64(0)):(t.classType||(assert(9==t.kind),this.currentType=y.Type.usize32),this.module.createI32(0));case _.NodeKind.TRUE:return this.currentType=y.Type.bool,this.module.createI32(1);case _.NodeKind.FALSE:return this.currentType=y.Type.bool,this.module.createI32(0);case _.NodeKind.THIS:return this.currentFunction.instanceMethodOf?(this.currentType=this.currentFunction.instanceMethodOf.type,this.module.createGetLocal(0,this.currentType.toNativeType())):(this.error(u.DiagnosticCode._this_cannot_be_referenced_in_current_location,e.range),this.currentType=this.options.isWasm64?y.Type.usize64:y.Type.usize32,this.module.createUnreachable());case _.NodeKind.SUPER:return this.currentFunction.instanceMethodOf&&this.currentFunction.instanceMethodOf.base?(this.currentType=this.currentFunction.instanceMethodOf.base.type,this.module.createGetLocal(0,this.currentType.toNativeType())):(this.error(u.DiagnosticCode._super_can_only_be_referenced_in_a_derived_class,e.range),this.currentType=this.options.isWasm64?y.Type.usize64:y.Type.usize32,this.module.createUnreachable())}var r=this.program.resolveIdentifier(e,this.currentFunction,this.currentEnum);if(!r)return this.module.createUnreachable();var n=r.element;switch(n.kind){case h.ElementKind.LOCAL:return n.is(h.ElementFlags.INLINED)?this.compileInlineConstant(n,t):(assert(n.index>=0),this.currentType=n.type,this.module.createGetLocal(n.index,this.currentType.toNativeType()));case h.ElementKind.GLOBAL:return n.is(h.ElementFlags.BUILTIN)?p.compileGetConstant(this,n,e):this.compileGlobal(n)?(assert(n.type!=y.Type.void),n.is(h.ElementFlags.INLINED)?this.compileInlineConstant(n,t):(this.currentType=n.type,this.module.createGetGlobal(n.internalName,this.currentType.toNativeType()))):this.module.createUnreachable();case h.ElementKind.ENUMVALUE:return n.is(h.ElementFlags.COMPILED)?(this.currentType=y.Type.i32,n.is(h.ElementFlags.INLINED)?this.module.createI32(n.constantValue):this.module.createGetGlobal(n.internalName,l.NativeType.I32)):(this.error(u.DiagnosticCode.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums,e.range),this.currentType=y.Type.i32,this.module.createUnreachable())}return this.error(u.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()},t.prototype.compileLiteralExpression=function(e,t,r){switch(void 0===r&&(r=!1),e.literalKind){case 4:assert(!r);var n=t.classType;return n&&n==this.program.elements.get("Array")&&n.typeArguments&&1==n.typeArguments.length?this.compileStaticArray(n.typeArguments[0],e.elementExpressions):(this.error(u.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable());case 0:var i=e.value;return r&&(i=-i),t==y.Type.f32?this.module.createF32(i):(this.currentType=y.Type.f64,this.module.createF64(i));case 1:var a=e.value;switch(r&&(a=i64_sub(i64_new(0),a)),t.kind){case 0:if(i64_is_i8(a))return this.module.createI32(i64_low(a));break;case 1:if(i64_is_i16(a))return this.module.createI32(i64_low(a));break;case 2:if(i64_is_i32(a))return this.module.createI32(i64_low(a));break;case 5:if(i64_is_u8(a))return this.module.createI32(i64_low(a));break;case 6:if(i64_is_u16(a))return this.module.createI32(i64_low(a));break;case 7:if(i64_is_u32(a))return this.module.createI32(i64_low(a));break;case 10:if(i64_is_bool(a))return this.module.createI32(i64_low(a));break;case 4:case 9:if(!this.options.isWasm64){if(i64_is_u32(a))return this.module.createI32(i64_low(a));break}return this.module.createI64(i64_low(a),i64_high(a));case 3:case 8:return this.module.createI64(i64_low(a),i64_high(a));case 11:if(i64_is_f32(a))return this.module.createF32(i64_to_f32(a));break;case 12:if(i64_is_f64(a))return this.module.createF64(i64_to_f64(a));break;case 13:break;default:assert(!1)}return i64_is_i32(a)?(this.currentType=y.Type.i32,this.module.createI32(i64_low(a))):(this.currentType=y.Type.i64,this.module.createI64(i64_low(a),i64_high(a)));case 2:return assert(!r),this.compileStaticString(e.value)}throw new Error("not implemented")},t.prototype.compileStaticString=function(e){var t=this.stringSegments.get(e);if(!t){var r=e.length,n=new Uint8Array(4+2*r);n[0]=255&r,n[1]=r>>>8&255,n[2]=r>>>16&255,n[3]=r>>>24&255;for(var i=0;i<r;++i)n[4+2*i]=255&e.charCodeAt(i),n[5+2*i]=e.charCodeAt(i)>>>8&255;t=this.addMemorySegment(n,this.options.usizeType.byteSize),this.stringSegments.set(e,t)}var a=t.offset;return this.currentType=this.options.usizeType,this.options.isWasm64?this.module.createI64(i64_low(a),i64_high(a)):(assert(i64_is_i32(a)),this.module.createI32(i64_low(a)))},t.prototype.compileStaticArray=function(e,t){var r,n=!0,i=t.length,a=e.toNativeType();switch(a){case l.NativeType.I32:r=changetype(new Int32Array(i));break;case l.NativeType.I64:r=changetype(new Array(i));break;case l.NativeType.F32:r=changetype(new Float32Array(i));break;case l.NativeType.F64:r=changetype(new Float64Array(i));break;default:throw new Error("concrete type expected")}for(var o,s=new Array(i),c=0;c<i;++c)if(s[c]=t[c]?this.compileExpression(t[c],e):e.toNativeZero(this.module),n)if(o=this.precomputeExpressionRef(s[c]),_BinaryenExpressionGetId(o)==l.ExpressionId.Const)switch(assert(_BinaryenExpressionGetType(o)==a),a){case l.NativeType.I32:changetype(r)[c]=_BinaryenConstGetValueI32(o);break;case l.NativeType.I64:changetype(r)[c]=i64_new(_BinaryenConstGetValueI64Low(o),_BinaryenConstGetValueI64High(o));break;case l.NativeType.F32:changetype(r)[c]=_BinaryenConstGetValueF32(o);break;case l.NativeType.F64:changetype(r)[c]=_BinaryenConstGetValueF64(o);break;default:assert(!1)}else n=!1;throw new Error("not implemented")},t.prototype.compileNewExpression=function(e,t){var r=this.program.resolveExpression(e.expression,this.currentFunction);if(r)if(r.element.kind==h.ElementKind.CLASS_PROTOTYPE){var n=r.element,i=n.resolveInclTypeArguments(e.typeArguments,null,e);if(i){var a=p.compileAllocate(this,i,e),o=new Array,c=this.currentFunction.getTempLocal(this.options.usizeType);if(o.push(this.module.createSetLocal(c.index,a)),i.members)try{for(var l=s(i.members.values()),d=l.next();!d.done;d=l.next()){var _=d.value;if(_.kind==h.ElementKind.FIELD){var y=_,m=y.prototype.declaration;y.is(h.ElementFlags.CONSTANT)?assert(!1):m&&m.initializer&&o.push(this.module.createStore(y.type.byteSize,this.module.createGetLocal(c.index,this.options.nativeSizeType),this.compileExpression(m.initializer,y.type),y.type.toNativeType(),y.memoryOffset))}}}catch(e){E={error:e}}finally{try{d&&!d.done&&(g=l.return)&&g.call(l)}finally{if(E)throw E.error}}var f=i.constructorInstance;return f&&o.push(this.compileCall(f,e.arguments,e,this.module.createGetLocal(c.index,this.options.nativeSizeType))),o.push(this.module.createGetLocal(c.index,this.options.nativeSizeType)),this.currentFunction.freeTempLocal(c),a=this.module.createBlock(null,o,this.options.nativeSizeType),this.currentType=i.type,a}}else this.error(u.DiagnosticCode.Cannot_use_new_with_an_expression_whose_type_lacks_a_construct_signature,e.expression.range);return this.module.createUnreachable();var E,g},t.prototype.compileParenthesizedExpression=function(e,t){return this.compileExpression(e.expression,t,0)},t.prototype.compilePropertyAccessExpression=function(e,t){var r=this.program.resolvePropertyAccess(e,this.currentFunction);if(!r)return this.module.createUnreachable();var n,i=r.element;switch(i.kind){case h.ElementKind.GLOBAL:return i.is(h.ElementFlags.BUILTIN)?p.compileGetConstant(this,i,e):this.compileGlobal(i)?(assert(i.type!=y.Type.void),i.is(h.ElementFlags.INLINED)?this.compileInlineConstant(i,t):(this.currentType=i.type,this.module.createGetGlobal(i.internalName,this.currentType.toNativeType()))):this.module.createUnreachable();case h.ElementKind.ENUMVALUE:return this.compileEnum(i.enum)?(this.currentType=y.Type.i32,i.is(h.ElementFlags.INLINED)?this.module.createI32(i.constantValue):this.module.createGetGlobal(i.internalName,l.NativeType.I32)):this.module.createUnreachable();case h.ElementKind.FIELD:return assert(null!=r.target),assert(null!=r.targetExpression),assert(i.memoryOffset>=0),n=this.compileExpression(r.targetExpression,this.options.usizeType),this.currentType=i.type,this.module.createLoad(i.type.size>>3,i.type.is(5),n,i.type.toNativeType(),i.memoryOffset);case h.ElementKind.PROPERTY:var a=i.getterPrototype;assert(null!=a);var o=a.resolve(null);return o?(assert(!o.parameters||!o.parameters.length),this.currentType=o.returnType,o.is(h.ElementFlags.INSTANCE)?(n=this.compileExpression(r.targetExpression,this.options.isWasm64?y.Type.usize64:y.Type.usize32),this.currentType=o.returnType,this.makeCall(o,[n])):this.makeCall(o)):this.module.createUnreachable()}return this.error(u.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()},t.prototype.compileTernaryExpression=function(e,t){var r=this.compileExpression(e.condition,y.Type.i32),n=this.compileExpression(e.ifThen,t),i=this.compileExpression(e.ifElse,t);return this.module.createIf(r,n,i)},t.prototype.compileUnaryPostfixExpression=function(e,t){var r,i,a,o=this.compileExpression(e.operand,t==y.Type.void?y.Type.i32:t,0,!1),s=!1;switch(e.operator){case d.Token.PLUS_PLUS:switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:s=!0;default:r=l.BinaryOp.AddI32,i=l.NativeType.I32,a=this.module.createI32(1);break;case 9:case 4:r=this.options.isWasm64?l.BinaryOp.AddI64:l.BinaryOp.AddI32,i=this.options.isWasm64?l.NativeType.I64:l.NativeType.I32,a=this.currentType.toNativeOne(this.module);break;case 3:case 8:r=l.BinaryOp.AddI64,i=l.NativeType.I64,a=this.module.createI64(1);break;case 11:r=l.BinaryOp.AddF32,i=l.NativeType.F32,a=this.module.createF32(1);break;case 12:r=l.BinaryOp.AddF64,i=l.NativeType.F64,a=this.module.createF64(1);break;case 13:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;case d.Token.MINUS_MINUS:switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:s=!0;default:r=l.BinaryOp.SubI32,i=l.NativeType.I32,a=this.module.createI32(1);break;case 9:case 4:r=this.options.isWasm64?l.BinaryOp.SubI64:l.BinaryOp.SubI32,i=this.options.isWasm64?l.NativeType.I64:l.NativeType.I32,a=this.currentType.toNativeOne(this.module);break;case 3:case 8:r=l.BinaryOp.SubI64,i=l.NativeType.I64,a=this.module.createI64(1);break;case 11:r=l.BinaryOp.SubF32,i=l.NativeType.F32,a=this.module.createF32(1);break;case 12:r=l.BinaryOp.SubF64,i=l.NativeType.F64,a=this.module.createF64(1);break;case 13:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("concrete type expected")}break;default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("unary postfix operator expected")}var c,p=null;return t==y.Type.void?c=this.module.createBinary(r,o,a):(p=this.currentFunction.getTempLocal(this.currentType),c=this.module.createBinary(r,this.module.createGetLocal(p.index,i),a)),s&&(assert(this.currentType.is(36)),c=n(c,this.currentType,this.module)),c=this.compileAssignmentWithValue(e.operand,c,!1),t==y.Type.void?(assert(!p),c):(this.currentType=assert(p).type,this.currentFunction.freeTempLocal(p),this.module.createBlock(null,[this.module.createSetLocal(p.index,o),c,this.module.createGetLocal(p.index,i)],i))},t.prototype.compileUnaryPrefixExpression=function(e,t,r){void 0===r&&(r=!0);var a,o=!1,s=!1;switch(e.operator){case d.Token.PLUS:if(this.currentType.isReference)return this.error(u.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable();a=this.compileExpression(e.operand,t==y.Type.void?y.Type.i32:t,0,!1),o=this.currentType.is(36);break;case d.Token.MINUS:if(e.operand.kind!=_.NodeKind.LITERAL||1!=e.operand.literalKind&&0!=e.operand.literalKind)switch(a=this.compileExpression(e.operand,t==y.Type.void?y.Type.i32:t,0,!1),this.currentType.kind){case 0:case 1:case 5:case 6:case 10:o=!0;default:a=this.module.createBinary(l.BinaryOp.SubI32,this.module.createI32(0),a);break;case 9:if(this.currentType.isReference)return this.error(u.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable();case 4:a=this.module.createBinary(this.options.isWasm64?l.BinaryOp.SubI64:l.BinaryOp.SubI32,this.currentType.toNativeZero(this.module),a);break;case 3:case 8:a=this.module.createBinary(l.BinaryOp.SubI64,this.module.createI64(0),a);break;case 11:a=this.module.createUnary(l.UnaryOp.NegF32,a);break;case 12:a=this.module.createUnary(l.UnaryOp.NegF64,a)}else a=this.compileLiteralExpression(e.operand,t,!0),this.addDebugLocation(a,e.range);break;case d.Token.PLUS_PLUS:switch(s=!0,a=this.compileExpression(e.operand,t==y.Type.void?y.Type.i32:t,0,!1),this.currentType.kind){case 0:case 1:case 5:case 6:case 10:o=!0;default:a=this.module.createBinary(l.BinaryOp.AddI32,a,this.module.createI32(1));break;case 9:if(this.currentType.isReference)return this.error(u.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable();case 4:a=this.module.createBinary(this.options.isWasm64?l.BinaryOp.AddI64:l.BinaryOp.AddI32,a,this.currentType.toNativeOne(this.module));break;case 3:case 8:a=this.module.createBinary(l.BinaryOp.AddI64,a,this.module.createI64(1));break;case 11:a=this.module.createBinary(l.BinaryOp.AddF32,a,this.module.createF32(1));break;case 12:a=this.module.createBinary(l.BinaryOp.AddF64,a,this.module.createF64(1))}break;case d.Token.MINUS_MINUS:switch(s=!0,a=this.compileExpression(e.operand,t==y.Type.void?y.Type.i32:t,0,!1),this.currentType.kind){case 0:case 1:case 5:case 6:case 10:o=!0;default:a=this.module.createBinary(l.BinaryOp.SubI32,a,this.module.createI32(1));break;case 9:if(this.currentType.isReference)return this.error(u.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable();case 4:a=this.module.createBinary(this.options.isWasm64?l.BinaryOp.SubI64:l.BinaryOp.SubI32,a,this.currentType.toNativeOne(this.module));break;case 3:case 8:a=this.module.createBinary(l.BinaryOp.SubI64,a,this.module.createI64(1));break;case 11:a=this.module.createBinary(l.BinaryOp.SubF32,a,this.module.createF32(1));break;case 12:a=this.module.createBinary(l.BinaryOp.SubF64,a,this.module.createF64(1))}break;case d.Token.EXCLAMATION:a=this.compileExpression(e.operand,t==y.Type.void?y.Type.i32:t,0,!0),a=i(a,this.currentType,this.module),this.currentType=y.Type.bool;break;case d.Token.TILDE:switch(a=this.compileExpression(e.operand,t==y.Type.void?y.Type.i32:t.is(8)?y.Type.i64:t,t==y.Type.void?0:1,!1),this.currentType.kind){case 0:case 1:case 5:case 6:case 10:o=!0;default:a=this.module.createBinary(l.BinaryOp.XorI32,a,this.module.createI32(-1));break;case 9:if(this.currentType.isReference)return this.error(u.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable();case 4:a=this.module.createBinary(this.options.isWasm64?l.BinaryOp.XorI64:l.BinaryOp.XorI32,a,this.currentType.toNativeNegOne(this.module));break;case 3:case 8:a=this.module.createBinary(l.BinaryOp.XorI64,a,this.module.createI64(-1,-1))}break;case d.Token.TYPEOF:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("not implemented");default:throw this.error(u.DiagnosticCode.Operation_not_supported,e.range),new Error("unary operator expected")}return o&&r&&(assert(this.currentType.is(36)),a=n(a,this.currentType,this.module)),s?this.compileAssignmentWithValue(e.operand,a,t!=y.Type.void):a},t.prototype.addDebugLocation=function(e,t){if(null!=this.options.sourceMap){var r=t.source;r.debugInfoIndex<0&&(r.debugInfoIndex=this.module.addDebugInfoFile(r.normalizedPath)),t.debugInfoRef=e,this.currentFunction.debugLocations||(this.currentFunction.debugLocations=[]),this.currentFunction.debugLocations.push(t)}},t}(u.DiagnosticEmitter);t.Compiler=f,t.makeSmallIntegerWrap=n,t.makeIsFalseish=i,t.makeIsTrueish=a},function(e,t,r){"use strict";function n(e){for(var t=e.length,r=new Array(t),n=0;n<t;++n)r[n]=e[n].toNativeType();return r}function i(e){var t=e.length;if(!t)return"";for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n].toString();return r.join(", ")}Object.defineProperty(t,"__esModule",{value:!0});var a=r(0);!function(e){e[e.I8=0]="I8",e[e.I16=1]="I16",e[e.I32=2]="I32",e[e.I64=3]="I64",e[e.ISIZE=4]="ISIZE",e[e.U8=5]="U8",e[e.U16=6]="U16",e[e.U32=7]="U32",e[e.U64=8]="U64",e[e.USIZE=9]="USIZE",e[e.BOOL=10]="BOOL",e[e.F32=11]="F32",e[e.F64=12]="F64",e[e.VOID=13]="VOID"}(t.TypeKind||(t.TypeKind={}));!function(e){e[e.NONE=0]="NONE",e[e.SIGNED=1]="SIGNED",e[e.UNSIGNED=2]="UNSIGNED",e[e.INTEGER=4]="INTEGER",e[e.FLOAT=8]="FLOAT",e[e.SIZE=16]="SIZE",e[e.SMALL=32]="SMALL",e[e.LONG=64]="LONG",e[e.VALUE=128]="VALUE",e[e.REFERENCE=256]="REFERENCE",e[e.NULLABLE=512]="NULLABLE"}(t.TypeFlags||(t.TypeFlags={}));var o=function(){function e(e,t,r){this.nullableType=null,this.kind=e,this.flags=t,this.size=r,this.byteSize=ceil(r/8),this.classType=null,this.nonNullableType=this}return e.prototype.computeSmallIntegerShift=function(e){return e.size-this.size},e.prototype.computeSmallIntegerMask=function(e){return-1>>>e.size-this.size},e.prototype.is=function(e){return(this.flags&e)==e},Object.defineProperty(e.prototype,"isClass",{get:function(){return null!=this.classType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isFunction",{get:function(){return null!=this.functionType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isReference",{get:function(){return null!=this.classType||null!=this.functionType},enumerable:!0,configurable:!0}),e.prototype.asClass=function(t){assert(9==this.kind);var r=new e(this.kind,-129&this.flags|256,this.size);return r.classType=t,r},e.prototype.asFunction=function(t){assert(9==this.kind&&!this.isReference);var r=new e(this.kind,-129&this.flags|256,this.size);return r.functionType=t,r},e.prototype.asNullable=function(){return assert(9==this.kind),this.nullableType||(assert(!this.is(512)&&this.isReference),this.nullableType=new e(this.kind,512|this.flags,this.size),this.nullableType.classType=this.classType,this.nullableType.functionType=this.functionType),this.nullableType},e.prototype.toString=function(e){switch(void 0===e&&(e=!1),this.kind){case 0:return"i8";case 1:return"i16";case 2:return"i32";case 3:return"i64";case 4:return"isize";case 5:return"u8";case 6:return"u16";case 7:return"u32";case 8:return"u64";case 9:return e?"usize":this.classType?this.classType.toString():this.functionType?this.functionType.toTypeString():"usize";case 10:return"bool";case 11:return"f32";case 12:return"f64";case 13:return"void";default:return assert(!1),""}},e.prototype.toNativeType=function(){switch(this.kind){default:return a.NativeType.I32;case 3:case 8:return a.NativeType.I64;case 4:case 9:return 64==this.size?a.NativeType.I64:a.NativeType.I32;case 11:return a.NativeType.F32;case 12:return a.NativeType.F64;case 13:return a.NativeType.None}},e.prototype.toNativeZero=function(e){switch(this.kind){case 13:assert(!1);default:return e.createI32(0);case 4:case 9:if(64!=this.size)return e.createI32(0);case 3:case 8:return e.createI64(0);case 11:return e.createF32(0);case 12:return e.createF64(0)}},e.prototype.toNativeOne=function(e){switch(this.kind){case 13:assert(!1);default:return e.createI32(1);case 4:case 9:if(64!=this.size)return e.createI32(1);case 3:case 8:return e.createI64(1);case 11:return e.createF32(1);case 12:return e.createF64(1)}},e.prototype.toNativeNegOne=function(e){switch(this.kind){case 13:assert(!1);default:return e.createI32(-1);case 4:case 9:if(64!=this.size)return e.createI32(-1);case 3:case 8:return e.createI64(-1,-1);case 11:return e.createF32(-1);case 12:return e.createF64(-1)}},e.prototype.toSignatureString=function(){switch(this.kind){default:return"i";case 3:case 8:return"I";case 4:case 9:return 64==this.size?"I":"i";case 11:return"f";case 12:return"F";case 13:return"v"}},e.i8=new e(0,165,8),e.i16=new e(1,165,16),e.i32=new e(2,133,32),e.i64=new e(3,197,64),e.isize32=new e(4,149,32),e.isize64=new e(4,213,64),e.u8=new e(5,166,8),e.u16=new e(6,166,16),e.u32=new e(7,134,32),e.u64=new e(8,198,64),e.usize32=new e(9,150,32),e.usize64=new e(9,214,64),e.bool=new e(10,166,1),e.f32=new e(11,137,32),e.f64=new e(12,201,64),e.void=new e(13,0,0),e}();t.Type=o,t.typesToNativeTypes=n,t.typesToString=i},function(e,t,r){"use strict";function n(e){Be=e}function i(){var e;return null!=Be?(e=Be,Be=null):e=[],e.length=0,e}function a(e,t){return null==t&&(t=i()),t.push(e),t}function o(e,t){if(t)for(var r=0,n=t.length;r<n;++r)if(t[r].modifierKind==e)return t[r];return null}function s(e,t){return null!=o(e,t)}function c(e,t){if(t)for(var r=0,n=t.length;r<n;++r){var i=t[r],a=i.name;if(a.kind==f.IDENTIFIER&&a.text==e)return i}return null}function p(e,t){return null!=c(e,t)}function u(e,t){void 0===t&&(t=!1);var r=e.name.text,n=e.parent;return n&&(e.kind!=f.VARIABLEDECLARATION||n.kind!=f.VARIABLE||(n=n.parent))?n.kind==f.CLASSDECLARATION?u(n,t)+(s(Q.STATIC,e.modifiers)?y.STATIC_DELIMITER:y.INSTANCE_DELIMITER)+r:n.kind==f.NAMESPACEDECLARATION||n.kind==f.ENUMDECLARATION?u(n,t)+y.STATIC_DELIMITER+r:t?r:e.range.source.internalPath+y.PATH_DELIMITER+r:r}function l(e){return e.endsWith(".ts")&&(e=e.substring(0,e.length-3)),e}function h(e,t){for(var r=0,n=e.length;r<n;++r)e[r].parent=t}function d(e,t){for(var r=0,n=e.length;r<n;++r){var i=e[r];i&&(i.parent=t)}}var _=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var y=r(2),m=r(7);t.Token=m.Token,t.Range=m.Range;var f,E=r(10);!function(e){e[e.SOURCE=0]="SOURCE",e[e.TYPE=1]="TYPE",e[e.TYPEPARAMETER=2]="TYPEPARAMETER",e[e.IDENTIFIER=3]="IDENTIFIER",e[e.ASSERTION=4]="ASSERTION",e[e.BINARY=5]="BINARY",e[e.CALL=6]="CALL",e[e.COMMA=7]="COMMA",e[e.ELEMENTACCESS=8]="ELEMENTACCESS",e[e.FALSE=9]="FALSE",e[e.LITERAL=10]="LITERAL",e[e.NEW=11]="NEW",e[e.NULL=12]="NULL",e[e.PARENTHESIZED=13]="PARENTHESIZED",e[e.PROPERTYACCESS=14]="PROPERTYACCESS",e[e.TERNARY=15]="TERNARY",e[e.SUPER=16]="SUPER",e[e.THIS=17]="THIS",e[e.TRUE=18]="TRUE",e[e.CONSTRUCTOR=19]="CONSTRUCTOR",e[e.UNARYPOSTFIX=20]="UNARYPOSTFIX",e[e.UNARYPREFIX=21]="UNARYPREFIX",e[e.BLOCK=22]="BLOCK",e[e.BREAK=23]="BREAK",e[e.CONTINUE=24]="CONTINUE",e[e.DO=25]="DO",e[e.EMPTY=26]="EMPTY",e[e.EXPORT=27]="EXPORT",e[e.EXPORTIMPORT=28]="EXPORTIMPORT",e[e.EXPRESSION=29]="EXPRESSION",e[e.FOR=30]="FOR",e[e.IF=31]="IF",e[e.IMPORT=32]="IMPORT",e[e.RETURN=33]="RETURN",e[e.SWITCH=34]="SWITCH",e[e.THROW=35]="THROW",e[e.TRY=36]="TRY",e[e.VARIABLE=37]="VARIABLE",e[e.WHILE=38]="WHILE",e[e.CLASSDECLARATION=39]="CLASSDECLARATION",e[e.ENUMDECLARATION=40]="ENUMDECLARATION",e[e.ENUMVALUEDECLARATION=41]="ENUMVALUEDECLARATION",e[e.FIELDDECLARATION=42]="FIELDDECLARATION",e[e.FUNCTIONDECLARATION=43]="FUNCTIONDECLARATION",e[e.IMPORTDECLARATION=44]="IMPORTDECLARATION",e[e.INTERFACEDECLARATION=45]="INTERFACEDECLARATION",e[e.METHODDECLARATION=46]="METHODDECLARATION",e[e.NAMESPACEDECLARATION=47]="NAMESPACEDECLARATION",e[e.TYPEDECLARATION=48]="TYPEDECLARATION",e[e.VARIABLEDECLARATION=49]="VARIABLEDECLARATION",e[e.DECORATOR=50]="DECORATOR",e[e.EXPORTMEMBER=51]="EXPORTMEMBER",e[e.MODIFIER=52]="MODIFIER",e[e.PARAMETER=53]="PARAMETER",e[e.SWITCHCASE=54]="SWITCHCASE"}(f=t.NodeKind||(t.NodeKind={}));var g=function(){function e(){this.parent=null}return e.createType=function(e,t,r,n){var i=new T;return i.range=n,i.name=e,i.typeArguments=t,i.isNullable=r,i},e.createIdentifierExpression=function(e,t){var r=new v;return r.range=t,r.text=e,r},e.createArrayLiteralExpression=function(e,t){var r=new S;return r.range=t,r.elementExpressions=e,d(e,r),r},e.createAssertionExpression=function(e,t,r,n){var i=new C;return i.range=n,i.assertionKind=e,i.expression=t,t.parent=i,i.toType=r,r.parent=i,i},e.createBinaryExpression=function(e,t,r,n){var i=new O;return i.range=n,i.operator=e,i.left=t,t.parent=i,i.right=r,r.parent=i,i},e.createCallExpression=function(e,t,r,n){var i=new b;return i.range=n,i.expression=e,e.parent=i,i.typeArguments=t,t&&h(t,i),i.arguments=r,h(r,i),i},e.createCommaExpression=function(e,t){var r=new k;return r.range=t,r.expressions=e,h(e,r),r},e.createConstructorExpression=function(e){var t=new x;return t.range=e,t},e.createElementAccessExpression=function(e,t,r){var n=new L;return n.range=r,n.expression=e,e.parent=n,n.elementExpression=t,t.parent=n,n},e.createFalseExpression=function(e){var t=new V;return t.range=e,t},e.createFloatLiteralExpression=function(e,t){var r=new R;return r.range=t,r.value=e,r},e.createIntegerLiteralExpression=function(e,t){var r=new B;return r.range=t,r.value=e,r},e.createNewExpression=function(e,t,r,n){var i=new F;return i.range=n,i.expression=e,e.parent=i,i.typeArguments=t,t&&h(t,i),i.arguments=r,h(r,i),i},e.createNullExpression=function(e){var t=new U;return t.range=e,t},e.createParenthesizedExpression=function(e,t){var r=new D;return r.range=t,r.expression=e,e.parent=r,r},e.createPropertyAccessExpression=function(e,t,r){var n=new w;return n.range=r,n.expression=e,e.parent=n,n.property=t,t.parent=n,n},e.createRegexpLiteralExpression=function(e,t,r){var n=new P;return n.range=r,n.pattern=e,n.patternFlags=t,n},e.createTernaryExpression=function(e,t,r,n){var i=new M;return i.range=n,i.condition=e,e.parent=i,i.ifThen=t,t.parent=i,i.ifElse=r,r.parent=i,i},e.createStringLiteralExpression=function(e,t){var r=new G;return r.range=t,r.value=e,r},e.createSuperExpression=function(e){var t=new K;return t.range=e,t},e.createThisExpression=function(e){var t=new z;return t.range=e,t},e.createTrueExpression=function(e){var t=new H;return t.range=e,t},e.createUnaryPostfixExpression=function(e,t,r){var n=new Y;return n.range=r,n.operator=e,n.operand=t,t.parent=n,n},e.createUnaryPrefixExpression=function(e,t,r){var n=new X;return n.range=r,n.operator=e,n.operand=t,t.parent=n,n},e.createBlockStatement=function(e,t){var r=new ee;return r.range=t,r.statements=e,h(e,r),r},e.createBreakStatement=function(e,t){var r=new te;return r.range=t,r.label=e,e&&(e.parent=r),r},e.createClassDeclaration=function(e,t,r,n,i,a,o,s){var c=new re;return c.range=s,c.name=e,e.parent=c,c.typeParameters=t,h(t,c),c.extendsType=r,r&&(r.parent=c),c.implementsTypes=n,h(n,c),c.members=i,h(i,c),c.modifiers=a,a&&h(a,c),c.decorators=o,o&&h(o,c),c},e.createContinueStatement=function(e,t){var r=new ne;return r.range=t,r.label=e,e&&(e.parent=r),r},e.createDecorator=function(e,t,r){var n=new ie;if(n.range=r,n.name=e,e.parent=n,n.arguments=t,t&&h(t,n),e.kind==f.IDENTIFIER)switch(e.text){case"global":n.decoratorKind=1;break;case"operator":n.decoratorKind=2;break;case"unmanaged":n.decoratorKind=3;break;case"offset":n.decoratorKind=4;break;default:n.decoratorKind=0}else n.decoratorKind=0;return n},e.createDoStatement=function(e,t,r){var n=new ae;return n.range=r,n.statement=e,e.parent=n,n.condition=t,t.parent=n,n},e.createEmptyStatement=function(e){var t=new oe;return t.range=e,t},e.createEnumDeclaration=function(e,t,r,n,i){var a=new se;return a.range=i,a.name=e,e.parent=a,a.values=t,h(t,a),a.modifiers=r,r&&h(r,a),a.decorators=n,n&&h(n,a),a},e.createEnumValueDeclaration=function(e,t,r){var n=new ce;return n.range=r,n.name=e,e.parent=n,n.value=t,t&&(t.parent=n),n},e.createExportStatement=function(e,t,r,n){var i=new le;if(i.range=n,i.members=e,h(e,i),i.path=t,t){var a=E.normalize(t.value);t.value.startsWith(".")?i.normalizedPath=E.resolve(a,n.source.normalizedPath):i.normalizedPath=a,i.internalPath=l(i.normalizedPath)}else i.normalizedPath=null,i.internalPath=null;return i.modifiers=r,r&&h(r,i),i},e.createExportImportStatement=function(e,t,r){var n=new pe;return n.range=r,n.name=e,e.parent=n,n.externalName=t,t.parent=n,n},e.createExportMember=function(e,t,r){var n=new ue;return n.range=r,n.name=e,e.parent=n,t?t.parent=n:t=e,n.externalName=t,n},e.createExpressionStatement=function(e){var t=new he;return t.range=e.range,t.expression=e,e.parent=t,t},e.createIfStatement=function(e,t,r,n){var i=new me;return i.range=n,i.condition=e,e.parent=i,i.ifTrue=t,t.parent=i,i.ifFalse=r,r&&(r.parent=i),i},e.createImportStatement=function(e,t,r){var n=new Ee;n.range=r,n.declarations=e,e&&h(e,n),n.namespaceName=null,n.path=t;var i=E.normalize(t.value);return t.value.startsWith(".")?n.normalizedPath=E.resolve(i,r.source.normalizedPath):n.normalizedPath=i,n.internalPath=l(n.normalizedPath),n},e.createImportStatementWithWildcard=function(e,t,r){var n=new Ee;return n.range=r,n.declarations=null,n.namespaceName=e,n.path=t,n.normalizedPath=E.resolve(E.normalize(t.value),r.source.normalizedPath),n.internalPath=l(n.normalizedPath),n},e.createImportDeclaration=function(e,t,r){var n=new fe;return n.range=r,n.externalName=e,e.parent=n,t?t.parent=n:t=e,n.name=t,n},e.createInterfaceDeclaration=function(e,t,r,n,i){var a=new ge;return a.range=i,a.name=e,e.parent=a,a.extendsType=t,t&&(t.parent=a),a.members=r,h(r,a),a.modifiers=n,n&&h(n,a),a},e.createFieldDeclaration=function(e,t,r,n,i,a){var o=new de;return o.range=a,o.name=e,e.parent=o,o.type=t,t&&(t.parent=o),o.initializer=r,r&&(r.parent=o),o.modifiers=n,n&&h(n,o),o.decorators=i,i&&h(i,o),o},e.createForStatement=function(e,t,r,n,i){var a=new _e;return a.range=i,a.initializer=e,e&&(e.parent=a),a.condition=t,t&&(t.parent=a),a.incrementor=r,r&&(r.parent=a),a.statement=n,n.parent=a,a},e.createTypeParameter=function(e,t,r){var n=new A;return n.range=r,n.name=e,e.parent=n,n.extendsType=t,t&&(t.parent=n),n},e.createParameter=function(e,t,r,n,i){var a=new Ie;return a.range=i,a.name=e,e.parent=a,a.type=t,t&&(t.parent=a),a.initializer=r,r&&(r.parent=a),a.parameterKind=n,a},e.createFunctionDeclaration=function(e,t,r,n,i,a,o,s){var c=new ye;return c.range=s,c.name=e,e.parent=c,c.typeParameters=t,h(t,c),c.parameters=r,h(r,c),c.returnType=n,n&&(n.parent=c),c.statements=i,i&&h(i,c),c.modifiers=a,a&&h(a,c),c.decorators=o,o&&h(o,c),c},e.createMethodDeclaration=function(e,t,r,n,i,a,o,s){var c=new Te;return c.range=s,c.name=e,e.parent=c,c.typeParameters=t,h(t,c),c.parameters=r,h(r,c),c.returnType=n,n&&(n.parent=c),c.statements=i,i&&h(i,c),c.modifiers=a,a&&h(a,c),c.decorators=o,o&&h(o,c),c},e.createModifier=function(e,t){var r=new ve;return r.range=t,r.modifierKind=e,r},e.createNamespaceDeclaration=function(e,t,r,n,i){var a=new Ae;return a.range=i,a.name=e,e.parent=a,a.members=t,h(t,a),a.modifiers=r,r&&h(r,a),a.decorators=n,n&&h(n,a),a},e.createReturnStatement=function(e,t){var r=new Ne;return r.range=t,r.value=e,e&&(e.parent=r),r},e.createSwitchStatement=function(e,t,r){var n=new Ce;return n.range=r,n.condition=e,e.parent=n,n.cases=t,h(t,n),n},e.createSwitchCase=function(e,t,r){var n=new Se;return n.range=r,n.label=e,e&&(e.parent=n),n.statements=t,h(t,n),n},e.createThrowStatement=function(e,t){var r=new Oe;return r.range=t,r.value=e,e.parent=r,r},e.createTryStatement=function(e,t,r,n,i){var a=new be;return a.range=i,a.statements=e,h(e,a),a.catchVariable=t,t&&(t.parent=a),a.catchStatements=r,r&&h(r,a),a.finallyStatements=n,n&&h(n,a),a},e.createTypeDeclaration=function(e,t,r,n,i){var a=new ke;return a.range=i,a.name=e,e.parent=a,a.alias=t,t.parent=a,a.modifiers=r,r&&h(r,a),a.decorators=n,n&&h(n,a),a},e.createVariableStatement=function(e,t,r,n){var i=new Le;return i.range=n,i.declarations=e,h(e,i),i.modifiers=t,t&&h(t,i),i.decorators=r,r&&h(r,i),i},e.createVariableDeclaration=function(e,t,r,n,i,a){var o=new xe;return o.range=a,o.name=e,e.parent=o,o.type=t,t&&(t.parent=o),o.initializer=r,r&&(r.parent=o),o.modifiers=n,o.decorators=i,o},e.createWhileStatement=function(e,t,r){var n=new Re;return n.range=r,n.condition=e,e.parent=n,n.statement=t,t.parent=n,n},e}();t.Node=g;var T=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.TYPE,t}return _(t,e),t}(g);t.TypeNode=T;var A=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.TYPEPARAMETER,t}return _(t,e),t}(g);t.TypeParameter=A;var I=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return _(t,e),t}(g);t.Expression=I;var v=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.IDENTIFIER,t}return _(t,e),t}(I);t.IdentifierExpression=v;!function(e){e[e.FLOAT=0]="FLOAT",e[e.INTEGER=1]="INTEGER",e[e.STRING=2]="STRING",e[e.REGEXP=3]="REGEXP",e[e.ARRAY=4]="ARRAY",e[e.OBJECT=5]="OBJECT"}(t.LiteralKind||(t.LiteralKind={}));var N=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.LITERAL,t}return _(t,e),t}(I);t.LiteralExpression=N;var S=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=4,t}return _(t,e),t}(N);t.ArrayLiteralExpression=S;!function(e){e[e.PREFIX=0]="PREFIX",e[e.AS=1]="AS"}(t.AssertionKind||(t.AssertionKind={}));var C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.ASSERTION,t}return _(t,e),t}(I);t.AssertionExpression=C;var O=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.BINARY,t}return _(t,e),t}(I);t.BinaryExpression=O;var b=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.CALL,t}return _(t,e),t}(I);t.CallExpression=b;var k=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.COMMA,t}return _(t,e),t}(I);t.CommaExpression=k;var x=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.CONSTRUCTOR,t.text="constructor",t}return _(t,e),t}(v);t.ConstructorExpression=x;var L=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.ELEMENTACCESS,t}return _(t,e),t}(I);t.ElementAccessExpression=L;var R=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=0,t}return _(t,e),t}(N);t.FloatLiteralExpression=R;var B=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=1,t}return _(t,e),t}(N);t.IntegerLiteralExpression=B;var F=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.NEW,t}return _(t,e),t}(b);t.NewExpression=F;var U=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.NULL,t.text="null",t}return _(t,e),t}(v);t.NullExpression=U;var D=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.PARENTHESIZED,t}return _(t,e),t}(I);t.ParenthesizedExpression=D;var w=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.PROPERTYACCESS,t}return _(t,e),t}(I);t.PropertyAccessExpression=w;var P=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=3,t}return _(t,e),t}(N);t.RegexpLiteralExpression=P;var M=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.TERNARY,t}return _(t,e),t}(I);t.TernaryExpression=M;var G=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=2,t}return _(t,e),t}(N);t.StringLiteralExpression=G;var K=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.SUPER,t.text="super",t}return _(t,e),t}(v);t.SuperExpression=K;var z=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.THIS,t.text="this",t}return _(t,e),t}(v);t.ThisExpression=z;var H=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.TRUE,t.text="true",t}return _(t,e),t}(v);t.TrueExpression=H;var V=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.FALSE,t.text="false",t}return _(t,e),t}(v);t.FalseExpression=V;var W=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return _(t,e),t}(I);t.UnaryExpression=W;var Y=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.UNARYPOSTFIX,t}return _(t,e),t}(W);t.UnaryPostfixExpression=Y;var X=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.UNARYPREFIX,t}return _(t,e),t}(W);t.UnaryPrefixExpression=X;var Q;!function(e){e[e.ASYNC=0]="ASYNC",e[e.CONST=1]="CONST",e[e.LET=2]="LET",e[e.DECLARE=3]="DECLARE",e[e.EXPORT=4]="EXPORT",e[e.IMPORT=5]="IMPORT",e[e.STATIC=6]="STATIC",e[e.ABSTRACT=7]="ABSTRACT",e[e.PUBLIC=8]="PUBLIC",e[e.PRIVATE=9]="PRIVATE",e[e.PROTECTED=10]="PROTECTED",e[e.READONLY=11]="READONLY",e[e.GET=12]="GET",e[e.SET=13]="SET"}(Q=t.ModifierKind||(t.ModifierKind={}));var q=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return _(t,e),t}(g);t.Statement=q;var j;!function(e){e[e.DEFAULT=0]="DEFAULT",e[e.ENTRY=1]="ENTRY",e[e.LIBRARY=2]="LIBRARY"}(j=t.SourceKind||(t.SourceKind={}));var Z=function(e){function t(t,r,n){var i=e.call(this)||this;return i.kind=f.SOURCE,i.parent=null,i.tokenizer=null,i.debugInfoIndex=-1,i.sourceKind=n,i.normalizedPath=t,i.internalPath=l(i.normalizedPath),i.statements=new Array,i.range=new m.Range(i,0,r.length),i.text=r,i}return _(t,e),Object.defineProperty(t.prototype,"isEntry",{get:function(){return this.sourceKind==j.ENTRY},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isLibrary",{get:function(){return this.sourceKind==j.LIBRARY},enumerable:!0,configurable:!0}),t}(g);t.Source=Z;var $=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.decorators=null,t.cachedProgramLevelInternalName=null,t.cachedFileLevelInternalName=null,t}return _(t,e),Object.defineProperty(t.prototype,"programLevelInternalName",{get:function(){return this.cachedProgramLevelInternalName||(this.cachedProgramLevelInternalName=u(this,!0)),this.cachedProgramLevelInternalName},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fileLevelInternalName",{get:function(){return this.cachedFileLevelInternalName||(this.cachedFileLevelInternalName=u(this,!1)),this.cachedFileLevelInternalName},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isTopLevel",{get:function(){var e=this.parent;return!!e&&(!(e.kind==f.VARIABLE&&!(e=e.parent))&&e.kind==f.SOURCE)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isTopLevelExport",{get:function(){var e=this.parent;return!(!e||e.kind==f.VARIABLE&&!(e=e.parent))&&(e.kind==f.NAMESPACEDECLARATION?s(Q.EXPORT,this.modifiers)&&e.isTopLevelExport:e.kind==f.CLASSDECLARATION?s(Q.STATIC,this.modifiers)&&e.isTopLevelExport:e.kind==f.SOURCE&&s(Q.EXPORT,this.modifiers))},enumerable:!0,configurable:!0}),t.prototype.needsExplicitExport=function(e){return e.name.text!=e.externalName.text||this.range.source!=e.range.source||!this.isTopLevelExport},t}(q);t.DeclarationStatement=$;var J=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return _(t,e),t}($);t.VariableLikeDeclarationStatement=J;var ee=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.BLOCK,t}return _(t,e),t}(q);t.BlockStatement=ee;var te=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.BREAK,t}return _(t,e),t}(q);t.BreakStatement=te;var re=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.CLASSDECLARATION,t}return _(t,e),t}($);t.ClassDeclaration=re;var ne=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.CONTINUE,t}return _(t,e),t}(q);t.ContinueStatement=ne;!function(e){e[e.CUSTOM=0]="CUSTOM",e[e.GLOBAL=1]="GLOBAL",e[e.OPERATOR=2]="OPERATOR",e[e.UNMANAGED=3]="UNMANAGED",e[e.OFFSET=4]="OFFSET"}(t.DecoratorKind||(t.DecoratorKind={}));var ie=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.DECORATOR,t}return _(t,e),t}(q);t.Decorator=ie;var ae=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.DO,t}return _(t,e),t}(q);t.DoStatement=ae;var oe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.EMPTY,t}return _(t,e),t}(q);t.EmptyStatement=oe;var se=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.ENUMDECLARATION,t}return _(t,e),t}($);t.EnumDeclaration=se;var ce=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.ENUMVALUEDECLARATION,t.modifiers=null,t}return _(t,e),t}($);t.EnumValueDeclaration=ce;var pe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.EXPORTIMPORT,t}return _(t,e),t}(g);t.ExportImportStatement=pe;var ue=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.EXPORTMEMBER,t}return _(t,e),t}(g);t.ExportMember=ue;var le=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.EXPORT,t}return _(t,e),t}(q);t.ExportStatement=le;var he=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.EXPRESSION,t}return _(t,e),t}(q);t.ExpressionStatement=he;var de=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.FIELDDECLARATION,t}return _(t,e),t}(J);t.FieldDeclaration=de;var _e=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.FOR,t}return _(t,e),t}(q);t.ForStatement=_e;var ye=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.FUNCTIONDECLARATION,t}return _(t,e),t}($);t.FunctionDeclaration=ye;var me=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.IF,t}return _(t,e),t}(q);t.IfStatement=me;var fe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.IMPORTDECLARATION,t.modifiers=null,t}return _(t,e),t}($);t.ImportDeclaration=fe;var Ee=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.IMPORT,t}return _(t,e),t}(q);t.ImportStatement=Ee;var ge=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.INTERFACEDECLARATION,t}return _(t,e),t}(re);t.InterfaceDeclaration=ge;var Te=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.METHODDECLARATION,t}return _(t,e),t}(ye);t.MethodDeclaration=Te;var Ae=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.NAMESPACEDECLARATION,t}return _(t,e),t}($);t.NamespaceDeclaration=Ae;!function(e){e[e.DEFAULT=0]="DEFAULT",e[e.OPTIONAL=1]="OPTIONAL",e[e.REST=2]="REST"}(t.ParameterKind||(t.ParameterKind={}));var Ie=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.PARAMETER,t}return _(t,e),t}(g);t.Parameter=Ie;var ve=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.MODIFIER,t}return _(t,e),t}(g);t.Modifier=ve;var Ne=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.RETURN,t}return _(t,e),t}(q);t.ReturnStatement=Ne;var Se=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.SWITCHCASE,t}return _(t,e),t}(g);t.SwitchCase=Se;var Ce=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.SWITCH,t}return _(t,e),t}(q);t.SwitchStatement=Ce;var Oe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.THROW,t}return _(t,e),t}(q);t.ThrowStatement=Oe;var be=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.TRY,t}return _(t,e),t}(q);t.TryStatement=be;var ke=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.TYPEDECLARATION,t}return _(t,e),t}($);t.TypeDeclaration=ke;var xe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.VARIABLEDECLARATION,t}return _(t,e),t}(J);t.VariableDeclaration=xe;var Le=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.VARIABLE,t}return _(t,e),t}(q);t.VariableStatement=Le;var Re=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=f.WHILE,t}return _(t,e),t}(q);t.WhileStatement=Re;var Be=null;t.setReusableModifiers=n,t.createModifiers=i,t.addModifier=a,t.getModifier=o,t.hasModifier=s,t.getFirstDecorator=c,t.hasDecorator=p,t.mangleInternalName=u,t.mangleInternalPath=l},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var i,a=r(1),o=r(9);!function(e){e[e.ABSTRACT=0]="ABSTRACT",e[e.AS=1]="AS",e[e.ASYNC=2]="ASYNC",e[e.AWAIT=3]="AWAIT",e[e.BREAK=4]="BREAK",e[e.CASE=5]="CASE",e[e.CATCH=6]="CATCH",e[e.CLASS=7]="CLASS",e[e.CONST=8]="CONST",e[e.CONTINUE=9]="CONTINUE",e[e.CONSTRUCTOR=10]="CONSTRUCTOR",e[e.DEBUGGER=11]="DEBUGGER",e[e.DECLARE=12]="DECLARE",e[e.DEFAULT=13]="DEFAULT",e[e.DELETE=14]="DELETE",e[e.DO=15]="DO",e[e.ELSE=16]="ELSE",e[e.ENUM=17]="ENUM",e[e.EXPORT=18]="EXPORT",e[e.EXTENDS=19]="EXTENDS",e[e.FALSE=20]="FALSE",e[e.FINALLY=21]="FINALLY",e[e.FOR=22]="FOR",e[e.FROM=23]="FROM",e[e.FUNCTION=24]="FUNCTION",e[e.GET=25]="GET",e[e.IF=26]="IF",e[e.IMPLEMENTS=27]="IMPLEMENTS",e[e.IMPORT=28]="IMPORT",e[e.IN=29]="IN",e[e.INSTANCEOF=30]="INSTANCEOF",e[e.INTERFACE=31]="INTERFACE",e[e.IS=32]="IS",e[e.KEYOF=33]="KEYOF",e[e.LET=34]="LET",e[e.MODULE=35]="MODULE",e[e.NAMESPACE=36]="NAMESPACE",e[e.NEW=37]="NEW",e[e.NULL=38]="NULL",e[e.OF=39]="OF",e[e.PACKAGE=40]="PACKAGE",e[e.PRIVATE=41]="PRIVATE",e[e.PROTECTED=42]="PROTECTED",e[e.PUBLIC=43]="PUBLIC",e[e.READONLY=44]="READONLY",e[e.RETURN=45]="RETURN",e[e.SET=46]="SET",e[e.STATIC=47]="STATIC",e[e.SUPER=48]="SUPER",e[e.SWITCH=49]="SWITCH",e[e.THIS=50]="THIS",e[e.THROW=51]="THROW",e[e.TRUE=52]="TRUE",e[e.TRY=53]="TRY",e[e.TYPE=54]="TYPE",e[e.TYPEOF=55]="TYPEOF",e[e.VAR=56]="VAR",e[e.VOID=57]="VOID",e[e.WHILE=58]="WHILE",e[e.WITH=59]="WITH",e[e.YIELD=60]="YIELD",e[e.OPENBRACE=61]="OPENBRACE",e[e.CLOSEBRACE=62]="CLOSEBRACE",e[e.OPENPAREN=63]="OPENPAREN",e[e.CLOSEPAREN=64]="CLOSEPAREN",e[e.OPENBRACKET=65]="OPENBRACKET",e[e.CLOSEBRACKET=66]="CLOSEBRACKET",e[e.DOT=67]="DOT",e[e.DOT_DOT_DOT=68]="DOT_DOT_DOT",e[e.SEMICOLON=69]="SEMICOLON",e[e.COMMA=70]="COMMA",e[e.LESSTHAN=71]="LESSTHAN",e[e.GREATERTHAN=72]="GREATERTHAN",e[e.LESSTHAN_EQUALS=73]="LESSTHAN_EQUALS",e[e.GREATERTHAN_EQUALS=74]="GREATERTHAN_EQUALS",e[e.EQUALS_EQUALS=75]="EQUALS_EQUALS",e[e.EXCLAMATION_EQUALS=76]="EXCLAMATION_EQUALS",e[e.EQUALS_EQUALS_EQUALS=77]="EQUALS_EQUALS_EQUALS",e[e.EXCLAMATION_EQUALS_EQUALS=78]="EXCLAMATION_EQUALS_EQUALS",e[e.EQUALS_GREATERTHAN=79]="EQUALS_GREATERTHAN",e[e.PLUS=80]="PLUS",e[e.MINUS=81]="MINUS",e[e.ASTERISK_ASTERISK=82]="ASTERISK_ASTERISK",e[e.ASTERISK=83]="ASTERISK",e[e.SLASH=84]="SLASH",e[e.PERCENT=85]="PERCENT",e[e.PLUS_PLUS=86]="PLUS_PLUS",e[e.MINUS_MINUS=87]="MINUS_MINUS",e[e.LESSTHAN_LESSTHAN=88]="LESSTHAN_LESSTHAN",e[e.GREATERTHAN_GREATERTHAN=89]="GREATERTHAN_GREATERTHAN",e[e.GREATERTHAN_GREATERTHAN_GREATERTHAN=90]="GREATERTHAN_GREATERTHAN_GREATERTHAN",e[e.AMPERSAND=91]="AMPERSAND",e[e.BAR=92]="BAR",e[e.CARET=93]="CARET",e[e.EXCLAMATION=94]="EXCLAMATION",e[e.TILDE=95]="TILDE",e[e.AMPERSAND_AMPERSAND=96]="AMPERSAND_AMPERSAND",e[e.BAR_BAR=97]="BAR_BAR",e[e.QUESTION=98]="QUESTION",e[e.COLON=99]="COLON",e[e.EQUALS=100]="EQUALS",e[e.PLUS_EQUALS=101]="PLUS_EQUALS",e[e.MINUS_EQUALS=102]="MINUS_EQUALS",e[e.ASTERISK_EQUALS=103]="ASTERISK_EQUALS",e[e.ASTERISK_ASTERISK_EQUALS=104]="ASTERISK_ASTERISK_EQUALS",e[e.SLASH_EQUALS=105]="SLASH_EQUALS",e[e.PERCENT_EQUALS=106]="PERCENT_EQUALS",e[e.LESSTHAN_LESSTHAN_EQUALS=107]="LESSTHAN_LESSTHAN_EQUALS",e[e.GREATERTHAN_GREATERTHAN_EQUALS=108]="GREATERTHAN_GREATERTHAN_EQUALS",e[e.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS=109]="GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS",e[e.AMPERSAND_EQUALS=110]="AMPERSAND_EQUALS",e[e.BAR_EQUALS=111]="BAR_EQUALS",e[e.CARET_EQUALS=112]="CARET_EQUALS",e[e.AT=113]="AT",e[e.IDENTIFIER=114]="IDENTIFIER",e[e.STRINGLITERAL=115]="STRINGLITERAL",e[e.INTEGERLITERAL=116]="INTEGERLITERAL",e[e.FLOATLITERAL=117]="FLOATLITERAL",e[e.INVALID=118]="INVALID",e[e.ENDOFFILE=119]="ENDOFFILE"}(i=t.Token||(t.Token={})),function(e){function t(t){switch(t){case"abstract":return e.ABSTRACT;case"as":return e.AS;case"async":return e.ASYNC;case"await":return e.AWAIT;case"break":return e.BREAK;case"case":return e.CASE;case"catch":return e.CATCH;case"class":return e.CLASS;case"continue":return e.CONTINUE;case"const":return e.CONST;case"constructor":return e.CONSTRUCTOR;case"debugger":return e.DEBUGGER;case"declare":return e.DECLARE;case"default":return e.DEFAULT;case"delete":return e.DELETE;case"do":return e.DO;case"else":return e.ELSE;case"enum":return e.ENUM;case"export":return e.EXPORT;case"extends":return e.EXTENDS;case"false":return e.FALSE;case"finally":return e.FINALLY;case"for":return e.FOR;case"from":return e.FROM;case"function":return e.FUNCTION;case"get":return e.GET;case"if":return e.IF;case"implements":return e.IMPLEMENTS;case"import":return e.IMPORT;case"in":return e.IN;case"instanceof":return e.INSTANCEOF;case"interface":return e.INTERFACE;case"is":return e.IS;case"keyof":return e.KEYOF;case"let":return e.LET;case"module":return e.MODULE;case"namespace":return e.NAMESPACE;case"new":return e.NEW;case"null":return e.NULL;case"of":return e.OF;case"package":return e.PACKAGE;case"private":return e.PRIVATE;case"protected":return e.PROTECTED;case"public":return e.PUBLIC;case"readonly":return e.READONLY;case"return":return e.RETURN;case"set":return e.SET;case"static":return e.STATIC;case"super":return e.SUPER;case"switch":return e.SWITCH;case"this":return e.THIS;case"throw":return e.THROW;case"true":return e.TRUE;case"try":return e.TRY;case"type":return e.TYPE;case"typeof":return e.TYPEOF;case"var":return e.VAR;case"void":return e.VOID;case"while":return e.WHILE;case"with":return e.WITH;case"yield":return e.YIELD;default:return e.INVALID}}function r(t){switch(t){case e.ABSTRACT:case e.AS:case e.CONSTRUCTOR:case e.DECLARE:case e.DELETE:case e.FROM:case e.GET:case e.IS:case e.KEYOF:case e.MODULE:case e.NAMESPACE:case e.READONLY:case e.SET:case e.TYPE:return!0;default:return!1}}e.fromKeyword=t,e.isAlsoIdentifier=r}(i=t.Token||(t.Token={}));var s=function(){function e(e,t,r){this.debugInfoRef=0,this.source=e,this.start=t,this.end=r}return e.join=function(t,r){if(t.source!=r.source)throw new Error("source mismatch");return new e(t.source,t.start<r.start?t.start:r.start,t.end>r.end?t.end:r.end)},Object.defineProperty(e.prototype,"atStart",{get:function(){return new e(this.source,this.start,this.start)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"atEnd",{get:function(){return new e(this.source,this.end,this.end)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"line",{get:function(){for(var e=this.source.text,t=this.start,r=1;t-- >0;)10==e.charCodeAt(t)&&r++;return r},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"column",{get:function(){for(var e=this.source.text,t=this.start,r=0;t-- >0&&10!=e.charCodeAt(t);)r++;return r},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return this.source.text.substring(this.start,this.end)},e}();t.Range=s;var c=function(e){function t(t,r){void 0===r&&(r=null);var n=e.call(this,r)||this;n.end=0,n.pos=0,n.token=-1,n.tokenPos=0,n.markedPos=0,n.markedToken=-1,n.markedTokenPos=0,n.nextToken=-1,n.nextTokenOnNewLine=!1,n.source=t,n.pos=0,n.end=t.text.length,n.diagnostics=r||new Array;var i=t.text;if(n.pos<n.end&&65279==i.charCodeAt(n.pos)&&++n.pos,n.pos+1<n.end&&35==i.charCodeAt(n.pos)&&33==i.charCodeAt(n.pos+1))for(n.pos+=2;n.pos<n.end&&10!=i.charCodeAt(n.pos);)++n.pos;return n}return n(t,e),t.prototype.next=function(e){return void 0===e&&(e=!1),this.nextToken=-1,this.token=this.unsafeNext(e)},t.prototype.unsafeNext=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=i32.MAX_VALUE);for(var r=this.source.text;this.pos<this.end;){this.tokenPos=this.pos;var n=r.charCodeAt(this.pos);switch(n){case 13:++this.pos<this.end&&10==r.charCodeAt(this.pos)&&++this.pos;break;case 10:case 9:case 11:case 12:case 32:++this.pos;break;case 33:return++this.pos,t>1&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,t>2&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.EXCLAMATION_EQUALS_EQUALS):i.EXCLAMATION_EQUALS):i.EXCLAMATION;case 34:case 39:case 96:return i.STRINGLITERAL;case 37:return++this.pos,t>1&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.PERCENT_EQUALS):i.PERCENT;case 38:if(++this.pos,t>1&&this.pos<this.end){if(38==r.charCodeAt(this.pos))return++this.pos,i.AMPERSAND_AMPERSAND;if(61==r.charCodeAt(this.pos))return++this.pos,i.AMPERSAND_EQUALS}return i.AMPERSAND;case 40:return++this.pos,i.OPENPAREN;case 41:return++this.pos,i.CLOSEPAREN;case 42:if(++this.pos,t>1&&this.pos<this.end){if(61==r.charCodeAt(this.pos))return++this.pos,i.ASTERISK_EQUALS;if(42==r.charCodeAt(this.pos))return++this.pos,t>2&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.ASTERISK_ASTERISK_EQUALS):i.ASTERISK_ASTERISK}return i.ASTERISK;case 43:if(++this.pos,t>1&&this.pos<this.end){if(43==r.charCodeAt(this.pos))return++this.pos,i.PLUS_PLUS;if(61==r.charCodeAt(this.pos))return++this.pos,i.PLUS_EQUALS}return i.PLUS;case 44:return++this.pos,i.COMMA;case 45:if(++this.pos,t>1&&this.pos<this.end){if(45==r.charCodeAt(this.pos))return++this.pos,i.MINUS_MINUS;if(61==r.charCodeAt(this.pos))return++this.pos,i.MINUS_EQUALS}return i.MINUS;case 46:if(++this.pos,t>1&&this.pos<this.end){if(o.isDecimalDigit(r.charCodeAt(this.pos)))return--this.pos,i.FLOATLITERAL;if(t>2&&this.pos+1<this.end&&46==r.charCodeAt(this.pos)&&46==r.charCodeAt(this.pos+1))return this.pos+=2,i.DOT_DOT_DOT}return i.DOT;case 47:if(++this.pos,t>1&&this.pos<this.end){if(47==r.charCodeAt(this.pos)){for(;++this.pos<this.end&&!o.isLineBreak(r.charCodeAt(this.pos)););continue}if(42==r.charCodeAt(this.pos)){for(var s=!1;++this.pos<this.end;)if(42==(n=r.charCodeAt(this.pos))&&this.pos+1<this.end&&47==r.charCodeAt(this.pos+1)){this.pos+=2,s=!0;break}s||this.error(a.DiagnosticCode._0_expected,this.range(this.pos),"*/");continue}if(61==r.charCodeAt(this.pos))return++this.pos,i.SLASH_EQUALS}return i.SLASH;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.testInteger()?i.INTEGERLITERAL:i.FLOATLITERAL;case 58:return++this.pos,i.COLON;case 59:return++this.pos,i.SEMICOLON;case 60:if(++this.pos,t>1&&this.pos<this.end){if(60==r.charCodeAt(this.pos))return++this.pos,t>2&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.LESSTHAN_LESSTHAN_EQUALS):i.LESSTHAN_LESSTHAN;if(61==r.charCodeAt(this.pos))return++this.pos,i.LESSTHAN_EQUALS}return i.LESSTHAN;case 61:if(++this.pos,t>1&&this.pos<this.end){if(61==r.charCodeAt(this.pos))return++this.pos,t>2&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.EQUALS_EQUALS_EQUALS):i.EQUALS_EQUALS;if(62==r.charCodeAt(this.pos))return++this.pos,i.EQUALS_GREATERTHAN}return i.EQUALS;case 62:if(++this.pos,t>1&&this.pos<this.end){if(62==r.charCodeAt(this.pos)){if(++this.pos,t>2&&this.pos<this.end){if(62==r.charCodeAt(this.pos))return++this.pos,t>3&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS):i.GREATERTHAN_GREATERTHAN_GREATERTHAN;if(61==r.charCodeAt(this.pos))return++this.pos,i.GREATERTHAN_GREATERTHAN_EQUALS}return i.GREATERTHAN_GREATERTHAN}if(61==r.charCodeAt(this.pos))return++this.pos,i.GREATERTHAN_EQUALS}return i.GREATERTHAN;case 63:return++this.pos,i.QUESTION;case 91:return++this.pos,i.OPENBRACKET;case 93:return++this.pos,i.CLOSEBRACKET;case 94:return++this.pos,t>1&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.CARET_EQUALS):i.CARET;case 123:return++this.pos,i.OPENBRACE;case 124:if(++this.pos,t>1&&this.pos<this.end){if(124==r.charCodeAt(this.pos))return++this.pos,i.BAR_BAR;if(61==r.charCodeAt(this.pos))return++this.pos,i.BAR_EQUALS}return i.BAR;case 125:return++this.pos,i.CLOSEBRACE;case 126:return++this.pos,i.TILDE;case 64:return++this.pos,i.AT;default:if(o.isIdentifierStart(n)){if(o.isKeywordCharacter(n)){for(var c=this.pos;++this.pos<this.end&&o.isIdentifierPart(n=r.charCodeAt(this.pos));)if(!o.isKeywordCharacter(n))return this.pos=c,i.IDENTIFIER;var p=r.substring(c,this.pos),u=i.fromKeyword(p);if(!(u==i.INVALID||e&&i.isAlsoIdentifier(u)))return u;this.pos=c}return i.IDENTIFIER}if(o.isWhiteSpace(n)){++this.pos;break}return this.error(a.DiagnosticCode.Invalid_character,this.range(this.pos,this.pos+1)),++this.pos,i.INVALID}}return i.ENDOFFILE},t.prototype.peek=function(e,t,r){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===r&&(r=i32.MAX_VALUE);var n=this.source.text;if(this.nextToken<0){var i=this.pos,a=this.token,s=this.tokenPos;if(this.nextToken=this.unsafeNext(t,r),e)for(this.nextTokenOnNewLine=!1;--this.tokenPos>i;)if(o.isLineBreak(n.charCodeAt(this.tokenPos))){this.nextTokenOnNewLine=!0;break}this.pos=i,this.token=a,this.tokenPos=s}return this.nextToken},t.prototype.skip=function(e){var t=this.pos,r=this.token,n=this.tokenPos,a=i32.MAX_VALUE;switch(e){case i.GREATERTHAN:a=1}return this.token=this.unsafeNext(e==i.IDENTIFIER,a),this.token==e?(this.nextToken=-1,!0):(this.pos=t,this.token=r,this.tokenPos=n,!1)},t.prototype.mark=function(){this.markedPos=this.pos,this.markedToken=this.token,this.markedTokenPos=this.tokenPos},t.prototype.reset=function(){this.pos=this.markedPos,this.token=this.markedToken,this.tokenPos=this.markedTokenPos,this.nextToken=-1},t.prototype.range=function(e,t){return void 0===e&&(e=-1),void 0===t&&(t=-1),e<0?(e=this.tokenPos,t=this.pos):t<0&&(t=e),new s(this.source,e,t)},t.prototype.readIdentifier=function(){for(var e=this.source.text,t=this.pos;++this.pos<this.end&&o.isIdentifierPart(e.charCodeAt(this.pos)););return e.substring(t,this.pos)},t.prototype.readString=function(){for(var e=this.source.text,t=e.charCodeAt(this.pos++),r=this.pos,n="";;){if(this.pos>=this.end){n+=e.substring(r,this.pos),this.error(a.DiagnosticCode.Unterminated_string_literal,this.range(r-1,this.end));break}var i=e.charCodeAt(this.pos);if(i==t){n+=e.substring(r,this.pos++);break}if(92!=i){if(o.isLineBreak(i)){n+=e.substring(r,this.pos),this.error(a.DiagnosticCode.Unterminated_string_literal,this.range(r-1,this.pos));break}++this.pos}else n+=e.substring(r,this.pos),n+=this.readEscapeSequence(),r=this.pos}return n},t.prototype.readEscapeSequence=function(){if(++this.pos>=this.end)return this.error(a.DiagnosticCode.Unexpected_end_of_text,this.range(this.end)),"";var e=this.source.text,t=e.charCodeAt(this.pos++);switch(t){case 48:return"\0";case 98:return"\b";case 116:return"\t";case 110:return"\n";case 118:return"\v";case 102:return"\f";case 114:return"\r";case 39:return"'";case 34:return'"';case 117:return this.pos<this.end&&123==e.charCodeAt(this.pos)?(++this.pos,this.readExtendedUnicodeEscape()):this.readUnicodeEscape();case 13:this.pos<this.end&&10==e.charCodeAt(this.pos)&&++this.pos;case 10:case 8232:case 8233:return"";default:return String.fromCharCode(t)}},t.prototype.readRegexpPattern=function(){for(var e=this.source.text,t=this.pos,r=!1;;){if(this.pos>=this.end){this.error(a.DiagnosticCode.Unterminated_regular_expression_literal,this.range(t,this.end));break}if(92!=e.charCodeAt(this.pos)){var n=e.charCodeAt(this.pos);if(47==n&&!r)break;if(o.isLineBreak(n)){this.error(a.DiagnosticCode.Unterminated_regular_expression_literal,this.range(t,this.pos));break}++this.pos,r=!1}else++this.pos,r=!0}return e.substring(t,this.pos)},t.prototype.readRegexpFlags=function(){for(var e=this.source.text,t=this.pos,r=0;this.pos<this.end;){var n=e.charCodeAt(this.pos);if(!o.isIdentifierPart(n))break;switch(++this.pos,n){case 103:r|=1&r?-1:1;break;case 105:r|=2&r?-1:2;break;case 109:r|=4&r?-1:4;break;default:r=-1}}return-1==r&&this.error(a.DiagnosticCode.Invalid_regular_expression_flags,this.range(t,this.pos)),e.substring(t,this.pos)},t.prototype.testInteger=function(){var e=this.source.text;if(48==e.charCodeAt(this.pos)&&this.pos+1<this.end)switch(e.charCodeAt(this.pos+2)){case 88:case 120:case 66:case 98:case 79:case 111:return!0}for(var t=this.pos;t<this.end;){var r=e.charCodeAt(t);if(46==r||69==r||101==r)return!1;if(r<48||r>57)break;t++}return!0},t.prototype.readInteger=function(){var e=this.source.text;if(48==e.charCodeAt(this.pos)&&this.pos+2<this.end){switch(e.charCodeAt(this.pos+1)){case 88:case 120:return this.pos+=2,this.readHexInteger();case 66:case 98:return this.pos+=2,this.readBinaryInteger();case 79:case 111:return this.pos+=2,this.readOctalInteger()}if(o.isOctalDigit(e.charCodeAt(this.pos+1))){var t=this.pos;++this.pos;var r=this.readOctalInteger();return this.error(a.DiagnosticCode.Octal_literals_are_not_allowed_in_strict_mode,this.range(t,this.pos)),r}}return this.readDecimalInteger()},t.prototype.readHexInteger=function(){for(var e=this.source.text,t=this.pos,r=i64_new(0,0),n=i64_new(16,0);this.pos<this.end;){var i=e.charCodeAt(this.pos);if(i>=48&&i<=57)r=i64_add(i64_mul(r,n),i64_new(i-48,0));else if(i>=65&&i<=70)r=i64_add(i64_mul(r,n),i64_new(10+i-65,0));else{if(!(i>=97&&i<=102))break;r=i64_add(i64_mul(r,n),i64_new(10+i-97,0))}++this.pos}return this.pos==t&&this.error(a.DiagnosticCode.Hexadecimal_digit_expected,this.range(t)),r},t.prototype.readDecimalInteger=function(){for(var e=this.source.text,t=this.pos,r=i64_new(0,0),n=i64_new(10,0);this.pos<this.end;){var i=e.charCodeAt(this.pos);if(!(i>=48&&i<=57))break;r=i64_add(i64_mul(r,n),i64_new(i-48,0)),++this.pos}return this.pos==t&&this.error(a.DiagnosticCode.Digit_expected,this.range(t)),r},t.prototype.readOctalInteger=function(){for(var e=this.source.text,t=this.pos,r=i64_new(0,0),n=i64_new(8,0);this.pos<this.end;){var i=e.charCodeAt(this.pos);if(!(i>=48&&i<=55))break;r=i64_add(i64_mul(r,n),i64_new(i-48,0)),++this.pos}return this.pos==t&&this.error(a.DiagnosticCode.Octal_digit_expected,this.range(t)),r},t.prototype.readBinaryInteger=function(){for(var e=this.source.text,t=this.pos,r=i64_new(0,0),n=i64_new(2,0),i=i64_new(1,0);this.pos<this.end;){var o=e.charCodeAt(this.pos);if(48==o)r=i64_mul(r,n);else{if(49!=o)break;r=i64_add(i64_mul(r,n),i)}++this.pos}return this.pos==t&&this.error(a.DiagnosticCode.Binary_digit_expected,this.range(t)),r},t.prototype.readFloat=function(){for(var e=this.pos,t=this.source.text;this.pos<this.end&&o.isDecimalDigit(t.charCodeAt(this.pos));)++this.pos;if(this.pos<this.end&&46==t.charCodeAt(this.pos))for(++this.pos;this.pos<this.end&&o.isDecimalDigit(t.charCodeAt(this.pos));)++this.pos;if(this.pos<this.end){var r=t.charCodeAt(this.pos);if(69==r||101==r)for(++this.pos<this.end&&(45==t.charCodeAt(this.pos)||43==t.charCodeAt(this.pos))&&o.isDecimalDigit(t.charCodeAt(this.pos+1))&&++this.pos;this.pos<this.end&&o.isDecimalDigit(t.charCodeAt(this.pos));)++this.pos}return parseFloat(t.substring(e,this.pos))},t.prototype.readUnicodeEscape=function(){for(var e=4,t=0,r=this.source.text;this.pos<this.end;){var n=r.charCodeAt(this.pos++);if(n>=48&&n<=57)t=16*t+n-48;else if(n>=65&&n<=70)t=16*t+10+n-65;else{if(!(n>=97&&n<=102))return this.error(a.DiagnosticCode.Hexadecimal_digit_expected,this.range(this.pos-1,this.pos)),"";t=16*t+10+n-97}if(0==--e)break}return e?(this.error(a.DiagnosticCode.Unexpected_end_of_text,this.range(this.pos)),""):String.fromCharCode(t)},t.prototype.readExtendedUnicodeEscape=function(){var e=this.pos,t=this.readHexInteger(),r=i64_low(t),n=!1;assert(!i64_high(t)),r>1114111&&(this.error(a.DiagnosticCode.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive,this.range(e,this.pos)),n=!0);var i=this.source.text;return this.pos>=this.end?(this.error(a.DiagnosticCode.Unexpected_end_of_text,this.range(e,this.end)),n=!0):125==i.charCodeAt(this.pos)?++this.pos:(this.error(a.DiagnosticCode.Unterminated_Unicode_escape_sequence,this.range(e,this.pos)),n=!0),n?"":r<65536?String.fromCharCode(r):String.fromCharCode(55296+((r-65536)/1024|0),(r-65536)%1024+56320)},t.prototype.finish=function(){},t}(a.DiagnosticEmitter);t.Tokenizer=c},function(e,t,r){"use strict";function n(e){switch(e){case 100:return"Operation not supported.";case 101:return"Operation is unsafe.";case 200:return"Conversion from type '{0}' to '{1}' possibly loses information and thus requires an explicit cast.";case 201:return"Conversion from type '{0}' to '{1}' will require an explicit cast when switching between 32/64-bit.";case 202:return"Type '{0}' cannot be changed to type '{1}'.";case 203:return"Type '{0}' cannot be reinterpreted as type '{1}'.";case 204:return"Basic type '{0}' cannot be nullable.";case 205:return"Cannot export a mutable global.";case 206:return"Compiling constant with non-constant initializer as mutable.";case 207:return"Structs cannot extend classes and vice-versa.";case 208:return"Structs cannot implement interfaces.";case 209:return"Invalid regular expression flags.";case 210:return"Implementation '{0}' must match the signature '{1}'.";case 1002:return"Unterminated string literal.";case 1003:return"Identifier expected.";case 1005:return"'{0}' expected.";case 1006:return"A file cannot have a reference to itself.";case 1009:return"Trailing comma not allowed.";case 1012:return"Unexpected token.";case 1014:return"A rest parameter must be last in a parameter list.";case 1015:return"Parameter cannot have question mark and initializer.";case 1016:return"A required parameter cannot follow an optional parameter.";case 1061:return"Enum member must have initializer.";case 1036:return"Statements are not allowed in ambient contexts.";case 1039:return"Initializers are not allowed in ambient contexts.";case 1042:return"'{0}' modifier cannot be used here.";case 1047:return"A rest parameter cannot be optional.";case 1048:return"A rest parameter cannot have an initializer.";case 1049:return"A 'set' accessor must have exactly one parameter.";case 1052:return"A 'set' accessor parameter cannot have an initializer.";case 1054:return"A 'get' accessor cannot have parameters.";case 1092:return"Type parameters cannot appear on a constructor declaration.";case 1093:return"Type annotation cannot appear on a constructor declaration.";case 1094:return"An accessor cannot have type parameters.";case 1095:return"A 'set' accessor cannot have a return type annotation.";case 1098:return"Type parameter list cannot be empty.";case 1104:return"A 'continue' statement can only be used within an enclosing iteration statement.";case 1105:return"A 'break' statement can only be used within an enclosing iteration or switch statement.";case 1108:return"A 'return' statement can only be used within a function body.";case 1109:return"Expression expected.";case 1110:return"Type expected.";case 1113:return"A 'default' clause cannot appear more than once in a 'switch' statement.";case 1114:return"Duplicate label '{0}'.";case 1121:return"Octal literals are not allowed in strict mode.";case 1124:return"Digit expected.";case 1125:return"Hexadecimal digit expected.";case 1126:return"Unexpected end of text.";case 1127:return"Invalid character.";case 1130:return"'case' or 'default' expected.";case 1140:return"Type argument expected.";case 1141:return"String literal expected.";case 1142:return"Line break not permitted here.";case 1146:return"Declaration expected.";case 1155:return"'const' declarations must be initialized.";case 1161:return"Unterminated regular expression literal.";case 1177:return"Binary digit expected.";case 1178:return"Octal digit expected.";case 1183:return"An implementation cannot be declared in ambient contexts.";case 1198:return"An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive.";case 1199:return"Unterminated Unicode escape sequence.";case 1206:return"Decorators are not valid here.";case 1242:return"'abstract' modifier can only appear on a class, method, or property declaration.";case 1311:return"A class may only extend another class.";case 2300:return"Duplicate identifier '{0}'.";case 2304:return"Cannot find name '{0}'.";case 2305:return"Module '{0}' has no exported member '{1}'.";case 2314:return"Generic type '{0}' requires {1} type argument(s).";case 2315:return"Type '{0}' is not generic.";case 2322:return"Type '{0}' is not assignable to type '{1}'.";case 2329:return"Index signature is missing in type '{0}'.";case 2332:return"'this' cannot be referenced in current location.";case 2335:return"'super' can only be referenced in a derived class.";case 2339:return"Property '{0}' does not exist on type '{1}'.";case 2349:return"Cannot invoke an expression whose type lacks a call signature. Type '{0}' has no compatible call signatures.";case 2351:return"Cannot use 'new' with an expression whose type lacks a construct signature.";case 2355:return"A function whose declared type is not 'void' must return a value.";case 2357:return"The operand of an increment or decrement operator must be a variable or a property access.";case 2364:return"The left-hand side of an assignment expression must be a variable or a property access.";case 2380:return"'get' and 'set' accessor must have the same type.";case 2390:return"Constructor implementation is missing.";case 2391:return"Function implementation is missing or not immediately following the declaration.";case 2392:return"Multiple constructor implementations are not allowed.";case 2393:return"Duplicate function implementation.";case 2484:return"Export declaration conflicts with exported declaration of '{0}'.";case 2540:return"Cannot assign to '{0}' because it is a constant or a read-only property.";case 2541:return"The target of an assignment must be a variable or a property access.";case 2542:return"Index signature in type '{0}' only permits reading.";case 2554:return"Expected {0} arguments, but got {1}.";case 2555:return"Expected at least {0} arguments, but got {1}.";case 2558:return"Expected {0} type arguments, but got {1}.";case 2651:return"A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.";case 2694:return"Namespace '{0}' has no exported member '{1}'.";case 6054:return"File '{0}' not found.";default:return""}}Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.Operation_not_supported=100]="Operation_not_supported",e[e.Operation_is_unsafe=101]="Operation_is_unsafe",e[e.Conversion_from_type_0_to_1_possibly_loses_information_and_thus_requires_an_explicit_cast=200]="Conversion_from_type_0_to_1_possibly_loses_information_and_thus_requires_an_explicit_cast",e[e.Conversion_from_type_0_to_1_will_require_an_explicit_cast_when_switching_between_32_64_bit=201]="Conversion_from_type_0_to_1_will_require_an_explicit_cast_when_switching_between_32_64_bit",e[e.Type_0_cannot_be_changed_to_type_1=202]="Type_0_cannot_be_changed_to_type_1",e[e.Type_0_cannot_be_reinterpreted_as_type_1=203]="Type_0_cannot_be_reinterpreted_as_type_1",e[e.Basic_type_0_cannot_be_nullable=204]="Basic_type_0_cannot_be_nullable",e[e.Cannot_export_a_mutable_global=205]="Cannot_export_a_mutable_global",e[e.Compiling_constant_with_non_constant_initializer_as_mutable=206]="Compiling_constant_with_non_constant_initializer_as_mutable",e[e.Structs_cannot_extend_classes_and_vice_versa=207]="Structs_cannot_extend_classes_and_vice_versa",e[e.Structs_cannot_implement_interfaces=208]="Structs_cannot_implement_interfaces",e[e.Invalid_regular_expression_flags=209]="Invalid_regular_expression_flags",e[e.Implementation_0_must_match_the_signature_1=210]="Implementation_0_must_match_the_signature_1",e[e.Unterminated_string_literal=1002]="Unterminated_string_literal",e[e.Identifier_expected=1003]="Identifier_expected",e[e._0_expected=1005]="_0_expected",e[e.A_file_cannot_have_a_reference_to_itself=1006]="A_file_cannot_have_a_reference_to_itself",e[e.Trailing_comma_not_allowed=1009]="Trailing_comma_not_allowed",e[e.Unexpected_token=1012]="Unexpected_token",e[e.A_rest_parameter_must_be_last_in_a_parameter_list=1014]="A_rest_parameter_must_be_last_in_a_parameter_list",e[e.Parameter_cannot_have_question_mark_and_initializer=1015]="Parameter_cannot_have_question_mark_and_initializer",e[e.A_required_parameter_cannot_follow_an_optional_parameter=1016]="A_required_parameter_cannot_follow_an_optional_parameter",e[e.Enum_member_must_have_initializer=1061]="Enum_member_must_have_initializer",e[e.Statements_are_not_allowed_in_ambient_contexts=1036]="Statements_are_not_allowed_in_ambient_contexts",e[e.Initializers_are_not_allowed_in_ambient_contexts=1039]="Initializers_are_not_allowed_in_ambient_contexts",e[e._0_modifier_cannot_be_used_here=1042]="_0_modifier_cannot_be_used_here",e[e.A_rest_parameter_cannot_be_optional=1047]="A_rest_parameter_cannot_be_optional",e[e.A_rest_parameter_cannot_have_an_initializer=1048]="A_rest_parameter_cannot_have_an_initializer",e[e.A_set_accessor_must_have_exactly_one_parameter=1049]="A_set_accessor_must_have_exactly_one_parameter",e[e.A_set_accessor_parameter_cannot_have_an_initializer=1052]="A_set_accessor_parameter_cannot_have_an_initializer",e[e.A_get_accessor_cannot_have_parameters=1054]="A_get_accessor_cannot_have_parameters",e[e.Type_parameters_cannot_appear_on_a_constructor_declaration=1092]="Type_parameters_cannot_appear_on_a_constructor_declaration",e[e.Type_annotation_cannot_appear_on_a_constructor_declaration=1093]="Type_annotation_cannot_appear_on_a_constructor_declaration",e[e.An_accessor_cannot_have_type_parameters=1094]="An_accessor_cannot_have_type_parameters",e[e.A_set_accessor_cannot_have_a_return_type_annotation=1095]="A_set_accessor_cannot_have_a_return_type_annotation",e[e.Type_parameter_list_cannot_be_empty=1098]="Type_parameter_list_cannot_be_empty",e[e.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement=1104]="A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement",e[e.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement=1105]="A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement",e[e.A_return_statement_can_only_be_used_within_a_function_body=1108]="A_return_statement_can_only_be_used_within_a_function_body",e[e.Expression_expected=1109]="Expression_expected",e[e.Type_expected=1110]="Type_expected",e[e.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement=1113]="A_default_clause_cannot_appear_more_than_once_in_a_switch_statement",e[e.Duplicate_label_0=1114]="Duplicate_label_0",e[e.Octal_literals_are_not_allowed_in_strict_mode=1121]="Octal_literals_are_not_allowed_in_strict_mode",e[e.Digit_expected=1124]="Digit_expected",e[e.Hexadecimal_digit_expected=1125]="Hexadecimal_digit_expected",e[e.Unexpected_end_of_text=1126]="Unexpected_end_of_text",e[e.Invalid_character=1127]="Invalid_character",e[e._case_or_default_expected=1130]="_case_or_default_expected",e[e.Type_argument_expected=1140]="Type_argument_expected",e[e.String_literal_expected=1141]="String_literal_expected",e[e.Line_break_not_permitted_here=1142]="Line_break_not_permitted_here",e[e.Declaration_expected=1146]="Declaration_expected",e[e._const_declarations_must_be_initialized=1155]="_const_declarations_must_be_initialized",e[e.Unterminated_regular_expression_literal=1161]="Unterminated_regular_expression_literal",e[e.Binary_digit_expected=1177]="Binary_digit_expected",e[e.Octal_digit_expected=1178]="Octal_digit_expected",e[e.An_implementation_cannot_be_declared_in_ambient_contexts=1183]="An_implementation_cannot_be_declared_in_ambient_contexts",e[e.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive=1198]="An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive",e[e.Unterminated_Unicode_escape_sequence=1199]="Unterminated_Unicode_escape_sequence",e[e.Decorators_are_not_valid_here=1206]="Decorators_are_not_valid_here",e[e._abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration=1242]="_abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration",e[e.A_class_may_only_extend_another_class=1311]="A_class_may_only_extend_another_class",e[e.Duplicate_identifier_0=2300]="Duplicate_identifier_0",e[e.Cannot_find_name_0=2304]="Cannot_find_name_0",e[e.Module_0_has_no_exported_member_1=2305]="Module_0_has_no_exported_member_1",e[e.Generic_type_0_requires_1_type_argument_s=2314]="Generic_type_0_requires_1_type_argument_s",e[e.Type_0_is_not_generic=2315]="Type_0_is_not_generic",e[e.Type_0_is_not_assignable_to_type_1=2322]="Type_0_is_not_assignable_to_type_1",e[e.Index_signature_is_missing_in_type_0=2329]="Index_signature_is_missing_in_type_0",e[e._this_cannot_be_referenced_in_current_location=2332]="_this_cannot_be_referenced_in_current_location",e[e._super_can_only_be_referenced_in_a_derived_class=2335]="_super_can_only_be_referenced_in_a_derived_class",e[e.Property_0_does_not_exist_on_type_1=2339]="Property_0_does_not_exist_on_type_1",e[e.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures=2349]="Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures",e[e.Cannot_use_new_with_an_expression_whose_type_lacks_a_construct_signature=2351]="Cannot_use_new_with_an_expression_whose_type_lacks_a_construct_signature",e[e.A_function_whose_declared_type_is_not_void_must_return_a_value=2355]="A_function_whose_declared_type_is_not_void_must_return_a_value",e[e.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access=2357]="The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access",e[e.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access=2364]="The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access",e[e._get_and_set_accessor_must_have_the_same_type=2380]="_get_and_set_accessor_must_have_the_same_type",e[e.Constructor_implementation_is_missing=2390]="Constructor_implementation_is_missing",e[e.Function_implementation_is_missing_or_not_immediately_following_the_declaration=2391]="Function_implementation_is_missing_or_not_immediately_following_the_declaration",e[e.Multiple_constructor_implementations_are_not_allowed=2392]="Multiple_constructor_implementations_are_not_allowed",e[e.Duplicate_function_implementation=2393]="Duplicate_function_implementation",e[e.Export_declaration_conflicts_with_exported_declaration_of_0=2484]="Export_declaration_conflicts_with_exported_declaration_of_0",e[e.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property=2540]="Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property",e[e.The_target_of_an_assignment_must_be_a_variable_or_a_property_access=2541]="The_target_of_an_assignment_must_be_a_variable_or_a_property_access",e[e.Index_signature_in_type_0_only_permits_reading=2542]="Index_signature_in_type_0_only_permits_reading",e[e.Expected_0_arguments_but_got_1=2554]="Expected_0_arguments_but_got_1",e[e.Expected_at_least_0_arguments_but_got_1=2555]="Expected_at_least_0_arguments_but_got_1",e[e.Expected_0_type_arguments_but_got_1=2558]="Expected_0_type_arguments_but_got_1",e[e.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums=2651]="A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums",e[e.Namespace_0_has_no_exported_member_1=2694]="Namespace_0_has_no_exported_member_1",e[e.File_0_not_found=6054]="File_0_not_found"}(t.DiagnosticCode||(t.DiagnosticCode={})),t.diagnosticCodeToString=n},function(e,t,r){"use strict";function n(e){switch(e){case 10:case 13:case 8232:case 8233:return!0;default:return!1}}function i(e){switch(e){case 32:case 9:case 11:case 12:case 160:case 133:case 5760:case 8239:case 8287:case 12288:case 65279:return!0;default:return e>=8192&&e<=8203}}function a(e){return e>=48&&e<=57}function o(e){return e>=48&&e<=55}function s(e){return e>=65&&e<=90||e>=97&&e<=122||36==e||95==e||e>127&&l(e)}function c(e){return e>=97&&e<=122}function p(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||36==e||95==e||e>127&&h(e)}function u(e,t){if(e<t[0])return!1;for(var r,n=0,i=t.length;n+1<i;){if(r=n+(i-n)/2,r-=r%2,t[r]<=e&&e<=t[r+1])return!0;e<t[r]?i=r:n=r+2}return!1}function l(e){return!(e<0||e>65535)&&u(e,d)}function h(e){return!(e<0||e>65535)&&u(e,_)}Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.NULL=0]="NULL",e[e.LINEFEED=10]="LINEFEED",e[e.CARRIAGERETURN=13]="CARRIAGERETURN",e[e.LINESEPARATOR=8232]="LINESEPARATOR",e[e.PARAGRAPHSEPARATOR=8233]="PARAGRAPHSEPARATOR",e[e.NEXTLINE=133]="NEXTLINE",e[e.SPACE=32]="SPACE",e[e.NONBREAKINGSPACE=160]="NONBREAKINGSPACE",e[e.ENQUAD=8192]="ENQUAD",e[e.EMQUAD=8193]="EMQUAD",e[e.ENSPACE=8194]="ENSPACE",e[e.EMSPACE=8195]="EMSPACE",e[e.THREEPEREMSPACE=8196]="THREEPEREMSPACE",e[e.FOURPEREMSPACE=8197]="FOURPEREMSPACE",e[e.SIXPEREMSPACE=8198]="SIXPEREMSPACE",e[e.FIGURESPACE=8199]="FIGURESPACE",e[e.PUNCTUATIONSPACE=8200]="PUNCTUATIONSPACE",e[e.THINSPACE=8201]="THINSPACE",e[e.HAIRSPACE=8202]="HAIRSPACE",e[e.ZEROWIDTHSPACE=8203]="ZEROWIDTHSPACE",e[e.NARROWNOBREAKSPACE=8239]="NARROWNOBREAKSPACE",e[e.IDEOGRAPHICSPACE=12288]="IDEOGRAPHICSPACE",e[e.MATHEMATICALSPACE=8287]="MATHEMATICALSPACE",e[e.OGHAM=5760]="OGHAM",e[e._=95]="_",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.AMPERSAND=38]="AMPERSAND",e[e.ASTERISK=42]="ASTERISK",e[e.AT=64]="AT",e[e.BACKSLASH=92]="BACKSLASH",e[e.BACKTICK=96]="BACKTICK",e[e.BAR=124]="BAR",e[e.CARET=94]="CARET",e[e.CLOSEBRACE=125]="CLOSEBRACE",e[e.CLOSEBRACKET=93]="CLOSEBRACKET",e[e.CLOSEPAREN=41]="CLOSEPAREN",e[e.COLON=58]="COLON",e[e.COMMA=44]="COMMA",e[e.DOLLAR=36]="DOLLAR",e[e.DOT=46]="DOT",e[e.DOUBLEQUOTE=34]="DOUBLEQUOTE",e[e.EQUALS=61]="EQUALS",e[e.EXCLAMATION=33]="EXCLAMATION",e[e.GREATERTHAN=62]="GREATERTHAN",e[e.HASH=35]="HASH",e[e.LESSTHAN=60]="LESSTHAN",e[e.MINUS=45]="MINUS",e[e.OPENBRACE=123]="OPENBRACE",e[e.OPENBRACKET=91]="OPENBRACKET",e[e.OPENPAREN=40]="OPENPAREN",e[e.PERCENT=37]="PERCENT",e[e.PLUS=43]="PLUS",e[e.QUESTION=63]="QUESTION",e[e.SEMICOLON=59]="SEMICOLON",e[e.SINGLEQUOTE=39]="SINGLEQUOTE",e[e.SLASH=47]="SLASH",e[e.TILDE=126]="TILDE",e[e.BACKSPACE=8]="BACKSPACE",e[e.FORMFEED=12]="FORMFEED",e[e.BYTEORDERMARK=65279]="BYTEORDERMARK",e[e.TAB=9]="TAB",e[e.VERTICALTAB=11]="VERTICALTAB"}(t.CharCode||(t.CharCode={})),t.isLineBreak=n,t.isWhiteSpace=i,t.isDecimalDigit=a,t.isOctalDigit=o,t.isIdentifierStart=s,t.isKeywordCharacter=c,t.isIdentifierPart=p;var d=[170,170,181,181,186,186,192,214,216,246,248,705,710,721,736,740,748,748,750,750,880,884,886,887,890,893,902,902,904,906,908,908,910,929,931,1013,1015,1153,1162,1319,1329,1366,1369,1369,1377,1415,1488,1514,1520,1522,1568,1610,1646,1647,1649,1747,1749,1749,1765,1766,1774,1775,1786,1788,1791,1791,1808,1808,1810,1839,1869,1957,1969,1969,1994,2026,2036,2037,2042,2042,2048,2069,2074,2074,2084,2084,2088,2088,2112,2136,2208,2208,2210,2220,2308,2361,2365,2365,2384,2384,2392,2401,2417,2423,2425,2431,2437,2444,2447,2448,2451,2472,2474,2480,2482,2482,2486,2489,2493,2493,2510,2510,2524,2525,2527,2529,2544,2545,2565,2570,2575,2576,2579,2600,2602,2608,2610,2611,2613,2614,2616,2617,2649,2652,2654,2654,2674,2676,2693,2701,2703,2705,2707,2728,2730,2736,2738,2739,2741,2745,2749,2749,2768,2768,2784,2785,2821,2828,2831,2832,2835,2856,2858,2864,2866,2867,2869,2873,2877,2877,2908,2909,2911,2913,2929,2929,2947,2947,2949,2954,2958,2960,2962,2965,2969,2970,2972,2972,2974,2975,2979,2980,2984,2986,2990,3001,3024,3024,3077,3084,3086,3088,3090,3112,3114,3123,3125,3129,3133,3133,3160,3161,3168,3169,3205,3212,3214,3216,3218,3240,3242,3251,3253,3257,3261,3261,3294,3294,3296,3297,3313,3314,3333,3340,3342,3344,3346,3386,3389,3389,3406,3406,3424,3425,3450,3455,3461,3478,3482,3505,3507,3515,3517,3517,3520,3526,3585,3632,3634,3635,3648,3654,3713,3714,3716,3716,3719,3720,3722,3722,3725,3725,3732,3735,3737,3743,3745,3747,3749,3749,3751,3751,3754,3755,3757,3760,3762,3763,3773,3773,3776,3780,3782,3782,3804,3807,3840,3840,3904,3911,3913,3948,3976,3980,4096,4138,4159,4159,4176,4181,4186,4189,4193,4193,4197,4198,4206,4208,4213,4225,4238,4238,4256,4293,4295,4295,4301,4301,4304,4346,4348,4680,4682,4685,4688,4694,4696,4696,4698,4701,4704,4744,4746,4749,4752,4784,4786,4789,4792,4798,4800,4800,4802,4805,4808,4822,4824,4880,4882,4885,4888,4954,4992,5007,5024,5108,5121,5740,5743,5759,5761,5786,5792,5866,5870,5872,5888,5900,5902,5905,5920,5937,5952,5969,5984,5996,5998,6e3,6016,6067,6103,6103,6108,6108,6176,6263,6272,6312,6314,6314,6320,6389,6400,6428,6480,6509,6512,6516,6528,6571,6593,6599,6656,6678,6688,6740,6823,6823,6917,6963,6981,6987,7043,7072,7086,7087,7098,7141,7168,7203,7245,7247,7258,7293,7401,7404,7406,7409,7413,7414,7424,7615,7680,7957,7960,7965,7968,8005,8008,8013,8016,8023,8025,8025,8027,8027,8029,8029,8031,8061,8064,8116,8118,8124,8126,8126,8130,8132,8134,8140,8144,8147,8150,8155,8160,8172,8178,8180,8182,8188,8305,8305,8319,8319,8336,8348,8450,8450,8455,8455,8458,8467,8469,8469,8473,8477,8484,8484,8486,8486,8488,8488,8490,8493,8495,8505,8508,8511,8517,8521,8526,8526,8544,8584,11264,11310,11312,11358,11360,11492,11499,11502,11506,11507,11520,11557,11559,11559,11565,11565,11568,11623,11631,11631,11648,11670,11680,11686,11688,11694,11696,11702,11704,11710,11712,11718,11720,11726,11728,11734,11736,11742,11823,11823,12293,12295,12321,12329,12337,12341,12344,12348,12353,12438,12445,12447,12449,12538,12540,12543,12549,12589,12593,12686,12704,12730,12784,12799,13312,19893,19968,40908,40960,42124,42192,42237,42240,42508,42512,42527,42538,42539,42560,42606,42623,42647,42656,42735,42775,42783,42786,42888,42891,42894,42896,42899,42912,42922,43e3,43009,43011,43013,43015,43018,43020,43042,43072,43123,43138,43187,43250,43255,43259,43259,43274,43301,43312,43334,43360,43388,43396,43442,43471,43471,43520,43560,43584,43586,43588,43595,43616,43638,43642,43642,43648,43695,43697,43697,43701,43702,43705,43709,43712,43712,43714,43714,43739,43741,43744,43754,43762,43764,43777,43782,43785,43790,43793,43798,43808,43814,43816,43822,43968,44002,44032,55203,55216,55238,55243,55291,63744,64109,64112,64217,64256,64262,64275,64279,64285,64285,64287,64296,64298,64310,64312,64316,64318,64318,64320,64321,64323,64324,64326,64433,64467,64829,64848,64911,64914,64967,65008,65019,65136,65140,65142,65276,65313,65338,65345,65370,65382,65470,65474,65479,65482,65487,65490,65495,65498,65500],_=[170,170,181,181,186,186,192,214,216,246,248,705,710,721,736,740,748,748,750,750,768,884,886,887,890,893,902,902,904,906,908,908,910,929,931,1013,1015,1153,1155,1159,1162,1319,1329,1366,1369,1369,1377,1415,1425,1469,1471,1471,1473,1474,1476,1477,1479,1479,1488,1514,1520,1522,1552,1562,1568,1641,1646,1747,1749,1756,1759,1768,1770,1788,1791,1791,1808,1866,1869,1969,1984,2037,2042,2042,2048,2093,2112,2139,2208,2208,2210,2220,2276,2302,2304,2403,2406,2415,2417,2423,2425,2431,2433,2435,2437,2444,2447,2448,2451,2472,2474,2480,2482,2482,2486,2489,2492,2500,2503,2504,2507,2510,2519,2519,2524,2525,2527,2531,2534,2545,2561,2563,2565,2570,2575,2576,2579,2600,2602,2608,2610,2611,2613,2614,2616,2617,2620,2620,2622,2626,2631,2632,2635,2637,2641,2641,2649,2652,2654,2654,2662,2677,2689,2691,2693,2701,2703,2705,2707,2728,2730,2736,2738,2739,2741,2745,2748,2757,2759,2761,2763,2765,2768,2768,2784,2787,2790,2799,2817,2819,2821,2828,2831,2832,2835,2856,2858,2864,2866,2867,2869,2873,2876,2884,2887,2888,2891,2893,2902,2903,2908,2909,2911,2915,2918,2927,2929,2929,2946,2947,2949,2954,2958,2960,2962,2965,2969,2970,2972,2972,2974,2975,2979,2980,2984,2986,2990,3001,3006,3010,3014,3016,3018,3021,3024,3024,3031,3031,3046,3055,3073,3075,3077,3084,3086,3088,3090,3112,3114,3123,3125,3129,3133,3140,3142,3144,3146,3149,3157,3158,3160,3161,3168,3171,3174,3183,3202,3203,3205,3212,3214,3216,3218,3240,3242,3251,3253,3257,3260,3268,3270,3272,3274,3277,3285,3286,3294,3294,3296,3299,3302,3311,3313,3314,3330,3331,3333,3340,3342,3344,3346,3386,3389,3396,3398,3400,3402,3406,3415,3415,3424,3427,3430,3439,3450,3455,3458,3459,3461,3478,3482,3505,3507,3515,3517,3517,3520,3526,3530,3530,3535,3540,3542,3542,3544,3551,3570,3571,3585,3642,3648,3662,3664,3673,3713,3714,3716,3716,3719,3720,3722,3722,3725,3725,3732,3735,3737,3743,3745,3747,3749,3749,3751,3751,3754,3755,3757,3769,3771,3773,3776,3780,3782,3782,3784,3789,3792,3801,3804,3807,3840,3840,3864,3865,3872,3881,3893,3893,3895,3895,3897,3897,3902,3911,3913,3948,3953,3972,3974,3991,3993,4028,4038,4038,4096,4169,4176,4253,4256,4293,4295,4295,4301,4301,4304,4346,4348,4680,4682,4685,4688,4694,4696,4696,4698,4701,4704,4744,4746,4749,4752,4784,4786,4789,4792,4798,4800,4800,4802,4805,4808,4822,4824,4880,4882,4885,4888,4954,4957,4959,4992,5007,5024,5108,5121,5740,5743,5759,5761,5786,5792,5866,5870,5872,5888,5900,5902,5908,5920,5940,5952,5971,5984,5996,5998,6e3,6002,6003,6016,6099,6103,6103,6108,6109,6112,6121,6155,6157,6160,6169,6176,6263,6272,6314,6320,6389,6400,6428,6432,6443,6448,6459,6470,6509,6512,6516,6528,6571,6576,6601,6608,6617,6656,6683,6688,6750,6752,6780,6783,6793,6800,6809,6823,6823,6912,6987,6992,7001,7019,7027,7040,7155,7168,7223,7232,7241,7245,7293,7376,7378,7380,7414,7424,7654,7676,7957,7960,7965,7968,8005,8008,8013,8016,8023,8025,8025,8027,8027,8029,8029,8031,8061,8064,8116,8118,8124,8126,8126,8130,8132,8134,8140,8144,8147,8150,8155,8160,8172,8178,8180,8182,8188,8204,8205,8255,8256,8276,8276,8305,8305,8319,8319,8336,8348,8400,8412,8417,8417,8421,8432,8450,8450,8455,8455,8458,8467,8469,8469,8473,8477,8484,8484,8486,8486,8488,8488,8490,8493,8495,8505,8508,8511,8517,8521,8526,8526,8544,8584,11264,11310,11312,11358,11360,11492,11499,11507,11520,11557,11559,11559,11565,11565,11568,11623,11631,11631,11647,11670,11680,11686,11688,11694,11696,11702,11704,11710,11712,11718,11720,11726,11728,11734,11736,11742,11744,11775,11823,11823,12293,12295,12321,12335,12337,12341,12344,12348,12353,12438,12441,12442,12445,12447,12449,12538,12540,12543,12549,12589,12593,12686,12704,12730,12784,12799,13312,19893,19968,40908,40960,42124,42192,42237,42240,42508,42512,42539,42560,42607,42612,42621,42623,42647,42655,42737,42775,42783,42786,42888,42891,42894,42896,42899,42912,42922,43e3,43047,43072,43123,43136,43204,43216,43225,43232,43255,43259,43259,43264,43309,43312,43347,43360,43388,43392,43456,43471,43481,43520,43574,43584,43597,43600,43609,43616,43638,43642,43643,43648,43714,43739,43741,43744,43759,43762,43766,43777,43782,43785,43790,43793,43798,43808,43814,43816,43822,43968,44010,44012,44013,44016,44025,44032,55203,55216,55238,55243,55291,63744,64109,64112,64217,64256,64262,64275,64279,64285,64296,64298,64310,64312,64316,64318,64318,64320,64321,64323,64324,64326,64433,64467,64829,64848,64911,64914,64967,65008,65019,65024,65039,65056,65062,65075,65076,65101,65103,65136,65140,65142,65276,65296,65305,65313,65338,65343,65343,65345,65370,65382,65470,65474,65479,65482,65487,65490,65495,65498,65500]},function(e,t,r){"use strict";function n(e){for(var t=0,r=e.length;t+1<r&&46==e.charCodeAt(t)&&e.charCodeAt(t+1)==o;)t+=2;(t>0||r<e.length)&&(e=e.substring(t,r),r-=t,t=0);for(var n;t+1<r;){if(n=!1,e.charCodeAt(t)==o&&46==e.charCodeAt(t+1)){if((n=t+2==r)||t+2<r&&e.charCodeAt(t+2)==o){e=n?e.substring(0,t):e.substring(0,t)+e.substring(t+2),r-=2;continue}if((n=t+3==r)&&46==e.charCodeAt(t+2)||t+3<r&&46==e.charCodeAt(t+2)&&e.charCodeAt(t+3)==o){for(var i=t;--i>=0;)if(e.charCodeAt(i)==o){t-i==3&&46==e.charCodeAt(i+1)&&46==e.charCodeAt(i+2)||(e=n?e.substring(0,i):e.substring(0,i)+e.substring(t+3),r-=t+3-i,t=i-1);break}if(i<0&&t>0&&(2!=t||46!=e.charCodeAt(0)||46!=e.charCodeAt(1))){e=e.substring(t+4),r=e.length;continue}}}t++}return r>0?e:"."}function i(e,t){return e.startsWith("std/")?e:n(a(t)+String.fromCharCode(o)+e)}function a(e){for(var t=e.length;--t>0;)if(e.charCodeAt(t)==o)return e.substring(0,t);return"."}Object.defineProperty(t,"__esModule",{value:!0});var o=47;t.normalize=n,t.resolve=i,t.dirname=a},function(e,t,r){r(12),e.exports=r(19)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(13),r(14),r(17)},function(e,t,r){(function(e){function t(){Error.captureStackTrace?Error.captureStackTrace(this,t):this.stack=this.name+": "+this.message+"\n"+(new Error).stack}function r(e){this.message=e||"assertion failed",Error.captureStackTrace?Error.captureStackTrace(this,r):this.stack=this.name+": "+this.message+"\n"+(new Error).stack}var n="undefined"!=typeof window&&window||void 0!==e&&e||self;Object.defineProperties(n.i8=function(e){return e<<24>>24},{MIN_VALUE:{value:-128,writable:!1},MAX_VALUE:{value:127,writable:!1}}),Object.defineProperties(n.i16=function(e){return e<<16>>16},{MIN_VALUE:{value:-32768,writable:!1},MAX_VALUE:{value:32767,writable:!1}}),Object.defineProperties(n.i32=n.isize=function(e){return 0|e},{MIN_VALUE:{value:-2147483648,writable:!1},MAX_VALUE:{value:2147483647,writable:!1}}),Object.defineProperties(n.u8=function(e){return 255&e},{MIN_VALUE:{value:0,writable:!1},MAX_VALUE:{value:255,writable:!1}}),Object.defineProperties(n.u16=function(e){return 65535&e},{MIN_VALUE:{value:0,writable:!1},MAX_VALUE:{value:65535,writable:!1}}),Object.defineProperties(n.u32=n.usize=function(e){return e>>>0},{MIN_VALUE:{value:0,writable:!1},MAX_VALUE:{value:4294967295,writable:!1}}),Object.defineProperties(n.bool=function(e){return!!e},{MIN_VALUE:{value:0,writable:!1},MAX_VALUE:{value:1,writable:!1}}),Object.defineProperties(n.f32=function(e){return Math.fround(e)},{MIN_VALUE:{value:Math.fround(-3.40282347e38),writable:!1},MAX_VALUE:{value:Math.fround(3.40282347e38),writable:!1},MIN_SAFE_INTEGER:{value:-16777215,writable:!1},MAX_SAFE_INTEGER:{value:16777215,writable:!1},EPSILON:{value:Math.fround(1.1920929e-7),writable:!1}}),Object.defineProperties(n.f64=function(e){return+e},{MIN_VALUE:{value:-1.7976931348623157e308,writable:!1},MAX_VALUE:{value:1.7976931348623157e308,writable:!1},MIN_SAFE_INTEGER:{value:-9007199254740991,writable:!1},MAX_SAFE_INTEGER:{value:9007199254740991,writable:!1},EPSILON:{value:2.220446049250313e-16,writable:!1}}),n.clz=Math.clz32,n.abs=Math.abs,n.max=Math.max,n.min=Math.min,n.ceil=Math.ceil,n.floor=Math.floor,n.select=function(e,t,r){return r?e:t},n.sqrt=Math.sqrt,n.trunc=Math.trunc,n.bswap=function(e){var t=e>>8&16711935,r=(16711935&e)<<8;return e=t|r,t=e>>16&65535,r=(65535&e)<<16,t|r},n.bswap16=function(e){return e<<8&65280|e>>8&255|4294901760&e},t.prototype=Object.create(Error.prototype),t.prototype.name="UnreachableError",t.prototype.message="unreachable",n.unreachable=function(){throw new t},r.prototype=Object.create(Error.prototype),r.prototype.name="AssertionError",n.assert=function(e,t){if(e)return e;throw new r(t)},n.changetype=function(e){return e},n.parseI32=function(e,t){return 0|parseInt(e,void 0)},String.fromCharCodes=function(e){return String.fromCharCode.apply(String,e)},String.fromCodePoints=function(e){return String.fromCodePoint.apply(String,e)}}).call(t,r(3))},function(e,t,r){(function(e){const t=e.Binaryen||r(15);for(var n in t)(n.startsWith("_Binaryen")||n.startsWith("_Relooper"))&&(e[n]=t[n]);e.allocate_memory=function(e){return e?t._malloc(e):0},e.free_memory=function(e){e&&t._free(e)},e.move_memory=function(e,r,n){return t._memmove(e,r,n)},e.store=function(e,r){t.HEAPU8[e]=r},e.load=function(e){return t.HEAPU8[e]};const i=r(0).Module;i.prototype.toText=function(){var e=t.print,r="";return t.print=function(e){r+=e+"\n"},_BinaryenModulePrint(this.ref),t.print=e,r},i.prototype.toAsmjs=function(){var e=t.print,r="";return t.print=function(e){r+=e+"\n"},_BinaryenModulePrintAsmjs(this.ref),t.print=e,r}}).call(t,r(3))},function(t,r){t.exports=e},function(e,t,r){"use strict";function n(e,t,r){switch(t.internalName){case"NaN":return e.currentType==u.Type.f32?e.module.createF32(NaN):(e.currentType=u.Type.f64,e.module.createF64(NaN));case"Infinity":return e.currentType==u.Type.f32?e.module.createF32(1/0):(e.currentType=u.Type.f64,e.module.createF64(1/0));case"HEAP_BASE":return e.currentType=e.options.usizeType,e.module.createGetGlobal("HEAP_BASE",e.currentType.toNativeType())}return e.error(p.DiagnosticCode.Operation_not_supported,r.range),e.module.createUnreachable()}function i(e,t,r,n,i,o){var h,d,_,y,m,f,E,g,T=e.module;switch(t.internalName){case"isNaN":if(e.currentType=u.Type.bool,1!=n.length)return r&&1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.f64,0);switch(e.currentType.kind){case 11:m=e.currentFunction.getAndFreeTempLocal(u.Type.f32),y=T.createBinary(l.BinaryOp.NeF32,T.createTeeLocal(m.index,h),T.createGetLocal(m.index,l.NativeType.F32));break;case 12:m=e.currentFunction.getAndFreeTempLocal(u.Type.f64),y=T.createBinary(l.BinaryOp.NeF64,T.createTeeLocal(m.index,h),T.createGetLocal(m.index,l.NativeType.F64));break;case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break;default:y=T.createI32(0)}return e.currentType=u.Type.bool,y;case"isFinite":if(e.currentType=u.Type.bool,1!=n.length)return r&&1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.f64,0);switch(e.currentType.kind){case 11:m=e.currentFunction.getAndFreeTempLocal(u.Type.f32),y=T.createSelect(T.createBinary(l.BinaryOp.NeF32,T.createUnary(l.UnaryOp.AbsF32,T.createTeeLocal(m.index,h)),T.createF32(1/0)),T.createI32(0),T.createBinary(l.BinaryOp.EqF32,T.createGetLocal(m.index,l.NativeType.F32),T.createGetLocal(m.index,l.NativeType.F32)));break;case 12:m=e.currentFunction.getAndFreeTempLocal(u.Type.f64),y=T.createSelect(T.createBinary(l.BinaryOp.NeF64,T.createUnary(l.UnaryOp.AbsF64,T.createTeeLocal(m.index,h)),T.createF64(1/0)),T.createI32(0),T.createBinary(l.BinaryOp.EqF64,T.createGetLocal(m.index,l.NativeType.F64),T.createGetLocal(m.index,l.NativeType.F64)));break;case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break;default:y=T.createI32(1)}return e.currentType=u.Type.bool,y;case"clz":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.i32,0);switch(e.currentType.kind){default:y=T.createUnary(l.UnaryOp.ClzI32,h);break;case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}case 4:y=T.createUnary(e.options.isWasm64?l.UnaryOp.ClzI64:l.UnaryOp.ClzI32,h);break;case 3:case 8:y=T.createUnary(l.UnaryOp.ClzI64,h);break;case 11:case 12:case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"ctz":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.i32,0);switch(e.currentType.kind){default:y=T.createUnary(l.UnaryOp.CtzI32,h);break;case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}case 4:y=T.createUnary(e.options.isWasm64?l.UnaryOp.CtzI64:l.UnaryOp.CtzI32,h);break;case 3:case 8:y=T.createUnary(l.UnaryOp.CtzI64,h);break;case 11:case 12:case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"popcnt":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.i32,0);switch(e.currentType.kind){default:y=T.createUnary(l.UnaryOp.PopcntI32,h);break;case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}case 4:y=T.createUnary(e.options.isWasm64?l.UnaryOp.PopcntI64:l.UnaryOp.PopcntI32,h);break;case 3:case 8:y=T.createUnary(l.UnaryOp.PopcntI64,h);break;case 11:case 12:case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"rotl":if(2!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.i32,0);switch(d=e.compileExpression(n[1],e.currentType),e.currentType.kind){case 0:case 1:case 5:case 6:case 10:y=c.makeSmallIntegerWrap(T.createBinary(l.BinaryOp.RotlI32,h,d),e.currentType,T);case 2:case 7:y=T.createBinary(l.BinaryOp.RotlI32,h,d);break;case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}case 4:y=T.createBinary(e.options.isWasm64?l.BinaryOp.RotlI64:l.BinaryOp.RotlI32,h,d);break;case 3:case 8:y=T.createBinary(l.BinaryOp.RotlI64,h,d);break;default:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"rotr":if(2!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.i32,0);switch(d=e.compileExpression(n[1],e.currentType),e.currentType.kind){case 0:case 1:case 5:case 6:case 10:y=c.makeSmallIntegerWrap(T.createBinary(l.BinaryOp.RotrI32,h,d),e.currentType,T);break;case 2:case 7:y=T.createBinary(l.BinaryOp.RotrI32,h,d);break;case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}case 4:y=T.createBinary(e.options.isWasm64?l.BinaryOp.RotrI64:l.BinaryOp.RotrI32,h,d);break;case 3:case 8:y=T.createBinary(l.BinaryOp.RotrI64,h,d);break;default:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"abs":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.f64,0);switch(e.currentType.kind){case 0:case 1:case 2:m=e.currentFunction.getAndFreeTempLocal(u.Type.i32),y=T.createSelect(T.createTeeLocal(m.index,h),T.createBinary(l.BinaryOp.SubI32,T.createI32(0),T.createGetLocal(m.index,l.NativeType.I32)),T.createBinary(l.BinaryOp.GtI32,T.createGetLocal(m.index,l.NativeType.I32),T.createI32(0)));break;case 4:m=e.currentFunction.getAndFreeTempLocal(e.options.usizeType),y=T.createSelect(T.createTeeLocal(m.index,h),T.createBinary(e.options.isWasm64?l.BinaryOp.SubI64:l.BinaryOp.SubI32,e.options.usizeType.toNativeZero(T),T.createGetLocal(m.index,e.options.nativeSizeType)),T.createBinary(e.options.isWasm64?l.BinaryOp.GtI64:l.BinaryOp.GtI32,T.createGetLocal(m.index,e.options.nativeSizeType),e.options.usizeType.toNativeZero(T)));break;case 3:m=e.currentFunction.getAndFreeTempLocal(u.Type.i64),y=T.createSelect(T.createTeeLocal(m.index,h),T.createBinary(l.BinaryOp.SubI64,T.createI64(0,0),T.createGetLocal(m.index,l.NativeType.I64)),T.createBinary(l.BinaryOp.GtI64,T.createGetLocal(m.index,l.NativeType.I64),T.createI64(0,0)));break;case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}case 5:case 6:case 7:case 8:case 10:y=h;break;case 11:y=T.createUnary(l.UnaryOp.AbsF32,h);break;case 12:y=T.createUnary(l.UnaryOp.AbsF64,h);break;case 13:y=T.createUnreachable();break;default:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"max":if(2!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.f64,0);switch(d=e.compileExpression(n[1],e.currentType),e.currentType.kind){case 0:case 1:case 2:m=e.currentFunction.getTempLocal(u.Type.i32),f=e.currentFunction.getAndFreeTempLocal(u.Type.i32),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(l.BinaryOp.GtI32,T.createGetLocal(m.index,l.NativeType.I32),T.createGetLocal(f.index,l.NativeType.I32)));break;case 5:case 6:case 7:case 10:m=e.currentFunction.getTempLocal(u.Type.i32),f=e.currentFunction.getAndFreeTempLocal(u.Type.i32),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(l.BinaryOp.GtU32,T.createGetLocal(m.index,l.NativeType.I32),T.createGetLocal(f.index,l.NativeType.I32)));break;case 3:m=e.currentFunction.getTempLocal(u.Type.i64),f=e.currentFunction.getAndFreeTempLocal(u.Type.i64),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(l.BinaryOp.GtI64,T.createGetLocal(m.index,l.NativeType.I64),T.createGetLocal(f.index,l.NativeType.I64)));break;case 8:m=e.currentFunction.getTempLocal(u.Type.i64),f=e.currentFunction.getAndFreeTempLocal(u.Type.i64),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(l.BinaryOp.GtU64,T.createGetLocal(m.index,l.NativeType.I64),T.createGetLocal(f.index,l.NativeType.I64)));break;case 4:m=e.currentFunction.getTempLocal(e.options.usizeType),f=e.currentFunction.getAndFreeTempLocal(e.options.usizeType),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(e.options.isWasm64?l.BinaryOp.GtI64:l.BinaryOp.GtI32,T.createGetLocal(m.index,e.options.nativeSizeType),T.createGetLocal(f.index,e.options.nativeSizeType)));break;case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}m=e.currentFunction.getTempLocal(e.options.usizeType),f=e.currentFunction.getAndFreeTempLocal(e.options.usizeType),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(e.options.isWasm64?l.BinaryOp.GtU64:l.BinaryOp.GtU32,T.createGetLocal(m.index,e.options.nativeSizeType),T.createGetLocal(f.index,e.options.nativeSizeType)));break;case 11:y=T.createBinary(l.BinaryOp.MaxF32,h,d);break;case 12:y=T.createBinary(l.BinaryOp.MaxF64,h,d);break;default:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"min":if(2!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.f64,0);switch(d=e.compileExpression(n[1],e.currentType),e.currentType.kind){case 0:case 1:case 2:m=e.currentFunction.getTempLocal(u.Type.i32),f=e.currentFunction.getAndFreeTempLocal(u.Type.i32),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(l.BinaryOp.LtI32,T.createGetLocal(m.index,l.NativeType.I32),T.createGetLocal(f.index,l.NativeType.I32)));break;case 5:case 6:case 7:case 10:m=e.currentFunction.getTempLocal(u.Type.i32),f=e.currentFunction.getAndFreeTempLocal(u.Type.i32),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(l.BinaryOp.LtU32,T.createGetLocal(m.index,l.NativeType.I32),T.createGetLocal(f.index,l.NativeType.I32)));break;case 3:m=e.currentFunction.getTempLocal(u.Type.i64),f=e.currentFunction.getAndFreeTempLocal(u.Type.i64),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(l.BinaryOp.LtI64,T.createGetLocal(m.index,l.NativeType.I64),T.createGetLocal(f.index,l.NativeType.I64)));break;case 8:m=e.currentFunction.getTempLocal(u.Type.i64),f=e.currentFunction.getAndFreeTempLocal(u.Type.i64),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(l.BinaryOp.LtU64,T.createGetLocal(m.index,l.NativeType.I64),T.createGetLocal(f.index,l.NativeType.I64)));break;case 4:m=e.currentFunction.getTempLocal(e.options.usizeType),f=e.currentFunction.getAndFreeTempLocal(e.options.usizeType),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(e.options.isWasm64?l.BinaryOp.LtI64:l.BinaryOp.LtI32,T.createGetLocal(m.index,e.options.nativeSizeType),T.createGetLocal(f.index,e.options.nativeSizeType)));break;case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}m=e.currentFunction.getTempLocal(e.options.usizeType),f=e.currentFunction.getAndFreeTempLocal(e.options.usizeType),e.currentFunction.freeTempLocal(m),y=T.createSelect(T.createTeeLocal(m.index,h),T.createTeeLocal(f.index,d),T.createBinary(e.options.isWasm64?l.BinaryOp.LtU64:l.BinaryOp.LtU32,T.createGetLocal(m.index,e.options.nativeSizeType),T.createGetLocal(f.index,e.options.nativeSizeType)));break;case 11:y=T.createBinary(l.BinaryOp.MinF32,h,d);break;case 12:y=T.createBinary(l.BinaryOp.MinF64,h,d);break;default:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"ceil":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.f64,0);switch(e.currentType.kind){case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}default:y=h;break;case 11:y=T.createUnary(l.UnaryOp.CeilF32,h);break;case 12:y=T.createUnary(l.UnaryOp.CeilF64,h);break;case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"floor":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.f64,0);switch(e.currentType.kind){case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}default:y=h;break;case 11:y=T.createUnary(l.UnaryOp.FloorF32,h);break;case 12:y=T.createUnary(l.UnaryOp.FloorF64,h);break;case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"copysign":if(2!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.f64,0);switch(d=e.compileExpression(n[1],e.currentType),e.currentType.kind){case 11:y=T.createBinary(l.BinaryOp.CopysignF32,h,d);break;case 12:y=T.createBinary(l.BinaryOp.CopysignF64,h,d);break;default:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"nearest":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.f64,0);switch(e.currentType.kind){case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}default:y=h;break;case 11:y=T.createUnary(l.UnaryOp.NearestF32,h);break;case 12:y=T.createUnary(l.UnaryOp.NearestF64,h);break;case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"reinterpret":if(1!=n.length)return r&&1==r.length||(r&&r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r?r.length.toString(10):"0")),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(!r||1!=r.length)return r&&r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r?r.length.toString(10):"0"),T.createUnreachable();switch(r[0].kind){case 2:case 7:h=e.compileExpression(n[0],u.Type.f32),y=T.createUnary(l.UnaryOp.ReinterpretF32,h);break;case 3:case 8:h=e.compileExpression(n[0],u.Type.f64),y=T.createUnary(l.UnaryOp.ReinterpretF64,h);break;case 9:if(r[0].isReference)return e.error(p.DiagnosticCode.Operation_not_supported,o.range),e.currentType=r[0],T.createUnreachable();case 4:h=e.compileExpression(n[0],e.options.isWasm64?u.Type.f64:u.Type.f32),y=T.createUnary(e.options.isWasm64?l.UnaryOp.ReinterpretF64:l.UnaryOp.ReinterpretF32,h);break;case 11:h=e.compileExpression(n[0],u.Type.u32),y=T.createUnary(l.UnaryOp.ReinterpretI32,h);break;case 12:h=e.compileExpression(n[0],u.Type.u64),y=T.createUnary(l.UnaryOp.ReinterpretI64,h);break;default:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return e.currentType=r[0],y;case"sqrt":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.f64,0);switch(e.currentType.kind){case 11:y=T.createUnary(l.UnaryOp.SqrtF32,h);break;case 12:y=T.createUnary(l.UnaryOp.SqrtF64,h);break;default:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"trunc":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),T.createUnreachable();if(r&&r.length){if(e.currentType=r[0],1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.f64,0);switch(e.currentType.kind){case 9:if(e.currentType.isReference){e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable();break}default:y=h;break;case 11:y=T.createUnary(l.UnaryOp.TruncF32,h);break;case 12:y=T.createUnary(l.UnaryOp.TruncF64,h);break;case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"load":return n.length<1||n.length>2?(r&&1==r.length||e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r?r.length.toString(10):"0"),n.length<1?e.error(p.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,o.range,"1",n.length.toString(10)):e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"2",n.length.toString(10)),T.createUnreachable()):r&&1==r.length?(h=e.compileExpression(n[0],e.options.usizeType),g=2==n.length?a(e,n[1]):0,g<0?T.createUnreachable():T.createLoad(r[0].byteSize,r[0].is(5),h,r[0].is(4)&&i.is(4)&&i.size>=r[0].size?(e.currentType=i).toNativeType():(e.currentType=r[0]).toNativeType(),g)):(r&&r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r?r.length.toString(10):"0"),T.createUnreachable());case"store":return e.currentType=u.Type.void,n.length<2||n.length>3?(r&&1==r.length||e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r?r.length.toString(10):"0"),n.length<2?e.error(p.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,o.range,"2",n.length.toString(10)):e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"3",n.length.toString(10)),T.createUnreachable()):r&&1==r.length?(h=e.compileExpression(n[0],e.options.usizeType),d=e.compileExpression(n[1],r[0],r[0].is(4)?0:1),e.currentType.is(4)&&r[0].is(4)&&r[0].size>e.currentType.size?(d=e.convertExpression(d,e.currentType,r[0],1,n[1]),E=r[0]):E=e.currentType,(g=3==n.length?a(e,n[2]):0)<0?T.createUnreachable():(e.currentType=u.Type.void,T.createStore(r[0].byteSize,h,d,E.toNativeType(),g))):(e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r?r.length.toString(10):"0"),T.createUnreachable());case"sizeof":return e.currentType=e.options.usizeType,0!=n.length?(r&&1==r.length||e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r?r.length.toString(10):"0"),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"0",n.length.toString(10)),T.createUnreachable()):r?1!=r.length?(e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable()):y=e.options.isWasm64?T.createI64(r[0].byteSize,0):T.createI32(r[0].byteSize):(e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1","0"),T.createUnreachable());case"select":if(3!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"3",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.i32,0);switch(d=e.compileExpression(n[1],E=e.currentType),_=e.compileExpression(n[2],u.Type.bool),e.currentType=E,e.currentType.kind){default:y=T.createSelect(h,d,_);break;case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=T.createUnreachable()}return y;case"unreachable":return 0!=n.length&&e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"0",n.length.toString(10)),r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),T.createUnreachable();case"current_memory":return e.currentType=u.Type.i32,0!=n.length&&e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"0",n.length.toString(10)),r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),T.createHost(l.HostOp.CurrentMemory);case"grow_memory":return e.currentType=u.Type.i32,1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"0",n.length.toString(10)),h=T.createUnreachable()):h=e.compileExpression(n[0],u.Type.i32),r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),T.createHost(l.HostOp.GrowMemory,null,[h]);case"move_memory":if(r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),3!=n.length)return e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"3",n.length.toString(10)),e.currentType=u.Type.void,T.createUnreachable();throw h=e.compileExpression(n[0],e.options.usizeType),d=e.compileExpression(n[1],e.options.usizeType),_=e.compileExpression(n[2],e.options.usizeType),e.currentType=u.Type.void,new Error("not implemented");case"set_memory":if(r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),3!=n.length)return e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"3",n.length.toString(10)),e.currentType=u.Type.void,T.createUnreachable();throw h=e.compileExpression(n[0],e.options.usizeType),d=e.compileExpression(n[1],u.Type.u32),_=e.compileExpression(n[2],e.options.usizeType),e.currentType=u.Type.void,new Error("not implemented");case"changetype":return r&&1==r.length?9!=r[0].kind?(e.error(p.DiagnosticCode.Operation_not_supported,o.range),e.currentType=r[0],T.createUnreachable()):1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=r[0],T.createUnreachable()):(h=e.compileExpression(n[0],e.options.usizeType,0),e.currentType=r[0],9!=e.currentType.kind?(e.error(p.DiagnosticCode.Operation_not_supported,o.range),T.createUnreachable()):h):(r&&r.length&&(e.currentType=r[0]),e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r?r.length.toString(10):"0"),T.createUnreachable());case"assert":if(n.length<1||n.length>2)return r&&(r.length&&(e.currentType=r[0].nonNullableType),1!=r.length&&e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10))),n.length<1?e.error(p.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,o.range,"1",n.length.toString(10)):n.length>2&&e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(r.length&&(e.currentType=r[0].nonNullableType),1!=r.length)return e.error(p.DiagnosticCode.Expected_0_type_arguments_but_got_1,o.range,"1",r.length.toString(10)),T.createUnreachable();h=e.compileExpression(n[0],r[0])}else h=e.compileExpression(n[0],u.Type.i32,0);if(E=e.currentType,e.currentType=E.nonNullableType,e.options.noAssert)return i==u.Type.void?(e.currentType=u.Type.void,T.createNop()):h;var A=s(e,2==n.length?n[1]:null,o);if(e.currentType=E.nonNullableType,i==u.Type.void){switch(e.currentType.kind){default:y=T.createIf(T.createUnary(l.UnaryOp.EqzI32,h),A);break;case 3:case 8:y=T.createIf(T.createUnary(l.UnaryOp.EqzI64,h),A);break;case 4:case 9:y=T.createIf(T.createUnary(e.options.isWasm64?l.UnaryOp.EqzI64:l.UnaryOp.EqzI32,h),A);break;case 11:y=T.createIf(T.createBinary(l.BinaryOp.EqF32,h,T.createF32(0)),A);break;case 12:y=T.createIf(T.createBinary(l.BinaryOp.EqF64,h,T.createF64(0)),A);break;case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=A}e.currentType=u.Type.void}else switch(e.currentType.kind){default:m=e.currentFunction.getAndFreeTempLocal(u.Type.i32),y=T.createIf(T.createUnary(l.UnaryOp.EqzI32,T.createTeeLocal(m.index,h)),A,T.createGetLocal(m.index,l.NativeType.I32));break;case 3:case 8:m=e.currentFunction.getAndFreeTempLocal(u.Type.i64),y=T.createIf(T.createUnary(l.UnaryOp.EqzI64,T.createTeeLocal(m.index,h)),A,T.createGetLocal(m.index,l.NativeType.I64));break;case 4:case 9:m=e.currentFunction.getAndFreeTempLocal(e.options.usizeType),y=T.createIf(T.createUnary(e.options.isWasm64?l.UnaryOp.EqzI64:l.UnaryOp.EqzI32,T.createTeeLocal(m.index,h)),A,T.createGetLocal(m.index,e.options.nativeSizeType));break;case 11:m=e.currentFunction.getAndFreeTempLocal(u.Type.f32),y=T.createIf(T.createBinary(l.BinaryOp.EqF32,T.createTeeLocal(m.index,h),T.createF32(0)),A,T.createGetLocal(m.index,l.NativeType.F32));break;case 12:m=e.currentFunction.getAndFreeTempLocal(u.Type.f64),y=T.createIf(T.createBinary(l.BinaryOp.EqF64,T.createTeeLocal(m.index,h),T.createF64(0)),A,T.createGetLocal(m.index,l.NativeType.F64));break;case 13:e.error(p.DiagnosticCode.Operation_not_supported,o.range),y=A}return y;case"i8":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=u.Type.i8,T.createUnreachable()):e.compileExpression(n[0],u.Type.i8,2);case"i16":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=u.Type.i16,T.createUnreachable()):e.compileExpression(n[0],u.Type.i16,2);case"i32":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=u.Type.i32,T.createUnreachable()):e.compileExpression(n[0],u.Type.i32,2);case"i64":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=u.Type.i64,T.createUnreachable()):e.compileExpression(n[0],u.Type.i64,2);case"isize":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=e.options.isWasm64?u.Type.isize64:u.Type.isize32,T.createUnreachable()):e.compileExpression(n[0],e.options.isWasm64?u.Type.isize64:u.Type.isize32,2);case"u8":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=u.Type.u8,T.createUnreachable()):e.compileExpression(n[0],u.Type.u8,2);case"u16":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=u.Type.u16,T.createUnreachable()):e.compileExpression(n[0],u.Type.u16,2);case"u32":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=u.Type.u32,T.createUnreachable()):e.compileExpression(n[0],u.Type.u32,2);case"u64":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=u.Type.u64,T.createUnreachable()):e.compileExpression(n[0],u.Type.u64,2);case"usize":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=e.options.usizeType,T.createUnreachable()):e.compileExpression(n[0],e.options.usizeType,2);case"bool":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=u.Type.bool,T.createUnreachable()):e.compileExpression(n[0],u.Type.bool,2);case"f32":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=u.Type.f32,T.createUnreachable()):e.compileExpression(n[0],u.Type.f32,2);case"f64":return r&&e.error(p.DiagnosticCode.Type_0_is_not_generic,o.range,t.internalName),1!=n.length?(e.error(p.DiagnosticCode.Expected_0_arguments_but_got_1,o.range,"1",n.length.toString(10)),e.currentType=u.Type.f64,T.createUnreachable()):e.compileExpression(n[0],u.Type.f64,2)}return e.error(p.DiagnosticCode.Operation_not_supported,o.range),T.createUnreachable()}function a(e,t){var r,n;return e.options.isWasm64?(r=e.precomputeExpression(t,u.Type.i64),(_BinaryenExpressionGetId(r)!=l.ExpressionId.Const||_BinaryenExpressionGetType(r)!=l.NativeType.I64||0!=_BinaryenConstGetValueI64High(r)||(n=_BinaryenConstGetValueI64Low(r))<0)&&(e.error(p.DiagnosticCode.Operation_not_supported,t.range),n=-1)):(r=e.precomputeExpression(t,u.Type.i32),(_BinaryenExpressionGetId(r)!=l.ExpressionId.Const||_BinaryenExpressionGetType(r)!=l.NativeType.I32||(n=_BinaryenConstGetValueI32(r))<0)&&(e.error(p.DiagnosticCode.Operation_not_supported,t.range),n=-1)),n}function o(e,t,r){var n=t.program,i=n.elements.get(e.options.allocateImpl);if(i)if(i.kind==h.ElementKind.FUNCTION_PROTOTYPE){var a=i.resolve();if(a)if(!a.is(h.ElementFlags.GENERIC)&&a.returnType==e.options.usizeType&&a.parameters&&1==a.parameters.length&&a.parameters[0].type==e.options.usizeType){if(e.compileFunction(a))return e.makeCall(a,[e.options.isWasm64?e.module.createI64(t.currentMemoryOffset):e.module.createI32(t.currentMemoryOffset)])}else n.error(p.DiagnosticCode.Implementation_0_must_match_the_signature_1,r.range,e.options.allocateImpl,"(size: usize): usize")}else n.error(p.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures,r.range,i.internalName);else n.error(p.DiagnosticCode.Cannot_find_name_0,r.range,e.options.allocateImpl);return e.module.createUnreachable()}function s(e,t,r){var n=e.module,i=n.createUnreachable(),a=e.program.elements.get("abort"),o=e.program.types.get("string");if(a&&a.kind==h.ElementKind.FUNCTION_PROTOTYPE&&o){var s=a.resolve();s&&e.compileFunction(s)&&(assert(s.parameters&&4==s.parameters.length),i=n.createBlock(null,[e.makeCall(s,[null!=t?e.compileExpression(t,o):e.options.usizeType.toNativeZero(n),e.compileStaticString(r.range.source.normalizedPath),n.createI32(r.range.line),n.createI32(r.range.column)]),i]))}return i}Object.defineProperty(t,"__esModule",{value:!0});var c=r(4),p=r(1),u=r(5),l=r(0),h=r(2);t.compileGetConstant=n,t.compileCall=i,t.compileAllocate=o,t.compileAbort=s},function(e,t,r){(function(e){const t=e.Long||r(18);e.i64_new=function(e,r){return t.fromBits(e,r)},e.i64_low=function(e){return e.low},e.i64_high=function(e){return e.high},e.i64_add=function(e,t){return e.add(t)},e.i64_sub=function(e,t){return e.sub(t)},e.i64_mul=function(e,t){return e.mul(t)},e.i64_div=function(e,t){return e.div(t)},e.i64_div_u=function(e,t){return e.toUnsigned().div(t.toUnsigned()).toSigned()},e.i64_rem=function(e,t){return e.mod(t)},e.i64_rem_u=function(e,t){return e.toUnsigned().mod(t.toUnsigned()).toSigned()},e.i64_and=function(e,t){return e.and(t)},e.i64_or=function(e,t){return e.or(t)},e.i64_xor=function(e,t){return e.xor(t)},e.i64_shl=function(e,t){return e.shl(t)},e.i64_shr=function(e,t){return e.shr(t)},e.i64_shr_u=function(e,t){return e.shru(t)},e.i64_not=function(e){return e.not()},e.i64_align=function(e,r){assert(r&&0==(r&r-1));var n=t.fromInt(r-1);return e.add(n).and(n.not())},e.i64_is_i8=function(e){return 0===e.high&&e.low>=0&&e.low<=i8.MAX_VALUE||-1===e.high&&e.low>=i8.MIN_VALUE&&e.low<0},e.i64_is_i16=function(e){return 0===e.high&&e.low>=0&&e.low<=i16.MAX_VALUE||-1===e.high&&e.low>=i16.MIN_VALUE&&e.low<0},e.i64_is_i32=function(e){return 0===e.high&&e.low>=0||-1===e.high&&e.low<0},e.i64_is_u8=function(e){return 0===e.high&&e.low>=0&&e.low<=u8.MAX_VALUE},e.i64_is_u16=function(e){return 0===e.high&&e.low>=0&&e.low<=u16.MAX_VALUE},e.i64_is_u32=function(e){return 0===e.high},e.i64_is_bool=function(e){return 0===e.high&&(0===e.low||1===e.low)};const n=t.fromNumber(f32.MIN_SAFE_INTEGER),i=t.fromNumber(f32.MAX_SAFE_INTEGER);e.i64_is_f32=function(e){return e.gte(n)&&e.lte(i)};const a=t.fromNumber(f64.MIN_SAFE_INTEGER),o=t.fromNumber(f64.MAX_SAFE_INTEGER);e.i64_is_f64=function(e){return e.gte(a)&&e.lte(o)},e.i64_to_f32=function(t){return e.Math.fround(t.toNumber())},e.i64_to_f64=function(e){return e.toNumber()},e.i64_to_string=function(e,t){return(t?e.toUnsigned():e).toString(10)}}).call(t,r(3))},function(e,t){function r(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function n(e){return!0===(e&&e.__isLong__)}function i(e,t){var r,n,i;return t?(e>>>=0,(i=0<=e&&e<256)&&(n=l[e])?n:(r=o(e,(0|e)<0?-1:0,!0),i&&(l[e]=r),r)):(e|=0,(i=-128<=e&&e<128)&&(n=u[e])?n:(r=o(e,e<0?-1:0,!1),i&&(u[e]=r),r))}function a(e,t){if(isNaN(e))return t?E:f;if(t){if(e<0)return E;if(e>=_)return v}else{if(e<=-y)return N;if(e+1>=y)return I}return e<0?a(-e,t).neg():o(e%d|0,e/d|0,t)}function o(e,t,n){return new r(e,t,n)}function s(e,t,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return f;if("number"==typeof t?(r=t,t=!1):t=!!t,(r=r||10)<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return s(e.substring(1),t,r).neg();for(var i=a(h(r,8)),o=f,c=0;c<e.length;c+=8){var p=Math.min(8,e.length-c),u=parseInt(e.substring(c,c+p),r);if(p<8){var l=a(h(r,p));o=o.mul(l).add(a(u))}else o=o.mul(i),o=o.add(a(u))}return o.unsigned=t,o}function c(e,t){return"number"==typeof e?a(e,t):"string"==typeof e?s(e,t):o(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}e.exports=r;var p=null;try{p=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0}),r.isLong=n;var u={},l={};r.fromInt=i,r.fromNumber=a,r.fromBits=o;var h=Math.pow;r.fromString=s,r.fromValue=c;var d=4294967296,_=d*d,y=_/2,m=i(1<<24),f=i(0);r.ZERO=f;var E=i(0,!0);r.UZERO=E;var g=i(1);r.ONE=g;var T=i(1,!0);r.UONE=T;var A=i(-1);r.NEG_ONE=A;var I=o(-1,2147483647,!1);r.MAX_VALUE=I;var v=o(-1,-1,!0);r.MAX_UNSIGNED_VALUE=v;var N=o(0,-2147483648,!1);r.MIN_VALUE=N;var S=r.prototype;S.toInt=function(){return this.unsigned?this.low>>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},S.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(N)){var t=a(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=a(h(e,6),this.unsigned),o=this,s="";;){var c=o.div(i),p=o.sub(c.mul(i)).toInt()>>>0,u=p.toString(e);if(o=c,o.isZero())return u+s;for(;u.length<6;)u="0"+u;s=""+u+s}},S.getHighBits=function(){return this.high},S.getHighBitsUnsigned=function(){return this.high>>>0},S.getLowBits=function(){return this.low},S.getLowBitsUnsigned=function(){return this.low>>>0},S.getNumBitsAbs=function(){if(this.isNegative())return this.eq(N)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},S.isZero=function(){return 0===this.high&&0===this.low},S.eqz=S.isZero,S.isNegative=function(){return!this.unsigned&&this.high<0},S.isPositive=function(){return this.unsigned||this.high>=0},S.isOdd=function(){return 1==(1&this.low)},S.isEven=function(){return 0==(1&this.low)},S.equals=function(e){return n(e)||(e=c(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},S.eq=S.equals,S.notEquals=function(e){return!this.eq(e)},S.neq=S.notEquals,S.ne=S.notEquals,S.lessThan=function(e){return this.comp(e)<0},S.lt=S.lessThan,S.lessThanOrEqual=function(e){return this.comp(e)<=0},S.lte=S.lessThanOrEqual,S.le=S.lessThanOrEqual,S.greaterThan=function(e){return this.comp(e)>0},S.gt=S.greaterThan,S.greaterThanOrEqual=function(e){return this.comp(e)>=0},S.gte=S.greaterThanOrEqual,S.ge=S.greaterThanOrEqual,S.compare=function(e){if(n(e)||(e=c(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},S.comp=S.compare,S.negate=function(){return!this.unsigned&&this.eq(N)?N:this.not().add(g)},S.neg=S.negate,S.add=function(e){n(e)||(e=c(e));var t=this.high>>>16,r=65535&this.high,i=this.low>>>16,a=65535&this.low,s=e.high>>>16,p=65535&e.high,u=e.low>>>16,l=65535&e.low,h=0,d=0,_=0,y=0;return y+=a+l,_+=y>>>16,y&=65535,_+=i+u,d+=_>>>16,_&=65535,d+=r+p,h+=d>>>16,d&=65535,h+=t+s,h&=65535,o(_<<16|y,h<<16|d,this.unsigned)},S.subtract=function(e){return n(e)||(e=c(e)),this.add(e.neg())},S.sub=S.subtract,S.multiply=function(e){if(this.isZero())return f;if(n(e)||(e=c(e)),p){return o(p.mul(this.low,this.high,e.low,e.high),p.get_high(),this.unsigned)}if(e.isZero())return f;if(this.eq(N))return e.isOdd()?N:f;if(e.eq(N))return this.isOdd()?N:f;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(m)&&e.lt(m))return a(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=65535&this.high,i=this.low>>>16,s=65535&this.low,u=e.high>>>16,l=65535&e.high,h=e.low>>>16,d=65535&e.low,_=0,y=0,E=0,g=0;return g+=s*d,E+=g>>>16,g&=65535,E+=i*d,y+=E>>>16,E&=65535,E+=s*h,y+=E>>>16,E&=65535,y+=r*d,_+=y>>>16,y&=65535,y+=i*h,_+=y>>>16,y&=65535,y+=s*l,_+=y>>>16,y&=65535,_+=t*d+r*h+i*l+s*u,_&=65535,o(E<<16|g,_<<16|y,this.unsigned)},S.mul=S.multiply,S.divide=function(e){if(n(e)||(e=c(e)),e.isZero())throw Error("division by zero");if(p){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;return o((this.unsigned?p.div_u:p.div_s)(this.low,this.high,e.low,e.high),p.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?E:f;var t,r,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return E;if(e.gt(this.shru(1)))return T;i=E}else{if(this.eq(N)){if(e.eq(g)||e.eq(A))return N;if(e.eq(N))return g;return t=this.shr(1).div(e).shl(1),t.eq(f)?e.isNegative()?g:A:(r=this.sub(e.mul(t)),i=t.add(r.div(e)))}if(e.eq(N))return this.unsigned?E:f;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=f}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(t)/Math.LN2),u=s<=48?1:h(2,s-48),l=a(t),d=l.mul(e);d.isNegative()||d.gt(r);)t-=u,l=a(t,this.unsigned),d=l.mul(e);l.isZero()&&(l=g),i=i.add(l),r=r.sub(d)}return i},S.div=S.divide,S.modulo=function(e){if(n(e)||(e=c(e)),p){return o((this.unsigned?p.rem_u:p.rem_s)(this.low,this.high,e.low,e.high),p.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},S.mod=S.modulo,S.rem=S.modulo,S.not=function(){return o(~this.low,~this.high,this.unsigned)},S.and=function(e){return n(e)||(e=c(e)),o(this.low&e.low,this.high&e.high,this.unsigned)},S.or=function(e){return n(e)||(e=c(e)),o(this.low|e.low,this.high|e.high,this.unsigned)},S.xor=function(e){return n(e)||(e=c(e)),o(this.low^e.low,this.high^e.high,this.unsigned)},S.shiftLeft=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):o(0,this.low<<e-32,this.unsigned)},S.shl=S.shiftLeft,S.shiftRight=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):o(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(e){if(n(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;if(e<32){return o(this.low>>>e|t<<32-e,t>>>e,this.unsigned)}return 32===e?o(t,0,this.unsigned):o(t>>>e-32,0,this.unsigned)},S.shru=S.shiftRightUnsigned,S.shr_u=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?o(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:o(this.low,this.high,!0)},S.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},S.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},S.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},r.fromBytes=function(e,t,n){return n?r.fromBytesLE(e,t):r.fromBytesBE(e,t)},r.fromBytesLE=function(e,t){return new r(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},r.fromBytesBE=function(e,t){return new r(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},function(e,t,r){"use strict";function n(e,t,r,n){return void 0===r&&(r=!1),void 0===n&&(n=null),n||(n=new A.Parser,r=!0),n.parseFile(e,t,r),n}function i(e){return e.nextFile()}function a(e){var t=e.program;return t.diagnosticsOffset<t.diagnostics.length?t.diagnostics[t.diagnosticsOffset++]:null}function o(e){return e.category==T.DiagnosticCategory.INFO}function s(e){return e.category==T.DiagnosticCategory.WARNING}function c(e){return e.category==T.DiagnosticCategory.ERROR}function p(){return new E.Options}function u(e,t){e.target=t}function l(e,t){e.noTreeShaking=t}function h(e,t){e.noAssert=t}function d(e,t){e.noMemory=t}function _(e,t){e.sourceMap=t}function y(e,t){e.memoryBase=t}function m(e,t){void 0===t&&(t=null);var r=e.finish();return new E.Compiler(r,t).compile()}function f(e){var t=new g.Decompiler;return t.decompile(e),t.finish()}Object.defineProperty(t,"__esModule",{value:!0});var E=r(4),g=r(20),T=r(1);t.formatDiagnostic=T.formatDiagnosticMessage;var A=r(21);t.parseFile=n,t.nextFile=i,t.nextDiagnostic=a,t.isInfo=o,t.isWarning=s,t.isError=c,t.createOptions=p,t.setTarget=u,t.setNoTreeShaking=l,t.setNoAssert=h,t.setNoMemory=d,t.setSourceMap=_,t.setMemoryBase=y,t.compile=m,t.decompile=f;var I=r(2);t.LIBRARY_PREFIX=I.LIBRARY_PREFIX},function(e,t,r){"use strict";function n(e){switch(e){case i.NativeType.None:return"void";case i.NativeType.I32:return"i32";case i.NativeType.I64:return"i64";case i.NativeType.F32:return"f32";case i.NativeType.F64:return"f64";case i.NativeType.Unreachable:throw new Error("unreachable type");case i.NativeType.Auto:throw new Error("auto type");default:throw new Error("unexpected type")}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),a=function(){function e(){this.text=[],this.functionId=0}return e.decompile=function(t){var r=new e;return r.decompile(t),r.finish()},e.prototype.decompile=function(e){throw new Error("not implemented")},e.prototype.decompileFunction=function(e){var t=i.readString(_BinaryenFunctionGetName(e))||"$"+this.functionId.toString(10),r=_BinaryenFunctionGetBody(e);this.push("function "),this.push(t),this.push("(");for(var a=0,o=_BinaryenFunctionGetNumParams(e);a<o;++a)a>0&&this.push(", "),this.push("$"),this.push(a.toString(10)),this.push(": "),this.push(n(_BinaryenFunctionGetParam(e,a)));this.push("): "),this.push(n(_BinaryenFunctionGetResult(e))),this.push(" "),_BinaryenExpressionGetId(r)!=i.ExpressionId.Block&&this.push("{\n"),this.decompileExpression(r),_BinaryenExpressionGetId(r)!=i.ExpressionId.Block&&this.push("\n}\n"),++this.functionId},e.prototype.decompileExpression=function(e){var t,r,a,o,s=_BinaryenExpressionGetId(e),c=_BinaryenExpressionGetType(e);switch(s){case i.ExpressionId.Block:for(null!=(r=i.readString(_BinaryenBlockGetName(e)))&&(this.push(r),this.push(": ")),this.push("{\n"),o=_BinaryenBlockGetNumChildren(e),a=0;a<o;++a)this.decompileExpression(_BinaryenBlockGetChild(e,a));return void this.push("}\n");case i.ExpressionId.If:return void(c==i.NativeType.None?(this.push("if ("),this.decompileExpression(_BinaryenIfGetCondition(e)),this.push(") "),this.decompileExpression(_BinaryenIfGetIfTrue(e)),(t=_BinaryenIfGetIfFalse(e))&&(this.push(" else "),this.decompileExpression(t))):(this.decompileExpression(_BinaryenIfGetCondition(e)),this.push(" ? "),this.decompileExpression(_BinaryenIfGetIfTrue(e)),this.push(" : "),this.decompileExpression(_BinaryenIfGetIfFalse(e))));case i.ExpressionId.Loop:null!=(r=i.readString(_BinaryenLoopGetName(e)))&&(this.push(r),this.push(": ")),this.push("do "),this.decompileExpression(_BinaryenLoopGetBody(e)),this.push("while (0);\n");case i.ExpressionId.Break:return(t=_BinaryenBreakGetCondition(e))&&(this.push("if ("),this.decompileExpression(t),this.push(") ")),void(null!=(r=i.readString(_BinaryenBreakGetName(e)))?(this.push("break "),this.push(r),this.push(";\n")):this.push("break;\n"));case i.ExpressionId.Switch:case i.ExpressionId.Call:case i.ExpressionId.CallImport:case i.ExpressionId.CallIndirect:case i.ExpressionId.GetLocal:return this.push("$"),void this.push(_BinaryenGetLocalGetIndex(e).toString(10));case i.ExpressionId.SetLocal:return this.push("$"),this.push(_BinaryenSetLocalGetIndex(e).toString(10)),this.push(" = "),void this.decompileExpression(_BinaryenSetLocalGetValue(e));case i.ExpressionId.GetGlobal:case i.ExpressionId.SetGlobal:case i.ExpressionId.Load:return this.push("load<"),this.push(n(c)),this.push(">("),this.push(_BinaryenLoadGetOffset(e).toString(10)),this.push(" + "),this.decompileExpression(_BinaryenLoadGetPtr(e)),void this.push(")");case i.ExpressionId.Store:return this.push("store<"),this.push(n(c)),this.push(">("),this.push(_BinaryenStoreGetOffset(e).toString(10)),this.push(" + "),this.decompileExpression(_BinaryenStoreGetPtr(e)),this.push(", "),this.decompileExpression(_BinaryenStoreGetValue(e)),void this.push(")");case i.ExpressionId.Const:switch(c){case i.NativeType.I32:return void this.push(_BinaryenConstGetValueI32(e).toString(10));case i.NativeType.I64:return void this.push(i64_to_string(i64_new(_BinaryenConstGetValueI64Low(e),_BinaryenConstGetValueI64High(e))));case i.NativeType.F32:return void this.push(_BinaryenConstGetValueF32(e).toString(10));case i.NativeType.F64:return void this.push(_BinaryenConstGetValueF64(e).toString(10))}break;case i.ExpressionId.Unary:switch(_BinaryenUnaryGetOp(e)){case i.UnaryOp.ClzI32:return this.push("clz<i32>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.CtzI32:return this.push("ctz<i32>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.PopcntI32:return this.push("popcnt<i32>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.NegF32:case i.UnaryOp.NegF64:return this.push("-"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.AbsF32:return this.push("abs<f32>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.CeilF32:return this.push("ceil<f32>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.FloorF32:return this.push("floor<f32>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.TruncF32:return this.push("trunc<f32>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.NearestF32:return this.push("nearest<i32>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.SqrtF32:return this.push("sqrt<f32>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.EqzI32:case i.UnaryOp.EqzI64:return this.push("!"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.ClzI64:return this.push("clz<i64>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.CtzI64:return this.push("ctz<i64>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.PopcntI64:return this.push("popcnt<i64>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.AbsF64:return this.push("abs<f64>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.CeilF64:return this.push("ceil<f64>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.FloorF64:return this.push("floor<f64>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.TruncF64:return this.push("trunc<f64>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.NearestF64:return this.push("nearest<f64>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.SqrtF64:return this.push("sqrt<f64>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.ExtendI32:return this.push("<i64>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.ExtendU32:return this.push("<i64><u64>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.WrapI64:case i.UnaryOp.TruncF32ToI32:return this.push("<i32>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.TruncF32ToI64:return this.push("<i64>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.TruncF32ToU32:return this.push("<i32><u32>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.TruncF32ToU64:return this.push("<i64><u64>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.TruncF64ToI32:return this.push("<i32>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.TruncF64ToI64:return this.push("<i64>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.TruncF64ToU32:return this.push("<i32><u32>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.TruncF64ToU64:return this.push("<i64><u64>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.ReinterpretF32:return this.push("reinterpret<f32,i32>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.ReinterpretF64:return this.push("reinterpret<f64,i64>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.ConvertI32ToF32:return this.push("<f32>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.ConvertI32ToF64:return this.push("<f64>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.ConvertU32ToF32:return this.push("<f32><u32>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.ConvertU32ToF64:return this.push("<f64><u32>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.ConvertI64ToF32:return this.push("<f32>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.ConvertI64ToF64:return this.push("<f64>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.ConvertU64ToF32:return this.push("<f32><u64>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.ConvertU64ToF64:return this.push("<f64><u64>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.PromoteF32:return this.push("<f64>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.DemoteF64:return this.push("<f32>"),void this.decompileExpression(_BinaryenUnaryGetValue(e));case i.UnaryOp.ReinterpretI32:return this.push("reinterpret<i32,f32>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")");case i.UnaryOp.ReinterpretI64:return this.push("reinterpret<i64,f64>("),this.decompileExpression(_BinaryenUnaryGetValue(e)),void this.push(")")}break;case i.ExpressionId.Binary:switch(_BinaryenBinaryGetOp(e)){case i.BinaryOp.AddI32:case i.BinaryOp.AddI64:case i.BinaryOp.AddF32:case i.BinaryOp.AddF64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" + "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.SubI32:case i.BinaryOp.SubI64:case i.BinaryOp.SubF32:case i.BinaryOp.SubF64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" - "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.MulI32:case i.BinaryOp.MulI64:case i.BinaryOp.MulF32:case i.BinaryOp.MulF64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" * "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.DivI32:case i.BinaryOp.DivI64:case i.BinaryOp.DivF32:case i.BinaryOp.DivF64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" / "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.DivU32:return this.push("<i32>(<u32>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" / <u32>"),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")");case i.BinaryOp.RemI32:case i.BinaryOp.RemI64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" % "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.RemU32:return this.push("<i32>(<u32>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" / <u32>"),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")");case i.BinaryOp.AndI32:case i.BinaryOp.AndI64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" & "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.OrI32:case i.BinaryOp.OrI64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" | "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.XorI32:case i.BinaryOp.XorI64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" ^ "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.ShlI32:case i.BinaryOp.ShlI64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" << "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.ShrU32:case i.BinaryOp.ShrU64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" >>> "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.ShrI32:case i.BinaryOp.ShrI64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" >> "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.RotlI32:return this.push("rotl<i32>("),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(", "),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")");case i.BinaryOp.RotrI32:return this.push("rotr<i32>("),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(", "),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")");case i.BinaryOp.EqI32:case i.BinaryOp.EqI64:case i.BinaryOp.EqF32:case i.BinaryOp.EqF64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" == "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.NeI32:case i.BinaryOp.NeI64:case i.BinaryOp.NeF32:case i.BinaryOp.NeF64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" != "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.LtI32:case i.BinaryOp.LtI64:case i.BinaryOp.LtF32:case i.BinaryOp.LtF64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" < "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.LtU32:return this.push("<u32>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" < <u32>"),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.LeI32:case i.BinaryOp.LeI64:case i.BinaryOp.LeF32:case i.BinaryOp.LeF64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" <= "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.LeU32:return this.push("<u32>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" <= <u32>"),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.GtI32:case i.BinaryOp.GtI64:case i.BinaryOp.GtF32:case i.BinaryOp.GtF64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" > "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.GtU32:return this.push("<u32>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" > <u32>"),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.GeI32:case i.BinaryOp.GeI64:case i.BinaryOp.GeF32:case i.BinaryOp.GeF64:return this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" >= "),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.GeU32:return this.push("<u32>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" >= <u32>"),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.DivU64:return this.push("<u64>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" / <u64>"),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.RemU64:return this.push("<u64>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" % <u64>"),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.RotlI64:return this.push("rotl<i64>("),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(", "),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")");case i.BinaryOp.RotrI64:return this.push("rotr<i64>("),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(", "),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")");case i.BinaryOp.LtU64:return this.push("<u64>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" < <u64>"),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.LeU64:return this.push("<u64>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" <= <u64>"),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.GtU64:return this.push("<u64>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" > <u64>"),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.GeU64:return this.push("<u64>"),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(" >= <u64>"),void this.decompileExpression(_BinaryenBinaryGetRight(e));case i.BinaryOp.CopysignF32:return this.push("copysign<f32>("),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(", "),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")");case i.BinaryOp.MinF32:return this.push("min<f32>("),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(", "),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")");case i.BinaryOp.MaxF32:return this.push("max<f32>("),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(", "),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")");case i.BinaryOp.CopysignF64:return this.push("copysign<f64>("),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(", "),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")");case i.BinaryOp.MinF64:return this.push("min<f64>("),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(", "),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")");case i.BinaryOp.MaxF64:return this.push("max<f64>("),this.decompileExpression(_BinaryenBinaryGetLeft(e)),this.push(", "),this.decompileExpression(_BinaryenBinaryGetRight(e)),void this.push(")")}return;case i.ExpressionId.Select:return this.push("select<"),this.push(n(c)),this.push(">("),this.decompileExpression(_BinaryenSelectGetIfTrue(e)),this.push(", "),this.decompileExpression(_BinaryenSelectGetIfFalse(e)),this.push(", "),this.decompileExpression(_BinaryenSelectGetCondition(e)),void this.push(")");case i.ExpressionId.Drop:return this.decompileExpression(_BinaryenDropGetValue(e)),void this.push(";\n");case i.ExpressionId.Return:return void((t=_BinaryenReturnGetValue(e))?(this.push("return "),this.decompileExpression(t),this.push(";\n")):this.push("return;\n"));case i.ExpressionId.Host:switch(_BinaryenHostGetOp(e)){case i.HostOp.CurrentMemory:return void this.push("current_memory()");case i.HostOp.GrowMemory:return this.push("grow_memory("),this.decompileExpression(_BinaryenHostGetOperand(e,0)),void this.push(")")}break;case i.ExpressionId.Nop:return void this.push(";\n");case i.ExpressionId.Unreachable:return void this.push("unreachable()");case i.ExpressionId.AtomicCmpxchg:case i.ExpressionId.AtomicRMW:case i.ExpressionId.AtomicWait:case i.ExpressionId.AtomicWake:}throw new Error("not implemented")},e.prototype.push=function(e){this.text.push(e)},e.prototype.finish=function(){var e=this.text.join("");return this.text=[],e},e}();t.Decompiler=a},function(e,t,r){"use strict";function n(e){switch(e){case c.Token.DOT_DOT_DOT:return 1;case c.Token.YIELD:return 2;case c.Token.EXCLAMATION:case c.Token.TILDE:case c.Token.PLUS:case c.Token.MINUS:case c.Token.PLUS_PLUS:case c.Token.MINUS_MINUS:case c.Token.TYPEOF:case c.Token.VOID:case c.Token.DELETE:return 16;case c.Token.NEW:return 19;default:return-1}}function i(e){switch(e){case c.Token.COMMA:return 0;case c.Token.EQUALS:case c.Token.PLUS_EQUALS:case c.Token.MINUS_EQUALS:case c.Token.ASTERISK_ASTERISK_EQUALS:case c.Token.ASTERISK_EQUALS:case c.Token.SLASH_EQUALS:case c.Token.PERCENT_EQUALS:case c.Token.LESSTHAN_LESSTHAN_EQUALS:case c.Token.GREATERTHAN_GREATERTHAN_EQUALS:case c.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS:case c.Token.AMPERSAND_EQUALS:case c.Token.CARET_EQUALS:case c.Token.BAR_EQUALS:return 3;case c.Token.QUESTION:return 4;case c.Token.BAR_BAR:return 5;case c.Token.AMPERSAND_AMPERSAND:return 6;case c.Token.BAR:return 7;case c.Token.CARET:return 8;case c.Token.AMPERSAND:return 9;case c.Token.EQUALS_EQUALS:case c.Token.EXCLAMATION_EQUALS:case c.Token.EQUALS_EQUALS_EQUALS:case c.Token.EXCLAMATION_EQUALS_EQUALS:return 10;case c.Token.AS:case c.Token.IN:case c.Token.INSTANCEOF:case c.Token.LESSTHAN:case c.Token.GREATERTHAN:case c.Token.LESSTHAN_EQUALS:case c.Token.GREATERTHAN_EQUALS:return 11;case c.Token.LESSTHAN_LESSTHAN:case c.Token.GREATERTHAN_GREATERTHAN:case c.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN:return 12;case c.Token.PLUS:case c.Token.MINUS:return 13;case c.Token.ASTERISK:case c.Token.SLASH:case c.Token.PERCENT:return 14;case c.Token.ASTERISK_ASTERISK:return 15;case c.Token.PLUS_PLUS:case c.Token.MINUS_MINUS:return 17;case c.Token.DOT:case c.Token.NEW:case c.Token.OPENBRACKET:return 19;default:return-1}}function a(e){switch(e){case c.Token.EQUALS:case c.Token.PLUS_EQUALS:case c.Token.MINUS_EQUALS:case c.Token.ASTERISK_ASTERISK_EQUALS:case c.Token.ASTERISK_EQUALS:case c.Token.SLASH_EQUALS:case c.Token.PERCENT_EQUALS:case c.Token.LESSTHAN_LESSTHAN_EQUALS:case c.Token.GREATERTHAN_GREATERTHAN_EQUALS:case c.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS:case c.Token.AMPERSAND_EQUALS:case c.Token.CARET_EQUALS:case c.Token.BAR_EQUALS:case c.Token.QUESTION:case c.Token.ASTERISK_ASTERISK:return!0;default:return!1}}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var s=r(2),c=r(7),p=r(1),u=r(10),l=r(6),h=function(e){function t(){var t=e.call(this)||this;return t.backlog=new Array,t.seenlog=new Set,t.program=new s.Program(t.diagnostics),t}return o(t,e),t.prototype.parseFile=function(e,t,r){for(var n=u.normalize(t),i=0,a=this.program.sources.length;i<a;++i)if(this.program.sources[i].normalizedPath==n)return;this.seenlog.add(n);var o=new l.Source(n,e,r?l.SourceKind.ENTRY:t.startsWith(s.LIBRARY_PREFIX)&&t.indexOf(s.PATH_DELIMITER,s.LIBRARY_PREFIX.length)<0?l.SourceKind.LIBRARY:l.SourceKind.DEFAULT);this.program.sources.push(o);var p=new c.Tokenizer(o,this.program.diagnostics);for(o.tokenizer=p;!p.skip(c.Token.ENDOFFILE);){var h=this.parseTopLevelStatement(p);h&&(h.parent=o,o.statements.push(h))}p.finish()},t.prototype.parseTopLevelStatement=function(e,t){void 0===t&&(t=!1);for(var r=null;e.skip(c.Token.AT);){var n=this.parseDecorator(e);if(!n)break;r||(r=[]),r.push(n)}var i=null;e.skip(c.Token.EXPORT)&&(i=l.addModifier(l.Node.createModifier(l.ModifierKind.EXPORT,e.range()),i)),e.skip(c.Token.DECLARE)&&(i=l.addModifier(l.Node.createModifier(l.ModifierKind.DECLARE,e.range()),i),e.peek(!0),e.nextTokenOnNewLine&&this.error(p.DiagnosticCode.Line_break_not_permitted_here,e.range(e.pos))),e.mark();var a,o=null;switch(e.next()){case c.Token.CONST:if(i=l.addModifier(l.Node.createModifier(l.ModifierKind.CONST,e.range()),i),e.skip(c.Token.ENUM)){o=this.parseEnum(e,i,r);break}o=this.parseVariable(e,i,r),r=null;break;case c.Token.LET:i=l.addModifier(l.Node.createModifier(l.ModifierKind.LET,e.range()),i);case c.Token.VAR:o=this.parseVariable(e,i,r),r=null;break;case c.Token.ENUM:o=this.parseEnum(e,i,r),r=null;break;case c.Token.FUNCTION:o=this.parseFunction(e,i,r),r=null;break;case c.Token.ABSTRACT:if(!e.skip(c.Token.CLASS)){this.error(p.DiagnosticCode._0_expected,e.range(e.pos),"class");break}i=l.addModifier(l.Node.createModifier(l.ModifierKind.ABSTRACT,e.range()),i);case c.Token.CLASS:o=this.parseClass(e,i,r),r=null;break;case c.Token.NAMESPACE:o=this.parseNamespace(e,i,r),r=null;break;case c.Token.IMPORT:o=(a=l.getModifier(l.ModifierKind.EXPORT,i))?this.parseExportImport(e,a.range):this.parseImport(e),i&&l.setReusableModifiers(i);break;case c.Token.TYPE:o=this.parseTypeDeclaration(e,i,r),r=null;break;default:l.hasModifier(l.ModifierKind.EXPORT,i)?(e.reset(),o=this.parseExport(e,i)):(i&&((a=l.getModifier(l.ModifierKind.DECLARE,i))&&this.error(p.DiagnosticCode._0_modifier_cannot_be_used_here,a.range,"declare"),l.setReusableModifiers(i)),e.reset(),t||(o=this.parseStatement(e,!0)))}if(r)for(var s=0,u=r.length;s<u;++s)this.error(p.DiagnosticCode.Decorators_are_not_valid_here,r[s].range);return o},t.prototype.nextFile=function(){return this.backlog.length?this.backlog.shift():null},t.prototype.finish=function(){if(this.backlog.length)throw new Error("backlog is not empty");return this.backlog=[],this.seenlog.clear(),this.program},t.prototype.parseType=function(e,t,r){void 0===t&&(t=!0),void 0===r&&(r=!1);var n=e.next(),i=e.tokenPos;if(n==c.Token.VOID)return l.Node.createType(l.Node.createIdentifierExpression("void",e.range()),[],!1,e.range(i,e.pos));var a;if(t&&n==c.Token.OPENPAREN){var o=this.parseType(e,!1,r);if(!o)return null;if(!e.skip(c.Token.CLOSEPAREN))return r||this.error(p.DiagnosticCode._0_expected,e.range(e.pos),"}"),null;a=o,a.range.start=i,a.range.end=e.pos}else if(n==c.Token.THIS)a=l.Node.createType(l.Node.createThisExpression(e.range()),[],!1,e.range(i,e.pos));else if(n==c.Token.TRUE||n==c.Token.FALSE)a=l.Node.createType(l.Node.createIdentifierExpression("bool",e.range()),[],!1,e.range(i,e.pos));else if(n==c.Token.STRINGLITERAL)e.readString(),a=l.Node.createType(l.Node.createIdentifierExpression("string",e.range()),[],!1,e.range(i,e.pos));else{if(n!=c.Token.IDENTIFIER)return r||this.error(p.DiagnosticCode.Identifier_expected,e.range()),null;var s=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),u=new Array,h=!1;if(e.skip(c.Token.LESSTHAN)){do{var d=this.parseType(e,!0,r);if(!d)return null;u.push(d)}while(e.skip(c.Token.COMMA));if(!e.skip(c.Token.GREATERTHAN))return r||this.error(p.DiagnosticCode._0_expected,e.range(e.pos),">"),null}if(e.skip(c.Token.BAR)){if(!e.skip(c.Token.NULL))return r||this.error(p.DiagnosticCode._0_expected,e.range(e.pos),"null"),null;h=!0}a=l.Node.createType(s,u,h,e.range(i,e.pos))}for(;e.skip(c.Token.OPENBRACKET);){var _=e.tokenPos;if(!e.skip(c.Token.CLOSEBRACKET))return r||this.error(p.DiagnosticCode._0_expected,e.range(),"]"),null;var y=e.range(_,e.pos);if(h=!1,e.skip(c.Token.BAR)){if(!e.skip(c.Token.NULL))return r||this.error(p.DiagnosticCode._0_expected,e.range(),"null"),null;h=!0}if(a=l.Node.createType(l.Node.createIdentifierExpression("Array",y),[a],h,e.range(i,e.pos)),h)break}return a},t.prototype.parseDecorator=function(e){var t=e.tokenPos;if(e.skip(c.Token.IDENTIFIER)){for(var r=e.readIdentifier(),n=l.Node.createIdentifierExpression(r,e.range(t,e.pos));e.skip(c.Token.DOT);){if(!e.skip(c.Token.IDENTIFIER))return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null;r=e.readIdentifier(),n=l.Node.createPropertyAccessExpression(n,l.Node.createIdentifierExpression(r,e.range()),e.range(t,e.pos))}var i;if(!e.skip(c.Token.OPENPAREN))return l.Node.createDecorator(n,null,e.range(t,e.pos));if(i=this.parseArguments(e))return l.Node.createDecorator(n,i,e.range(t,e.pos))}else this.error(p.DiagnosticCode.Identifier_expected,e.range());return null},t.prototype.parseVariable=function(e,t,r){var n=t&&t.length?t[0].range.start:e.tokenPos,i=new Array,a=l.hasModifier(l.ModifierKind.DECLARE,t);do{var o=this.parseVariableDeclaration(e,a,t,r);if(!o)return null;i.push(o)}while(e.skip(c.Token.COMMA));var s=l.Node.createVariableStatement(i,t,r,e.range(n,e.pos));return e.skip(c.Token.SEMICOLON),s},t.prototype.parseVariableDeclaration=function(e,t,r,n){if(void 0===t&&(t=!1),!e.skip(c.Token.IDENTIFIER))return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null;var i=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),a=null;e.skip(c.Token.COLON)&&(a=this.parseType(e));var o=null;if(e.skip(c.Token.EQUALS)){if(t&&this.error(p.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts,e.range()),!(o=this.parseExpression(e,1)))return null}else l.hasModifier(l.ModifierKind.CONST,r)?l.hasModifier(l.ModifierKind.DECLARE,r)||this.error(p.DiagnosticCode._const_declarations_must_be_initialized,i.range):a||this.error(p.DiagnosticCode.Type_expected,e.range(e.pos));return l.Node.createVariableDeclaration(i,a,o,r,n,c.Range.join(i.range,e.range()))},t.prototype.parseEnum=function(e,t,r){var n=t&&t.length?t[0].range.start:e.tokenPos;if(e.next()!=c.Token.IDENTIFIER)return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null;var i=l.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.next()!=c.Token.OPENBRACE)return this.error(p.DiagnosticCode._0_expected,e.range(),"{"),null;var a=new Array;if(!e.skip(c.Token.CLOSEBRACE)){do{var o=this.parseEnumValue(e);if(!o)return null;a.push(o)}while(e.skip(c.Token.COMMA));if(!e.skip(c.Token.CLOSEBRACE))return this.error(p.DiagnosticCode._0_expected,e.range(),"}"),null}var s=l.Node.createEnumDeclaration(i,a,t,r,e.range(n,e.pos));return e.skip(c.Token.SEMICOLON),s},t.prototype.parseEnumValue=function(e){if(!e.skip(c.Token.IDENTIFIER))return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null;var t=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),r=null;return e.skip(c.Token.EQUALS)&&!(r=this.parseExpression(e,1))?null:l.Node.createEnumValueDeclaration(t,r,c.Range.join(t.range,e.range()))},t.prototype.parseReturn=function(e){var t=null;if(e.peek(!0)!=c.Token.SEMICOLON&&e.nextToken!=c.Token.CLOSEBRACE&&!e.nextTokenOnNewLine&&!(t=this.parseExpression(e)))return null;var r=l.Node.createReturnStatement(t,e.range());return e.skip(c.Token.SEMICOLON),r},t.prototype.parseTypeParameters=function(e){var t=new Array;if(e.skip(c.Token.GREATERTHAN))this.error(p.DiagnosticCode.Type_parameter_list_cannot_be_empty,e.range());else{do{var r=this.parseTypeParameter(e);if(!r)return null;t.push(r)}while(e.skip(c.Token.COMMA));if(!e.skip(c.Token.GREATERTHAN))return this.error(p.DiagnosticCode._0_expected,e.range(),">"),null}return t},t.prototype.parseTypeParameter=function(e){if(e.next()==c.Token.IDENTIFIER){var t=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),r=null;return e.skip(c.Token.EXTENDS)&&!(r=this.parseType(e))?null:l.Node.createTypeParameter(t,r,c.Range.join(t.range,e.range()))}return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null},t.prototype.parseParameters=function(e){var t=new Array,r=null,n=!1,i=!1;if(e.peek()!=c.Token.CLOSEPAREN)do{var a=this.parseParameter(e);if(!a)return null;switch(r&&!i&&(this.error(p.DiagnosticCode.A_rest_parameter_must_be_last_in_a_parameter_list,r.name.range),i=!0),a.parameterKind){default:n&&this.error(p.DiagnosticCode.A_required_parameter_cannot_follow_an_optional_parameter,a.name.range);break;case l.ParameterKind.OPTIONAL:n=!0;break;case l.ParameterKind.REST:r=a}t.push(a)}while(e.skip(c.Token.COMMA));return e.skip(c.Token.CLOSEPAREN)?t:(this.error(p.DiagnosticCode._0_expected,e.range(),")"),null)},t.prototype.parseParameter=function(e){var t=!1,r=!1,n=null;if(e.skip(c.Token.DOT_DOT_DOT)&&(t=!0,n=e.range()),e.skip(c.Token.IDENTIFIER)){t||(n=e.range());var i=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),a=null;if((r=e.skip(c.Token.QUESTION))&&t&&this.error(p.DiagnosticCode.A_rest_parameter_cannot_be_optional,i.range),e.skip(c.Token.COLON)&&!(a=this.parseType(e)))return null;var o=null;return!e.skip(c.Token.EQUALS)||(t&&this.error(p.DiagnosticCode.A_rest_parameter_cannot_have_an_initializer,i.range),r?this.error(p.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer,i.range):r=!0,o=this.parseExpression(e,1))?l.Node.createParameter(i,a,o,t?l.ParameterKind.REST:r?l.ParameterKind.OPTIONAL:l.ParameterKind.DEFAULT,c.Range.join(n,e.range())):null}return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null},t.prototype.parseFunction=function(e,t,r){var n=t&&t.length?t[0].range.start:e.tokenPos;if(!e.skip(c.Token.IDENTIFIER))return this.error(p.DiagnosticCode.Identifier_expected,e.range(e.pos)),null;var i=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),a=null;if(e.skip(c.Token.LESSTHAN)){if(!(a=this.parseTypeParameters(e)))return null}else a=[];if(!e.skip(c.Token.OPENPAREN))return this.error(p.DiagnosticCode._0_expected,e.range(e.pos),"("),null;var o=this.parseParameters(e);if(!o)return null;var s=l.hasModifier(l.ModifierKind.SET,t);s&&(1!=o.length&&this.error(p.DiagnosticCode.A_set_accessor_must_have_exactly_one_parameter,i.range),o.length&&o[0].initializer&&this.error(p.DiagnosticCode.A_set_accessor_parameter_cannot_have_an_initializer,i.range)),l.hasModifier(l.ModifierKind.GET,t)&&o.length&&this.error(p.DiagnosticCode.A_get_accessor_cannot_have_parameters,i.range);var u=null;if(e.skip(c.Token.COLON)){if(!(u=this.parseType(e,s)))return null}else s||this.error(p.DiagnosticCode.Type_expected,e.range(e.pos));var h=l.hasModifier(l.ModifierKind.DECLARE,t),d=null;if(e.skip(c.Token.OPENBRACE))for(d=new Array,h&&this.error(p.DiagnosticCode.An_implementation_cannot_be_declared_in_ambient_contexts,e.range());!e.skip(c.Token.CLOSEBRACE);){var _=this.parseStatement(e);if(!_)return null;d.push(_)}else h||this.error(p.DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration,e.range(e.pos));var y=l.Node.createFunctionDeclaration(i,a,o,u,d,t,r,e.range(n,e.pos));return e.skip(c.Token.SEMICOLON),y},t.prototype.parseClass=function(e,t,r){var n=r&&r.length?r[0].range.start:t&&t.length?t[0].range.start:e.tokenPos;if(e.skip(c.Token.IDENTIFIER)){var i,a=l.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.skip(c.Token.LESSTHAN)){if(!(i=this.parseTypeParameters(e)))return null}else i=[];var o=null;if(e.skip(c.Token.EXTENDS)&&!(o=this.parseType(e)))return null;var s=new Array;if(e.skip(c.Token.IMPLEMENTS))do{var u=this.parseType(e);if(!u)return null;s.push(u)}while(e.skip(c.Token.COMMA));if(e.skip(c.Token.OPENBRACE)){var h=new Array;if(!e.skip(c.Token.CLOSEBRACE)){var d=l.hasModifier(l.ModifierKind.DECLARE,t);do{var _=this.parseClassMember(e,d);if(!_)return null;h.push(_)}while(!e.skip(c.Token.CLOSEBRACE))}return l.Node.createClassDeclaration(a,i,o,s,h,t,r,e.range(n,e.pos))}this.error(p.DiagnosticCode._0_expected,e.range(),"{")}else this.error(p.DiagnosticCode.Identifier_expected,e.range());return null},t.prototype.parseClassMember=function(e,t){for(var r=e.pos,n=new Array;e.skip(c.Token.AT);){var i=this.parseDecorator(e);if(!i)break;n.push(i)}var a=null;e.skip(c.Token.PUBLIC)?a=l.addModifier(l.Node.createModifier(l.ModifierKind.PUBLIC,e.range()),a):e.skip(c.Token.PRIVATE)?a=l.addModifier(l.Node.createModifier(l.ModifierKind.PRIVATE,e.range()),a):e.skip(c.Token.PROTECTED)&&(a=l.addModifier(l.Node.createModifier(l.ModifierKind.PROTECTED,e.range()),a)),e.skip(c.Token.STATIC)?a=l.addModifier(l.Node.createModifier(l.ModifierKind.STATIC,e.range()),a):e.skip(c.Token.ABSTRACT)&&(a=l.addModifier(l.Node.createModifier(l.ModifierKind.ABSTRACT,e.range()),a)),e.skip(c.Token.READONLY)&&(a=l.addModifier(l.Node.createModifier(l.ModifierKind.READONLY,e.range()),a)),e.mark();var o=!1,s=!1;(o=e.skip(c.Token.GET))?e.peek(!0,!0)!=c.Token.IDENTIFIER||e.nextTokenOnNewLine?(e.reset(),o=!1):a=l.addModifier(l.Node.createModifier(l.ModifierKind.GET,e.range()),a):(s=e.skip(c.Token.SET))&&(e.peek(!0,!0)!=c.Token.IDENTIFIER||e.nextTokenOnNewLine?(e.reset(),s=!1):a=l.addModifier(l.Node.createModifier(l.ModifierKind.SET,e.range()),a));var u=e.skip(c.Token.CONSTRUCTOR);if(u||e.skip(c.Token.IDENTIFIER)){var h,d=u?l.Node.createConstructorExpression(e.range()):l.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.skip(c.Token.LESSTHAN)){if(u&&this.error(p.DiagnosticCode.Type_parameters_cannot_appear_on_a_constructor_declaration,e.range()),!(h=this.parseTypeParameters(e)))return null}else h=[];if(e.skip(c.Token.OPENPAREN)){var _=this.parseParameters(e);if(!_)return null;o&&_.length&&this.error(p.DiagnosticCode.A_get_accessor_cannot_have_parameters,d.range),s&&(1!=_.length&&this.error(p.DiagnosticCode.A_set_accessor_must_have_exactly_one_parameter,d.range),_.length&&_[0].initializer&&this.error(p.DiagnosticCode.A_set_accessor_parameter_cannot_have_an_initializer,d.range));var y=null;if(e.skip(c.Token.COLON)){if(d.kind==l.NodeKind.CONSTRUCTOR?this.error(p.DiagnosticCode.Type_annotation_cannot_appear_on_a_constructor_declaration,e.range()):s&&this.error(p.DiagnosticCode.A_set_accessor_cannot_have_a_return_type_annotation,e.range()),!(y=this.parseType(e,d.kind==l.NodeKind.CONSTRUCTOR||s)))return null}else s||d.kind==l.NodeKind.CONSTRUCTOR||this.error(p.DiagnosticCode.Type_expected,e.range());var m=null;if(e.skip(c.Token.OPENBRACE))for(t&&this.error(p.DiagnosticCode.An_implementation_cannot_be_declared_in_ambient_contexts,e.range()),m=new Array;!e.skip(c.Token.CLOSEBRACE);){var f=this.parseStatement(e);if(!f)return null;m.push(f)}else t||this.error(p.DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration,e.range());var E=l.Node.createMethodDeclaration(d,h,_,y,m,a,n,e.range(r,e.pos));return e.skip(c.Token.SEMICOLON),E}if(u)this.error(p.DiagnosticCode.Constructor_implementation_is_missing,d.range);else{if(!o&&!s){var g;(g=l.getModifier(l.ModifierKind.ABSTRACT,a))&&this.error(p.DiagnosticCode._0_modifier_cannot_be_used_here,g.range,"abstract"),(g=l.getModifier(l.ModifierKind.GET,a))&&this.error(p.DiagnosticCode._0_modifier_cannot_be_used_here,g.range,"get"),(g=l.getModifier(l.ModifierKind.SET,a))&&this.error(p.DiagnosticCode._0_modifier_cannot_be_used_here,g.range,"set");var T=null;if(e.skip(c.Token.COLON)){if(!(T=this.parseType(e)))return null}else this.error(p.DiagnosticCode.Type_expected,e.range());var A=null;if(e.skip(c.Token.EQUALS)&&!(A=this.parseExpression(e)))return null;var I=l.Node.createFieldDeclaration(d,T,A,a,n,e.range(r,e.pos));return e.skip(c.Token.SEMICOLON),I}this.error(p.DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration,d.range)}}else this.error(p.DiagnosticCode.Identifier_expected,e.range());return null},t.prototype.parseNamespace=function(e,t,r){var n=t&&t.length?t[0].range.start:e.tokenPos;if(e.skip(c.Token.IDENTIFIER)){var i=l.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.skip(c.Token.OPENBRACE)){for(var a=new Array;!e.skip(c.Token.CLOSEBRACE);){var o=this.parseTopLevelStatement(e,!0);if(!o)return null;a.push(o)}var s=l.Node.createNamespaceDeclaration(i,a,t,r,e.range(n,e.pos));return e.skip(c.Token.SEMICOLON),s}this.error(p.DiagnosticCode._0_expected,e.range(),"{")}else this.error(p.DiagnosticCode.Identifier_expected,e.range());return null},t.prototype.parseExport=function(e,t){var r=t&&t.length?t[0].range.start:e.tokenPos;if(e.skip(c.Token.OPENBRACE)){var n=new Array;if(!e.skip(c.Token.CLOSEBRACE)){do{var i=this.parseExportMember(e);if(!i)return null;n.push(i)}while(e.skip(c.Token.COMMA));if(!e.skip(c.Token.CLOSEBRACE))return this.error(p.DiagnosticCode._0_expected,e.range(),"}"),null}var a=null;if(e.skip(c.Token.FROM)){if(!e.skip(c.Token.STRINGLITERAL))return this.error(p.DiagnosticCode.String_literal_expected,e.range()),null;a=l.Node.createStringLiteralExpression(e.readString(),e.range())}var o=l.Node.createExportStatement(n,a,t,e.range(r,e.pos));return o.normalizedPath&&!this.seenlog.has(o.normalizedPath)&&(this.backlog.push(o.normalizedPath),this.seenlog.add(o.normalizedPath)),e.skip(c.Token.SEMICOLON),o}return this.error(p.DiagnosticCode._0_expected,e.range(),"{"),null},t.prototype.parseExportMember=function(e){if(e.skip(c.Token.IDENTIFIER)){var t=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),r=null;if(e.skip(c.Token.AS)){if(!e.skip(c.Token.IDENTIFIER))return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null;r=l.Node.createIdentifierExpression(e.readIdentifier(),e.range())}return l.Node.createExportMember(t,r,r?c.Range.join(t.range,r.range):t.range)}return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null},t.prototype.parseImport=function(e){var t=e.tokenPos,r=null,n=null,i=!1;if(e.skip(c.Token.OPENBRACE)){if(r=new Array,!e.skip(c.Token.CLOSEBRACE)){do{var a=this.parseImportDeclaration(e);if(!a)return null;r.push(a)}while(e.skip(c.Token.COMMA));if(!e.skip(c.Token.CLOSEBRACE))return this.error(p.DiagnosticCode._0_expected,e.range(),"}"),null}}else if(e.skip(c.Token.ASTERISK)){if(!e.skip(c.Token.AS))return this.error(p.DiagnosticCode._0_expected,e.range(),"as"),null;if(!e.skip(c.Token.IDENTIFIER))return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null;n=l.Node.createIdentifierExpression(e.readIdentifier(),e.range())}else i=!0;if(i||e.skip(c.Token.FROM)){if(e.skip(c.Token.STRINGLITERAL)){var o,s=l.Node.createStringLiteralExpression(e.readString(),e.range());return n?(assert(!r),o=l.Node.createImportStatementWithWildcard(n,s,e.range(t,e.pos))):o=l.Node.createImportStatement(r,s,e.range(t,e.pos)),this.seenlog.has(o.normalizedPath)||(this.backlog.push(o.normalizedPath),this.seenlog.add(o.normalizedPath)),e.skip(c.Token.SEMICOLON),o}this.error(p.DiagnosticCode.String_literal_expected,e.range())}else this.error(p.DiagnosticCode._0_expected,e.range(),"from");return null},t.prototype.parseImportDeclaration=function(e){if(e.skip(c.Token.IDENTIFIER)){var t=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),r=null;if(e.skip(c.Token.AS)){if(!e.skip(c.Token.IDENTIFIER))return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null;r=l.Node.createIdentifierExpression(e.readIdentifier(),e.range())}return l.Node.createImportDeclaration(t,r,r?c.Range.join(t.range,r.range):t.range)}return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null},t.prototype.parseExportImport=function(e,t){if(e.skip(c.Token.IDENTIFIER)){var r=l.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.skip(c.Token.EQUALS)){if(e.skip(c.Token.IDENTIFIER)){var n=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),i=l.Node.createExportImportStatement(n,r,c.Range.join(t,e.range()));return e.skip(c.Token.SEMICOLON),i}this.error(p.DiagnosticCode.Identifier_expected,e.range())}else this.error(p.DiagnosticCode._0_expected,e.range(),"=")}else this.error(p.DiagnosticCode.Identifier_expected,e.range());return null},t.prototype.parseStatement=function(e,t){switch(void 0===t&&(t=!1),e.mark(),e.next()){case c.Token.BREAK:return this.parseBreak(e);case c.Token.CONST:return this.parseVariable(e,[l.Node.createModifier(l.ModifierKind.CONST,e.range())],null);case c.Token.CONTINUE:return this.parseContinue(e);case c.Token.DO:return this.parseDoStatement(e);case c.Token.FOR:return this.parseForStatement(e);case c.Token.IF:return this.parseIfStatement(e);case c.Token.LET:return this.parseVariable(e,[l.Node.createModifier(l.ModifierKind.LET,e.range())],null);case c.Token.VAR:return this.parseVariable(e,null,null);case c.Token.OPENBRACE:return this.parseBlockStatement(e,t);case c.Token.RETURN:return t&&this.error(p.DiagnosticCode.A_return_statement_can_only_be_used_within_a_function_body,e.range()),this.parseReturn(e);case c.Token.SEMICOLON:return l.Node.createEmptyStatement(e.range(e.tokenPos));case c.Token.SWITCH:return this.parseSwitchStatement(e);case c.Token.THROW:return this.parseThrowStatement(e);case c.Token.TRY:return this.parseTryStatement(e);case c.Token.TYPE:return this.parseTypeDeclaration(e,null);case c.Token.WHILE:return this.parseWhileStatement(e);default:return e.reset(),this.parseExpressionStatement(e)}},t.prototype.parseBlockStatement=function(e,t){for(var r=e.tokenPos,n=new Array;!e.skip(c.Token.CLOSEBRACE);){var i=this.parseStatement(e,t);if(!i)return null;n.push(i)}var a=l.Node.createBlockStatement(n,e.range(r,e.pos));return e.skip(c.Token.SEMICOLON),a},t.prototype.parseBreak=function(e){var t=null;e.peek(!0)!=c.Token.IDENTIFIER||e.nextTokenOnNewLine||(e.next(!0),t=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()));var r=l.Node.createBreakStatement(t,e.range());return e.skip(c.Token.SEMICOLON),r},t.prototype.parseContinue=function(e){var t=null;e.peek(!0)!=c.Token.IDENTIFIER||e.nextTokenOnNewLine||(e.next(!0),t=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()));var r=l.Node.createContinueStatement(t,e.range());return e.skip(c.Token.SEMICOLON),r},t.prototype.parseDoStatement=function(e){var t=e.tokenPos,r=this.parseStatement(e);if(!r)return null;if(e.skip(c.Token.WHILE))if(e.skip(c.Token.OPENPAREN)){var n=this.parseExpression(e);if(!n)return null;if(e.skip(c.Token.CLOSEPAREN)){var i=l.Node.createDoStatement(r,n,e.range(t,e.pos));return e.skip(c.Token.SEMICOLON),i}this.error(p.DiagnosticCode._0_expected,e.range(),")")}else this.error(p.DiagnosticCode._0_expected,e.range(),"(");else this.error(p.DiagnosticCode._0_expected,e.range(),"while");return null},t.prototype.parseExpressionStatement=function(e){var t=this.parseExpression(e);if(!t)return null;var r=l.Node.createExpressionStatement(t);return e.skip(c.Token.SEMICOLON),r},t.prototype.parseForStatement=function(e){var t=e.tokenPos;if(e.skip(c.Token.OPENPAREN)){var r=null;if(e.skip(c.Token.LET)||e.skip(c.Token.CONST)||e.skip(c.Token.VAR))r=this.parseVariable(e,null,null);else if(!e.skip(c.Token.SEMICOLON)&&!(r=this.parseExpressionStatement(e)))return null;if(e.token==c.Token.SEMICOLON){var n=null;if(!e.skip(c.Token.SEMICOLON)&&!(n=this.parseExpressionStatement(e)))return null;if(e.token==c.Token.SEMICOLON){var i=null;if(!e.skip(c.Token.CLOSEPAREN)){if(!(i=this.parseExpression(e)))return null;if(!e.skip(c.Token.CLOSEPAREN))return this.error(p.DiagnosticCode._0_expected,e.range(),")"),null}var a=this.parseStatement(e);return a?l.Node.createForStatement(r,n?n.expression:null,i,a,e.range(t,e.pos)):null}this.error(p.DiagnosticCode._0_expected,e.range(),";")}else this.error(p.DiagnosticCode._0_expected,e.range(),";")}else this.error(p.DiagnosticCode._0_expected,e.range(),"(");return null},t.prototype.parseIfStatement=function(e){var t=e.tokenPos;if(e.skip(c.Token.OPENPAREN)){var r=this.parseExpression(e);if(!r)return null;if(e.skip(c.Token.CLOSEPAREN)){var n=this.parseStatement(e);if(!n)return null;var i=null;return e.skip(c.Token.ELSE)&&!(i=this.parseStatement(e))?null:l.Node.createIfStatement(r,n,i,e.range(t,e.pos))}this.error(p.DiagnosticCode._0_expected,e.range(),")")}else this.error(p.DiagnosticCode._0_expected,e.range(),"(");return null},t.prototype.parseSwitchStatement=function(e){var t=e.tokenPos;if(e.skip(c.Token.OPENPAREN)){var r=this.parseExpression(e);if(!r)return null;if(e.skip(c.Token.CLOSEPAREN)){if(e.skip(c.Token.OPENBRACE)){for(var n=new Array;!e.skip(c.Token.CLOSEBRACE);){var i=this.parseSwitchCase(e);if(!i)return null;n.push(i)}var a=l.Node.createSwitchStatement(r,n,e.range(t,e.pos));return e.skip(c.Token.SEMICOLON),a}this.error(p.DiagnosticCode._0_expected,e.range(),"{")}else this.error(p.DiagnosticCode._0_expected,e.range(),")")}else this.error(p.DiagnosticCode._0_expected,e.range(),"(");return null},t.prototype.parseSwitchCase=function(e){var t,r,n=e.tokenPos;if(e.skip(c.Token.CASE)){var i=this.parseExpression(e);if(!i)return null;if(e.skip(c.Token.COLON)){for(t=new Array;e.peek()!=c.Token.CASE&&e.nextToken!=c.Token.DEFAULT&&e.nextToken!=c.Token.CLOSEBRACE;){if(!(r=this.parseStatement(e)))return null;t.push(r)}return l.Node.createSwitchCase(i,t,e.range(n,e.pos))}this.error(p.DiagnosticCode._0_expected,e.range(),":")}else if(e.skip(c.Token.DEFAULT)){if(e.skip(c.Token.COLON)){for(t=new Array;e.peek()!=c.Token.CASE&&e.nextToken!=c.Token.DEFAULT&&e.nextToken!=c.Token.CLOSEBRACE;){if(!(r=this.parseStatement(e)))return null;t.push(r)}return l.Node.createSwitchCase(null,t,e.range(n,e.pos))}this.error(p.DiagnosticCode._0_expected,e.range(),":")}else this.error(p.DiagnosticCode._case_or_default_expected,e.range());return null},t.prototype.parseThrowStatement=function(e){var t=e.tokenPos,r=this.parseExpression(e);if(!r)return null;var n=l.Node.createThrowStatement(r,e.range(t,e.pos));return e.skip(c.Token.SEMICOLON),n},t.prototype.parseTryStatement=function(e){var t,r=e.tokenPos;if(e.skip(c.Token.OPENBRACE)){for(var n=new Array;!e.skip(c.Token.CLOSEBRACE);){if(!(t=this.parseStatement(e)))return null;n.push(t)}var i=null,a=null,o=null;if(e.skip(c.Token.CATCH)){if(!e.skip(c.Token.OPENPAREN))return this.error(p.DiagnosticCode._0_expected,e.range(),"("),null;if(!e.skip(c.Token.IDENTIFIER))return this.error(p.DiagnosticCode.Identifier_expected,e.range()),null;if(i=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),!e.skip(c.Token.CLOSEPAREN))return this.error(p.DiagnosticCode._0_expected,e.range(),")"),null;if(!e.skip(c.Token.OPENBRACE))return this.error(p.DiagnosticCode._0_expected,e.range(),"{"),null;for(a=[];!e.skip(c.Token.CLOSEBRACE);){if(!(t=this.parseStatement(e)))return null;a.push(t)}}if(e.skip(c.Token.FINALLY)){if(!e.skip(c.Token.OPENBRACE))return this.error(p.DiagnosticCode._0_expected,e.range(),"{"),null;for(o=[];!e.skip(c.Token.CLOSEBRACE);){if(!(t=this.parseStatement(e)))return null;o.push(t)}}if(!a&&!o)return this.error(p.DiagnosticCode._0_expected,e.range(),"catch"),null;var s=l.Node.createTryStatement(n,i,a,o,e.range(r,e.pos));return e.skip(c.Token.SEMICOLON),s}return this.error(p.DiagnosticCode._0_expected,e.range(),"{"),null},t.prototype.parseTypeDeclaration=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r=null);var n=r&&r.length?r[0].range.start:t&&t.length?t[0].range.start:e.tokenPos;if(e.skip(c.Token.IDENTIFIER)){var i=l.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.skip(c.Token.EQUALS)){var a=this.parseType(e);if(!a)return null;var o=l.Node.createTypeDeclaration(i,a,t,r,e.range(n,e.pos));return e.skip(c.Token.SEMICOLON),o}this.error(p.DiagnosticCode._0_expected,e.range(),"=")}else this.error(p.DiagnosticCode.Identifier_expected,e.range());return null},t.prototype.parseWhileStatement=function(e){var t=e.tokenPos;if(e.skip(c.Token.OPENPAREN)){var r=this.parseExpression(e);if(!r)return null;if(e.skip(c.Token.CLOSEPAREN)){var n=this.parseStatement(e);if(!n)return null;var i=l.Node.createWhileStatement(r,n,e.range(t,e.pos));return e.skip(c.Token.SEMICOLON),i}this.error(p.DiagnosticCode._0_expected,e.range(),")")}else this.error(p.DiagnosticCode._0_expected,e.range(),"(");return null},t.prototype.parseExpressionStart=function(e){var t=e.next(!0),r=e.tokenPos,i=null;if(t==c.Token.NULL)return l.Node.createNullExpression(e.range());if(t==c.Token.TRUE)return l.Node.createTrueExpression(e.range());if(t==c.Token.FALSE)return l.Node.createFalseExpression(e.range());var a=n(t);if(-1!=a){var o;return t==c.Token.NEW?(o=this.parseExpression(e,18))?o.kind==l.NodeKind.CALL?l.Node.createNewExpression(o.expression,o.typeArguments,o.arguments,e.range(r,e.pos)):(this.error(p.DiagnosticCode.Operation_not_supported,e.range()),null):null:(o=this.parseExpression(e,a))?(t!=c.Token.PLUS_PLUS&&t!=c.Token.MINUS_MINUS||o.kind!=l.NodeKind.IDENTIFIER&&o.kind!=l.NodeKind.ELEMENTACCESS&&o.kind!=l.NodeKind.PROPERTYACCESS&&this.error(p.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access,o.range),l.Node.createUnaryPrefixExpression(t,o,e.range(r,e.pos))):null}switch(t){case c.Token.OPENPAREN:return i=this.parseExpression(e),i?e.skip(c.Token.CLOSEPAREN)?l.Node.createParenthesizedExpression(i,e.range(r,e.pos)):(this.error(p.DiagnosticCode._0_expected,e.range(),")"),null):null;case c.Token.OPENBRACKET:var s=new Array;if(!e.skip(c.Token.CLOSEBRACKET)){do{if(e.peek()==c.Token.COMMA)i=null;else if(!(i=this.parseExpression(e,1)))return null;if(s.push(i),e.peek()==c.Token.CLOSEBRACKET)break}while(e.skip(c.Token.COMMA));if(!e.skip(c.Token.CLOSEBRACKET))return this.error(p.DiagnosticCode._0_expected,e.range(),"]"),null}return l.Node.createArrayLiteralExpression(s,e.range(r,e.pos));case c.Token.LESSTHAN:var u=this.parseType(e);return u?e.skip(c.Token.GREATERTHAN)?(i=this.parseExpression(e,18),i?l.Node.createAssertionExpression(0,i,u,e.range(r,e.pos)):null):(this.error(p.DiagnosticCode._0_expected,e.range(),">"),null):null;case c.Token.IDENTIFIER:return l.Node.createIdentifierExpression(e.readIdentifier(),e.range(r,e.pos));case c.Token.THIS:return l.Node.createThisExpression(e.range(r,e.pos));case c.Token.CONSTRUCTOR:return l.Node.createConstructorExpression(e.range(r,e.pos));case c.Token.SUPER:return l.Node.createSuperExpression(e.range(r,e.pos));case c.Token.STRINGLITERAL:return l.Node.createStringLiteralExpression(e.readString(),e.range(r,e.pos));case c.Token.INTEGERLITERAL:return l.Node.createIntegerLiteralExpression(e.readInteger(),e.range(r,e.pos));case c.Token.FLOATLITERAL:return l.Node.createFloatLiteralExpression(e.readFloat(),e.range(r,e.pos));case c.Token.SLASH:var h=e.readRegexpPattern();return e.skip(c.Token.SLASH)?l.Node.createRegexpLiteralExpression(h,e.readRegexpFlags(),e.range(r,e.pos)):(this.error(p.DiagnosticCode._0_expected,e.range(),"/"),null);default:return this.error(p.DiagnosticCode.Expression_expected,e.range()),null}},t.prototype.tryParseTypeArgumentsBeforeArguments=function(e){if(e.mark(),!e.skip(c.Token.LESSTHAN))return null;var t=new Array;do{var r=this.parseType(e,!0,!0);if(!r)return e.reset(),null;t.push(r)}while(e.skip(c.Token.COMMA));return e.skip(c.Token.GREATERTHAN)&&e.skip(c.Token.OPENPAREN)?t:(e.reset(),null)},t.prototype.parseArguments=function(e){var t=new Array;if(!e.skip(c.Token.CLOSEPAREN)){do{var r=this.parseExpression(e,1);if(!r)return null;t.push(r)}while(e.skip(c.Token.COMMA));if(!e.skip(c.Token.CLOSEPAREN))return this.error(p.DiagnosticCode._0_expected,e.range(),")"),null}return t},t.prototype.parseExpression=function(e,t){void 0===t&&(t=0);var r=this.parseExpressionStart(e);if(!r)return null;var n=r.range.start,o=this.tryParseTypeArgumentsBeforeArguments(e);if(o||e.skip(c.Token.OPENPAREN)){var s=this.parseArguments(e);if(!s)return null;r=l.Node.createCallExpression(r,o,s,e.range(n,e.pos))}for(var u,h,d=null;(h=i(u=e.peek()))>=t;)switch(e.next(),u){case c.Token.AS:var _=this.parseType(e);if(!_)return null;r=l.Node.createAssertionExpression(1,r,_,e.range(n,e.pos));break;case c.Token.OPENBRACKET:if(!(d=this.parseExpression(e)))return null;if(!e.skip(c.Token.CLOSEBRACKET))return this.error(p.DiagnosticCode._0_expected,e.range(),"]"),null;r=l.Node.createElementAccessExpression(r,d,e.range(n,e.pos));break;case c.Token.PLUS_PLUS:case c.Token.MINUS_MINUS:r.kind!=l.NodeKind.IDENTIFIER&&r.kind!=l.NodeKind.ELEMENTACCESS&&r.kind!=l.NodeKind.PROPERTYACCESS&&this.error(p.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access,r.range),r=l.Node.createUnaryPostfixExpression(u,r,e.range(n,e.pos));break;case c.Token.QUESTION:var y=this.parseExpression(e);if(!y)return null;if(!e.skip(c.Token.COLON))return this.error(p.DiagnosticCode._0_expected,e.range(),":"),null;var m=this.parseExpression(e);if(!m)return null;r=l.Node.createTernaryExpression(r,y,m,e.range(n,e.pos));break;case c.Token.COMMA:var f=[r];do{if(!(r=this.parseExpression(e,1)))return null;f.push(r)}while(e.skip(c.Token.COMMA));r=l.Node.createCommaExpression(f,e.range(n,e.pos));break;default:if(!(d=this.parseExpression(e,a(u)?h:h+1)))return null;if(u==c.Token.DOT)if(d.kind==l.NodeKind.IDENTIFIER)r=l.Node.createPropertyAccessExpression(r,d,e.range(n,e.pos));else{if(d.kind!=l.NodeKind.CALL)return this.error(p.DiagnosticCode.Identifier_expected,d.range),null;var E=d;if(E.expression.kind!=l.NodeKind.IDENTIFIER)return this.error(p.DiagnosticCode.Identifier_expected,E.expression.range),null;E.expression=l.Node.createPropertyAccessExpression(r,E.expression,e.range(n,e.pos)),r=E}else r=l.Node.createBinaryExpression(u,r,d,e.range(n,e.pos))}return r},t}(p.DiagnosticEmitter);t.Parser=h;!function(e){e[e.COMMA=0]="COMMA",e[e.SPREAD=1]="SPREAD",e[e.YIELD=2]="YIELD",e[e.ASSIGNMENT=3]="ASSIGNMENT",e[e.CONDITIONAL=4]="CONDITIONAL",e[e.LOGICAL_OR=5]="LOGICAL_OR",e[e.LOGICAL_AND=6]="LOGICAL_AND",e[e.BITWISE_OR=7]="BITWISE_OR",e[e.BITWISE_XOR=8]="BITWISE_XOR",e[e.BITWISE_AND=9]="BITWISE_AND",e[e.EQUALITY=10]="EQUALITY",e[e.RELATIONAL=11]="RELATIONAL",e[e.SHIFT=12]="SHIFT",e[e.ADDITIVE=13]="ADDITIVE",e[e.MULTIPLICATIVE=14]="MULTIPLICATIVE",e[e.EXPONENTIATED=15]="EXPONENTIATED",e[e.UNARY_PREFIX=16]="UNARY_PREFIX",e[e.UNARY_POSTFIX=17]="UNARY_POSTFIX",e[e.CALL=18]="CALL",e[e.MEMBERACCESS=19]="MEMBERACCESS",e[e.GROUPING=20]="GROUPING",e[e.INVALID=-1]="INVALID"}(t.Precedence||(t.Precedence={}))}])});
|
||
//# sourceMappingURL=assemblyscript.js.map
|