mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
2 lines
393 KiB
JavaScript
2 lines
393 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){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=28)}([function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=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])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),a=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}}}},s=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),s=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)s.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 s};Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),c=r(7),p=r(4),l=r(3);t.PATH_DELIMITER="/",t.PARENT_SUBST="..",t.GETTER_PREFIX="get:",t.SETTER_PREFIX="set:",t.INSTANCE_DELIMITER="#",t.STATIC_DELIMITER=".",t.INNER_DELIMITER="~",t.LIBRARY_SUBST="~lib",t.LIBRARY_PREFIX=t.LIBRARY_SUBST+t.PATH_DELIMITER;var u,h=function(){return function(){}}(),d=function(){return function(){}}(),_=function(){return function(){}}();function y(e){switch(e){case"[]":return u.INDEXED_GET;case"[]=":return u.INDEXED_SET;case"{}":return u.UNCHECKED_INDEXED_GET;case"{}=":return u.UNCHECKED_INDEXED_SET;case"+":return u.ADD;case"-":return u.SUB;case"*":return u.MUL;case"/":return u.DIV;case"%":return u.REM;case"**":return u.POW;case"&":return u.AND;case"|":return u.OR;case"^":return u.XOR;case"==":return u.EQ;case"!=":return u.NE;case">":return u.GT;case">=":return u.GE;case"<":return u.LT;case"<=":return u.LE}return u.INVALID}!function(e){e[e.INVALID=0]="INVALID",e[e.INDEXED_GET=1]="INDEXED_GET",e[e.INDEXED_SET=2]="INDEXED_SET",e[e.UNCHECKED_INDEXED_GET=3]="UNCHECKED_INDEXED_GET",e[e.UNCHECKED_INDEXED_SET=4]="UNCHECKED_INDEXED_SET",e[e.ADD=5]="ADD",e[e.SUB=6]="SUB",e[e.MUL=7]="MUL",e[e.DIV=8]="DIV",e[e.REM=9]="REM",e[e.POW=10]="POW",e[e.AND=11]="AND",e[e.OR=12]="OR",e[e.XOR=13]="XOR",e[e.EQ=14]="EQ",e[e.NE=15]="NE",e[e.GT=16]="GT",e[e.GE=17]="GE",e[e.LT=18]="LT",e[e.LE=19]="LE"}(u=t.OperatorKind||(t.OperatorKind={}));var g,m,T,E=new Map,f=function(e){function r(t){void 0===t&&(t=null);var r=e.call(this,t)||this;return r.diagnosticsOffset=0,r.elementsLookup=new Map,r.instancesLookup=new Map,r.typesLookup=E,r.typeAliases=new Map,r.fileLevelExports=new Map,r.moduleLevelExports=new Map,r.arrayPrototype=null,r.arrayBufferViewPrototype=null,r.stringInstance=null,r.resolvedThisExpression=null,r.resolvedElementExpression=null,r.sources=[],r}return i(r,e),r.prototype.getSource=function(e){for(var t=this.sources,r=0,n=t.length;r<n;++r){var i=t[r];if(i.normalizedPath==e)return i}return null},r.prototype.lookupSourceByPath=function(e){return this.getSource(e+".ts")||this.getSource(e+"/index.ts")||this.getSource(t.LIBRARY_PREFIX+e+".ts")||this.getSource(t.LIBRARY_PREFIX+e+"/index.ts")},r.prototype.initialize=function(e){this.options=e,this.typesLookup=new Map([["i8",c.Type.i8],["i16",c.Type.i16],["i32",c.Type.i32],["i64",c.Type.i64],["isize",e.isizeType],["u8",c.Type.u8],["u16",c.Type.u16],["u32",c.Type.u32],["u64",c.Type.u64],["usize",e.usizeType],["bool",c.Type.bool],["f32",c.Type.f32],["f64",c.Type.f64],["void",c.Type.void],["number",c.Type.f64],["boolean",c.Type.bool]]);for(var t=new Map,r=new Array,n=new Array,i=new Array,l=0,u=this.sources.length;l<u;++l)for(var h=this.sources[l].statements,d=0,_=h.length;d<_;++d){var y=h[d];switch(y.kind){case p.NodeKind.CLASSDECLARATION:this.initializeClass(y,n,i);break;case p.NodeKind.ENUMDECLARATION:this.initializeEnum(y);break;case p.NodeKind.EXPORT:this.initializeExports(y,t);break;case p.NodeKind.FUNCTIONDECLARATION:this.initializeFunction(y);break;case p.NodeKind.IMPORT:this.initializeImports(y,t,r);break;case p.NodeKind.INTERFACEDECLARATION:this.initializeInterface(y);break;case p.NodeKind.NAMESPACEDECLARATION:this.initializeNamespace(y,n,i);break;case p.NodeKind.TYPEDECLARATION:this.initializeTypeAlias(y);break;case p.NodeKind.VARIABLE:this.initializeVariables(y)}}for(l=0;l<r.length;){var m=r[l];(N=this.tryResolveImport(m.referencedName,t))?(this.elementsLookup.set(m.internalName,N),r.splice(l,1)):(N=this.tryResolveImport(m.referencedNameAlt,t))?(this.elementsLookup.set(m.internalName,N),r.splice(l,1)):(this.error(o.DiagnosticCode.Module_0_has_no_exported_member_1,m.declaration.range,m.declaration.parent.path.value,m.declaration.externalName.text),++l)}try{for(var T=a(t),E=T.next();!E.done;E=T.next()){var f=s(E.value,2),I=f[0],v=f[1],A=v,N=void 0;do{if(!A.isReExport){(N=this.elementsLookup.get(A.referencedName))||(N=this.elementsLookup.get(A.member.name.text))?this.setExportAndCheckLibrary(I,N,A.member.externalName):this.error(o.DiagnosticCode.Cannot_find_name_0,v.member.range,v.member.name.text);break}if(N=this.fileLevelExports.get(A.referencedName)){this.setExportAndCheckLibrary(I,N,A.member.externalName);break}(A=t.get(A.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(A)}}catch(e){w={error:e}}finally{try{E&&!E.done&&(M=T.return)&&M.call(T)}finally{if(w)throw w.error}}for(l=0,u=n.length;l<u;++l){var C=n[l],S=C.declaration,O=assert(S.extendsType),L=this.resolveIdentifier(O.name,null);if(L)if(L.kind==g.CLASS_PROTOTYPE){var b=L;C.basePrototype=b}else this.error(o.DiagnosticCode.A_class_may_only_extend_another_class,O.range)}var k=e.globalAliases;if(k)try{for(var x=a(k),R=x.next();!R.done;R=x.next()){var B=s(R.value,2),U=B[0],D=B[1];(N=this.elementsLookup.get(D))&&this.elementsLookup.set(U,N)}}catch(e){G={error:e}}finally{try{R&&!R.done&&(K=x.return)&&K.call(x)}finally{if(G)throw G.error}}var F=this.elementsLookup.get("Array");F&&(assert(F.kind==g.CLASS_PROTOTYPE),this.arrayPrototype=F);var P=this.elementsLookup.get("ArrayBufferView");P&&(assert(P.kind==g.INTERFACE_PROTOTYPE),this.arrayBufferViewPrototype=P);var w,M,G,K,z=this.elementsLookup.get("String");if(z){assert(z.kind==g.CLASS_PROTOTYPE);var V=z.resolve(null);if(V)if(this.typesLookup.has("string")){var H=z.declaration;this.error(o.DiagnosticCode.Duplicate_identifier_0,H.name.range,H.programLevelInternalName)}else this.stringInstance=V,this.typesLookup.set("string",V.type)}},r.prototype.tryResolveImport=function(e,t){for(var r,n=this.fileLevelExports;;){if(r=n.get(e))return r;var i=t.get(e);if(!i)return null;if(!i.isReExport)return this.elementsLookup.get(i.referencedName);e=i.referencedName}},r.prototype.filterDecorators=function(e,t){for(var r=T.NONE,n=0,i=e.length;n<i;++n){var a=e[n];if(a.name.kind==p.NodeKind.IDENTIFIER){var s=a.name.text,c=I(p.stringToDecoratorKind(s));c&&(t&c?r&c?this.error(o.DiagnosticCode.Duplicate_decorator,a.range,s):r|=c:this.error(o.DiagnosticCode.Decorator_0_is_not_valid_here,a.range,s))}}return r},r.prototype.checkGlobalOptions=function(e,t){var r=t.parent;if(e.hasDecorator(T.GLOBAL)||t.range.source.is(m.BUILTIN)||t.range.source.isLibrary&&e.is(m.EXPORT)&&(assert(r).kind==p.NodeKind.SOURCE||r.kind==p.NodeKind.VARIABLE&&assert(r.parent).kind==p.NodeKind.SOURCE)){var n=t.programLevelInternalName;this.elementsLookup.has(n)?this.error(o.DiagnosticCode.Duplicate_identifier_0,t.name.range,e.internalName):(this.elementsLookup.set(n,e),e.is(m.BUILTIN)&&(e.internalName=n))}},r.prototype.initializeClass=function(e,t,r,n){void 0===n&&(n=null);var i=e.fileLevelInternalName;if(this.elementsLookup.has(i))this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,i);else{var a=e.decorators,s=e.name.text,c=new F(this,s,i,e,a?this.filterDecorators(a,T.GLOBAL|T.SEALED|T.UNMANAGED):T.NONE);c.parent=n,this.elementsLookup.set(i,c);var l=e.implementsTypes;if(l){var u=l.length;c.hasDecorator(T.UNMANAGED)?u&&this.error(o.DiagnosticCode.Unmanaged_classes_cannot_implement_interfaces,p.Range.join(e.name.range,l[u-1].range)):u&&r.push(c)}if(e.extendsType&&t.push(c),n){if(n.members){if(n.members.has(s))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,i)}else n.members=new Map;n.members.set(s,c),n.is(m.MODULE_EXPORT)&&c.is(m.EXPORT)&&c.set(m.MODULE_EXPORT)}else if(c.is(m.EXPORT)){if(this.fileLevelExports.has(i))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,i);if(this.fileLevelExports.set(i,c),c.is(m.EXPORT)&&e.range.source.isEntry){if(this.moduleLevelExports.has(i))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,i);c.set(m.MODULE_EXPORT),this.moduleLevelExports.set(i,c)}}for(var h=e.members,d=0,_=h.length;d<_;++d){var y=h[d];switch(y.kind){case p.NodeKind.FIELDDECLARATION:this.initializeField(y,c);break;case p.NodeKind.METHODDECLARATION:y.isAny(m.GET|m.SET)?this.initializeAccessor(y,c):this.initializeMethod(y,c);break;default:throw new Error("class member expected")}}this.checkGlobalOptions(c,e)}},r.prototype.initializeField=function(e,t){var r=e.name.text,n=e.fileLevelInternalName,i=e.decorators;if(e.is(m.STATIC)){if(this.elementsLookup.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 a=new O(this,r,n,c.Type.void,e,i?this.filterDecorators(i,T.NONE):T.NONE);a.parent=t,t.members.set(r,a),this.elementsLookup.set(n,a),t.is(m.MODULE_EXPORT)&&a.set(m.MODULE_EXPORT)}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 s=new B(t,r,n,e);i&&this.filterDecorators(i,T.NONE),t.instanceMembers.set(r,s)}},r.prototype.initializeMethod=function(e,t){var r=e.name.text,n=e.fileLevelInternalName,i=null,a=e.decorators,s=T.NONE;if(a&&(s=this.filterDecorators(a,T.OPERATOR|T.INLINE)),e.is(m.STATIC)){if(assert(e.name.kind!=p.NodeKind.CONSTRUCTOR),this.elementsLookup.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 k(this,r,n,e,t,s),t.members.set(r,i),this.elementsLookup.set(n,i),t.is(m.MODULE_EXPORT)&&i.set(m.MODULE_EXPORT)}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 k(this,r,n,e,t,s),e.name.kind==p.NodeKind.CONSTRUCTOR?t.constructorPrototype?this.error(o.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed,e.name.range):(i.set(m.CONSTRUCTOR),t.constructorPrototype=i):t.instanceMembers.set(r,i),t.is(m.MODULE_EXPORT)&&i.set(m.MODULE_EXPORT)}this.checkOperatorOverloads(e.decorators,i,t)},r.prototype.checkOperatorOverloads=function(e,t,r){if(e)for(var n=0,i=e.length;n<i;++n){var a=e[n];if(a.decoratorKind==p.DecoratorKind.OPERATOR){var s=a.arguments&&a.arguments.length||0;if(1==s){var c=a.arguments[0];if(c.kind==p.NodeKind.LITERAL&&c.literalKind==p.LiteralKind.STRING){var l=y(c.value);if(l==u.INVALID)this.error(o.DiagnosticCode.Operation_not_supported,c.range);else{var h=r.overloadPrototypes;h.has(l)?this.error(o.DiagnosticCode.Duplicate_function_implementation,c.range):(t.operatorKind=l,h.set(l,t))}}else this.error(o.DiagnosticCode.String_literal_expected,c.range)}else this.error(o.DiagnosticCode.Expected_0_arguments_but_got_1,a.range,"1",s.toString(0))}}},r.prototype.initializeAccessor=function(e,r){var n=e.name.text,i=e.fileLevelInternalName,a=this.elementsLookup.get(i),s=e.is(m.GET),c=!1;if(a){if(a.kind!=g.PROPERTY||null!=(s?a.getterPrototype:a.setterPrototype))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,i)}else a=new D(this,n,i,r),c=!0;var p=e.decorators,l=T.NONE;p&&(l=this.filterDecorators(p,T.INLINE));var u=(s?t.GETTER_PREFIX:t.SETTER_PREFIX)+n;if(e.is(m.STATIC)){var h=r.internalName+t.STATIC_DELIMITER+u;if(this.elementsLookup.has(h))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,h);var d=new k(this,u,h,e,null,l);if(s?a.getterPrototype=d:a.setterPrototype=d,c){if(r.members){if(r.members.has(n))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,h)}else r.members=new Map;r.members.set(n,a)}else assert(r.members&&r.members.has(n));this.elementsLookup.set(i,a),r.is(m.MODULE_EXPORT)&&a.set(m.MODULE_EXPORT)}else{var _=r.internalName+t.INSTANCE_DELIMITER+u;if(r.instanceMembers){if(r.instanceMembers.has(u))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,i)}else r.instanceMembers=new Map;var y=new k(this,u,_,e,r,l);s?a.getterPrototype=y:a.setterPrototype=y,r.instanceMembers.set(u,a),this.elementsLookup.set(i,a),r.is(m.MODULE_EXPORT)&&(a.set(m.MODULE_EXPORT),y.set(m.MODULE_EXPORT))}},r.prototype.initializeEnum=function(e,t){void 0===t&&(t=null);var r=e.fileLevelInternalName;if(this.elementsLookup.has(r))this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);else{var n=e.name.text,i=new N(this,n,r,e);if(i.parent=t,this.elementsLookup.set(r,i),t){if(t.members){if(t.members.has(n))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r)}else t.members=new Map;t.members.set(n,i),t.is(m.MODULE_EXPORT)&&i.is(m.EXPORT)&&i.set(m.MODULE_EXPORT)}else if(i.is(m.EXPORT)){if(this.fileLevelExports.has(r))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,r);if(this.fileLevelExports.set(r,i),e.range.source.isEntry){if(this.moduleLevelExports.has(r))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,r);i.set(m.MODULE_EXPORT),this.moduleLevelExports.set(r,i)}}for(var a=e.values,s=0,c=a.length;s<c;++s)this.initializeEnumValue(a[s],i);this.checkGlobalOptions(i,e)}},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 C(t,this,r,n,e);t.members.set(r,i),t.is(m.MODULE_EXPORT)&&i.set(m.MODULE_EXPORT)},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.fileLevelExports.set(e,t),r.range.source.isLibrary&&(this.elementsLookup.has(r.text)?this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,r.range,r.text):(t.internalName=r.text,this.elementsLookup.set(r.text,t)))},r.prototype.initializeExport=function(e,r,n){var i,a,s,c=e.range.source.internalPath+t.PATH_DELIMITER+e.externalName.text;if(this.fileLevelExports.has(c))this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.externalName.range,c);else if(null==r){if(i=e.range.source.internalPath+t.PATH_DELIMITER+e.name.text,a=this.elementsLookup.get(i))return void this.setExportAndCheckLibrary(c,a,e.externalName);if(n.has(c))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.externalName.range,c);(s=new h).isReExport=!1,s.referencedName=i,s.member=e,n.set(c,s)}else{if(i=r+t.PATH_DELIMITER+e.name.text,a=this.elementsLookup.get(i))return void this.setExportAndCheckLibrary(c,a,e.externalName);for(var p=new Set;s=n.get(i);){if(!s.isReExport){if(a=this.elementsLookup.get(s.referencedName))return void this.setExportAndCheckLibrary(c,a,e.externalName);break}if(a=this.fileLevelExports.get(s.referencedName))return void this.setExportAndCheckLibrary(c,a,e.externalName);if(i=s.referencedName,p.has(s))break;p.add(s)}if(n.has(c))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.externalName.range,c);(s=new h).isReExport=!0,s.referencedName=i,s.member=e,n.set(c,s)}},r.prototype.initializeFunction=function(e,t){void 0===t&&(t=null);var r=e.fileLevelInternalName;if(this.elementsLookup.has(r))this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);else{var n=e.name.text,i=e.decorators,a=new k(this,n,r,e,null,i?this.filterDecorators(i,T.GLOBAL|T.INLINE):T.NONE);if(a.parent=t,this.elementsLookup.set(r,a),t){if(t.members){if(t.members.has(n))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r)}else t.members=new Map;t.members.set(n,a),t.is(m.MODULE_EXPORT)&&a.is(m.EXPORT)&&(a.parent=t,a.set(m.MODULE_EXPORT))}else if(a.is(m.EXPORT)){if(this.fileLevelExports.has(r))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,r);if(this.fileLevelExports.set(r,a),e.range.source.isEntry){if(this.moduleLevelExports.has(r))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);a.set(m.MODULE_EXPORT),this.moduleLevelExports.set(r,a)}}this.checkGlobalOptions(a,e)}},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.namespaceName.text,p=e.range.source.internalPath+t.PATH_DELIMITER+c;if(this.elementsLookup.has(p))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.namespaceName.range,p);this.error(o.DiagnosticCode.Operation_not_supported,e.range)}},r.prototype.initializeImport=function(e,r,n,i){var a=e.fileLevelInternalName;if(this.elementsLookup.has(a))this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,a);else{var s,c=r+t.PATH_DELIMITER+e.externalName.text;if(s=this.fileLevelExports.get(c))this.elementsLookup.set(a,s);else{var p=t.PATH_DELIMITER+"index",l=new d;l.internalName=a,r.endsWith(p)?(l.referencedName=c,l.referencedNameAlt=r.substring(0,r.length-p.length+1)+e.externalName.text):(l.referencedName=c,l.referencedNameAlt=r+p+t.PATH_DELIMITER+e.externalName.text),l.declaration=e,i.push(l)}}},r.prototype.initializeInterface=function(e,t){void 0===t&&(t=null);var r=e.fileLevelInternalName;if(this.elementsLookup.has(r))this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);else{var n=e.decorators,i=new w(this,e.name.text,r,e,n?this.filterDecorators(n,T.GLOBAL):T.NONE);if(i.parent=t,this.elementsLookup.set(r,i),t){if(t.members){if(t.members.has(i.internalName))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r)}else t.members=new Map;t.members.set(i.internalName,i),t.is(m.MODULE_EXPORT)&&i.is(m.EXPORT)&&i.set(m.MODULE_EXPORT)}else if(i.is(m.EXPORT)){if(this.fileLevelExports.has(r))return void this.error(o.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,r);if(this.fileLevelExports.set(r,i),e.range.source.isEntry){if(this.moduleLevelExports.has(r))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);i.set(m.MODULE_EXPORT),this.moduleLevelExports.set(r,i)}}for(var a=e.members,s=0,c=a.length;s<c;++s){var l=a[s];switch(l.kind){case p.NodeKind.FIELDDECLARATION:this.initializeField(l,i);break;case p.NodeKind.METHODDECLARATION:l.isAny(m.GET|m.SET)?this.initializeAccessor(l,i):this.initializeMethod(l,i);break;default:throw new Error("interface member expected")}}this.checkGlobalOptions(i,e)}},r.prototype.initializeNamespace=function(e,t,r,n){void 0===n&&(n=null);var i=e.fileLevelInternalName,a=e.name.text,s=this.elementsLookup.get(i);if(s||((s=new A(this,a,i,e)).parent=n,this.elementsLookup.set(i,s),this.checkGlobalOptions(s,e)),n){if(n.members){if(n.members.has(a))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,i)}else n.members=new Map;n.members.set(a,s),n.is(m.MODULE_EXPORT)&&s.is(m.EXPORT)&&s.set(m.MODULE_EXPORT)}else if(s.is(m.EXPORT)){var c=this.fileLevelExports.get(i);if(c?(c.is(m.EXPORT)||this.error(o.DiagnosticCode.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local,e.name.range,s.internalName),s=c):this.fileLevelExports.set(i,s),e.range.source.isEntry){if(this.moduleLevelExports.has(i))return void this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,i);s.set(m.MODULE_EXPORT),this.moduleLevelExports.set(i,s)}}for(var l=e.members,u=0,h=l.length;u<h;++u)switch(l[u].kind){case p.NodeKind.CLASSDECLARATION:this.initializeClass(l[u],t,r,s);break;case p.NodeKind.ENUMDECLARATION:this.initializeEnum(l[u],s);break;case p.NodeKind.FUNCTIONDECLARATION:this.initializeFunction(l[u],s);break;case p.NodeKind.INTERFACEDECLARATION:this.initializeInterface(l[u],s);break;case p.NodeKind.NAMESPACEDECLARATION:this.initializeNamespace(l[u],t,r,s);break;case p.NodeKind.TYPEDECLARATION:this.error(o.DiagnosticCode.Operation_not_supported,l[u].range);break;case p.NodeKind.VARIABLE:this.initializeVariables(l[u],s);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.typesLookup.has(r)||this.typeAliases.has(r))this.error(o.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);else{var n=new _;n.typeParameters=e.typeParameters,n.type=e.type,this.typeAliases.set(r,n)}},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],s=a.decorators,p=a.fileLevelInternalName;if(this.elementsLookup.has(p))this.error(o.DiagnosticCode.Duplicate_identifier_0,a.name.range,p);else{var l=a.name.text,u=new O(this,l,p,c.Type.void,a,s?this.filterDecorators(s,T.GLOBAL):T.NONE);if(u.parent=t,this.elementsLookup.set(p,u),t){if(t.members){if(t.members.has(l)){this.error(o.DiagnosticCode.Duplicate_identifier_0,a.name.range,p);continue}}else t.members=new Map;t.members.set(l,u),t.is(m.MODULE_EXPORT)&&u.is(m.EXPORT)&&u.set(m.MODULE_EXPORT)}else if(u.is(m.EXPORT)&&(this.fileLevelExports.has(p)?this.error(o.DiagnosticCode.Duplicate_identifier_0,a.name.range,p):this.fileLevelExports.set(p,u),a.range.source.isEntry)){if(this.moduleLevelExports.has(p)){this.error(o.DiagnosticCode.Duplicate_identifier_0,a.name.range,p);continue}u.set(m.MODULE_EXPORT),this.moduleLevelExports.set(p,u)}this.checkGlobalOptions(u,a)}}},r.prototype.resolveSignature=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r=!0);var n=e.explicitThisType,i=null;if(n&&!(i=this.resolveType(n,t,r)))return null;for(var a=e.parameterTypes,s=a.length,o=new Array(s),l=new Array(s),u=0,h=!1,d=0;d<s;++d){var _=a[d];switch(_.parameterKind){case p.ParameterKind.DEFAULT:u=d+1;break;case p.ParameterKind.REST:assert(d==s),h=!0}var y=this.resolveType(assert(_.type),t,r);if(!y)return null;o[d]=y,l[d]=_.name.text}var g,m=e.returnType;if(m){if(!(g=this.resolveType(m,t,r)))return null}else g=c.Type.void;var T=new c.Signature(o,g,i);return T.parameterNames=l,T.requiredParameters=u,T.hasRest=h,T},r.prototype.resolveType=function(e,r,n){if(void 0===r&&(r=null),void 0===n&&(n=!0),e.kind==p.NodeKind.SIGNATURE){var i=this.resolveSignature(e,r,n);return i?c.Type.u32.asFunction(i):null}var a,s=e,l=s.name.text,u=l,h=s.range.source.internalPath+t.PATH_DELIMITER+l;if((a=this.elementsLookup.get(h))||(a=this.elementsLookup.get(u)))switch(a.kind){case g.CLASS_PROTOTYPE:var d=a.resolveUsingTypeArguments(s.typeArguments,r,null);return d?d.type:null}var _,y=this.typeAliases.get(l);if(y)return this.resolveType(y.type,r,n);if(s.typeArguments){for(var m=s.typeArguments.length,T=new Array(m),E=0;E<m;++E){var f=this.resolveType(s.typeArguments[E],r,n);if(!f)return null;T[E]=f}if(m){var I=c.typesToString(T);I.length&&(h+="<"+I+">",u+="<"+I+">")}else if(r){var v=r.get(u);if(v)return v}}return(_=this.typesLookup.get(h))||(_=this.typesLookup.get(u))?_:(n&&this.error(o.DiagnosticCode.Cannot_find_name_0,s.name.range,u),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,p.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),c=0;c<i;++c){var l=this.resolveType(t[c],r,!0);if(!l)return null;s[c]=l}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==g.ENUMVALUE)return this.resolvedThisExpression=null,this.resolvedElementExpression=null,i}else if(r){if(i=r.flow.getScopedLocal(s))return this.resolvedThisExpression=null,this.resolvedElementExpression=null,i;if(a=r.prototype.parent)do{if(i=this.elementsLookup.get(a.internalName+t.STATIC_DELIMITER+s))return this.resolvedThisExpression=null,this.resolvedElementExpression=null,i}while(a=a.parent)}return(i=this.elementsLookup.get(e.range.source.internalPath+t.PATH_DELIMITER+s))?(this.resolvedThisExpression=null,this.resolvedElementExpression=null,i):(i=this.elementsLookup.get(s))?(this.resolvedThisExpression=null,this.resolvedElementExpression=null,i):(this.error(o.DiagnosticCode.Cannot_find_name_0,e.range,s),null)},r.prototype.resolvePropertyAccess=function(e,t){var r=e.expression,n=this.resolveExpression(r,t);if(!n)return null;var i=e.property.text;switch(n.kind){case g.GLOBAL:case g.LOCAL:case g.FIELD:if(!(a=n.type.classReference))return this.error(o.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.property.range,i,n.type.toString()),null;n=a;break;case g.PROPERTY:var a,s=assert(n.getterPrototype).resolve();if(!s)return null;if(!(a=s.signature.returnType.classReference))return this.error(o.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.property.range,i,s.signature.returnType.toString()),null;n=a;break;case g.CLASS:var c=this.resolvedElementExpression;if(c){var p=n.lookupOverload(u.INDEXED_GET);if(!p)return this.error(o.DiagnosticCode.Index_signature_is_missing_in_type_0,c.range,n.internalName),null;var l=p.signature.returnType;if(!(n=l.classReference))return this.error(o.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.property.range,i,l.toString()),null}}switch(n.kind){case g.CLASS_PROTOTYPE:case g.CLASS:for(;;){var h=void 0;if((d=n.members)&&(h=d.get(i)))return this.resolvedThisExpression=r,this.resolvedElementExpression=null,h;if(n.kind==g.CLASS_PROTOTYPE){if(!n.basePrototype)break;n=n.basePrototype}else{if(n.kind!=g.CLASS)break;if(!n.base)break;n=n.base}}break;default:var d;h=void 0;if((d=n.members)&&(h=d.get(i)))return this.resolvedThisExpression=r,this.resolvedElementExpression=null,h}return this.error(o.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.property.range,i,n.internalName),null},r.prototype.resolveElementAccess=function(e,t){var r=e.expression,n=this.resolveExpression(r,t);if(!n)return null;switch(n.kind){case g.GLOBAL:case g.LOCAL:case g.FIELD:if(n=n.type.classReference)return this.resolvedThisExpression=r,this.resolvedElementExpression=e.elementExpression,n;break;case g.CLASS:var i=n.lookupOverload(u.INDEXED_GET);if(!i)return this.error(o.DiagnosticCode.Index_signature_is_missing_in_type_0,e.range,n.internalName),null;if(n=i.signature.returnType.classReference)return this.resolvedThisExpression=r,this.resolvedElementExpression=e.elementExpression,n}return this.error(o.DiagnosticCode.Operation_not_supported,r.range),null},r.prototype.resolveExpression=function(e,t){for(;e.kind==p.NodeKind.PARENTHESIZED;)e=e.expression;switch(e.kind){case p.NodeKind.ASSERTION:var r=this.resolveType(e.toType);if(r)if(l=r.classReference)return this.resolvedThisExpression=null,this.resolvedElementExpression=null,l;return null;case p.NodeKind.BINARY:throw new Error("not implemented");case p.NodeKind.THIS:if(t.flow.is(1024))if(n=t.flow.getScopedLocal("this"))return this.resolvedThisExpression=null,this.resolvedElementExpression=null,n;return(i=t.parent)?(this.resolvedThisExpression=null,this.resolvedElementExpression=null,i):(this.error(o.DiagnosticCode._this_cannot_be_referenced_in_current_location,e.range),null);case p.NodeKind.SUPER:var n,i;if(t.flow.is(1024))if(n=t.flow.getScopedLocal("super"))return this.resolvedThisExpression=null,this.resolvedElementExpression=null,n;return(i=t.parent)&&i.kind==g.CLASS&&(i=i.base)?(this.resolvedThisExpression=null,this.resolvedElementExpression=null,i):(this.error(o.DiagnosticCode._super_can_only_be_referenced_in_a_derived_class,e.range),null);case p.NodeKind.IDENTIFIER:return this.resolveIdentifier(e,t);case p.NodeKind.LITERAL:switch(e.literalKind){case p.LiteralKind.STRING:return this.resolvedThisExpression=e,this.resolvedElementExpression=null,this.stringInstance}break;case p.NodeKind.PROPERTYACCESS:return this.resolvePropertyAccess(e,t);case p.NodeKind.ELEMENTACCESS:return this.resolveElementAccess(e,t);case p.NodeKind.CALL:var a=e.expression,s=this.resolveExpression(a,t);if(!s)return null;if(s.kind==g.FUNCTION_PROTOTYPE){var c=s.resolveUsingTypeArguments(e.typeArguments,t.flow.contextualTypeArguments,e);if(!c)return null;var l,u=c.signature.returnType;if(l=u.classReference)return l;var h=u.signatureReference;if(h){var d=h.cachedFunctionTarget;return d||(d=new R(this,h),h.cachedFunctionTarget=d),d}return this.error(o.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures,a.range,s.internalName),null}}return this.error(o.DiagnosticCode.Operation_not_supported,e.range),null},r}(o.DiagnosticEmitter);function I(e){switch(e){case p.DecoratorKind.GLOBAL:return T.GLOBAL;case p.DecoratorKind.OPERATOR:return T.OPERATOR;case p.DecoratorKind.UNMANAGED:return T.UNMANAGED;case p.DecoratorKind.SEALED:return T.SEALED;case p.DecoratorKind.INLINE:return T.INLINE;default:return T.NONE}}t.Program=f,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.FUNCTION_TARGET=6]="FUNCTION_TARGET",e[e.CLASS_PROTOTYPE=7]="CLASS_PROTOTYPE",e[e.CLASS=8]="CLASS",e[e.INTERFACE_PROTOTYPE=9]="INTERFACE_PROTOTYPE",e[e.INTERFACE=10]="INTERFACE",e[e.FIELD_PROTOTYPE=11]="FIELD_PROTOTYPE",e[e.FIELD=12]="FIELD",e[e.PROPERTY=13]="PROPERTY",e[e.NAMESPACE=14]="NAMESPACE"}(g=t.ElementKind||(t.ElementKind={})),function(e){e[e.NONE=0]="NONE",e[e.IMPORT=1]="IMPORT",e[e.EXPORT=2]="EXPORT",e[e.DECLARE=4]="DECLARE",e[e.CONST=8]="CONST",e[e.LET=16]="LET",e[e.STATIC=32]="STATIC",e[e.READONLY=64]="READONLY",e[e.ABSTRACT=128]="ABSTRACT",e[e.PUBLIC=256]="PUBLIC",e[e.PRIVATE=512]="PRIVATE",e[e.PROTECTED=1024]="PROTECTED",e[e.GET=2048]="GET",e[e.SET=4096]="SET",e[e.AMBIENT=8192]="AMBIENT",e[e.GENERIC=16384]="GENERIC",e[e.GENERIC_CONTEXT=32768]="GENERIC_CONTEXT",e[e.INSTANCE=65536]="INSTANCE",e[e.CONSTRUCTOR=131072]="CONSTRUCTOR",e[e.ARROW=262144]="ARROW",e[e.MODULE_EXPORT=524288]="MODULE_EXPORT",e[e.MODULE_IMPORT=1048576]="MODULE_IMPORT",e[e.BUILTIN=2097152]="BUILTIN",e[e.COMPILED=4194304]="COMPILED",e[e.INLINED=8388608]="INLINED",e[e.SCOPED=16777216]="SCOPED",e[e.TRAMPOLINE=33554432]="TRAMPOLINE"}(m=t.CommonFlags||(t.CommonFlags={})),function(e){e[e.NONE=0]="NONE",e[e.GLOBAL=1]="GLOBAL",e[e.OPERATOR=2]="OPERATOR",e[e.UNMANAGED=4]="UNMANAGED",e[e.SEALED=8]="SEALED",e[e.INLINE=16]="INLINE"}(T=t.DecoratorFlags||(t.DecoratorFlags={})),t.decoratorKindToFlag=I;var v=function(){function e(e,t,r){this.flags=m.NONE,this.decoratorFlags=T.NONE,this.members=null,this.parent=null,this.program=e,this.simpleName=t,this.internalName=r}return e.prototype.is=function(e){return(this.flags&e)==e},e.prototype.isAny=function(e){return 0!=(this.flags&e)},e.prototype.set=function(e){this.flags|=e},e.prototype.hasDecorator=function(e){return(this.decoratorFlags&e)==e},e}();t.Element=v;var A=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n)||this;return a.kind=g.NAMESPACE,a.declaration=i,a.flags=i.flags,a}return i(t,e),t}(v);t.Namespace=A;var N=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n)||this;return a.kind=g.ENUM,a.declaration=i,a.flags=i.flags,a}return i(t,e),t}(v);t.Enum=N;var C=function(e){function t(t,r,n,i,a){var s=e.call(this,r,n,i)||this;return s.kind=g.ENUMVALUE,s.constantValue=0,s.parent=t,s.declaration=a,s}return i(t,e),t}(v);t.EnumValue=C,function(e){e[e.NONE=0]="NONE",e[e.INTEGER=1]="INTEGER",e[e.FLOAT=2]="FLOAT"}(t.ConstantValueKind||(t.ConstantValueKind={}));var S=function(e){function t(t,r,n,i,a){var s=e.call(this,t,r,n)||this;return s.constantValueKind=0,s.type=i,s.declaration=a,s}return i(t,e),t.prototype.withConstantIntegerValue=function(e,t){return this.constantValueKind=1,this.constantIntegerValue=i64_new(e,t),this.set(m.CONST|m.INLINED),this},t.prototype.withConstantFloatValue=function(e){return this.constantValueKind=2,this.constantFloatValue=e,this.set(m.CONST|m.INLINED),this},t}(v);t.VariableLikeElement=S;var O=function(e){function t(t,r,n,i,a,s){var o=e.call(this,t,r,n,i,a)||this;return o.kind=g.GLOBAL,o.flags=a?a.flags:m.NONE,o.decoratorFlags=s,o.type=i,o}return i(t,e),t}(S);t.Global=O;var L=function(){return function(e,t,r){void 0===r&&(r=null),this.name=e,this.type=t,this.initializer=r}}();t.Parameter=L;var b=function(e){function t(t,r,n,i,a){void 0===a&&(a=null);var s=e.call(this,t,r,r,i,a)||this;return s.kind=g.LOCAL,s.scopedGlobal=null,s.index=n,s}return i(t,e),t}(S);t.Local=b;var k=function(e){function r(t,r,n,i,a,s){void 0===a&&(a=null),void 0===s&&(s=T.NONE);var o=e.call(this,t,r,n)||this;return o.kind=g.FUNCTION_PROTOTYPE,o.instances=new Map,o.classTypeArguments=null,o.operatorKind=u.INVALID,o.declaration=i,o.flags=i.flags,o.classPrototype=a,o.decoratorFlags=s,o}return i(r,e),r.prototype.resolve=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var r=e?c.typesToString(e):"",n=this.instances.get(r);if(n)return n;var i=this.declaration,o=this.is(m.INSTANCE),l=this.classPrototype,u=t;if(t=new Map,u)try{for(var h=a(u),d=h.next();!d.done;d=h.next()){var _=s(d.value,2),y=_[0],g=_[1];t.set(y,g)}}catch(e){M={error:e}}finally{try{d&&!d.done&&(G=h.return)&&G.call(h)}finally{if(M)throw M.error}}var T=this.classTypeArguments;if(T){assert(this.is(m.INSTANCE));var E=assert(l).declaration.typeParameters,f=E.length;assert(f==T.length);for(var I=0;I<f;++I)t.set(E[I].name.text,T[I])}else assert(!T);var v,A=i.signature,N=i.typeParameters;if(e&&(v=e.length)){assert(N&&v==N.length);for(I=0;I<v;++I)t.set(N[I].name.text,e[I])}else assert(!N||0==N.length);var C=null,S=null;if(o){if(!(C=assert(l).resolve(T,t)))return null;S=C.type,t.set("this",S)}var O,L=A.parameterTypes,b=L.length,k=new Array(b),R=new Array(b),B=0;for(I=0;I<b;++I){var U=L[I];U.parameterKind==p.ParameterKind.DEFAULT&&(B=I+1);var D=assert(U.type),F=this.program.resolveType(D,t,!0);if(!F)return null;k[I]=F,R[I]=U.name.text}if(this.is(m.SET))O=c.Type.void;else if(this.is(m.CONSTRUCTOR))O=assert(C).type;else{D=assert(A.returnType);var P=this.program.resolveType(D,t,!0);if(!P)return null;O=P}var w=new c.Signature(k,O,S);w.parameterNames=R,w.requiredParameters=B;var M,G,K=this.internalName;return r.length&&(K+="<"+r+">"),n=new x(this,K,w,C||l,t),this.instances.set(r,n),this.program.instancesLookup.set(K,n),n},r.prototype.resolvePartial=function(e){assert(this.is(m.INSTANCE));var n=assert(this.classPrototype);if(!e||!e.length)return this;var i=this.simpleName,a=c.typesToString(e),s=new r(this.program,i,n.internalName+"<"+a+">"+t.INSTANCE_DELIMITER+i,this.declaration,n,this.decoratorFlags);return s.flags=this.flags,s.operatorKind=this.operatorKind,s.classTypeArguments=e,s},r.prototype.resolveUsingTypeArguments=function(e,t,r){var n=null;return!this.is(m.GENERIC)||(assert(null!=e&&0!=e.length),n=this.program.resolveTypeArguments(assert(this.declaration.typeParameters),e,t,r))?this.resolve(n,t):null},r.prototype.resolveBuiltinTypeArguments=function(e,t){assert(this.is(m.BUILTIN));var r=null;if(e){var n=e.length;r=new Array(n);for(var i=0;i<n;++i){var a=this.program.resolveType(e[i],t,!0);if(!a)return null;r[i]=a}}return r},r.prototype.toString=function(){return this.simpleName},r}(v);t.FunctionPrototype=k;var x=function(e){function t(t,r,n,i,o){void 0===i&&(i=null),void 0===o&&(o=null);var c,p,l=e.call(this,t.program,t.simpleName,r)||this;if(l.kind=g.FUNCTION,l.localsByName=new Map,l.localsByIndex=[],l.additionalLocals=[],l.breakContext=null,l.debugLocations=[],l.ref=0,l.functionTableIndex=-1,l.trampoline=null,l.outerScope=null,l.nextBreakId=0,l.breakStack=null,l.nextInlineId=0,l.tempI32s=null,l.tempI64s=null,l.tempF32s=null,l.tempF64s=null,l.prototype=t,l.signature=n,l.parent=i,l.flags=t.flags,l.decoratorFlags=t.decoratorFlags,l.contextualTypeArguments=o,!t.is(m.AMBIENT|m.BUILTIN)&&!t.is(m.DECLARE)){var u=0;if(i&&i.kind==g.CLASS){assert(l.is(m.INSTANCE));var h=new b(t.program,"this",u++,assert(n.thisType));l.localsByName.set("this",h),l.localsByIndex[h.index]=h;var d=i.contextualTypeArguments;if(d){l.contextualTypeArguments||(l.contextualTypeArguments=new Map);try{for(var _=a(d),y=_.next();!y.done;y=_.next()){var T=s(y.value,2),E=T[0],f=T[1];l.contextualTypeArguments.has(E)||l.contextualTypeArguments.set(E,f)}}catch(e){c={error:e}}finally{try{y&&!y.done&&(p=_.return)&&p.call(_)}finally{if(c)throw c.error}}}}else assert(!l.is(m.INSTANCE));for(var I=n.parameterTypes,v=0,A=I.length;v<A;++v){var N=I[v],C=n.getParameterName(v);h=new b(t.program,C,u++,N);l.localsByName.set(C,h),l.localsByIndex[h.index]=h}}return l.flow=G.create(l),l}return i(t,e),t.prototype.addLocal=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r=null);var n=this.signature.parameterTypes.length+this.additionalLocals.length;this.is(m.INSTANCE)&&++n;var i=new b(this.prototype.program,t||"var$"+n.toString(10),n,e,r);if(t){if(this.localsByName.has(t))throw new Error("duplicate local name");this.localsByName.set(t,i)}return this.localsByIndex[i.index]=i,this.additionalLocals.push(e),i},t.prototype.getTempLocal=function(e,t){var r,n;switch(e.toNativeType()){case l.NativeType.I32:r=this.tempI32s;break;case l.NativeType.I64:r=this.tempI64s;break;case l.NativeType.F32:r=this.tempF32s;break;case l.NativeType.F64:r=this.tempF64s;break;default:throw new Error("concrete type expected")}return r&&r.length?(n=r.pop()).type=e:n=this.addLocal(e),this.flow.setLocalWrapped(n.index,t),n},t.prototype.freeTempLocal=function(e){if(!e.is(m.INLINED)){var t;switch(assert(e.index>=0),assert(null!=e.type),e.type.toNativeType()){case l.NativeType.I32:t=this.tempI32s||(this.tempI32s=[]);break;case l.NativeType.I64:t=this.tempI64s||(this.tempI64s=[]);break;case l.NativeType.F32:t=this.tempF32s||(this.tempF32s=[]);break;case l.NativeType.F64:t=this.tempF64s||(this.tempF64s=[]);break;default:throw new Error("concrete type expected")}assert(e.index>=0),t.push(e)}},t.prototype.getAndFreeTempLocal=function(e,t){var r,n;switch(e.toNativeType()){case l.NativeType.I32:r=this.tempI32s||(this.tempI32s=[]);break;case l.NativeType.I64:r=this.tempI64s||(this.tempI64s=[]);break;case l.NativeType.F32:r=this.tempF32s||(this.tempF32s=[]);break;case l.NativeType.F64:r=this.tempF64s||(this.tempF64s=[]);break;default:throw new Error("concrete type expected")}return r.length?(n=r[r.length-1]).type=e:(n=this.addLocal(e),r.push(n)),this.flow.setLocalWrapped(n.index,t),n},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(this.ref=t,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)for(var r=this.debugLocations,n=0,i=r.length;n<i;++n){var a=r[n];e.setDebugLocation(t,a.debugInfoRef,a.source.debugInfoIndex,a.line,a.column)}},t.prototype.toString=function(){return this.prototype.simpleName},t}(v);t.Function=x;var R=function(e){function t(t,r){var n=e.call(this,t,"","")||this;n.kind=g.FUNCTION_TARGET;var i=r.toSignatureString();return n.simpleName=i,n.internalName=i,n.signature=r,n.type=c.Type.u32.asFunction(r),n}return i(t,e),t}(v);t.FunctionTarget=R;var B=function(e){function t(t,r,n,i){var a=e.call(this,t.program,r,n)||this;return a.kind=g.FIELD_PROTOTYPE,a.classPrototype=t,a.declaration=i,a.flags=i.flags,a}return i(t,e),t}(v);t.FieldPrototype=B;var U=function(e){function t(t,r,n,i,a){var s=e.call(this,t.program,t.simpleName,r,n,i)||this;return s.kind=g.FIELD,s.memoryOffset=-1,s.prototype=t,s.flags=t.flags,s.type=n,s.parent=a,s}return i(t,e),t}(S);t.Field=U;var D=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n)||this;return a.kind=g.PROPERTY,a.getterPrototype=null,a.setterPrototype=null,a.parent=i,a}return i(t,e),t}(v);t.Property=D;var F=function(e){function r(t,r,n,i,a){var s=e.call(this,t,r,n)||this;return s.kind=g.CLASS_PROTOTYPE,s.instances=new Map,s.instanceMembers=null,s.basePrototype=null,s.constructorPrototype=null,s.overloadPrototypes=new Map,s.declaration=i,s.flags=i.flags,s.decoratorFlags=a,s}return i(r,e),r.prototype.resolve=function(e,r){void 0===r&&(r=null);var n=e?c.typesToString(e):"",i=this.instances.get(n);if(i)return i;var l=r;if(r=new Map,l)try{for(var h=a(l),d=h.next();!d.done;d=h.next()){var _=s(d.value,2),y=_[0],E=_[1];r.set(y,E)}}catch(e){O={error:e}}finally{try{d&&!d.done&&(L=h.return)&&L.call(h)}finally{if(O)throw O.error}}var f,I,v=this.declaration,A=null;if(v.extendsType){var N=this.program.resolveType(v.extendsType,null);if(!N)return null;if(!(A=N.classReference))return this.program.error(o.DiagnosticCode.A_class_may_only_extend_another_class,v.extendsType.range),null;if(A.hasDecorator(T.SEALED))return this.program.error(o.DiagnosticCode.Class_0_is_sealed_and_cannot_be_extended,v.extendsType.range,A.internalName),null;if(A.hasDecorator(T.UNMANAGED)!=this.hasDecorator(T.UNMANAGED))return this.program.error(o.DiagnosticCode.Unmanaged_classes_cannot_extend_managed_classes_and_vice_versa,p.Range.join(v.name.range,v.extendsType.range)),null}if(e){if((I=e.length)!=v.typeParameters.length)throw new Error("type argument count mismatch");for(f=0;f<I;++f)r.set(v.typeParameters[f].name.text,e[f])}else if(v.typeParameters.length)throw new Error("type argument count mismatch");var C=this.simpleName,S=this.internalName;n.length&&(C+="<"+n+">",S+="<"+n+">"),(i=new P(this,C,S,e,A)).contextualTypeArguments=r,this.instances.set(n,i),this.program.instancesLookup.set(S,i);var O,L,b,k,x,R,B,F,w=0;if(A&&(w=A.currentMemoryOffset,A.members)){i.members||(i.members=new Map);try{for(var M=a(A.members.values()),G=M.next();!G.done;G=M.next()){var K=G.value;i.members.set(K.simpleName,K)}}catch(e){b={error:e}}finally{try{G&&!G.done&&(k=M.return)&&k.call(M)}finally{if(b)throw b.error}}}if(this.constructorPrototype){var z=this.constructorPrototype.resolvePartial(e);z&&(i.constructorInstance=z.resolve())}if(this.instanceMembers)try{for(var V=a(this.instanceMembers.values()),H=V.next();!H.done;H=V.next()){var X=H.value;switch(X.kind){case g.FIELD_PROTOTYPE:i.members||(i.members=new Map);var W=X.declaration;if(!W.type)throw new Error("type expected");var Y=this.program.resolveType(W.type,i.contextualTypeArguments);if(Y){var Q=new U(X,S+t.INSTANCE_DELIMITER+X.simpleName,Y,W,i);switch(Y.byteSize){case 1:break;case 2:1&w&&++w;break;case 4:3&w&&(w=1+(3|w));break;case 8:7&w&&(w=1+(7|w));break;default:assert(!1)}Q.memoryOffset=w,w+=Y.byteSize,i.members.set(X.simpleName,Q)}break;case g.FUNCTION_PROTOTYPE:i.members||(i.members=new Map);var q=X.resolvePartial(e);q&&(q.internalName=S+t.INSTANCE_DELIMITER+q.simpleName,i.members.set(X.simpleName,q));break;case g.PROPERTY:i.members||(i.members=new Map);var j=assert(X.getterPrototype),Z=X.setterPrototype,$=new D(this.program,X.simpleName,S+t.INSTANCE_DELIMITER+X.simpleName,this),J=j.resolvePartial(e);if(!J)return null;if(J.internalName=S+t.INSTANCE_DELIMITER+J.simpleName,$.getterPrototype=J,Z){var ee=Z.resolvePartial(e);if(!ee)return null;ee.internalName=S+t.INSTANCE_DELIMITER+ee.simpleName,$.setterPrototype=ee}i.members.set(X.simpleName,$);break;default:assert(!1)}}}catch(e){x={error:e}}finally{try{H&&!H.done&&(R=V.return)&&R.call(V)}finally{if(x)throw x.error}}try{for(var te=a(this.overloadPrototypes),re=te.next();!re.done;re=te.next()){var ne=s(re.value,2),ie=ne[0],ae=ne[1];assert(ie!=u.INVALID);var se=void 0;if(ae.is(m.INSTANCE)){var oe=ae.resolvePartial(e);if(!oe)continue;se=oe.resolve()}else se=ae.resolve();if(se){var ce=i.overloads;ce||(i.overloads=ce=new Map),ce.set(ie,se)}}}catch(e){B={error:e}}finally{try{re&&!re.done&&(F=te.return)&&F.call(te)}finally{if(B)throw B.error}}return i.currentMemoryOffset=w,i},r.prototype.resolveUsingTypeArguments=function(e,t,r){var n=null;if(this.is(m.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)},r.prototype.toString=function(){return this.simpleName},r}(v);t.ClassPrototype=F;var P=function(e){function t(t,r,n,i,o){void 0===i&&(i=null),void 0===o&&(o=null);var c=e.call(this,t.program,r,n)||this;if(c.kind=g.CLASS,c.contextualTypeArguments=null,c.currentMemoryOffset=0,c.constructorInstance=null,c.overloads=null,c.prototype=t,c.flags=t.flags,c.decoratorFlags=t.decoratorFlags,c.typeArguments=i,c.type=t.program.options.usizeType.asClass(c),c.base=o,o){var p=o.contextualTypeArguments;if(p){c.contextualTypeArguments||(c.contextualTypeArguments=new Map);try{for(var l=a(p),u=l.next();!u.done;u=l.next()){var h=s(u.value,2),d=h[0],_=h[1];c.contextualTypeArguments.set(d,_)}}catch(e){T={error:e}}finally{try{u&&!u.done&&(E=l.return)&&E.call(l)}finally{if(T)throw T.error}}}}var y,m,T,E,f=c.prototype.declaration;if(f){var I=f.typeParameters;if(i){if((m=i.length)!=I.length)throw new Error("type argument count mismatch");if(m)for(c.contextualTypeArguments||(c.contextualTypeArguments=new Map),y=0;y<m;++y)c.contextualTypeArguments.set(I[y].name.text,i[y])}else if(I.length)throw new Error("type argument count mismatch")}return c}return i(t,e),t.prototype.isAssignableTo=function(e){var t=this;do{if(t==e)return!0}while(t=t.base);return!1},t.prototype.lookupOverload=function(e,t){if(void 0===t&&(t=!1),t)switch(e){case u.INDEXED_GET:if(r=this.lookupOverload(u.UNCHECKED_INDEXED_GET))return r;break;case u.INDEXED_SET:var r;if(r=this.lookupOverload(u.UNCHECKED_INDEXED_SET))return r;break;default:assert(!1)}var n=this;do{var i=n.overloads;if(i){var a=i.get(e);if(a)return a}}while(n=n.base);return null},t.prototype.toString=function(){return this.simpleName},t}(v);t.Class=P;var w=function(e){function t(t,r,n,i,a){var s=e.call(this,t,r,n,i,a)||this;return s.kind=g.INTERFACE_PROTOTYPE,s}return i(t,e),t}(F);t.InterfacePrototype=w;var M=function(e){function t(t,r,n,i,a){void 0===i&&(i=[]),void 0===a&&(a=null);var s=e.call(this,t,r,n,i,a)||this;return s.kind=g.INTERFACE,s}return i(t,e),t}(P);t.Interface=M,function(e){e[e.NONE=0]="NONE",e[e.RETURNS=1]="RETURNS",e[e.THROWS=2]="THROWS",e[e.BREAKS=4]="BREAKS",e[e.CONTINUES=8]="CONTINUES",e[e.ALLOCATES=16]="ALLOCATES",e[e.CONDITIONALLY_RETURNS=32]="CONDITIONALLY_RETURNS",e[e.CONDITIONALLY_THROWS=64]="CONDITIONALLY_THROWS",e[e.CONDITIONALLY_BREAKS=128]="CONDITIONALLY_BREAKS",e[e.CONDITIONALLY_CONTINUES=256]="CONDITIONALLY_CONTINUES",e[e.CONDITIONALLY_ALLOCATES=512]="CONDITIONALLY_ALLOCATES",e[e.INLINE_CONTEXT=1024]="INLINE_CONTEXT",e[e.UNCHECKED_CONTEXT=2048]="UNCHECKED_CONTEXT",e[e.RETURNS_WRAPPED=4096]="RETURNS_WRAPPED"}(t.FlowFlags||(t.FlowFlags={}));var G=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.returnLabel=null,r.returnType=t.signature.returnType,r.contextualTypeArguments=t.contextualTypeArguments,r.wrappedLocals=i64_new(0),r.wrappedLocalsExt=null,r},e.prototype.is=function(e){return(this.flags&e)==e},e.prototype.isAny=function(e){return 0!=(this.flags&e)},e.prototype.set=function(e){this.flags|=e},e.prototype.unset=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.returnLabel=this.returnLabel,t.returnType=this.returnType,t.contextualTypeArguments=this.contextualTypeArguments,t.wrappedLocals=this.wrappedLocals,t.wrappedLocalsExt=this.wrappedLocalsExt?this.wrappedLocalsExt.slice():null,t},e.prototype.leaveBranchOrScope=function(){var e,t,r=assert(this.parent);if(this.scopedLocals){try{for(var n=a(this.scopedLocals.values()),i=n.next();!i.done;i=n.next()){var s=i.value;s.is(m.SCOPED)&&this.currentFunction.freeTempLocal(s)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.scopedLocals=null}return this.is(1)&&r.set(32),this.is(2)&&r.set(64),this.is(4)&&r.breakLabel==this.breakLabel&&r.set(128),this.is(8)&&r.continueLabel==this.continueLabel&&r.set(256),this.is(16)&&r.set(512),r},e.prototype.addScopedLocal=function(e,t,r,n){var i=this.currentFunction.getTempLocal(e,!1);if(this.scopedLocals){var a=this.scopedLocals.get(t);if(a)return n?this.currentFunction.program.error(o.DiagnosticCode.Duplicate_identifier_0,n.name.range):assert(!1),a}else this.scopedLocals=new Map;return this.scopedLocals.set(t,i),this.setLocalWrapped(i.index,r),i},e.prototype.addScopedLocalAlias=function(e,t,r){if(this.scopedLocals){var n=this.scopedLocals.get(r);if(n){var i=n.declaration;return i?this.currentFunction.program.error(o.DiagnosticCode.Duplicate_identifier_0,i.name.range):assert(!1),n}}else this.scopedLocals=new Map;assert(e<this.currentFunction.localsByIndex.length);var a=new b(this.currentFunction.program,r,e,t,null);return this.scopedLocals.set(r,a),a},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.localsByName.get(e)},e.prototype.isLocalWrapped=function(e){var t,r;if(e<64){if(e<0)return!0;t=this.wrappedLocals}else{if(!(r=this.wrappedLocalsExt))return!1;var n=(e-64)/64|0;if(n>=r.length)return!1;t=r[n],e-=64*(n+1)}return i64_ne(i64_and(t,i64_shl(i64_one,i64_new(e))),i64_zero)},e.prototype.setLocalWrapped=function(e,t){var r,n=-1;if(e<64){if(e<0)return;r=this.wrappedLocals}else{var i=this.wrappedLocalsExt;if(n=(e-64)/64|0,i)for(;i.length<=n;)i.push(i64_new(0));else i=new Array(n+1);r=i[n],e-=64*(n+1)}r=t?i64_or(r,i64_shl(i64_one,i64_new(e))):i64_and(r,i64_not(i64_shl(i64_one,i64_new(e)))),n>=0?this.wrappedLocalsExt[n]=r:this.wrappedLocals=r},e.prototype.inherit=function(e){this.flags|=4127&e.flags,this.wrappedLocals=e.wrappedLocals,this.wrappedLocalsExt=e.wrappedLocalsExt},e.prototype.inheritMutual=function(e,t){this.flags|=e.flags&t.flags&4127,this.wrappedLocals=i64_and(e.wrappedLocals,t.wrappedLocals);var r=e.wrappedLocalsExt,n=t.wrappedLocalsExt;if(null!=r&&null!=n){var i=this.wrappedLocalsExt,a=min(r.length,n.length);if(a){if(i)for(;i.length<a;)i.push(i64_new(0));else i=new Array(a);for(var s=0;s<a;++s)i[s]=i64_and(r[s],n[s])}}},e.prototype.canOverflow=function(e,t){if(assert(t!=c.Type.void),!t.is(36))return!1;var r;switch(l.getExpressionId(e)){case l.ExpressionId.GetLocal:var n=this.currentFunction,i=n.localsByIndex[l.getGetLocalIndex(e)];return!n.flow.isLocalWrapped(i.index)||K(i.type,t);case l.ExpressionId.SetLocal:return assert(l.isTeeLocal(e)),this.canOverflow(l.getSetLocalValue(e),t);case l.ExpressionId.GetGlobal:return!1;case l.ExpressionId.Binary:switch(l.getBinaryOp(e)){case l.BinaryOp.EqI32:case l.BinaryOp.EqI64:case l.BinaryOp.EqF32:case l.BinaryOp.EqF64:case l.BinaryOp.NeI32:case l.BinaryOp.NeI64:case l.BinaryOp.NeF32:case l.BinaryOp.NeF64:case l.BinaryOp.LtI32:case l.BinaryOp.LtU32:case l.BinaryOp.LtI64:case l.BinaryOp.LtU64:case l.BinaryOp.LtF32:case l.BinaryOp.LtF64:case l.BinaryOp.LeI32:case l.BinaryOp.LeU32:case l.BinaryOp.LeI64:case l.BinaryOp.LeU64:case l.BinaryOp.LeF32:case l.BinaryOp.LeF64:case l.BinaryOp.GtI32:case l.BinaryOp.GtU32:case l.BinaryOp.GtI64:case l.BinaryOp.GtU64:case l.BinaryOp.GtF32:case l.BinaryOp.GtF64:case l.BinaryOp.GeI32:case l.BinaryOp.GeU32:case l.BinaryOp.GeI64:case l.BinaryOp.GeU64:case l.BinaryOp.GeF32:case l.BinaryOp.GeF64:return!1;case l.BinaryOp.MulI32:return!(l.getExpressionId(r=l.getBinaryLeft(e))==l.ExpressionId.Const&&(0==l.getConstValueI32(r)||1==l.getConstValueI32(r)&&!this.canOverflow(l.getBinaryRight(e),t))||l.getExpressionId(r=l.getBinaryRight(e))==l.ExpressionId.Const&&(0==l.getConstValueI32(r)||1==l.getConstValueI32(r)&&!this.canOverflow(l.getBinaryLeft(e),t)));case l.BinaryOp.AndI32:return!(l.getExpressionId(r=l.getBinaryLeft(e))==l.ExpressionId.Const&&l.getConstValueI32(r)<=t.computeSmallIntegerMask(c.Type.i32)||!this.canOverflow(r,t)||l.getExpressionId(r=l.getBinaryRight(e))==l.ExpressionId.Const&&l.getConstValueI32(r)<=t.computeSmallIntegerMask(c.Type.i32)||!this.canOverflow(r,t));case l.BinaryOp.ShlI32:var a=32-t.size;return l.getExpressionId(r=l.getBinaryRight(e))!=l.ExpressionId.Const||l.getConstValueI32(r)<a;case l.BinaryOp.ShrI32:a=32-t.size;return this.canOverflow(l.getBinaryLeft(e),t)&&(l.getExpressionId(r=l.getBinaryRight(e))!=l.ExpressionId.Const||l.getConstValueI32(r)<a);case l.BinaryOp.ShrU32:a=32-t.size;return t.is(1)?!(l.getExpressionId(r=l.getBinaryRight(e))==l.ExpressionId.Const&&l.getConstValueI32(r)>a):this.canOverflow(l.getBinaryLeft(e),t)&&!(l.getExpressionId(r=l.getBinaryRight(e))==l.ExpressionId.Const&&l.getConstValueI32(r)>=a);case l.BinaryOp.DivU32:case l.BinaryOp.RemI32:case l.BinaryOp.RemU32:return this.canOverflow(l.getBinaryLeft(e),t)||this.canOverflow(l.getBinaryRight(e),t)}break;case l.ExpressionId.Unary:switch(l.getUnaryOp(e)){case l.UnaryOp.EqzI32:case l.UnaryOp.EqzI64:return!1;case l.UnaryOp.ClzI32:case l.UnaryOp.CtzI32:case l.UnaryOp.PopcntI32:return t.size<7}break;case l.ExpressionId.Const:var s=0;switch(l.getExpressionType(e)){case l.NativeType.I32:s=l.getConstValueI32(e);break;case l.NativeType.I64:s=l.getConstValueI64Low(e);break;case l.NativeType.F32:s=i32(l.getConstValueF32(e));break;case l.NativeType.F64:s=i32(l.getConstValueF64(e));break;default:assert(!1)}switch(t.kind){case 0:return s<i8.MIN_VALUE||s>i8.MAX_VALUE;case 1:return s<i16.MIN_VALUE||s>i16.MAX_VALUE;case 5:return s<0||s>u8.MAX_VALUE;case 6:return s<0||s>u16.MAX_VALUE;case 10:return 0!=(-2&s)}break;case l.ExpressionId.Load:var o=void 0;switch(l.getLoadBytes(e)){case 1:o=l.isLoadSigned(e)?c.Type.i8:c.Type.u8;break;case 2:o=l.isLoadSigned(e)?c.Type.i16:c.Type.u16;break;default:o=l.isLoadSigned(e)?c.Type.i32:c.Type.u32}return K(o,t);case l.ExpressionId.Block:if(!l.getBlockName(e)){var p=assert(l.getBlockChildCount(e)),u=l.getBlockChild(e,p-1);return this.canOverflow(u,t)}break;case l.ExpressionId.If:return this.canOverflow(l.getIfTrue(e),t)||this.canOverflow(assert(l.getIfFalse(e)),t);case l.ExpressionId.Select:return this.canOverflow(l.getSelectThen(e),t)||this.canOverflow(l.getSelectElse(e),t);case l.ExpressionId.Call:var h=this.currentFunction.program,d=assert(h.instancesLookup.get(assert(l.getCallTarget(e))));assert(d.kind==g.FUNCTION);var _=d.signature.returnType;return!d.flow.is(4096)||K(_,t);case l.ExpressionId.Unreachable:return!1}return!0},e.prototype.finalize=function(){assert(null==this.parent),this.continueLabel=null,this.breakLabel=null,this.returnLabel=null,this.contextualTypeArguments=null},e}();function K(e,t){var r=e.byteSize,n=t.byteSize;return!e.is(4)||r>n||e.is(1)!=t.is(1)}t.Flow=G},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(20)),n(r(19)),n(r(18)),n(r(17))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(8),a=r(1),s=r(8);function o(e){switch(e){case n.INFO:return"INFO";case n.WARNING:return"WARNING";case n.ERROR:return"ERROR";default:return assert(!1),""}}function c(e){switch(e){case n.INFO:return t.COLOR_BLUE;case n.WARNING:return t.COLOR_YELLOW;case n.ERROR:return t.COLOR_RED;default:return assert(!1),""}}t.DiagnosticCode=s.DiagnosticCode,t.diagnosticCodeToString=s.diagnosticCodeToString,function(e){e[e.INFO=0]="INFO",e[e.WARNING=1]="WARNING",e[e.ERROR=2]="ERROR"}(n=t.DiagnosticCategory||(t.DiagnosticCategory={})),t.diagnosticCategoryToString=o,t.COLOR_BLUE="[93m",t.COLOR_YELLOW="[93m",t.COLOR_RED="[91m",t.COLOR_RESET="[0m",t.diagnosticCategoryToColor=c;var p=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,a,s){void 0===n&&(n=null),void 0===a&&(a=null),void 0===s&&(s=null);var o=i.diagnosticCodeToString(t);return null!=n&&(o=o.replace("{0}",n)),null!=a&&(o=o.replace("{1}",a)),null!=s&&(o=o.replace("{2}",s)),new e(t,r,o)},e.createInfo=function(t,r,i){return void 0===r&&(r=null),void 0===i&&(i=null),e.create(t,n.INFO,r,i)},e.createWarning=function(t,r,i){return void 0===r&&(r=null),void 0===i&&(i=null),e.create(t,n.WARNING,r,i)},e.createError=function(t,r,i){return void 0===r&&(r=null),void 0===i&&(i=null),e.create(t,n.ERROR,r,i)},e.prototype.withRange=function(e){return this.range=e,this},e.prototype.toString=function(){return this.range?o(this.category)+" "+this.code.toString(10)+': "'+this.message+'" in '+this.range.source.normalizedPath+":"+this.range.line.toString(10)+":"+this.range.column.toString(10):o(this.category)+" "+this.code.toString(10)+": "+this.message},e}();function l(e,r){void 0===r&&(r=!1);for(var n=e.source.text,i=n.length,s=e.start,o=e.end;s>0&&!a.isLineBreak(n.charCodeAt(s-1));)s--;for(;o<i&&!a.isLineBreak(n.charCodeAt(o));)o++;for(var c=["\n ",n.substring(s,o),"\n "];s<e.start;)c.push(" "),s++;if(r&&c.push(t.COLOR_RED),e.start==e.end)c.push("^");else for(;s++<e.end;)c.push("~");return r&&c.push(t.COLOR_RESET),c.join("")}t.DiagnosticMessage=p,t.formatDiagnosticMessage=function(e,r,n){void 0===r&&(r=!1),void 0===n&&(n=!1);var i=[];if(r&&i.push(c(e.category)),i.push(o(e.category)),r&&i.push(t.COLOR_RESET),i.push(e.code<1e3?" AS":" TS"),i.push(e.code.toString(10)),i.push(": "),i.push(e.message),e.range){var a=e.range;n&&(i.push("\n"),i.push(l(e.range,r))),i.push("\n"),i.push(" in "),i.push(a.source.normalizedPath),i.push("("),i.push(a.line.toString(10)),i.push(","),i.push(a.column.toString(10)),i.push(")")}return i.join("")},t.formatDiagnosticContext=l;var u=function(){function e(e){void 0===e&&(e=null),this.diagnostics=e||new Array}return e.prototype.emitDiagnostic=function(e,t,r,n,i,a){void 0===n&&(n=null),void 0===i&&(i=null),void 0===a&&(a=null);var s=p.create(e,t,n,i,a).withRange(r);this.diagnostics.push(s)},e.prototype.info=function(e,t,r,i,a){void 0===r&&(r=null),void 0===i&&(i=null),void 0===a&&(a=null),this.emitDiagnostic(e,n.INFO,t,r,i,a)},e.prototype.warning=function(e,t,r,i,a){void 0===r&&(r=null),void 0===i&&(i=null),void 0===a&&(a=null),this.emitDiagnostic(e,n.WARNING,t,r,i,a)},e.prototype.error=function(e,t,r,i,a){void 0===r&&(r=null),void 0===i&&(i=null),void 0===a&&(a=null),this.emitDiagnostic(e,n.ERROR,t,r,i,a)},e}();t.DiagnosticEmitter=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i,a=r(9);!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"}(n=t.NativeType||(t.NativeType={})),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"}(i=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",e[e.ExtendI8ToI32=_BinaryenExtendS8Int32()]="ExtendI8ToI32",e[e.ExtendI16ToI32=_BinaryenExtendS16Int32()]="ExtendI16ToI32",e[e.ExtendI8ToI64=_BinaryenExtendS8Int64()]="ExtendI8ToI64",e[e.ExtendI16ToI64=_BinaryenExtendS16Int64()]="ExtendI16ToI64",e[e.ExtendI32ToI64=_BinaryenExtendS32Int64()]="ExtendI32ToI64"}(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 s=function(){function e(){}return e.create=function(t,r){var n=new e;return n.buffer=t,n.offset=r,n},e}();t.MemorySegment=s;var o=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=p(t);try{var n=new e;return n.ref=_BinaryenModuleRead(r,t.length),n.out=allocate_memory(24),n}finally{free_memory(changetype(r))}},e.prototype.addFunctionType=function(e,t,r){var n=h(e),i=l(r);try{return _BinaryenAddFunctionType(this.ref,n,t,i,r?r.length:0)}finally{free_memory(i),free_memory(n)}},e.prototype.getFunctionTypeBySignature=function(e,t){var r=l(t);try{return _BinaryenGetFunctionTypeBySignature(this.ref,e,r,t?t.length:0)}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=h(t),i=u(r);try{return _BinaryenHost(this.ref,e,n,i,r?r.length:0)}finally{free_memory(i),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=h(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=h(e);try{return _BinaryenSetGlobal(this.ref,r,t)}finally{free_memory(r)}},e.prototype.createBlock=function(e,t,r){void 0===r&&(r=n.None);var i=h(e),a=u(t);try{return _BinaryenBlock(this.ref,i,a,t.length,r)}finally{free_memory(a),free_memory(i)}},e.prototype.createBreak=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=h(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=h(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 i=e.length,a=new Array(i),s=0;s<i;++s)a[s]=h(e[s]);var o=l(a),c=h(t);try{return _BinaryenSwitch(this.ref,o,i,c,r,n)}finally{free_memory(c),free_memory(o);for(s=i-1;s>=0;--s)free_memory(a[s])}},e.prototype.createCall=function(e,t,r){var n=h(e),i=u(t);try{return _BinaryenCall(this.ref,n,i,t&&t.length||0,r)}finally{free_memory(i),free_memory(n)}},e.prototype.createCallImport=function(e,t,r){var n=h(e),i=u(t);try{return _BinaryenCallImport(this.ref,n,i,t&&t.length||0,r)}finally{free_memory(i),free_memory(n)}},e.prototype.createCallIndirect=function(e,t,r){var n=u(t),i=h(r);try{return _BinaryenCallIndirect(this.ref,e,n,t&&t.length||0,i)}finally{free_memory(i),free_memory(n)}},e.prototype.createUnreachable=function(){return _BinaryenUnreachable(this.ref)},e.prototype.addGlobal=function(e,t,r,n){var i=h(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 i=h(e),a=l(r);try{return _BinaryenAddFunction(this.ref,i,t,a,r?r.length:0,n)}finally{free_memory(a),free_memory(i)}},e.prototype.removeFunction=function(e){var t=h(e);try{_BinaryenRemoveFunction(this.ref,t)}finally{free_memory(t)}},e.prototype.addFunctionExport=function(e,t){var r=h(e),n=h(t);try{return _BinaryenAddFunctionExport(this.ref,r,n)}finally{free_memory(n),free_memory(r)}},e.prototype.addTableExport=function(e,t){var r=h(e),n=h(t);try{return _BinaryenAddTableExport(this.ref,r,n)}finally{free_memory(n),free_memory(r)}},e.prototype.addMemoryExport=function(e,t){var r=h(e),n=h(t);try{return _BinaryenAddMemoryExport(this.ref,r,n)}finally{free_memory(n),free_memory(r)}},e.prototype.addGlobalExport=function(e,t){var r=h(e),n=h(t);try{return _BinaryenAddGlobalExport(this.ref,r,n)}finally{free_memory(n),free_memory(r)}},e.prototype.removeExport=function(e){var t=h(e);try{_BinaryenRemoveExport(this.ref,t)}finally{free_memory(t)}},e.prototype.addFunctionImport=function(e,t,r,n){var i=h(e),a=h(t),s=h(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=h(e),i=h(t),a=h(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=h(e),i=h(t),a=h(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=h(e),a=h(t),s=h(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=h(e);try{_BinaryenRemoveImport(this.ref,t)}finally{free_memory(t)}},e.prototype.setMemory=function(e,t,r,n,i){void 0===i&&(i=null);for(var s=h(i),o=r.length,c=new Array(o),u=new Array(o),d=new Array(o),_=0;_<o;++_){var y=r[_].buffer,g=r[_].offset;c[_]=p(y),u[_]=n==a.Target.WASM64?this.createI64(i64_low(g),i64_high(g)):this.createI32(i64_low(g)),d[_]=y.length}var m=l(c),T=l(u),E=l(d);try{_BinaryenSetMemory(this.ref,e,t,s,m,T,E,o)}finally{free_memory(E),free_memory(T),free_memory(m);for(_=o-1;_>=0;--_)free_memory(c[_]);free_memory(s)}},e.prototype.setFunctionTable=function(e){var t=u(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),i=0;i<r;++i)n[i]=h(e[i]);var a=l(n);try{t?_BinaryenFunctionRunPasses(t,this.ref,a,r):_BinaryenModuleRunPasses(this.ref,a,r)}finally{free_memory(a);for(i=r;i>=0;--i)free_memory(n[i])}},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=h(e),n=0,i=0;try{_BinaryenModuleAllocateAndWrite(t,this.ref,r),n=d(t);var a=d(t+4);i=d(t+8);var s=new y;return s.output=function(e,t){for(var r=new Uint8Array(t),n=0;n<t;++n)r[n]=load(e+n);return r}(n,a),s.sourceMap=_(i),s}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 c.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;var a,s;switch(r-=1,_BinaryenExpressionGetId(e)){case i.Const:switch(_BinaryenExpressionGetType(e)){case n.I32:return this.createI32(_BinaryenConstGetValueI32(e));case n.I64:return this.createI64(_BinaryenConstGetValueI64Low(e),_BinaryenConstGetValueI64High(e));case n.F32:return this.createF32(_BinaryenConstGetValueF32(e));case n.F64:return this.createF64(_BinaryenConstGetValueF64(e));default:throw new Error("concrete type expected")}case i.GetLocal:return _BinaryenGetLocal(this.ref,_BinaryenGetLocalGetIndex(e),_BinaryenExpressionGetType(e));case i.GetGlobal:var o=_BinaryenGetGlobalGetName(e);if(!o)break;return _BinaryenGetGlobal(this.ref,o,_BinaryenExpressionGetType(e));case i.Load:if(!(a=this.cloneExpression(_BinaryenLoadGetPtr(e),t,r)))break;return _BinaryenLoadIsAtomic(e)?_BinaryenAtomicLoad(this.ref,_BinaryenLoadGetBytes(e),_BinaryenLoadGetOffset(e),_BinaryenExpressionGetType(e),a):_BinaryenLoad(this.ref,_BinaryenLoadGetBytes(e),_BinaryenLoadIsSigned(e)?1:0,_BinaryenLoadGetOffset(e),_BinaryenLoadGetAlign(e),_BinaryenExpressionGetType(e),a);case i.Unary:if(!(a=this.cloneExpression(_BinaryenUnaryGetValue(e),t,r)))break;return _BinaryenUnary(this.ref,_BinaryenUnaryGetOp(e),a);case i.Binary:if(!(a=this.cloneExpression(_BinaryenBinaryGetLeft(e),t,r)))break;if(!(s=this.cloneExpression(_BinaryenBinaryGetRight(e),t,r)))break;return _BinaryenBinary(this.ref,_BinaryenBinaryGetOp(e),a,s)}return 0},e.prototype.addDebugInfoFile=function(e){var t=h(e);try{return _BinaryenModuleAddDebugInfoFileName(this.ref,t)}finally{free_memory(t)}},e.prototype.getDebugInfoFile=function(e){return _(_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.MAX_MEMORY_WASM64=65535,e}();t.Module=o,t.getExpressionId=function(e){return _BinaryenExpressionGetId(e)},t.getExpressionType=function(e){return _BinaryenExpressionGetType(e)},t.getConstValueI32=function(e){return _BinaryenConstGetValueI32(e)},t.getConstValueI64Low=function(e){return _BinaryenConstGetValueI64Low(e)},t.getConstValueI64High=function(e){return _BinaryenConstGetValueI64High(e)},t.getConstValueF32=function(e){return _BinaryenConstGetValueF32(e)},t.getConstValueF64=function(e){return _BinaryenConstGetValueF64(e)},t.getGetLocalIndex=function(e){return _BinaryenGetLocalGetIndex(e)},t.getSetLocalIndex=function(e){return _BinaryenSetLocalGetIndex(e)},t.getSetLocalValue=function(e){return _BinaryenSetLocalGetValue(e)},t.isTeeLocal=function(e){return _BinaryenSetLocalIsTee(e)},t.getBinaryOp=function(e){return _BinaryenBinaryGetOp(e)},t.getBinaryLeft=function(e){return _BinaryenBinaryGetLeft(e)},t.getBinaryRight=function(e){return _BinaryenBinaryGetRight(e)},t.getUnaryOp=function(e){return _BinaryenUnaryGetOp(e)},t.getUnaryValue=function(e){return _BinaryenUnaryGetValue(e)},t.getLoadBytes=function(e){return _BinaryenLoadGetBytes(e)},t.getLoadOffset=function(e){return _BinaryenLoadGetOffset(e)},t.getLoadPtr=function(e){return _BinaryenLoadGetPtr(e)},t.isLoadSigned=function(e){return _BinaryenLoadIsSigned(e)},t.getStoreBytes=function(e){return _BinaryenStoreGetBytes(e)},t.getStoreOffset=function(e){return _BinaryenStoreGetOffset(e)},t.getStorePtr=function(e){return _BinaryenStoreGetPtr(e)},t.getStoreValue=function(e){return _BinaryenStoreGetValue(e)},t.getBlockName=function(e){return _(_BinaryenBlockGetName(e))},t.getBlockChildCount=function(e){return _BinaryenBlockGetNumChildren(e)},t.getBlockChild=function(e,t){return _BinaryenBlockGetChild(e,t)},t.getIfCondition=function(e){return _BinaryenIfGetCondition(e)},t.getIfTrue=function(e){return _BinaryenIfGetIfTrue(e)},t.getIfFalse=function(e){return _BinaryenIfGetIfFalse(e)},t.getLoopName=function(e){return _(_BinaryenLoopGetName(e))},t.getLoopBody=function(e){return _BinaryenLoopGetBody(e)},t.getBreakName=function(e){return _(_BinaryenBreakGetName(e))},t.getBreakCondition=function(e){return _BinaryenBreakGetCondition(e)},t.getSelectThen=function(e){return _BinaryenSelectGetIfTrue(e)},t.getSelectElse=function(e){return _BinaryenSelectGetIfFalse(e)},t.getSelectCondition=function(e){return _BinaryenSelectGetCondition(e)},t.getDropValue=function(e){return _BinaryenDropGetValue(e)},t.getReturnValue=function(e){return _BinaryenReturnGetValue(e)},t.getCallTarget=function(e){return _(_BinaryenCallGetTarget(e))},t.getHostOp=function(e){return _BinaryenHostGetOp(e)},t.getHostOperandCount=function(e){return _BinaryenHostGetNumOperands(e)},t.getHostOperand=function(e,t){return _BinaryenHostGetOperand(e,t)},t.getHostName=function(e){return _(_BinaryenHostGetNameOperand(e))},t.getFunctionBody=function(e){return _BinaryenFunctionGetBody(e)},t.getFunctionName=function(e){return _(_BinaryenFunctionGetName(e))},t.getFunctionParamCount=function(e){return _BinaryenFunctionGetNumParams(e)},t.getFunctionParamType=function(e,t){return _BinaryenFunctionGetParam(e,t)},t.getFunctionResultType=function(e){return _BinaryenFunctionGetResult(e)};var c=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 i=l(r);try{_RelooperAddBranchForSwitch(e,t,i,r.length,n)}finally{free_memory(i)}},e.prototype.renderAndDispose=function(e,t){return _RelooperRenderAndDispose(this.ref,e,t,this.module.ref)},e}();function p(e){if(!e)return 0;for(var t=e.length,r=allocate_memory(t),n=r,i=0;i<t;++i)store(n++,e[i]);return r}function l(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 u(e){return l(e)}function h(e){if(null==e)return 0;for(var t=allocate_memory(function(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}(e)+1),r=t,n=0,i=e.length;n<i;++n){var a=e.charCodeAt(n);a>=55296&&a<=57343&&n+1<i&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++n)),a<=127?store(r++,a):a<=2047?(store(r++,192|a>>>6),store(r++,128|63&a)):a<=65535?(store(r++,224|a>>>12),store(r++,128|a>>>6&63),store(r++,128|63&a)):a<=2097151?(store(r++,240|a>>>18),store(r++,128|a>>>12&63),store(r++,128|a>>>6&63),store(r++,128|63&a)):a<=67108863?(store(r++,248|a>>>24),store(r++,128|a>>>18&63),store(r++,128|a>>>12&63),store(r++,128|a>>>6&63),store(r++,128|63&a)):(store(r++,252|a>>>30),store(r++,128|a>>>24&63),store(r++,128|a>>>18&63),store(r++,128|a>>>12&63),store(r++,128|a>>>6&63),store(r++,128|63&a))}return store(r,0),t}function d(e){return load(e)|load(e+1)<<8|load(e+2)<<16|load(e+3)<<24}function _(e){if(!e)return null;for(var t,r,n,i,a,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++),t=248==(252&t)?(3&t)<<24|r<<18|n<<12|i<<6|a:(1&t)<<30|r<<24|n<<18|i<<12|a<<6|63&load(e++))),s.push(t)):s.push((31&t)<<6|r)):s.push(t);return String.fromCodePoints(s)}t.Relooper=c,t.readString=_;var y=function(){return function(){}}();t.BinaryModule=y},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=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])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var a=r(0),s=r(6);t.Token=s.Token,t.Range=s.Range;var o,c=r(1);!function(e){e[e.SOURCE=0]="SOURCE",e[e.TYPE=1]="TYPE",e[e.TYPEPARAMETER=2]="TYPEPARAMETER",e[e.PARAMETER=3]="PARAMETER",e[e.SIGNATURE=4]="SIGNATURE",e[e.IDENTIFIER=5]="IDENTIFIER",e[e.ASSERTION=6]="ASSERTION",e[e.BINARY=7]="BINARY",e[e.CALL=8]="CALL",e[e.COMMA=9]="COMMA",e[e.ELEMENTACCESS=10]="ELEMENTACCESS",e[e.FALSE=11]="FALSE",e[e.FUNCTION=12]="FUNCTION",e[e.LITERAL=13]="LITERAL",e[e.NEW=14]="NEW",e[e.NULL=15]="NULL",e[e.PARENTHESIZED=16]="PARENTHESIZED",e[e.PROPERTYACCESS=17]="PROPERTYACCESS",e[e.TERNARY=18]="TERNARY",e[e.SUPER=19]="SUPER",e[e.THIS=20]="THIS",e[e.TRUE=21]="TRUE",e[e.CONSTRUCTOR=22]="CONSTRUCTOR",e[e.UNARYPOSTFIX=23]="UNARYPOSTFIX",e[e.UNARYPREFIX=24]="UNARYPREFIX",e[e.BLOCK=25]="BLOCK",e[e.BREAK=26]="BREAK",e[e.CONTINUE=27]="CONTINUE",e[e.DO=28]="DO",e[e.EMPTY=29]="EMPTY",e[e.EXPORT=30]="EXPORT",e[e.EXPORTIMPORT=31]="EXPORTIMPORT",e[e.EXPRESSION=32]="EXPRESSION",e[e.FOR=33]="FOR",e[e.IF=34]="IF",e[e.IMPORT=35]="IMPORT",e[e.RETURN=36]="RETURN",e[e.SWITCH=37]="SWITCH",e[e.THROW=38]="THROW",e[e.TRY=39]="TRY",e[e.VARIABLE=40]="VARIABLE",e[e.VOID=41]="VOID",e[e.WHILE=42]="WHILE",e[e.CLASSDECLARATION=43]="CLASSDECLARATION",e[e.ENUMDECLARATION=44]="ENUMDECLARATION",e[e.ENUMVALUEDECLARATION=45]="ENUMVALUEDECLARATION",e[e.FIELDDECLARATION=46]="FIELDDECLARATION",e[e.FUNCTIONDECLARATION=47]="FUNCTIONDECLARATION",e[e.IMPORTDECLARATION=48]="IMPORTDECLARATION",e[e.INTERFACEDECLARATION=49]="INTERFACEDECLARATION",e[e.METHODDECLARATION=50]="METHODDECLARATION",e[e.NAMESPACEDECLARATION=51]="NAMESPACEDECLARATION",e[e.TYPEDECLARATION=52]="TYPEDECLARATION",e[e.VARIABLEDECLARATION=53]="VARIABLEDECLARATION",e[e.DECORATOR=54]="DECORATOR",e[e.EXPORTMEMBER=55]="EXPORTMEMBER",e[e.SWITCHCASE=56]="SWITCHCASE",e[e.COMMENT=57]="COMMENT"}(o=t.NodeKind||(t.NodeKind={}));var p=function(){function e(){this.parent=null,this.flags=a.CommonFlags.NONE}return e.prototype.is=function(e){return(this.flags&e)==e},e.prototype.isAny=function(e){return 0!=(this.flags&e)},e.prototype.set=function(e){this.flags|=e},e.createType=function(e,t,r,n){var i=new u;return i.range=n,i.name=e,e.parent=i,i.typeArguments=t,t&&xe(t,i),i.isNullable=r,i},e.createOmittedType=function(t){return e.createType(e.createIdentifierExpression("",t),null,!1,t)},e.createTypeParameter=function(e,t,r){var n=new h;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 d;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.createSignature=function(e,t,r,n,i){var a=new y;return a.range=i,a.parameterTypes=e,xe(e,a),a.returnType=t,t.parent=a,a.explicitThisType=r,r&&(r.parent=a),a.isNullable=n,a},e.createDecorator=function(e,t,r){var n=new m;return n.range=r,n.name=e,e.parent=n,n.arguments=t,t&&xe(t,n),n.decoratorKind=e.kind==o.IDENTIFIER?g(e.text):_.CUSTOM,n},e.createComment=function(e,t,r){var n=new T;return n.range=r,n.commentKind=t,n.text=e,n},e.createIdentifierExpression=function(e,t){var r=new I;return r.range=t,r.text=e,r},e.createEmptyIdentifierExpression=function(e){var t=new I;return t.range=e,t.text="",t},e.createArrayLiteralExpression=function(e,t){var r=new A;return r.range=t,r.elementExpressions=e,function(e,t){for(var r=0,n=e.length;r<n;++r){var i=e[r];i&&(i.parent=t)}}(e,r),r},e.createAssertionExpression=function(e,t,r,n){var i=new N;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 C;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 S;return i.range=n,i.expression=e,e.parent=i,i.typeArguments=t,t&&xe(t,i),i.arguments=r,xe(r,i),i},e.createCommaExpression=function(e,t){var r=new O;return r.range=t,r.expressions=e,xe(e,r),r},e.createConstructorExpression=function(e){var t=new L;return t.range=e,t},e.createElementAccessExpression=function(e,t,r){var n=new b;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 k;return r.range=t,r.value=e,r},e.createFunctionExpression=function(e){var t=new x;return t.flags=e.flags&a.CommonFlags.ARROW,t.range=e.range,t.declaration=e,t},e.createIntegerLiteralExpression=function(e,t){var r=new R;return r.range=t,r.value=e,r},e.createNewExpression=function(e,t,r,n){var i=new B;return i.range=n,i.expression=e,e.parent=i,i.typeArguments=t,t&&xe(t,i),i.arguments=r,xe(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 F;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 w;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 M;return r.range=t,r.value=e,r},e.createSuperExpression=function(e){var t=new G;return t.range=e,t},e.createThisExpression=function(e){var t=new K;return t.range=e,t},e.createTrueExpression=function(e){var t=new z;return t.range=e,t},e.createUnaryPostfixExpression=function(e,t,r){var n=new X;return n.range=r,n.operator=e,n.operand=t,t.parent=n,n},e.createUnaryPrefixExpression=function(e,t,r){var n=new W;return n.range=r,n.operator=e,n.operand=t,t.parent=n,n},e.createBlockStatement=function(e,t){var r=new $;return r.range=t,r.statements=e,xe(e,r),r},e.createBreakStatement=function(e,t){var r=new J;return r.range=t,r.label=e,e&&(e.parent=r),r},e.createClassDeclaration=function(e,t,r,n,i,a,s,o){var c=new ee;return c.range=o,c.flags=s,c.name=e,e.parent=c,c.typeParameters=t,xe(t,c),c.extendsType=r,r&&(r.parent=c),c.implementsTypes=n,n&&xe(n,c),c.members=i,xe(i,c),c.decorators=a,a&&xe(a,c),c},e.createContinueStatement=function(e,t){var r=new te;return r.range=t,r.label=e,e&&(e.parent=r),r},e.createDoStatement=function(e,t,r){var n=new re;return n.range=r,n.statement=e,e.parent=n,n.condition=t,t.parent=n,n},e.createEmptyStatement=function(e){var t=new ne;return t.range=e,t},e.createEnumDeclaration=function(e,t,r,n,i){var a=new ie;return a.range=i,a.flags=n,a.name=e,e.parent=a,a.values=t,xe(t,a),a.decorators=r,r&&xe(r,a),a},e.createEnumValueDeclaration=function(e,t,r,n){var i=new ae;return i.range=n,i.flags=r,i.name=e,e.parent=i,i.value=t,t&&(t.parent=i),i},e.createExportStatement=function(e,t,r,n){var i=new ce;if(i.range=n,i.flags=r,i.members=e,xe(e,i),i.path=t,t){var a=c.normalizePath(t.value);t.value.startsWith(".")?i.normalizedPath=c.resolvePath(a,n.source.normalizedPath):i.normalizedPath=a,i.internalPath=ke(i.normalizedPath)}else i.normalizedPath=null,i.internalPath=null;return i},e.createExportImportStatement=function(e,t,r){var n=new se;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 oe;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 pe;return t.range=e.range,t.expression=e,e.parent=t,t},e.createIfStatement=function(e,t,r,n){var i=new de;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 ye;n.range=r,n.declarations=e,e&&xe(e,n),n.namespaceName=null,n.path=t;var i=c.normalizePath(t.value);return t.value.startsWith(".")?n.normalizedPath=c.resolvePath(i,r.source.normalizedPath):(i.startsWith(a.LIBRARY_PREFIX)||(i=a.LIBRARY_PREFIX+i),n.normalizedPath=i),n.internalPath=ke(n.normalizedPath),n},e.createImportStatementWithWildcard=function(e,t,r){var n=new ye;return n.range=r,n.declarations=null,n.namespaceName=e,n.path=t,n.normalizedPath=c.resolvePath(c.normalizePath(t.value),r.source.normalizedPath),n.internalPath=ke(n.normalizedPath),n},e.createImportDeclaration=function(e,t,r){var n=new _e;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,a,s){var o=new ge;return o.range=s,o.flags=a,o.name=e,e.parent=o,o.typeParameters=t,t&&xe(t,o),o.extendsType=r,r&&(r.parent=o),o.members=n,xe(n,o),o.decorators=i,i&&xe(i,o),o},e.createFieldDeclaration=function(e,t,r,n,i,a){var s=new le;return s.range=a,s.flags=i,s.name=e,e.parent=s,s.type=t,t&&(t.parent=s),s.initializer=r,r&&(r.parent=s),s.decorators=n,n&&xe(n,s),s},e.createForStatement=function(e,t,r,n,i){var a=new ue;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.createFunctionDeclaration=function(e,t,r,n,i,a,s){var o=new he;return o.range=s,o.flags=a,o.name=e,e.parent=o,o.typeParameters=t,t&&xe(t,o),o.signature=r,r.parent=o,o.body=n,n&&(n.parent=o),o.decorators=i,i&&xe(i,o),o},e.createMethodDeclaration=function(e,t,r,n,i,a,s){var o=new me;return o.range=s,o.flags=a,o.name=e,e.parent=o,o.typeParameters=t,t&&xe(t,o),o.signature=r,r.parent=o,o.body=n,n&&(n.parent=o),o.decorators=i,i&&xe(i,o),o},e.createNamespaceDeclaration=function(e,t,r,n,i){var a=new Te;return a.range=i,a.flags=n,a.name=e,e.parent=a,a.members=t,xe(t,a),a.decorators=r,r&&xe(r,a),a},e.createReturnStatement=function(e,t){var r=new Ee;return r.range=t,r.value=e,e&&(e.parent=r),r},e.createSwitchStatement=function(e,t,r){var n=new Ie;return n.range=r,n.condition=e,e.parent=n,n.cases=t,xe(t,n),n},e.createSwitchCase=function(e,t,r){var n=new fe;return n.range=r,n.label=e,e&&(e.parent=n),n.statements=t,xe(t,n),n},e.createThrowStatement=function(e,t){var r=new ve;return r.range=t,r.value=e,e.parent=r,r},e.createTryStatement=function(e,t,r,n,i){var a=new Ae;return a.range=i,a.statements=e,xe(e,a),a.catchVariable=t,t&&(t.parent=a),a.catchStatements=r,r&&xe(r,a),a.finallyStatements=n,n&&xe(n,a),a},e.createTypeDeclaration=function(e,t,r,n,i,a){var s=new Ne;return s.range=a,s.flags=i,s.name=e,e.parent=s,s.typeParameters=t,t&&xe(t,s),s.type=r,r.parent=s,s.decorators=n,n&&xe(n,s),s},e.createVariableStatement=function(e,t,r,n){var i=new Se;return i.range=n,i.flags=r,i.declarations=e,xe(e,i),i.decorators=t,t&&xe(t,i),i},e.createVariableDeclaration=function(e,t,r,n,i,a){var s=new Ce;return s.range=a,s.flags=i,s.name=e,e.parent=s,s.type=t,t&&(t.parent=s),s.initializer=r,r&&(r.parent=s),s.decorators=n,s},e.createVoidStatement=function(e,t){var r=new Oe;return r.range=t,r.expression=e,r},e.createWhileStatement=function(e,t,r){var n=new Le;return n.range=r,n.condition=e,e.parent=n,n.statement=t,t.parent=n,n},e}();t.Node=p;var l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(p);t.CommonTypeNode=l;var u=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.TYPE,t}return i(t,e),t}(l);t.TypeNode=u;var h=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.TYPEPARAMETER,t}return i(t,e),t}(p);t.TypeParameterNode=h,function(e){e[e.DEFAULT=0]="DEFAULT",e[e.OPTIONAL=1]="OPTIONAL",e[e.REST=2]="REST"}(t.ParameterKind||(t.ParameterKind={}));var d=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.PARAMETER,t.implicitFieldDeclaration=null,t}return i(t,e),t}(p);t.ParameterNode=d;var _,y=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.SIGNATURE,t}return i(t,e),t}(l);function g(e){switch(e){case"global":return _.GLOBAL;case"operator":return _.OPERATOR;case"unmanaged":return _.UNMANAGED;case"sealed":return _.SEALED;case"inline":return _.INLINE;default:return _.CUSTOM}}t.SignatureNode=y,function(e){e[e.CUSTOM=0]="CUSTOM",e[e.GLOBAL=1]="GLOBAL",e[e.OPERATOR=2]="OPERATOR",e[e.UNMANAGED=3]="UNMANAGED",e[e.SEALED=4]="SEALED",e[e.INLINE=5]="INLINE"}(_=t.DecoratorKind||(t.DecoratorKind={})),t.stringToDecoratorKind=g;var m=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.DECORATOR,t}return i(t,e),t}(p);t.DecoratorNode=m,function(e){e[e.LINE=0]="LINE",e[e.TRIPLE=1]="TRIPLE",e[e.BLOCK=2]="BLOCK"}(t.CommentKind||(t.CommentKind={}));var T=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.COMMENT,t}return i(t,e),t}(p);t.CommentNode=T;var E=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(p);t.Expression=E;var f,I=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.IDENTIFIER,t}return i(t,e),t}(E);t.IdentifierExpression=I,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"}(f=t.LiteralKind||(t.LiteralKind={}));var v=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.LITERAL,t}return i(t,e),t}(E);t.LiteralExpression=v;var A=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=f.ARRAY,t}return i(t,e),t}(v);t.ArrayLiteralExpression=A,function(e){e[e.PREFIX=0]="PREFIX",e[e.AS=1]="AS"}(t.AssertionKind||(t.AssertionKind={}));var N=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.ASSERTION,t}return i(t,e),t}(E);t.AssertionExpression=N;var C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.BINARY,t}return i(t,e),t}(E);t.BinaryExpression=C;var S=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.CALL,t}return i(t,e),t}(E);t.CallExpression=S;var O=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.COMMA,t}return i(t,e),t}(E);t.CommaExpression=O;var L=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.CONSTRUCTOR,t.text="constructor",t}return i(t,e),t}(I);t.ConstructorExpression=L;var b=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.ELEMENTACCESS,t}return i(t,e),t}(E);t.ElementAccessExpression=b;var k=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=f.FLOAT,t}return i(t,e),t}(v);t.FloatLiteralExpression=k;var x=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.FUNCTION,t}return i(t,e),t}(E);t.FunctionExpression=x;var R=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=f.INTEGER,t}return i(t,e),t}(v);t.IntegerLiteralExpression=R;var B=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.NEW,t}return i(t,e),t}(S);t.NewExpression=B;var U=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.NULL,t.text="null",t}return i(t,e),t}(I);t.NullExpression=U;var D=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.PARENTHESIZED,t}return i(t,e),t}(E);t.ParenthesizedExpression=D;var F=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.PROPERTYACCESS,t}return i(t,e),t}(E);t.PropertyAccessExpression=F;var P=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=f.REGEXP,t}return i(t,e),t}(v);t.RegexpLiteralExpression=P;var w=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.TERNARY,t}return i(t,e),t}(E);t.TernaryExpression=w;var M=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=f.STRING,t}return i(t,e),t}(v);t.StringLiteralExpression=M;var G=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.SUPER,t.text="super",t}return i(t,e),t}(I);t.SuperExpression=G;var K=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.THIS,t.text="this",t}return i(t,e),t}(I);t.ThisExpression=K;var z=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.TRUE,t.text="true",t}return i(t,e),t}(I);t.TrueExpression=z;var V=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.FALSE,t.text="false",t}return i(t,e),t}(I);t.FalseExpression=V;var H=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(E);t.UnaryExpression=H;var X=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.UNARYPOSTFIX,t}return i(t,e),t}(H);t.UnaryPostfixExpression=X;var W=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.UNARYPREFIX,t}return i(t,e),t}(H);t.UnaryPrefixExpression=W;var Y,Q=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(p);t.Statement=Q,function(e){e[e.DEFAULT=0]="DEFAULT",e[e.ENTRY=1]="ENTRY",e[e.LIBRARY=2]="LIBRARY"}(Y=t.SourceKind||(t.SourceKind={}));var q=function(e){function t(t,r,n){var i=e.call(this)||this;return i.kind=o.SOURCE,i.parent=null,i.tokenizer=null,i.debugInfoIndex=-1,i.sourceKind=n,i.normalizedPath=t,i.internalPath=ke(i.normalizedPath),i.statements=new Array,i.range=new s.Range(i,0,r.length),i.text=r,i}return i(t,e),Object.defineProperty(t.prototype,"isEntry",{get:function(){return this.sourceKind==Y.ENTRY},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isLibrary",{get:function(){return this.sourceKind==Y.LIBRARY},enumerable:!0,configurable:!0}),t}(p);t.Source=q;var j=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 i(t,e),Object.defineProperty(t.prototype,"programLevelInternalName",{get:function(){return this.cachedProgramLevelInternalName||(this.cachedProgramLevelInternalName=be(this,!0)),this.cachedProgramLevelInternalName},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fileLevelInternalName",{get:function(){return this.cachedFileLevelInternalName||(this.cachedFileLevelInternalName=be(this,!1)),this.cachedFileLevelInternalName},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isTopLevel",{get:function(){var e=this.parent;return!!e&&(!(e.kind==o.VARIABLE&&!(e=e.parent))&&e.kind==o.SOURCE)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isTopLevelExport",{get:function(){var e=this.parent;return!(!e||e.kind==o.VARIABLE&&!(e=e.parent))&&(e.kind==o.NAMESPACEDECLARATION?this.is(a.CommonFlags.EXPORT)&&e.isTopLevelExport:e.kind==o.CLASSDECLARATION?this.is(a.CommonFlags.STATIC)&&e.isTopLevelExport:e.kind==o.SOURCE&&this.is(a.CommonFlags.EXPORT))},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=j;var Z=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(j);t.VariableLikeDeclarationStatement=Z;var $=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.BLOCK,t}return i(t,e),t}(Q);t.BlockStatement=$;var J=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.BREAK,t}return i(t,e),t}(Q);t.BreakStatement=J;var ee=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.CLASSDECLARATION,t}return i(t,e),Object.defineProperty(t.prototype,"isGeneric",{get:function(){var e=this.typeParameters;return null!=e&&e.length>0},enumerable:!0,configurable:!0}),t}(j);t.ClassDeclaration=ee;var te=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.CONTINUE,t}return i(t,e),t}(Q);t.ContinueStatement=te;var re=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.DO,t}return i(t,e),t}(Q);t.DoStatement=re;var ne=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.EMPTY,t}return i(t,e),t}(Q);t.EmptyStatement=ne;var ie=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.ENUMDECLARATION,t}return i(t,e),t}(j);t.EnumDeclaration=ie;var ae=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.ENUMVALUEDECLARATION,t}return i(t,e),t}(j);t.EnumValueDeclaration=ae;var se=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.EXPORTIMPORT,t}return i(t,e),t}(p);t.ExportImportStatement=se;var oe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.EXPORTMEMBER,t}return i(t,e),t}(p);t.ExportMember=oe;var ce=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.EXPORT,t}return i(t,e),t}(Q);t.ExportStatement=ce;var pe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.EXPRESSION,t}return i(t,e),t}(Q);t.ExpressionStatement=pe;var le=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.FIELDDECLARATION,t.parameterIndex=-1,t}return i(t,e),t}(Z);t.FieldDeclaration=le;var ue=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.FOR,t}return i(t,e),t}(Q);t.ForStatement=ue;var he=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.FUNCTIONDECLARATION,t}return i(t,e),Object.defineProperty(t.prototype,"isGeneric",{get:function(){var e=this.typeParameters;return null!=e&&e.length>0},enumerable:!0,configurable:!0}),t}(j);t.FunctionDeclaration=he;var de=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.IF,t}return i(t,e),t}(Q);t.IfStatement=de;var _e=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.IMPORTDECLARATION,t}return i(t,e),t}(j);t.ImportDeclaration=_e;var ye=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.IMPORT,t}return i(t,e),t}(Q);t.ImportStatement=ye;var ge=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.INTERFACEDECLARATION,t}return i(t,e),t}(ee);t.InterfaceDeclaration=ge;var me=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.METHODDECLARATION,t}return i(t,e),t}(he);t.MethodDeclaration=me;var Te=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.NAMESPACEDECLARATION,t}return i(t,e),t}(j);t.NamespaceDeclaration=Te;var Ee=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.RETURN,t}return i(t,e),t}(Q);t.ReturnStatement=Ee;var fe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.SWITCHCASE,t}return i(t,e),t}(p);t.SwitchCase=fe;var Ie=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.SWITCH,t}return i(t,e),t}(Q);t.SwitchStatement=Ie;var ve=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.THROW,t}return i(t,e),t}(Q);t.ThrowStatement=ve;var Ae=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.TRY,t}return i(t,e),t}(Q);t.TryStatement=Ae;var Ne=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.TYPEDECLARATION,t}return i(t,e),t}(j);t.TypeDeclaration=Ne;var Ce=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.VARIABLEDECLARATION,t}return i(t,e),t}(Z);t.VariableDeclaration=Ce;var Se=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.VARIABLE,t}return i(t,e),t}(Q);t.VariableStatement=Se;var Oe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.VOID,t}return i(t,e),t}(Q);t.VoidStatement=Oe;var Le=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=o.WHILE,t}return i(t,e),t}(Q);function be(e,t){void 0===t&&(t=!1);var r=e.name.text,n=e.parent;return n&&(e.kind!=o.VARIABLEDECLARATION||n.kind!=o.VARIABLE||(n=n.parent))?n.kind==o.CLASSDECLARATION?be(n,t)+(e.is(a.CommonFlags.STATIC)?a.STATIC_DELIMITER:a.INSTANCE_DELIMITER)+r:n.kind==o.NAMESPACEDECLARATION||n.kind==o.ENUMDECLARATION?be(n,t)+a.STATIC_DELIMITER+r:t?r:e.range.source.internalPath+a.PATH_DELIMITER+r:r}function ke(e){return e.endsWith(".ts")&&(e=e.substring(0,e.length-3)),e}function xe(e,t){for(var r=0,n=e.length;r<n;++r)e[r].parent=t}t.WhileStatement=Le,t.hasDecorator=function(e,t){if(t)for(var r=0,n=t.length;r<n;++r){var i=t[r].name;if(i.kind==o.IDENTIFIER&&i.text==e)return!0}return!1},t.mangleInternalName=be,t.mangleInternalPath=ke},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";var n,i=this&&this.__extends||(n=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])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var a,s=r(2),o=r(4),c=r(1);function p(e){switch(e){case"abstract":return a.ABSTRACT;case"as":return a.AS;case"async":return a.ASYNC;case"await":return a.AWAIT;case"break":return a.BREAK;case"case":return a.CASE;case"catch":return a.CATCH;case"class":return a.CLASS;case"continue":return a.CONTINUE;case"const":return a.CONST;case"constructor":return a.CONSTRUCTOR;case"debugger":return a.DEBUGGER;case"declare":return a.DECLARE;case"default":return a.DEFAULT;case"delete":return a.DELETE;case"do":return a.DO;case"else":return a.ELSE;case"enum":return a.ENUM;case"export":return a.EXPORT;case"extends":return a.EXTENDS;case"false":return a.FALSE;case"finally":return a.FINALLY;case"for":return a.FOR;case"from":return a.FROM;case"function":return a.FUNCTION;case"get":return a.GET;case"if":return a.IF;case"implements":return a.IMPLEMENTS;case"import":return a.IMPORT;case"in":return a.IN;case"instanceof":return a.INSTANCEOF;case"interface":return a.INTERFACE;case"is":return a.IS;case"keyof":return a.KEYOF;case"let":return a.LET;case"module":return a.MODULE;case"namespace":return a.NAMESPACE;case"new":return a.NEW;case"null":return a.NULL;case"of":return a.OF;case"package":return a.PACKAGE;case"private":return a.PRIVATE;case"protected":return a.PROTECTED;case"public":return a.PUBLIC;case"readonly":return a.READONLY;case"return":return a.RETURN;case"set":return a.SET;case"static":return a.STATIC;case"super":return a.SUPER;case"switch":return a.SWITCH;case"this":return a.THIS;case"throw":return a.THROW;case"true":return a.TRUE;case"try":return a.TRY;case"type":return a.TYPE;case"typeof":return a.TYPEOF;case"var":return a.VAR;case"void":return a.VOID;case"while":return a.WHILE;case"with":return a.WITH;case"yield":return a.YIELD;default:return a.INVALID}}function l(e){switch(e){case a.ABSTRACT:case a.AS:case a.CONSTRUCTOR:case a.DECLARE:case a.DELETE:case a.FROM:case a.GET:case a.IS:case a.KEYOF:case a.MODULE:case a.NAMESPACE:case a.READONLY:case a.SET:case a.TYPE:return!0;default:return!1}}!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"}(a=t.Token||(t.Token={})),t.tokenFromKeyword=p,t.tokenIsAlsoIdentifier=l,t.operatorTokenToString=function(e){switch(e){case a.DELETE:return"delete";case a.IN:return"in";case a.INSTANCEOF:return"instanceof";case a.NEW:return"new";case a.TYPEOF:return"typeof";case a.VOID:return"void";case a.YIELD:return"yield";case a.DOT_DOT_DOT:return"...";case a.COMMA:return",";case a.LESSTHAN:return"<";case a.GREATERTHAN:return">";case a.LESSTHAN_EQUALS:return"<=";case a.GREATERTHAN_EQUALS:return">=";case a.EQUALS_EQUALS:return"==";case a.EXCLAMATION_EQUALS:return"!=";case a.EQUALS_EQUALS_EQUALS:return"===";case a.EXCLAMATION_EQUALS_EQUALS:return"!==";case a.PLUS:return"+";case a.MINUS:return"-";case a.ASTERISK_ASTERISK:return"**";case a.ASTERISK:return"*";case a.SLASH:return"/";case a.PERCENT:return"%";case a.PLUS_PLUS:return"++";case a.MINUS_MINUS:return"--";case a.LESSTHAN_LESSTHAN:return"<<";case a.GREATERTHAN_GREATERTHAN:return">>";case a.GREATERTHAN_GREATERTHAN_GREATERTHAN:return">>>";case a.AMPERSAND:return"&";case a.BAR:return"|";case a.CARET:return"^";case a.EXCLAMATION:return"!";case a.TILDE:return"~";case a.AMPERSAND_AMPERSAND:return"&&";case a.BAR_BAR:return"||";case a.EQUALS:return"=";case a.PLUS_EQUALS:return"+=";case a.MINUS_EQUALS:return"-=";case a.ASTERISK_EQUALS:return"*=";case a.ASTERISK_ASTERISK_EQUALS:return"**=";case a.SLASH_EQUALS:return"/=";case a.PERCENT_EQUALS:return"%=";case a.LESSTHAN_LESSTHAN_EQUALS:return"<<=";case a.GREATERTHAN_GREATERTHAN_EQUALS:return">>=";case a.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS:return">>>=";case a.AMPERSAND_EQUALS:return"&=";case a.BAR_EQUALS:return"|=";case a.CARET_EQUALS:return"^=";default:return assert(!1),""}};var u=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=1,r=this.start;r>=0;--r)10==e.charCodeAt(r)&&t++;return t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"column",{get:function(){for(var e=this.source.text,t=0,r=this.start-1;r>=0&&10!=e.charCodeAt(r);--r)++t;return t},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return this.source.text.substring(this.start,this.end)},e}();t.Range=u;var h=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.nextToken=-1,n.nextTokenPos=0,n.nextTokenOnNewLine=!1,n.onComment=null,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 i(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,a.EXCLAMATION_EQUALS_EQUALS):a.EXCLAMATION_EQUALS):a.EXCLAMATION;case 34:case 39:case 96:return a.STRINGLITERAL;case 37:return++this.pos,t>1&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,a.PERCENT_EQUALS):a.PERCENT;case 38:if(++this.pos,t>1&&this.pos<this.end){if(38==r.charCodeAt(this.pos))return++this.pos,a.AMPERSAND_AMPERSAND;if(61==r.charCodeAt(this.pos))return++this.pos,a.AMPERSAND_EQUALS}return a.AMPERSAND;case 40:return++this.pos,a.OPENPAREN;case 41:return++this.pos,a.CLOSEPAREN;case 42:if(++this.pos,t>1&&this.pos<this.end){if(61==r.charCodeAt(this.pos))return++this.pos,a.ASTERISK_EQUALS;if(42==r.charCodeAt(this.pos))return++this.pos,t>2&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,a.ASTERISK_ASTERISK_EQUALS):a.ASTERISK_ASTERISK}return a.ASTERISK;case 43:if(++this.pos,t>1&&this.pos<this.end){if(43==r.charCodeAt(this.pos))return++this.pos,a.PLUS_PLUS;if(61==r.charCodeAt(this.pos))return++this.pos,a.PLUS_EQUALS}return a.PLUS;case 44:return++this.pos,a.COMMA;case 45:if(++this.pos,t>1&&this.pos<this.end){if(45==r.charCodeAt(this.pos))return++this.pos,a.MINUS_MINUS;if(61==r.charCodeAt(this.pos))return++this.pos,a.MINUS_EQUALS}return a.MINUS;case 46:if(++this.pos,t>1&&this.pos<this.end){if(c.isDecimalDigit(r.charCodeAt(this.pos)))return--this.pos,a.FLOATLITERAL;if(t>2&&this.pos+1<this.end&&46==r.charCodeAt(this.pos)&&46==r.charCodeAt(this.pos+1))return this.pos+=2,a.DOT_DOT_DOT}return a.DOT;case 47:var i=this.pos;if(++this.pos,t>1&&this.pos<this.end){if(47==r.charCodeAt(this.pos)){var u=o.CommentKind.LINE;for(this.pos+1<this.end&&47==r.charCodeAt(this.pos+1)&&(++this.pos,u=o.CommentKind.TRIPLE);++this.pos<this.end;)if(10==r.charCodeAt(this.pos)){++this.pos;break}this.onComment&&this.onComment(u,r.substring(i,this.pos),this.range(i,this.pos));break}if(42==r.charCodeAt(this.pos)){for(var h=!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,h=!0;break}h?this.onComment&&this.onComment(o.CommentKind.BLOCK,r.substring(i,this.pos),this.range(i,this.pos)):this.error(s.DiagnosticCode._0_expected,this.range(this.pos),"*/");break}if(61==r.charCodeAt(this.pos))return++this.pos,a.SLASH_EQUALS}return a.SLASH;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.testInteger()?a.INTEGERLITERAL:a.FLOATLITERAL;case 58:return++this.pos,a.COLON;case 59:return++this.pos,a.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,a.LESSTHAN_LESSTHAN_EQUALS):a.LESSTHAN_LESSTHAN;if(61==r.charCodeAt(this.pos))return++this.pos,a.LESSTHAN_EQUALS}return a.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,a.EQUALS_EQUALS_EQUALS):a.EQUALS_EQUALS;if(62==r.charCodeAt(this.pos))return++this.pos,a.EQUALS_GREATERTHAN}return a.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,a.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS):a.GREATERTHAN_GREATERTHAN_GREATERTHAN;if(61==r.charCodeAt(this.pos))return++this.pos,a.GREATERTHAN_GREATERTHAN_EQUALS}return a.GREATERTHAN_GREATERTHAN}if(61==r.charCodeAt(this.pos))return++this.pos,a.GREATERTHAN_EQUALS}return a.GREATERTHAN;case 63:return++this.pos,a.QUESTION;case 91:return++this.pos,a.OPENBRACKET;case 93:return++this.pos,a.CLOSEBRACKET;case 94:return++this.pos,t>1&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,a.CARET_EQUALS):a.CARET;case 123:return++this.pos,a.OPENBRACE;case 124:if(++this.pos,t>1&&this.pos<this.end){if(124==r.charCodeAt(this.pos))return++this.pos,a.BAR_BAR;if(61==r.charCodeAt(this.pos))return++this.pos,a.BAR_EQUALS}return a.BAR;case 125:return++this.pos,a.CLOSEBRACE;case 126:return++this.pos,a.TILDE;case 64:return++this.pos,a.AT;default:if(c.isIdentifierStart(n)){if(c.isKeywordCharacter(n)){for(var d=this.pos;++this.pos<this.end&&c.isIdentifierPart(n=r.charCodeAt(this.pos));)if(!c.isKeywordCharacter(n))return this.pos=d,a.IDENTIFIER;var _=p(r.substring(d,this.pos));if(!(_==a.INVALID||e&&l(_)))return _;this.pos=d}return a.IDENTIFIER}if(c.isWhiteSpace(n)){++this.pos;break}return this.error(s.DiagnosticCode.Invalid_character,this.range(this.pos,this.pos+1)),++this.pos,a.INVALID}}return a.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),this.nextTokenPos=this.tokenPos,e)for(this.nextTokenOnNewLine=!1;--this.tokenPos>i;)if(c.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,i=i32.MAX_VALUE;switch(e){case a.GREATERTHAN:i=1}return this.token=this.unsafeNext(e==a.IDENTIFIER,i),this.token==e?(this.nextToken=-1,!0):(this.pos=t,this.token=r,this.tokenPos=n,!1)},t.prototype.mark=function(){var e;return _?(e=_,_=null):e=new d,e.pos=this.pos,e.token=this.token,e.tokenPos=this.tokenPos,e},t.prototype.discard=function(e){_=e},t.prototype.reset=function(e){this.pos=e.pos,this.token=e.token,this.tokenPos=e.tokenPos,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 u(this.source,e,t)},t.prototype.readIdentifier=function(){for(var e=this.source.text,t=this.pos;++this.pos<this.end&&c.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(s.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(c.isLineBreak(i)){n+=e.substring(r,this.pos),this.error(s.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(s.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(s.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(c.isLineBreak(n)){this.error(s.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(!c.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(s.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(c.isOctalDigit(e.charCodeAt(this.pos+1))){var t=this.pos;++this.pos;var r=this.readOctalInteger();return this.error(s.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(s.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(s.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(s.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 a=e.charCodeAt(this.pos);if(48==a)r=i64_mul(r,n);else{if(49!=a)break;r=i64_add(i64_mul(r,n),i)}++this.pos}return this.pos==t&&this.error(s.DiagnosticCode.Binary_digit_expected,this.range(t)),r},t.prototype.readFloat=function(){return this.readDecimalFloat()},t.prototype.readDecimalFloat=function(){for(var e=this.pos,t=this.source.text;this.pos<this.end&&c.isDecimalDigit(t.charCodeAt(this.pos));)++this.pos;if(this.pos<this.end&&46==t.charCodeAt(this.pos))for(++this.pos;this.pos<this.end&&c.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))&&c.isDecimalDigit(t.charCodeAt(this.pos+1))&&++this.pos;this.pos<this.end&&c.isDecimalDigit(t.charCodeAt(this.pos));)++this.pos}return parseFloat(t.substring(e,this.pos))},t.prototype.readHexFloat=function(){throw new Error("not implemented")},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(s.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(s.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(s.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(s.DiagnosticCode.Unexpected_end_of_text,this.range(e,this.end)),n=!0):125==i.charCodeAt(this.pos)?++this.pos:(this.error(s.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}(s.DiagnosticEmitter);t.Tokenizer=h;var d=function(){return function(){}}();t.State=d;var _=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(3);!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.POINTER=16]="POINTER",e[e.SHORT=32]="SHORT",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 i=function(){function e(e,t,r){this.cachedNullableType=null,this.kind=e,this.flags=t,this.size=r,this.byteSize=ceil(r/8),this.classReference=null,this.signatureReference=null,this.nonNullableType=this}return Object.defineProperty(e.prototype,"intType",{get:function(){switch(this.kind){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:return this;case 10:default:return e.i32}},enumerable:!0,configurable:!0}),e.prototype.computeSmallIntegerShift=function(e){return e.size-this.size},e.prototype.computeSmallIntegerMask=function(e){var t=this.is(2)?this.size:this.size-1;return-1>>>e.size-t},e.prototype.is=function(e){return(this.flags&e)==e},e.prototype.isAny=function(e){return 0!=(this.flags&e)},e.prototype.asClass=function(t){assert(9==this.kind&&!this.classReference);var r=new e(this.kind,-129&this.flags|256,this.size);return r.classReference=t,r},e.prototype.asFunction=function(t){assert(7==this.kind&&!this.signatureReference);var r=new e(this.kind,-129&this.flags|256,this.size);return r.signatureReference=t,r},e.prototype.asNullable=function(){return assert(this.is(256)),this.cachedNullableType||(assert(!this.is(512)),this.cachedNullableType=new e(this.kind,512|this.flags,this.size),this.cachedNullableType.classReference=this.classReference,this.cachedNullableType.signatureReference=this.signatureReference),this.cachedNullableType},e.prototype.isAssignableTo=function(e,t){var r,n,i,a;if(void 0===t&&(t=!1),this.is(256)){if(e.is(256))if(r=this.classReference){if(n=e.classReference)return r.isAssignableTo(n)}else if((i=this.signatureReference)&&(a=e.signatureReference))return i.isAssignableTo(a)}else if(!e.is(256))if(this.is(4))if(e.is(4)){if(!t||this.is(1)==e.is(1))return this.size<=e.size}else{if(11==e.kind)return this.size<=23;if(12==e.kind)return this.size<=52}else if(this.is(8)&&e.is(8))return this.size<=e.size;return!1},e.commonCompatible=function(e,t,r){return t.isAssignableTo(e,r)?e:e.isAssignableTo(t,r)?t:null},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:var t=this.signatureReference;return e||!t?"u32":t.toString(!0);case 8:return"u64";case 9:var r=this.classReference;return e||!r?"usize":r.toString();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 n.NativeType.I32;case 3:case 8:return n.NativeType.I64;case 4:case 9:return 64==this.size?n.NativeType.I64:n.NativeType.I32;case 11:return n.NativeType.F32;case 12:return n.NativeType.F64;case 13:return n.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=i,t.typesToNativeTypes=function(e){for(var t=e.length,r=new Array(t),n=0;n<t;++n)r[n]=e[n].toNativeType();return r},t.typesToString=function(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(",")};var a=function(){function e(e,t,r){void 0===e&&(e=null),void 0===t&&(t=null),void 0===r&&(r=null),this.cachedFunctionTarget=null,this.parameterTypes=e||[],this.parameterNames=null,this.requiredParameters=0,this.returnType=t||i.void,this.thisType=r,this.hasRest=!1,this.type=i.u32.asFunction(this)}return e.prototype.getParameterName=function(e){var t=this.parameterNames;return t&&t.length>e?t[e]:o(e)},e.prototype.isAssignableTo=function(e){var t=this.thisType,r=e.thisType;if(t){if(!r||!t.isAssignableTo(r))return!1}else if(r)return!1;if(this.hasRest!=e.hasRest)return!1;var n=this.parameterTypes,i=e.parameterTypes,a=n.length;if(a!=i.length)return!1;for(var s=0;s<a;++s){var o=n[s],c=i[s];if(!o.isAssignableTo(c))return!1}var p=this.returnType,l=e.returnType;return p==l||p.isAssignableTo(l)},e.makeSignatureString=function(e,t,r){void 0===r&&(r=null);var n=[];if(r&&n.push(r.toSignatureString()),e)for(var i=0,a=e.length;i<a;++i)n.push(e[i].toSignatureString());return n.push(t.toSignatureString()),n.join("")},e.prototype.toSignatureString=function(){return e.makeSignatureString(this.parameterTypes,this.returnType,this.thisType)},e.prototype.toString=function(e){void 0===e&&(e=!1);var t=new Array;t.push("(");var r=0,n=this.thisType;n&&e&&(t.push("this: "),t.push(n.toString()),r=1);var i=this.parameterTypes,a=i.length;if(a)for(var s=this.parameterNames,c=s?s.length:0,p=this.requiredParameters,l=this.hasRest?a-1:-1,u=0;u<a;++u,++r)r&&t.push(", "),u==l&&t.push("..."),u<c?t.push(s[u]):t.push(o(u)),u>=p&&u!=l?t.push("?: "):t.push(": "),t.push(i[u].toString());return t.push(") => "),t.push(this.returnType.toString()),t.join("")},e}();t.Signature=a;var s=null;function o(e){s||(s=[]);for(var t=s.length;t<=e;++t)s.push("arg$"+t.toString(10));return s[e-1]}t.getDefaultParameterName=o},function(e,t,r){"use strict";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_requires_an_explicit_cast=200]="Conversion_from_type_0_to_1_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.Unmanaged_classes_cannot_extend_managed_classes_and_vice_versa=207]="Unmanaged_classes_cannot_extend_managed_classes_and_vice_versa",e[e.Unmanaged_classes_cannot_implement_interfaces=208]="Unmanaged_classes_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.Class_0_is_sealed_and_cannot_be_extended=211]="Class_0_is_sealed_and_cannot_be_extended",e[e.Decorator_0_is_not_valid_here=212]="Decorator_0_is_not_valid_here",e[e.Duplicate_decorator=213]="Duplicate_decorator",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.A_declare_modifier_cannot_be_used_in_an_already_ambient_context=1038]="A_declare_modifier_cannot_be_used_in_an_already_ambient_context",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.Interface_declaration_cannot_have_implements_clause=1176]="Interface_declaration_cannot_have_implements_clause",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.A_parameter_property_cannot_be_declared_using_a_rest_parameter=1317]="A_parameter_property_cannot_be_declared_using_a_rest_parameter",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.Operator_0_cannot_be_applied_to_types_1_and_2=2365]="Operator_0_cannot_be_applied_to_types_1_and_2",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.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local=2395]="Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local",e[e.Type_0_has_no_property_1=2460]="Type_0_has_no_property_1",e[e.The_0_operator_cannot_be_applied_to_type_1=2469]="The_0_operator_cannot_be_applied_to_type_1",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=function(e){switch(e){case 100:return"Operation not supported.";case 101:return"Operation is unsafe.";case 200:return"Conversion from type '{0}' to '{1}' 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"Unmanaged classes cannot extend managed classes and vice-versa.";case 208:return"Unmanaged classes cannot implement interfaces.";case 209:return"Invalid regular expression flags.";case 210:return"Implementation '{0}' must match the signature '{1}'.";case 211:return"Class '{0}' is sealed and cannot be extended.";case 212:return"Decorator '{0}' is not valid here.";case 213:return"Duplicate decorator.";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 1038:return"A 'declare' modifier cannot be used in an already ambient context.";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 1176:return"Interface declaration cannot have 'implements' clause.";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 1317:return"A parameter property cannot be declared using a rest parameter.";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 2365:return"Operator '{0}' cannot be applied to types '{1}' and '{2}'.";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 2395:return"Individual declarations in merged declaration '{0}' must be all exported or all local.";case 2460:return"Type '{0}' has no property '{1}'.";case 2469:return"The '{0}' operator cannot be applied to type '{1}'.";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""}}},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=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])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),a=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 s,o=r(21),c=r(2),p=r(3),l=r(0),u=r(6),h=r(4),d=r(7),_=r(1);!function(e){e[e.WASM32=0]="WASM32",e[e.WASM64=1]="WASM64"}(s=t.Target||(t.Target={}));var y=function(){function e(){this.target=s.WASM32,this.noTreeShaking=!1,this.noAssert=!1,this.noMemory=!1,this.importMemory=!1,this.importTable=!1,this.memoryBase=0,this.sourceMap=!1,this.globalAliases=null,this.features=0}return Object.defineProperty(e.prototype,"isWasm64",{get:function(){return this.target==s.WASM64},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usizeType",{get:function(){return this.target==s.WASM64?d.Type.usize64:d.Type.usize32},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isizeType",{get:function(){return this.target==s.WASM64?d.Type.isize64:d.Type.isize32},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nativeSizeType",{get:function(){return this.target==s.WASM64?p.NativeType.I64:p.NativeType.I32},enumerable:!0,configurable:!0}),e.prototype.hasFeature=function(e){return 0!=(this.features&e)},e}();t.Options=y,function(e){e[e.NONE=0]="NONE",e[e.SIGNEXT=1]="SIGNEXT"}(t.Feature||(t.Feature={})),function(e){e[e.NONE=0]="NONE",e[e.IMPLICIT=1]="IMPLICIT",e[e.EXPLICIT=2]="EXPLICIT"}(t.ConversionKind||(t.ConversionKind={})),function(e){e[e.NONE=0]="NONE",e[e.WRAP=1]="WRAP"}(t.WrapMode||(t.WrapMode={}));var g=function(e){function t(t,r){void 0===r&&(r=null);var n=e.call(this,t.diagnostics)||this;return n.outerFunction=null,n.currentEnum=null,n.currentType=d.Type.void,n.startFunctionBody=[],n.memorySegments=[],n.stringSegments=new Map,n.functionTable=[],n.argcVar=0,n.argcSet=0,n.f32ModInstance=null,n.f64ModInstance=null,n.f32PowInstance=null,n.f64PowInstance=null,n.program=t,r||(r=new y),n.options=r,n.memoryOffset=i64_new(max(r.memoryBase,r.usizeType.byteSize)),n.module=p.Module.create(),n}return i(t,e),t.compile=function(e,r){return void 0===r&&(r=null),new t(e,r).compile()},t.prototype.compile=function(){var e=this.options,t=this.module,r=this.program;r.initialize(e);var n=assert(r.elementsLookup.get("start"));assert(n.kind==l.ElementKind.FUNCTION_PROTOTYPE);var i=new l.Function(n,n.internalName,new d.Signature([],d.Type.void));this.startFunction=i,this.currentFunction=i;for(var a=r.sources,s=0,o=a.length;s<o;++s)a[s].isEntry&&this.compileSource(a[s]);var c=this.startFunctionBody;if(c.length){var u=i.signature,h=t.addFunction(i.internalName,this.ensureFunctionType(u.parameterTypes,u.returnType,u.thisType),d.typesToNativeTypes(i.additionalLocals),t.createBlock(null,c));i.finalize(t,h),t.setStart(h)}if(!e.noMemory){var _=this.memoryOffset;_=i64_align(_,e.usizeType.byteSize),this.memoryOffset=_,e.isWasm64?t.addGlobal("HEAP_BASE",p.NativeType.I64,!1,t.createI64(i64_low(_),i64_high(_))):t.addGlobal("HEAP_BASE",p.NativeType.I32,!1,t.createI32(i64_low(_)));var y=i64_shr_u(i64_align(_,65536),i64_new(16,0));t.setMemory(i64_low(y),this.options.isWasm64?p.Module.MAX_MEMORY_WASM64:p.Module.MAX_MEMORY_WASM32,this.memorySegments,e.target,"memory")}e.importMemory&&t.addMemoryImport("0","env","memory");var g=this.functionTable,m=g.length,T=!1;if(m){var E=new Array(m);for(s=0;s<m;++s)E[s]=g[s].ref;t.setFunctionTable(E),t.addTableExport("0","table"),T=!0}return e.importTable&&(t.addTableImport("0","env","table"),T||t.addTableExport("0","table")),t},t.prototype.compileSourceByPath=function(e,t){var r=this.program.lookupSourceByPath(e);r?this.compileSource(r):this.error(c.DiagnosticCode.File_0_not_found,t.range,e)},t.prototype.compileSource=function(e){if(!e.is(l.CommonFlags.COMPILED)){e.set(l.CommonFlags.COMPILED);for(var t=this.options.noTreeShaking,r=e.isEntry,n=this.startFunction,i=this.startFunctionBody,a=e.statements,s=0,o=a.length;s<o;++s){var c=a[s];switch(c.kind){case h.NodeKind.CLASSDECLARATION:(t||r&&c.is(l.CommonFlags.EXPORT))&&!c.isGeneric&&this.compileClassDeclaration(c,[]);break;case h.NodeKind.INTERFACEDECLARATION:break;case h.NodeKind.ENUMDECLARATION:(t||r&&c.is(l.CommonFlags.EXPORT))&&this.compileEnumDeclaration(c);break;case h.NodeKind.FUNCTIONDECLARATION:(t||r&&c.is(l.CommonFlags.EXPORT))&&!c.isGeneric&&this.compileFunctionDeclaration(c,[]);break;case h.NodeKind.IMPORT:this.compileSourceByPath(c.normalizedPath,c.path);break;case h.NodeKind.NAMESPACEDECLARATION:(t||r&&c.is(l.CommonFlags.EXPORT))&&this.compileNamespaceDeclaration(c);break;case h.NodeKind.VARIABLE:var p=this.compileVariableStatement(c);p&&i.push(p);break;case h.NodeKind.EXPORT:null!=c.normalizedPath&&this.compileSourceByPath(c.normalizedPath,c.path),(t||r)&&this.compileExportStatement(c);break;default:var u=this.currentFunction;this.currentFunction=n,i.push(this.compileStatement(c)),this.currentFunction=u}}}},t.prototype.compileGlobalDeclaration=function(e){var t=assert(this.program.elementsLookup.get(e.fileLevelInternalName));return assert(t.kind==l.ElementKind.GLOBAL),this.compileGlobal(t)?t:null},t.prototype.compileGlobal=function(e){if(e.is(l.CommonFlags.COMPILED))return!0;e.set(l.CommonFlags.COMPILED);var t=this.module,r=e.declaration,n=0;if(e.type==d.Type.void)if(r)if(r.type){var i=this.program.resolveType(r.type);if(!i)return!1;if(i==d.Type.void)return this.error(c.DiagnosticCode.Type_expected,r.type.range),!1;e.type=i}else{if(!r.initializer)return this.error(c.DiagnosticCode.Type_expected,r.name.range.atEnd),!1;if(n=this.compileExpression(r.initializer,d.Type.void,0,1),this.currentType==d.Type.void)return this.error(c.DiagnosticCode.Type_0_is_not_assignable_to_type_1,r.initializer.range,this.currentType.toString(),"<auto>"),!1;e.type=this.currentType}else assert(!1);if(e.is(l.CommonFlags.AMBIENT|l.CommonFlags.BUILTIN))return!0;var a=e.type.toNativeType(),s=e.isAny(l.CommonFlags.CONST)||e.is(l.CommonFlags.STATIC|l.CommonFlags.READONLY);if(e.is(l.CommonFlags.AMBIENT))return s?(e.set(l.CommonFlags.MODULE_IMPORT),t.addGlobalImport(e.internalName,e.parent?e.parent.simpleName:"env",e.simpleName,a),e.set(l.CommonFlags.COMPILED),!0):(this.error(c.DiagnosticCode.Operation_not_supported,assert(r).range),!1);var o=!1;e.is(l.CommonFlags.INLINED)?n=this.compileInlineConstant(e,e.type,!0):r&&r.initializer?(n||(n=this.compileExpression(r.initializer,e.type,1,1)),p.getExpressionId(n)!=p.ExpressionId.Const&&(s?(n=this.precomputeExpressionRef(n),p.getExpressionId(n)!=p.ExpressionId.Const&&(this.warning(c.DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable,r.range),o=!0)):o=!0)):n=e.type.toNativeZero(t);var u=e.internalName;if(o)t.addGlobal(u,a,!0,e.type.toNativeZero(t)),this.startFunctionBody.push(t.createSetGlobal(u,n));else if(s){switch(p.getExpressionType(n)){case p.NativeType.I32:e.constantValueKind=1,e.constantIntegerValue=i64_new(p.getConstValueI32(n),0);break;case p.NativeType.I64:e.constantValueKind=1,e.constantIntegerValue=i64_new(p.getConstValueI64Low(n),p.getConstValueI64High(n));break;case p.NativeType.F32:e.constantValueKind=2,e.constantFloatValue=p.getConstValueF32(n);break;case p.NativeType.F64:e.constantValueKind=2,e.constantFloatValue=p.getConstValueF64(n);break;default:return assert(!1),!1}e.set(l.CommonFlags.INLINED),e.is(l.CommonFlags.MODULE_EXPORT)?(t.addGlobal(u,a,!1,n),t.addGlobalExport(u,m(e))):r&&r.isTopLevel&&t.addGlobal(u,a,!1,n)}else t.addGlobal(u,a,!s,n);return!0},t.prototype.compileEnumDeclaration=function(e){var t=assert(this.program.elementsLookup.get(e.fileLevelInternalName));return assert(t.kind==l.ElementKind.ENUM),this.compileEnum(t)?t:null},t.prototype.compileEnum=function(e){if(e.is(l.CommonFlags.COMPILED))return!0;e.set(l.CommonFlags.COMPILED);var t=this.module;this.currentEnum=e;var r,n,i=null;if(e.members)try{for(var s=a(e.members.values()),o=s.next();!o.done;o=s.next()){var u=o.value;if(u.kind==l.ElementKind.ENUMVALUE){var h=!1,_=u,y=_.declaration;if(_.set(l.CommonFlags.COMPILED),_.is(l.CommonFlags.INLINED))e.declaration.isTopLevelExport&&t.addGlobal(_.internalName,p.NativeType.I32,!1,t.createI32(_.constantValue));else{var g=void 0;y.value?(g=this.compileExpression(y.value,d.Type.i32,1,0),p.getExpressionId(g)!=p.ExpressionId.Const&&(g=this.precomputeExpressionRef(g),p.getExpressionId(g)!=p.ExpressionId.Const&&(e.is(l.CommonFlags.CONST)&&this.warning(c.DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable,y.range),h=!0))):null==i?g=t.createI32(0):i.is(l.CommonFlags.INLINED)?g=t.createI32(i.constantValue+1):(g=t.createBinary(p.BinaryOp.AddI32,t.createGetGlobal(i.internalName,p.NativeType.I32),t.createI32(1)),e.is(l.CommonFlags.CONST)&&this.warning(c.DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable,y.range),h=!0),h?(t.addGlobal(_.internalName,p.NativeType.I32,!0,t.createI32(0)),this.startFunctionBody.push(t.createSetGlobal(_.internalName,g))):(t.addGlobal(_.internalName,p.NativeType.I32,!1,g),p.getExpressionType(g)==p.NativeType.I32?(_.constantValue=p.getConstValueI32(g),_.set(l.CommonFlags.INLINED)):(assert(!1),_.constantValue=0))}i=_,e.is(l.CommonFlags.MODULE_EXPORT)&&(u.is(l.CommonFlags.INLINED)?t.addGlobalExport(u.internalName,m(u)):y&&this.warning(c.DiagnosticCode.Cannot_export_a_mutable_global,y.range))}}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return this.currentEnum=null,!0},t.prototype.compileFunctionDeclaration=function(e,t,r){void 0===r&&(r=null);var n=assert(this.program.elementsLookup.get(e.fileLevelInternalName));return assert(n.kind==l.ElementKind.FUNCTION_PROTOTYPE),this.compileFunctionUsingTypeArguments(n,t,r,null,n.declaration.name)},t.prototype.compileFunctionUsingTypeArguments=function(e,t,r,n,i){var a=e.resolveUsingTypeArguments(t,r,i);return a?(a.outerScope=n,this.compileFunction(a)?a:null):null},t.prototype.ensureFunctionType=function(e,t,r){void 0===r&&(r=null);var n,i=e?e.length:0,a=0;if(r?((n=new Array(1+i))[0]=r.toNativeType(),a=1):n=new Array(i),e)for(var s=0;s<i;++s,++a)n[a]=e[s].toNativeType();var o=t.toNativeType(),c=this.module,p=c.getFunctionTypeBySignature(o,n);if(!p){var l=d.Signature.makeSignatureString(e,t,r);p=c.addFunctionType(l,o,n)}return p},t.prototype.compileFunction=function(e){if(e.is(l.CommonFlags.COMPILED))return!0;assert(!e.is(l.CommonFlags.AMBIENT|l.CommonFlags.BUILTIN)||"abort"==e.internalName),e.set(l.CommonFlags.COMPILED);var t,r=e.prototype.declaration,n=r.body;n?e.is(l.CommonFlags.AMBIENT)&&this.error(c.DiagnosticCode.An_implementation_cannot_be_declared_in_ambient_contexts,r.name.range):e.is(l.CommonFlags.AMBIENT)||this.error(c.DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration,r.name.range);var i=e.signature,a=this.ensureFunctionType(i.parameterTypes,i.returnType,i.thisType),s=this.module;if(n){var o=e.is(l.CommonFlags.CONSTRUCTOR),p=e.signature.returnType,u=this.currentFunction;this.currentFunction=e;var _=e.flow,y=void 0;if(n.kind==h.NodeKind.EXPRESSION)assert(!e.isAny(l.CommonFlags.CONSTRUCTOR|l.CommonFlags.GET|l.CommonFlags.SET)),assert(e.is(l.CommonFlags.ARROW)),y=this.compileExpression(n.expression,p,1,0),_.set(1),_.canOverflow(y,p)||_.set(4096),_.finalize();else if(assert(n.kind==h.NodeKind.BLOCK),y=this.compileStatement(n),_.finalize(),o){var g=this.options.nativeSizeType;if(assert(e.is(l.CommonFlags.INSTANCE)),!_.is(1))if(_.is(16))y=s.createBlock(null,[y,s.createGetLocal(0,g)],g);else{var T=assert(e.parent);assert(T.kind==l.ElementKind.CLASS),y=s.createBlock(null,[y,s.createTeeLocal(0,this.makeConditionalAllocate(T,r.name))],g)}}else p==d.Type.void||_.is(1)||this.error(c.DiagnosticCode.A_function_whose_declared_type_is_not_void_must_return_a_value,r.signature.returnType.range);this.currentFunction=u,t=s.addFunction(e.internalName,a,d.typesToNativeTypes(e.additionalLocals),y)}else{e.set(l.CommonFlags.MODULE_IMPORT);T=e.prototype.parent;t=s.addFunctionImport(e.internalName,T?T.simpleName:"env",e.simpleName,a)}return e.is(l.CommonFlags.MODULE_EXPORT)&&(i.requiredParameters<i.parameterTypes.length&&(e=this.ensureTrampoline(e),this.ensureArgcSet()),s.addFunctionExport(e.internalName,m(e))),e.finalize(s,t),!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 h.NodeKind.CLASSDECLARATION:!r&&!a.is(l.CommonFlags.EXPORT)||a.isGeneric||this.compileClassDeclaration(a,[]);break;case h.NodeKind.INTERFACEDECLARATION:!r&&!a.is(l.CommonFlags.EXPORT)||a.isGeneric||this.compileInterfaceDeclaration(a,[]);break;case h.NodeKind.ENUMDECLARATION:(r||a.is(l.CommonFlags.EXPORT))&&this.compileEnumDeclaration(a);break;case h.NodeKind.FUNCTIONDECLARATION:!r&&!a.is(l.CommonFlags.EXPORT)||a.isGeneric||this.compileFunctionDeclaration(a,[]);break;case h.NodeKind.NAMESPACEDECLARATION:(r||a.is(l.CommonFlags.EXPORT))&&this.compileNamespaceDeclaration(a);break;case h.NodeKind.VARIABLE:if(r||a.is(l.CommonFlags.EXPORT)){var s=this.compileVariableStatement(a,!0);s&&this.startFunctionBody.push(s)}break;default:assert(!1)}}},t.prototype.compileNamespace=function(e){if(e.members){var t,r,n=this.options.noTreeShaking;try{for(var i=a(e.members.values()),s=i.next();!s.done;s=i.next()){var o=s.value;switch(o.kind){case l.ElementKind.CLASS_PROTOTYPE:!n&&!o.is(l.CommonFlags.EXPORT)||o.is(l.CommonFlags.GENERIC)||this.compileClassUsingTypeArguments(o,[]);break;case l.ElementKind.ENUM:this.compileEnum(o);break;case l.ElementKind.FUNCTION_PROTOTYPE:!n&&!o.is(l.CommonFlags.EXPORT)||o.is(l.CommonFlags.GENERIC)||this.compileFunctionUsingTypeArguments(o,[],null,null,o.declaration.name);break;case l.ElementKind.GLOBAL:this.compileGlobal(o);break;case l.ElementKind.NAMESPACE:this.compileNamespace(o)}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}}},t.prototype.compileExportStatement=function(e){for(var t=this.module,r=this.program.fileLevelExports,n=e.members,i=0,a=n.length;i<a;++i){var s=n[i],o=e.range.source.internalPath+l.PATH_DELIMITER+s.externalName.text,p=r.get(o);if(p)switch(p.kind){case l.ElementKind.CLASS_PROTOTYPE:p.is(l.CommonFlags.GENERIC)||this.compileClassUsingTypeArguments(p,[]);break;case l.ElementKind.ENUM:this.compileEnum(p);break;case l.ElementKind.FUNCTION_PROTOTYPE:if(!p.is(l.CommonFlags.GENERIC)&&e.range.source.isEntry){var u=this.compileFunctionUsingTypeArguments(p,[],null,null,p.declaration.name);if(u){var h=u.prototype.declaration;h&&h.needsExplicitExport(s)&&t.addFunctionExport(u.internalName,s.externalName.text)}}break;case l.ElementKind.GLOBAL:if(this.compileGlobal(p)&&e.range.source.isEntry){var d=p.declaration;d&&d.needsExplicitExport(s)&&(p.is(l.CommonFlags.INLINED)?t.addGlobalExport(p.internalName,s.externalName.text):this.warning(c.DiagnosticCode.Cannot_export_a_mutable_global,s.range))}break;case l.ElementKind.NAMESPACE:this.compileNamespace(p)}}},t.prototype.compileClassDeclaration=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null);var i=assert(this.program.elementsLookup.get(e.fileLevelInternalName));assert(i.kind==l.ElementKind.CLASS_PROTOTYPE),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.resolveUsingTypeArguments(t,r,n);i&&this.compileClass(i)},t.prototype.compileClass=function(e){if(e.is(l.CommonFlags.COMPILED))return!0;e.set(l.CommonFlags.COMPILED);var t=e.prototype.members;if(t)try{for(var r=a(t.values()),n=r.next();!n.done;n=r.next()){switch((y=n.value).kind){case l.ElementKind.GLOBAL:this.compileGlobal(y);break;case l.ElementKind.FUNCTION_PROTOTYPE:y.is(l.CommonFlags.GENERIC)||this.compileFunctionUsingTypeArguments(y,[],null,null,y.declaration.name);break;case l.ElementKind.PROPERTY:(S=y.getterPrototype)&&this.compileFunctionUsingTypeArguments(S,[],null,null,S.declaration.name),(O=y.setterPrototype)&&this.compileFunctionUsingTypeArguments(O,[],null,null,O.declaration.name)}}}catch(e){s={error:e}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(s)throw s.error}}var i=e.constructorInstance;i&&this.compileFunction(i);var s,o,c,p,u=e.members;if(u)try{for(var h=a(u.values()),_=h.next();!_.done;_=h.next()){var y;switch((y=_.value).kind){case l.ElementKind.FUNCTION_PROTOTYPE:y.is(l.CommonFlags.GENERIC)||this.compileFunctionUsingTypeArguments(y,[],e.contextualTypeArguments,null,y.declaration.name);break;case l.ElementKind.FIELD:if(y.set(l.CommonFlags.COMPILED),!e.is(l.CommonFlags.MODULE_EXPORT)||y.is(l.CommonFlags.PRIVATE))break;var g=this.module,T=y.simpleName,E=y.type,f=E.toNativeType(),I=y.memoryOffset,v=this.options.usizeType,A=this.options.nativeSizeType,N=m(y,l.GETTER_PREFIX+T);if(g.addFunction(N,this.ensureFunctionType(null,E,v),null,g.createLoad(E.byteSize,E.is(1),g.createGetLocal(0,A),f,I)),g.addFunctionExport(N,N),y.is(l.CommonFlags.READONLY))break;var C=m(y,l.SETTER_PREFIX+T);g.addFunction(C,this.ensureFunctionType([E],d.Type.void,v),null,g.createStore(E.byteSize,g.createGetLocal(0,A),g.createGetLocal(1,f),f,I)),g.addFunctionExport(C,C);break;case l.ElementKind.PROPERTY:var S,O;(S=y.getterPrototype)&&this.compileFunctionUsingTypeArguments(S,[],e.contextualTypeArguments,null,S.declaration.name),(O=y.setterPrototype)&&this.compileFunctionUsingTypeArguments(O,[],e.contextualTypeArguments,null,O.declaration.name)}}}catch(e){c={error:e}}finally{try{_&&!_.done&&(p=h.return)&&p.call(h)}finally{if(c)throw c.error}}return!0},t.prototype.compileInterfaceDeclaration=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null),this.error(c.DiagnosticCode.Operation_not_supported,e.range)},t.prototype.addMemorySegment=function(e,t){void 0===t&&(t=8);var r=i64_align(this.memoryOffset,t),n=p.MemorySegment.create(e,r);return this.memorySegments.push(n),this.memoryOffset=i64_add(r,i64_new(e.length,0)),n},t.prototype.ensureFunctionTableEntry=function(e){if(assert(e.is(l.CommonFlags.COMPILED)),e.functionTableIndex>=0)return e.functionTableIndex;var t=this.functionTable,r=t.length;return!e.is(l.CommonFlags.TRAMPOLINE)&&e.signature.requiredParameters<e.signature.parameterTypes.length&&(e=this.ensureTrampoline(e)),t.push(e),e.functionTableIndex=r,r},t.prototype.compileStatement=function(e){var t,r=this.module;switch(e.kind){case h.NodeKind.BLOCK:t=this.compileBlockStatement(e);break;case h.NodeKind.BREAK:t=this.compileBreakStatement(e);break;case h.NodeKind.CONTINUE:t=this.compileContinueStatement(e);break;case h.NodeKind.DO:t=this.compileDoStatement(e);break;case h.NodeKind.EMPTY:t=this.compileEmptyStatement(e);break;case h.NodeKind.EXPRESSION:t=this.compileExpressionStatement(e);break;case h.NodeKind.FOR:t=this.compileForStatement(e);break;case h.NodeKind.IF:t=this.compileIfStatement(e);break;case h.NodeKind.RETURN:t=this.compileReturnStatement(e);break;case h.NodeKind.SWITCH:t=this.compileSwitchStatement(e);break;case h.NodeKind.THROW:t=this.compileThrowStatement(e);break;case h.NodeKind.TRY:t=this.compileTryStatement(e);break;case h.NodeKind.VARIABLE:(t=this.compileVariableStatement(e))||(t=r.createNop());break;case h.NodeKind.VOID:t=this.compileVoidStatement(e);break;case h.NodeKind.WHILE:t=this.compileWhileStatement(e);break;case h.NodeKind.TYPEDECLARATION:if(this.currentFunction==this.startFunction)return r.createNop();default:assert(!1),t=r.createUnreachable()}return this.options.sourceMap&&this.addDebugLocation(t,e.range),t},t.prototype.compileStatements=function(e){for(var t=e.length,r=new Array(t),n=0,i=this.currentFunction.flow,a=0;a<t;++a){var s=this.compileStatement(e[a]);if(p.getExpressionId(s)!=p.ExpressionId.Nop&&(r[n++]=s,i.isAny(13)))break}return r.length=n,r},t.prototype.compileBlockStatement=function(e){var t=e.statements,r=this.currentFunction.flow.enterBranchOrScope();this.currentFunction.flow=r;var n=this.compileStatements(t),i=0==n.length?this.module.createNop():1==n.length?n[0]:this.module.createBlock(null,n,p.NativeType.None),a=r.leaveBranchOrScope();return this.currentFunction.flow=a,a.inherit(r),i},t.prototype.compileBreakStatement=function(e){var t=this.module;if(e.label)return this.error(c.DiagnosticCode.Operation_not_supported,e.label.range),t.createUnreachable();var r=this.currentFunction.flow,n=r.breakLabel;return null==n?(this.error(c.DiagnosticCode.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement,e.range),t.createUnreachable()):(r.set(4),t.createBreak(n))},t.prototype.compileContinueStatement=function(e){var t=this.module,r=e.label;if(r)return this.error(c.DiagnosticCode.Operation_not_supported,r.range),t.createUnreachable();var n=this.currentFunction.flow,i=n.continueLabel;return null==i?(this.error(c.DiagnosticCode.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement,e.range),t.createUnreachable()):(n.set(8),t.createBreak(i))},t.prototype.compileDoStatement=function(e){var t=this.currentFunction,r=this.module,n=t.enterBreakContext(),i=t.flow.enterBranchOrScope();t.flow=i;var a="break|"+n;i.breakLabel=a;var s="continue|"+n;i.continueLabel=s;var o=this.compileStatement(e.statement),c=this.makeIsTrueish(this.compileExpression(e.condition,d.Type.i32,0,0),this.currentType);return t.flow=i.leaveBranchOrScope(),t.leaveBreakContext(),r.createBlock(a,[r.createLoop(s,i.isAny(13)?o:r.createBlock(null,[o,r.createBreak(s,c)],p.NativeType.None))],p.NativeType.None)},t.prototype.compileEmptyStatement=function(e){return this.module.createNop()},t.prototype.compileExpressionStatement=function(e){var t=this.compileExpression(e.expression,d.Type.void,0,0);return this.currentType!=d.Type.void&&(t=this.module.createDrop(t),this.currentType=d.Type.void),t},t.prototype.compileForStatement=function(e){var t=this.currentFunction,r=t.enterBreakContext(),n=t.flow.enterBranchOrScope();t.flow=n;var i=n.breakLabel="break|"+r;n.breakLabel=i;var a="continue|"+r;n.continueLabel=a;var s=this.module,o=e.initializer?this.compileStatement(e.initializer):s.createNop(),c=0,l=!0;if(e.condition){c=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,d.Type.bool,0),this.currentType);var u=this.precomputeExpressionRef(c);p.getExpressionId(u)==p.ExpressionId.Const&&(assert(p.getExpressionType(u)==p.NativeType.I32),0!=p.getConstValueI32(u)&&(l=!0)),c=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,d.Type.bool,0),this.currentType)}else c=s.createI32(1),l=!0;var h=e.incrementor?this.compileExpression(e.incrementor,d.Type.void,1,0):s.createNop(),_=this.compileStatement(e.statement),y=n.leaveBranchOrScope();l&&y.inherit(n),t.flow=y,t.leaveBreakContext();var g=s.createBlock(i,[o,s.createLoop(a,s.createBlock(null,[s.createIf(c,s.createBlock(null,[_,h,s.createBreak(a)],p.NativeType.None))],p.NativeType.None))],p.NativeType.None);return n.isAny(3)&&(g=s.createBlock(null,[g,s.createUnreachable()])),g},t.prototype.compileIfStatement=function(e){var t=this.module,r=this.currentFunction,n=e.ifTrue,i=e.ifFalse,a=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,d.Type.bool,0),this.currentType);if(!this.options.noTreeShaking||this.currentFunction.isAny(l.CommonFlags.GENERIC|l.CommonFlags.GENERIC_CONTEXT)){var s=this.precomputeExpressionRef(a);if(p.getExpressionId(s)==p.ExpressionId.Const&&p.getExpressionType(s)==p.NativeType.I32)return p.getConstValueI32(s)?this.compileStatement(n):i?this.compileStatement(i):t.createNop();a=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,d.Type.bool,0),this.currentType)}var o=r.flow.enterBranchOrScope();r.flow=o;var c,u=this.compileStatement(n);r.flow=o.leaveBranchOrScope();var h=0;if(i){c=r.flow.enterBranchOrScope(),r.flow=c,h=this.compileStatement(i);var _=c.leaveBranchOrScope();r.flow=_,_.inheritMutual(o,c)}return t.createIf(a,u,h)},t.prototype.compileReturnStatement=function(e){var t=this.module,r=this.currentFunction,n=0,i=r.flow;if(i.set(1),e.value){var a=i.returnType;n=this.compileExpression(e.value,a,1,r.is(l.CommonFlags.MODULE_EXPORT)?1:0),i.canOverflow(n,a)||i.set(4096)}return i.is(1024)?t.createBreak(assert(i.returnLabel),0,n):t.createReturn(n)},t.prototype.compileSwitchStatement=function(e){var t=this.module,r=this.currentFunction,n=r.enterBreakContext(),i=r.getTempLocal(d.Type.u32,!1),a=i.index,s=e.cases,o=s.length,c=new Array(1+o);c[0]=t.createSetLocal(a,this.compileExpression(e.condition,d.Type.u32,1,0));for(var l=1,u=-1,h=0;h<o;++h){var _=s[h].label;_?c[l++]=t.createBreak("case"+h.toString(10)+"|"+n,t.createBinary(p.BinaryOp.EqI32,t.createGetLocal(a,p.NativeType.I32),this.compileExpression(_,d.Type.u32,1,0))):u=h}r.freeTempLocal(i),c[l]=t.createBreak((u>=0?"case"+u.toString(10):"break")+"|"+n);var y=t.createBlock("case0|"+n,c,p.NativeType.None),g=!0,m=!0,T=!0,E=!0;for(h=0;h<o;++h){var f=s[h].statements,I=f.length,v=r.flow.enterBranchOrScope();r.flow=v;var A="break|"+n;v.breakLabel=A;var N=h!=o-1,C=N?"case"+(h+1).toString(10)+"|"+n:A,S=new Array(1+I);S[0]=y;for(var O=1,L=0;L<I;++L){var b=this.compileStatement(f[L]);if(p.getExpressionId(b)!=p.ExpressionId.Nop&&(S[O++]=b,v.is(13)))break}S.length=O,N||v.is(1)||(g=!1),N||v.is(4096)||(m=!1),N||v.is(2)||(T=!1),N||v.is(16)||(E=!1),r.flow=v.leaveBranchOrScope(),y=t.createBlock(C,S,p.NativeType.None)}if(r.leaveBreakContext(),u>=0){v=r.flow;g&&v.set(1),m&&v.set(4096),T&&v.set(2),E&&v.set(16)}return y},t.prototype.compileThrowStatement=function(e){var t=this.currentFunction.flow;return t.set(2),t.set(1),o.compileAbort(this,null,e)},t.prototype.compileTryStatement=function(e){return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()},t.prototype.compileVariableStatement=function(e,t){void 0===t&&(t=!1);var r=this.program,n=this.currentFunction,i=e.declarations,a=i.length;if(t||n==this.startFunction&&e.parent&&e.parent.kind==h.NodeKind.SOURCE){for(var s=0;s<a;++s)this.compileGlobalDeclaration(i[s]);return 0}var o=new Array,u=this.currentFunction.flow;for(s=0;s<a;++s){var _=i[s],y=_.name.text,g=null,m=0;if(_.type){if(!(g=r.resolveType(_.type,u.contextualTypeArguments)))continue;_.initializer&&(m=this.compileExpression(_.initializer,g,1,0))}else{if(!_.initializer){this.error(c.DiagnosticCode.Type_expected,_.name.range.atEnd);continue}if(m=this.compileExpression(_.initializer,d.Type.void,0,0),this.currentType==d.Type.void){this.error(c.DiagnosticCode.Type_0_is_not_assignable_to_type_1,_.range,this.currentType.toString(),"<auto>");continue}g=this.currentType}var T=!1;if(_.is(l.CommonFlags.CONST))if(m)if(m=this.precomputeExpressionRef(m),p.getExpressionId(m)==p.ExpressionId.Const){var E=new l.Local(r,y,-1,g);switch(p.getExpressionType(m)){case p.NativeType.I32:E=E.withConstantIntegerValue(p.getConstValueI32(m),0);break;case p.NativeType.I64:E=E.withConstantIntegerValue(p.getConstValueI64Low(m),p.getConstValueI64High(m));break;case p.NativeType.F32:E=E.withConstantFloatValue(p.getConstValueF32(m));break;case p.NativeType.F64:E=E.withConstantFloatValue(p.getConstValueF64(m));break;default:return assert(!1),this.module.createUnreachable()}var f=n.flow.scopedLocals;if(f){if(f.has(y))return this.error(c.DiagnosticCode.Duplicate_identifier_0,_.name.range,y),this.module.createUnreachable()}else n.flow.scopedLocals=f=new Map;f.set(y,E),T=!0}else this.warning(c.DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable,_.range);else this.error(c.DiagnosticCode._const_declarations_must_be_initialized,_.range);if(!T){E=void 0;E=_.isAny(l.CommonFlags.LET|l.CommonFlags.CONST)||u.is(1024)?u.addScopedLocal(g,y,!1,_):n.addLocal(g,y,_),m?(o.push(this.compileAssignmentWithValue(_.name,m)),u.setLocalWrapped(E.index,!u.canOverflow(m,g))):u.setLocalWrapped(E.index,!0)}}return o.length?1==o.length?o[0]:this.module.createBlock(null,o,p.NativeType.None):0},t.prototype.compileVoidStatement=function(e){return this.compileExpression(e.expression,d.Type.void,2,0)},t.prototype.compileWhileStatement=function(e){var t=this.module,r=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,d.Type.bool,0),this.currentType);if(!this.options.noTreeShaking||this.currentFunction.isAny(l.CommonFlags.GENERIC|l.CommonFlags.GENERIC_CONTEXT)){var n=this.precomputeExpressionRef(r);if(p.getExpressionId(n)==p.ExpressionId.Const&&p.getExpressionType(n)==p.NativeType.I32){if(!p.getConstValueI32(n))return t.createNop()}else r=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,d.Type.bool,0),this.currentType)}var i=this.currentFunction,a=i.enterBreakContext(),s=i.flow.enterBranchOrScope();i.flow=s;var o="break|"+a;s.breakLabel=o;var c="continue|"+a;s.continueLabel=c;var u=this.compileStatement(e.statement);i.flow=s.leaveBranchOrScope(),i.leaveBreakContext();var h=t.createBlock(o,[t.createLoop(c,t.createIf(r,s.isAny(13)?u:t.createBlock(null,[u,t.createBreak(c)],p.NativeType.None)))],p.NativeType.None);return h},t.prototype.compileInlineConstant=function(e,t,r){assert(e.is(l.CommonFlags.INLINED));var n=e.type;switch(!r&&n.is(4)&&t.is(4)&&n.size<t.size?(this.currentType=t).kind:(this.currentType=n).kind){case 0:case 1:var i=n.computeSmallIntegerShift(d.Type.i32);return this.module.createI32(1==e.constantValueKind?i64_low(e.constantIntegerValue)<<i>>i:0);case 5:case 6:case 10:var a=e.type.computeSmallIntegerMask(d.Type.i32);return this.module.createI32(1==e.constantValueKind?i64_low(e.constantIntegerValue)&a: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 12:if(!e.is(l.CommonFlags.BUILTIN)||t!=d.Type.f32)return this.module.createF64(e.constantFloatValue);this.currentType=d.Type.f32;case 11:return this.module.createF32(e.constantFloatValue);default:return assert(!1),this.module.createUnreachable()}},t.prototype.compileExpression=function(e,t,r,n){var i;switch(this.currentType=t,e.kind){case h.NodeKind.ASSERTION:i=this.compileAssertionExpression(e,t);break;case h.NodeKind.BINARY:i=this.compileBinaryExpression(e,t);break;case h.NodeKind.CALL:i=this.compileCallExpression(e,t);break;case h.NodeKind.COMMA:i=this.compileCommaExpression(e,t);break;case h.NodeKind.ELEMENTACCESS:i=this.compileElementAccessExpression(e,t);break;case h.NodeKind.FUNCTION:i=this.compileFunctionExpression(e,t);break;case h.NodeKind.IDENTIFIER:case h.NodeKind.FALSE:case h.NodeKind.NULL:case h.NodeKind.THIS:case h.NodeKind.SUPER:case h.NodeKind.TRUE:i=this.compileIdentifierExpression(e,t,0==r);break;case h.NodeKind.LITERAL:i=this.compileLiteralExpression(e,t);break;case h.NodeKind.NEW:i=this.compileNewExpression(e,t);break;case h.NodeKind.PARENTHESIZED:i=this.compileParenthesizedExpression(e,t);break;case h.NodeKind.PROPERTYACCESS:i=this.compilePropertyAccessExpression(e,t,0==r);break;case h.NodeKind.TERNARY:i=this.compileTernaryExpression(e,t);break;case h.NodeKind.UNARYPOSTFIX:i=this.compileUnaryPostfixExpression(e,t);break;case h.NodeKind.UNARYPREFIX:i=this.compileUnaryPrefixExpression(e,t);break;default:assert(!1),i=this.module.createUnreachable()}var a=this.currentType;return 0!=r&&a!=t?(i=this.convertExpression(i,a,t,r,n,e),this.currentType=t):1==n&&(i=this.ensureSmallIntegerWrap(i,a)),this.options.sourceMap&&this.addDebugLocation(i,e.range),i},t.prototype.compileExpressionRetainType=function(e,t,r){return this.compileExpression(e,t==d.Type.void?d.Type.i32:t,0,r)},t.prototype.precomputeExpression=function(e,t,r,n){return this.precomputeExpressionRef(this.compileExpression(e,t,r,n))},t.prototype.precomputeExpressionRef=function(e){var t=this.module,r=this.currentType,n=r.toNativeType(),i=t.getFunctionTypeBySignature(n,null);i||(i=t.addFunctionType(r.toSignatureString(),n,null));var a=t.addFunction("__precompute",i,null,e);t.runPasses(["precompute"],a);var s=p.getFunctionBody(a);return t.removeFunction("__precompute"),s},t.prototype.convertExpression=function(e,t,r,n,i,a){assert(0!=n);var s=this.module;return 13==t.kind?(assert(13!=r.kind),this.error(c.DiagnosticCode.Type_0_is_not_assignable_to_type_1,a.range,t.toString(),r.toString()),s.createUnreachable()):13==r.kind?s.createDrop(e):(1!=n||t.isAssignableTo(r)||this.error(c.DiagnosticCode.Conversion_from_type_0_to_1_requires_an_explicit_cast,a.range,t.toString(),r.toString()),t.is(8)?r.is(8)?11==t.kind?12==r.kind&&(e=s.createUnary(p.UnaryOp.PromoteF32,e)):11==r.kind&&(e=s.createUnary(p.UnaryOp.DemoteF64,e)):r.is(4)?e=11==t.kind?r.is(1)?r.is(64)?s.createUnary(p.UnaryOp.TruncF32ToI64,e):s.createUnary(p.UnaryOp.TruncF32ToI32,e):r.is(64)?s.createUnary(p.UnaryOp.TruncF32ToU64,e):s.createUnary(p.UnaryOp.TruncF32ToU32,e):r.is(1)?r.is(64)?s.createUnary(p.UnaryOp.TruncF64ToI64,e):s.createUnary(p.UnaryOp.TruncF64ToI32,e):r.is(64)?s.createUnary(p.UnaryOp.TruncF64ToU64,e):s.createUnary(p.UnaryOp.TruncF64ToU32,e):(assert(0==r.flags,"void type expected"),e=s.createDrop(e)):t.is(4)&&r.is(8)?e=11==r.kind?t.is(64)?s.createUnary(t.is(1)?p.UnaryOp.ConvertI64ToF32:p.UnaryOp.ConvertU64ToF32,e):s.createUnary(t.is(1)?p.UnaryOp.ConvertI32ToF32:p.UnaryOp.ConvertU32ToF32,e):t.is(64)?s.createUnary(t.is(1)?p.UnaryOp.ConvertI64ToF64:p.UnaryOp.ConvertU64ToF64,e):s.createUnary(t.is(1)?p.UnaryOp.ConvertI32ToF64:p.UnaryOp.ConvertU32ToF64,e):t.is(64)?r.is(64)||(e=s.createUnary(p.UnaryOp.WrapI64,e)):r.is(64)?(e=s.createUnary(r.is(1)?p.UnaryOp.ExtendI32:p.UnaryOp.ExtendU32,this.ensureSmallIntegerWrap(e,t)),i=0):t.is(32)&&t.size<r.size&&(e=this.ensureSmallIntegerWrap(e,t),i=0),this.currentType=r,1==i?this.ensureSmallIntegerWrap(e,r):e)},t.prototype.compileAssertionExpression=function(e,t){var r=this.program.resolveType(e.toType,this.currentFunction.flow.contextualTypeArguments);return r?this.compileExpression(e.expression,r,2,0):this.module.createUnreachable()},t.prototype.compileBinaryExpression=function(e,t){var r,n,i,a,s,o,h=this.module,_=e.left,y=e.right,g=!1,m=e.operator;switch(m){case u.Token.LESSTHAN:if(r=this.compileExpressionRetainType(_,t,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.LT)){o=this.compileBinaryOverload(v,_,y,e);break}if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!0)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,"<",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,_),i=this.convertExpression(i,a,a=s,1,1,y),s.kind){case 0:case 1:case 2:o=h.createBinary(p.BinaryOp.LtI32,r,i);break;case 3:o=h.createBinary(p.BinaryOp.LtI64,r,i);break;case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.LtI64:p.BinaryOp.LtI32,r,i);break;case 5:case 6:case 7:case 10:o=h.createBinary(p.BinaryOp.LtU32,r,i);break;case 9:o=h.createBinary(this.options.isWasm64?p.BinaryOp.LtU64:p.BinaryOp.LtU32,r,i);break;case 8:o=h.createBinary(p.BinaryOp.LtU64,r,i);break;case 11:o=h.createBinary(p.BinaryOp.LtF32,r,i);break;case 12:o=h.createBinary(p.BinaryOp.LtF64,r,i);break;default:assert(!1),o=h.createUnreachable()}this.currentType=d.Type.bool;break;case u.Token.GREATERTHAN:if(r=this.compileExpressionRetainType(_,t,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.GT)){o=this.compileBinaryOverload(v,_,y,e);break}if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!0)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,">",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,_),i=this.convertExpression(i,a,a=s,1,1,y),s.kind){case 0:case 1:case 2:o=h.createBinary(p.BinaryOp.GtI32,r,i);break;case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.GtI64:p.BinaryOp.GtI32,r,i);break;case 3:o=h.createBinary(p.BinaryOp.GtI64,r,i);break;case 5:case 6:case 7:case 10:o=h.createBinary(p.BinaryOp.GtU32,r,i);break;case 9:o=h.createBinary(this.options.isWasm64?p.BinaryOp.GtU64:p.BinaryOp.GtU32,r,i);break;case 8:o=h.createBinary(p.BinaryOp.GtU64,r,i);break;case 11:o=h.createBinary(p.BinaryOp.GtF32,r,i);break;case 12:o=h.createBinary(p.BinaryOp.GtF64,r,i);break;default:assert(!1),o=h.createUnreachable()}this.currentType=d.Type.bool;break;case u.Token.LESSTHAN_EQUALS:if(r=this.compileExpressionRetainType(_,t,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.LE)){o=this.compileBinaryOverload(v,_,y,e);break}if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!0)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,"<=",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,_),i=this.convertExpression(i,a,a=s,1,1,y),s.kind){case 0:case 1:case 2:o=h.createBinary(p.BinaryOp.LeI32,r,i);break;case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.LeI64:p.BinaryOp.LeI32,r,i);break;case 3:o=h.createBinary(p.BinaryOp.LeI64,r,i);break;case 5:case 6:case 7:case 10:o=h.createBinary(p.BinaryOp.LeU32,r,i);break;case 9:o=h.createBinary(this.options.isWasm64?p.BinaryOp.LeU64:p.BinaryOp.LeU32,r,i);break;case 8:o=h.createBinary(p.BinaryOp.LeU64,r,i);break;case 11:o=h.createBinary(p.BinaryOp.LeF32,r,i);break;case 12:o=h.createBinary(p.BinaryOp.LeF64,r,i);break;default:assert(!1),o=h.createUnreachable()}this.currentType=d.Type.bool;break;case u.Token.GREATERTHAN_EQUALS:if(r=this.compileExpressionRetainType(_,t,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.GE)){o=this.compileBinaryOverload(v,_,y,e);break}if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!0)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,">=",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,_),i=this.convertExpression(i,a,a=s,1,1,y),s.kind){case 0:case 1:case 2:o=h.createBinary(p.BinaryOp.GeI32,r,i);break;case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.GeI64:p.BinaryOp.GeI32,r,i);break;case 3:o=h.createBinary(p.BinaryOp.GeI64,r,i);break;case 5:case 6:case 7:case 10:o=h.createBinary(p.BinaryOp.GeU32,r,i);break;case 9:o=h.createBinary(this.options.isWasm64?p.BinaryOp.GeU64:p.BinaryOp.GeU32,r,i);break;case 8:o=h.createBinary(p.BinaryOp.GeU64,r,i);break;case 11:o=h.createBinary(p.BinaryOp.GeF32,r,i);break;case 12:o=h.createBinary(p.BinaryOp.GeF64,r,i);break;default:assert(!1),o=h.createUnreachable()}this.currentType=d.Type.bool;break;case u.Token.EQUALS_EQUALS_EQUALS:case u.Token.EQUALS_EQUALS:if(r=this.compileExpressionRetainType(_,t,0),n=this.currentType,m==u.Token.EQUALS_EQUALS)if(I=n.classReference)if(v=I.lookupOverload(l.OperatorKind.EQ)){o=this.compileBinaryOverload(v,_,y,e);break}if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,u.operatorTokenToString(e.operator),n.toString(),a.toString()),this.currentType=t,h.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,_),i=this.convertExpression(i,a,a=s,1,1,y),s.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:o=h.createBinary(p.BinaryOp.EqI32,r,i);break;case 9:case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.EqI64:p.BinaryOp.EqI32,r,i);break;case 3:case 8:o=h.createBinary(p.BinaryOp.EqI64,r,i);break;case 11:o=h.createBinary(p.BinaryOp.EqF32,r,i);break;case 12:o=h.createBinary(p.BinaryOp.EqF64,r,i);break;default:assert(!1),o=h.createUnreachable()}this.currentType=d.Type.bool;break;case u.Token.EXCLAMATION_EQUALS_EQUALS:case u.Token.EXCLAMATION_EQUALS:if(r=this.compileExpressionRetainType(_,t,0),n=this.currentType,m==u.Token.EXCLAMATION_EQUALS)if(I=n.classReference)if(v=I.lookupOverload(l.OperatorKind.NE)){o=this.compileBinaryOverload(v,_,y,e);break}if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,u.operatorTokenToString(e.operator),n.toString(),a.toString()),this.currentType=t,h.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,_),i=this.convertExpression(i,a,a=s,1,1,y),s.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:o=h.createBinary(p.BinaryOp.NeI32,r,i);break;case 9:case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.NeI64:p.BinaryOp.NeI32,r,i);break;case 3:case 8:o=h.createBinary(p.BinaryOp.NeI64,r,i);break;case 11:o=h.createBinary(p.BinaryOp.NeF32,r,i);break;case 12:o=h.createBinary(p.BinaryOp.NeF64,r,i);break;default:assert(!1),o=h.createUnreachable()}this.currentType=d.Type.bool;break;case u.Token.EQUALS:return this.compileAssignment(_,y,t);case u.Token.PLUS_EQUALS:g=!0;case u.Token.PLUS:if(r=this.compileExpressionRetainType(_,t,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.ADD)){o=this.compileBinaryOverload(v,_,y,e);break}if(g)i=this.compileExpression(y,n,1,0);else{if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,"+",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,_),i=this.convertExpression(i,a,a=s,1,0,y)}switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:case 2:case 7:o=h.createBinary(p.BinaryOp.AddI32,r,i);break;case 9:case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.AddI64:p.BinaryOp.AddI32,r,i);break;case 3:case 8:o=h.createBinary(p.BinaryOp.AddI64,r,i);break;case 11:o=h.createBinary(p.BinaryOp.AddF32,r,i);break;case 12:o=h.createBinary(p.BinaryOp.AddF64,r,i);break;default:assert(!1),o=h.createUnreachable()}break;case u.Token.MINUS_EQUALS:g=!0;case u.Token.MINUS:if(r=this.compileExpressionRetainType(_,t,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.SUB)){o=this.compileBinaryOverload(v,_,y,e);break}if(g)i=this.compileExpression(y,n,1,0),a=this.currentType;else{if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,"-",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,_),i=this.convertExpression(i,a,a=s,1,0,y)}switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:case 2:case 7:o=h.createBinary(p.BinaryOp.SubI32,r,i);break;case 9:case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.SubI64:p.BinaryOp.SubI32,r,i);break;case 3:case 8:o=h.createBinary(p.BinaryOp.SubI64,r,i);break;case 11:o=h.createBinary(p.BinaryOp.SubF32,r,i);break;case 12:o=h.createBinary(p.BinaryOp.SubF64,r,i);break;default:assert(!1),o=h.createUnreachable()}break;case u.Token.ASTERISK_EQUALS:g=!0;case u.Token.ASTERISK:if(r=this.compileExpressionRetainType(_,t,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.MUL)){o=this.compileBinaryOverload(v,_,y,e);break}if(g)r=this.ensureSmallIntegerWrap(r,n),i=this.compileExpression(y,n,1,1);else{if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,"*",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,_),i=this.convertExpression(i,a,a=s,1,0,y)}switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:case 2:case 7:o=h.createBinary(p.BinaryOp.MulI32,r,i);break;case 9:case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.MulI64:p.BinaryOp.MulI32,r,i);break;case 3:case 8:o=h.createBinary(p.BinaryOp.MulI64,r,i);break;case 11:o=h.createBinary(p.BinaryOp.MulF32,r,i);break;case 12:o=h.createBinary(p.BinaryOp.MulF64,r,i);break;default:assert(!1),o=h.createUnreachable()}break;case u.Token.ASTERISK_ASTERISK_EQUALS:g=!0;case u.Token.ASTERISK_ASTERISK:if(r=this.compileExpressionRetainType(_,t,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.POW)){o=this.compileBinaryOverload(v,_,y,e);break}var T=void 0;if(11==this.currentType.kind){if(i=this.compileExpression(y,d.Type.f32,1,0),a=this.currentType,!(T=this.f32PowInstance)){if(!(E=this.program.elementsLookup.get("Mathf"))){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Mathf"),o=h.createUnreachable();break}if(!(f=E.members?E.members.get("pow"):null)){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Mathf.pow"),o=h.createUnreachable();break}assert(f.kind==l.ElementKind.FUNCTION_PROTOTYPE),this.f32PowInstance=T=f.resolve()}}else if(r=this.convertExpression(r,this.currentType,d.Type.f64,1,0,_),n=this.currentType,i=this.compileExpression(y,d.Type.f64,1,0),a=this.currentType,!(T=this.f64PowInstance)){if(!(E=this.program.elementsLookup.get("Math"))){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Math"),o=h.createUnreachable();break}if(!(f=E.members?E.members.get("pow"):null)){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Math.pow"),o=h.createUnreachable();break}assert(f.kind==l.ElementKind.FUNCTION_PROTOTYPE),this.f64PowInstance=T=f.resolve()}o=T&&this.compileFunction(T)?this.makeCallDirect(T,[r,i]):h.createUnreachable();break;case u.Token.SLASH_EQUALS:g=!0;case u.Token.SLASH:if(r=this.compileExpressionRetainType(_,t,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.DIV)){o=this.compileBinaryOverload(v,_,y,e);break}if(g)r=this.ensureSmallIntegerWrap(r,n),i=this.compileExpression(y,n,1,1),a=this.currentType;else{if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,"/",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();r=this.convertExpression(r,n,n=s,1,1,_),i=this.convertExpression(i,a,a=s,1,1,y)}switch(this.currentType.kind){case 0:case 1:case 2:o=h.createBinary(p.BinaryOp.DivI32,r,i);break;case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.DivI64:p.BinaryOp.DivI32,r,i);break;case 3:o=h.createBinary(p.BinaryOp.DivI64,r,i);break;case 5:case 6:case 10:case 7:o=h.createBinary(p.BinaryOp.DivU32,r,i);break;case 9:o=h.createBinary(this.options.isWasm64?p.BinaryOp.DivU64:p.BinaryOp.DivU32,r,i);break;case 8:o=h.createBinary(p.BinaryOp.DivU64,r,i);break;case 11:o=h.createBinary(p.BinaryOp.DivF32,r,i);break;case 12:o=h.createBinary(p.BinaryOp.DivF64,r,i);break;default:assert(!1),o=h.createUnreachable()}break;case u.Token.PERCENT_EQUALS:g=!0;case u.Token.PERCENT:if(r=this.compileExpressionRetainType(_,t,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.REM)){o=this.compileBinaryOverload(v,_,y,e);break}if(g)r=this.ensureSmallIntegerWrap(r,n),i=this.compileExpression(y,n,1,1),a=this.currentType;else{if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,"%",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();r=this.convertExpression(r,n,n=s,1,1,_),i=this.convertExpression(i,a,a=s,1,1,y)}switch(this.currentType.kind){case 0:case 1:case 2:o=h.createBinary(p.BinaryOp.RemI32,r,i);break;case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.RemI64:p.BinaryOp.RemI32,r,i);break;case 3:o=h.createBinary(p.BinaryOp.RemI64,r,i);break;case 5:case 6:case 10:case 7:o=h.createBinary(p.BinaryOp.RemU32,r,i);break;case 9:o=h.createBinary(this.options.isWasm64?p.BinaryOp.RemU64:p.BinaryOp.RemU32,r,i);break;case 8:o=h.createBinary(p.BinaryOp.RemU64,r,i);break;case 11:if(!(T=this.f32ModInstance)){if(!(E=this.program.elementsLookup.get("Mathf"))){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Mathf"),o=h.createUnreachable();break}if(!(f=E.members?E.members.get("mod"):null)){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Mathf.mod"),o=h.createUnreachable();break}assert(f.kind==l.ElementKind.FUNCTION_PROTOTYPE),this.f32ModInstance=T=f.resolve()}o=T&&this.compileFunction(T)?this.makeCallDirect(T,[r,i]):h.createUnreachable();break;case 12:if(!(T=this.f64ModInstance)){var E,f;if(!(E=this.program.elementsLookup.get("Math"))){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Math"),o=h.createUnreachable();break}if(!(f=E.members?E.members.get("mod"):null)){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Math.mod"),o=h.createUnreachable();break}assert(f.kind==l.ElementKind.FUNCTION_PROTOTYPE),this.f64ModInstance=T=f.resolve()}o=T&&this.compileFunction(T)?this.makeCallDirect(T,[r,i]):h.createUnreachable();break;default:assert(!1),o=h.createUnreachable()}break;case u.Token.LESSTHAN_LESSTHAN_EQUALS:g=!0;case u.Token.LESSTHAN_LESSTHAN:switch(r=this.compileExpressionRetainType(_,t.intType,0),n=this.currentType,i=this.compileExpression(y,n,1,0),a=this.currentType,this.currentType.kind){case 0:case 1:case 5:case 6:case 10:case 2:case 7:o=h.createBinary(p.BinaryOp.ShlI32,r,i);break;case 3:case 8:o=h.createBinary(p.BinaryOp.ShlI64,r,i);break;case 9:case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.ShlI64:p.BinaryOp.ShlI32,r,i);break;case 11:case 12:return this.error(c.DiagnosticCode.The_0_operator_cannot_be_applied_to_type_1,e.range,u.operatorTokenToString(e.operator),this.currentType.toString()),h.createUnreachable();default:assert(!1),o=h.createUnreachable()}break;case u.Token.GREATERTHAN_GREATERTHAN_EQUALS:g=!0;case u.Token.GREATERTHAN_GREATERTHAN:switch(r=this.compileExpressionRetainType(_,t.intType,1),n=this.currentType,i=this.compileExpression(y,n,1,1),a=this.currentType,this.currentType.kind){case 0:case 1:case 2:o=h.createBinary(p.BinaryOp.ShrI32,r,i);break;case 3:o=h.createBinary(p.BinaryOp.ShrI64,r,i);break;case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.ShrI64:p.BinaryOp.ShrI32,r,i);break;case 5:case 6:case 10:case 7:o=h.createBinary(p.BinaryOp.ShrU32,r,i);break;case 8:o=h.createBinary(p.BinaryOp.ShrU64,r,i);break;case 9:o=h.createBinary(this.options.isWasm64?p.BinaryOp.ShrU64:p.BinaryOp.ShrU32,r,i);break;case 11:case 12:return this.error(c.DiagnosticCode.The_0_operator_cannot_be_applied_to_type_1,e.range,u.operatorTokenToString(e.operator),this.currentType.toString()),h.createUnreachable();default:assert(!1),o=h.createUnreachable()}break;case u.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS:g=!0;case u.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN:switch(r=this.compileExpressionRetainType(_,t.intType,1),n=this.currentType,i=this.compileExpression(y,n,1,0),a=this.currentType,this.currentType.kind){case 5:case 6:case 10:o=h.createBinary(p.BinaryOp.ShrU32,r,i);case 0:case 1:case 2:case 7:o=h.createBinary(p.BinaryOp.ShrU32,r,i);break;case 3:case 8:o=h.createBinary(p.BinaryOp.ShrU64,r,i);break;case 9:case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.ShrU64:p.BinaryOp.ShrU32,r,i);break;case 11:case 12:return this.error(c.DiagnosticCode.The_0_operator_cannot_be_applied_to_type_1,e.range,u.operatorTokenToString(e.operator),this.currentType.toString()),h.createUnreachable();default:assert(!1),o=h.createUnreachable()}break;case u.Token.AMPERSAND_EQUALS:g=!0;case u.Token.AMPERSAND:if(r=this.compileExpressionRetainType(_,t.intType,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.AND)){o=this.compileBinaryOverload(v,_,y,e);break}if(g)i=this.compileExpression(y,n,1,0),a=this.currentType;else{if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,"&",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,_),i=this.convertExpression(i,a,a=s,1,0,y)}switch(this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 10:case 7:o=h.createBinary(p.BinaryOp.AndI32,r,i);break;case 3:case 8:o=h.createBinary(p.BinaryOp.AndI64,r,i);break;case 9:case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.AndI64:p.BinaryOp.AndI32,r,i);break;case 11:case 12:return this.error(c.DiagnosticCode.The_0_operator_cannot_be_applied_to_type_1,e.range,u.operatorTokenToString(e.operator),this.currentType.toString()),h.createUnreachable();default:assert(!1),o=h.createUnreachable()}break;case u.Token.BAR_EQUALS:g=!0;case u.Token.BAR:if(r=this.compileExpressionRetainType(_,t.intType,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.OR)){o=this.compileBinaryOverload(v,_,y,e);break}if(g)i=this.compileExpression(y,n,1,0),a=this.currentType;else{if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,"|",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,_),i=this.convertExpression(i,a,a=s,1,0,y)}switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:o=h.createBinary(p.BinaryOp.OrI32,r,i);break;case 2:case 7:o=h.createBinary(p.BinaryOp.OrI32,r,i);break;case 3:case 8:o=h.createBinary(p.BinaryOp.OrI64,r,i);break;case 9:case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.OrI64:p.BinaryOp.OrI32,r,i);break;case 11:case 12:return this.error(c.DiagnosticCode.The_0_operator_cannot_be_applied_to_type_1,e.range,u.operatorTokenToString(e.operator),this.currentType.toString()),h.createUnreachable();default:assert(!1),o=h.createUnreachable()}break;case u.Token.CARET_EQUALS:g=!0;case u.Token.CARET:var I,v;if(r=this.compileExpressionRetainType(_,t.intType,0),I=(n=this.currentType).classReference)if(v=I.lookupOverload(l.OperatorKind.XOR)){o=this.compileBinaryOverload(v,_,y,e);break}if(g)i=this.compileExpression(y,n,1,0),a=this.currentType;else{if(i=this.compileExpressionRetainType(y,n,0),a=this.currentType,!(s=d.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,"^",n.toString(),a.toString()),this.currentType=t,h.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,_),i=this.convertExpression(i,a,a=s,1,0,y)}switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:o=h.createBinary(p.BinaryOp.XorI32,r,i);break;case 2:case 7:o=h.createBinary(p.BinaryOp.XorI32,r,i);break;case 3:case 8:o=h.createBinary(p.BinaryOp.XorI64,r,i);break;case 9:case 4:o=h.createBinary(this.options.isWasm64?p.BinaryOp.XorI64:p.BinaryOp.XorI32,r,i);break;case 11:case 12:return this.error(c.DiagnosticCode.The_0_operator_cannot_be_applied_to_type_1,e.range,u.operatorTokenToString(e.operator),this.currentType.toString()),h.createUnreachable();default:assert(!1),o=h.createUnreachable()}break;case u.Token.AMPERSAND_AMPERSAND:if(r=this.compileExpressionRetainType(_,t,0),n=this.currentType,i=this.compileExpression(y,n,1,0),a=this.currentType,o=h.cloneExpression(r,!0,0))this.makeIsTrueish(r,this.currentType),o=h.createIf(this.makeIsTrueish(r,this.currentType),i,o);else{var A=this.currentFunction.flow,N=this.currentFunction.getAndFreeTempLocal(this.currentType,!A.canOverflow(r,this.currentType));o=h.createIf(this.makeIsTrueish(h.createTeeLocal(N.index,r),this.currentType),i,h.createGetLocal(assert(N).index,this.currentType.toNativeType()))}break;case u.Token.BAR_BAR:if(r=this.compileExpressionRetainType(_,t,0),n=this.currentType,i=this.compileExpression(y,n,1,0),a=this.currentType,o=this.module.cloneExpression(r,!0,0))o=this.module.createIf(this.makeIsTrueish(r,this.currentType),o,i);else{A=this.currentFunction.flow,N=this.currentFunction.getAndFreeTempLocal(this.currentType,!A.canOverflow(r,this.currentType));o=h.createIf(this.makeIsTrueish(h.createTeeLocal(N.index,r),this.currentType),h.createGetLocal(assert(N).index,this.currentType.toNativeType()),i)}break;default:assert(!1),o=this.module.createUnreachable()}return g?this.compileAssignmentWithValue(_,o,t!=d.Type.void):o},t.prototype.compileUnaryOverload=function(e,t,r){var n,i=0;if(e.is(l.CommonFlags.INSTANCE)){var a=assert(e.parent);assert(a.kind==l.ElementKind.CLASS),i=this.compileExpression(t,a.type,1,0),n=[]}else n=[t];return this.compileCallDirect(e,n,r,i,e.hasDecorator(l.DecoratorFlags.INLINE))},t.prototype.compileBinaryOverload=function(e,t,r,n){var i,a=0;if(e.is(l.CommonFlags.INSTANCE)){var s=assert(e.parent);assert(s.kind==l.ElementKind.CLASS),a=this.compileExpression(t,s.type,1,0),i=[r]}else i=[t,r];return this.compileCallDirect(e,i,n,a,e.hasDecorator(l.DecoratorFlags.INLINE))},t.prototype.compileAssignment=function(e,t,r){var n,i=this.program,a=this.currentFunction,s=i.resolveExpression(e,a);if(!s)return this.module.createUnreachable();switch(s.kind){case l.ElementKind.GLOBAL:if(!this.compileGlobal(s))return this.module.createUnreachable();assert(s.type!=d.Type.void);case l.ElementKind.LOCAL:case l.ElementKind.FIELD:n=s.type;break;case l.ElementKind.PROPERTY:var o=s.setterPrototype;if(o){var p=o.resolve();if(!p)return this.module.createUnreachable();assert(1==p.signature.parameterTypes.length),n=p.signature.parameterTypes[0];break}return this.error(c.DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property,e.range,s.internalName),this.module.createUnreachable();case l.ElementKind.CLASS:if(i.resolvedElementExpression){var u=a.flow.is(2048),h=s.lookupOverload(l.OperatorKind.INDEXED_SET,u);if(!h)return s.lookupOverload(l.OperatorKind.INDEXED_GET,u)?this.error(c.DiagnosticCode.Index_signature_in_type_0_only_permits_reading,e.range,s.internalName):this.error(c.DiagnosticCode.Index_signature_is_missing_in_type_0,e.range,s.internalName),this.module.createUnreachable();assert(2==h.signature.parameterTypes.length),n=h.signature.parameterTypes[1];break}default:return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}var _=this.compileExpression(t,n,1,0);return this.compileAssignmentWithValue(e,_,r!=d.Type.void)},t.prototype.compileAssignmentWithValue=function(e,t,r){void 0===r&&(r=!1);var n=this.module,i=this.program.resolveExpression(e,this.currentFunction);if(!i)return n.createUnreachable();switch(i.kind){case l.ElementKind.LOCAL:var a=i.type;return this.currentType=r?a:d.Type.void,i.is(l.CommonFlags.CONST)?(this.error(c.DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property,e.range,i.internalName),n.createUnreachable()):((_=this.currentFunction.flow).setLocalWrapped(i.index,!_.canOverflow(t,a)),r?n.createTeeLocal(i.index,t):n.createSetLocal(i.index,t));case l.ElementKind.GLOBAL:if(!this.compileGlobal(i))return n.createUnreachable();a=i.type;if(assert(a!=d.Type.void),this.currentType=r?a:d.Type.void,i.is(l.CommonFlags.CONST))return this.error(c.DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property,e.range,i.internalName),n.createUnreachable();if(t=this.ensureSmallIntegerWrap(t,a),r){var s=a.toNativeType(),o=i.internalName;return n.createBlock(null,[n.createSetGlobal(o,t),n.createGetGlobal(o,s)],s)}return n.createSetGlobal(i.internalName,t);case l.ElementKind.FIELD:var p=i.declaration;if(i.is(l.CommonFlags.READONLY)&&!this.currentFunction.is(l.CommonFlags.CONSTRUCTOR)&&null!=p&&null==p.initializer)return this.error(c.DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property,e.range,i.internalName),n.createUnreachable();var u=assert(this.program.resolvedThisExpression),h=this.compileExpressionRetainType(u,this.options.usizeType,0);a=i.type;this.currentType=r?a:d.Type.void;s=a.toNativeType();if(10==a.kind&&(t=this.ensureSmallIntegerWrap(t,a)),r){var _=(O=this.currentFunction).flow,y=O.getAndFreeTempLocal(a,!_.canOverflow(t,a)).index;return n.createBlock(null,[n.createSetLocal(y,t),n.createStore(a.byteSize,h,n.createGetLocal(y,s),s,i.memoryOffset),n.createGetLocal(y,s)],s)}return n.createStore(a.byteSize,h,t,s,i.memoryOffset);case l.ElementKind.PROPERTY:var g=i.setterPrototype;if(g){var m=g.resolve();if(!m)return n.createUnreachable();if(!r){if(m.is(l.CommonFlags.INSTANCE)){u=assert(this.program.resolvedThisExpression),h=this.compileExpressionRetainType(u,this.options.usizeType,0);return this.makeCallDirect(m,[h,t])}return this.makeCallDirect(m,[t])}var T=i.getterPrototype;assert(null!=T);var E=T.resolve();if(!E)return n.createUnreachable();var f=(k=E.signature.returnType).toNativeType();if(m.is(l.CommonFlags.INSTANCE)){u=assert(this.program.resolvedThisExpression),h=this.compileExpressionRetainType(u,this.options.usizeType,0),y=this.currentFunction.getAndFreeTempLocal(k,!1).index;return n.createBlock(null,[this.makeCallDirect(m,[n.createTeeLocal(y,h),t]),this.makeCallDirect(E,[n.createGetLocal(y,f)])],f)}return n.createBlock(null,[this.makeCallDirect(m,[t]),this.makeCallDirect(E)],f)}return this.error(c.DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property,e.range,i.internalName),n.createUnreachable();case l.ElementKind.CLASS:var I=this.program.resolvedElementExpression;if(I){var v=this.currentFunction.flow.is(2048),A=i.lookupOverload(l.OperatorKind.INDEXED_GET,v);if(!A)return this.error(c.DiagnosticCode.Index_signature_is_missing_in_type_0,e.range,i.internalName),n.createUnreachable();var N=i.lookupOverload(l.OperatorKind.INDEXED_SET,v);if(!N)return this.error(c.DiagnosticCode.Index_signature_in_type_0_only_permits_reading,e.range,i.internalName),this.currentType=r?A.signature.returnType:d.Type.void,n.createUnreachable();var C=i.type,S=(u=assert(this.program.resolvedThisExpression),h=this.compileExpressionRetainType(u,this.options.usizeType,0),this.compileExpression(I,d.Type.i32,1,0));if(r){var O,L=(O=this.currentFunction).getTempLocal(C,!1),b=O.getAndFreeTempLocal(this.currentType,!1),k=A.signature.returnType;return this.currentFunction.freeTempLocal(L),n.createBlock(null,[this.makeCallDirect(N,[n.createTeeLocal(L.index,h),n.createTeeLocal(b.index,S),t]),this.makeCallDirect(A,[n.createGetLocal(L.index,L.type.toNativeType()),n.createGetLocal(b.index,b.type.toNativeType())])],k.toNativeType())}return this.makeCallDirect(N,[h,S,t])}}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable()},t.prototype.compileCallExpression=function(e,t){var r,n,i=this.module,a=this.currentFunction,s=this.program.resolveExpression(e.expression,a);if(!s)return i.createUnreachable();switch(s.kind){case l.ElementKind.FUNCTION_PROTOTYPE:var o=s,u=e.typeArguments;if(o.is(l.CommonFlags.AMBIENT|l.CommonFlags.BUILTIN))return this.compileCallExpressionBuiltin(o,e,t);var _=null;if(u){if(!o.is(l.CommonFlags.GENERIC))return this.error(c.DiagnosticCode.Type_0_is_not_generic,e.expression.range,o.internalName),i.createUnreachable();_=o.resolveUsingTypeArguments(u,this.currentFunction.flow.contextualTypeArguments,e)}else{if(o.is(l.CommonFlags.GENERIC)){for(var y=new Map,g=assert(o.declaration.typeParameters),m=g.length,T=0;T<m;++T)y.set(g[T].name.text,null);var E=o.declaration.signature.parameterTypes,f=E.length,I=e.arguments,v=I.length,A=new Array(v);for(T=0;T<f;++T){var N=E[T].type,C=N.kind==h.NodeKind.TYPE?N.name.text:null,S=T<v?I[T]:o.declaration.signature.parameterTypes[T].initializer;if(!S)return this.error(c.DiagnosticCode.Expected_0_arguments_but_got_1,e.range,f.toString(10),v.toString(10)),i.createUnreachable();if(null!==C&&y.has(C)){if(k=y.get(C)){A[T]=this.compileExpressionRetainType(S,k,0);var O=void 0;if(!(O=d.Type.commonCompatible(k,this.currentType,!0))&&!(O=d.Type.commonCompatible(k,this.currentType,!1)))return this.error(c.DiagnosticCode.Type_0_is_not_assignable_to_type_1,E[T].type.range,this.currentType.toString(),k.toString()),i.createUnreachable();k=O}else A[T]=this.compileExpressionRetainType(S,d.Type.i32,0),k=this.currentType;y.set(C,k)}else{var L=this.program.resolveType(E[T].type,this.currentFunction.flow.contextualTypeArguments,!0);if(!L)return i.createUnreachable();A[T]=this.compileExpression(S,L,1,0)}}var b=new Array(m);for(T=0;T<m;++T){var k=assert(y.get(g[T].name.text));b[T]=k}return(_=o.resolve(b,this.currentFunction.flow.contextualTypeArguments))?this.makeCallDirect(_,A):this.module.createUnreachable()}_=o.resolve(null,this.currentFunction.flow.contextualTypeArguments)}if(!_)return this.module.createUnreachable();var x=0;return _.is(l.CommonFlags.INSTANCE)&&(x=this.compileExpressionRetainType(assert(this.program.resolvedThisExpression),this.options.usizeType,0)),this.compileCallDirect(_,e.arguments,e,x,_.hasDecorator(l.DecoratorFlags.INLINE));case l.ElementKind.LOCAL:if(r=s.type.signatureReference){n=i.createGetLocal(s.index,p.NativeType.I32);break}return this.error(c.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures,e.range,s.type.toString()),i.createUnreachable();case l.ElementKind.GLOBAL:if(r=s.type.signatureReference){n=i.createGetGlobal(s.internalName,s.type.toNativeType());break}return this.error(c.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures,e.range,s.type.toString()),i.createUnreachable();case l.ElementKind.FIELD:if(r=s.type.signatureReference){var R=assert(this.program.resolvedThisExpression);x=this.compileExpressionRetainType(R,this.options.usizeType,0);n=i.createLoad(4,!1,x,p.NativeType.I32,s.memoryOffset);break}return this.error(c.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures,e.range,s.type.toString()),i.createUnreachable();case l.ElementKind.FUNCTION_TARGET:r=s.signature,n=this.compileExpression(e.expression,s.type,1,0);break;case l.ElementKind.PROPERTY:default:return this.error(c.DiagnosticCode.Operation_not_supported,e.range),i.createUnreachable()}return this.compileCallIndirect(r,n,e.arguments,e)},t.prototype.compileCallExpressionBuiltin=function(e,t,r){var n=o.compileCall(this,e,e.resolveBuiltinTypeArguments(t.typeArguments,this.currentFunction.flow.contextualTypeArguments),t.arguments,r,t);return n||(this.error(c.DiagnosticCode.Operation_not_supported,t.range),this.module.createUnreachable())},t.prototype.checkCallSignature=function(e,t,r,n){if(r!=(null!=e.thisType))return this.error(c.DiagnosticCode.Operation_not_supported,n.range),!1;var i=e.hasRest;if(i)return this.error(c.DiagnosticCode.Operation_not_supported,n.range),!1;var a=e.requiredParameters,s=e.parameterTypes.length;return t<a?(this.error(a<s?c.DiagnosticCode.Expected_at_least_0_arguments_but_got_1:c.DiagnosticCode.Expected_0_arguments_but_got_1,n.range,a.toString(),t.toString()),!1):!(t>s&&!i)||(this.error(c.DiagnosticCode.Expected_0_arguments_but_got_1,n.range,s.toString(),t.toString()),!1)},t.prototype.compileCallDirect=function(e,t,r,n,i){void 0===n&&(n=0),void 0===i&&(i=!1);var a=t.length,s=e.signature;if(!this.checkCallSignature(s,a,0!=n,r))return this.module.createUnreachable();if(i)return assert(!e.is(l.CommonFlags.TRAMPOLINE)),this.compileCallInlineUnchecked(e,t,r,n);var o=n?a+1:a,c=new Array(o),p=0;n&&(c[0]=n,p=1);for(var u=s.parameterTypes,h=0;h<a;++h,++p)c[p]=this.compileExpression(t[h],u[h],1,0);return assert(p==o),this.makeCallDirect(e,c)},t.prototype.compileCallInlineUnchecked=function(e,t,r,n){void 0===n&&(n=0);var i=t.length,s=e.signature,o=this.currentFunction,u=this.module,_=e.prototype.declaration,y=o.flow,g=e.internalName+"|inlined."+(e.nextInlineId++).toString(10),m=e.signature.returnType,T=l.Flow.create(o);T.set(1024),T.returnLabel=g,T.returnType=m,T.contextualTypeArguments=e.contextualTypeArguments;var E=[];if(n){var f=assert(e.parent);if(assert(f.kind==l.ElementKind.CLASS),p.getExpressionId(n)==p.ExpressionId.GetLocal)T.addScopedLocalAlias(p.getGetLocalIndex(n),f.type,"this");else{var I=T.addScopedLocal(f.type,"this",!1);E.push(u.createSetLocal(I.index,n))}}for(var v=s.parameterTypes,A=0;A<i;++A){var N=this.compileExpression(t[A],v[A],1,0);if(p.getExpressionId(N)==p.ExpressionId.GetLocal)T.addScopedLocalAlias(p.getGetLocalIndex(N),v[A],s.getParameterName(A));else{var C=T.addScopedLocal(v[A],s.getParameterName(A),!T.canOverflow(N,v[A]));E.push(u.createSetLocal(C.index,N))}}o.flow=T;var S=s.parameterTypes.length;for(A=i;A<S;++A){var O=this.compileExpression(assert(_.signature.parameterTypes[A].initializer),v[A],1,1);C=T.addScopedLocal(v[A],s.getParameterName(A),!T.canOverflow(O,v[A]));E.push(u.createSetLocal(C.index,O))}var L=assert(_.body);if(L.kind==h.NodeKind.BLOCK)for(var b=L.statements,k=(A=0,b.length);A<k;++A)E.push(this.compileStatement(b[A]));else E.push(this.compileStatement(L));var x,R,B=T.scopedLocals;if(B){try{for(var U=a(B.values()),D=U.next();!D.done;D=U.next()){var F=D.value;F.is(l.CommonFlags.SCOPED)&&o.freeTempLocal(F)}}catch(e){x={error:e}}finally{try{D&&!D.done&&(R=U.return)&&R.call(U)}finally{if(x)throw x.error}}T.scopedLocals=null}return T.finalize(),this.currentFunction.flow=y,this.currentType=m,m==d.Type.void||T.is(1)?u.createBlock(g,E,m.toNativeType()):(this.error(c.DiagnosticCode.A_function_whose_declared_type_is_not_void_must_return_a_value,_.signature.returnType.range),u.createUnreachable())},t.prototype.ensureTrampoline=function(e){var t=e.trampoline;if(t)return t;var r=e.signature,n=e.internalName,i=r.parameterTypes,a=e.prototype.declaration.signature.parameterTypes,s=r.returnType,o=r.thisType,c=e.is(l.CommonFlags.INSTANCE),u=r.requiredParameters,h=u,_=i.length,y=_;c&&(++h,++y);var g=assert(y-h),m=new Array(h),T=0,E=this.module;c&&(m[0]=E.createGetLocal(0,this.options.nativeSizeType),T=1);for(var f=0;f<u;++f,++T)m[T]=E.createGetLocal(T,i[f].toNativeType());assert(T==h);var I=new d.Signature(i,s,o),v=n+"|trampoline";I.requiredParameters=_,(t=new l.Function(e.prototype,v,I,e.parent,e.contextualTypeArguments)).set(e.flags|l.CommonFlags.TRAMPOLINE|l.CommonFlags.COMPILED),e.trampoline=t;var A=this.currentFunction;this.currentFunction=t;var N=g+1,C=new Array(N),S="of"+g.toString(10);for(f=0;f<N;++f){var O=f.toString(10)+S;C[f]=O}var L=E.createBlock(C[0],[E.createBlock("oob",[E.createSwitch(C,"oob",u?E.createBinary(p.BinaryOp.SubI32,E.createGetGlobal("~argc",p.NativeType.I32),E.createI32(u)):E.createGetGlobal("~argc",p.NativeType.I32))]),E.createUnreachable()]);for(f=0;f<g;++f,++T){var b=i[u+f];L=E.createBlock(C[f+1],[L,E.createSetLocal(T,this.compileExpression(assert(a[u+f].initializer),b,1,1))]),m[T]=E.createGetLocal(T,b.toNativeType())}this.currentFunction=A,assert(T==y);var k=E.addFunction(v,this.ensureFunctionType(I.parameterTypes,I.returnType,I.thisType),d.typesToNativeTypes(t.additionalLocals),E.createBlock(null,[L,E.createCall(n,m,s.toNativeType())],s.toNativeType()));return t.finalize(E,k),t},t.prototype.ensureArgcVar=function(){if(!this.argcVar){var e=this.module;this.argcVar=e.addGlobal("~argc",p.NativeType.I32,!0,e.createI32(0))}return"~argc"},t.prototype.ensureArgcSet=function(){if(!this.argcSet){var e=this.module;this.argcSet=e.addFunction("~setargc",this.ensureFunctionType([d.Type.u32],d.Type.void),null,e.createSetGlobal(this.ensureArgcVar(),e.createGetLocal(0,p.NativeType.I32))),e.addFunctionExport("~setargc","_setargc")}return"~setargc"},t.prototype.makeCallDirect=function(e,t){void 0===t&&(t=null);var r=t?t.length:0,n=r,i=e.signature.requiredParameters,a=e.signature.parameterTypes.length,s=a;e.is(l.CommonFlags.INSTANCE)&&(++i,++s,--n),assert(r>=i);var o=this.module;if(!this.compileFunction(e))return o.createUnreachable();var c=e.signature.returnType,p=e.is(l.CommonFlags.MODULE_IMPORT);if(r<s){t||((t=new Array(s)).length=0);for(var u=e.signature.parameterTypes,h=n;h<a;++h)t.push(u[h].toNativeZero(o));if(!p){var d=e;if(e=this.ensureTrampoline(e),!this.compileFunction(e))return o.createUnreachable();e.flow.flags=d.flow.flags,this.program.instancesLookup.set(e.internalName,e);var _=c.toNativeType();return this.currentType=c,o.createBlock(null,[o.createSetGlobal(this.ensureArgcVar(),o.createI32(n)),o.createCall(e.internalName,t,_)],_)}}return this.currentType=c,p?o.createCallImport(e.internalName,t,c.toNativeType()):o.createCall(e.internalName,t,c.toNativeType())},t.prototype.compileCallIndirect=function(e,t,r,n,i){void 0===i&&(i=0);var a=r.length;if(!this.checkCallSignature(e,a,0!=i,n))return this.module.createUnreachable();var s=i?a+1:a,o=new Array(s),c=0;i&&(o[0]=i,c=1);for(var p=e.parameterTypes,l=0;l<a;++l,++c)o[c]=this.compileExpression(r[l],p[l],1,0);return assert(c==s),this.makeCallIndirect(e,t,o)},t.prototype.makeCallIndirect=function(e,t,r){void 0===r&&(r=null);var n=r?r.length:0,i=n,a=e.requiredParameters,s=e.parameterTypes.length,o=s;e.thisType&&(++a,++o,--i),assert(n>=a),this.ensureFunctionType(e.parameterTypes,e.returnType,e.thisType);var c=this.module;if(n<o){r||((r=new Array(o)).length=0);for(var p=e.parameterTypes,l=i;l<s;++l)r.push(p[l].toNativeZero(c))}var u=e.returnType;return this.currentType=u,c.createBlock(null,[c.createSetGlobal(this.ensureArgcVar(),c.createI32(i)),c.createCallIndirect(t,r,e.toSignatureString())],u.toNativeType())},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],d.Type.void,2,0);return i[n]=this.compileExpression(r[n],t,1,0),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();switch(r.kind){case l.ElementKind.CLASS:var n=this.currentFunction.flow.is(2048),i=r.lookupOverload(l.OperatorKind.INDEXED_GET,n);if(!i)return this.error(c.DiagnosticCode.Index_signature_is_missing_in_type_0,e.expression.range,r.internalName),this.module.createUnreachable();var a=this.compileExpression(e.expression,r.type,1,0);return this.compileCallDirect(i,[e.elementExpression],e,a)}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()},t.prototype.compileFunctionExpression=function(e,t){var r=e.declaration,n=r.name,i=(n.text.length?n.text:"anonymous")+"|"+this.functionTable.length.toString(10),a=this.currentFunction,s=new l.FunctionPrototype(this.program,i,a.internalName+l.INNER_DELIMITER+i,r,null,l.DecoratorFlags.NONE),o=a.flow,c=this.compileFunctionUsingTypeArguments(s,[],o.contextualTypeArguments,o,r);if(!c)return this.module.createUnreachable();this.currentType=c.signature.type;var p=this.ensureFunctionTableEntry(c);return p<0?this.module.createUnreachable():this.module.createI32(p)},t.prototype.compileIdentifierExpression=function(e,t,r){var n=this.module,i=this.currentFunction;switch(e.kind){case h.NodeKind.NULL:var a=this.options;return t.classReference||(this.currentType=a.usizeType),a.isWasm64?n.createI64(0):n.createI32(0);case h.NodeKind.TRUE:return this.currentType=d.Type.bool,n.createI32(1);case h.NodeKind.FALSE:return this.currentType=d.Type.bool,n.createI32(0);case h.NodeKind.THIS:if((u=i.flow).is(1024))if(_=u.getScopedLocal("this"))return this.currentType=_.type,n.createGetLocal(_.index,_.type.toNativeType());if(i.is(l.CommonFlags.INSTANCE)){var s=assert(i.parent);assert(s.kind==l.ElementKind.CLASS);var o=s.type;return i.is(l.CommonFlags.CONSTRUCTOR)&&!u.is(16)?(u.set(16),this.currentType=o,n.createTeeLocal(0,this.makeConditionalAllocate(s,e))):(this.currentType=o,n.createGetLocal(0,o.toNativeType()))}return this.error(c.DiagnosticCode._this_cannot_be_referenced_in_current_location,e.range),this.currentType=this.options.usizeType,n.createUnreachable();case h.NodeKind.SUPER:var u,_;if((u=i.flow).is(1024))if(_=u.getScopedLocal("this"))if(y=assert(_.type.classReference).base)return this.currentType=y.type,n.createGetLocal(_.index,y.type.toNativeType());if(i.is(l.CommonFlags.INSTANCE)){var y;s=assert(i.parent);if(assert(s.kind==l.ElementKind.CLASS),y=s.base){var g=y.type;return this.currentType=g,n.createGetLocal(0,g.toNativeType())}}return this.error(c.DiagnosticCode._super_can_only_be_referenced_in_a_derived_class,e.range),this.currentType=this.options.usizeType,n.createUnreachable()}var m=this.program.resolveIdentifier(e,i,this.currentEnum);if(!m)return n.createUnreachable();switch(m.kind){case l.ElementKind.LOCAL:if(m.is(l.CommonFlags.INLINED))return this.compileInlineConstant(m,t,r);var T=m.type,E=m.index;return assert(E>=0),this.currentType=T,this.module.createGetLocal(E,T.toNativeType());case l.ElementKind.GLOBAL:if(!this.compileGlobal(m))return this.module.createUnreachable();var f=m.type;return assert(f!=d.Type.void),m.is(l.CommonFlags.INLINED)?this.compileInlineConstant(m,t,r):(this.currentType=f,this.module.createGetGlobal(m.internalName,f.toNativeType()));case l.ElementKind.ENUMVALUE:return m.is(l.CommonFlags.COMPILED)?(this.currentType=d.Type.i32,m.is(l.CommonFlags.INLINED)?this.module.createI32(m.constantValue):this.module.createGetGlobal(m.internalName,p.NativeType.I32)):(this.error(c.DiagnosticCode.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums,e.range),this.currentType=d.Type.i32,this.module.createUnreachable());case l.ElementKind.FUNCTION_PROTOTYPE:var I=m.resolve(null,i.flow.contextualTypeArguments);if(!I||!this.compileFunction(I))return n.createUnreachable();var v=this.ensureFunctionTableEntry(I);return this.currentType=I.signature.type,this.module.createI32(v)}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()},t.prototype.compileLiteralExpression=function(e,t,r){void 0===r&&(r=!1);var n=this.module;switch(e.literalKind){case h.LiteralKind.ARRAY:assert(!r);var i=t.classReference;return i&&i.prototype==this.program.arrayPrototype?this.compileArrayLiteral(assert(i.typeArguments)[0],e.elementExpressions,e):(this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable());case h.LiteralKind.FLOAT:var a=e.value;return r&&(a=-a),t==d.Type.f32?n.createF32(a):(this.currentType=d.Type.f64,n.createF64(a));case h.LiteralKind.INTEGER:var s=e.value;switch(r&&(s=i64_sub(i64_new(0),s)),t.kind){case 0:if(i64_is_i8(s))return n.createI32(i64_low(s));break;case 5:if(i64_is_u8(s))return n.createI32(i64_low(s));break;case 1:if(i64_is_i16(s))return n.createI32(i64_low(s));break;case 6:if(i64_is_u16(s))return n.createI32(i64_low(s));break;case 2:case 7:if(i64_is_i32(s)||i64_is_u32(s))return n.createI32(i64_low(s));break;case 10:if(i64_is_bool(s))return n.createI32(i64_low(s));break;case 4:case 9:if(!this.options.isWasm64){if(i64_is_i32(s)||i64_is_u32(s))return n.createI32(i64_low(s));break}return n.createI64(i64_low(s),i64_high(s));case 3:case 8:return n.createI64(i64_low(s),i64_high(s));case 11:if(i64_is_f32(s))return n.createF32(i64_to_f32(s));break;case 12:if(i64_is_f64(s))return n.createF64(i64_to_f64(s));break;case 13:break;default:return assert(!1),n.createUnreachable()}return i64_is_i32(s)?(this.currentType=d.Type.i32,n.createI32(i64_low(s))):(this.currentType=d.Type.i64,n.createI64(i64_low(s),i64_high(s)));case h.LiteralKind.STRING:return assert(!r),this.compileStaticString(e.value)}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.currentType=t,n.createUnreachable()},t.prototype.compileStaticString=function(e){var t=this.module,r=this.options,n=this.stringSegments,i=n.get(e);if(!i){var a=e.length,s=new Uint8Array(4+2*a);s[0]=255&a,s[1]=a>>>8&255,s[2]=a>>>16&255,s[3]=a>>>24&255;for(var o=0;o<a;++o)s[4+2*o]=255&e.charCodeAt(o),s[5+2*o]=e.charCodeAt(o)>>>8&255;i=this.addMemorySegment(s,r.usizeType.byteSize),n.set(e,i)}var c=i.offset,p=this.program.typesLookup.get("string");return this.currentType=p||r.usizeType,r.isWasm64?t.createI64(i64_low(c),i64_high(c)):(assert(i64_is_i32(c)),t.createI32(i64_low(c)))},t.prototype.compileArrayLiteral=function(e,t,r){var n=!0,i=this.module,a=assert(this.program.arrayPrototype);if(!a||a.kind!=l.ElementKind.CLASS_PROTOTYPE)return i.createUnreachable();var s=a.resolve([e]);if(!s)return i.createUnreachable();var o=s.type,u=t.length;if(u){var h=e.toNativeType(),d=void 0,y=void 0;switch(h){case p.NativeType.I32:d=changetype(new Int32Array(u)),y=4*u;break;case p.NativeType.I64:d=changetype(new Array(u)),y=8*u;break;case p.NativeType.F32:d=changetype(new Float32Array(u)),y=4*u;break;case p.NativeType.F64:d=changetype(new Float64Array(u)),y=8*u;break;default:return assert(!1),i.createUnreachable()}for(var g=new Array(u),m=void 0,T=0;T<u;++T)if(g[T]=t[T]?this.compileExpression(t[T],e,1,0):e.toNativeZero(i),n)if(m=this.precomputeExpressionRef(g[T]),p.getExpressionId(m)==p.ExpressionId.Const)switch(assert(p.getExpressionType(m)==h),h){case p.NativeType.I32:changetype(d)[T]=p.getConstValueI32(m);break;case p.NativeType.I64:changetype(d)[T]=i64_new(p.getConstValueI64Low(m),p.getConstValueI64High(m));break;case p.NativeType.F32:changetype(d)[T]=p.getConstValueF32(m);break;case p.NativeType.F64:changetype(d)[T]=p.getConstValueF64(m);break;default:assert(!1)}else n=!1;var E=this.options.usizeType.byteSize;if(n){var f=E+4,I=1<<32-clz(y+8-1),v=new Uint8Array(f+I),A=this.addMemorySegment(v),N=0;switch(8==E?(_.writeI64(i64_add(A.offset,i64_new(f)),v,N),N+=8):(assert(0==i64_high(A.offset)),_.writeI32(i64_low(A.offset)+f,v,N),N+=4),_.writeI32(u,v,N),N+=4,assert(N==f),_.writeI32(y,v,N),N+=8,h){case p.NativeType.I32:for(T=0;T<u;++T)_.writeI32(changetype(d)[T],v,N),N+=4;break;case p.NativeType.I64:for(T=0;T<u;++T)_.writeI64(changetype(d)[T],v,N),N+=8;break;case p.NativeType.F32:for(T=0;T<u;++T)_.writeF32(changetype(d)[T],v,N),N+=4;break;case p.NativeType.F64:for(T=0;T<u;++T)_.writeF64(changetype(d)[T],v,N),N+=8;break;default:return assert(!1),i.createUnreachable()}return assert(N<=f+I),this.currentType=o,8==E?i.createI64(i64_low(A.offset),i64_high(A.offset)):i.createI32(i64_low(A.offset))}this.currentType=o;var C=s.lookupOverload(l.OperatorKind.INDEXED_SET,!0);if(!C)return this.error(c.DiagnosticCode.Index_signature_in_type_0_only_permits_reading,r.range,s.internalName),i.createUnreachable();var S=o.toNativeType(),O=this.currentFunction,L=O.getTempLocal(o,!1),b=new Array(2+u),k=0;b[k++]=i.createSetLocal(L.index,this.makeCallDirect(assert(s.constructorInstance),[i.createI32(0),i.createI32(u)]));for(T=0;T<u;++T)b[k++]=this.makeCallDirect(C,[i.createGetLocal(L.index,S),i.createI32(T),g[T]]);return assert(k+1==b.length),b[k]=i.createGetLocal(L.index,S),O.freeTempLocal(L),this.currentType=o,i.createBlock(null,b,S)}return this.currentType=o,this.makeCallDirect(assert(s.constructorInstance),[i.createI32(0),i.createI32(0)])},t.prototype.compileNewExpression=function(e,t){var r=this.module,n=this.options,i=this.currentFunction,a=this.program.resolveExpression(e.expression,i);if(!a)return r.createUnreachable();if(a.kind!=l.ElementKind.CLASS_PROTOTYPE)return this.error(c.DiagnosticCode.Cannot_use_new_with_an_expression_whose_type_lacks_a_construct_signature,e.expression.range),this.module.createUnreachable();var s,o=a.resolveUsingTypeArguments(e.typeArguments,i.flow.contextualTypeArguments,e);if(!o)return r.createUnreachable();for(var p=o,u=o.constructorInstance;!u&&(p=o.base);)u=p.constructorInstance;return s=u?this.compileCallDirect(u,e.arguments,e,n.usizeType.toNativeZero(r)):this.makeAllocate(o,e),this.currentType=o.type,s},t.prototype.compileParenthesizedExpression=function(e,t){return this.compileExpression(e.expression,t,0,0)},t.prototype.compilePropertyAccessExpression=function(e,t,r){var n=this.program,i=this.module,a=n.resolvePropertyAccess(e,this.currentFunction);if(!a)return i.createUnreachable();switch(a.kind){case l.ElementKind.GLOBAL:if(!this.compileGlobal(a))return i.createUnreachable();var s=a.type;return assert(s!=d.Type.void),a.is(l.CommonFlags.INLINED)?this.compileInlineConstant(a,t,r):(this.currentType=s,i.createGetGlobal(a.internalName,s.toNativeType()));case l.ElementKind.ENUMVALUE:var o=a.parent;return assert(null!==o&&o.kind==l.ElementKind.ENUM),this.compileEnum(o)?(this.currentType=d.Type.i32,a.is(l.CommonFlags.INLINED)?i.createI32(a.constantValue):i.createGetGlobal(a.internalName,p.NativeType.I32)):this.module.createUnreachable();case l.ElementKind.FIELD:var u=assert(n.resolvedThisExpression);assert(a.memoryOffset>=0);var h=this.compileExpressionRetainType(u,this.options.usizeType,0);return this.currentType=a.type,i.createLoad(a.type.byteSize,a.type.is(5),h,a.type.toNativeType(),a.memoryOffset);case l.ElementKind.PROPERTY:var _=a.getterPrototype;if(_){var y=_.resolve(null);if(!y)return i.createUnreachable();var g=y.signature;if(!this.checkCallSignature(g,0,y.is(l.CommonFlags.INSTANCE),e))return i.createUnreachable();if(y.is(l.CommonFlags.INSTANCE)){o=assert(y.parent);assert(o.kind==l.ElementKind.CLASS);u=assert(n.resolvedThisExpression),h=this.compileExpressionRetainType(u,this.options.usizeType,0);return this.currentType=g.returnType,this.compileCallDirect(y,[],e,h)}return this.currentType=g.returnType,this.compileCallDirect(y,[],e)}return this.error(c.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.range,a.simpleName,a.parent.toString()),i.createUnreachable()}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),i.createUnreachable()},t.prototype.compileTernaryExpression=function(e,t){var r,n,i,a,s=e.ifThen,o=e.ifElse,u=this.currentFunction,h=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,d.Type.bool,0),this.currentType);if(!this.options.noTreeShaking||this.currentFunction.isAny(l.CommonFlags.GENERIC|l.CommonFlags.GENERIC_CONTEXT)){var _=this.precomputeExpressionRef(h);if(p.getExpressionId(_)==p.ExpressionId.Const&&p.getExpressionType(_)==p.NativeType.I32)return p.getConstValueI32(_)?this.compileExpression(s,t,1,0):this.compileExpression(o,t,1,0);h=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,d.Type.bool,0),this.currentType)}if(u.is(l.CommonFlags.CONSTRUCTOR)){var y=u.flow;y=y.enterBranchOrScope(),u.flow=y,r=this.compileExpressionRetainType(s,t,0),i=this.currentType;var g=y.is(16);y=y.leaveBranchOrScope(),u.flow=y,y=y.enterBranchOrScope(),u.flow=y,n=this.compileExpressionRetainType(o,t,0),a=this.currentType;var m=y.is(16);y=y.leaveBranchOrScope(),u.flow=y,g&&m&&y.set(16)}else r=this.compileExpressionRetainType(s,t,0),i=this.currentType,n=this.compileExpressionRetainType(o,t,0),a=this.currentType;var T=d.Type.commonCompatible(i,a,!1);return T?(r=this.convertExpression(r,i,T,1,0,s),n=this.convertExpression(n,a,T,1,0,o),this.currentType=T,this.module.createIf(h,r,n)):(this.error(c.DiagnosticCode.Type_0_is_not_assignable_to_type_1,e.range,i.toString(),a.toString()),this.currentType=t,this.module.createUnreachable())},t.prototype.compileUnaryPostfixExpression=function(e,t){var r=this.module,n=this.currentFunction,i=this.compileExpression(e.operand,t==d.Type.void?d.Type.i32:t,0,0);if(p.getExpressionId(i)==p.ExpressionId.Unreachable)return i;var a,s,o,l=this.currentType;switch(e.operator){case u.Token.PLUS_PLUS:if(l.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),r.createUnreachable();switch(l.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:a=p.BinaryOp.AddI32,s=p.NativeType.I32,o=r.createI32(1);break;case 9:case 4:a=(h=this.options).isWasm64?p.BinaryOp.AddI64:p.BinaryOp.AddI32,s=h.nativeSizeType,o=l.toNativeOne(r);break;case 3:case 8:a=p.BinaryOp.AddI64,s=p.NativeType.I64,o=r.createI64(1);break;case 11:a=p.BinaryOp.AddF32,s=p.NativeType.F32,o=r.createF32(1);break;case 12:a=p.BinaryOp.AddF64,s=p.NativeType.F64,o=r.createF64(1);break;default:return assert(!1),r.createUnreachable()}break;case u.Token.MINUS_MINUS:if(l.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),r.createUnreachable();switch(l.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:a=p.BinaryOp.SubI32,s=p.NativeType.I32,o=r.createI32(1);break;case 9:case 4:var h;a=(h=this.options).isWasm64?p.BinaryOp.SubI64:p.BinaryOp.SubI32,s=h.nativeSizeType,o=l.toNativeOne(r);break;case 3:case 8:a=p.BinaryOp.SubI64,s=p.NativeType.I64,o=r.createI64(1);break;case 11:a=p.BinaryOp.SubF32,s=p.NativeType.F32,o=r.createF32(1);break;case 12:a=p.BinaryOp.SubF64,s=p.NativeType.F64,o=r.createF64(1);break;default:return assert(!1),r.createUnreachable()}break;default:return assert(!1),r.createUnreachable()}if(t==d.Type.void)return this.compileAssignmentWithValue(e.operand,r.createBinary(a,i,o),!1);var _=n.getTempLocal(l,!1),y=this.compileAssignmentWithValue(e.operand,r.createBinary(a,this.module.createGetLocal(_.index,s),o),!1);this.currentType=assert(_).type,n.freeTempLocal(_);var g=_.index;return r.createBlock(null,[r.createSetLocal(g,i),y,r.createGetLocal(g,s)],s)},t.prototype.compileUnaryPrefixExpression=function(e,t){var r,n=this.module,i=!1;switch(e.operator){case u.Token.PLUS:if(this.currentType.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable();r=this.compileExpression(e.operand,t==d.Type.void?d.Type.i32:t,0,0);break;case u.Token.MINUS:if(this.currentType.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable();if(e.operand.kind!=h.NodeKind.LITERAL||e.operand.literalKind!=h.LiteralKind.INTEGER&&e.operand.literalKind!=h.LiteralKind.FLOAT)switch(r=this.compileExpression(e.operand,t==d.Type.void?d.Type.i32:t,0,0),this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:r=n.createBinary(p.BinaryOp.SubI32,n.createI32(0),r);break;case 9:if(this.currentType.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable();case 4:r=n.createBinary(this.options.isWasm64?p.BinaryOp.SubI64:p.BinaryOp.SubI32,this.currentType.toNativeZero(n),r);break;case 3:case 8:r=n.createBinary(p.BinaryOp.SubI64,n.createI64(0),r);break;case 11:r=n.createUnary(p.UnaryOp.NegF32,r);break;case 12:r=n.createUnary(p.UnaryOp.NegF64,r);break;default:assert(!1),r=n.createUnreachable()}else r=this.compileLiteralExpression(e.operand,t,!0),this.options.sourceMap&&this.addDebugLocation(r,e.range);break;case u.Token.PLUS_PLUS:if(this.currentType.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable();switch(i=!0,r=this.compileExpression(e.operand,t==d.Type.void?d.Type.i32:t,0,0),this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:r=n.createBinary(p.BinaryOp.AddI32,r,this.module.createI32(1));break;case 9:if(this.currentType.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable();case 4:r=n.createBinary(this.options.isWasm64?p.BinaryOp.AddI64:p.BinaryOp.AddI32,r,this.currentType.toNativeOne(n));break;case 3:case 8:r=n.createBinary(p.BinaryOp.AddI64,r,n.createI64(1));break;case 11:r=n.createBinary(p.BinaryOp.AddF32,r,n.createF32(1));break;case 12:r=n.createBinary(p.BinaryOp.AddF64,r,n.createF64(1));break;default:assert(!1),r=n.createUnreachable()}break;case u.Token.MINUS_MINUS:if(this.currentType.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable();switch(i=!0,r=this.compileExpression(e.operand,t==d.Type.void?d.Type.i32:t,0,0),this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:r=n.createBinary(p.BinaryOp.SubI32,r,n.createI32(1));break;case 9:if(this.currentType.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable();case 4:r=n.createBinary(this.options.isWasm64?p.BinaryOp.SubI64:p.BinaryOp.SubI32,r,this.currentType.toNativeOne(n));break;case 3:case 8:r=n.createBinary(p.BinaryOp.SubI64,r,n.createI64(1));break;case 11:r=n.createBinary(p.BinaryOp.SubF32,r,n.createF32(1));break;case 12:r=n.createBinary(p.BinaryOp.SubF64,r,n.createF64(1));break;default:assert(!1),r=n.createUnreachable()}break;case u.Token.EXCLAMATION:r=this.compileExpression(e.operand,t==d.Type.void?d.Type.i32:t,0,0),r=this.makeIsFalseish(r,this.currentType),this.currentType=d.Type.bool;break;case u.Token.TILDE:if(this.currentType.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable();switch(r=this.compileExpression(e.operand,t==d.Type.void?d.Type.i32:t.is(8)?d.Type.i64:t,t==d.Type.void?0:1,0),this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:r=n.createBinary(p.BinaryOp.XorI32,r,n.createI32(-1));break;case 9:if(this.currentType.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable();case 4:r=n.createBinary(this.options.isWasm64?p.BinaryOp.XorI64:p.BinaryOp.XorI32,r,this.currentType.toNativeNegOne(n));break;case 3:case 8:r=n.createBinary(p.BinaryOp.XorI64,r,n.createI64(-1,-1));break;default:assert(!1),r=n.createUnreachable()}break;case u.Token.TYPEOF:return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable();default:return assert(!1),n.createUnreachable()}return i?this.compileAssignmentWithValue(e.operand,r,t!=d.Type.void):r},t.prototype.ensureSmallIntegerWrap=function(e,t){var r=this.module,n=this.currentFunction.flow;switch(t.kind){case 0:n.canOverflow(e,t)&&(e=this.options.hasFeature(1)?r.createUnary(p.UnaryOp.ExtendI8ToI32,e):r.createBinary(p.BinaryOp.ShrI32,r.createBinary(p.BinaryOp.ShlI32,e,r.createI32(24)),r.createI32(24)));break;case 1:n.canOverflow(e,t)&&(e=this.options.hasFeature(1)?r.createUnary(p.UnaryOp.ExtendI16ToI32,e):r.createBinary(p.BinaryOp.ShrI32,r.createBinary(p.BinaryOp.ShlI32,e,r.createI32(16)),r.createI32(16)));break;case 5:n.canOverflow(e,t)&&(e=r.createBinary(p.BinaryOp.AndI32,e,r.createI32(255)));break;case 6:n.canOverflow(e,t)&&(e=r.createBinary(p.BinaryOp.AndI32,e,r.createI32(65535)));break;case 10:n.canOverflow(e,t)&&(e=r.createBinary(p.BinaryOp.AndI32,e,r.createI32(1)))}return e},t.prototype.makeIsFalseish=function(e,t){var r=this.module;switch(t.kind){case 0:case 1:case 5:case 6:case 10:e=this.ensureSmallIntegerWrap(e,t);case 2:case 7:return r.createUnary(p.UnaryOp.EqzI32,e);case 3:case 8:return r.createUnary(p.UnaryOp.EqzI64,e);case 9:case 4:return r.createUnary(64==t.size?p.UnaryOp.EqzI64:p.UnaryOp.EqzI32,e);case 11:return r.createBinary(p.BinaryOp.EqF32,e,r.createF32(0));case 12:return r.createBinary(p.BinaryOp.EqF64,e,r.createF64(0));default:return assert(!1),r.createI32(1)}},t.prototype.makeIsTrueish=function(e,t){var r=this.module;switch(t.kind){case 0:case 1:case 5:case 6:case 10:e=this.ensureSmallIntegerWrap(e,t);case 2:case 7:return e;case 3:case 8:return r.createBinary(p.BinaryOp.NeI64,e,r.createI64(0));case 9:case 4:return 64==t.size?r.createBinary(p.BinaryOp.NeI64,e,r.createI64(0)):e;case 11:return r.createBinary(p.BinaryOp.NeF32,e,r.createF32(0));case 12:return r.createBinary(p.BinaryOp.NeF64,e,r.createF64(0));default:return assert(!1),r.createI32(0)}},t.prototype.makeAllocate=function(e,t){var r,n,i=this.module,s=this.currentFunction,c=this.options.nativeSizeType,p=s.getTempLocal(e.type,!1),u=new Array;if(u.push(i.createSetLocal(p.index,o.compileAllocate(this,e,t))),e.members)try{for(var h=a(e.members.values()),d=h.next();!d.done;d=h.next()){var _=d.value;if(_.kind==l.ElementKind.FIELD){var y=_,g=y.type,m=g.toNativeType(),T=y.prototype.declaration;if(assert(!y.isAny(l.CommonFlags.CONST)),T.initializer)u.push(i.createStore(g.byteSize,i.createGetLocal(p.index,c),this.compileExpression(T.initializer,g,1,0),m,y.memoryOffset));else{var E=y.prototype.declaration.parameterIndex;u.push(i.createStore(g.byteSize,i.createGetLocal(p.index,c),E>=0?i.createGetLocal(1+E,m):g.toNativeZero(i),m,y.memoryOffset))}}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}return u.push(i.createGetLocal(p.index,c)),s.freeTempLocal(p),this.currentType=e.type,i.createBlock(null,u,c)},t.prototype.makeConditionalAllocate=function(e,t){var r=this.module,n=this.options.nativeSizeType;return this.currentType=e.type,r.createIf(n==p.NativeType.I64?r.createBinary(p.BinaryOp.NeI64,r.createGetLocal(0,p.NativeType.I64),r.createI64(0)):r.createGetLocal(0,p.NativeType.I32),r.createGetLocal(0,n),r.createTeeLocal(0,this.makeAllocate(e,t)))},t.prototype.addDebugLocation=function(e,t){var r=this.currentFunction,n=t.source;n.debugInfoIndex<0&&(n.debugInfoIndex=this.module.addDebugInfoFile(n.normalizedPath)),t.debugInfoRef=e,r.debugLocations.push(t)},t}(c.DiagnosticEmitter);function m(e,t){switch(void 0===t&&(t=e.simpleName),e.kind){case l.ElementKind.FUNCTION:return(r=e.parent||e.prototype.parent)?m(r)+(e.is(l.CommonFlags.INSTANCE)?l.INSTANCE_DELIMITER:l.STATIC_DELIMITER)+t:t;case l.ElementKind.FIELD:case l.ElementKind.ENUMVALUE:return m(r=assert(e.parent))+(e.is(l.CommonFlags.INSTANCE)?l.INSTANCE_DELIMITER:l.STATIC_DELIMITER)+t;case l.ElementKind.CLASS:return(r=e.prototype.parent)?m(r)+l.STATIC_DELIMITER+t:t;default:var r;return(r=e.parent)?m(r)+l.STATIC_DELIMITER+t:t}}t.Compiler=g},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=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])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var a=r(0),s=r(6),o=r(2),c=r(1),p=r(4),l=a.LIBRARY_PREFIX+"builtins.ts",u=function(e){function t(){var t=e.call(this)||this;return t.backlog=new Array,t.seenlog=new Set,t.onComment=null,t.tryParseSignatureIsSignature=!1,t.program=new a.Program(t.diagnostics),t}return i(t,e),t.prototype.parseFile=function(e,t,r){for(var n=this.program,i=c.normalizePath(t),o=p.mangleInternalPath(i),u=n.sources,h=0,d=u.length;h<d;++h)if(u[h].internalPath==o)return;this.seenlog.add(o);var _=new p.Source(i,e,r?p.SourceKind.ENTRY:t.startsWith(a.LIBRARY_PREFIX)&&t.indexOf(a.PATH_DELIMITER,a.LIBRARY_PREFIX.length)<0?p.SourceKind.LIBRARY:p.SourceKind.DEFAULT);u.push(_),_.normalizedPath==l&&_.set(a.CommonFlags.BUILTIN);var y=new s.Tokenizer(_,n.diagnostics);y.onComment=this.onComment,_.tokenizer=y;for(var g=_.statements;!y.skip(s.Token.ENDOFFILE);){var m=this.parseTopLevelStatement(y);m&&(m.parent=_,g.push(m))}y.finish()},t.prototype.parseTopLevelStatement=function(e,t){void 0===t&&(t=null);for(var r=a.CommonFlags.NONE,n=-1,i=null;e.skip(s.Token.AT);){n<0&&(n=e.tokenPos);var c=this.parseDecorator(e);c?(i||(i=[]),i.push(c)):this.skipStatement(e)}r|=e.source.flags&a.CommonFlags.BUILTIN;var p=0,l=0;e.skip(s.Token.EXPORT)&&(e.skip(s.Token.DEFAULT)&&this.error(o.DiagnosticCode.Operation_not_supported,e.range()),n<0&&(n=e.tokenPos),r|=a.CommonFlags.EXPORT,p=e.tokenPos,l=e.pos);var u=null!=t&&t.is(a.CommonFlags.AMBIENT);e.skip(s.Token.DECLARE)?(n<0&&(n=e.tokenPos),u&&this.error(o.DiagnosticCode.A_declare_modifier_cannot_be_used_in_an_already_ambient_context,e.range()),r|=a.CommonFlags.DECLARE|a.CommonFlags.AMBIENT):u&&(r|=a.CommonFlags.AMBIENT);var h=null,d=e.peek();switch(n<0&&(n=e.nextTokenPos),d){case s.Token.CONST:if(e.next(),r|=a.CommonFlags.CONST,e.skip(s.Token.ENUM)){h=this.parseEnum(e,r,i,n);break}h=this.parseVariable(e,r,i,n),i=null;break;case s.Token.LET:r|=a.CommonFlags.LET;case s.Token.VAR:e.next(),h=this.parseVariable(e,r,i,n),i=null;break;case s.Token.ENUM:e.next(),h=this.parseEnum(e,r,i,n),i=null;break;case s.Token.FUNCTION:e.next(),h=this.parseFunction(e,r,i,n),i=null;break;case s.Token.ABSTRACT:if(e.next(),r|=a.CommonFlags.ABSTRACT,!e.skip(s.Token.CLASS)){this.error(o.DiagnosticCode._0_expected,e.range(e.pos),"class");break}case s.Token.CLASS:case s.Token.INTERFACE:e.next(),h=this.parseClassOrInterface(e,r,i,n),i=null;break;case s.Token.NAMESPACE:e.next(),h=this.parseNamespace(e,r,i,n),i=null;break;case s.Token.IMPORT:e.next(),h=(r|=a.CommonFlags.IMPORT)&a.CommonFlags.EXPORT?this.parseExportImport(e,n):this.parseImport(e);break;case s.Token.TYPE:e.next(),h=this.parseTypeDeclaration(e,r,i,n),i=null;break;default:r&a.CommonFlags.EXPORT?h=this.parseExport(e,r,n):(l&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(p,l),"export"),t||(h=this.parseStatement(e,!0)))}if(i)for(var _=0,y=i.length;_<y;++_)this.error(o.DiagnosticCode.Decorators_are_not_valid_here,i[_].range);return h},t.prototype.nextFile=function(){var e=this.backlog;return e.length?e.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,i=e.next(),a=e.tokenPos;if(i==s.Token.VOID)return p.Node.createType(p.Node.createIdentifierExpression("void",e.range()),[],!1,e.range(a,e.pos));if(i==s.Token.OPENPAREN){var c=e.skip(s.Token.OPENPAREN),l=this.tryParseSignature(e);if(l){if(c){if(!e.skip(s.Token.CLOSEPAREN))return this.error(o.DiagnosticCode._0_expected,e.range(),")"),null;if(!e.skip(s.Token.BAR))return this.error(o.DiagnosticCode._0_expected,e.range(),"|"),null;e.skip(s.Token.NULL)||this.error(o.DiagnosticCode._0_expected,e.range(),"null"),l.isNullable=!0}return l}if(c||this.tryParseSignatureIsSignature)return this.error(o.DiagnosticCode.Unexpected_token,e.range()),null;if(!t)return this.error(o.DiagnosticCode.Unexpected_token,e.range()),null;var u=this.parseType(e,!1,r);if(!u)return null;if(!e.skip(s.Token.CLOSEPAREN))return r||this.error(o.DiagnosticCode._0_expected,e.range(e.pos),"}"),null;(n=u).range.start=a,n.range.end=e.pos}else if(i==s.Token.THIS)n=p.Node.createType(p.Node.createThisExpression(e.range()),[],!1,e.range(a,e.pos));else if(i==s.Token.TRUE||i==s.Token.FALSE)n=p.Node.createType(p.Node.createIdentifierExpression("bool",e.range()),[],!1,e.range(a,e.pos));else if(i==s.Token.STRINGLITERAL)e.readString(),n=p.Node.createType(p.Node.createIdentifierExpression("string",e.range()),[],!1,e.range(a,e.pos));else{if(i!=s.Token.IDENTIFIER)return r||this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;var h=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),d=new Array,_=!1;if(e.skip(s.Token.LESSTHAN)){do{var y=this.parseType(e,!0,r);if(!y)return null;d.push(y)}while(e.skip(s.Token.COMMA));if(!e.skip(s.Token.GREATERTHAN))return r||this.error(o.DiagnosticCode._0_expected,e.range(e.pos),">"),null}if(e.skip(s.Token.BAR)){if(!e.skip(s.Token.NULL))return r||this.error(o.DiagnosticCode._0_expected,e.range(e.pos),"null"),null;_=!0}n=p.Node.createType(h,d,_,e.range(a,e.pos))}for(;e.skip(s.Token.OPENBRACKET);){var g=e.tokenPos;if(!e.skip(s.Token.CLOSEBRACKET))return r||this.error(o.DiagnosticCode._0_expected,e.range(),"]"),null;var m=e.range(g,e.pos);_=!1;if(e.skip(s.Token.BAR)){if(!e.skip(s.Token.NULL))return r||this.error(o.DiagnosticCode._0_expected,e.range(),"null"),null;_=!0}if(n=p.Node.createType(p.Node.createIdentifierExpression("Array",m),[n],_,e.range(a,e.pos)),_)break}return n},t.prototype.tryParseSignature=function(e){var t,r=e.mark(),n=e.tokenPos,i=null,a=null,c=!1;if(e.skip(s.Token.CLOSEPAREN))c=!0,e.discard(r),i=[];else{c=!1;do{var l=p.ParameterKind.DEFAULT;if(e.skip(s.Token.DOT_DOT_DOT)&&(c=!0,e.discard(r),l=p.ParameterKind.REST),e.skip(s.Token.THIS)){if(!e.skip(s.Token.COLON))return e.reset(r),this.tryParseSignatureIsSignature=!1,null;c=!0,e.discard(r);var u=this.parseType(e,!1);if(!u)return null;if(u.kind!=p.NodeKind.TYPE)return this.error(o.DiagnosticCode.Operation_not_supported,u.range),this.tryParseSignatureIsSignature=!0,null;a=u}else{if(!e.skip(s.Token.IDENTIFIER))return c?this.error(o.DiagnosticCode.Identifier_expected,e.range()):e.reset(r),this.tryParseSignatureIsSignature=c,null;var h=p.Node.createIdentifierExpression(e.readIdentifier(),e.range(e.tokenPos,e.pos));if(e.skip(s.Token.QUESTION)&&(c=!0,e.discard(r),l==p.ParameterKind.REST?this.error(o.DiagnosticCode.A_rest_parameter_cannot_be_optional,e.range()):l=p.ParameterKind.OPTIONAL),e.skip(s.Token.COLON)){c=!0,e.discard(r);var d=this.parseType(e);if(!d)return this.tryParseSignatureIsSignature=c,null;var _=new p.ParameterNode;_.parameterKind=l,_.name=h,_.type=d,i?i.push(_):i=[_]}else c&&this.error(o.DiagnosticCode.Type_expected,e.range())}}while(e.skip(s.Token.COMMA));if(!e.skip(s.Token.CLOSEPAREN))return this.error(o.DiagnosticCode._0_expected,e.range(),")"),this.tryParseSignatureIsSignature=c,null}return e.skip(s.Token.EQUALS_GREATERTHAN)?(c=!0,e.discard(r),(t=this.parseType(e))?(this.tryParseSignatureIsSignature=!0,p.Node.createSignature(i||[],t,a,!1,e.range(n,e.pos))):(this.tryParseSignatureIsSignature=c,null)):(c?this.error(o.DiagnosticCode._0_expected,e.range(),"=>"):e.reset(r),this.tryParseSignatureIsSignature=c,null)},t.prototype.parseDecorator=function(e){var t=e.tokenPos;if(e.skip(s.Token.IDENTIFIER)){for(var r=e.readIdentifier(),n=p.Node.createIdentifierExpression(r,e.range(t,e.pos));e.skip(s.Token.DOT);){if(!e.skip(s.Token.IDENTIFIER))return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;r=e.readIdentifier(),n=p.Node.createPropertyAccessExpression(n,p.Node.createIdentifierExpression(r,e.range()),e.range(t,e.pos))}var i=void 0;if(!e.skip(s.Token.OPENPAREN))return p.Node.createDecorator(n,null,e.range(t,e.pos));if(i=this.parseArguments(e))return p.Node.createDecorator(n,i,e.range(t,e.pos))}else this.error(o.DiagnosticCode.Identifier_expected,e.range());return null},t.prototype.parseVariable=function(e,t,r,n){var i=new Array;do{var a=this.parseVariableDeclaration(e,t,r);if(!a)return null;i.push(a)}while(e.skip(s.Token.COMMA));var o=p.Node.createVariableStatement(i,r,t,e.range(n,e.pos));return e.skip(s.Token.SEMICOLON),o},t.prototype.parseVariableDeclaration=function(e,t,r){if(!e.skip(s.Token.IDENTIFIER))return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;var n=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),i=t,c=null;e.skip(s.Token.COLON)&&(c=this.parseType(e));var l=null;if(e.skip(s.Token.EQUALS)){if(i&a.CommonFlags.AMBIENT&&this.error(o.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts,e.range()),!(l=this.parseExpression(e,1)))return null}else i&a.CommonFlags.CONST?i&a.CommonFlags.AMBIENT||this.error(o.DiagnosticCode._const_declarations_must_be_initialized,n.range):c||this.error(o.DiagnosticCode.Type_expected,e.range(e.pos));return p.Node.createVariableDeclaration(n,c,l,r,i,s.Range.join(n.range,e.range()))},t.prototype.parseEnum=function(e,t,r,n){if(e.next()!=s.Token.IDENTIFIER)return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;var i=p.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.next()!=s.Token.OPENBRACE)return this.error(o.DiagnosticCode._0_expected,e.range(),"{"),null;for(var c=new Array;!e.skip(s.Token.CLOSEBRACE);){var l=this.parseEnumValue(e,a.CommonFlags.NONE);if(!l)return null;if(c.push(l),!e.skip(s.Token.COMMA)){if(e.skip(s.Token.CLOSEBRACE))break;return this.error(o.DiagnosticCode._0_expected,e.range(),"}"),null}}var u=p.Node.createEnumDeclaration(i,c,r,t,e.range(n,e.pos));return e.skip(s.Token.SEMICOLON),u},t.prototype.parseEnumValue=function(e,t){if(!e.skip(s.Token.IDENTIFIER))return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;var r=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),n=null;return e.skip(s.Token.EQUALS)&&!(n=this.parseExpression(e,1))?null:p.Node.createEnumValueDeclaration(r,n,t,s.Range.join(r.range,e.range()))},t.prototype.parseReturn=function(e){var t=null;if(e.peek(!0)!=s.Token.SEMICOLON&&e.nextToken!=s.Token.CLOSEBRACE&&!e.nextTokenOnNewLine&&!(t=this.parseExpression(e)))return null;var r=p.Node.createReturnStatement(t,e.range());return e.skip(s.Token.SEMICOLON),r},t.prototype.parseTypeParameters=function(e){for(var t=new Array;!e.skip(s.Token.GREATERTHAN);){var r=this.parseTypeParameter(e);if(!r)return null;if(t.push(r),!e.skip(s.Token.COMMA)){if(e.skip(s.Token.GREATERTHAN))break;return this.error(o.DiagnosticCode._0_expected,e.range(),">"),null}}return 0===t.length&&this.error(o.DiagnosticCode.Type_parameter_list_cannot_be_empty,e.range()),t},t.prototype.parseTypeParameter=function(e){if(e.next()==s.Token.IDENTIFIER){var t=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),r=null;if(e.skip(s.Token.EXTENDS)){var n=this.parseType(e);if(!n)return null;if(n.kind!=p.NodeKind.TYPE)return this.error(o.DiagnosticCode.Operation_not_supported,n.range),null;r=n}return p.Node.createTypeParameter(t,r,s.Range.join(t.range,e.range()))}return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null},t.prototype.parseParameters=function(e,t){void 0===t&&(t=!1);for(var r=new Array,n=null,i=!1,a=!1;!e.skip(s.Token.CLOSEPAREN);){var c=this.parseParameter(e,t);if(!c)return null;switch(n&&!a&&(this.error(o.DiagnosticCode.A_rest_parameter_must_be_last_in_a_parameter_list,n.name.range),a=!0),c.parameterKind){default:i&&this.error(o.DiagnosticCode.A_required_parameter_cannot_follow_an_optional_parameter,c.name.range);break;case p.ParameterKind.OPTIONAL:i=!0;break;case p.ParameterKind.REST:n=c}if(r.push(c),!e.skip(s.Token.COMMA)){if(e.skip(s.Token.CLOSEPAREN))break;return this.error(o.DiagnosticCode._0_expected,e.range(),")"),null}}return r},t.prototype.parseParameter=function(e,t){void 0===t&&(t=!1);var r=!1,n=!1,i=null,c=a.CommonFlags.NONE;if(e.skip(s.Token.PUBLIC)?(i=e.range(),t||this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,i,"public"),c|=a.CommonFlags.PUBLIC):e.skip(s.Token.PROTECTED)?(i=e.range(),t||this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,i,"protected"),c|=a.CommonFlags.PROTECTED):e.skip(s.Token.PRIVATE)&&(i=e.range(),t||this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,i,"private"),c|=a.CommonFlags.PRIVATE),e.skip(s.Token.READONLY)&&(i||(i=e.range()),t||this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,i,"readonly"),c|=a.CommonFlags.READONLY),e.skip(s.Token.DOT_DOT_DOT)&&(c?this.error(o.DiagnosticCode.A_parameter_property_cannot_be_declared_using_a_rest_parameter,e.range()):i=e.range(),r=!0),e.skip(s.Token.IDENTIFIER)){r||(i=e.range());var l=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),u=null;if((n=e.skip(s.Token.QUESTION))&&r&&this.error(o.DiagnosticCode.A_rest_parameter_cannot_be_optional,l.range),e.skip(s.Token.COLON)){if(!(u=this.parseType(e)))return null}else u=p.Node.createOmittedType(e.range(e.pos));var h=null;if(e.skip(s.Token.EQUALS)&&(r&&this.error(o.DiagnosticCode.A_rest_parameter_cannot_have_an_initializer,l.range),n?this.error(o.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer,l.range):n=!0,!(h=this.parseExpression(e,1))))return null;var d=p.Node.createParameter(l,u,h,r?p.ParameterKind.REST:n?p.ParameterKind.OPTIONAL:p.ParameterKind.DEFAULT,s.Range.join(i,e.range()));return d.flags|=c,d}return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null},t.prototype.parseFunction=function(e,t,r,n){if(!e.skip(s.Token.IDENTIFIER))return this.error(o.DiagnosticCode.Identifier_expected,e.range(e.pos)),null;var i=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),c=-1,l=null;if(e.skip(s.Token.LESSTHAN)){if(c=e.tokenPos,!(l=this.parseTypeParameters(e)))return null;t|=a.CommonFlags.GENERIC}if(!e.skip(s.Token.OPENPAREN))return this.error(o.DiagnosticCode._0_expected,e.range(e.pos),"("),null;c<0&&(c=e.tokenPos);var u=this.parseParameters(e);if(!u)return null;var h=0!=(t&a.CommonFlags.SET);h&&(1!=u.length&&this.error(o.DiagnosticCode.A_set_accessor_must_have_exactly_one_parameter,i.range),u.length&&u[0].initializer&&this.error(o.DiagnosticCode.A_set_accessor_parameter_cannot_have_an_initializer,i.range)),t&a.CommonFlags.GET&&u.length&&this.error(o.DiagnosticCode.A_get_accessor_cannot_have_parameters,i.range);var d=null;if(e.skip(s.Token.COLON)&&!(d=this.parseType(e,!0,h)))return null;d||(d=p.Node.createOmittedType(e.range(e.pos)),h||this.error(o.DiagnosticCode.Type_expected,d.range));var _=p.Node.createSignature(u,d,null,!1,e.range(c,e.pos)),y=null;if(e.skip(s.Token.OPENBRACE)){if(t&a.CommonFlags.AMBIENT&&this.error(o.DiagnosticCode.An_implementation_cannot_be_declared_in_ambient_contexts,e.range()),!(y=this.parseBlockStatement(e,!1)))return null}else t&a.CommonFlags.AMBIENT||this.error(o.DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration,e.range(e.pos));var g=p.Node.createFunctionDeclaration(i,l,_,y,r,t,e.range(n,e.pos));return e.skip(s.Token.SEMICOLON),g},t.prototype.parseFunctionExpression=function(e){var t,r=e.tokenPos,n=!1;if(e.token==s.Token.FUNCTION){if(t=e.skip(s.Token.IDENTIFIER)?p.Node.createIdentifierExpression(e.readIdentifier(),e.range()):p.Node.createEmptyIdentifierExpression(e.range(e.pos)),!e.skip(s.Token.OPENPAREN))return this.error(o.DiagnosticCode._0_expected,e.range(e.pos),"("),null}else n=!0,assert(e.token==s.Token.OPENPAREN),t=p.Node.createEmptyIdentifierExpression(e.range(e.tokenPos));var i=e.pos,a=this.parseParameters(e);return a?this.parseFunctionExpressionCommon(e,t,a,n,r,i):null},t.prototype.parseFunctionExpressionCommon=function(e,t,r,n,i,c){void 0===i&&(i=-1),void 0===c&&(c=-1),i<0&&(i=t.range.start),c<0&&(c=i);var l=null;if(e.skip(s.Token.COLON)){if(!(l=this.parseType(e)))return null}else l=p.Node.createOmittedType(e.range(e.pos)),this.error(o.DiagnosticCode.Type_expected,l.range);if(n&&!e.skip(s.Token.EQUALS_GREATERTHAN))return this.error(o.DiagnosticCode._0_expected,e.range(e.pos),"=>"),null;var u,h=p.Node.createSignature(r,l,null,!1,e.range(c,e.pos));if(n)u=this.parseStatement(e,!1);else{if(!e.skip(s.Token.OPENBRACE))return this.error(o.DiagnosticCode._0_expected,e.range(e.pos),"{"),null;u=this.parseBlockStatement(e,!1)}if(!u)return null;var d=p.Node.createFunctionDeclaration(t,null,h,u,null,n?a.CommonFlags.ARROW:a.CommonFlags.NONE,e.range(i,e.pos));return p.Node.createFunctionExpression(d)},t.prototype.parseClassOrInterface=function(e,t,r,n){var i=e.token==s.Token.INTERFACE;if(!e.skip(s.Token.IDENTIFIER))return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;var c,l=p.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.skip(s.Token.LESSTHAN)){if(!(c=this.parseTypeParameters(e)))return null;t|=a.CommonFlags.GENERIC}else c=[];var u=null;if(e.skip(s.Token.EXTENDS)){var h=this.parseType(e);if(!h)return null;if(h.kind!=p.NodeKind.TYPE)return this.error(o.DiagnosticCode.Operation_not_supported,h.range),null;u=h}var d=null;if(e.skip(s.Token.IMPLEMENTS)){i&&this.error(o.DiagnosticCode.Interface_declaration_cannot_have_implements_clause,e.range());do{var _=this.parseType(e);if(!_)return null;i||(d||(d=[]),d.push(_))}while(e.skip(s.Token.COMMA))}if(!e.skip(s.Token.OPENBRACE))return this.error(o.DiagnosticCode._0_expected,e.range(),"{"),null;var y,g=new Array;if(i?(assert(!d),y=p.Node.createInterfaceDeclaration(l,c,u,g,r,t,e.range(n,e.pos))):y=p.Node.createClassDeclaration(l,c,u,d,g,r,t,e.range(n,e.pos)),!e.skip(s.Token.CLOSEBRACE))do{var m=this.parseClassMember(e,y);if(!m)return null;m.parent=y,g.push(m)}while(!e.skip(s.Token.CLOSEBRACE));return y},t.prototype.parseClassMember=function(e,t){for(var r=e.pos,n=new Array;e.skip(s.Token.AT);){var i=this.parseDecorator(e);if(!i)break;n.push(i)}var c=t.flags&a.CommonFlags.AMBIENT;e.skip(s.Token.PUBLIC)?c|=a.CommonFlags.PUBLIC:e.skip(s.Token.PRIVATE)?c|=a.CommonFlags.PRIVATE:e.skip(s.Token.PROTECTED)&&(c|=a.CommonFlags.PROTECTED);var l=0,u=0,h=0,d=0;e.skip(s.Token.STATIC)?(c|=a.CommonFlags.STATIC,l=e.tokenPos,u=e.pos):(e.skip(s.Token.ABSTRACT)?(c|=a.CommonFlags.ABSTRACT|a.CommonFlags.INSTANCE,h=e.tokenPos,d=e.pos):c|=a.CommonFlags.INSTANCE,t.flags&a.CommonFlags.GENERIC&&(c|=a.CommonFlags.GENERIC_CONTEXT));var _=0,y=0;e.skip(s.Token.READONLY)&&(c|=a.CommonFlags.READONLY,_=e.tokenPos,y=e.pos);var g=e.mark(),m=!1,T=!1,E=!1,f=0,I=0;if(e.skip(s.Token.GET)?e.peek(!0,!0)!=s.Token.IDENTIFIER||e.nextTokenOnNewLine?e.reset(g):(c|=a.CommonFlags.GET,T=!0,f=e.tokenPos,I=e.pos,c&a.CommonFlags.READONLY&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(_,y),"readonly")):e.skip(s.Token.SET)?e.peek(!0,!0)!=s.Token.IDENTIFIER||e.nextTokenOnNewLine?e.reset(g):(c|=a.CommonFlags.SET|a.CommonFlags.SET,E=!0,f=e.tokenPos,I=e.pos,c&a.CommonFlags.READONLY&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(_,y),"readonly")):e.skip(s.Token.CONSTRUCTOR)&&(m=!0,(c|=a.CommonFlags.CONSTRUCTOR)&a.CommonFlags.STATIC&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(l,u),"static"),c&a.CommonFlags.ABSTRACT&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(h,d),"abstract"),c&a.CommonFlags.READONLY&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(_,y),"readonly")),!m&&!e.skip(s.Token.IDENTIFIER))return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;var v=m?p.Node.createConstructorExpression(e.range()):p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),A=null;if(e.skip(s.Token.LESSTHAN)){var N=e.tokenPos;if(!(A=this.parseTypeParameters(e)))return null;m?this.error(o.DiagnosticCode.Type_parameters_cannot_appear_on_a_constructor_declaration,e.range(N,e.pos)):T||E?this.error(o.DiagnosticCode.An_accessor_cannot_have_type_parameters,e.range(N,e.pos)):c|=a.CommonFlags.GENERIC}if(e.skip(s.Token.OPENPAREN)){var C=e.tokenPos,S=this.parseParameters(e,m);if(!S)return null;if(m)for(var O=0,L=S.length;O<L;++O){var b=S[O];if(b.isAny(a.CommonFlags.PUBLIC|a.CommonFlags.PROTECTED|a.CommonFlags.PRIVATE|a.CommonFlags.READONLY)){var k=p.Node.createFieldDeclaration(b.name,b.type,null,null,b.flags|a.CommonFlags.INSTANCE,b.range);k.parameterIndex=O,k.parent=t,b.implicitFieldDeclaration=k,t.members.push(k)}}else T?S.length&&this.error(o.DiagnosticCode.A_get_accessor_cannot_have_parameters,v.range):E&&(1!=S.length&&this.error(o.DiagnosticCode.A_set_accessor_must_have_exactly_one_parameter,v.range),S.length&&S[0].initializer&&this.error(o.DiagnosticCode.A_set_accessor_parameter_cannot_have_an_initializer,v.range));var x=null;if(e.skip(s.Token.COLON)){if(v.kind==p.NodeKind.CONSTRUCTOR?this.error(o.DiagnosticCode.Type_annotation_cannot_appear_on_a_constructor_declaration,e.range()):E&&this.error(o.DiagnosticCode.A_set_accessor_cannot_have_a_return_type_annotation,e.range()),!(x=this.parseType(e,v.kind==p.NodeKind.CONSTRUCTOR||E)))return null}else x=p.Node.createOmittedType(e.range(e.pos)),E||v.kind==p.NodeKind.CONSTRUCTOR||this.error(o.DiagnosticCode.Type_expected,x.range);var R=p.Node.createSignature(S,x,null,!1,e.range(C,e.pos)),B=null;if(e.skip(s.Token.OPENBRACE)){if(c&a.CommonFlags.AMBIENT&&this.error(o.DiagnosticCode.An_implementation_cannot_be_declared_in_ambient_contexts,e.range()),!(B=this.parseBlockStatement(e,!1)))return null}else c&a.CommonFlags.AMBIENT||this.error(o.DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration,e.range());var U=p.Node.createMethodDeclaration(v,A,R,B,n,c,e.range(r,e.pos));return e.skip(s.Token.SEMICOLON),U}if(m)this.error(o.DiagnosticCode.Constructor_implementation_is_missing,v.range);else{if(!T&&!E){c&a.CommonFlags.ABSTRACT&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(h,d),"abstract"),c&a.CommonFlags.GET&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(0,0),"get"),c&a.CommonFlags.SET&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(f,I),"set");var D=null;if(e.skip(s.Token.COLON)){if(!(D=this.parseType(e)))return null}else this.error(o.DiagnosticCode.Type_expected,e.range());var F=null;if(e.skip(s.Token.EQUALS)&&!(F=this.parseExpression(e)))return null;var P=p.Node.createFieldDeclaration(v,D,F,n,c,e.range(r,e.pos));return e.skip(s.Token.SEMICOLON),P}this.error(o.DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration,v.range)}return null},t.prototype.parseNamespace=function(e,t,r,n){if(e.skip(s.Token.IDENTIFIER)){var i=p.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.skip(s.Token.OPENBRACE)){for(var a=new Array,c=p.Node.createNamespaceDeclaration(i,a,r,t,e.range(n,e.pos));!e.skip(s.Token.CLOSEBRACE);){var l=this.parseTopLevelStatement(e,c);if(!l)return null;l.parent=c,a.push(l)}return e.skip(s.Token.SEMICOLON),c}this.error(o.DiagnosticCode._0_expected,e.range(),"{")}else this.error(o.DiagnosticCode.Identifier_expected,e.range());return null},t.prototype.parseExport=function(e,t,r){if(e.skip(s.Token.OPENBRACE)){var n=new Array;if(!e.skip(s.Token.CLOSEBRACE)){do{var i=this.parseExportMember(e);if(!i)return null;n.push(i)}while(e.skip(s.Token.COMMA));if(!e.skip(s.Token.CLOSEBRACE))return this.error(o.DiagnosticCode._0_expected,e.range(),"}"),null}var a=null;if(e.skip(s.Token.FROM)){if(!e.skip(s.Token.STRINGLITERAL))return this.error(o.DiagnosticCode.String_literal_expected,e.range()),null;a=p.Node.createStringLiteralExpression(e.readString(),e.range())}var c=p.Node.createExportStatement(n,a,t,e.range(r,e.pos)),l=c.internalPath;return null==l||this.seenlog.has(l)||(this.backlog.push(l),this.seenlog.add(l)),e.skip(s.Token.SEMICOLON),c}return this.error(o.DiagnosticCode._0_expected,e.range(),"{"),null},t.prototype.parseExportMember=function(e){if(e.skip(s.Token.IDENTIFIER)){var t=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),r=null;if(e.skip(s.Token.AS)){if(!e.skip(s.Token.IDENTIFIER))return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;r=p.Node.createIdentifierExpression(e.readIdentifier(),e.range())}return p.Node.createExportMember(t,r,r?s.Range.join(t.range,r.range):t.range)}return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null},t.prototype.parseImport=function(e){var t=e.tokenPos,r=null,n=null,i=!1;if(e.skip(s.Token.OPENBRACE)){if(r=new Array,!e.skip(s.Token.CLOSEBRACE)){do{var a=this.parseImportDeclaration(e);if(!a)return null;r.push(a)}while(e.skip(s.Token.COMMA));if(!e.skip(s.Token.CLOSEBRACE))return this.error(o.DiagnosticCode._0_expected,e.range(),"}"),null}}else if(e.skip(s.Token.ASTERISK)){if(!e.skip(s.Token.AS))return this.error(o.DiagnosticCode._0_expected,e.range(),"as"),null;if(!e.skip(s.Token.IDENTIFIER))return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;n=p.Node.createIdentifierExpression(e.readIdentifier(),e.range())}else i=!0;if(i||e.skip(s.Token.FROM)){if(e.skip(s.Token.STRINGLITERAL)){var c=p.Node.createStringLiteralExpression(e.readString(),e.range()),l=void 0;n?(assert(!r),l=p.Node.createImportStatementWithWildcard(n,c,e.range(t,e.pos))):l=p.Node.createImportStatement(r,c,e.range(t,e.pos));var u=l.internalPath;return this.seenlog.has(u)||(this.backlog.push(u),this.seenlog.add(u)),e.skip(s.Token.SEMICOLON),l}this.error(o.DiagnosticCode.String_literal_expected,e.range())}else this.error(o.DiagnosticCode._0_expected,e.range(),"from");return null},t.prototype.parseImportDeclaration=function(e){if(e.skip(s.Token.IDENTIFIER)){var t=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),r=null;if(e.skip(s.Token.AS)){if(!e.skip(s.Token.IDENTIFIER))return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;r=p.Node.createIdentifierExpression(e.readIdentifier(),e.range())}return p.Node.createImportDeclaration(t,r,r?s.Range.join(t.range,r.range):t.range)}return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null},t.prototype.parseExportImport=function(e,t){if(e.skip(s.Token.IDENTIFIER)){var r=p.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.skip(s.Token.EQUALS)){if(e.skip(s.Token.IDENTIFIER)){var n=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),i=p.Node.createExportImportStatement(n,r,e.range(t,e.pos));return e.skip(s.Token.SEMICOLON),i}this.error(o.DiagnosticCode.Identifier_expected,e.range())}else this.error(o.DiagnosticCode._0_expected,e.range(),"=")}else this.error(o.DiagnosticCode.Identifier_expected,e.range());return null},t.prototype.parseStatement=function(e,t){void 0===t&&(t=!1);var r=e.mark(),n=null;switch(e.next()){case s.Token.BREAK:n=this.parseBreak(e);break;case s.Token.CONST:n=this.parseVariable(e,a.CommonFlags.CONST,null,e.tokenPos);break;case s.Token.CONTINUE:n=this.parseContinue(e);break;case s.Token.DO:n=this.parseDoStatement(e);break;case s.Token.FOR:n=this.parseForStatement(e);break;case s.Token.IF:n=this.parseIfStatement(e);break;case s.Token.LET:n=this.parseVariable(e,a.CommonFlags.LET,null,e.tokenPos);break;case s.Token.VAR:n=this.parseVariable(e,a.CommonFlags.NONE,null,e.tokenPos);break;case s.Token.OPENBRACE:n=this.parseBlockStatement(e,t);break;case s.Token.RETURN:t&&this.error(o.DiagnosticCode.A_return_statement_can_only_be_used_within_a_function_body,e.range()),n=this.parseReturn(e);break;case s.Token.SEMICOLON:return p.Node.createEmptyStatement(e.range(e.tokenPos));case s.Token.SWITCH:n=this.parseSwitchStatement(e);break;case s.Token.THROW:n=this.parseThrowStatement(e);break;case s.Token.TRY:n=this.parseTryStatement(e);break;case s.Token.TYPE:n=this.parseTypeDeclaration(e,a.CommonFlags.NONE,null,e.tokenPos);break;case s.Token.VOID:n=this.parseVoidStatement(e);break;case s.Token.WHILE:n=this.parseWhileStatement(e);break;default:e.reset(r),n=this.parseExpressionStatement(e)}return n?e.discard(r):(e.reset(r),this.skipStatement(e)),n},t.prototype.parseBlockStatement=function(e,t){for(var r=e.tokenPos,n=new Array;!e.skip(s.Token.CLOSEBRACE);){var i=e.mark(),a=this.parseStatement(e,t);a?(e.discard(i),n.push(a)):(e.reset(i),this.skipStatement(e))}var o=p.Node.createBlockStatement(n,e.range(r,e.pos));return e.skip(s.Token.SEMICOLON),o},t.prototype.parseBreak=function(e){var t=null;e.peek(!0)!=s.Token.IDENTIFIER||e.nextTokenOnNewLine||(e.next(!0),t=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()));var r=p.Node.createBreakStatement(t,e.range());return e.skip(s.Token.SEMICOLON),r},t.prototype.parseContinue=function(e){var t=null;e.peek(!0)!=s.Token.IDENTIFIER||e.nextTokenOnNewLine||(e.next(!0),t=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()));var r=p.Node.createContinueStatement(t,e.range());return e.skip(s.Token.SEMICOLON),r},t.prototype.parseDoStatement=function(e){var t=e.tokenPos,r=this.parseStatement(e);if(!r)return null;if(e.skip(s.Token.WHILE))if(e.skip(s.Token.OPENPAREN)){var n=this.parseExpression(e);if(!n)return null;if(e.skip(s.Token.CLOSEPAREN)){var i=p.Node.createDoStatement(r,n,e.range(t,e.pos));return e.skip(s.Token.SEMICOLON),i}this.error(o.DiagnosticCode._0_expected,e.range(),")")}else this.error(o.DiagnosticCode._0_expected,e.range(),"(");else this.error(o.DiagnosticCode._0_expected,e.range(),"while");return null},t.prototype.parseExpressionStatement=function(e){var t=this.parseExpression(e);if(!t)return null;var r=p.Node.createExpressionStatement(t);return e.skip(s.Token.SEMICOLON),r},t.prototype.parseForStatement=function(e){var t=e.tokenPos;if(e.skip(s.Token.OPENPAREN)){var r=null;if(e.skip(s.Token.CONST))r=this.parseVariable(e,a.CommonFlags.CONST,null,e.tokenPos);else if(e.skip(s.Token.LET))r=this.parseVariable(e,a.CommonFlags.LET,null,e.tokenPos);else if(e.skip(s.Token.VAR))r=this.parseVariable(e,a.CommonFlags.NONE,null,e.tokenPos);else if(!e.skip(s.Token.SEMICOLON)&&!(r=this.parseExpressionStatement(e)))return null;if(e.token==s.Token.SEMICOLON){var n=null;if(!e.skip(s.Token.SEMICOLON)&&!(n=this.parseExpressionStatement(e)))return null;if(e.token==s.Token.SEMICOLON){var i=null;if(!e.skip(s.Token.CLOSEPAREN)){if(!(i=this.parseExpression(e)))return null;if(!e.skip(s.Token.CLOSEPAREN))return this.error(o.DiagnosticCode._0_expected,e.range(),")"),null}var c=this.parseStatement(e);return c?p.Node.createForStatement(r,n?n.expression:null,i,c,e.range(t,e.pos)):null}this.error(o.DiagnosticCode._0_expected,e.range(),";")}else this.error(o.DiagnosticCode._0_expected,e.range(),";")}else this.error(o.DiagnosticCode._0_expected,e.range(),"(");return null},t.prototype.parseIfStatement=function(e){var t=e.tokenPos;if(e.skip(s.Token.OPENPAREN)){var r=this.parseExpression(e);if(!r)return null;if(e.skip(s.Token.CLOSEPAREN)){var n=this.parseStatement(e);if(!n)return null;var i=null;return e.skip(s.Token.ELSE)&&!(i=this.parseStatement(e))?null:p.Node.createIfStatement(r,n,i,e.range(t,e.pos))}this.error(o.DiagnosticCode._0_expected,e.range(),")")}else this.error(o.DiagnosticCode._0_expected,e.range(),"(");return null},t.prototype.parseSwitchStatement=function(e){var t=e.tokenPos;if(e.skip(s.Token.OPENPAREN)){var r=this.parseExpression(e);if(!r)return null;if(e.skip(s.Token.CLOSEPAREN)){if(e.skip(s.Token.OPENBRACE)){for(var n=new Array;!e.skip(s.Token.CLOSEBRACE);){var i=this.parseSwitchCase(e);if(!i)return null;n.push(i)}var a=p.Node.createSwitchStatement(r,n,e.range(t,e.pos));return e.skip(s.Token.SEMICOLON),a}this.error(o.DiagnosticCode._0_expected,e.range(),"{")}else this.error(o.DiagnosticCode._0_expected,e.range(),")")}else this.error(o.DiagnosticCode._0_expected,e.range(),"(");return null},t.prototype.parseSwitchCase=function(e){var t,r,n=e.tokenPos;if(e.skip(s.Token.CASE)){var i=this.parseExpression(e);if(!i)return null;if(e.skip(s.Token.COLON)){for(t=new Array;e.peek()!=s.Token.CASE&&e.nextToken!=s.Token.DEFAULT&&e.nextToken!=s.Token.CLOSEBRACE;){if(!(r=this.parseStatement(e)))return null;t.push(r)}return p.Node.createSwitchCase(i,t,e.range(n,e.pos))}this.error(o.DiagnosticCode._0_expected,e.range(),":")}else if(e.skip(s.Token.DEFAULT)){if(e.skip(s.Token.COLON)){for(t=new Array;e.peek()!=s.Token.CASE&&e.nextToken!=s.Token.DEFAULT&&e.nextToken!=s.Token.CLOSEBRACE;){if(!(r=this.parseStatement(e)))return null;t.push(r)}return p.Node.createSwitchCase(null,t,e.range(n,e.pos))}this.error(o.DiagnosticCode._0_expected,e.range(),":")}else this.error(o.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=p.Node.createThrowStatement(r,e.range(t,e.pos));return e.skip(s.Token.SEMICOLON),n},t.prototype.parseTryStatement=function(e){var t,r=e.tokenPos;if(e.skip(s.Token.OPENBRACE)){for(var n=new Array;!e.skip(s.Token.CLOSEBRACE);){if(!(t=this.parseStatement(e)))return null;n.push(t)}var i=null,a=null,c=null;if(e.skip(s.Token.CATCH)){if(!e.skip(s.Token.OPENPAREN))return this.error(o.DiagnosticCode._0_expected,e.range(),"("),null;if(!e.skip(s.Token.IDENTIFIER))return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;if(i=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),!e.skip(s.Token.CLOSEPAREN))return this.error(o.DiagnosticCode._0_expected,e.range(),")"),null;if(!e.skip(s.Token.OPENBRACE))return this.error(o.DiagnosticCode._0_expected,e.range(),"{"),null;for(a=[];!e.skip(s.Token.CLOSEBRACE);){if(!(t=this.parseStatement(e)))return null;a.push(t)}}if(e.skip(s.Token.FINALLY)){if(!e.skip(s.Token.OPENBRACE))return this.error(o.DiagnosticCode._0_expected,e.range(),"{"),null;for(c=[];!e.skip(s.Token.CLOSEBRACE);){if(!(t=this.parseStatement(e)))return null;c.push(t)}}if(!a&&!c)return this.error(o.DiagnosticCode._0_expected,e.range(),"catch"),null;var l=p.Node.createTryStatement(n,i,a,c,e.range(r,e.pos));return e.skip(s.Token.SEMICOLON),l}return this.error(o.DiagnosticCode._0_expected,e.range(),"{"),null},t.prototype.parseTypeDeclaration=function(e,t,r,n){if(e.skip(s.Token.IDENTIFIER)){var i=p.Node.createIdentifierExpression(e.readIdentifier(),e.range()),c=null;if(e.skip(s.Token.LESSTHAN)){if(!(c=this.parseTypeParameters(e)))return null;t|=a.CommonFlags.GENERIC}if(e.skip(s.Token.EQUALS)){var l=this.parseType(e);if(!l)return null;var u=p.Node.createTypeDeclaration(i,c,l,r,t,e.range(n,e.pos));return e.skip(s.Token.SEMICOLON),u}this.error(o.DiagnosticCode._0_expected,e.range(),"=")}else this.error(o.DiagnosticCode.Identifier_expected,e.range());return null},t.prototype.parseVoidStatement=function(e){var t=e.tokenPos,r=this.parseExpression(e,20);if(!r)return null;var n=p.Node.createVoidStatement(r,e.range(t,e.pos));return e.skip(s.Token.SEMICOLON),n},t.prototype.parseWhileStatement=function(e){var t=e.tokenPos;if(e.skip(s.Token.OPENPAREN)){var r=this.parseExpression(e);if(!r)return null;if(e.skip(s.Token.CLOSEPAREN)){var n=this.parseStatement(e);if(!n)return null;var i=p.Node.createWhileStatement(r,n,e.range(t,e.pos));return e.skip(s.Token.SEMICOLON),i}this.error(o.DiagnosticCode._0_expected,e.range(),")")}else this.error(o.DiagnosticCode._0_expected,e.range(),"(");return null},t.prototype.parseExpressionStart=function(e){var t=e.next(!0),r=e.tokenPos,n=null;if(t==s.Token.NULL)return p.Node.createNullExpression(e.range());if(t==s.Token.TRUE)return p.Node.createTrueExpression(e.range());if(t==s.Token.FALSE)return p.Node.createFalseExpression(e.range());var i=function(e){switch(e){case s.Token.DOT_DOT_DOT:return 1;case s.Token.YIELD:return 2;case s.Token.EXCLAMATION:case s.Token.TILDE:case s.Token.PLUS:case s.Token.MINUS:case s.Token.PLUS_PLUS:case s.Token.MINUS_MINUS:case s.Token.TYPEOF:case s.Token.VOID:case s.Token.DELETE:return 16;case s.Token.NEW:return 19;default:return-1}}(t);if(-1!=i){var a=void 0;return t==s.Token.NEW?(a=this.parseExpression(e,18))?a.kind==p.NodeKind.CALL?p.Node.createNewExpression(a.expression,a.typeArguments,a.arguments,e.range(r,e.pos)):(this.error(o.DiagnosticCode.Operation_not_supported,e.range()),null):null:(a=this.parseExpression(e,i))?(t!=s.Token.PLUS_PLUS&&t!=s.Token.MINUS_MINUS||a.kind!=p.NodeKind.IDENTIFIER&&a.kind!=p.NodeKind.ELEMENTACCESS&&a.kind!=p.NodeKind.PROPERTYACCESS&&this.error(o.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access,a.range),p.Node.createUnaryPrefixExpression(t,a,e.range(r,e.pos))):null}switch(t){case s.Token.OPENPAREN:if(e.skip(s.Token.CLOSEPAREN))return this.parseFunctionExpressionCommon(e,p.Node.createEmptyIdentifierExpression(e.range(r)),[],!0);var c=e.mark(),l=!0;do{switch(e.next(!0)){case s.Token.DOT_DOT_DOT:return e.reset(c),this.parseFunctionExpression(e);case s.Token.IDENTIFIER:switch(e.readIdentifier(),e.next()){case s.Token.CLOSEPAREN:if(!e.skip(s.Token.EQUALS_GREATERTHAN)){l=!1;break}case s.Token.COLON:return e.reset(c),this.parseFunctionExpression(e);case s.Token.QUESTION:case s.Token.COMMA:break;default:l=!1}break;default:l=!1}}while(l);return e.reset(c),(n=this.parseExpression(e))?e.skip(s.Token.CLOSEPAREN)?p.Node.createParenthesizedExpression(n,e.range(r,e.pos)):(this.error(o.DiagnosticCode._0_expected,e.range(),")"),null):null;case s.Token.OPENBRACKET:for(var u=new Array;!e.skip(s.Token.CLOSEBRACKET);){if(e.peek()==s.Token.COMMA)n=null;else if(!(n=this.parseExpression(e,1)))return null;if(u.push(n),!e.skip(s.Token.COMMA)){if(e.skip(s.Token.CLOSEBRACKET))break;return this.error(o.DiagnosticCode._0_expected,e.range(),"]"),null}}return p.Node.createArrayLiteralExpression(u,e.range(r,e.pos));case s.Token.LESSTHAN:var h=this.parseType(e);return h?e.skip(s.Token.GREATERTHAN)?(n=this.parseExpression(e,18))?p.Node.createAssertionExpression(p.AssertionKind.PREFIX,n,h,e.range(r,e.pos)):null:(this.error(o.DiagnosticCode._0_expected,e.range(),">"),null):null;case s.Token.IDENTIFIER:return p.Node.createIdentifierExpression(e.readIdentifier(),e.range(r,e.pos));case s.Token.THIS:return p.Node.createThisExpression(e.range(r,e.pos));case s.Token.CONSTRUCTOR:return p.Node.createConstructorExpression(e.range(r,e.pos));case s.Token.SUPER:return p.Node.createSuperExpression(e.range(r,e.pos));case s.Token.STRINGLITERAL:return p.Node.createStringLiteralExpression(e.readString(),e.range(r,e.pos));case s.Token.INTEGERLITERAL:return p.Node.createIntegerLiteralExpression(e.readInteger(),e.range(r,e.pos));case s.Token.FLOATLITERAL:return p.Node.createFloatLiteralExpression(e.readFloat(),e.range(r,e.pos));case s.Token.SLASH:var d=e.readRegexpPattern();return e.skip(s.Token.SLASH)?p.Node.createRegexpLiteralExpression(d,e.readRegexpFlags(),e.range(r,e.pos)):(this.error(o.DiagnosticCode._0_expected,e.range(),"/"),null);case s.Token.FUNCTION:return this.parseFunctionExpression(e);default:return this.error(o.DiagnosticCode.Expression_expected,e.range()),null}},t.prototype.tryParseTypeArgumentsBeforeArguments=function(e){var t=e.mark();if(!e.skip(s.Token.LESSTHAN))return null;var r=new Array;do{if(e.peek()===s.Token.GREATERTHAN)break;var n=this.parseType(e,!0,!0);if(!n)return e.reset(t),null;r.push(n)}while(e.skip(s.Token.COMMA));return e.skip(s.Token.GREATERTHAN)&&e.skip(s.Token.OPENPAREN)?r:(e.reset(t),null)},t.prototype.parseArguments=function(e){for(var t=new Array;!e.skip(s.Token.CLOSEPAREN);){var r=this.parseExpression(e,1);if(!r)return null;if(t.push(r),!e.skip(s.Token.COMMA)){if(e.skip(s.Token.CLOSEPAREN))break;return this.error(o.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;for(var n,i,a=r.range.start;(n=this.tryParseTypeArgumentsBeforeArguments(e))||e.skip(s.Token.OPENPAREN);){var c=this.parseArguments(e);if(!c)return null;r=p.Node.createCallExpression(r,n,c,e.range(a,e.pos))}for(var l,u=null;(l=h(i=e.peek()))>=t;)switch(e.next(),i){case s.Token.AS:var _=this.parseType(e);if(!_)return null;r=p.Node.createAssertionExpression(p.AssertionKind.AS,r,_,e.range(a,e.pos));break;case s.Token.OPENBRACKET:if(!(u=this.parseExpression(e)))return null;if(!e.skip(s.Token.CLOSEBRACKET))return this.error(o.DiagnosticCode._0_expected,e.range(),"]"),null;r=p.Node.createElementAccessExpression(r,u,e.range(a,e.pos));break;case s.Token.PLUS_PLUS:case s.Token.MINUS_MINUS:r.kind!=p.NodeKind.IDENTIFIER&&r.kind!=p.NodeKind.ELEMENTACCESS&&r.kind!=p.NodeKind.PROPERTYACCESS&&this.error(o.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access,r.range),r=p.Node.createUnaryPostfixExpression(i,r,e.range(a,e.pos));break;case s.Token.QUESTION:var y=this.parseExpression(e);if(!y)return null;if(!e.skip(s.Token.COLON))return this.error(o.DiagnosticCode._0_expected,e.range(),":"),null;var g=this.parseExpression(e,t>0?1:0);if(!g)return null;r=p.Node.createTernaryExpression(r,y,g,e.range(a,e.pos));break;case s.Token.COMMA:var m=[r];do{if(!(r=this.parseExpression(e,1)))return null;m.push(r)}while(e.skip(s.Token.COMMA));r=p.Node.createCommaExpression(m,e.range(a,e.pos));break;default:if(!(u=this.parseExpression(e,d(i)?l:l+1)))return null;if(i==s.Token.DOT)if(u.kind==p.NodeKind.IDENTIFIER)r=p.Node.createPropertyAccessExpression(r,u,e.range(a,e.pos));else{if(u.kind!=p.NodeKind.CALL)return this.error(o.DiagnosticCode.Identifier_expected,u.range),null;var T=u;if(T.expression.kind!=p.NodeKind.IDENTIFIER)return this.error(o.DiagnosticCode.Identifier_expected,T.expression.range),null;T.expression=p.Node.createPropertyAccessExpression(r,T.expression,e.range(a,e.pos)),r=T}else r=p.Node.createBinaryExpression(i,r,u,e.range(a,e.pos))}return r},t.prototype.skipStatement=function(e){for(e.peek(!0),e.nextTokenOnNewLine&&e.next();;){var t=e.peek(!0);if(t==s.Token.ENDOFFILE||t==s.Token.SEMICOLON){e.next();break}if(e.nextTokenOnNewLine)break;switch(e.next()){case s.Token.IDENTIFIER:e.readIdentifier();break;case s.Token.STRINGLITERAL:e.readString();break;case s.Token.INTEGERLITERAL:e.readInteger();break;case s.Token.FLOATLITERAL:e.readFloat()}}},t}(o.DiagnosticEmitter);function h(e){switch(e){case s.Token.COMMA:return 0;case s.Token.EQUALS:case s.Token.PLUS_EQUALS:case s.Token.MINUS_EQUALS:case s.Token.ASTERISK_ASTERISK_EQUALS:case s.Token.ASTERISK_EQUALS:case s.Token.SLASH_EQUALS:case s.Token.PERCENT_EQUALS:case s.Token.LESSTHAN_LESSTHAN_EQUALS:case s.Token.GREATERTHAN_GREATERTHAN_EQUALS:case s.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS:case s.Token.AMPERSAND_EQUALS:case s.Token.CARET_EQUALS:case s.Token.BAR_EQUALS:return 3;case s.Token.QUESTION:return 4;case s.Token.BAR_BAR:return 5;case s.Token.AMPERSAND_AMPERSAND:return 6;case s.Token.BAR:return 7;case s.Token.CARET:return 8;case s.Token.AMPERSAND:return 9;case s.Token.EQUALS_EQUALS:case s.Token.EXCLAMATION_EQUALS:case s.Token.EQUALS_EQUALS_EQUALS:case s.Token.EXCLAMATION_EQUALS_EQUALS:return 10;case s.Token.AS:case s.Token.IN:case s.Token.INSTANCEOF:case s.Token.LESSTHAN:case s.Token.GREATERTHAN:case s.Token.LESSTHAN_EQUALS:case s.Token.GREATERTHAN_EQUALS:return 11;case s.Token.LESSTHAN_LESSTHAN:case s.Token.GREATERTHAN_GREATERTHAN:case s.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN:return 12;case s.Token.PLUS:case s.Token.MINUS:return 13;case s.Token.ASTERISK:case s.Token.SLASH:case s.Token.PERCENT:return 14;case s.Token.ASTERISK_ASTERISK:return 15;case s.Token.PLUS_PLUS:case s.Token.MINUS_MINUS:return 17;case s.Token.DOT:case s.Token.NEW:case s.Token.OPENBRACKET:return 19;default:return-1}}function d(e){switch(e){case s.Token.EQUALS:case s.Token.PLUS_EQUALS:case s.Token.MINUS_EQUALS:case s.Token.ASTERISK_ASTERISK_EQUALS:case s.Token.ASTERISK_EQUALS:case s.Token.SLASH_EQUALS:case s.Token.PERCENT_EQUALS:case s.Token.LESSTHAN_LESSTHAN_EQUALS:case s.Token.GREATERTHAN_GREATERTHAN_EQUALS:case s.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS:case s.Token.AMPERSAND_EQUALS:case s.Token.CARET_EQUALS:case s.Token.BAR_EQUALS:case s.Token.QUESTION:case s.Token.ASTERISK_ASTERISK:return!0;default:return!1}}t.Parser=u,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={}))},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=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])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),a=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}}}},s=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),s=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)s.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 s};Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),c=r(1),p=function(){function e(e,t){void 0===t&&(t=!1),this.seen=new Set,this.program=e,this.includePrivate}return e.prototype.walk=function(){try{for(var e=a(this.program.moduleLevelExports.values()),t=e.next();!t.done;t=e.next()){var r=t.value;this.visitElement(r)}}catch(e){n={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(n)throw n.error}}var n,i},e.prototype.visitElement=function(e){if((!e.is(o.CommonFlags.PRIVATE)||this.includePrivate)&&!this.seen.has(e))switch(this.seen.add(e),e.kind){case o.ElementKind.GLOBAL:e.is(o.CommonFlags.COMPILED)&&this.visitGlobal(e);break;case o.ElementKind.ENUM:e.is(o.CommonFlags.COMPILED)&&this.visitEnum(e);break;case o.ElementKind.FUNCTION_PROTOTYPE:this.visitFunctionInstances(e);break;case o.ElementKind.CLASS_PROTOTYPE:this.visitClassInstances(e);break;case o.ElementKind.FIELD:e.is(o.CommonFlags.COMPILED)&&this.visitField(e);break;case o.ElementKind.PROPERTY:var t=e,r=t.getterPrototype;r&&this.visitFunctionInstances(r);var n=t.setterPrototype;n&&this.visitFunctionInstances(n);break;case o.ElementKind.NAMESPACE:(function e(t){var r=t.members;if(r)try{for(var n=a(r.values()),i=n.next();!i.done;i=n.next()){var s=i.value;switch(s.kind){case o.ElementKind.FUNCTION_PROTOTYPE:try{for(var c=a(s.instances.values()),p=c.next();!p.done;p=c.next()){var l=p.value;if(l.is(o.CommonFlags.COMPILED))return!0}}catch(e){y={error:e}}finally{try{p&&!p.done&&(g=c.return)&&g.call(c)}finally{if(y)throw y.error}}break;case o.ElementKind.CLASS_PROTOTYPE:try{for(var u=a(s.instances.values()),h=u.next();!h.done;h=u.next()){var l=h.value;if(l.is(o.CommonFlags.COMPILED))return!0}}catch(e){m={error:e}}finally{try{h&&!h.done&&(T=u.return)&&T.call(u)}finally{if(m)throw m.error}}break;default:if(s.is(o.CommonFlags.COMPILED)||e(s))return!0}}}catch(e){d={error:e}}finally{try{i&&!i.done&&(_=n.return)&&_.call(n)}finally{if(d)throw d.error}}return!1;var d,_,y,g,m,T})(e)&&this.visitNamespace(e);break;default:assert(!1)}},e.prototype.visitFunctionInstances=function(e){try{for(var t=a(e.instances.values()),r=t.next();!r.done;r=t.next()){var n=r.value;n.is(o.CommonFlags.COMPILED)&&this.visitFunction(n)}}catch(e){i={error:e}}finally{try{r&&!r.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}var i,s},e.prototype.visitClassInstances=function(e){try{for(var t=a(e.instances.values()),r=t.next();!r.done;r=t.next()){var n=r.value;n.is(o.CommonFlags.COMPILED)&&this.visitClass(n)}}catch(e){i={error:e}}finally{try{r&&!r.done&&(s=t.return)&&s.call(t)}finally{if(i)throw i.error}}var i,s},e}(),l=function(e){function t(t,r){void 0===r&&(r=!1);var n=e.call(this,t,r)||this;return n.sb=[],n.indentLevel=0,n}return i(t,e),t.build=function(e){return new t(e).build()},t.prototype.visitGlobal=function(e){var t=this.sb,r=e.is(o.CommonFlags.INLINED);if(c.indent(t,this.indentLevel),r&&t.push("const "),t.push(this.typeToString(e.type)),t.push(" "),t.push(e.simpleName),r)switch(e.constantValueKind){case 1:t.push(" = "),t.push(i64_to_string(e.constantIntegerValue));break;case 2:t.push(" = "),t.push(e.constantFloatValue.toString());break;default:assert(!1)}t.push(";\n")},t.prototype.visitEnum=function(e){var t=this.sb;c.indent(t,this.indentLevel++),t.push("interface "),t.push(e.simpleName),t.push(" {\n");var r,n,i,p,l=e.members;if(l){try{for(var u=a(l),h=u.next();!h.done;h=u.next()){var d=s(h.value,2),_=d[0];if((T=d[1]).kind==o.ElementKind.ENUMVALUE){var y=T.is(o.CommonFlags.INLINED);c.indent(t,this.indentLevel),y?t.push("const "):t.push("readonly "),t.push("unsigned long "),t.push(_),y&&(t.push(" = "),t.push(T.constantValue.toString(10))),t.push(";\n")}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}try{for(var g=a(l.values()),m=g.next();!m.done;m=g.next()){var T;(T=m.value).kind!=o.ElementKind.ENUMVALUE&&this.visitElement(T)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(p=g.return)&&p.call(g)}finally{if(i)throw i.error}}}c.indent(t,--this.indentLevel),t.push("}\n")},t.prototype.visitFunction=function(e){var t=this.sb,r=e.signature;c.indent(t,this.indentLevel),t.push(this.typeToString(r.returnType)),t.push(" "),t.push(e.simpleName),t.push("(");for(var n=r.parameterTypes,i=n.length,s=0;s<i;++s)s&&t.push(", "),t.push(this.typeToString(n[s])),t.push(" "),t.push(r.getParameterName(s));t.push(");\n");var o,p,l=e.members;if(l&&l.size){c.indent(t,this.indentLevel),t.push("interface "),t.push(e.simpleName),t.push(" {\n");try{for(var u=a(l.values()),h=u.next();!h.done;h=u.next()){var d=h.value;this.visitElement(d)}}catch(e){o={error:e}}finally{try{h&&!h.done&&(p=u.return)&&p.call(u)}finally{if(o)throw o.error}}c.indent(t,--this.indentLevel),t.push("}\n")}},t.prototype.visitClass=function(e){var t=this.sb;c.indent(t,this.indentLevel++),t.push("interface "),t.push(e.simpleName),t.push(" {\n"),c.indent(t,--this.indentLevel),t.push("}\n")},t.prototype.visitInterface=function(e){this.visitClass(e)},t.prototype.visitField=function(e){},t.prototype.visitNamespace=function(e){var t=this.sb;c.indent(t,this.indentLevel++),t.push("interface "),t.push(e.simpleName),t.push(" {\n");var r,n,i=e.members;if(i)try{for(var s=a(i.values()),o=s.next();!o.done;o=s.next()){var p=o.value;this.visitElement(p)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}c.indent(t,--this.indentLevel),t.push("}\n")},t.prototype.typeToString=function(e){switch(e.kind){case 0:return"byte";case 1:return"short";case 2:return"long";case 3:return"long long";case 4:return this.program.options.isWasm64?"long long":"long";case 5:return"octet";case 6:return"unsigned short";case 7:return"unsigned long";case 8:return"unsigned long long";case 9:return this.program.options.isWasm64?"unsigned long long":"unsigned long";case 10:return"boolean";case 11:return"unrestricted float";case 12:return"unrestricted double";case 13:return"void";default:return assert(!1),""}},t.prototype.build=function(){var e=this.sb;return e.push("interface ASModule {\n"),++this.indentLevel,this.walk(),--this.indentLevel,e.push("}\n"),e.join("")},t}(p);t.IDLBuilder=l;var u=function(e){function t(t,r){void 0===r&&(r=!1);var n=e.call(this,t,r)||this;return n.sb=[],n.indentLevel=0,n}return i(t,e),t.build=function(e){return new t(e).build()},t.prototype.visitGlobal=function(e){var t=this.sb,r=e.is(o.CommonFlags.INLINED);c.indent(t,this.indentLevel),e.is(o.CommonFlags.STATIC)?r?t.push("static readonly "):assert(!1):r?t.push("const "):t.push("var "),t.push(e.simpleName),t.push(": "),t.push(this.typeToString(e.type)),t.push(";\n"),this.visitNamespace(e)},t.prototype.visitEnum=function(e){var t=this.sb;c.indent(t,this.indentLevel++),t.push("enum "),t.push(e.simpleName),t.push(" {\n");var r,n,i=e.members;if(i){var p=i.size;try{for(var l=a(i),u=l.next();!u.done;u=l.next()){var h=s(u.value,2),d=h[0],_=h[1];_.kind==o.ElementKind.ENUMVALUE&&(c.indent(t,this.indentLevel),t.push(d),_.is(o.CommonFlags.INLINED)&&(t.push(" = "),t.push(_.constantValue.toString(10))),t.push(",\n"),--p)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}p&&this.visitNamespace(e)}c.indent(t,--this.indentLevel),t.push("}\n")},t.prototype.visitFunction=function(e){if(!e.is(o.CommonFlags.PRIVATE)){var t=this.sb,r=e.signature;c.indent(t,this.indentLevel),e.is(o.CommonFlags.PROTECTED)&&t.push("protected "),e.is(o.CommonFlags.STATIC)&&t.push("static "),e.is(o.CommonFlags.GET)?(t.push("get "),t.push(e.prototype.declaration.name.text)):e.is(o.CommonFlags.SET)?(t.push("set "),t.push(e.prototype.declaration.name.text)):(e.is(o.CommonFlags.INSTANCE)||t.push("function "),t.push(e.simpleName)),t.push("(");for(var n=r.parameterTypes,i=n.length,a=0;a<i;++a)a&&t.push(", "),t.push(r.getParameterName(a)),t.push(": "),t.push(this.typeToString(n[a]));e.isAny(o.CommonFlags.CONSTRUCTOR|o.CommonFlags.SET)?t.push(")"):(t.push("): "),t.push(this.typeToString(r.returnType))),t.push(";\n"),this.visitNamespace(e)}},t.prototype.visitClass=function(e){var t=this.sb,r=e.kind==o.ElementKind.INTERFACE;c.indent(t,this.indentLevel++),r?t.push("interface "):(e.is(o.CommonFlags.ABSTRACT)&&t.push("abstract "),t.push("class ")),t.push(e.simpleName);var n=e.base;n&&n.is(o.CommonFlags.COMPILED|o.CommonFlags.MODULE_EXPORT)&&(t.push(" extends "),t.push(n.simpleName)),t.push(" {\n");var i=e.prototype.members;if(i)try{for(var s=a(i.values()),p=s.next();!p.done;p=s.next()){var l=p.value;this.visitElement(l)}}catch(e){u={error:e}}finally{try{p&&!p.done&&(h=s.return)&&h.call(s)}finally{if(u)throw u.error}}var u,h,d,_,y=e.constructorInstance;if(y&&this.visitFunction(y),i=e.members)try{for(var g=a(i.values()),m=g.next();!m.done;m=g.next()){l=m.value;this.visitElement(l)}}catch(e){d={error:e}}finally{try{m&&!m.done&&(_=g.return)&&_.call(g)}finally{if(d)throw d.error}}c.indent(t,--this.indentLevel),t.push("}\n")},t.prototype.visitInterface=function(e){this.visitClass(e)},t.prototype.visitField=function(e){if(!e.is(o.CommonFlags.PRIVATE)){var t=this.sb;c.indent(t,this.indentLevel),e.is(o.CommonFlags.PROTECTED)&&t.push("protected "),e.is(o.CommonFlags.STATIC)&&t.push("static "),e.is(o.CommonFlags.READONLY)&&t.push("readonly "),t.push(e.simpleName),t.push(": "),t.push(this.typeToString(e.type)),t.push(";\n")}},t.prototype.visitNamespace=function(e){var t,r,n=e.members;if(n&&n.size){var i=this.sb;c.indent(i,this.indentLevel++),i.push("namespace "),i.push(e.simpleName),i.push(" {\n");try{for(var s=a(n.values()),o=s.next();!o.done;o=s.next()){var p=o.value;this.visitElement(p)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}c.indent(i,--this.indentLevel),i.push("}\n")}},t.prototype.typeToString=function(e){switch(e.kind){case 0:return"i8";case 1:return"i16";case 2:return"i32";case 3:return"I64";case 4:return this.program.options.isWasm64?"I64":"i32";case 5:return"u8";case 6:return"u16";case 7:return"u32";case 8:return"U64";case 9:return this.program.options.isWasm64?"U64":"u32";case 10:return"bool";case 11:return"f32";case 12:return"f64";case 13:return"void";default:return assert(!1),""}},t.prototype.build=function(){var e=this.sb;return e.push("declare module ASModule {\n"),e.push(" type i8 = number;\n"),e.push(" type i16 = number;\n"),e.push(" type i32 = number;\n"),e.push(" type u8 = number;\n"),e.push(" type u16 = number;\n"),e.push(" type u32 = number;\n"),e.push(" type f32 = number;\n"),e.push(" type f64 = number;\n"),e.push(" type bool = any;\n"),++this.indentLevel,this.walk(),--this.indentLevel,e.push("}\n"),this.sb.join("")},t}(p);t.TSDBuilder=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(3),i=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=n.getFunctionName(e)||"$"+this.functionId.toString(10),r=n.getFunctionBody(e);this.push("function "),this.push(t),this.push("(");for(var i=0,s=n.getFunctionParamCount(e);i<s;++i)i>0&&this.push(", "),this.push("$"),this.push(i.toString(10)),this.push(": "),this.push(a(n.getFunctionParamType(e,i)));this.push("): "),this.push(a(n.getFunctionResultType(e))),this.push(" "),n.getExpressionId(r)!=n.ExpressionId.Block&&this.push("{\n"),this.decompileExpression(r),n.getExpressionId(r)!=n.ExpressionId.Block&&this.push("\n}\n"),++this.functionId},e.prototype.decompileExpression=function(e){var t,r,i,s,o=n.getExpressionId(e),c=n.getExpressionType(e);switch(o){case n.ExpressionId.Block:for(null!=(r=n.getBlockName(e))&&(this.push(r),this.push(": ")),this.push("{\n"),s=n.getBlockChildCount(e),i=0;i<s;++i)this.decompileExpression(n.getBlockChild(e,i));return void this.push("}\n");case n.ExpressionId.If:return void(c==n.NativeType.None?(this.push("if ("),this.decompileExpression(n.getIfCondition(e)),this.push(") "),this.decompileExpression(n.getIfTrue(e)),(t=n.getIfFalse(e))&&(this.push(" else "),this.decompileExpression(t))):(this.decompileExpression(n.getIfCondition(e)),this.push(" ? "),this.decompileExpression(n.getIfTrue(e)),this.push(" : "),this.decompileExpression(n.getIfFalse(e))));case n.ExpressionId.Loop:null!=(r=n.getLoopName(e))&&(this.push(r),this.push(": ")),this.push("do "),this.decompileExpression(n.getLoopBody(e)),this.push("while (0);\n");case n.ExpressionId.Break:return(t=n.getBreakCondition(e))&&(this.push("if ("),this.decompileExpression(t),this.push(") ")),void(null!=(r=n.getBreakName(e))?(this.push("break "),this.push(r),this.push(";\n")):this.push("break;\n"));case n.ExpressionId.Switch:case n.ExpressionId.Call:case n.ExpressionId.CallImport:case n.ExpressionId.CallIndirect:throw new Error("not implemented");case n.ExpressionId.GetLocal:return this.push("$"),void this.push(n.getGetLocalIndex(e).toString(10));case n.ExpressionId.SetLocal:return this.push("$"),this.push(n.getSetLocalIndex(e).toString(10)),this.push(" = "),void this.decompileExpression(n.getSetLocalValue(e));case n.ExpressionId.GetGlobal:case n.ExpressionId.SetGlobal:throw new Error("not implemented");case n.ExpressionId.Load:return this.push("load<"),this.push(a(c)),this.push(">("),this.push(n.getLoadOffset(e).toString(10)),this.push(" + "),this.decompileExpression(n.getLoadPtr(e)),void this.push(")");case n.ExpressionId.Store:return this.push("store<"),this.push(a(c)),this.push(">("),this.push(n.getStoreOffset(e).toString(10)),this.push(" + "),this.decompileExpression(n.getStorePtr(e)),this.push(", "),this.decompileExpression(n.getStoreValue(e)),void this.push(")");case n.ExpressionId.Const:switch(c){case n.NativeType.I32:return void this.push(n.getConstValueI32(e).toString(10));case n.NativeType.I64:return void this.push(i64_to_string(i64_new(n.getConstValueI64Low(e),n.getConstValueI64High(e))));case n.NativeType.F32:return void this.push(n.getConstValueF32(e).toString(10));case n.NativeType.F64:return void this.push(n.getConstValueF64(e).toString(10))}break;case n.ExpressionId.Unary:switch(n.getUnaryOp(e)){case n.UnaryOp.ClzI32:return this.push("clz<i32>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.CtzI32:return this.push("ctz<i32>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.PopcntI32:return this.push("popcnt<i32>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.NegF32:case n.UnaryOp.NegF64:return this.push("-"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.AbsF32:return this.push("abs<f32>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.CeilF32:return this.push("ceil<f32>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.FloorF32:return this.push("floor<f32>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.TruncF32:return this.push("trunc<f32>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.NearestF32:return this.push("nearest<i32>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.SqrtF32:return this.push("sqrt<f32>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.EqzI32:case n.UnaryOp.EqzI64:return this.push("!"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.ClzI64:return this.push("clz<i64>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.CtzI64:return this.push("ctz<i64>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.PopcntI64:return this.push("popcnt<i64>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.AbsF64:return this.push("abs<f64>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.CeilF64:return this.push("ceil<f64>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.FloorF64:return this.push("floor<f64>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.TruncF64:return this.push("trunc<f64>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.NearestF64:return this.push("nearest<f64>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.SqrtF64:return this.push("sqrt<f64>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.ExtendI32:return this.push("<i64>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.ExtendU32:return this.push("<i64><u64>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.WrapI64:case n.UnaryOp.TruncF32ToI32:return this.push("<i32>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.TruncF32ToI64:return this.push("<i64>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.TruncF32ToU32:return this.push("<i32><u32>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.TruncF32ToU64:return this.push("<i64><u64>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.TruncF64ToI32:return this.push("<i32>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.TruncF64ToI64:return this.push("<i64>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.TruncF64ToU32:return this.push("<i32><u32>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.TruncF64ToU64:return this.push("<i64><u64>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.ReinterpretF32:return this.push("reinterpret<f32,i32>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.ReinterpretF64:return this.push("reinterpret<f64,i64>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.ConvertI32ToF32:return this.push("<f32>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.ConvertI32ToF64:return this.push("<f64>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.ConvertU32ToF32:return this.push("<f32><u32>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.ConvertU32ToF64:return this.push("<f64><u32>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.ConvertI64ToF32:return this.push("<f32>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.ConvertI64ToF64:return this.push("<f64>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.ConvertU64ToF32:return this.push("<f32><u64>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.ConvertU64ToF64:return this.push("<f64><u64>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.PromoteF32:return this.push("<f64>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.DemoteF64:return this.push("<f32>"),void this.decompileExpression(n.getUnaryValue(e));case n.UnaryOp.ReinterpretI32:return this.push("reinterpret<i32,f32>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")");case n.UnaryOp.ReinterpretI64:return this.push("reinterpret<i64,f64>("),this.decompileExpression(n.getUnaryValue(e)),void this.push(")")}break;case n.ExpressionId.Binary:switch(n.getBinaryOp(e)){case n.BinaryOp.AddI32:case n.BinaryOp.AddI64:case n.BinaryOp.AddF32:case n.BinaryOp.AddF64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" + "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.SubI32:case n.BinaryOp.SubI64:case n.BinaryOp.SubF32:case n.BinaryOp.SubF64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" - "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.MulI32:case n.BinaryOp.MulI64:case n.BinaryOp.MulF32:case n.BinaryOp.MulF64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" * "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.DivI32:case n.BinaryOp.DivI64:case n.BinaryOp.DivF32:case n.BinaryOp.DivF64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" / "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.DivU32:return this.push("<i32>(<u32>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" / <u32>"),this.decompileExpression(n.getBinaryRight(e)),void this.push(")");case n.BinaryOp.RemI32:case n.BinaryOp.RemI64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" % "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.RemU32:return this.push("<i32>(<u32>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" / <u32>"),this.decompileExpression(n.getBinaryRight(e)),void this.push(")");case n.BinaryOp.AndI32:case n.BinaryOp.AndI64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" & "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.OrI32:case n.BinaryOp.OrI64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" | "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.XorI32:case n.BinaryOp.XorI64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" ^ "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.ShlI32:case n.BinaryOp.ShlI64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" << "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.ShrU32:case n.BinaryOp.ShrU64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" >>> "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.ShrI32:case n.BinaryOp.ShrI64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" >> "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.RotlI32:return this.push("rotl<i32>("),this.decompileExpression(n.getBinaryLeft(e)),this.push(", "),this.decompileExpression(n.getBinaryRight(e)),void this.push(")");case n.BinaryOp.RotrI32:return this.push("rotr<i32>("),this.decompileExpression(n.getBinaryLeft(e)),this.push(", "),this.decompileExpression(n.getBinaryRight(e)),void this.push(")");case n.BinaryOp.EqI32:case n.BinaryOp.EqI64:case n.BinaryOp.EqF32:case n.BinaryOp.EqF64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" == "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.NeI32:case n.BinaryOp.NeI64:case n.BinaryOp.NeF32:case n.BinaryOp.NeF64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" != "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.LtI32:case n.BinaryOp.LtI64:case n.BinaryOp.LtF32:case n.BinaryOp.LtF64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" < "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.LtU32:return this.push("<u32>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" < <u32>"),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.LeI32:case n.BinaryOp.LeI64:case n.BinaryOp.LeF32:case n.BinaryOp.LeF64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" <= "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.LeU32:return this.push("<u32>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" <= <u32>"),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.GtI32:case n.BinaryOp.GtI64:case n.BinaryOp.GtF32:case n.BinaryOp.GtF64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" > "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.GtU32:return this.push("<u32>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" > <u32>"),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.GeI32:case n.BinaryOp.GeI64:case n.BinaryOp.GeF32:case n.BinaryOp.GeF64:return this.decompileExpression(n.getBinaryLeft(e)),this.push(" >= "),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.GeU32:return this.push("<u32>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" >= <u32>"),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.DivU64:return this.push("<u64>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" / <u64>"),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.RemU64:return this.push("<u64>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" % <u64>"),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.RotlI64:return this.push("rotl<i64>("),this.decompileExpression(n.getBinaryLeft(e)),this.push(", "),this.decompileExpression(n.getBinaryRight(e)),void this.push(")");case n.BinaryOp.RotrI64:return this.push("rotr<i64>("),this.decompileExpression(n.getBinaryLeft(e)),this.push(", "),this.decompileExpression(n.getBinaryRight(e)),void this.push(")");case n.BinaryOp.LtU64:return this.push("<u64>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" < <u64>"),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.LeU64:return this.push("<u64>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" <= <u64>"),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.GtU64:return this.push("<u64>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" > <u64>"),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.GeU64:return this.push("<u64>"),this.decompileExpression(n.getBinaryLeft(e)),this.push(" >= <u64>"),void this.decompileExpression(n.getBinaryRight(e));case n.BinaryOp.CopysignF32:return this.push("copysign<f32>("),this.decompileExpression(n.getBinaryLeft(e)),this.push(", "),this.decompileExpression(n.getBinaryRight(e)),void this.push(")");case n.BinaryOp.MinF32:return this.push("min<f32>("),this.decompileExpression(n.getBinaryLeft(e)),this.push(", "),this.decompileExpression(n.getBinaryRight(e)),void this.push(")");case n.BinaryOp.MaxF32:return this.push("max<f32>("),this.decompileExpression(n.getBinaryLeft(e)),this.push(", "),this.decompileExpression(n.getBinaryRight(e)),void this.push(")");case n.BinaryOp.CopysignF64:return this.push("copysign<f64>("),this.decompileExpression(n.getBinaryLeft(e)),this.push(", "),this.decompileExpression(n.getBinaryRight(e)),void this.push(")");case n.BinaryOp.MinF64:return this.push("min<f64>("),this.decompileExpression(n.getBinaryLeft(e)),this.push(", "),this.decompileExpression(n.getBinaryRight(e)),void this.push(")");case n.BinaryOp.MaxF64:return this.push("max<f64>("),this.decompileExpression(n.getBinaryLeft(e)),this.push(", "),this.decompileExpression(n.getBinaryRight(e)),void this.push(")")}return;case n.ExpressionId.Select:return this.push("select<"),this.push(a(c)),this.push(">("),this.decompileExpression(n.getSelectThen(e)),this.push(", "),this.decompileExpression(n.getSelectElse(e)),this.push(", "),this.decompileExpression(n.getSelectCondition(e)),void this.push(")");case n.ExpressionId.Drop:return this.decompileExpression(n.getDropValue(e)),void this.push(";\n");case n.ExpressionId.Return:return void((t=n.getReturnValue(e))?(this.push("return "),this.decompileExpression(t),this.push(";\n")):this.push("return;\n"));case n.ExpressionId.Host:switch(n.getHostOp(e)){case n.HostOp.CurrentMemory:return void this.push("current_memory()");case n.HostOp.GrowMemory:return this.push("grow_memory("),this.decompileExpression(n.getHostOperand(e,0)),void this.push(")")}break;case n.ExpressionId.Nop:return void this.push(";\n");case n.ExpressionId.Unreachable:return void this.push("unreachable()");case n.ExpressionId.AtomicCmpxchg:case n.ExpressionId.AtomicRMW:case n.ExpressionId.AtomicWait:case n.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}();function a(e){switch(e){case n.NativeType.None:return"void";case n.NativeType.I32:return"i32";case n.NativeType.I64:return"i64";case n.NativeType.F32:return"f32";case n.NativeType.F64:return"f64";case n.NativeType.Unreachable:throw new Error("unreachable type");case n.NativeType.Auto:throw new Error("auto type");default:throw new Error("unexpected type")}}t.Decompiler=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(9),i=r(12),a=r(11),s=r(2);t.formatDiagnostic=s.formatDiagnosticMessage;var o=r(10),c=r(0);t.LIBRARY_PREFIX=c.LIBRARY_PREFIX,t.parseFile=function(e,t,r,n){return void 0===r&&(r=!1),void 0===n&&(n=null),n||(n=new o.Parser),n.parseFile(e,t,r),n},t.nextFile=function(e){return e.nextFile()},t.nextDiagnostic=function(e){var t=e.program;return t.diagnosticsOffset<t.diagnostics.length?t.diagnostics[t.diagnosticsOffset++]:null},t.isInfo=function(e){return e.category==s.DiagnosticCategory.INFO},t.isWarning=function(e){return e.category==s.DiagnosticCategory.WARNING},t.isError=function(e){return e.category==s.DiagnosticCategory.ERROR},t.createOptions=function(){return new n.Options},t.setTarget=function(e,t){e.target=t},t.setNoTreeShaking=function(e,t){e.noTreeShaking=t},t.setNoAssert=function(e,t){e.noAssert=t},t.setNoMemory=function(e,t){e.noMemory=t},t.setImportMemory=function(e,t){e.importMemory=t},t.setImportTable=function(e,t){e.importTable=t},t.setSourceMap=function(e,t){e.sourceMap=t},t.setMemoryBase=function(e,t){e.memoryBase=t},t.setGlobalAlias=function(e,t,r){var n=e.globalAliases;n||(e.globalAliases=n=new Map),n.set(t,r)},t.FEATURE_SIGNEXT=1,t.enableFeature=function(e,t){e.features|=t},t.finishParsing=function(e){return e.finish()},t.compileProgram=function(e,t){return void 0===t&&(t=null),new n.Compiler(e,t).compile()},t.decompileModule=function(e){var t=new i.Decompiler;return t.decompile(e),t.finish()},t.buildIDL=function(e){return a.IDLBuilder.build(e)},t.buildTSD=function(e){return a.TSDBuilder.build(e)}},function(e,t,r){(function(e){const t=new Float64Array(1),r=new Float32Array(t.buffer),n=new Int32Array(t.buffer);e.f32_as_i32=function(e){return r[0]=e,n[0]},e.i32_as_f32=function(e){return n[0]=e,r[0]},e.f64_as_i64=function(e){return t[0]=e,i64_new(n[0],n[1])},e.i64_as_f64=function(e){return n[0]=i64_low(e),n[1]=i64_high(e),t[0]}}).call(this,r(5))},function(e,t){e.exports=n;var r=null;try{r=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){}function n(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function i(e){return!0===(e&&e.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=i;var a={},s={};function o(e,t){var r,n,i;return t?(i=0<=(e>>>=0)&&e<256)&&(n=s[e])?n:(r=p(e,(0|e)<0?-1:0,!0),i&&(s[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(n=a[e])?n:(r=p(e,e<0?-1:0,!1),i&&(a[e]=r),r)}function c(e,t){if(isNaN(e))return t?T:m;if(t){if(e<0)return T;if(e>=_)return A}else{if(e<=-y)return N;if(e+1>=y)return v}return e<0?c(-e,t).neg():p(e%d|0,e/d|0,t)}function p(e,t,r){return new n(e,t,r)}n.fromInt=o,n.fromNumber=c,n.fromBits=p;var l=Math.pow;function u(e,t,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return m;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 u(e.substring(1),t,r).neg();for(var i=c(l(r,8)),a=m,s=0;s<e.length;s+=8){var o=Math.min(8,e.length-s),p=parseInt(e.substring(s,s+o),r);if(o<8){var h=c(l(r,o));a=a.mul(h).add(c(p))}else a=(a=a.mul(i)).add(c(p))}return a.unsigned=t,a}function h(e,t){return"number"==typeof e?c(e,t):"string"==typeof e?u(e,t):p(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}n.fromString=u,n.fromValue=h;var d=4294967296,_=d*d,y=_/2,g=o(1<<24),m=o(0);n.ZERO=m;var T=o(0,!0);n.UZERO=T;var E=o(1);n.ONE=E;var f=o(1,!0);n.UONE=f;var I=o(-1);n.NEG_ONE=I;var v=p(-1,2147483647,!1);n.MAX_VALUE=v;var A=p(-1,-1,!0);n.MAX_UNSIGNED_VALUE=A;var N=p(0,-2147483648,!1);n.MIN_VALUE=N;var C=n.prototype;C.toInt=function(){return this.unsigned?this.low>>>0:this.low},C.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},C.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=c(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=c(l(e,6),this.unsigned),a=this,s="";;){var o=a.div(i),p=(a.sub(o.mul(i)).toInt()>>>0).toString(e);if((a=o).isZero())return p+s;for(;p.length<6;)p="0"+p;s=""+p+s}},C.getHighBits=function(){return this.high},C.getHighBitsUnsigned=function(){return this.high>>>0},C.getLowBits=function(){return this.low},C.getLowBitsUnsigned=function(){return this.low>>>0},C.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},C.isZero=function(){return 0===this.high&&0===this.low},C.eqz=C.isZero,C.isNegative=function(){return!this.unsigned&&this.high<0},C.isPositive=function(){return this.unsigned||this.high>=0},C.isOdd=function(){return 1==(1&this.low)},C.isEven=function(){return 0==(1&this.low)},C.equals=function(e){return i(e)||(e=h(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},C.eq=C.equals,C.notEquals=function(e){return!this.eq(e)},C.neq=C.notEquals,C.ne=C.notEquals,C.lessThan=function(e){return this.comp(e)<0},C.lt=C.lessThan,C.lessThanOrEqual=function(e){return this.comp(e)<=0},C.lte=C.lessThanOrEqual,C.le=C.lessThanOrEqual,C.greaterThan=function(e){return this.comp(e)>0},C.gt=C.greaterThan,C.greaterThanOrEqual=function(e){return this.comp(e)>=0},C.gte=C.greaterThanOrEqual,C.ge=C.greaterThanOrEqual,C.compare=function(e){if(i(e)||(e=h(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},C.comp=C.compare,C.negate=function(){return!this.unsigned&&this.eq(N)?N:this.not().add(E)},C.neg=C.negate,C.add=function(e){i(e)||(e=h(e));var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,a=65535&this.low,s=e.high>>>16,o=65535&e.high,c=e.low>>>16,l=0,u=0,d=0,_=0;return d+=(_+=a+(65535&e.low))>>>16,u+=(d+=n+c)>>>16,l+=(u+=r+o)>>>16,l+=t+s,p((d&=65535)<<16|(_&=65535),(l&=65535)<<16|(u&=65535),this.unsigned)},C.subtract=function(e){return i(e)||(e=h(e)),this.add(e.neg())},C.sub=C.subtract,C.multiply=function(e){if(this.isZero())return m;if(i(e)||(e=h(e)),r)return p(r.mul(this.low,this.high,e.low,e.high),r.get_high(),this.unsigned);if(e.isZero())return m;if(this.eq(N))return e.isOdd()?N:m;if(e.eq(N))return this.isOdd()?N:m;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(g)&&e.lt(g))return c(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,a=this.low>>>16,s=65535&this.low,o=e.high>>>16,l=65535&e.high,u=e.low>>>16,d=65535&e.low,_=0,y=0,T=0,E=0;return T+=(E+=s*d)>>>16,y+=(T+=a*d)>>>16,T&=65535,y+=(T+=s*u)>>>16,_+=(y+=n*d)>>>16,y&=65535,_+=(y+=a*u)>>>16,y&=65535,_+=(y+=s*l)>>>16,_+=t*d+n*u+a*l+s*o,p((T&=65535)<<16|(E&=65535),(_&=65535)<<16|(y&=65535),this.unsigned)},C.mul=C.multiply,C.divide=function(e){if(i(e)||(e=h(e)),e.isZero())throw Error("division by zero");var t,n,a;if(r)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?p((this.unsigned?r.div_u:r.div_s)(this.low,this.high,e.low,e.high),r.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?T:m;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return T;if(e.gt(this.shru(1)))return f;a=T}else{if(this.eq(N))return e.eq(E)||e.eq(I)?N:e.eq(N)?E:(t=this.shr(1).div(e).shl(1)).eq(m)?e.isNegative()?E:I:(n=this.sub(e.mul(t)),a=t.add(n.div(e)));else if(e.eq(N))return this.unsigned?T:m;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();a=m}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(t)/Math.LN2),o=s<=48?1:l(2,s-48),u=c(t),d=u.mul(e);d.isNegative()||d.gt(n);)d=(u=c(t-=o,this.unsigned)).mul(e);u.isZero()&&(u=E),a=a.add(u),n=n.sub(d)}return a},C.div=C.divide,C.modulo=function(e){return i(e)||(e=h(e)),r?p((this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,e.low,e.high),r.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},C.mod=C.modulo,C.rem=C.modulo,C.not=function(){return p(~this.low,~this.high,this.unsigned)},C.and=function(e){return i(e)||(e=h(e)),p(this.low&e.low,this.high&e.high,this.unsigned)},C.or=function(e){return i(e)||(e=h(e)),p(this.low|e.low,this.high|e.high,this.unsigned)},C.xor=function(e){return i(e)||(e=h(e)),p(this.low^e.low,this.high^e.high,this.unsigned)},C.shiftLeft=function(e){return i(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?p(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):p(0,this.low<<e-32,this.unsigned)},C.shl=C.shiftLeft,C.shiftRight=function(e){return i(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?p(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):p(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},C.shr=C.shiftRight,C.shiftRightUnsigned=function(e){if(i(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?p(this.low>>>e|t<<32-e,t>>>e,this.unsigned):p(32===e?t:t>>>e-32,0,this.unsigned)},C.shru=C.shiftRightUnsigned,C.shr_u=C.shiftRightUnsigned,C.toSigned=function(){return this.unsigned?p(this.low,this.high,!1):this},C.toUnsigned=function(){return this.unsigned?this:p(this.low,this.high,!0)},C.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},C.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]},C.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]},n.fromBytes=function(e,t,r){return r?n.fromBytesLE(e,t):n.fromBytesBE(e,t)},n.fromBytesLE=function(e,t){return new n(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},n.fromBytesBE=function(e,t){return new n(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){(function(e){const t=e.Long||r(15);e.i64_zero=t.ZERO,e.i64_one=t.ONE,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_eq=function(e,t){return e.eq(t)},e.i64_ne=function(e,t){return e.ne(t)},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),s=t.fromNumber(f64.MAX_SAFE_INTEGER);e.i64_is_f64=function(e){return e.gte(a)&&e.lte(s)},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(this,r(5))},function(e,t,r){"use strict";function n(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function i(e,t,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function a(e,t){var r=n(e,t),i=n(e,t+4);return i64_new(r,i)}Object.defineProperty(t,"__esModule",{value:!0}),t.readI32=n,t.writeI32=i,t.readI64=a,t.writeI64=function(e,t,r){i(i64_low(e),t,r),i(i64_high(e),t,r+4)},t.readF32=function(e,t){return i32_as_f32(n(e,t))},t.writeF32=function(e,t,r){i(f32_as_i32(e),t,r)},t.readF64=function(e,t){return i64_as_f64(a(e,t))},t.writeF64=function(e,t,r){var n=f64_as_i64(e);i(i64_low(n),t,r),i(i64_high(n),t,r+4)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=" ",i=" ",a=" ";t.indent=function(e,t){for(;t>=4;)e.push(a),t-=4;t>=2&&(e.push(i),t-=2),t&&e.push(n)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=47;function i(e){for(var t,r=0,i=e.length;r+1<i&&46==e.charCodeAt(r)&&e.charCodeAt(r+1)==n;)r+=2;for((r>0||i<e.length)&&(e=e.substring(r,i),i-=r,r=0);r+1<i;){if(t=!1,e.charCodeAt(r)==n&&46==e.charCodeAt(r+1)){if((t=r+2==i)||r+2<i&&e.charCodeAt(r+2)==n){e=t?e.substring(0,r):e.substring(0,r)+e.substring(r+2),i-=2;continue}if((t=r+3==i)&&46==e.charCodeAt(r+2)||r+3<i&&46==e.charCodeAt(r+2)&&e.charCodeAt(r+3)==n){for(var a=r;--a>=0;)if(e.charCodeAt(a)==n){r-a==3&&46==e.charCodeAt(a+1)&&46==e.charCodeAt(a+2)||(e=t?e.substring(0,a):e.substring(0,a)+e.substring(r+3),i-=r+3-a,r=a-1);break}if(a<0&&r>0&&(2!=r||46!=e.charCodeAt(0)||46!=e.charCodeAt(1))){i=(e=e.substring(r+4)).length;continue}}}r++}return i>0?e:"."}function a(e){for(var t=e.length;--t>0;)if(e.charCodeAt(t)==n)return e.substring(0,t);return"."}t.normalizePath=i,t.resolvePath=function(e,t){return e.startsWith("std/")?e:i(a(t)+String.fromCharCode(n)+e)},t.dirname=a},function(e,t,r){"use strict";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=function(e){switch(e){case 10:case 13:case 8232:case 8233:return!0;default:return!1}},t.isWhiteSpace=function(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}},t.isDecimalDigit=function(e){return e>=48&&e<=57},t.isOctalDigit=function(e){return e>=48&&e<=55},t.isIdentifierStart=function(e){return e>=65&&e<=90||e>=97&&e<=122||36==e||95==e||e>127&&!((t=e)<0||t>65535)&&a(t,n);var t},t.isKeywordCharacter=function(e){return e>=97&&e<=122},t.isIdentifierPart=function(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||36==e||95==e||e>127&&!((t=e)<0||t>65535)&&a(t,i);var t};var n=[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],i=[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 a(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,t[r-=r%2]<=e&&e<=t[r+1])return!0;e<t[r]?i=r:n=r+2}return!1}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(4),a=r(7),s=r(3),o=r(0);function c(e,t,r,c,h,d){var y,g,m,T,E=e.module;switch(t.internalName){case"isInteger":var f=l(e,r,c,d);return e.currentType=a.Type.bool,f?f.is(4)&&!f.is(256)?E.createI32(1):E.createI32(0):E.createUnreachable();case"isFloat":f=l(e,r,c,d);return e.currentType=a.Type.bool,f?f.is(8)?E.createI32(1):E.createI32(0):E.createUnreachable();case"isSigned":f=l(e,r,c,d);return e.currentType=a.Type.bool,f?f.is(1)?E.createI32(1):E.createI32(0):E.createUnreachable();case"isReference":f=l(e,r,c,d);return e.currentType=a.Type.bool,f?(e.currentType=a.Type.bool,f.is(256)?E.createI32(1):E.createI32(0)):E.createUnreachable();case"isString":f=l(e,r,c,d);if(e.currentType=a.Type.bool,!f)return E.createUnreachable();if(L=f.classReference){var I=e.program.stringInstance;if(I&&L.isAssignableTo(I))return E.createI32(1)}return E.createI32(0);case"isArray":f=l(e,r,c,d);return e.currentType=a.Type.bool,f?null!=(L=f.classReference)&&null!=L.lookupOverload(o.OperatorKind.INDEXED_GET)?E.createI32(1):E.createI32(0):E.createUnreachable();case"clz":if(1!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,1)}else y=e.compileExpression(c[0],a.Type.i32,0,1);switch(e.currentType.kind){case 0:case 1:case 5:case 6:T=E.createUnary(s.UnaryOp.ClzI32,y);break;case 10:case 2:case 7:T=E.createUnary(s.UnaryOp.ClzI32,y);break;case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}case 4:T=E.createUnary(e.options.isWasm64?s.UnaryOp.ClzI64:s.UnaryOp.ClzI32,y);break;case 3:case 8:T=E.createUnary(s.UnaryOp.ClzI64,y);break;default:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"ctz":if(1!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],0,1)}else y=e.compileExpression(c[0],a.Type.i32,0,1);switch(e.currentType.kind){case 0:case 1:case 5:case 6:T=E.createUnary(s.UnaryOp.CtzI32,y);break;case 10:case 2:case 7:T=E.createUnary(s.UnaryOp.CtzI32,y);break;case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}case 4:T=E.createUnary(e.options.isWasm64?s.UnaryOp.CtzI64:s.UnaryOp.CtzI32,y);break;case 3:case 8:T=E.createUnary(s.UnaryOp.CtzI64,y);break;default:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"popcnt":if(1!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,1)}else y=e.compileExpression(c[0],a.Type.i32,0,1);switch(e.currentType.kind){case 0:case 1:case 5:case 6:T=E.createUnary(s.UnaryOp.PopcntI32,y);break;case 10:case 2:case 7:T=E.createUnary(s.UnaryOp.PopcntI32,y);break;case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}case 4:T=E.createUnary(e.options.isWasm64?s.UnaryOp.PopcntI64:s.UnaryOp.PopcntI32,y);break;case 3:case 8:T=E.createUnary(s.UnaryOp.PopcntI64,y);break;default:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"rotl":if(2!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"2",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,1)}else y=e.compileExpression(c[0],a.Type.i32,0,1);switch(g=e.compileExpression(c[1],e.currentType,1,0),e.currentType.kind){case 0:case 1:case 5:case 6:case 10:T=e.ensureSmallIntegerWrap(E.createBinary(s.BinaryOp.RotlI32,y,g),e.currentType);case 2:case 7:T=E.createBinary(s.BinaryOp.RotlI32,y,g);break;case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}case 4:T=E.createBinary(e.options.isWasm64?s.BinaryOp.RotlI64:s.BinaryOp.RotlI32,y,g);break;case 3:case 8:T=E.createBinary(s.BinaryOp.RotlI64,y,g);break;default:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"rotr":if(2!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"2",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,1)}else y=e.compileExpression(c[0],a.Type.i32,0,1);switch(g=e.compileExpression(c[1],e.currentType,1,0),e.currentType.kind){case 0:case 1:case 5:case 6:case 10:T=e.ensureSmallIntegerWrap(E.createBinary(s.BinaryOp.RotrI32,y,g),e.currentType);break;case 2:case 7:T=E.createBinary(s.BinaryOp.RotrI32,y,g);break;case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}case 4:T=E.createBinary(e.options.isWasm64?s.BinaryOp.RotrI64:s.BinaryOp.RotrI32,y,g);break;case 3:case 8:T=E.createBinary(s.BinaryOp.RotrI64,y,g);break;default:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"abs":if(1!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,1)}else y=e.compileExpression(c[0],a.Type.f64,0,1);switch(e.currentType.kind){case 0:case 1:case 2:var v=e.currentFunction.getAndFreeTempLocal(a.Type.i32,!1);T=E.createSelect(E.createTeeLocal(v.index,y),E.createBinary(s.BinaryOp.SubI32,E.createI32(0),E.createGetLocal(v.index,s.NativeType.I32)),E.createBinary(s.BinaryOp.GtI32,E.createGetLocal(v.index,s.NativeType.I32),E.createI32(0)));break;case 4:v=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);T=E.createSelect(E.createTeeLocal(v.index,y),E.createBinary(e.options.isWasm64?s.BinaryOp.SubI64:s.BinaryOp.SubI32,e.options.usizeType.toNativeZero(E),E.createGetLocal(v.index,e.options.nativeSizeType)),E.createBinary(e.options.isWasm64?s.BinaryOp.GtI64:s.BinaryOp.GtI32,E.createGetLocal(v.index,e.options.nativeSizeType),e.options.usizeType.toNativeZero(E)));break;case 3:v=e.currentFunction.getAndFreeTempLocal(a.Type.i64,!1);T=E.createSelect(E.createTeeLocal(v.index,y),E.createBinary(s.BinaryOp.SubI64,E.createI64(0,0),E.createGetLocal(v.index,s.NativeType.I64)),E.createBinary(s.BinaryOp.GtI64,E.createGetLocal(v.index,s.NativeType.I64),E.createI64(0,0)));break;case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}case 5:case 6:case 7:case 8:case 10:T=y;break;case 11:T=E.createUnary(s.UnaryOp.AbsF32,y);break;case 12:T=E.createUnary(s.UnaryOp.AbsF64,y);break;case 13:T=E.createUnreachable();break;default:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"max":if(2!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"2",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,1)}else y=e.compileExpression(c[0],a.Type.f64,0,1);switch(g=e.compileExpression(c[1],e.currentType,1,1),e.currentType.kind){case 0:case 1:case 2:var A=e.currentFunction.flow,N=e.currentFunction.getTempLocal(e.currentType,!A.canOverflow(y,e.currentType)),C=e.currentFunction.getAndFreeTempLocal(e.currentType,!A.canOverflow(g,e.currentType));e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(s.BinaryOp.GtI32,E.createGetLocal(N.index,s.NativeType.I32),E.createGetLocal(C.index,s.NativeType.I32)));break;case 5:case 6:case 7:case 10:A=e.currentFunction.flow,N=e.currentFunction.getTempLocal(e.currentType,!A.canOverflow(y,e.currentType)),C=e.currentFunction.getAndFreeTempLocal(e.currentType,!A.canOverflow(g,e.currentType));e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(s.BinaryOp.GtU32,E.createGetLocal(N.index,s.NativeType.I32),E.createGetLocal(C.index,s.NativeType.I32)));break;case 3:N=e.currentFunction.getTempLocal(a.Type.i64,!1),C=e.currentFunction.getAndFreeTempLocal(a.Type.i64,!1);e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(s.BinaryOp.GtI64,E.createGetLocal(N.index,s.NativeType.I64),E.createGetLocal(C.index,s.NativeType.I64)));break;case 8:N=e.currentFunction.getTempLocal(a.Type.i64,!1),C=e.currentFunction.getAndFreeTempLocal(a.Type.i64,!1);e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(s.BinaryOp.GtU64,E.createGetLocal(N.index,s.NativeType.I64),E.createGetLocal(C.index,s.NativeType.I64)));break;case 4:N=e.currentFunction.getTempLocal(e.options.usizeType,!1),C=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(e.options.isWasm64?s.BinaryOp.GtI64:s.BinaryOp.GtI32,E.createGetLocal(N.index,e.options.nativeSizeType),E.createGetLocal(C.index,e.options.nativeSizeType)));break;case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}N=e.currentFunction.getTempLocal(e.options.usizeType,!1),C=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(e.options.isWasm64?s.BinaryOp.GtU64:s.BinaryOp.GtU32,E.createGetLocal(N.index,e.options.nativeSizeType),E.createGetLocal(C.index,e.options.nativeSizeType)));break;case 11:T=E.createBinary(s.BinaryOp.MaxF32,y,g);break;case 12:T=E.createBinary(s.BinaryOp.MaxF64,y,g);break;default:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"min":if(2!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"2",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,1)}else y=e.compileExpression(c[0],a.Type.f64,0,1);switch(g=e.compileExpression(c[1],e.currentType,1,1),e.currentType.kind){case 0:case 1:case 2:A=e.currentFunction.flow,N=e.currentFunction.getTempLocal(e.currentType,!A.canOverflow(y,e.currentType)),C=e.currentFunction.getAndFreeTempLocal(e.currentType,!A.canOverflow(g,e.currentType));e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(s.BinaryOp.LtI32,E.createGetLocal(N.index,s.NativeType.I32),E.createGetLocal(C.index,s.NativeType.I32)));break;case 5:case 6:case 7:case 10:A=e.currentFunction.flow,N=e.currentFunction.getTempLocal(e.currentType,!A.canOverflow(y,e.currentType)),C=e.currentFunction.getAndFreeTempLocal(e.currentType,!A.canOverflow(g,e.currentType));e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(s.BinaryOp.LtU32,E.createGetLocal(N.index,s.NativeType.I32),E.createGetLocal(C.index,s.NativeType.I32)));break;case 3:N=e.currentFunction.getTempLocal(a.Type.i64,!1),C=e.currentFunction.getAndFreeTempLocal(a.Type.i64,!1);e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(s.BinaryOp.LtI64,E.createGetLocal(N.index,s.NativeType.I64),E.createGetLocal(C.index,s.NativeType.I64)));break;case 8:N=e.currentFunction.getTempLocal(a.Type.i64,!1),C=e.currentFunction.getAndFreeTempLocal(a.Type.i64,!1);e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(s.BinaryOp.LtU64,E.createGetLocal(N.index,s.NativeType.I64),E.createGetLocal(C.index,s.NativeType.I64)));break;case 4:N=e.currentFunction.getTempLocal(e.options.usizeType,!1),C=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(e.options.isWasm64?s.BinaryOp.LtI64:s.BinaryOp.LtI32,E.createGetLocal(N.index,e.options.nativeSizeType),E.createGetLocal(C.index,e.options.nativeSizeType)));break;case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}N=e.currentFunction.getTempLocal(e.options.usizeType,!1),C=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);e.currentFunction.freeTempLocal(N),T=E.createSelect(E.createTeeLocal(N.index,y),E.createTeeLocal(C.index,g),E.createBinary(e.options.isWasm64?s.BinaryOp.LtU64:s.BinaryOp.LtU32,E.createGetLocal(N.index,e.options.nativeSizeType),E.createGetLocal(C.index,e.options.nativeSizeType)));break;case 11:T=E.createBinary(s.BinaryOp.MinF32,y,g);break;case 12:T=E.createBinary(s.BinaryOp.MinF64,y,g);break;default:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"ceil":if(1!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,0)}else y=e.compileExpression(c[0],a.Type.f64,0,0);switch(e.currentType.kind){case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}default:T=y;break;case 11:T=E.createUnary(s.UnaryOp.CeilF32,y);break;case 12:T=E.createUnary(s.UnaryOp.CeilF64,y);break;case 13:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"floor":if(1!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,0)}else y=e.compileExpression(c[0],a.Type.f64,0,0);switch(e.currentType.kind){case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}default:T=y;break;case 11:T=E.createUnary(s.UnaryOp.FloorF32,y);break;case 12:T=E.createUnary(s.UnaryOp.FloorF64,y);break;case 13:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"copysign":if(2!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"2",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,0)}else y=e.compileExpression(c[0],a.Type.f64,0,0);switch(g=e.compileExpression(c[1],e.currentType,1,0),e.currentType.kind){case 11:T=E.createBinary(s.BinaryOp.CopysignF32,y,g);break;case 12:T=E.createBinary(s.BinaryOp.CopysignF64,y,g);break;default:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"nearest":if(1!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,0)}else y=e.compileExpression(c[0],a.Type.f64,0,0);switch(e.currentType.kind){case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}default:T=y;break;case 11:T=E.createUnary(s.UnaryOp.NearestF32,y);break;case 12:T=E.createUnary(s.UnaryOp.NearestF64,y);break;case 13:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"reinterpret":if(1!=c.length)return r&&1==r.length||(r&&r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0")),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable();if(!r||1!=r.length)return r&&r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0"),E.createUnreachable();switch(r[0].kind){case 2:case 7:y=e.compileExpression(c[0],a.Type.f32,1,0),T=E.createUnary(s.UnaryOp.ReinterpretF32,y);break;case 3:case 8:y=e.compileExpression(c[0],a.Type.f64,1,0),T=E.createUnary(s.UnaryOp.ReinterpretF64,y);break;case 9:if(r[0].is(256))return e.error(n.DiagnosticCode.Operation_not_supported,d.range),e.currentType=r[0],E.createUnreachable();case 4:y=e.compileExpression(c[0],e.options.isWasm64?a.Type.f64:a.Type.f32,1,0),T=E.createUnary(e.options.isWasm64?s.UnaryOp.ReinterpretF64:s.UnaryOp.ReinterpretF32,y);break;case 11:y=e.compileExpression(c[0],a.Type.i32,1,0),T=E.createUnary(s.UnaryOp.ReinterpretI32,y);break;case 12:y=e.compileExpression(c[0],a.Type.i64,1,0),T=E.createUnary(s.UnaryOp.ReinterpretI64,y);break;default:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return e.currentType=r[0],T;case"sqrt":if(1!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,0)}else y=e.compileExpression(c[0],a.Type.f64,0,0);switch(e.currentType.kind){case 11:T=E.createUnary(s.UnaryOp.SqrtF32,y);break;case 12:T=E.createUnary(s.UnaryOp.SqrtF64,y);break;default:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"trunc":if(1!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable();if(r&&r.length){if(e.currentType=r[0],1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,0)}else y=e.compileExpression(c[0],a.Type.f64,0,0);switch(e.currentType.kind){case 9:if(e.currentType.is(256)){e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable();break}default:T=y;break;case 11:T=E.createUnary(s.UnaryOp.TruncF32,y);break;case 12:T=E.createUnary(s.UnaryOp.TruncF64,y);break;case 13:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"load":return c.length<1||c.length>2?(r&&1==r.length||e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0"),c.length<1?e.error(n.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,d.range,"1",c.length.toString(10)):e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"2",c.length.toString(10)),E.createUnreachable()):r&&1==r.length?(y=e.compileExpression(c[0],e.options.usizeType,1,0),(b=2==c.length?u(e,c[1]):0)<0?E.createUnreachable():(e.currentType=r[0],E.createLoad(r[0].byteSize,r[0].is(5),y,r[0].is(4)&&h.is(4)&&h.size>r[0].size?(e.currentType=h).toNativeType():(e.currentType=r[0]).toNativeType(),b))):(r&&r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0"),E.createUnreachable());case"store":if(e.currentType=a.Type.void,c.length<2||c.length>3)return r&&1==r.length||e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0"),c.length<2?e.error(n.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,d.range,"2",c.length.toString(10)):e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"3",c.length.toString(10)),E.createUnreachable();if(!r||1!=r.length)return e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0"),E.createUnreachable();y=e.compileExpression(c[0],e.options.usizeType,1,0),g=e.compileExpression(c[1],r[0],r[0].is(4)?0:1,0);f=void 0;return r[0].is(4)&&(!e.currentType.is(4)||e.currentType.size<r[0].size)?(g=e.convertExpression(g,e.currentType,r[0],1,0,c[1]),f=r[0]):f=e.currentType,(b=3==c.length?u(e,c[2]):0)<0?E.createUnreachable():(e.currentType=a.Type.void,E.createStore(r[0].byteSize,y,g,f.toNativeType(),b));case"sizeof":if(e.currentType=e.options.usizeType,0!=c.length)return r&&1==r.length||e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0"),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"0",c.length.toString(10)),E.createUnreachable();r&&1==r.length||e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0");var S=r[0].byteSize;return e.options.isWasm64?h.is(4)&&h.size<=32?(e.currentType=a.Type.u32,T=E.createI32(S)):T=E.createI64(S,0):h.is(4)&&64==h.size?(e.currentType=a.Type.u64,T=E.createI64(S,0)):T=E.createI32(S),T;case"alignof":if(e.currentType=e.options.usizeType,0!=c.length)return r&&1==r.length||e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0"),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"0",c.length.toString(10)),E.createUnreachable();if(!r||1!=r.length)return e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0"),E.createUnreachable();var O=void 0;switch(S=r[0].byteSize){case 1:O=0;break;case 2:O=1;break;case 4:O=2;break;case 8:O=3;break;default:return assert(!1),E.createUnreachable()}return e.options.isWasm64?h.is(4)&&h.size<=32?(e.currentType=a.Type.u32,T=E.createI32(O)):T=E.createI64(O,0):h.is(4)&&64==h.size?(e.currentType=a.Type.u64,T=E.createI64(O,0)):T=E.createI32(O),T;case"offsetof":if(e.currentType=e.options.usizeType,c.length>1)return r&&1==r.length||e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0"),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable();if(!r||1!=r.length)return e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0"),E.createUnreachable();var L;if(!(L=r[0].classReference))return e.error(n.DiagnosticCode.Operation_not_supported,d.range),E.createUnreachable();var b=void 0;if(c.length){if(c[0].kind!=i.NodeKind.LITERAL||c[0].literalKind!=i.LiteralKind.STRING)return e.error(n.DiagnosticCode.String_literal_expected,c[0].range),E.createUnreachable();var k=c[0].value,x=L.members?L.members.get(k):null;if(!x||x.kind!=o.ElementKind.FIELD)return e.error(n.DiagnosticCode.Type_0_has_no_property_1,c[0].range,L.internalName,k),E.createUnreachable();b=x.memoryOffset}else b=L.currentMemoryOffset;return e.options.isWasm64?h.is(4)&&h.size<=32?(e.currentType=a.Type.u32,E.createI32(b)):E.createI64(b):h.is(4)&&64==h.size?(e.currentType=a.Type.u64,E.createI64(b)):E.createI32(b);case"select":if(3!=c.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"3",c.length.toString(10)),E.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,0)}else y=e.compileExpressionRetainType(c[0],a.Type.i32,0);f=e.currentType;switch(g=e.compileExpression(c[1],f,1,0),m=e.makeIsTrueish(e.compileExpressionRetainType(c[2],a.Type.bool,0),e.currentType),e.currentType=f,e.currentType.kind){case 0:case 1:case 5:case 6:case 10:default:T=E.createSelect(y,g,m);break;case 13:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=E.createUnreachable()}return T;case"unreachable":return 0!=c.length&&e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"0",c.length.toString(10)),r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),E.createUnreachable();case"current_memory":return e.currentType=a.Type.i32,0!=c.length&&e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"0",c.length.toString(10)),r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),E.createHost(s.HostOp.CurrentMemory);case"grow_memory":return e.currentType=a.Type.i32,1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"0",c.length.toString(10)),y=E.createUnreachable()):y=e.compileExpression(c[0],a.Type.i32,1,0),r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),E.createHost(s.HostOp.GrowMemory,null,[y]);case"move_memory":if(r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),3!=c.length)return e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"3",c.length.toString(10)),e.currentType=a.Type.void,E.createUnreachable();throw y=e.compileExpression(c[0],e.options.usizeType,1,0),g=e.compileExpression(c[1],e.options.usizeType,1,0),m=e.compileExpression(c[2],e.options.usizeType,1,0),e.currentType=a.Type.void,new Error("not implemented");case"set_memory":if(r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),3!=c.length)return e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"3",c.length.toString(10)),e.currentType=a.Type.void,E.createUnreachable();throw y=e.compileExpression(c[0],e.options.usizeType,1,0),g=e.compileExpression(c[1],a.Type.u32,1,0),m=e.compileExpression(c[2],e.options.usizeType,1,0),e.currentType=a.Type.void,new Error("not implemented");case"changetype":return r&&1==r.length?9!=r[0].kind?(e.error(n.DiagnosticCode.Operation_not_supported,d.range),e.currentType=r[0],E.createUnreachable()):1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=r[0],E.createUnreachable()):(y=e.compileExpressionRetainType(c[0],e.options.usizeType,0),e.currentType=r[0],9!=e.currentType.kind?(e.error(n.DiagnosticCode.Operation_not_supported,d.range),E.createUnreachable()):y):(r&&r.length&&(e.currentType=r[0]),e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r?r.length.toString(10):"0"),E.createUnreachable());case"assert":if(c.length<1||c.length>2)return r&&(r.length&&(e.currentType=r[0].nonNullableType),1!=r.length&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10))),c.length<1?e.error(n.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,d.range,"1",c.length.toString(10)):c.length>2&&e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"2",c.length.toString(10)),E.createUnreachable();if(r){if(r.length&&(e.currentType=r[0].nonNullableType),1!=r.length)return e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,d.range,"1",r.length.toString(10)),E.createUnreachable();y=e.compileExpression(c[0],r[0],1,1)}else y=e.compileExpressionRetainType(c[0],a.Type.bool,1);f=e.currentType;if(e.currentType=f.nonNullableType,e.options.noAssert)return h==a.Type.void?(e.currentType=a.Type.void,E.createNop()):y;var R=_(e,2==c.length?c[1]:null,d);if(e.currentType=f.nonNullableType,h==a.Type.void){switch(e.currentType.kind){default:T=E.createIf(E.createUnary(s.UnaryOp.EqzI32,y),R);break;case 3:case 8:T=E.createIf(E.createUnary(s.UnaryOp.EqzI64,y),R);break;case 4:case 9:T=E.createIf(E.createUnary(e.options.isWasm64?s.UnaryOp.EqzI64:s.UnaryOp.EqzI32,y),R);break;case 11:T=E.createIf(E.createBinary(s.BinaryOp.EqF32,y,E.createF32(0)),R);break;case 12:T=E.createIf(E.createBinary(s.BinaryOp.EqF64,y,E.createF64(0)),R);break;case 13:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=R}e.currentType=a.Type.void}else switch(e.currentType.kind){case 0:case 1:case 5:case 6:case 10:A=e.currentFunction.flow,v=e.currentFunction.getAndFreeTempLocal(e.currentType,!A.canOverflow(y,e.currentType));T=E.createIf(E.createTeeLocal(v.index,y),E.createGetLocal(v.index,s.NativeType.I32),R);break;case 2:case 7:default:v=e.currentFunction.getAndFreeTempLocal(a.Type.i32,!1);T=E.createIf(E.createTeeLocal(v.index,y),E.createGetLocal(v.index,s.NativeType.I32),R);break;case 3:case 8:v=e.currentFunction.getAndFreeTempLocal(a.Type.i64,!1);T=E.createIf(E.createUnary(s.UnaryOp.EqzI64,E.createTeeLocal(v.index,y)),R,E.createGetLocal(v.index,s.NativeType.I64));break;case 4:case 9:v=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);T=E.createIf(E.createUnary(e.options.isWasm64?s.UnaryOp.EqzI64:s.UnaryOp.EqzI32,E.createTeeLocal(v.index,y)),R,E.createGetLocal(v.index,e.options.nativeSizeType));break;case 11:v=e.currentFunction.getAndFreeTempLocal(a.Type.f32,!1);T=E.createIf(E.createBinary(s.BinaryOp.EqF32,E.createTeeLocal(v.index,y),E.createF32(0)),R,E.createGetLocal(v.index,s.NativeType.F32));break;case 12:v=e.currentFunction.getAndFreeTempLocal(a.Type.f64,!1);T=E.createIf(E.createBinary(s.BinaryOp.EqF64,E.createTeeLocal(v.index,y),E.createF64(0)),R,E.createGetLocal(v.index,s.NativeType.F64));break;case 13:e.error(n.DiagnosticCode.Operation_not_supported,d.range),T=R}return T;case"unchecked":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),E.createUnreachable()):((A=e.currentFunction.flow).set(2048),T=e.compileExpressionRetainType(c[0],h,0),A.unset(2048),T);case"i8":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=a.Type.i8,E.createUnreachable()):e.compileExpression(c[0],a.Type.i8,2,0);case"i16":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=a.Type.i16,E.createUnreachable()):e.compileExpression(c[0],a.Type.i16,2,0);case"i32":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=a.Type.i32,E.createUnreachable()):e.compileExpression(c[0],a.Type.i32,2,0);case"i64":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=a.Type.i64,E.createUnreachable()):e.compileExpression(c[0],a.Type.i64,2,0);case"isize":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=e.options.isWasm64?a.Type.isize64:a.Type.isize32,E.createUnreachable()):e.compileExpression(c[0],e.options.isWasm64?a.Type.isize64:a.Type.isize32,2,0);case"u8":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=a.Type.u8,E.createUnreachable()):e.compileExpression(c[0],a.Type.u8,2,0);case"u16":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=a.Type.u16,E.createUnreachable()):e.compileExpression(c[0],a.Type.u16,2,0);case"u32":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=a.Type.u32,E.createUnreachable()):e.compileExpression(c[0],a.Type.u32,2,0);case"u64":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=a.Type.u64,E.createUnreachable()):e.compileExpression(c[0],a.Type.u64,2,0);case"usize":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=e.options.usizeType,E.createUnreachable()):e.compileExpression(c[0],e.options.usizeType,2,0);case"bool":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=a.Type.bool,E.createUnreachable()):e.compileExpression(c[0],a.Type.bool,2,0);case"f32":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=a.Type.f32,E.createUnreachable()):e.compileExpression(c[0],a.Type.f32,2,0);case"f64":return r&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),1!=c.length?(e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,d.range,"1",c.length.toString(10)),e.currentType=a.Type.f64,E.createUnreachable()):e.compileExpression(c[0],a.Type.f64,2,0)}var B=function(e,t,r,n,i){switch(t.internalName){case"i32.clz":return p("clz",e,a.Type.i32,r,a.Type.i32,i);case"i64.clz":return p("clz",e,a.Type.i64,r,a.Type.i64,i);case"i32.ctz":return p("ctz",e,a.Type.i32,r,a.Type.i32,i);case"i64.ctz":return p("ctz",e,a.Type.i64,r,a.Type.i64,i);case"i32.popcnt":return p("popcnt",e,a.Type.i32,r,a.Type.i32,i);case"i64.popcnt":return p("popcnt",e,a.Type.i64,r,a.Type.i64,i);case"i32.rotl":return p("rotl",e,a.Type.i32,r,a.Type.i32,i);case"i64.rotl":return p("rotl",e,a.Type.i64,r,a.Type.i64,i);case"i32.rotr":return p("rotr",e,a.Type.i32,r,a.Type.i32,i);case"i64.rotr":return p("rotr",e,a.Type.i64,r,a.Type.i64,i);case"f32.abs":return p("abs",e,a.Type.f32,r,a.Type.f32,i);case"f64.abs":return p("abs",e,a.Type.f64,r,a.Type.f64,i);case"f32.max":return p("max",e,a.Type.f32,r,a.Type.f32,i);case"f64.max":return p("max",e,a.Type.f64,r,a.Type.f64,i);case"f32.min":return p("min",e,a.Type.f32,r,a.Type.f32,i);case"f64.min":return p("min",e,a.Type.f64,r,a.Type.f64,i);case"f32.ceil":return p("ceil",e,a.Type.f32,r,a.Type.f32,i);case"f64.ceil":return p("ceil",e,a.Type.f64,r,a.Type.f64,i);case"f32.floor":return p("floor",e,a.Type.f32,r,a.Type.f32,i);case"f64.floor":return p("floor",e,a.Type.f64,r,a.Type.f64,i);case"f32.copysign":return p("copysign",e,a.Type.f32,r,a.Type.f32,i);case"f64.copysign":return p("copysign",e,a.Type.f64,r,a.Type.f64,i);case"f32.nearest":return p("nearest",e,a.Type.f32,r,a.Type.f32,i);case"f64.nearest":return p("nearest",e,a.Type.f64,r,a.Type.f64,i);case"i32.reinterpret_f32":return p("reinterpret",e,a.Type.i32,r,a.Type.f32,i);case"i64.reinterpret_f64":return p("reinterpret",e,a.Type.i64,r,a.Type.f64,i);case"f32.reinterpret_i32":return p("reinterpret",e,a.Type.f32,r,a.Type.i32,i);case"f64.reinterpret_i64":return p("reinterpret",e,a.Type.f64,r,a.Type.i64,i);case"f32.sqrt":return p("sqrt",e,a.Type.f32,r,a.Type.f32,i);case"f64.sqrt":return p("sqrt",e,a.Type.f64,r,a.Type.f64,i);case"f32.trunc":return p("trunc",e,a.Type.f32,r,a.Type.f32,i);case"f64.trunc":return p("trunc",e,a.Type.f64,r,a.Type.f64,i);case"i32.load8_s":return p("load",e,a.Type.i8,r,a.Type.i32,i);case"i32.load8_u":return p("load",e,a.Type.u8,r,a.Type.u32,i);case"i32.load16_s":return p("load",e,a.Type.i16,r,a.Type.i32,i);case"i32.load16_u":return p("load",e,a.Type.u16,r,a.Type.u32,i);case"i32.load":return p("load",e,a.Type.i32,r,a.Type.i32,i);case"i64.load8_s":return p("load",e,a.Type.i8,r,a.Type.i64,i);case"i64.load8_u":return p("load",e,a.Type.u8,r,a.Type.u64,i);case"i64.load16_s":return p("load",e,a.Type.i16,r,a.Type.i64,i);case"i64.load16_u":return p("load",e,a.Type.u16,r,a.Type.u64,i);case"i64.load32_s":return p("load",e,a.Type.i32,r,a.Type.i64,i);case"i64.load32_u":return p("load",e,a.Type.u32,r,a.Type.u64,i);case"i64.load":return p("load",e,a.Type.i64,r,a.Type.i64,i);case"f32.load":return p("load",e,a.Type.f32,r,a.Type.f32,i);case"f64.load":return p("load",e,a.Type.f64,r,a.Type.f64,i);case"i32.store8":return p("store",e,a.Type.i8,r,a.Type.i32,i);case"i32.store16":return p("store",e,a.Type.i16,r,a.Type.i32,i);case"i32.store":return p("store",e,a.Type.i32,r,a.Type.i32,i);case"i64.store8":return p("store",e,a.Type.i8,r,a.Type.i64,i);case"i64.store16":return p("store",e,a.Type.i16,r,a.Type.i64,i);case"i64.store32":return p("store",e,a.Type.i32,r,a.Type.i64,i);case"i64.store":return p("store",e,a.Type.i64,r,a.Type.i64,i);case"f32.store":return p("store",e,a.Type.f32,r,a.Type.f32,i);case"f64.store":return p("store",e,a.Type.f64,r,a.Type.f64,i)}return 0}(e,t,c,0,d);return B?(r&&r.length&&e.error(n.DiagnosticCode.Type_0_is_not_generic,d.range,t.internalName),B):(e.error(n.DiagnosticCode.Operation_not_supported,d.range),E.createUnreachable())}function p(e,t,r,n,i,a){var s=assert(t.program.elementsLookup.get(e));return assert(s.kind==o.ElementKind.FUNCTION_PROTOTYPE),c(t,s,[r],n,i,a)}function l(e,t,r,i){if(0==r.length)return t&&1==t.length?t[0]:(e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,i.range,"1",t?t.length.toString(10):"0"),null);if(1==r.length){if(t)if(1==t.length)e.compileExpression(r[0],t[0],1,0);else{if(t.length)return e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,i.range,"1",t.length.toString(10)),null;e.compileExpressionRetainType(r[0],a.Type.i32,0)}else e.compileExpressionRetainType(r[0],a.Type.i32,0);return e.currentType}return t&&t.length>1&&e.error(n.DiagnosticCode.Expected_0_type_arguments_but_got_1,i.range,"1",t.length.toString(10)),e.error(n.DiagnosticCode.Expected_0_arguments_but_got_1,i.range,"1",r.length.toString(10)),null}function u(e,t){var r,i;return e.options.isWasm64?(r=e.precomputeExpression(t,a.Type.usize64,1,0),(s.getExpressionId(r)!=s.ExpressionId.Const||s.getExpressionType(r)!=s.NativeType.I64||0!=s.getConstValueI64High(r)||(i=s.getConstValueI64Low(r))<0)&&(e.error(n.DiagnosticCode.Operation_not_supported,t.range),i=-1)):(r=e.precomputeExpression(t,a.Type.usize32,1,0),(s.getExpressionId(r)!=s.ExpressionId.Const||s.getExpressionType(r)!=s.NativeType.I32||(i=s.getConstValueI32(r))<0)&&(e.error(n.DiagnosticCode.Operation_not_supported,t.range),i=-1)),i}t.compileCall=c;var h="allocate_memory";t.compileAllocate=function(e,t,r){var i=e.program;assert(t.program==i);var a=e.module,s=e.options,c=i.elementsLookup.get(h);if(!c)return i.error(n.DiagnosticCode.Cannot_find_name_0,r.range,h),a.createUnreachable();if(c.kind!=o.ElementKind.FUNCTION_PROTOTYPE)return i.error(n.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures,r.range,c.internalName),a.createUnreachable();var p=c.resolve();return p&&e.compileFunction(p)?(e.currentType=t.type,a.createCall(p.internalName,[s.isWasm64?a.createI64(t.currentMemoryOffset):a.createI32(t.currentMemoryOffset)],s.nativeSizeType)):a.createUnreachable()};var d="abort";function _(e,t,r){var n=e.program,i=e.module,c=n.typesLookup.get("string");if(!c)return i.createUnreachable();var p=n.elementsLookup.get(d);if(!p||p.kind!=o.ElementKind.FUNCTION_PROTOTYPE)return i.createUnreachable();var l=p.resolve();if(!l||!e.compileFunction(l))return i.createUnreachable();var u=null!=t?e.compileExpression(t,c,1,0):c.toNativeZero(i),h=e.compileStaticString(r.range.source.normalizedPath);return e.currentType=a.Type.void,i.createBlock(null,[i.createCallImport(l.internalName,[u,h,i.createI32(r.range.line),i.createI32(r.range.column)],s.NativeType.None),i.createUnreachable()])}t.compileAbort=_},function(t,r){t.exports=e},function(e,t,r){(function(e){const t=e.Binaryen||r(22);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(3).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(this,r(5))},function(e,t){e.exports=(e=>{var t=new Uint8Array(0),r=0;e.allocate_memory=function(e){if(!(e>>>=0))return 0;if(r+e>t.length){var n=t;(t=new Uint8Array(Math.max(65536,t.length+e,2*t.length))).set(n)}var i=r;return 7&(r+=e)&&(r=1+(7|r)),i},e.free_memory=function(e){},e.move_memory=function(e,r,n){t.copyWithin(e,r,r+n)},e.store=function(e,r,n){t[e+(0|n)]=r},e.load=function(e,r){return t[e+(0|r)]}})},function(e,t){e.exports=(e=>{e.JSMath=Math})},function(e,t,r){(function(e){var t="undefined"!=typeof window&&window||void 0!==e&&e||self;function n(){Error.captureStackTrace?Error.captureStackTrace(this,n):this.stack=this.name+": "+this.message+"\n"+(new Error).stack}function i(e){this.message=e||"assertion failed",Error.captureStackTrace?Error.captureStackTrace(this,i):this.stack=this.name+": "+this.message+"\n"+(new Error).stack}Object.defineProperties(t.i8=function(e){return e<<24>>24},{MIN_VALUE:{value:-128,writable:!1},MAX_VALUE:{value:127,writable:!1}}),Object.defineProperties(t.i16=function(e){return e<<16>>16},{MIN_VALUE:{value:-32768,writable:!1},MAX_VALUE:{value:32767,writable:!1}}),Object.defineProperties(t.i32=t.isize=function(e){return 0|e},{MIN_VALUE:{value:-2147483648,writable:!1},MAX_VALUE:{value:2147483647,writable:!1}}),Object.defineProperties(t.u8=function(e){return 255&e},{MIN_VALUE:{value:0,writable:!1},MAX_VALUE:{value:255,writable:!1}}),Object.defineProperties(t.u16=function(e){return 65535&e},{MIN_VALUE:{value:0,writable:!1},MAX_VALUE:{value:65535,writable:!1}}),Object.defineProperties(t.u32=t.usize=function(e){return e>>>0},{MIN_VALUE:{value:0,writable:!1},MAX_VALUE:{value:4294967295,writable:!1}}),Object.defineProperties(t.bool=function(e){return!!e},{MIN_VALUE:{value:0,writable:!1},MAX_VALUE:{value:1,writable:!1}}),Object.defineProperties(t.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_POSITIVE_VALUE:{value:Math.fround(1.175494351e-38),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(t.f64=function(e){return+e},{MIN_VALUE:{value:-1.7976931348623157e308,writable:!1},MAX_VALUE:{value:1.7976931348623157e308,writable:!1},MIN_POSITIVE_VALUE:{value:2.2250738585072014e-308,writable:!1},MIN_SAFE_INTEGER:{value:-9007199254740991,writable:!1},MAX_SAFE_INTEGER:{value:9007199254740991,writable:!1},EPSILON:{value:2.220446049250313e-16,writable:!1}}),t.clz=Math.clz32,t.ctz=function(e){var t=Math.clz32(e&-e);return e?31-t:t},t.popcnt=function(e){return 16843009*((e=(858993459&(e-=e>>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)>>>24},t.rotl=function(e,t){return e<<(t&=31)|e>>>32-t},t.rotr=function(e,t){return e>>>(t&=31)|e<<32-t},t.abs=Math.abs,t.max=Math.max,t.min=Math.min,t.ceil=Math.ceil,t.floor=Math.floor,t.nearest=function(e){return.5===Math.abs(e-Math.trunc(e))?2*Math.round(.5*e):Math.round(e)},t.select=function(e,t,r){return r?e:t},t.sqrt=Math.sqrt,t.trunc=Math.trunc,t.copysign=function(e,t){return Math.abs(e)*Math.sign(t)},t.bswap=function(e){var t=e>>8&16711935,r=(16711935&e)<<8;return(t=(e=t|r)>>16&65535)|(r=(65535&e)<<16)},t.bswap16=function(e){return e<<8&65280|e>>8&255|4294901760&e},n.prototype=Object.create(Error.prototype),n.prototype.name="UnreachableError",n.prototype.message="unreachable",t.unreachable=function(){throw new n},i.prototype=Object.create(Error.prototype),i.prototype.name="AssertionError",t.assert=function(e,t){if(e)return e;throw new i(t)},t.changetype=function(e){return e},t.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)},t.isInteger=Number.isInteger,t.isFloat=function(e){return"number"==typeof e},t.isReference=function(e){return"object"==typeof e||"string"==typeof e},t.isString=function(e){return"string"==typeof e||e instanceof String},t.isArray=Array.isArray,t.unchecked=function(e){return e},t.fmod=function(e,t){return e%t},t.fmodf=function(e,t){return Math.fround(e%t)},r(25)(t),r(24)(t)}).call(this,r(5))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(26),r(23),r(16),r(14)},function(e,t,r){r(27),e.exports=r(13)}])});
|
||
//# sourceMappingURL=assemblyscript.js.map
|