mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
3 lines
438 KiB
JavaScript
3 lines
438 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,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},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=15)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),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.DEFINITE_ASSIGNMENT=8192]="DEFINITE_ASSIGNMENT",e[e.AMBIENT=16384]="AMBIENT",e[e.GENERIC=32768]="GENERIC",e[e.GENERIC_CONTEXT=65536]="GENERIC_CONTEXT",e[e.INSTANCE=131072]="INSTANCE",e[e.CONSTRUCTOR=262144]="CONSTRUCTOR",e[e.ARROW=524288]="ARROW",e[e.MODULE_EXPORT=1048576]="MODULE_EXPORT",e[e.MODULE_IMPORT=2097152]="MODULE_IMPORT",e[e.RESOLVED=4194304]="RESOLVED",e[e.COMPILED=8388608]="COMPILED",e[e.INLINED=16777216]="INLINED",e[e.SCOPED=33554432]="SCOPED",e[e.TRAMPOLINE=67108864]="TRAMPOLINE",e[e.VIRTUAL=134217728]="VIRTUAL",e[e.MAIN=268435456]="MAIN",e[e.QUOTED=536870912]="QUOTED"}(t.CommonFlags||(t.CommonFlags={})),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,t.FILESPACE_PREFIX="file:"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(10),a=r(2),s=r(10);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="[96m",t.COLOR_YELLOW="[93m",t.COLOR_RED="[91m",t.COLOR_RESET="[0m",t.diagnosticCategoryToColor=c;var l=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 p(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=l,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(p(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=p;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=l.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";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(24)),n(r(25)),n(r(26)),n(r(27))},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),a=r(8);t.Token=a.Token,t.Range=a.Range;var s,o=r(2);!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.CLASS=9]="CLASS",e[e.COMMA=10]="COMMA",e[e.ELEMENTACCESS=11]="ELEMENTACCESS",e[e.FALSE=12]="FALSE",e[e.FUNCTION=13]="FUNCTION",e[e.INSTANCEOF=14]="INSTANCEOF",e[e.LITERAL=15]="LITERAL",e[e.NEW=16]="NEW",e[e.NULL=17]="NULL",e[e.PARENTHESIZED=18]="PARENTHESIZED",e[e.PROPERTYACCESS=19]="PROPERTYACCESS",e[e.TERNARY=20]="TERNARY",e[e.SUPER=21]="SUPER",e[e.THIS=22]="THIS",e[e.TRUE=23]="TRUE",e[e.CONSTRUCTOR=24]="CONSTRUCTOR",e[e.UNARYPOSTFIX=25]="UNARYPOSTFIX",e[e.UNARYPREFIX=26]="UNARYPREFIX",e[e.BLOCK=27]="BLOCK",e[e.BREAK=28]="BREAK",e[e.CONTINUE=29]="CONTINUE",e[e.DO=30]="DO",e[e.EMPTY=31]="EMPTY",e[e.EXPORT=32]="EXPORT",e[e.EXPORTIMPORT=33]="EXPORTIMPORT",e[e.EXPRESSION=34]="EXPRESSION",e[e.FOR=35]="FOR",e[e.IF=36]="IF",e[e.IMPORT=37]="IMPORT",e[e.RETURN=38]="RETURN",e[e.SWITCH=39]="SWITCH",e[e.THROW=40]="THROW",e[e.TRY=41]="TRY",e[e.VARIABLE=42]="VARIABLE",e[e.VOID=43]="VOID",e[e.WHILE=44]="WHILE",e[e.CLASSDECLARATION=45]="CLASSDECLARATION",e[e.ENUMDECLARATION=46]="ENUMDECLARATION",e[e.ENUMVALUEDECLARATION=47]="ENUMVALUEDECLARATION",e[e.FIELDDECLARATION=48]="FIELDDECLARATION",e[e.FUNCTIONDECLARATION=49]="FUNCTIONDECLARATION",e[e.IMPORTDECLARATION=50]="IMPORTDECLARATION",e[e.INTERFACEDECLARATION=51]="INTERFACEDECLARATION",e[e.METHODDECLARATION=52]="METHODDECLARATION",e[e.NAMESPACEDECLARATION=53]="NAMESPACEDECLARATION",e[e.TYPEDECLARATION=54]="TYPEDECLARATION",e[e.VARIABLEDECLARATION=55]="VARIABLEDECLARATION",e[e.DECORATOR=56]="DECORATOR",e[e.EXPORTMEMBER=57]="EXPORTMEMBER",e[e.SWITCHCASE=58]="SWITCHCASE",e[e.COMMENT=59]="COMMENT"}(s=t.NodeKind||(t.NodeKind={})),t.nodeIsConstantValue=function(e){switch(e){case s.LITERAL:case s.NULL:case s.TRUE:case s.FALSE:return!0}return!1},t.nodeIsCallable=function(e){switch(e){case s.IDENTIFIER:case s.CALL:case s.ELEMENTACCESS:case s.PROPERTYACCESS:case s.PARENTHESIZED:return!0}return!1},t.nodeIsGenericCallable=function(e){switch(e){case s.IDENTIFIER:case s.PROPERTYACCESS:return!0}return!1};var c=function(){function e(){this.parent=null,this.flags=i.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 p;return i.range=n,i.name=e,e.parent=i,i.typeArguments=t,t&&Fe(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 u;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 h;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 _;return a.range=i,a.parameters=e,Fe(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 g;return n.range=r,n.name=e,e.parent=n,n.arguments=t,t&&Fe(t,n),n.decoratorKind=m(e),n},e.createComment=function(e,t,r){var n=new y;return n.range=r,n.commentKind=t,n.text=e,n},e.createIdentifierExpression=function(e,t){var r=new T;return r.range=t,r.text=e,r},e.createEmptyIdentifierExpression=function(e){var t=new T;return t.range=e,t.text="",t},e.createArrayLiteralExpression=function(e,t){var r=new v;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 A;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 N;return i.range=n,i.expression=e,e.parent=i,i.typeArguments=t,t&&Fe(t,i),i.arguments=r,Fe(r,i),i},e.createClassExpression=function(e){var t=new O;return t.range=e.range,t.declaration=e,t},e.createCommaExpression=function(e,t){var r=new S;return r.range=t,r.expressions=e,Fe(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 X;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 R;return t.flags=e.flags&i.CommonFlags.ARROW,t.range=e.range,t.declaration=e,t},e.createInstanceOfExpression=function(e,t,r){var n=new x;return n.range=r,n.expression=e,e.parent=n,n.isType=t,t.parent=n,n},e.createIntegerLiteralExpression=function(e,t){var r=new F;return r.range=t,r.value=e,r},e.createNewExpression=function(e,t,r,n){var i=new D;return i.range=n,i.expression=e,e.parent=i,i.typeArguments=t,t&&Fe(t,i),i.arguments=r,Fe(r,i),i},e.createNullExpression=function(e){var t=new B;return t.range=e,t},e.createObjectLiteralExpression=function(e,t,r){var n=new U;return n.range=r,n.names=e,n.values=t,n},e.createParenthesizedExpression=function(e,t){var r=new P;return r.range=t,r.expression=e,e.parent=r,r},e.createPropertyAccessExpression=function(e,t,r){var n=new w;return n.range=r,n.expression=e,e.parent=n,n.property=t,t.parent=n,n},e.createRegexpLiteralExpression=function(e,t,r){var n=new M;return n.range=r,n.pattern=e,n.patternFlags=t,n},e.createTernaryExpression=function(e,t,r,n){var i=new G;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 K;return r.range=t,r.value=e,r},e.createSuperExpression=function(e){var t=new z;return t.range=e,t},e.createThisExpression=function(e){var t=new V;return t.range=e,t},e.createTrueExpression=function(e){var t=new H;return t.range=e,t},e.createUnaryPostfixExpression=function(e,t,r){var n=new Y;return n.range=r,n.operator=e,n.operand=t,t.parent=n,n},e.createUnaryPrefixExpression=function(e,t,r){var n=new Q;return n.range=r,n.operator=e,n.operand=t,t.parent=n,n},e.createBlockStatement=function(e,t){var r=new ee;return r.range=t,r.statements=e,Fe(e,r),r},e.createBreakStatement=function(e,t){var r=new te;return r.range=t,r.label=e,e&&(e.parent=r),r},e.createClassDeclaration=function(e,t,r,n,i,a,s,o){var c=new re;return c.range=o,c.flags=s,c.name=e,e.parent=c,c.typeParameters=t,Fe(t,c),c.extendsType=r,r&&(r.parent=c),c.implementsTypes=n,n&&Fe(n,c),c.members=i,Fe(i,c),c.decorators=a,a&&Fe(a,c),c},e.createContinueStatement=function(e,t){var r=new ne;return r.range=t,r.label=e,e&&(e.parent=r),r},e.createDoStatement=function(e,t,r){var n=new ie;return n.range=r,n.statement=e,e.parent=n,n.condition=t,t.parent=n,n},e.createEmptyStatement=function(e){var t=new ae;return t.range=e,t},e.createEnumDeclaration=function(e,t,r,n,i){var a=new se;return a.range=i,a.flags=n,a.name=e,e.parent=a,a.values=t,Fe(t,a),a.decorators=r,r&&Fe(r,a),a},e.createEnumValueDeclaration=function(e,t,r,n){var i=new oe;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 pe;if(i.range=n,i.flags=r,i.members=e,e&&Fe(e,i),i.path=t,t){var a=o.normalizePath(t.value);t.value.startsWith(".")?i.normalizedPath=o.resolvePath(a,n.source.normalizedPath):i.normalizedPath=a,i.internalPath=xe(i.normalizedPath)}else i.normalizedPath=null,i.internalPath=null;return i},e.createExportImportStatement=function(e,t,r){var n=new ce;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 le;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 ue;return t.range=e.range,t.expression=e,e.parent=t,t},e.createIfStatement=function(e,t,r,n){var i=new me;return i.range=n,i.condition=e,e.parent=i,i.ifTrue=t,t.parent=i,i.ifFalse=r,r&&(r.parent=i),i},e.createImportStatement=function(e,t,r){var n=new ye;n.range=r,n.declarations=e,e&&Fe(e,n),n.namespaceName=null,n.path=t;var a=o.normalizePath(t.value);return t.value.startsWith(".")?n.normalizedPath=o.resolvePath(a,r.source.normalizedPath):(a.startsWith(i.LIBRARY_PREFIX)||(a=i.LIBRARY_PREFIX+a),n.normalizedPath=a),n.internalPath=xe(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=o.resolvePath(o.normalizePath(t.value),r.source.normalizedPath),n.internalPath=xe(n.normalizedPath),n},e.createImportDeclaration=function(e,t,r){var n=new ge;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 Ee;return o.range=s,o.flags=a,o.name=e,e.parent=o,o.typeParameters=t,t&&Fe(t,o),o.extendsType=r,r&&(r.parent=o),o.members=n,Fe(n,o),o.decorators=i,i&&Fe(i,o),o},e.createFieldDeclaration=function(e,t,r,n,i,a){var s=new he;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&&Fe(n,s),s},e.createForStatement=function(e,t,r,n,i){var a=new de;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 _e;return o.range=s,o.flags=a,o.name=e,e.parent=o,o.typeParameters=t,t&&Fe(t,o),o.signature=r,r.parent=o,o.body=n,n&&(n.parent=o),o.decorators=i,i&&Fe(i,o),o},e.createMethodDeclaration=function(e,t,r,n,i,a,s){var o=new fe;return o.range=s,o.flags=a,o.name=e,e.parent=o,o.typeParameters=t,t&&Fe(t,o),o.signature=r,r.parent=o,o.body=n,n&&(n.parent=o),o.decorators=i,i&&Fe(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,Fe(t,a),a.decorators=r,r&&Fe(r,a),a},e.createReturnStatement=function(e,t){var r=new Ie;return r.range=t,r.value=e,e&&(e.parent=r),r},e.createSwitchStatement=function(e,t,r){var n=new Ae;return n.range=r,n.condition=e,e.parent=n,n.cases=t,Fe(t,n),n},e.createSwitchCase=function(e,t,r){var n=new ve;return n.range=r,n.label=e,e&&(e.parent=n),n.statements=t,Fe(t,n),n},e.createThrowStatement=function(e,t){var r=new Ce;return r.range=t,r.value=e,e.parent=r,r},e.createTryStatement=function(e,t,r,n,i){var a=new Ne;return a.range=i,a.statements=e,Fe(e,a),a.catchVariable=t,t&&(t.parent=a),a.catchStatements=r,r&&Fe(r,a),a.finallyStatements=n,n&&Fe(n,a),a},e.createTypeDeclaration=function(e,t,r,n,i,a){var s=new Oe;return s.range=a,s.flags=i,s.name=e,e.parent=s,s.typeParameters=t,t&&Fe(t,s),s.type=r,r.parent=s,s.decorators=n,n&&Fe(n,s),s},e.createVariableStatement=function(e,t,r,n){var i=new Le;return i.range=n,i.flags=r,i.declarations=e,Fe(e,i),i.decorators=t,t&&Fe(t,i),i},e.createVariableDeclaration=function(e,t,r,n,i,a){var s=new Se;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 be;return r.range=t,r.expression=e,r},e.createWhileStatement=function(e,t,r){var n=new ke;return n.range=r,n.condition=e,e.parent=n,n.statement=t,t.parent=n,n},e}();t.Node=c;var l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(c);t.CommonTypeNode=l;var p=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.TYPE,t}return n(t,e),t}(l);t.TypeNode=p;var u=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.TYPEPARAMETER,t}return n(t,e),t}(c);t.TypeParameterNode=u,function(e){e[e.DEFAULT=0]="DEFAULT",e[e.OPTIONAL=1]="OPTIONAL",e[e.REST=2]="REST"}(t.ParameterKind||(t.ParameterKind={}));var h=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.PARAMETER,t.implicitFieldDeclaration=null,t}return n(t,e),t}(c);t.ParameterNode=h;var d,_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.SIGNATURE,t}return n(t,e),t}(l);function m(e){if(e.kind==s.IDENTIFIER){var t=e.text;switch(assert(t.length),t.charCodeAt(0)){case 98:if("builtin"==t)return d.BUILTIN;break;case 101:if("external"==t)return d.EXTERNAL;break;case 103:if("global"==t)return d.GLOBAL;break;case 105:if("inline"==t)return d.INLINE;break;case 111:if("operator"==t)return d.OPERATOR;break;case 115:if("sealed"==t)return d.SEALED;break;case 117:if("unmanaged"==t)return d.UNMANAGED}}else if(e.kind==s.PROPERTYACCESS&&e.expression.kind==s.IDENTIFIER){t=e.expression.text;assert(t.length);var r=e.property.text;if(assert(r.length),"operator"==t)switch(r.charCodeAt(0)){case 98:if("binary"==r)return d.OPERATOR_BINARY;break;case 112:switch(r){case"prefix":return d.OPERATOR_PREFIX;case"postfix":return d.OPERATOR_POSTFIX}}}return d.CUSTOM}t.SignatureNode=_,function(e){e[e.CUSTOM=0]="CUSTOM",e[e.GLOBAL=1]="GLOBAL",e[e.OPERATOR=2]="OPERATOR",e[e.OPERATOR_BINARY=3]="OPERATOR_BINARY",e[e.OPERATOR_PREFIX=4]="OPERATOR_PREFIX",e[e.OPERATOR_POSTFIX=5]="OPERATOR_POSTFIX",e[e.UNMANAGED=6]="UNMANAGED",e[e.SEALED=7]="SEALED",e[e.INLINE=8]="INLINE",e[e.EXTERNAL=9]="EXTERNAL",e[e.BUILTIN=10]="BUILTIN"}(d=t.DecoratorKind||(t.DecoratorKind={})),t.decoratorNameToKind=m;var g=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.DECORATOR,t}return n(t,e),t}(c);t.DecoratorNode=g,function(e){e[e.LINE=0]="LINE",e[e.TRIPLE=1]="TRIPLE",e[e.BLOCK=2]="BLOCK"}(t.CommentKind||(t.CommentKind={}));var y=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.COMMENT,t}return n(t,e),t}(c);t.CommentNode=y;var E=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(c);t.Expression=E;var f,T=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.IDENTIFIER,t}return n(t,e),t}(E);t.IdentifierExpression=T,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 I=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.LITERAL,t}return n(t,e),t}(E);t.LiteralExpression=I;var v=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=f.ARRAY,t}return n(t,e),t}(I);t.ArrayLiteralExpression=v,function(e){e[e.PREFIX=0]="PREFIX",e[e.AS=1]="AS"}(t.AssertionKind||(t.AssertionKind={}));var A=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.ASSERTION,t}return n(t,e),t}(E);t.AssertionExpression=A;var C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.BINARY,t}return n(t,e),t}(E);t.BinaryExpression=C;var N=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.CALL,t}return n(t,e),t}(E);t.CallExpression=N;var O=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.CLASS,t}return n(t,e),t}(E);t.ClassExpression=O;var S=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.COMMA,t}return n(t,e),t}(E);t.CommaExpression=S;var L=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.CONSTRUCTOR,t.text="constructor",t}return n(t,e),t}(T);t.ConstructorExpression=L;var b=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.ELEMENTACCESS,t}return n(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 n(t,e),t}(I);t.FloatLiteralExpression=k;var R=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.FUNCTION,t}return n(t,e),t}(E);t.FunctionExpression=R;var x=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.INSTANCEOF,t}return n(t,e),t}(E);t.InstanceOfExpression=x;var F=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=f.INTEGER,t}return n(t,e),t}(I);t.IntegerLiteralExpression=F;var D=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.NEW,t}return n(t,e),t}(N);t.NewExpression=D;var B=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.NULL,t.text="null",t}return n(t,e),t}(T);t.NullExpression=B;var U=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=f.OBJECT,t}return n(t,e),t}(I);t.ObjectLiteralExpression=U;var P=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.PARENTHESIZED,t}return n(t,e),t}(E);t.ParenthesizedExpression=P;var w=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.PROPERTYACCESS,t}return n(t,e),t}(E);t.PropertyAccessExpression=w;var M=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=f.REGEXP,t}return n(t,e),t}(I);t.RegexpLiteralExpression=M;var G=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.TERNARY,t}return n(t,e),t}(E);t.TernaryExpression=G;var K=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.literalKind=f.STRING,t}return n(t,e),t}(I);t.StringLiteralExpression=K;var z=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.SUPER,t.text="super",t}return n(t,e),t}(T);t.SuperExpression=z;var V=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.THIS,t.text="this",t}return n(t,e),t}(T);t.ThisExpression=V;var H=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.TRUE,t.text="true",t}return n(t,e),t}(T);t.TrueExpression=H;var X=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.FALSE,t.text="false",t}return n(t,e),t}(T);t.FalseExpression=X;var W=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(E);t.UnaryExpression=W;var Y=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.UNARYPOSTFIX,t}return n(t,e),t}(W);t.UnaryPostfixExpression=Y;var Q=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.UNARYPREFIX,t}return n(t,e),t}(W);t.UnaryPrefixExpression=Q,t.isLastStatement=function(e){var t=assert(e.parent);if(t.kind==s.BLOCK){var r=t.statements;if(r[r.length-1]===e)switch(assert(t.parent).kind){case s.FUNCTIONDECLARATION:case s.METHODDECLARATION:return!0}}return!1};var q,j=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(c);t.Statement=j,function(e){e[e.DEFAULT=0]="DEFAULT",e[e.ENTRY=1]="ENTRY",e[e.LIBRARY=2]="LIBRARY"}(q=t.SourceKind||(t.SourceKind={}));var Z=function(e){function t(t,r,n){var o=e.call(this)||this;o.kind=s.SOURCE,o.parent=null,o.tokenizer=null,o.debugInfoIndex=-1,o.exportPaths=null,o.sourceKind=n,o.normalizedPath=t;var c=xe(o.normalizedPath);o.internalPath=c;var l=c.lastIndexOf(i.PATH_DELIMITER);return o.simplePath=l>=0?c.substring(l+1):c,o.statements=new Array,o.range=new a.Range(o,0,r.length),o.text=r,o}return n(t,e),Object.defineProperty(t.prototype,"isEntry",{get:function(){return this.sourceKind==q.ENTRY},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isLibrary",{get:function(){return this.sourceKind==q.LIBRARY},enumerable:!0,configurable:!0}),t}(c);t.Source=Z;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 n(t,e),Object.defineProperty(t.prototype,"programLevelInternalName",{get:function(){return this.cachedProgramLevelInternalName||(this.cachedProgramLevelInternalName=Re(this,!0)),this.cachedProgramLevelInternalName},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fileLevelInternalName",{get:function(){return this.cachedFileLevelInternalName||(this.cachedFileLevelInternalName=Re(this,!1)),this.cachedFileLevelInternalName},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isTopLevel",{get:function(){var e=this.parent;return!!e&&(!(e.kind==s.VARIABLE&&!(e=e.parent))&&e.kind==s.SOURCE)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isTopLevelExport",{get:function(){var e=this.parent;return!(!e||e.kind==s.VARIABLE&&!(e=e.parent))&&(e.kind==s.NAMESPACEDECLARATION?this.is(i.CommonFlags.EXPORT)&&e.isTopLevelExport:e.kind==s.CLASSDECLARATION?this.is(i.CommonFlags.STATIC)&&e.isTopLevelExport:e.kind==s.SOURCE&&this.is(i.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}(j);t.DeclarationStatement=J;var $=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(J);t.VariableLikeDeclarationStatement=$;var ee=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.BLOCK,t}return n(t,e),t}(j);t.BlockStatement=ee;var te=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.BREAK,t}return n(t,e),t}(j);t.BreakStatement=te;var re=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.CLASSDECLARATION,t}return n(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=re;var ne=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.CONTINUE,t}return n(t,e),t}(j);t.ContinueStatement=ne;var ie=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.DO,t}return n(t,e),t}(j);t.DoStatement=ie;var ae=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.EMPTY,t}return n(t,e),t}(j);t.EmptyStatement=ae;var se=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.ENUMDECLARATION,t}return n(t,e),t}(J);t.EnumDeclaration=se;var oe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.ENUMVALUEDECLARATION,t}return n(t,e),t}(J);t.EnumValueDeclaration=oe;var ce=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.EXPORTIMPORT,t}return n(t,e),t}(c);t.ExportImportStatement=ce;var le=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.EXPORTMEMBER,t}return n(t,e),t}(c);t.ExportMember=le;var pe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.EXPORT,t}return n(t,e),t}(j);t.ExportStatement=pe;var ue=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.EXPRESSION,t}return n(t,e),t}(j);t.ExpressionStatement=ue;var he=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.FIELDDECLARATION,t.parameterIndex=-1,t}return n(t,e),t}($);t.FieldDeclaration=he;var de=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.FOR,t}return n(t,e),t}(j);t.ForStatement=de;var _e=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.FUNCTIONDECLARATION,t}return n(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=_e;var me=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.IF,t}return n(t,e),t}(j);t.IfStatement=me;var ge=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.IMPORTDECLARATION,t}return n(t,e),t}(J);t.ImportDeclaration=ge;var ye=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.IMPORT,t}return n(t,e),t}(j);t.ImportStatement=ye;var Ee=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.INTERFACEDECLARATION,t}return n(t,e),t}(re);t.InterfaceDeclaration=Ee;var fe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.METHODDECLARATION,t}return n(t,e),t}(_e);t.MethodDeclaration=fe;var Te=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.NAMESPACEDECLARATION,t}return n(t,e),t}(J);t.NamespaceDeclaration=Te;var Ie=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.RETURN,t}return n(t,e),t}(j);t.ReturnStatement=Ie;var ve=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.SWITCHCASE,t}return n(t,e),t}(c);t.SwitchCase=ve;var Ae=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.SWITCH,t}return n(t,e),t}(j);t.SwitchStatement=Ae;var Ce=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.THROW,t}return n(t,e),t}(j);t.ThrowStatement=Ce;var Ne=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.TRY,t}return n(t,e),t}(j);t.TryStatement=Ne;var Oe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.TYPEDECLARATION,t}return n(t,e),t}(J);t.TypeDeclaration=Oe;var Se=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.VARIABLEDECLARATION,t}return n(t,e),t}($);t.VariableDeclaration=Se;var Le=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.VARIABLE,t}return n(t,e),t}(j);t.VariableStatement=Le;var be=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.VOID,t}return n(t,e),t}(j);t.VoidStatement=be;var ke=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.kind=s.WHILE,t}return n(t,e),t}(j);function Re(e,t){void 0===t&&(t=!1);var r=e.name.text,n=e.parent;return n&&(e.kind!=s.VARIABLEDECLARATION||n.kind!=s.VARIABLE||(n=n.parent))?n.kind==s.CLASSDECLARATION?Re(n,t)+(e.is(i.CommonFlags.STATIC)?i.STATIC_DELIMITER:i.INSTANCE_DELIMITER)+r:n.kind==s.NAMESPACEDECLARATION||n.kind==s.ENUMDECLARATION?Re(n,t)+i.STATIC_DELIMITER+r:t?r:e.range.source.internalPath+i.PATH_DELIMITER+r:r}function xe(e){return e.endsWith(".ts")&&(e=e.substring(0,e.length-3)),e}function Fe(e,t){for(var r=0,n=e.length;r<n;++r)e[r].parent=t}t.WhileStatement=ke,t.findDecorator=function(e,t){if(t)for(var r=0,n=t.length;r<n;++r){var i=t[r];if(i.decoratorKind==e)return i}return null},t.mangleInternalName=Re,t.mangleInternalPath=xe},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),i=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}},a=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),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 s,o=r(0),c=r(1),l=r(6),p=r(3),u=r(5),h=r(11),d=function(){return function(){}}(),_=function(){return function(){}}(),m=function(){return function(){}}();function g(e,t){switch(assert(t.length),e){case p.DecoratorKind.OPERATOR:case p.DecoratorKind.OPERATOR_BINARY:switch(t.charCodeAt(0)){case 91:if("[]"==t)return s.INDEXED_GET;if("[]="==t)return s.INDEXED_SET;break;case 123:if("{}"==t)return s.UNCHECKED_INDEXED_GET;if("{}="==t)return s.UNCHECKED_INDEXED_SET;break;case 43:if("+"==t)return s.ADD;break;case 45:if("-"==t)return s.SUB;break;case 42:if("*"==t)return s.MUL;if("**"==t)return s.POW;break;case 47:if("/"==t)return s.DIV;break;case 37:if("%"==t)return s.REM;break;case 38:if("&"==t)return s.BITWISE_AND;break;case 124:if("|"==t)return s.BITWISE_OR;break;case 94:if("^"==t)return s.BITWISE_XOR;break;case 61:if("=="==t)return s.EQ;break;case 33:if("!="==t)return s.NE;break;case 62:if(">"==t)return s.GT;if(">="==t)return s.GE;if(">>"==t)return s.BITWISE_SHR;if(">>>"==t)return s.BITWISE_SHR_U;break;case 60:if("<"==t)return s.LT;if("<="==t)return s.LE;if("<<"==t)return s.BITWISE_SHL}break;case p.DecoratorKind.OPERATOR_PREFIX:switch(t.charCodeAt(0)){case 43:if("+"==t)return s.PLUS;if("++"==t)return s.PREFIX_INC;break;case 45:if("-"==t)return s.MINUS;if("--"==t)return s.PREFIX_DEC;break;case 33:if("!"==t)return s.NOT;break;case 126:if("~"==t)return s.BITWISE_NOT}break;case p.DecoratorKind.OPERATOR_POSTFIX:switch(t.charCodeAt(0)){case 43:if("++"==t)return s.POSTFIX_INC;break;case 45:if("--"==t)return s.POSTFIX_DEC}}return s.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.BITWISE_AND=11]="BITWISE_AND",e[e.BITWISE_OR=12]="BITWISE_OR",e[e.BITWISE_XOR=13]="BITWISE_XOR",e[e.BITWISE_SHL=14]="BITWISE_SHL",e[e.BITWISE_SHR=15]="BITWISE_SHR",e[e.BITWISE_SHR_U=16]="BITWISE_SHR_U",e[e.EQ=17]="EQ",e[e.NE=18]="NE",e[e.GT=19]="GT",e[e.GE=20]="GE",e[e.LT=21]="LT",e[e.LE=22]="LE",e[e.PLUS=23]="PLUS",e[e.MINUS=24]="MINUS",e[e.NOT=25]="NOT",e[e.BITWISE_NOT=26]="BITWISE_NOT",e[e.PREFIX_INC=27]="PREFIX_INC",e[e.PREFIX_DEC=28]="PREFIX_DEC",e[e.POSTFIX_INC=29]="POSTFIX_INC",e[e.POSTFIX_DEC=30]="POSTFIX_DEC"}(s=t.OperatorKind||(t.OperatorKind={}));var y,E,f=new Map,T=function(e){function t(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=f,r.typeAliases=new Map,r.fileLevelExports=new Map,r.moduleLevelExports=new Map,r.arrayBufferInstance=null,r.arrayPrototype=null,r.stringInstance=null,r.mainFunction=null,r.abortInstance=null,r.memoryAllocateInstance=null,r.hasGC=!1,r.gcAllocateInstance=null,r.gcLinkInstance=null,r.gcMarkInstance=null,r.gcHeaderSize=0,r.gcHookOffset=0,r.resolver=new h.Resolver(r),r.sources=[],r}return n(t,e),t.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},t.prototype.lookupSourceByPath=function(e){var t;return this.getSource(e+".ts")||this.getSource(e+"/index.ts")||this.getSource((t=o.LIBRARY_PREFIX+e)+".ts")||this.getSource(t+"/index.ts")},t.prototype.initialize=function(e){var t,r,n,s;this.options=e,this.typesLookup=new Map([["i8",l.Type.i8],["i16",l.Type.i16],["i32",l.Type.i32],["i64",l.Type.i64],["isize",e.isizeType],["u8",l.Type.u8],["u16",l.Type.u16],["u32",l.Type.u32],["u64",l.Type.u64],["usize",e.usizeType],["bool",l.Type.bool],["f32",l.Type.f32],["f64",l.Type.f64],["void",l.Type.void],["number",l.Type.f64],["boolean",l.Type.bool]]),this.setConstantInteger("ASC_TARGET",l.Type.i32,i64_new(e.isWasm64?2:1)),this.setConstantInteger("ASC_NO_TREESHAKING",l.Type.bool,i64_new(e.noTreeShaking?1:0,0)),this.setConstantInteger("ASC_NO_ASSERT",l.Type.bool,i64_new(e.noAssert?1:0,0)),this.setConstantInteger("ASC_MEMORY_BASE",l.Type.i32,i64_new(e.memoryBase,0)),this.setConstantInteger("ASC_OPTIMIZE_LEVEL",l.Type.i32,i64_new(e.optimizeLevelHint,0)),this.setConstantInteger("ASC_SHRINK_LEVEL",l.Type.i32,i64_new(e.shrinkLevelHint,0)),this.setConstantInteger("ASC_FEATURE_MUTABLE_GLOBAL",l.Type.bool,i64_new(e.hasFeature(2)?1:0,0)),this.setConstantInteger("ASC_FEATURE_SIGN_EXTENSION",l.Type.bool,i64_new(e.hasFeature(1)?1:0,0));for(var u=new Array,h=new Map,d=new Array,_=new Array,m=0,g=this.sources.length;m<g;++m){var E=this.sources[m],f=new A(this,E);this.elementsLookup.set(f.internalName,f),this.currentFilespace=f;for(var T=E.statements,I=0,v=T.length;I<v;++I){var C=T[I];switch(C.kind){case p.NodeKind.CLASSDECLARATION:this.initializeClass(C,d,_);break;case p.NodeKind.ENUMDECLARATION:this.initializeEnum(C);break;case p.NodeKind.EXPORT:this.initializeExports(C,h);break;case p.NodeKind.FUNCTIONDECLARATION:this.initializeFunction(C);break;case p.NodeKind.IMPORT:this.initializeImports(C,h,u);break;case p.NodeKind.INTERFACEDECLARATION:this.initializeInterface(C);break;case p.NodeKind.NAMESPACEDECLARATION:this.initializeNamespace(C,d,_);break;case p.NodeKind.TYPEDECLARATION:this.initializeTypeAlias(C);break;case p.NodeKind.VARIABLE:this.initializeVariables(C)}}}for(m=0;m<u.length;){var N=u[m];if(X=N.declaration)(x=this.tryLocateImport(N.externalName,h))?(this.elementsLookup.set(N.localName,x),u.splice(m,1)):(x=this.tryLocateImport(N.externalNameAlt,h))?(this.elementsLookup.set(N.localName,x),u.splice(m,1)):(this.error(c.DiagnosticCode.Module_0_has_no_exported_member_1,X.range,X.parent.path.value,X.externalName.text),++m);else(x=this.elementsLookup.get(N.externalName))?(this.elementsLookup.set(N.localName,x),u.splice(m,1)):(x=this.elementsLookup.get(N.externalNameAlt))?(this.elementsLookup.set(N.localName,x),u.splice(m,1)):(assert(!1),++m)}try{for(var O=i(h),S=O.next();!S.done;S=O.next()){var L=a(S.value,2),b=L[0],k=L[1],R=k,x=void 0;do{if(!R.isReExport){(x=this.elementsLookup.get(R.externalName))||(x=this.elementsLookup.get(R.member.name.text))?this.setExportAndCheckLibrary(b,x,k.member.externalName):this.error(c.DiagnosticCode.Cannot_find_name_0,k.member.range,k.member.name.text);break}if(x=this.fileLevelExports.get(R.externalName)){this.setExportAndCheckLibrary(b,x,k.member.externalName);break}(R=h.get(R.externalName))||this.error(c.DiagnosticCode.Module_0_has_no_exported_member_1,k.member.externalName.range,k.member.parent.path.value,k.member.externalName.text)}while(R)}}catch(e){t={error:e}}finally{try{S&&!S.done&&(r=O.return)&&r.call(O)}finally{if(t)throw t.error}}var F=this.resolver;for(m=0,g=d.length;m<g;++m){var D=d[m],B=D.declaration,U=assert(B.extendsType),P=F.resolveIdentifier(U.name,null);if(P)if(P.kind==y.CLASS_PROTOTYPE){var w=P;D.basePrototype=w}else this.error(c.DiagnosticCode.A_class_may_only_extend_another_class,U.range)}var M=e.globalAliases;if(M)try{for(var G=i(M),K=G.next();!K.done;K=G.next()){var z=a(K.value,2),V=z[0],H=z[1];if(H.length){if(!(x=this.elementsLookup.get(H)))throw new Error("element not found: "+H);this.elementsLookup.set(V,x)}}}catch(e){n={error:e}}finally{try{K&&!K.done&&(s=G.return)&&s.call(G)}finally{if(n)throw n.error}}if(this.elementsLookup.has("ArrayBuffer")){x=assert(this.elementsLookup.get("ArrayBuffer"));assert(x.kind==y.CLASS_PROTOTYPE),this.arrayBufferInstance=F.resolveClass(x,null)}if(this.elementsLookup.has("Array")){x=assert(this.elementsLookup.get("Array"));assert(x.kind==y.CLASS_PROTOTYPE),this.arrayPrototype=x}if(this.elementsLookup.has("String")){x=assert(this.elementsLookup.get("String"));if(assert(x.kind==y.CLASS_PROTOTYPE),W=F.resolveClass(x,null))if(this.typesLookup.has("string")){var X=x.declaration;this.error(c.DiagnosticCode.Duplicate_identifier_0,X.name.range,X.programLevelInternalName)}else this.stringInstance=W,this.typesLookup.set("string",W.type)}x=assert(this.elementsLookup.get("start"));(assert(x.kind==y.FUNCTION_PROTOTYPE),this.startFunction=x,this.moduleLevelExports.has("main"))&&((x=this.moduleLevelExports.get("main").element).kind!=y.FUNCTION_PROTOTYPE||x.isAny(o.CommonFlags.GENERIC|o.CommonFlags.AMBIENT)||(x.set(o.CommonFlags.MAIN),this.mainFunction=x));if(this.elementsLookup.has("abort")){x=this.elementsLookup.get("abort");assert(x.kind==y.FUNCTION_PROTOTYPE),(W=this.resolver.resolveFunction(x,null))&&(this.abortInstance=W)}if(this.elementsLookup.has("memory")){var W,Y=(x=this.elementsLookup.get("memory")).members;if(Y)if(Y.has("allocate"))x=assert(Y.get("allocate")),assert(x.kind==y.FUNCTION_PROTOTYPE),(W=this.resolver.resolveFunction(x,null))&&(this.memoryAllocateInstance=W)}if(this.elementsLookup.has("__gc_allocate")&&this.elementsLookup.has("__gc_link")&&this.elementsLookup.has("__gc_mark")){x=this.elementsLookup.get("__gc_allocate");assert(x.kind==y.FUNCTION_PROTOTYPE);var Q=assert(this.resolver.resolveFunction(x,null)),q=Q.signature;assert(2==q.parameterTypes.length),assert(q.parameterTypes[0]==this.options.usizeType),assert(q.parameterTypes[1].signatureReference),assert(q.returnType==this.options.usizeType),x=this.elementsLookup.get("__gc_link"),assert(x.kind==y.FUNCTION_PROTOTYPE);var j=assert(this.resolver.resolveFunction(x,null));q=j.signature,assert(2==q.parameterTypes.length),assert(q.parameterTypes[0]==this.options.usizeType),assert(q.parameterTypes[1]==this.options.usizeType),assert(q.returnType==l.Type.void),x=this.elementsLookup.get("__gc_mark"),assert(x.kind==y.FUNCTION_PROTOTYPE);var Z=assert(this.resolver.resolveFunction(x,null));q=Z.signature,assert(1==q.parameterTypes.length),assert(q.parameterTypes[0]==this.options.usizeType),assert(q.returnType==l.Type.void),this.gcAllocateInstance=Q,this.gcLinkInstance=j,this.gcMarkInstance=Z;var J=2*e.usizeType.byteSize;this.gcHookOffset=J,this.gcHeaderSize=J+4+7&-8,this.hasGC=!0}},t.prototype.setConstantInteger=function(e,t,r){assert(t.is(4));var n=new L(this,e,e,t,null,E.NONE).withConstantIntegerValue(r);n.set(o.CommonFlags.RESOLVED),this.elementsLookup.set(e,n)},t.prototype.setConstantFloat=function(e,t,r){assert(t.is(8));var n=new L(this,e,e,t,null,E.NONE).withConstantFloatValue(r);n.set(o.CommonFlags.RESOLVED),this.elementsLookup.set(e,n)},t.prototype.tryLocateImport=function(e,t){for(var r,n=this.fileLevelExports;;){if(r=n.get(e))return r;var i=t.get(e);if(!i)break;if(!i.isReExport)return this.elementsLookup.get(i.externalName);e=i.externalName}return null},t.prototype.checkDecorators=function(e,t){for(var r=E.NONE,n=0,i=e.length;n<i;++n){var a=e[n],s=I(p.decoratorNameToKind(a.name));s&&(s==E.BUILTIN?a.range.source.isLibrary?r|=s:this.error(c.DiagnosticCode.Decorator_0_is_not_valid_here,a.range,a.name.range.toString()):t&s?r&s?this.error(c.DiagnosticCode.Duplicate_decorator,a.range,a.name.range.toString()):r|=s:this.error(c.DiagnosticCode.Decorator_0_is_not_valid_here,a.range,a.name.range.toString()))}return r},t.prototype.checkGlobal=function(e,t){var r=t.parent;if(e.hasDecorator(E.GLOBAL)||t.range.source.isLibrary&&e.is(o.CommonFlags.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(c.DiagnosticCode.Duplicate_identifier_0,t.name.range,e.internalName):this.elementsLookup.set(n,e)}e.hasDecorator(E.BUILTIN)&&(e.internalName=t.programLevelInternalName)},t.prototype.initializeClass=function(e,t,r,n){void 0===n&&(n=null);var i=e.fileLevelInternalName;if(this.elementsLookup.has(i))this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,i);else{var a=e.decorators,s=e.name.text,l=new P(this,s,i,e,a?this.checkDecorators(a,E.GLOBAL|E.SEALED|E.UNMANAGED):E.NONE);l.parent=n,this.elementsLookup.set(i,l);var u=e.implementsTypes;if(u){var h=u.length;if(l.hasDecorator(E.UNMANAGED))h&&this.error(c.DiagnosticCode.Unmanaged_classes_cannot_implement_interfaces,p.Range.join(e.name.range,u[h-1].range));else if(h){for(var d=0;d<h;++d)this.warning(c.DiagnosticCode.Operation_not_supported,u[d].range);r.push(l)}}if(e.extendsType&&t.push(l),n){if(n.members){if(n.members.has(s))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,i)}else n.members=new Map;n.members.set(s,l),n.is(o.CommonFlags.MODULE_EXPORT)&&l.is(o.CommonFlags.EXPORT)&&l.set(o.CommonFlags.MODULE_EXPORT)}else if(l.is(o.CommonFlags.EXPORT)){if(this.fileLevelExports.has(i))return void this.error(c.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,i);if(this.fileLevelExports.set(i,l),this.currentFilespace.members.set(s,l),l.is(o.CommonFlags.EXPORT)&&e.range.source.isEntry){if(this.moduleLevelExports.has(s)){var _=this.moduleLevelExports.get(s);return void this.error(c.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,_.element.internalName)}l.set(o.CommonFlags.MODULE_EXPORT),this.moduleLevelExports.set(s,{element:l,identifier:e.name})}}for(var m=e.members,g=(d=0,m.length);d<g;++d){var y=m[d];switch(y.kind){case p.NodeKind.FIELDDECLARATION:this.initializeField(y,l);break;case p.NodeKind.METHODDECLARATION:y.isAny(o.CommonFlags.GET|o.CommonFlags.SET)?this.initializeAccessor(y,l):this.initializeMethod(y,l);break;default:return void assert(!1)}}this.checkGlobal(l,e)}},t.prototype.initializeField=function(e,t){var r=e.name.text,n=e.fileLevelInternalName,i=e.decorators,a=t.kind==y.INTERFACE_PROTOTYPE;if(e.is(o.CommonFlags.STATIC)){if(a&&assert(!1),this.elementsLookup.has(n))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,n);if(t.members){if(t.members.has(r))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else t.members=new Map;var s=new L(this,r,n,l.Type.void,e,i?this.checkDecorators(i,E.INLINE):E.NONE);s.parent=t,t.members.set(r,s),this.elementsLookup.set(n,s),t.is(o.CommonFlags.MODULE_EXPORT)&&s.set(o.CommonFlags.MODULE_EXPORT),s.hasDecorator(E.INLINE)&&!s.is(o.CommonFlags.READONLY)&&this.error(c.DiagnosticCode.Decorator_0_is_not_valid_here,assert(p.findDecorator(p.DecoratorKind.INLINE,i)).range,"inline")}else{if(a&&assert(!e.isAny(o.CommonFlags.ABSTRACT|o.CommonFlags.GET|o.CommonFlags.SET)),t.instanceMembers){if(t.instanceMembers.has(r))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else t.instanceMembers=new Map;var u=new D(t,r,n,e);i&&this.checkDecorators(i,E.NONE),t.instanceMembers.set(r,u)}},t.prototype.initializeMethod=function(e,t){var r=e.name.text,n=e.fileLevelInternalName,i=null,a=e.decorators,s=E.NONE;if(a&&(s=this.checkDecorators(a,E.OPERATOR_BINARY|E.OPERATOR_PREFIX|E.OPERATOR_POSTFIX|E.INLINE)),e.is(o.CommonFlags.STATIC)){if(assert(e.name.kind!=p.NodeKind.CONSTRUCTOR),this.elementsLookup.has(n))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,n);if(t.members){if(t.members.has(r))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else t.members=new Map;i=new R(this,r,n,e,t,s),t.members.set(r,i),this.elementsLookup.set(n,i),t.is(o.CommonFlags.MODULE_EXPORT)&&i.set(o.CommonFlags.MODULE_EXPORT)}else{if(t.instanceMembers){if(t.instanceMembers.has(r))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else t.instanceMembers=new Map;i=new R(this,r,n,e,t,s),e.name.kind==p.NodeKind.CONSTRUCTOR?t.constructorPrototype?this.error(c.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed,e.name.range):(i.set(o.CommonFlags.CONSTRUCTOR),t.constructorPrototype=i):t.instanceMembers.set(r,i),t.is(o.CommonFlags.MODULE_EXPORT)&&i.set(o.CommonFlags.MODULE_EXPORT)}this.checkOperatorOverloads(e.decorators,i,t)},t.prototype.checkOperatorOverloads=function(e,t,r){if(e)for(var n=0,i=e.length;n<i;++n){var a=e[n];switch(a.decoratorKind){case p.DecoratorKind.OPERATOR:case p.DecoratorKind.OPERATOR_BINARY:case p.DecoratorKind.OPERATOR_PREFIX:case p.DecoratorKind.OPERATOR_POSTFIX:var o=a.arguments&&a.arguments.length||0;if(1==o){var l=a.arguments[0];if(l.kind==p.NodeKind.LITERAL&&l.literalKind==p.LiteralKind.STRING){var u=g(a.decoratorKind,l.value);if(u==s.INVALID)this.error(c.DiagnosticCode.Operation_not_supported,l.range);else{var h=r.overloadPrototypes;h.has(u)?this.error(c.DiagnosticCode.Duplicate_function_implementation,l.range):(t.operatorKind=u,h.set(u,t))}}else this.error(c.DiagnosticCode.String_literal_expected,l.range)}else this.error(c.DiagnosticCode.Expected_0_arguments_but_got_1,a.range,"1",o.toString(0))}}},t.prototype.initializeAccessor=function(e,t){var r=e.name.text,n=e.fileLevelInternalName,i=this.elementsLookup.get(n),a=e.is(o.CommonFlags.GET),s=!1;if(i){if(i.kind!=y.PROPERTY||null!=(a?i.getterPrototype:i.setterPrototype))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else i=new U(this,r,n,t),s=!0;var l=e.decorators,p=E.NONE;l&&(p=this.checkDecorators(l,E.INLINE));var u=(a?o.GETTER_PREFIX:o.SETTER_PREFIX)+r;if(e.is(o.CommonFlags.STATIC)){var h=t.internalName+o.STATIC_DELIMITER+u;if(this.elementsLookup.has(h))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,h);var d=new R(this,u,h,e,null,p);if(a?i.getterPrototype=d:i.setterPrototype=d,s){if(t.members){if(t.members.has(r))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,h)}else t.members=new Map;t.members.set(r,i)}else assert(t.members&&t.members.has(r));this.elementsLookup.set(n,i),t.is(o.CommonFlags.MODULE_EXPORT)&&i.set(o.CommonFlags.MODULE_EXPORT)}else{var _=t.internalName+o.INSTANCE_DELIMITER+u;if(t.instanceMembers){if(t.instanceMembers.has(u))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else t.instanceMembers=new Map;var m=new R(this,u,_,e,t,p);a?i.getterPrototype=m:i.setterPrototype=m,t.instanceMembers.set(u,i),this.elementsLookup.set(n,i),t.is(o.CommonFlags.MODULE_EXPORT)&&(i.set(o.CommonFlags.MODULE_EXPORT),m.set(o.CommonFlags.MODULE_EXPORT))}},t.prototype.initializeEnum=function(e,t){void 0===t&&(t=null);var r=e.fileLevelInternalName;if(this.elementsLookup.has(r))this.error(c.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(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,r)}else t.members=new Map;t.members.set(n,i),t.is(o.CommonFlags.MODULE_EXPORT)&&i.is(o.CommonFlags.EXPORT)&&i.set(o.CommonFlags.MODULE_EXPORT)}else if(i.is(o.CommonFlags.EXPORT)){if(this.fileLevelExports.has(r))return void this.error(c.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,r);if(this.fileLevelExports.set(r,i),this.currentFilespace.members.set(n,i),e.range.source.isEntry){if(this.moduleLevelExports.has(n)){var a=this.moduleLevelExports.get(n);return void this.error(c.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,a.element.internalName)}i.set(o.CommonFlags.MODULE_EXPORT),this.moduleLevelExports.set(n,{element:i,identifier:e.name})}}for(var s=e.values,l=0,p=s.length;l<p;++l)this.initializeEnumValue(s[l],i);this.checkGlobal(i,e)}},t.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(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,n)}else t.members=new Map;var i=new O(t,this,r,n,e);t.members.set(r,i),t.is(o.CommonFlags.MODULE_EXPORT)&&i.set(o.CommonFlags.MODULE_EXPORT)},t.prototype.initializeExports=function(e,t){var r=e.members;if(r)for(var n=0,i=r.length;n<i;++n)this.initializeExport(r[n],e.internalPath,t);else this.error(c.DiagnosticCode.Operation_not_supported,e.range)},t.prototype.setExportAndCheckLibrary=function(e,t,r){this.fileLevelExports.set(e,t);var n=r.range.source.internalPath,i=o.FILESPACE_PREFIX+n,a=this.elementsLookup.get(i);a||(a=assert(this.elementsLookup.get(i+o.PATH_DELIMITER+"index"))),assert(a.kind==y.FILESPACE);var s=r.text;a.members.set(s,t);var l=r.range.source;l.isLibrary?this.elementsLookup.has(s)?this.error(c.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,r.range,s):(t.internalName=s,this.elementsLookup.set(s,t)):l.isEntry&&this.moduleLevelExports.set(r.text,{element:t,identifier:r})},t.prototype.initializeExport=function(e,t,r){var n,i,a,s=e.range.source.internalPath+o.PATH_DELIMITER+e.externalName.text;if(this.fileLevelExports.has(s))this.error(c.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.externalName.range,s);else if(null==t){if(n=e.range.source.internalPath+o.PATH_DELIMITER+e.name.text,this.elementsLookup.has(n))return void this.setExportAndCheckLibrary(s,this.elementsLookup.get(n),e.externalName);if(r.has(s))return void this.error(c.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.externalName.range,s);(a=new _).isReExport=!1,a.externalName=n,a.member=e,r.set(s,a)}else{if(n=t+o.PATH_DELIMITER+e.name.text,i=this.elementsLookup.get(n))return void this.setExportAndCheckLibrary(s,i,e.externalName);for(var l=new Set;a=r.get(n);){if(!a.isReExport){if(i=this.elementsLookup.get(a.externalName))return void this.setExportAndCheckLibrary(s,i,e.externalName);break}if(i=this.fileLevelExports.get(a.externalName))return void this.setExportAndCheckLibrary(s,i,e.externalName);if(n=a.externalName,l.has(a))break;l.add(a)}if(r.has(s))return void this.error(c.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.externalName.range,s);(a=new _).isReExport=!0,a.externalName=n,a.member=e,r.set(s,a)}},t.prototype.initializeFunction=function(e,t){void 0===t&&(t=null);var r=e.fileLevelInternalName;if(this.elementsLookup.has(r))this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);else{var n=e.name.text,i=e.decorators,a=new R(this,n,r,e,null,i?this.checkDecorators(i,E.GLOBAL|E.INLINE|E.EXTERNAL):E.NONE);if(a.parent=t,this.elementsLookup.set(r,a),t){if(t.members){if(t.members.has(n))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,r)}else t.members=new Map;t.members.set(n,a),t.is(o.CommonFlags.MODULE_EXPORT)&&a.is(o.CommonFlags.EXPORT)&&(a.parent=t,a.set(o.CommonFlags.MODULE_EXPORT))}else if(a.is(o.CommonFlags.EXPORT)){if(this.fileLevelExports.has(r))return void this.error(c.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,r);if(this.fileLevelExports.set(r,a),this.currentFilespace.members.set(n,a),e.range.source.isEntry){if(this.moduleLevelExports.has(n)){var s=this.moduleLevelExports.get(n);return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,s.element.internalName)}a.set(o.CommonFlags.MODULE_EXPORT),this.moduleLevelExports.set(n,{element:a,identifier:e.name})}}this.checkGlobal(a,e)}},t.prototype.initializeImports=function(e,t,r){var n=e.declarations;if(n)for(var i=0,a=n.length;i<a;++i)this.initializeImport(n[i],e.internalPath,t,r);else if(e.namespaceName){var s=e.namespaceName.text,l=e.range.source.internalPath+o.PATH_DELIMITER+s;if(this.elementsLookup.has(l))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.namespaceName.range,l);var p=this.elementsLookup.get(e.internalPath);if(p)return void this.elementsLookup.set(l,p);var u=new d;u.localName=l;var h=o.FILESPACE_PREFIX+e.internalPath;u.externalName=h,u.externalNameAlt=h+o.PATH_DELIMITER+"index",u.declaration=null,r.push(u)}},t.prototype.initializeImport=function(e,t,r,n){var i=e.fileLevelInternalName;if(this.elementsLookup.has(i))this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,i);else{var a,s=t+o.PATH_DELIMITER+e.externalName.text;if(a=this.fileLevelExports.get(s))this.elementsLookup.set(i,a);else{var l=o.PATH_DELIMITER+"index",p=new d;p.localName=i,t.endsWith(l)?(p.externalName=s,p.externalNameAlt=t.substring(0,t.length-l.length+1)+e.externalName.text):(p.externalName=s,p.externalNameAlt=t+l+o.PATH_DELIMITER+e.externalName.text),p.declaration=e,n.push(p)}}},t.prototype.initializeInterface=function(e,t){void 0===t&&(t=null);var r=e.fileLevelInternalName;if(this.elementsLookup.has(r))this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);else{var n=e.decorators,i=e.name.text,a=new M(this,i,r,e,n?this.checkDecorators(n,E.GLOBAL):E.NONE);if(a.parent=t,this.elementsLookup.set(r,a),t){if(t.members){if(t.members.has(a.internalName))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,r)}else t.members=new Map;t.members.set(a.internalName,a),t.is(o.CommonFlags.MODULE_EXPORT)&&a.is(o.CommonFlags.EXPORT)&&a.set(o.CommonFlags.MODULE_EXPORT)}else if(a.is(o.CommonFlags.EXPORT)){if(this.fileLevelExports.has(r))return void this.error(c.DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0,e.name.range,r);if(this.fileLevelExports.set(r,a),this.currentFilespace.members.set(i,a),e.range.source.isEntry){if(this.moduleLevelExports.has(i)){var s=this.moduleLevelExports.get(i);return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,s.element.internalName)}a.set(o.CommonFlags.MODULE_EXPORT),this.moduleLevelExports.set(i,{element:a,identifier:e.name})}}for(var l=e.members,u=0,h=l.length;u<h;++u){var d=l[u];switch(d.kind){case p.NodeKind.FIELDDECLARATION:this.initializeField(d,a);break;case p.NodeKind.METHODDECLARATION:d.isAny(o.CommonFlags.GET|o.CommonFlags.SET)?this.initializeAccessor(d,a):this.initializeMethod(d,a);break;default:throw new Error("interface member expected")}}this.checkGlobal(a,e)}},t.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 C(this,a,i,e)).parent=n,this.elementsLookup.set(i,s),this.checkGlobal(s,e)),n){if(n.members){if(n.members.has(a))return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,i)}else n.members=new Map;n.members.set(a,s),n.is(o.CommonFlags.MODULE_EXPORT)&&s.is(o.CommonFlags.EXPORT)&&s.set(o.CommonFlags.MODULE_EXPORT)}else if(s.is(o.CommonFlags.EXPORT)){var l=this.fileLevelExports.get(i);if(l?(l.is(o.CommonFlags.EXPORT)||this.error(c.DiagnosticCode.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local,e.name.range,s.internalName),s=l):this.fileLevelExports.set(i,s),this.currentFilespace.members.set(a,s),e.range.source.isEntry){if(this.moduleLevelExports.has(a)){var u=this.moduleLevelExports.get(a);if(u.element!==s)return void this.error(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,u.element.internalName)}else this.moduleLevelExports.set(a,{element:s,identifier:e.name});s.set(o.CommonFlags.MODULE_EXPORT)}}for(var h=e.members,d=0,_=h.length;d<_;++d)switch(h[d].kind){case p.NodeKind.CLASSDECLARATION:this.initializeClass(h[d],t,r,s);break;case p.NodeKind.ENUMDECLARATION:this.initializeEnum(h[d],s);break;case p.NodeKind.FUNCTIONDECLARATION:this.initializeFunction(h[d],s);break;case p.NodeKind.INTERFACEDECLARATION:this.initializeInterface(h[d],s);break;case p.NodeKind.NAMESPACEDECLARATION:this.initializeNamespace(h[d],t,r,s);break;case p.NodeKind.TYPEDECLARATION:this.error(c.DiagnosticCode.Operation_not_supported,h[d].range);break;case p.NodeKind.VARIABLE:this.initializeVariables(h[d],s);break;default:throw new Error("namespace member expected")}},t.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(c.DiagnosticCode.Duplicate_identifier_0,e.name.range,r);else{var n=new m;n.typeParameters=e.typeParameters,n.type=e.type,this.typeAliases.set(r,n)}},t.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,u=a.fileLevelInternalName;if(this.elementsLookup.has(u))this.error(c.DiagnosticCode.Duplicate_identifier_0,a.name.range,u);else{var h=a.name.text,d=new L(this,h,u,l.Type.void,a,s?this.checkDecorators(s,E.GLOBAL|E.INLINE|E.EXTERNAL):E.NONE);if(d.parent=t,this.elementsLookup.set(u,d),d.hasDecorator(E.INLINE)&&!d.is(o.CommonFlags.CONST)&&this.error(c.DiagnosticCode.Decorator_0_is_not_valid_here,assert(p.findDecorator(p.DecoratorKind.INLINE,s)).range,"inline"),t){if(t.members){if(t.members.has(h)){this.error(c.DiagnosticCode.Duplicate_identifier_0,a.name.range,u);continue}}else t.members=new Map;t.members.set(h,d),t.is(o.CommonFlags.MODULE_EXPORT)&&d.is(o.CommonFlags.EXPORT)&&d.set(o.CommonFlags.MODULE_EXPORT)}else if(d.is(o.CommonFlags.EXPORT)&&(this.fileLevelExports.has(u)?this.error(c.DiagnosticCode.Duplicate_identifier_0,a.name.range,u):this.fileLevelExports.set(u,d),this.currentFilespace.members.set(h,d),a.range.source.isEntry)){if(this.moduleLevelExports.has(h)){var _=this.moduleLevelExports.get(h);this.error(c.DiagnosticCode.Duplicate_identifier_0,a.name.range,_.element.internalName);continue}d.set(o.CommonFlags.MODULE_EXPORT),this.moduleLevelExports.set(h,{element:d,identifier:a.name})}this.checkGlobal(d,a)}}},t}(c.DiagnosticEmitter);function I(e){switch(e){case p.DecoratorKind.GLOBAL:return E.GLOBAL;case p.DecoratorKind.OPERATOR:case p.DecoratorKind.OPERATOR_BINARY:return E.OPERATOR_BINARY;case p.DecoratorKind.OPERATOR_PREFIX:return E.OPERATOR_PREFIX;case p.DecoratorKind.OPERATOR_POSTFIX:return E.OPERATOR_POSTFIX;case p.DecoratorKind.UNMANAGED:return E.UNMANAGED;case p.DecoratorKind.SEALED:return E.SEALED;case p.DecoratorKind.INLINE:return E.INLINE;case p.DecoratorKind.EXTERNAL:return E.EXTERNAL;case p.DecoratorKind.BUILTIN:return E.BUILTIN;default:return E.NONE}}t.Program=T,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",e[e.FILESPACE=15]="FILESPACE"}(y=t.ElementKind||(t.ElementKind={})),function(e){e[e.NONE=0]="NONE",e[e.GLOBAL=1]="GLOBAL",e[e.OPERATOR_BINARY=2]="OPERATOR_BINARY",e[e.OPERATOR_PREFIX=4]="OPERATOR_PREFIX",e[e.OPERATOR_POSTFIX=8]="OPERATOR_POSTFIX",e[e.UNMANAGED=16]="UNMANAGED",e[e.SEALED=32]="SEALED",e[e.INLINE=64]="INLINE",e[e.EXTERNAL=128]="EXTERNAL",e[e.BUILTIN=256]="BUILTIN"}(E=t.DecoratorFlags||(t.DecoratorFlags={})),t.decoratorKindToFlag=I;var v=function(){function e(e,t,r){this.flags=o.CommonFlags.NONE,this.decoratorFlags=E.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){var n=e.call(this,t,r.internalPath,o.FILESPACE_PREFIX+r.internalPath)||this;return n.kind=y.FILESPACE,n.members=new Map,n}return n(t,e),t}(v);t.Filespace=A;var C=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n)||this;return a.kind=y.NAMESPACE,a.declaration=i,a.flags=i.flags,a}return n(t,e),t}(v);t.Namespace=C;var N=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n)||this;return a.kind=y.ENUM,a.declaration=i,a.flags=i.flags,a}return n(t,e),t}(v);t.Enum=N;var O=function(e){function t(t,r,n,i,a){var s=e.call(this,r,n,i)||this;return s.kind=y.ENUMVALUE,s.constantValue=0,s.parent=t,s.declaration=a,s}return n(t,e),t}(v);t.EnumValue=O,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 n(t,e),t.prototype.withConstantIntegerValue=function(e){return this.constantValueKind=1,this.constantIntegerValue=e,this.set(o.CommonFlags.CONST|o.CommonFlags.INLINED),this},t.prototype.withConstantFloatValue=function(e){return this.constantValueKind=2,this.constantFloatValue=e,this.set(o.CommonFlags.CONST|o.CommonFlags.INLINED),this},t}(v);t.VariableLikeElement=S;var L=function(e){function t(t,r,n,i,a,s){var c=e.call(this,t,r,n,i,a)||this;return c.kind=y.GLOBAL,c.flags=a?a.flags:o.CommonFlags.NONE,c.decoratorFlags=s,c.type=i,c}return n(t,e),t}(S);t.Global=L;var b=function(){return function(e,t,r){void 0===r&&(r=null),this.name=e,this.type=t,this.initializer=r}}();t.Parameter=b;var k=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=y.LOCAL,s.scopedGlobal=null,s.index=n,s}return n(t,e),t}(S);t.Local=k;var R=function(e){function t(t,r,n,i,a,o){void 0===a&&(a=null),void 0===o&&(o=E.NONE);var c=e.call(this,t,r,n)||this;return c.kind=y.FUNCTION_PROTOTYPE,c.instances=new Map,c.classTypeArguments=null,c.operatorKind=s.INVALID,c.declaration=i,c.flags=i.flags,c.classPrototype=a,c.decoratorFlags=o,c}return n(t,e),t.prototype.toString=function(){return this.simpleName},t}(v);t.FunctionPrototype=R;var x=function(e){function t(t,r,n,s,c){var l,p;void 0===s&&(s=null),void 0===c&&(c=null);var u=e.call(this,t.program,t.simpleName,r)||this;if(u.kind=y.FUNCTION,u.localsByName=new Map,u.localsByIndex=[],u.additionalLocals=[],u.breakContext=null,u.debugLocations=[],u.ref=0,u.functionTableIndex=-1,u.trampoline=null,u.outerScope=null,u.nextBreakId=0,u.breakStack=null,u.nextInlineId=0,u.tempI32s=null,u.tempI64s=null,u.tempF32s=null,u.tempF64s=null,u.prototype=t,u.signature=n,u.parent=s,u.flags=t.flags,u.decoratorFlags=t.decoratorFlags,u.contextualTypeArguments=c,!t.is(o.CommonFlags.AMBIENT)){var h=0;if(s&&s.kind==y.CLASS){assert(u.is(o.CommonFlags.INSTANCE));var d=new k(t.program,"this",h++,assert(n.thisType));u.localsByName.set("this",d),u.localsByIndex[d.index]=d;var _=s.contextualTypeArguments;if(_){u.contextualTypeArguments||(u.contextualTypeArguments=new Map);try{for(var m=i(_),g=m.next();!g.done;g=m.next()){var E=a(g.value,2),f=E[0],T=E[1];u.contextualTypeArguments.has(f)||u.contextualTypeArguments.set(f,T)}}catch(e){l={error:e}}finally{try{g&&!g.done&&(p=m.return)&&p.call(m)}finally{if(l)throw l.error}}}}else assert(!u.is(o.CommonFlags.INSTANCE));for(var I=n.parameterTypes,v=0,A=I.length;v<A;++v){var C=I[v],N=n.getParameterName(v);d=new k(t.program,N,h++,C);u.localsByName.set(N,d),u.localsByIndex[d.index]=d}}return u.flow=K.create(u),u}return n(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(o.CommonFlags.INSTANCE)&&++n;var i=new k(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(void 0===t&&(t=!1),e.toNativeType()){case 1:r=this.tempI32s;break;case 2:r=this.tempI64s;break;case 3:r=this.tempF32s;break;case 4:r=this.tempF64s;break;default:throw new Error("concrete type expected")}return r&&r.length?((n=r.pop()).type=e,n.flags=o.CommonFlags.NONE):n=this.addLocal(e),e.is(36)&&this.flow.setLocalWrapped(n.index,t),n},t.prototype.freeTempLocal=function(e){if(!e.is(o.CommonFlags.INLINED)){var t;switch(assert(e.index>=0),assert(null!=e.type),e.type.toNativeType()){case 1:t=this.tempI32s||(this.tempI32s=[]);break;case 2:t=this.tempI64s||(this.tempI64s=[]);break;case 3:t=this.tempF32s||(this.tempF32s=[]);break;case 4: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 1:r=this.tempI32s||(this.tempI32s=[]);break;case 2:r=this.tempI64s||(this.tempI64s=[]);break;case 3:r=this.tempF32s||(this.tempF32s=[]);break;case 4: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)),e.is(36)&&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 F=function(e){function t(t,r){var n=e.call(this,t,"","")||this;n.kind=y.FUNCTION_TARGET;var i=r.toSignatureString();return n.simpleName=i,n.internalName=i,n.signature=r,n.type=l.Type.u32.asFunction(r),n}return n(t,e),t}(v);t.FunctionTarget=F;var D=function(e){function t(t,r,n,i){var a=e.call(this,t.program,r,n)||this;return a.kind=y.FIELD_PROTOTYPE,a.classPrototype=t,a.declaration=i,a.flags=i.flags,a}return n(t,e),t}(v);t.FieldPrototype=D;var B=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=y.FIELD,s.memoryOffset=-1,s.prototype=t,s.flags=t.flags,s.type=n,s.parent=a,s}return n(t,e),t}(S);t.Field=B;var U=function(e){function t(t,r,n,i){var a=e.call(this,t,r,n)||this;return a.kind=y.PROPERTY,a.getterPrototype=null,a.setterPrototype=null,a.parent=i,a}return n(t,e),t}(v);t.Property=U;var P=function(e){function t(t,r,n,i,a){var s=e.call(this,t,r,n)||this;return s.kind=y.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 n(t,e),t.prototype.toString=function(){return this.simpleName},t}(v);t.ClassPrototype=P;var w=function(e){function t(t,r,n,s,o){var c,l;void 0===s&&(s=null),void 0===o&&(o=null);var p=e.call(this,t.program,r,n)||this;if(p.kind=y.CLASS,p.contextualTypeArguments=null,p.currentMemoryOffset=0,p.constructorInstance=null,p.overloads=null,p.gcHookIndex=-1,p.prototype=t,p.flags=t.flags,p.decoratorFlags=t.decoratorFlags,p.typeArguments=s,p.type=t.program.options.usizeType.asClass(p),p.base=o,o){var u=o.contextualTypeArguments;if(u){p.contextualTypeArguments||(p.contextualTypeArguments=new Map);try{for(var h=i(u),d=h.next();!d.done;d=h.next()){var _=a(d.value,2),m=_[0],g=_[1];p.contextualTypeArguments.set(m,g)}}catch(e){c={error:e}}finally{try{d&&!d.done&&(l=h.return)&&l.call(h)}finally{if(c)throw c.error}}}}var E,f,T=p.prototype.declaration;if(T){var I=T.typeParameters;if(s){if((f=s.length)!=I.length)throw new Error("type argument count mismatch");if(f)for(p.contextualTypeArguments||(p.contextualTypeArguments=new Map),E=0;E<f;++E)p.contextualTypeArguments.set(I[E].name.text,s[E])}else if(I.length)throw new Error("type argument count mismatch")}return p}return n(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 s.INDEXED_GET:if(r=this.lookupOverload(s.UNCHECKED_INDEXED_GET))return r;break;case s.INDEXED_SET:var r;if(r=this.lookupOverload(s.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.offsetof=function(e){var t=assert(this.members);assert(t.has(e));var r=t.get(e);return assert(r.kind==y.FIELD),r.memoryOffset},t.prototype.toString=function(){return this.simpleName},t}(v);t.Class=w;var M=function(e){function t(t,r,n,i,a){var s=e.call(this,t,r,n,i,a)||this;return s.kind=y.INTERFACE_PROTOTYPE,s}return n(t,e),t}(P);t.InterfacePrototype=M;var G=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=y.INTERFACE,s}return n(t,e),t}(w);t.Interface=G,function(e){e[e.NONE=0]="NONE",e[e.RETURNS=1]="RETURNS",e[e.RETURNS_WRAPPED=2]="RETURNS_WRAPPED",e[e.THROWS=4]="THROWS",e[e.BREAKS=8]="BREAKS",e[e.CONTINUES=16]="CONTINUES",e[e.ALLOCATES=32]="ALLOCATES",e[e.CONDITIONALLY_RETURNS=64]="CONDITIONALLY_RETURNS",e[e.CONDITIONALLY_THROWS=128]="CONDITIONALLY_THROWS",e[e.CONDITIONALLY_BREAKS=256]="CONDITIONALLY_BREAKS",e[e.CONDITIONALLY_CONTINUES=512]="CONDITIONALLY_CONTINUES",e[e.CONDITIONALLY_ALLOCATES=1024]="CONDITIONALLY_ALLOCATES",e[e.INLINE_CONTEXT=2048]="INLINE_CONTEXT",e[e.UNCHECKED_CONTEXT=4096]="UNCHECKED_CONTEXT",e[e.ANY_TERMINATING=29]="ANY_TERMINATING",e[e.ANY_CATEGORICAL=63]="ANY_CATEGORICAL",e[e.ANY_CONDITIONAL=1984]="ANY_CONDITIONAL"}(t.FlowFlags||(t.FlowFlags={}));var K=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.fork=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.free=function(){var e,t,r=assert(this.parent);if(this.scopedLocals){try{for(var n=i(this.scopedLocals.values()),a=n.next();!a.done;a=n.next()){var s=a.value;s.is(o.CommonFlags.SCOPED)&&this.currentFunction.freeTempLocal(s)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.scopedLocals=null}return 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(c.DiagnosticCode.Duplicate_identifier_0,n.name.range):assert(!1),a}else this.scopedLocals=new Map;return i.set(o.CommonFlags.SCOPED),this.scopedLocals.set(t,i),e.is(36)&&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(c.DiagnosticCode.Duplicate_identifier_0,i.name.range):assert(!1),n}}else this.scopedLocals=new Map;assert(e<this.currentFunction.localsByIndex.length);var a=new k(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;for(n=(e-64)/64|0,i||(this.wrappedLocalsExt=i=new Array(n+1),i.length=0);i.length<=n;)i.push(i64_new(0));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|=2047&e.flags,this.wrappedLocals=e.wrappedLocals,this.wrappedLocalsExt=e.wrappedLocalsExt},e.prototype.inheritConditional=function(e){e.is(1)&&this.set(64),e.is(4)&&this.set(128),e.is(8)&&e.breakLabel==this.breakLabel&&this.set(256),e.is(16)&&e.continueLabel==this.continueLabel&&this.set(512),e.is(32)&&this.set(1024)},e.prototype.inheritMutual=function(e,t){this.flags|=e.flags&t.flags&63,this.flags|=1984&e.flags,this.flags|=1984&t.flags,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!=l.Type.void),!t.is(36))return!1;var r;switch(u.getExpressionId(e)){case u.ExpressionId.GetLocal:var n=this.currentFunction,i=n.localsByIndex[u.getGetLocalIndex(e)];return!n.flow.isLocalWrapped(i.index)||z(i.type,t);case u.ExpressionId.SetLocal:return assert(u.isTeeLocal(e)),this.canOverflow(u.getSetLocalValue(e),t);case u.ExpressionId.GetGlobal:var a=assert(this.currentFunction.program.elementsLookup.get(assert(u.getGetGlobalName(e))));return assert(a.kind==y.GLOBAL),z(assert(a.type),t);case u.ExpressionId.Binary:switch(u.getBinaryOp(e)){case u.BinaryOp.EqI32:case u.BinaryOp.EqI64:case u.BinaryOp.EqF32:case u.BinaryOp.EqF64:case u.BinaryOp.NeI32:case u.BinaryOp.NeI64:case u.BinaryOp.NeF32:case u.BinaryOp.NeF64:case u.BinaryOp.LtI32:case u.BinaryOp.LtU32:case u.BinaryOp.LtI64:case u.BinaryOp.LtU64:case u.BinaryOp.LtF32:case u.BinaryOp.LtF64:case u.BinaryOp.LeI32:case u.BinaryOp.LeU32:case u.BinaryOp.LeI64:case u.BinaryOp.LeU64:case u.BinaryOp.LeF32:case u.BinaryOp.LeF64:case u.BinaryOp.GtI32:case u.BinaryOp.GtU32:case u.BinaryOp.GtI64:case u.BinaryOp.GtU64:case u.BinaryOp.GtF32:case u.BinaryOp.GtF64:case u.BinaryOp.GeI32:case u.BinaryOp.GeU32:case u.BinaryOp.GeI64:case u.BinaryOp.GeU64:case u.BinaryOp.GeF32:case u.BinaryOp.GeF64:return!1;case u.BinaryOp.MulI32:return!(u.getExpressionId(r=u.getBinaryLeft(e))==u.ExpressionId.Const&&(0==u.getConstValueI32(r)||1==u.getConstValueI32(r)&&!this.canOverflow(u.getBinaryRight(e),t))||u.getExpressionId(r=u.getBinaryRight(e))==u.ExpressionId.Const&&(0==u.getConstValueI32(r)||1==u.getConstValueI32(r)&&!this.canOverflow(u.getBinaryLeft(e),t)));case u.BinaryOp.AndI32:return!(u.getExpressionId(r=u.getBinaryLeft(e))==u.ExpressionId.Const&&u.getConstValueI32(r)<=t.computeSmallIntegerMask(l.Type.i32)||!this.canOverflow(r,t)||u.getExpressionId(r=u.getBinaryRight(e))==u.ExpressionId.Const&&u.getConstValueI32(r)<=t.computeSmallIntegerMask(l.Type.i32)||!this.canOverflow(r,t));case u.BinaryOp.ShlI32:var s=32-t.size;return u.getExpressionId(r=u.getBinaryRight(e))!=u.ExpressionId.Const||u.getConstValueI32(r)<s;case u.BinaryOp.ShrI32:s=32-t.size;return this.canOverflow(u.getBinaryLeft(e),t)&&(u.getExpressionId(r=u.getBinaryRight(e))!=u.ExpressionId.Const||u.getConstValueI32(r)<s);case u.BinaryOp.ShrU32:s=32-t.size;return t.is(1)?!(u.getExpressionId(r=u.getBinaryRight(e))==u.ExpressionId.Const&&u.getConstValueI32(r)>s):this.canOverflow(u.getBinaryLeft(e),t)&&!(u.getExpressionId(r=u.getBinaryRight(e))==u.ExpressionId.Const&&u.getConstValueI32(r)>=s);case u.BinaryOp.DivU32:case u.BinaryOp.RemI32:case u.BinaryOp.RemU32:return this.canOverflow(u.getBinaryLeft(e),t)||this.canOverflow(u.getBinaryRight(e),t)}break;case u.ExpressionId.Unary:switch(u.getUnaryOp(e)){case u.UnaryOp.EqzI32:case u.UnaryOp.EqzI64:return!1;case u.UnaryOp.ClzI32:case u.UnaryOp.CtzI32:case u.UnaryOp.PopcntI32:return t.size<7}break;case u.ExpressionId.Const:var o=0;switch(u.getExpressionType(e)){case 1:o=u.getConstValueI32(e);break;case 2:o=u.getConstValueI64Low(e);break;case 3:o=i32(u.getConstValueF32(e));break;case 4:o=i32(u.getConstValueF64(e));break;default:assert(!1)}switch(t.kind){case 0:return o<i8.MIN_VALUE||o>i8.MAX_VALUE;case 1:return o<i16.MIN_VALUE||o>i16.MAX_VALUE;case 5:return o<0||o>u8.MAX_VALUE;case 6:return o<0||o>u16.MAX_VALUE;case 10:return 0!=(-2&o)}break;case u.ExpressionId.Load:var c=void 0;switch(u.getLoadBytes(e)){case 1:c=u.isLoadSigned(e)?l.Type.i8:l.Type.u8;break;case 2:c=u.isLoadSigned(e)?l.Type.i16:l.Type.u16;break;default:c=u.isLoadSigned(e)?l.Type.i32:l.Type.u32}return z(c,t);case u.ExpressionId.Block:if(!u.getBlockName(e)){var p=assert(u.getBlockChildCount(e)),h=u.getBlockChild(e,p-1);return this.canOverflow(h,t)}break;case u.ExpressionId.If:return this.canOverflow(u.getIfTrue(e),t)||this.canOverflow(assert(u.getIfFalse(e)),t);case u.ExpressionId.Select:return this.canOverflow(u.getSelectThen(e),t)||this.canOverflow(u.getSelectElse(e),t);case u.ExpressionId.Call:var d=this.currentFunction.program,_=assert(d.instancesLookup.get(assert(u.getCallTarget(e))));assert(_.kind==y.FUNCTION);var m=_.signature.returnType;return!_.flow.is(2)||z(m,t);case u.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 z(e,t){return!e.is(4)||e.size>t.size||e.is(1)!=t.is(1)}t.Flow=K},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(9);!function(e){e[e.None=0]="None",e[e.I32=1]="I32",e[e.I64=2]="I64",e[e.F32=3]="F32",e[e.F64=4]="F64",e[e.Unreachable=5]="Unreachable",e[e.Auto=-1]="Auto"}(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.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"}(n=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.CurrentMemory=_BinaryenCurrentMemory()]="CurrentMemory",e[e.GrowMemory=_BinaryenGrowMemory()]="GrowMemory"}(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 a=function(){function e(){}return e.create=function(t,r){var n=new e;return n.buffer=t,n.offset=r,n},e}();t.MemorySegment=a;var s=function(){function e(){this.cachedTemporaryName=0,this.hasTemporaryFunction=!1,this.cachedPrecomputeName=0,this.cachedPrecomputeNames=0}return e.create=function(){var t=new e;return t.ref=_BinaryenModuleCreate(),t.cachedByValue=memory.allocate(16),t},e.createFrom=function(t){var r=c(t);try{var n=new e;return n.ref=_BinaryenModuleRead(r,t.length),n.cachedByValue=memory.allocate(24),n}finally{memory.free(changetype(r))}},e.prototype.addFunctionType=function(e,t,r){var n=u(e),i=l(r);try{return _BinaryenAddFunctionType(this.ref,n,t,i,r?r.length:0)}finally{memory.free(i),memory.free(n)}},e.prototype.getFunctionTypeBySignature=function(e,t){var r=l(t);try{return _BinaryenGetFunctionTypeBySignature(this.ref,e,r,t?t.length:0)}finally{memory.free(r)}},e.prototype.removeFunctionType=function(e){var t=u(e);try{_BinaryenRemoveFunctionType(this.ref,t)}finally{memory.free(t)}},e.prototype.createI32=function(e){var t=this.cachedByValue;return _BinaryenLiteralInt32(t,e),_BinaryenConst(this.ref,t)},e.prototype.createI64=function(e,t){void 0===t&&(t=0);var r=this.cachedByValue;return _BinaryenLiteralInt64(r,e,t),_BinaryenConst(this.ref,r)},e.prototype.createF32=function(e){var t=this.cachedByValue;return _BinaryenLiteralFloat32(t,e),_BinaryenConst(this.ref,t)},e.prototype.createF64=function(e){var t=this.cachedByValue;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=u(t),i=p(r);try{return _BinaryenHost(this.ref,e,n,i,r?r.length:0)}finally{memory.free(i),memory.free(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=u(e);try{return _BinaryenGetGlobal(this.ref,r,t)}finally{memory.free(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=u(e);try{return _BinaryenSetGlobal(this.ref,r,t)}finally{memory.free(r)}},e.prototype.createBlock=function(e,t,r){void 0===r&&(r=0);var n=u(e),i=p(t);try{return _BinaryenBlock(this.ref,n,i,t.length,r)}finally{memory.free(i),memory.free(n)}},e.prototype.createBreak=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=u(e);try{return _BinaryenBreak(this.ref,n,t,r)}finally{memory.free(n)}},e.prototype.createDrop=function(e){return _BinaryenDrop(this.ref,e)},e.prototype.createLoop=function(e,t){var r=u(e);try{return _BinaryenLoop(this.ref,r,t)}finally{memory.free(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]=u(e[s]);var o=l(a),c=u(t);try{return _BinaryenSwitch(this.ref,o,i,c,r,n)}finally{memory.free(c),memory.free(o);for(s=i-1;s>=0;--s)memory.free(a[s])}},e.prototype.createCall=function(e,t,r){var n=u(e),i=p(t);try{return _BinaryenCall(this.ref,n,i,t&&t.length||0,r)}finally{memory.free(i),memory.free(n)}},e.prototype.createCallIndirect=function(e,t,r){var n=p(t),i=u(r);try{return _BinaryenCallIndirect(this.ref,e,n,t&&t.length||0,i)}finally{memory.free(i),memory.free(n)}},e.prototype.createUnreachable=function(){return _BinaryenUnreachable(this.ref)},e.prototype.addGlobal=function(e,t,r,n){var i=u(e);try{return _BinaryenAddGlobal(this.ref,i,t,r?1:0,n)}finally{memory.free(i)}},e.prototype.removeGlobal=function(e){var t=u(e);try{_BinaryenRemoveGlobal(this.ref,t)}finally{memory.free(t)}},e.prototype.addFunction=function(e,t,r,n){var i=u(e),a=l(r);try{return _BinaryenAddFunction(this.ref,i,t,a,r?r.length:0,n)}finally{memory.free(a),memory.free(i)}},e.prototype.removeFunction=function(e){var t=u(e);try{_BinaryenRemoveFunction(this.ref,t)}finally{memory.free(t)}},e.prototype.addTemporaryFunction=function(e,t,r){this.hasTemporaryFunction=assert(!this.hasTemporaryFunction);var n=this.cachedTemporaryName;n||(this.cachedTemporaryName=n=u(""));var i=l(t);try{var a=_BinaryenAddFunctionType(this.ref,n,e,i,t?t.length:0);return _BinaryenAddFunction(this.ref,n,a,0,0,r)}finally{memory.free(i)}},e.prototype.removeTemporaryFunction=function(){this.hasTemporaryFunction=!assert(this.hasTemporaryFunction);var e=assert(this.cachedTemporaryName);_BinaryenRemoveFunction(this.ref,e),_BinaryenRemoveFunctionType(this.ref,e)},e.prototype.addFunctionExport=function(e,t){var r=u(e),n=u(t);try{return _BinaryenAddFunctionExport(this.ref,r,n)}finally{memory.free(n),memory.free(r)}},e.prototype.addTableExport=function(e,t){var r=u(e),n=u(t);try{return _BinaryenAddTableExport(this.ref,r,n)}finally{memory.free(n),memory.free(r)}},e.prototype.addMemoryExport=function(e,t){var r=u(e),n=u(t);try{return _BinaryenAddMemoryExport(this.ref,r,n)}finally{memory.free(n),memory.free(r)}},e.prototype.addGlobalExport=function(e,t){var r=u(e),n=u(t);try{return _BinaryenAddGlobalExport(this.ref,r,n)}finally{memory.free(n),memory.free(r)}},e.prototype.removeExport=function(e){var t=u(e);try{_BinaryenRemoveExport(this.ref,t)}finally{memory.free(t)}},e.prototype.addFunctionImport=function(e,t,r,n){var i=u(e),a=u(t),s=u(r);try{return _BinaryenAddFunctionImport(this.ref,i,a,s,n)}finally{memory.free(s),memory.free(a),memory.free(i)}},e.prototype.addTableImport=function(e,t,r){var n=u(e),i=u(t),a=u(r);try{return _BinaryenAddTableImport(this.ref,n,i,a)}finally{memory.free(a),memory.free(i),memory.free(n)}},e.prototype.addMemoryImport=function(e,t,r){var n=u(e),i=u(t),a=u(r);try{return _BinaryenAddMemoryImport(this.ref,n,i,a)}finally{memory.free(a),memory.free(i),memory.free(n)}},e.prototype.addGlobalImport=function(e,t,r,n){var i=u(e),a=u(t),s=u(r);try{return _BinaryenAddGlobalImport(this.ref,i,a,s,n)}finally{memory.free(s),memory.free(a),memory.free(i)}},e.prototype.setMemory=function(e,t,r,n,a){void 0===a&&(a=null);for(var s=u(a),o=r.length,p=new Array(o),h=new Array(o),d=new Array(o),_=0;_<o;++_){var m=r[_].buffer,g=r[_].offset;p[_]=c(m),h[_]=n==i.Target.WASM64?this.createI64(i64_low(g),i64_high(g)):this.createI32(i64_low(g)),d[_]=m.length}var y=l(p),E=l(h),f=l(d);try{_BinaryenSetMemory(this.ref,e,t,s,y,E,f,o)}finally{memory.free(f),memory.free(E),memory.free(y);for(_=o-1;_>=0;--_)memory.free(p[_]);memory.free(s)}},e.prototype.setFunctionTable=function(e,t,r){for(var n=r.length,i=new Array(n),a=0;a<n;++a)i[a]=u(r[a]);var s=l(i);try{_BinaryenSetFunctionTable(this.ref,e,t,s,n)}finally{memory.free(s);for(a=n;a>=0;--a)memory.free(i[a])}},e.prototype.setStart=function(e){_BinaryenSetStart(this.ref,e)},e.prototype.getOptimizeLevel=function(){return _BinaryenGetOptimizeLevel()},e.prototype.setOptimizeLevel=function(e){void 0===e&&(e=2),_BinaryenSetOptimizeLevel(e)},e.prototype.getShrinkLevel=function(){return _BinaryenGetShrinkLevel()},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]=u(e[i]);var a=l(n);try{t?_BinaryenFunctionRunPasses(t,this.ref,a,r):_BinaryenModuleRunPasses(this.ref,a,r)}finally{memory.free(a);for(i=r;i>=0;--i)memory.free(n[i])}},e.prototype.precomputeExpression=function(e){var t=_BinaryenGetOptimizeLevel(),r=_BinaryenGetShrinkLevel(),n=_BinaryenGetDebugInfo();_BinaryenSetOptimizeLevel(4),_BinaryenSetShrinkLevel(0),_BinaryenSetDebugInfo(!1);var i=_BinaryenExpressionGetType(e),a=this.addTemporaryFunction(i,null,e),s=this.cachedPrecomputeNames;if(!s){var o=u("precompute");this.cachedPrecomputeName=o,this.cachedPrecomputeNames=s=l([o])}return _BinaryenFunctionRunPasses(a,this.ref,s,1),e=_BinaryenFunctionGetBody(a),this.removeTemporaryFunction(),_BinaryenSetOptimizeLevel(t),_BinaryenSetShrinkLevel(r),_BinaryenSetDebugInfo(n),e},e.prototype.validate=function(){return 1==_BinaryenModuleValidate(this.ref)},e.prototype.interpret=function(){_BinaryenModuleInterpret(this.ref)},e.prototype.toBinary=function(e){var t=this.cachedByValue,r=u(e),n=0,i=0;try{_BinaryenModuleAllocateAndWrite(t,this.ref,r),n=h(t);var a=h(t+4);i=h(t+8);var s=new _;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=d(i),s}finally{r&&memory.free(r),n&&memory.free(n),i&&memory.free(i)}},e.prototype.toText=function(){throw new Error("not implemented")},e.prototype.toAsmjs=function(){throw new Error("not implemented")},e.prototype.dispose=function(){assert(this.ref),memory.free(this.cachedByValue),memory.free(this.cachedTemporaryName),memory.free(this.cachedPrecomputeName),memory.free(this.cachedPrecomputeNames),_BinaryenModuleDispose(this.ref),this.ref=0},e.prototype.createRelooper=function(){return o.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 i,a;switch(r-=1,_BinaryenExpressionGetId(e)){case n.Const:switch(_BinaryenExpressionGetType(e)){case 1:return this.createI32(_BinaryenConstGetValueI32(e));case 2:return this.createI64(_BinaryenConstGetValueI64Low(e),_BinaryenConstGetValueI64High(e));case 3:return this.createF32(_BinaryenConstGetValueF32(e));case 4:return this.createF64(_BinaryenConstGetValueF64(e));default:throw new Error("concrete type expected")}case n.GetLocal:return _BinaryenGetLocal(this.ref,_BinaryenGetLocalGetIndex(e),_BinaryenExpressionGetType(e));case n.GetGlobal:var s=_BinaryenGetGlobalGetName(e);if(!s)break;return _BinaryenGetGlobal(this.ref,s,_BinaryenExpressionGetType(e));case n.Load:if(!(i=this.cloneExpression(_BinaryenLoadGetPtr(e),t,r)))break;return _BinaryenLoadIsAtomic(e)?_BinaryenAtomicLoad(this.ref,_BinaryenLoadGetBytes(e),_BinaryenLoadGetOffset(e),_BinaryenExpressionGetType(e),i):_BinaryenLoad(this.ref,_BinaryenLoadGetBytes(e),_BinaryenLoadIsSigned(e)?1:0,_BinaryenLoadGetOffset(e),_BinaryenLoadGetAlign(e),_BinaryenExpressionGetType(e),i);case n.Unary:if(!(i=this.cloneExpression(_BinaryenUnaryGetValue(e),t,r)))break;return _BinaryenUnary(this.ref,_BinaryenUnaryGetOp(e),i);case n.Binary:if(!(i=this.cloneExpression(_BinaryenBinaryGetLeft(e),t,r)))break;if(!(a=this.cloneExpression(_BinaryenBinaryGetRight(e),t,r)))break;return _BinaryenBinary(this.ref,_BinaryenBinaryGetOp(e),i,a)}return 0},e.prototype.addDebugInfoFile=function(e){var t=u(e);try{return _BinaryenModuleAddDebugInfoFileName(this.ref,t)}finally{memory.free(t)}},e.prototype.getDebugInfoFile=function(e){return d(_BinaryenModuleGetDebugInfoFileName(this.ref,e))},e.prototype.setDebugLocation=function(e,t,r,n,i){_BinaryenFunctionSetDebugLocation(e,t,r,n,i)},e.UNLIMITED_MEMORY=-1,e}();t.Module=s,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.getGetGlobalName=function(e){return d(_BinaryenGetGlobalGetName(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 d(_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 d(_BinaryenLoopGetName(e))},t.getLoopBody=function(e){return _BinaryenLoopGetBody(e)},t.getBreakName=function(e){return d(_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 d(_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 d(_BinaryenHostGetNameOperand(e))},t.getFunctionBody=function(e){return _BinaryenFunctionGetBody(e)},t.getFunctionName=function(e){return d(_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 o=function(){function e(){}return e.create=function(t){var r=new e;return r.module=t,r.ref=_RelooperCreate(t.ref),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{memory.free(i)}},e.prototype.renderAndDispose=function(e,t){return _RelooperRenderAndDispose(this.ref,e,t)},e}();function c(e){if(!e)return 0;for(var t=e.length,r=memory.allocate(t),n=r,i=0;i<t;++i)store(n++,e[i]);return r}function l(e){if(!e)return 0;for(var t=memory.allocate(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 p(e){return l(e)}function u(e){if(null==e)return 0;for(var t=memory.allocate(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 h(e){return load(e)|load(e+1)<<8|load(e+2)<<16|load(e+3)<<24}function d(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=o,t.readString=d;var _=function(){return function(){}}();t.BinaryModule=_,t.needsExplicitUnreachable=function e(t){switch(_BinaryenExpressionGetType(t)){case 1:case 2:case 3:case 4:return!1}switch(_BinaryenExpressionGetId(t)){case n.Unreachable:case n.Return:return!1;case n.Break:return 0!=_BinaryenBreakGetCondition(t);case n.Block:if(!_BinaryenBlockGetName(t)){var r=_BinaryenBlockGetNumChildren(t);return r>0&&e(_BinaryenBlockGetChild(t,r-1))}}return!0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4);!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:return e.i8;case 1:return e.i16;case 11:case 2:return e.i32;case 12:case 3:return e.i64;case 4:return 64==this.size?e.isize64:e.isize32;case 5:return e.u8;case 6:return e.u16;case 7:return e.u32;case 8:return e.u64;case 9:return 64==this.size?e.usize64:e.usize32;case 10:default:return e.i32}},enumerable:!0,configurable:!0}),e.prototype.isManaged=function(e){if(e.hasGC){var t=this.classReference;return null!==t&&!t.hasDecorator(n.DecoratorFlags.UNMANAGED)}return!1},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.nonNullableType=this,this.cachedNullableType.classReference=this.classReference,this.cachedNullableType.signatureReference=this.signatureReference),this.cachedNullableType},e.prototype.isAssignableTo=function(t,r){var n,i,a,s;if(void 0===r&&(r=!1),this.is(256)){if(t.is(256)&&(!this.is(512)||t.is(512)))if(n=this.classReference){if(i=t.classReference)return n.isAssignableTo(i)}else if((a=this.signatureReference)&&(s=t.signatureReference))return a.isAssignableTo(s)}else if(!t.is(256))if(this.is(4))if(t.is(4)){if(!r||this==e.bool||this.is(1)==t.is(1))return this.size<=t.size}else{if(11==t.kind)return this.size<=23;if(12==t.kind)return this.size<=52}else if(this.is(8)&&t.is(8))return this.size<=t.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){if(void 0===e&&(e=!1),!e&&this.is(256)){var t=this.classReference;if(t)return this.is(512)?t.toString()+" | null":t.toString();var r=this.signatureReference;if(r)return this.is(512)?"("+r.toString(!0)+") | null":r.toString(!0);assert(!1)}switch(this.kind){case 0:return"i8";case 1:return"i16";case 2:return"i32";case 3:return"i64";case 4:return"isize";case 5:return"u8";case 6:return"u16";case 7:return"u32";case 8:return"u64";case 9:return"usize";case 10:return"bool";case 11:return"f32";case 12:return"f64";default:assert(!1);case 13:return"void"}},e.prototype.toNativeType=function(){switch(this.kind){default:return 1;case 3:case 8:return 2;case 4:case 9:return 64==this.size?2:1;case 11:return 3;case 12:return 4;case 13:return 0}},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 l=this.returnType,p=e.returnType;return l==p||l.isAssignableTo(p)},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,l=this.requiredParameters,p=this.hasRest?a-1:-1,u=0;u<a;++u,++r)r&&t.push(", "),u==p&&t.push("..."),u<c?t.push(s[u]):t.push(o(u)),u>=l&&u!=p?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){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=this&&this.__extends||function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var i,a,s=r(1),o=r(3),c=r(2);function l(e){switch(assert(e.length),e.charCodeAt(0)){case 97:switch(e){case"abstract":return i.ABSTRACT;case"as":return i.AS;case"async":return i.ASYNC;case"await":return i.AWAIT}break;case 98:switch(e){case"break":return i.BREAK}break;case 99:switch(e){case"case":return i.CASE;case"catch":return i.CATCH;case"class":return i.CLASS;case"continue":return i.CONTINUE;case"const":return i.CONST;case"constructor":return i.CONSTRUCTOR}break;case 100:switch(e){case"debugger":return i.DEBUGGER;case"declare":return i.DECLARE;case"default":return i.DEFAULT;case"delete":return i.DELETE;case"do":return i.DO}break;case 101:switch(e){case"else":return i.ELSE;case"enum":return i.ENUM;case"export":return i.EXPORT;case"extends":return i.EXTENDS}break;case 102:switch(e){case"false":return i.FALSE;case"finally":return i.FINALLY;case"for":return i.FOR;case"from":return i.FROM;case"function":return i.FUNCTION}break;case 103:switch(e){case"get":return i.GET}break;case 105:switch(e){case"if":return i.IF;case"implements":return i.IMPLEMENTS;case"import":return i.IMPORT;case"in":return i.IN;case"instanceof":return i.INSTANCEOF;case"interface":return i.INTERFACE;case"is":return i.IS}break;case 107:switch(e){case"keyof":return i.KEYOF}break;case 108:switch(e){case"let":return i.LET}break;case 109:switch(e){case"module":return i.MODULE}break;case 110:switch(e){case"namespace":return i.NAMESPACE;case"new":return i.NEW;case"null":return i.NULL}break;case 111:switch(e){case"of":return i.OF}break;case 112:switch(e){case"package":return i.PACKAGE;case"private":return i.PRIVATE;case"protected":return i.PROTECTED;case"public":return i.PUBLIC}break;case 114:switch(e){case"readonly":return i.READONLY;case"return":return i.RETURN}break;case 115:switch(e){case"set":return i.SET;case"static":return i.STATIC;case"super":return i.SUPER;case"switch":return i.SWITCH}break;case 116:switch(e){case"this":return i.THIS;case"throw":return i.THROW;case"true":return i.TRUE;case"try":return i.TRY;case"type":return i.TYPE;case"typeof":return i.TYPEOF}break;case 118:switch(e){case"var":return i.VAR;case"void":return i.VOID}break;case 119:switch(e){case"while":return i.WHILE;case"with":return i.WITH}break;case 121:switch(e){case"yield":return i.YIELD}}return i.INVALID}function p(e){switch(e){case i.ABSTRACT:case i.AS:case i.CONSTRUCTOR:case i.DECLARE:case i.DELETE:case i.FROM:case i.FOR:case i.GET:case i.IS:case i.KEYOF:case i.MODULE:case i.NAMESPACE:case i.READONLY:case i.SET:case i.TYPE:case i.VOID: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"}(i=t.Token||(t.Token={})),function(e){e[e.DEFAULT=0]="DEFAULT",e[e.PREFER=1]="PREFER",e[e.ALWAYS=2]="ALWAYS"}(a=t.IdentifierHandling||(t.IdentifierHandling={})),t.tokenFromKeyword=l,t.tokenIsAlsoIdentifier=p,t.operatorTokenToString=function(e){switch(e){case i.DELETE:return"delete";case i.IN:return"in";case i.INSTANCEOF:return"instanceof";case i.NEW:return"new";case i.TYPEOF:return"typeof";case i.VOID:return"void";case i.YIELD:return"yield";case i.DOT_DOT_DOT:return"...";case i.COMMA:return",";case i.LESSTHAN:return"<";case i.GREATERTHAN:return">";case i.LESSTHAN_EQUALS:return"<=";case i.GREATERTHAN_EQUALS:return">=";case i.EQUALS_EQUALS:return"==";case i.EXCLAMATION_EQUALS:return"!=";case i.EQUALS_EQUALS_EQUALS:return"===";case i.EXCLAMATION_EQUALS_EQUALS:return"!==";case i.PLUS:return"+";case i.MINUS:return"-";case i.ASTERISK_ASTERISK:return"**";case i.ASTERISK:return"*";case i.SLASH:return"/";case i.PERCENT:return"%";case i.PLUS_PLUS:return"++";case i.MINUS_MINUS:return"--";case i.LESSTHAN_LESSTHAN:return"<<";case i.GREATERTHAN_GREATERTHAN:return">>";case i.GREATERTHAN_GREATERTHAN_GREATERTHAN:return">>>";case i.AMPERSAND:return"&";case i.BAR:return"|";case i.CARET:return"^";case i.EXCLAMATION:return"!";case i.TILDE:return"~";case i.AMPERSAND_AMPERSAND:return"&&";case i.BAR_BAR:return"||";case i.EQUALS:return"=";case i.PLUS_EQUALS:return"+=";case i.MINUS_EQUALS:return"-=";case i.ASTERISK_EQUALS:return"*=";case i.ASTERISK_ASTERISK_EQUALS:return"**=";case i.SLASH_EQUALS:return"/=";case i.PERCENT_EQUALS:return"%=";case i.LESSTHAN_LESSTHAN_EQUALS:return"<<=";case i.GREATERTHAN_GREATERTHAN_EQUALS:return">>=";case i.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS:return">>>=";case i.AMPERSAND_EQUALS:return"&=";case i.BAR_EQUALS:return"|=";case i.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 n(t,e),t.prototype.next=function(e){return void 0===e&&(e=a.DEFAULT),this.nextToken=-1,this.token=this.unsafeNext(e)},t.prototype.unsafeNext=function(e,t){void 0===e&&(e=a.DEFAULT),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:if(!(++this.pos<this.end&&10==r.charCodeAt(this.pos)))break;case 10:case 9:case 11:case 12:case 32:++this.pos;break;case 33:return++this.pos,t>1&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,t>2&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.EXCLAMATION_EQUALS_EQUALS):i.EXCLAMATION_EQUALS):i.EXCLAMATION;case 34:case 39:case 96:return i.STRINGLITERAL;case 37:return++this.pos,t>1&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.PERCENT_EQUALS):i.PERCENT;case 38:if(++this.pos,t>1&&this.pos<this.end){if(38==r.charCodeAt(this.pos))return++this.pos,i.AMPERSAND_AMPERSAND;if(61==r.charCodeAt(this.pos))return++this.pos,i.AMPERSAND_EQUALS}return i.AMPERSAND;case 40:return++this.pos,i.OPENPAREN;case 41:return++this.pos,i.CLOSEPAREN;case 42:if(++this.pos,t>1&&this.pos<this.end){if(61==r.charCodeAt(this.pos))return++this.pos,i.ASTERISK_EQUALS;if(42==r.charCodeAt(this.pos))return++this.pos,t>2&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.ASTERISK_ASTERISK_EQUALS):i.ASTERISK_ASTERISK}return i.ASTERISK;case 43:if(++this.pos,t>1&&this.pos<this.end){if(43==r.charCodeAt(this.pos))return++this.pos,i.PLUS_PLUS;if(61==r.charCodeAt(this.pos))return++this.pos,i.PLUS_EQUALS}return i.PLUS;case 44:return++this.pos,i.COMMA;case 45:if(++this.pos,t>1&&this.pos<this.end){if(45==r.charCodeAt(this.pos))return++this.pos,i.MINUS_MINUS;if(61==r.charCodeAt(this.pos))return++this.pos,i.MINUS_EQUALS}return i.MINUS;case 46:if(++this.pos,t>1&&this.pos<this.end){if(c.isDecimalDigit(r.charCodeAt(this.pos)))return--this.pos,i.FLOATLITERAL;if(t>2&&this.pos+1<this.end&&46==r.charCodeAt(this.pos)&&46==r.charCodeAt(this.pos+1))return this.pos+=2,i.DOT_DOT_DOT}return i.DOT;case 47:var u=this.pos;if(++this.pos,t>1&&this.pos<this.end){if(47==r.charCodeAt(this.pos)){var h=o.CommentKind.LINE;for(this.pos+1<this.end&&47==r.charCodeAt(this.pos+1)&&(++this.pos,h=o.CommentKind.TRIPLE);++this.pos<this.end;)if(10==r.charCodeAt(this.pos)){++this.pos;break}this.onComment&&this.onComment(h,r.substring(u,this.pos),this.range(u,this.pos));break}if(42==r.charCodeAt(this.pos)){for(var d=!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,d=!0;break}d?this.onComment&&this.onComment(o.CommentKind.BLOCK,r.substring(u,this.pos),this.range(u,this.pos)):this.error(s.DiagnosticCode._0_expected,this.range(this.pos),"*/");break}if(61==r.charCodeAt(this.pos))return++this.pos,i.SLASH_EQUALS}return i.SLASH;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.testInteger()?i.INTEGERLITERAL:i.FLOATLITERAL;case 58:return++this.pos,i.COLON;case 59:return++this.pos,i.SEMICOLON;case 60:if(++this.pos,t>1&&this.pos<this.end){if(60==r.charCodeAt(this.pos))return++this.pos,t>2&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.LESSTHAN_LESSTHAN_EQUALS):i.LESSTHAN_LESSTHAN;if(61==r.charCodeAt(this.pos))return++this.pos,i.LESSTHAN_EQUALS}return i.LESSTHAN;case 61:if(++this.pos,t>1&&this.pos<this.end){if(61==r.charCodeAt(this.pos))return++this.pos,t>2&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.EQUALS_EQUALS_EQUALS):i.EQUALS_EQUALS;if(62==r.charCodeAt(this.pos))return++this.pos,i.EQUALS_GREATERTHAN}return i.EQUALS;case 62:if(++this.pos,t>1&&this.pos<this.end){if(62==r.charCodeAt(this.pos)){if(++this.pos,t>2&&this.pos<this.end){if(62==r.charCodeAt(this.pos))return++this.pos,t>3&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS):i.GREATERTHAN_GREATERTHAN_GREATERTHAN;if(61==r.charCodeAt(this.pos))return++this.pos,i.GREATERTHAN_GREATERTHAN_EQUALS}return i.GREATERTHAN_GREATERTHAN}if(61==r.charCodeAt(this.pos))return++this.pos,i.GREATERTHAN_EQUALS}return i.GREATERTHAN;case 63:return++this.pos,i.QUESTION;case 91:return++this.pos,i.OPENBRACKET;case 93:return++this.pos,i.CLOSEBRACKET;case 94:return++this.pos,t>1&&this.pos<this.end&&61==r.charCodeAt(this.pos)?(++this.pos,i.CARET_EQUALS):i.CARET;case 123:return++this.pos,i.OPENBRACE;case 124:if(++this.pos,t>1&&this.pos<this.end){if(124==r.charCodeAt(this.pos))return++this.pos,i.BAR_BAR;if(61==r.charCodeAt(this.pos))return++this.pos,i.BAR_EQUALS}return i.BAR;case 125:return++this.pos,i.CLOSEBRACE;case 126:return++this.pos,i.TILDE;case 64:return++this.pos,i.AT;default:if(c.isIdentifierStart(n)){if(c.isKeywordCharacter(n)){for(var _=this.pos;++this.pos<this.end&&c.isIdentifierPart(n=r.charCodeAt(this.pos));)if(!c.isKeywordCharacter(n))return this.pos=_,i.IDENTIFIER;var m=l(r.substring(_,this.pos));if(m!=i.INVALID&&e!==a.ALWAYS&&(e!==a.PREFER||!p(m)))return m;this.pos=_}return i.IDENTIFIER}if(c.isWhiteSpace(n)){++this.pos;break}return this.error(s.DiagnosticCode.Invalid_character,this.range(this.pos,this.pos+1)),++this.pos,i.INVALID}}return i.ENDOFFILE},t.prototype.peek=function(e,t,r){void 0===e&&(e=!1),void 0===t&&(t=a.DEFAULT),void 0===r&&(r=i32.MAX_VALUE);var n=this.source.text;if(this.nextToken<0){var i=this.pos,s=this.token,o=this.tokenPos;if(this.nextToken=this.unsafeNext(t,r),this.nextTokenPos=this.tokenPos,e){this.nextTokenOnNewLine=!1;for(var l=i,p=this.nextTokenPos;l<p;++l)if(c.isLineBreak(n.charCodeAt(l))){this.nextTokenOnNewLine=!0;break}}this.pos=i,this.token=s,this.tokenPos=o}return this.nextToken},t.prototype.skipIdentifier=function(e){return void 0===e&&(e=a.PREFER),this.skip(i.IDENTIFIER,e)},t.prototype.skip=function(e,t){void 0===t&&(t=a.DEFAULT);var r=this.pos,n=this.token,s=this.tokenPos,o=i32.MAX_VALUE;switch(e){case i.GREATERTHAN:o=1}return this.token=this.unsafeNext(t,o),this.token==e?(this.nextToken=-1,!0):(this.pos=r,this.token=n,this.tokenPos=s,!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)&&95!=r)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),i=t;this.pos<this.end;){var a=this.pos,o=e.charCodeAt(a);if(o>=48&&o<=57)r=i64_add(i64_mul(r,n),i64_new(o-48,0));else if(o>=65&&o<=70)r=i64_add(i64_mul(r,n),i64_new(10+o-65,0));else if(o>=97&&o<=102)r=i64_add(i64_mul(r,n),i64_new(10+o-97,0));else{if(95!=o)break;i==a&&this.error(i==t?s.DiagnosticCode.Numeric_separators_are_not_allowed_here:s.DiagnosticCode.Multiple_consecutive_numeric_separators_are_not_permitted,this.range(a)),i=a+1}this.pos=a+1}return this.pos==t?this.error(s.DiagnosticCode.Hexadecimal_digit_expected,this.range(t)):i==this.pos&&this.error(s.DiagnosticCode.Numeric_separators_are_not_allowed_here,this.range(i-1)),r},t.prototype.readDecimalInteger=function(){for(var e=this.source.text,t=this.pos,r=i64_new(0,0),n=i64_new(10,0),i=t;this.pos<this.end;){var a=this.pos,o=e.charCodeAt(a);if(o>=48&&o<=57)r=i64_add(i64_mul(r,n),i64_new(o-48,0));else{if(95!=o)break;i==a&&this.error(i==t?s.DiagnosticCode.Numeric_separators_are_not_allowed_here:s.DiagnosticCode.Multiple_consecutive_numeric_separators_are_not_permitted,this.range(a)),i=a+1}this.pos=a+1}return this.pos==t?this.error(s.DiagnosticCode.Digit_expected,this.range(t)):i==this.pos&&this.error(s.DiagnosticCode.Numeric_separators_are_not_allowed_here,this.range(i-1)),r},t.prototype.readOctalInteger=function(){for(var e=this.source.text,t=this.pos,r=i64_new(0,0),n=i64_new(8,0),i=t;this.pos<this.end;){var a=this.pos,o=e.charCodeAt(a);if(o>=48&&o<=55)r=i64_add(i64_mul(r,n),i64_new(o-48,0));else{if(95!=o)break;i==a&&this.error(i==t?s.DiagnosticCode.Numeric_separators_are_not_allowed_here:s.DiagnosticCode.Multiple_consecutive_numeric_separators_are_not_permitted,this.range(a)),i=a+1}++this.pos}return this.pos==t?this.error(s.DiagnosticCode.Octal_digit_expected,this.range(t)):i==this.pos&&this.error(s.DiagnosticCode.Numeric_separators_are_not_allowed_here,this.range(i-1)),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),a=t;this.pos<this.end;){var o=this.pos,c=e.charCodeAt(o);if(48==c)r=i64_mul(r,n);else if(49==c)r=i64_add(i64_mul(r,n),i);else{if(95!=c)break;a==o&&this.error(a==t?s.DiagnosticCode.Numeric_separators_are_not_allowed_here:s.DiagnosticCode.Multiple_consecutive_numeric_separators_are_not_permitted,this.range(o)),a=o+1}this.pos=o+1}return this.pos==t?this.error(s.DiagnosticCode.Binary_digit_expected,this.range(t)):a==this.pos&&this.error(s.DiagnosticCode.Numeric_separators_are_not_allowed_here,this.range(a-1)),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";var n=this&&this.__extends||function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),i=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}},a=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),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 s,o=r(23),c=r(1),l=r(5),p=r(0),u=r(4),h=r(8),d=r(3),_=r(6),m=r(2);!function(e){e[e.WASM32=0]="WASM32",e[e.WASM64=1]="WASM64"}(s=t.Target||(t.Target={}));var g=function(){function e(){this.target=s.WASM32,this.noTreeShaking=!1,this.noAssert=!1,this.importMemory=!1,this.importTable=!1,this.sourceMap=!1,this.memoryBase=0,this.globalAliases=null,this.features=0,this.optimizeLevelHint=0,this.shrinkLevelHint=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?_.Type.usize64:_.Type.usize32},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isizeType",{get:function(){return this.target==s.WASM64?_.Type.isize64:_.Type.isize32},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nativeSizeType",{get:function(){return this.target==s.WASM64?2:1},enumerable:!0,configurable:!0}),e.prototype.hasFeature=function(e){return 0!=(this.features&e)},e}();t.Options=g,function(e){e[e.NONE=0]="NONE",e[e.SIGN_EXTENSION=1]="SIGN_EXTENSION",e[e.MUTABLE_GLOBAL=2]="MUTABLE_GLOBAL"}(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 y,E,f=function(e){function t(t,r){void 0===r&&(r=null);var n=e.call(this,t.diagnostics)||this;return n.currentOuterFunction=null,n.currentInlineFunctions=[],n.currentEnum=null,n.currentType=_.Type.void,n.memorySegments=[],n.stringSegments=new Map,n.functionTable=["null"],n.argcVar=0,n.argcSet=0,n.needsIterateRoots=!1,n.f32ModInstance=null,n.f64ModInstance=null,n.f32PowInstance=null,n.f64PowInstance=null,n.program=t,n.resolver=t.resolver,r||(r=new g),n.options=r,n.memoryOffset=i64_new(max(r.memoryBase,8)),n.module=l.Module.create(),n}return n(t,e),t.compile=function(e,r){return void 0===r&&(r=null),new t(e,r).compile()},t.prototype.compile=function(){var e,t,r=this.options,n=this.module,s=this.program;s.initialize(r);var c=new u.Function(s.startFunction,"start",new _.Signature([],_.Type.void));this.startFunctionInstance=c;var p=new Array;this.startFunctionBody=p,this.currentFunction=c,r.isWasm64?n.addGlobal("HEAP_BASE",2,!0,n.createI64(0,0)):n.addGlobal("HEAP_BASE",1,!1,n.createI32(0));for(var h=s.sources,d=0,m=h.length;d<m;++d)h[d].isEntry&&this.compileSource(h[d]);if(p.length||null!==s.mainFunction){var g=c.signature,y=n.addFunction(c.internalName,this.ensureFunctionType(g.parameterTypes,g.returnType,g.thisType),_.typesToNativeTypes(c.additionalLocals),n.createBlock(null,p));c.finalize(n,y),s.mainFunction||n.setStart(y)}var E=this.memoryOffset;E=i64_align(E,r.usizeType.byteSize),this.memoryOffset=E,n.removeGlobal("HEAP_BASE"),r.isWasm64?n.addGlobal("HEAP_BASE",2,!1,n.createI64(i64_low(E),i64_high(E))):n.addGlobal("HEAP_BASE",1,!1,n.createI32(i64_low(E)));var f=this.memorySegments.length?i64_low(i64_shr_u(i64_align(E,65536),i64_new(16,0))):0;n.setMemory(f,l.Module.UNLIMITED_MEMORY,this.memorySegments,r.target,"memory"),r.importMemory&&n.addMemoryImport("0","env","memory");var T=this.functionTable;n.setFunctionTable(T.length,4294967295,T),n.addTableExport("0","table"),n.addFunction("null",this.ensureFunctionType(null,_.Type.void),null,n.createBlock(null,[])),r.importTable&&n.addTableImport("0","env","table");try{for(var I=i(s.moduleLevelExports),v=I.next();!v.done;v=I.next()){var A=a(v.value,2),C=A[0],N=A[1];this.makeModuleExport(C,N.element)}}catch(t){e={error:t}}finally{try{v&&!v.done&&(t=I.return)&&t.call(I)}finally{if(e)throw e.error}}return this.needsIterateRoots&&o.compileIterateRoots(this),n},t.prototype.makeModuleExport=function(e,t,r){var n,a,s,o,l,h,d,m,g,y;void 0===r&&(r="");var E=t.members;if(E){var f=r+e+(t.kind==u.ElementKind.CLASS?p.INSTANCE_DELIMITER:p.STATIC_DELIMITER);if(t.kind==u.ElementKind.NAMESPACE)try{for(var T=i(E.values()),I=T.next();!I.done;I=T.next()){(C=I.value).is(p.CommonFlags.EXPORT)&&this.makeModuleExport(C.simpleName,C,f)}}catch(e){n={error:e}}finally{try{I&&!I.done&&(a=T.return)&&a.call(T)}finally{if(n)throw n.error}}else try{for(var v=i(E.values()),A=v.next();!A.done;A=v.next()){var C;(C=A.value).is(p.CommonFlags.PRIVATE)||this.makeModuleExport(C.simpleName,C,f)}}catch(e){s={error:e}}finally{try{A&&!A.done&&(o=v.return)&&o.call(v)}finally{if(s)throw s.error}}}switch(t.kind){case u.ElementKind.GLOBAL:if(t.is(p.CommonFlags.CONST)||t.is(p.CommonFlags.STATIC|p.CommonFlags.READONLY)||this.options.hasFeature(2))this.module.addGlobalExport(t.internalName,r+e);else(N=t.declaration)&&this.error(c.DiagnosticCode.Cannot_export_a_mutable_global,N.name.range);break;case u.ElementKind.ENUMVALUE:var N;if(assert(t.parent).is(p.CommonFlags.CONST)||this.options.hasFeature(2))this.module.addGlobalExport(t.internalName,r+e);else(N=t.declaration)&&this.error(c.DiagnosticCode.Cannot_export_a_mutable_global,N.name.range);break;case u.ElementKind.FUNCTION:var O=(X=t).signature;O.requiredParameters<O.parameterTypes.length&&(X=this.ensureTrampoline(X),this.ensureArgcSet()),X.is(p.CommonFlags.COMPILED)&&this.module.addFunctionExport(X.internalName,r+e);break;case u.ElementKind.PROPERTY:var S=assert(t.getterPrototype);this.makeModuleExport(p.GETTER_PREFIX+e,S,r);var L=t.setterPrototype;L&&this.makeModuleExport(p.SETTER_PREFIX+e,L,r);break;case u.ElementKind.FIELD:var b=this.module,k=t.type,R=k.toNativeType(),x=t.memoryOffset,F=this.options.usizeType,D=this.options.nativeSizeType,B=r+p.GETTER_PREFIX+e;if(b.addFunction(B,this.ensureFunctionType(null,k,F),null,b.createLoad(k.byteSize,k.is(1),b.createGetLocal(0,D),R,x)),b.addFunctionExport(B,B),!t.is(p.CommonFlags.READONLY)){var U=r+p.SETTER_PREFIX+e;b.addFunction(U,this.ensureFunctionType([k],_.Type.void,F),null,b.createStore(k.byteSize,b.createGetLocal(0,D),b.createGetLocal(1,R),R,x)),b.addFunctionExport(U,U)}break;case u.ElementKind.FUNCTION_PROTOTYPE:try{for(var P=i(t.instances.values()),w=P.next();!w.done;w=P.next()){var M=w.value;try{for(var G=i(M.values()),K=G.next();!K.done;K=G.next()){var z=e;if((X=K.value).is(p.CommonFlags.GENERIC))z+=(W=X.internalName).substring(W.lastIndexOf("<"));this.makeModuleExport(z,X,r)}}catch(e){d={error:e}}finally{try{K&&!K.done&&(m=G.return)&&m.call(G)}finally{if(d)throw d.error}}}}catch(e){l={error:e}}finally{try{w&&!w.done&&(h=P.return)&&h.call(P)}finally{if(l)throw l.error}}break;case u.ElementKind.CLASS_PROTOTYPE:try{for(var V=i(t.instances.values()),H=V.next();!H.done;H=V.next()){var X,W;z=e;if((X=H.value).is(p.CommonFlags.GENERIC))z+=(W=X.internalName).substring(W.lastIndexOf("<"));var Y=X.constructorInstance;Y&&this.makeModuleExport(z+p.INSTANCE_DELIMITER+Y.simpleName,Y,r),this.makeModuleExport(z,X,r)}}catch(e){g={error:e}}finally{try{H&&!H.done&&(y=V.return)&&y.call(V)}finally{if(g)throw g.error}}break;case u.ElementKind.ENUM:case u.ElementKind.CLASS:case u.ElementKind.NAMESPACE:break;default:assert(!1)}},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(p.CommonFlags.COMPILED)){e.set(p.CommonFlags.COMPILED);for(var t=this.options.noTreeShaking,r=e.isEntry,n=this.startFunctionInstance,i=this.startFunctionBody,a=e.statements,s=0,o=a.length;s<o;++s){var c=a[s];switch(c.kind){case d.NodeKind.CLASSDECLARATION:(t||r&&c.is(p.CommonFlags.EXPORT))&&!c.isGeneric&&this.compileClassDeclaration(c,[],null);break;case d.NodeKind.INTERFACEDECLARATION:break;case d.NodeKind.ENUMDECLARATION:(t||r&&c.is(p.CommonFlags.EXPORT))&&this.compileEnumDeclaration(c);break;case d.NodeKind.FUNCTIONDECLARATION:(t||r&&c.is(p.CommonFlags.EXPORT))&&!c.isGeneric&&this.compileFunctionDeclaration(c,[]);break;case d.NodeKind.IMPORT:this.compileSourceByPath(c.normalizedPath,c.path);break;case d.NodeKind.NAMESPACEDECLARATION:(t||r&&c.is(p.CommonFlags.EXPORT))&&this.compileNamespaceDeclaration(c);break;case d.NodeKind.VARIABLE:var l=this.compileVariableStatement(c);l&&i.push(l);break;case d.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==u.ElementKind.GLOBAL),this.compileGlobal(t)?t:null},t.prototype.compileGlobal=function(e){if(e.is(p.CommonFlags.COMPILED))return!0;e.set(p.CommonFlags.COMPILED);var t=this.module,r=e.declaration,n=0;if(!e.is(p.CommonFlags.RESOLVED))if(r)if(r.type){var i=this.resolver.resolveType(r.type);if(!i)return!1;if(i==_.Type.void)return this.error(c.DiagnosticCode.Type_expected,r.type.range),!1;e.type=i,e.set(p.CommonFlags.RESOLVED)}else{if(!r.initializer)return this.error(c.DiagnosticCode.Type_expected,r.name.range.atEnd),!1;if(n=this.compileExpressionRetainType(r.initializer,_.Type.void,1),this.currentType==_.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,e.set(p.CommonFlags.RESOLVED)}else assert(!1);if(e.is(p.CommonFlags.AMBIENT)&&e.hasDecorator(u.DecoratorFlags.BUILTIN))return!0;var a=e.type.toNativeType(),s=e.is(p.CommonFlags.CONST)||e.is(p.CommonFlags.STATIC|p.CommonFlags.READONLY);if(e.is(p.CommonFlags.AMBIENT))return s||this.options.hasFeature(2)?(e.set(p.CommonFlags.MODULE_IMPORT),r?T(e,r):(y="env",E=e.simpleName),t.addGlobalImport(e.internalName,y,E,a),e.set(p.CommonFlags.COMPILED),!0):(this.error(c.DiagnosticCode.Operation_not_supported,assert(r).range),!1);var o=!1;if(null!==r&&null!==r.initializer){if(n||(n=this.compileExpression(r.initializer,e.type,1,1)),l.getExpressionId(n)!=l.ExpressionId.Const&&(s?(n=t.precomputeExpression(n),l.getExpressionId(n)!=l.ExpressionId.Const&&(this.warning(c.DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable,r.range),o=!0)):o=!0),e.hasDecorator(u.DecoratorFlags.INLINE)&&!o){switch(assert(l.getExpressionId(n)==l.ExpressionId.Const),l.getExpressionType(n)){case 1:e.constantValueKind=1,e.constantIntegerValue=i64_new(l.getConstValueI32(n),0);break;case 2:e.constantValueKind=1,e.constantIntegerValue=i64_new(l.getConstValueI64Low(n),l.getConstValueI64High(n));break;case 3:e.constantValueKind=2,e.constantFloatValue=l.getConstValueF32(n);break;case 4:e.constantValueKind=2,e.constantFloatValue=l.getConstValueF64(n);break;default:return assert(!1),!1}e.set(p.CommonFlags.INLINED)}}else n=e.type.toNativeZero(t);var h=e.internalName;return o?(t.addGlobal(h,a,!0,e.type.toNativeZero(t)),this.startFunctionBody.push(t.createSetGlobal(h,n))):t.addGlobal(h,a,!s,n),!0},t.prototype.compileEnumDeclaration=function(e){var t=assert(this.program.elementsLookup.get(e.fileLevelInternalName));return assert(t.kind==u.ElementKind.ENUM),this.compileEnum(t)?t:null},t.prototype.compileEnum=function(e){var t,r;if(e.is(p.CommonFlags.COMPILED))return!0;e.set(p.CommonFlags.COMPILED);var n=this.module;this.currentEnum=e;var a=null,s=!1;if(e.members)try{for(var o=i(e.members.values()),h=o.next();!h.done;h=o.next()){var d=h.value;if(d.kind==u.ElementKind.ENUMVALUE){var m=!1,g=d,y=g.declaration;g.set(p.CommonFlags.COMPILED);var E=void 0;y.value?(E=this.compileExpression(y.value,_.Type.i32,1,0),l.getExpressionId(E)!=l.ExpressionId.Const&&(e.is(p.CommonFlags.CONST)?(E=n.precomputeExpression(E),l.getExpressionId(E)!=l.ExpressionId.Const&&(this.error(c.DiagnosticCode.In_const_enum_declarations_member_initializer_must_be_constant_expression,y.value.range),m=!0)):m=!0)):null==a?E=n.createI32(0):(s&&this.error(c.DiagnosticCode.Enum_member_must_have_initializer,y.range),E=n.createBinary(l.BinaryOp.AddI32,n.createGetGlobal(a.internalName,1),n.createI32(1)),E=n.precomputeExpression(E),l.getExpressionId(E)!=l.ExpressionId.Const&&(e.is(p.CommonFlags.CONST)&&this.error(c.DiagnosticCode.In_const_enum_declarations_member_initializer_must_be_constant_expression,y.range),m=!0)),m?(n.addGlobal(g.internalName,1,!0,n.createI32(0)),this.startFunctionBody.push(n.createSetGlobal(g.internalName,E)),s=!0):(n.addGlobal(g.internalName,1,!e.is(p.CommonFlags.CONST),E),s=!1),a=g}}}catch(e){t={error:e}}finally{try{h&&!h.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.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==u.ElementKind.FUNCTION_PROTOTYPE),this.compileFunctionUsingTypeArguments(n,t,r,null,n.declaration.name)},t.prototype.compileFunctionUsingTypeArguments=function(e,t,r,n,i){var a=this.resolver.resolveFunctionInclTypeArguments(e,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,l=c.getFunctionTypeBySignature(o,n);if(!l){var p=_.Signature.makeSignatureString(e,t,r);l=c.addFunctionType(p,o,n)}return l},t.prototype.compileFunction=function(e){if(e.is(p.CommonFlags.COMPILED))return!0;assert(!(e.is(p.CommonFlags.AMBIENT)&&e.hasDecorator(u.DecoratorFlags.BUILTIN))),e.set(p.CommonFlags.COMPILED);var t,r=e.prototype.declaration,n=r.body;n?e.is(p.CommonFlags.AMBIENT)&&this.error(c.DiagnosticCode.An_implementation_cannot_be_declared_in_ambient_contexts,r.name.range):e.is(p.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(p.CommonFlags.CONSTRUCTOR),h=e.signature.returnType,m=this.currentFunction;this.currentFunction=e;var g=e.flow,f=void 0;if(n.kind==d.NodeKind.EXPRESSION)assert(!e.isAny(p.CommonFlags.CONSTRUCTOR|p.CommonFlags.GET|p.CommonFlags.SET|p.CommonFlags.MAIN)),assert(e.is(p.CommonFlags.ARROW)),f=this.compileExpression(n.expression,h,1,0),g.set(1),g.canOverflow(f,h)||g.set(2),g.finalize();else{assert(n.kind==d.NodeKind.BLOCK);var I=this.compileStatements(n.statements);if(e.is(p.CommonFlags.MAIN)&&(s.addGlobal("~started",1,!0,s.createI32(0)),I.unshift(s.createIf(s.createUnary(l.UnaryOp.EqzI32,s.createGetGlobal("~started",1)),s.createBlock(null,[s.createCall("start",null,0),s.createSetGlobal("~started",s.createI32(1))])))),g.finalize(),o){var v=this.options.nativeSizeType;if(assert(e.is(p.CommonFlags.INSTANCE)),!g.is(1))if(g.is(32))I.push(s.createGetLocal(0,v));else{var A=assert(e.parent);assert(A.kind==u.ElementKind.CLASS),I.push(s.createTeeLocal(0,this.makeConditionalAllocate(A,r.name)))}}else h==_.Type.void||g.is(1)||this.error(c.DiagnosticCode.A_function_whose_declared_type_is_not_void_must_return_a_value,r.signature.returnType.range);f=I.length?1==I.length?I[0]:s.createBlock(null,I,h.toNativeType()):s.createNop()}if(this.currentFunction=m,t=s.addFunction(e.internalName,a,_.typesToNativeTypes(e.additionalLocals),f),e.hasDecorator(u.DecoratorFlags.EXTERNAL)){var C=assert(d.findDecorator(d.DecoratorKind.EXTERNAL,r.decorators));this.error(c.DiagnosticCode.Operation_not_supported,C.range)}}else e.set(p.CommonFlags.MODULE_IMPORT),T(e,r),t=s.addFunctionImport(e.internalName,y,E,a);return 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 d.NodeKind.CLASSDECLARATION:!r&&!a.is(p.CommonFlags.EXPORT)||a.isGeneric||this.compileClassDeclaration(a,[]);break;case d.NodeKind.INTERFACEDECLARATION:!r&&!a.is(p.CommonFlags.EXPORT)||a.isGeneric||this.compileInterfaceDeclaration(a,[]);break;case d.NodeKind.ENUMDECLARATION:(r||a.is(p.CommonFlags.EXPORT))&&this.compileEnumDeclaration(a);break;case d.NodeKind.FUNCTIONDECLARATION:!r&&!a.is(p.CommonFlags.EXPORT)||a.isGeneric||this.compileFunctionDeclaration(a,[]);break;case d.NodeKind.NAMESPACEDECLARATION:(r||a.is(p.CommonFlags.EXPORT))&&this.compileNamespaceDeclaration(a);break;case d.NodeKind.VARIABLE:if(r||a.is(p.CommonFlags.EXPORT)){var s=this.compileVariableStatement(a,!0);s&&this.startFunctionBody.push(s)}break;default:assert(!1)}}},t.prototype.compileNamespace=function(e){var t,r;if(e.members){var n=this.options.noTreeShaking;try{for(var a=i(e.members.values()),s=a.next();!s.done;s=a.next()){var o=s.value;switch(o.kind){case u.ElementKind.CLASS_PROTOTYPE:!n&&!o.is(p.CommonFlags.EXPORT)||o.is(p.CommonFlags.GENERIC)||this.compileClassUsingTypeArguments(o,[]);break;case u.ElementKind.ENUM:this.compileEnum(o);break;case u.ElementKind.FUNCTION_PROTOTYPE:if((n||o.is(p.CommonFlags.EXPORT))&&!o.is(p.CommonFlags.GENERIC)){if(o.hasDecorator(u.DecoratorFlags.BUILTIN))break;this.compileFunctionUsingTypeArguments(o,[],null,null,o.declaration.name)}break;case u.ElementKind.GLOBAL:this.compileGlobal(o);break;case u.ElementKind.NAMESPACE:this.compileNamespace(o)}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}},t.prototype.compileExportStatement=function(e){var t=this.program.fileLevelExports,r=e.members;if(r)for(var n=0,i=r.length;n<i;++n){var a=r[n],s=t.get(e.range.source.internalPath+p.PATH_DELIMITER+a.externalName.text);if(s)switch(s.kind){case u.ElementKind.CLASS_PROTOTYPE:s.is(p.CommonFlags.GENERIC)||this.compileClassUsingTypeArguments(s,[]);break;case u.ElementKind.ENUM:this.compileEnum(s);break;case u.ElementKind.FUNCTION_PROTOTYPE:!s.is(p.CommonFlags.GENERIC)&&e.range.source.isEntry&&this.compileFunctionUsingTypeArguments(s,[],null,null,s.declaration.name);break;case u.ElementKind.GLOBAL:this.compileGlobal(s);break;case u.ElementKind.NAMESPACE:this.compileNamespace(s)}}},t.prototype.compileClassDeclaration=function(e,t,r){void 0===r&&(r=null);var n=assert(this.program.elementsLookup.get(e.fileLevelInternalName));assert(n.kind==u.ElementKind.CLASS_PROTOTYPE),this.compileClassUsingTypeArguments(n,t,r,e)},t.prototype.compileClassUsingTypeArguments=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null);var i=this.resolver.resolveClassInclTypeArguments(e,t,r,n||e.declaration);i&&this.compileClass(i)},t.prototype.compileClass=function(e){var t,r,n,a;if(e.is(p.CommonFlags.COMPILED))return!0;e.set(p.CommonFlags.COMPILED);var s=e.prototype.members;if(s)try{for(var o=i(s.values()),c=o.next();!c.done;c=o.next()){switch((m=c.value).kind){case u.ElementKind.GLOBAL:this.compileGlobal(m);break;case u.ElementKind.FUNCTION_PROTOTYPE:m.is(p.CommonFlags.GENERIC)||this.compileFunctionUsingTypeArguments(m,[],null,null,m.declaration.name);break;case u.ElementKind.PROPERTY:(g=m.getterPrototype)&&this.compileFunctionUsingTypeArguments(g,[],null,null,g.declaration.name),(y=m.setterPrototype)&&this.compileFunctionUsingTypeArguments(y,[],null,null,y.declaration.name)}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}var l=e.constructorInstance;l&&this.compileFunction(l);var h=e.members;if(h)try{for(var d=i(h.values()),_=d.next();!_.done;_=d.next()){var m;switch((m=_.value).kind){case u.ElementKind.FUNCTION_PROTOTYPE:m.is(p.CommonFlags.GENERIC)||this.compileFunctionUsingTypeArguments(m,[],e.contextualTypeArguments,null,m.declaration.name);break;case u.ElementKind.FIELD:m.set(p.CommonFlags.COMPILED);break;case u.ElementKind.PROPERTY:var g,y;(g=m.getterPrototype)&&this.compileFunctionUsingTypeArguments(g,[],e.contextualTypeArguments,null,g.declaration.name),(y=m.setterPrototype)&&this.compileFunctionUsingTypeArguments(y,[],e.contextualTypeArguments,null,y.declaration.name)}}}catch(e){n={error:e}}finally{try{_&&!_.done&&(a=d.return)&&a.call(d)}finally{if(n)throw n.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=l.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(p.CommonFlags.COMPILED)),e.functionTableIndex>=0)return e.functionTableIndex;var t=this.functionTable,r=t.length;return!e.is(p.CommonFlags.TRAMPOLINE)&&e.signature.requiredParameters<e.signature.parameterTypes.length&&(e=this.ensureTrampoline(e)),t.push(e.internalName),e.functionTableIndex=r,r},t.prototype.compileStatement=function(e){var t,r=this.module;switch(e.kind){case d.NodeKind.BLOCK:t=this.compileBlockStatement(e);break;case d.NodeKind.BREAK:t=this.compileBreakStatement(e);break;case d.NodeKind.CONTINUE:t=this.compileContinueStatement(e);break;case d.NodeKind.DO:t=this.compileDoStatement(e);break;case d.NodeKind.EMPTY:t=this.compileEmptyStatement(e);break;case d.NodeKind.EXPRESSION:t=this.compileExpressionStatement(e);break;case d.NodeKind.FOR:t=this.compileForStatement(e);break;case d.NodeKind.IF:t=this.compileIfStatement(e);break;case d.NodeKind.RETURN:t=this.compileReturnStatement(e);break;case d.NodeKind.SWITCH:t=this.compileSwitchStatement(e);break;case d.NodeKind.THROW:t=this.compileThrowStatement(e);break;case d.NodeKind.TRY:t=this.compileTryStatement(e);break;case d.NodeKind.VARIABLE:(t=this.compileVariableStatement(e))||(t=r.createNop());break;case d.NodeKind.VOID:t=this.compileVoidStatement(e);break;case d.NodeKind.WHILE:t=this.compileWhileStatement(e);break;case d.NodeKind.TYPEDECLARATION:if(this.currentFunction==this.startFunctionInstance)return r.createNop();default:assert(!1),t=r.createUnreachable()}return this.options.sourceMap&&this.addDebugLocation(t,e.range),t},t.prototype.compileStatements=function(e){var t=e.length,r=new Array(t);r.length=0;for(var n=this.currentFunction.flow,i=0;i<t;++i){var a=this.compileStatement(e[i]);switch(l.getExpressionId(a)){case l.ExpressionId.Block:if(!l.getBlockName(a)){for(var s=0,o=l.getBlockChildCount(a);s<o;++s)r.push(l.getBlockChild(a,s));break}default:r.push(a);case l.ExpressionId.Nop:}if(n.isAny(29)){l.needsExplicitUnreachable(a)&&r.push(this.module.createUnreachable());break}}return r},t.prototype.compileBlockStatement=function(e){var t=e.statements,r=this.currentFunction.flow,n=r.fork();this.currentFunction.flow=n;var i=this.compileStatements(t),a=0==i.length?this.module.createNop():1==i.length?i[0]:this.module.createBlock(null,i,l.getExpressionType(i[i.length-1]));return this.currentFunction.flow=n.free(),r.inherit(n),a},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(8),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(16),t.createBreak(i))},t.prototype.compileDoStatement=function(e){var t=this.currentFunction,r=this.module,n=t.enterBreakContext(),i=t.flow,a=i.fork();t.flow=a;var s="break|"+n;a.breakLabel=s;var o="continue|"+n;a.continueLabel=o;var c=this.compileStatement(e.statement),l=this.makeIsTrueish(this.compileExpression(e.condition,_.Type.i32,0,0),this.currentType);t.flow=a.free(),t.leaveBreakContext();var p=a.isAny(29);a.unset(792),i.inherit(a);var u=[r.createLoop(o,p?c:r.createBlock(null,[c,r.createBreak(o,l)],0))];return p&&u.push(r.createUnreachable()),r.createBlock(s,u)},t.prototype.compileEmptyStatement=function(e){return this.module.createNop()},t.prototype.compileExpressionStatement=function(e){var t=this.compileExpression(e.expression,_.Type.void,0,0);return this.currentType!=_.Type.void&&(t=this.module.createDrop(t),this.currentType=_.Type.void),t},t.prototype.compileForStatement=function(e){var t=this.currentFunction,r=t.enterBreakContext(),n=t.flow,i=n.fork();t.flow=i;var a=i.breakLabel="break|"+r;i.breakLabel=a;var s="continue|"+r;i.continueLabel=s;var o="repeat|"+r,c=this.module,p=e.initializer?this.compileStatement(e.initializer):0,u=0,h=!1;if(e.condition){u=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,_.Type.bool,0),this.currentType);var m=c.precomputeExpression(u);l.getExpressionId(m)==l.ExpressionId.Const&&(assert(1==l.getExpressionType(m)),0!=l.getConstValueI32(m)&&(h=!0)),u=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,_.Type.bool,0),this.currentType)}else u=c.createI32(1),h=!0;var g=e.incrementor?this.compileExpression(e.incrementor,_.Type.void,1,0):0,y=e.statement,E=y.kind==d.NodeKind.BLOCK&&1==y.statements.length?this.compileStatement(y.statements[0]):this.compileStatement(y);t.flow=i.free(),t.leaveBreakContext();var f=i.isAny(528);i.unset(792),h?n.inherit(i):n.inheritConditional(i);var T=new Array;p&&T.push(p);var I=new Array;return f?I.push(c.createBlock(s,[c.createBreak(a,c.createUnary(l.UnaryOp.EqzI32,u)),E],0)):(I.push(c.createBreak(a,c.createUnary(l.UnaryOp.EqzI32,u))),I.push(E)),g&&I.push(g),I.push(c.createBreak(o)),T.push(c.createLoop(o,c.createBlock(null,I,0))),c.createBlock(a,T)},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,_.Type.bool,0),this.currentType);if(!this.options.noTreeShaking||this.currentFunction.isAny(p.CommonFlags.GENERIC|p.CommonFlags.GENERIC_CONTEXT)){var s=t.precomputeExpression(a);if(l.getExpressionId(s)==l.ExpressionId.Const&&1==l.getExpressionType(s))return l.getConstValueI32(s)?this.compileStatement(n):i?this.compileStatement(i):t.createNop();a=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,_.Type.bool,0),this.currentType)}var o=r.flow,c=o.fork();r.flow=c;var u=this.compileStatement(n);r.flow=c.free();var h=0;if(i){var d=o.fork();r.flow=d,h=this.compileStatement(i),r.flow=d.free(),o.inheritMutual(c,d)}else o.inheritConditional(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;if(a==_.Type.void)return this.compileExpressionRetainType(e.value,a,0),this.error(c.DiagnosticCode.Type_0_is_not_assignable_to_type_1,e.value.range,this.currentType.toString(),a.toString()),this.currentType=_.Type.void,t.createUnreachable();n=this.compileExpression(e.value,a,1,r.is(p.CommonFlags.MODULE_EXPORT)?1:0),i.canOverflow(n,a)||i.set(2)}return d.isLastStatement(e)?n||t.createNop():i.is(2048)?t.createBreak(assert(i.returnLabel),0,n):t.createReturn(n)},t.prototype.compileSwitchStatement=function(e){var t=this.module,r=this.currentFunction,n=e.cases,i=n.length;if(!i)return this.compileExpression(e.condition,_.Type.void,1,0);var a=r.enterBreakContext(),s=r.flow,o=r.getTempLocal(_.Type.u32,!1),c=o.index,p=new Array(1+i);p[0]=t.createSetLocal(c,this.compileExpression(e.condition,_.Type.u32,1,0));for(var u=1,h=-1,d=0;d<i;++d){var m=n[d].label;m?p[u++]=t.createBreak("case"+d.toString(10)+"|"+a,t.createBinary(l.BinaryOp.EqI32,t.createGetLocal(c,1),this.compileExpression(m,_.Type.u32,1,0))):h=d}r.freeTempLocal(o),p[u]=t.createBreak((h>=0?"case"+h.toString(10):"break")+"|"+a);var g=t.createBlock("case0|"+a,p,0),y=!0,E=!0,f=!0,T=!0;for(d=0;d<i;++d){var I=n[d].statements,v=I.length,A=s.fork();r.flow=A;var C="break|"+a;A.breakLabel=C;var N=d==i-1,O=N?C:"case"+(d+1).toString(10)+"|"+a,S=new Array(1+v);S[0]=g;for(var L=1,b=!1,k=0;k<v;++k){var R=this.compileStatement(I[k]);if(l.getExpressionId(R)!=l.ExpressionId.Nop&&(S[L++]=R,A.isAny(29))){b=!0;break}}S.length=L,(b||N)&&(A.is(1)||(y=!1),A.is(2)||(E=!1),A.is(4)||(f=!1),A.is(32)||(T=!1)),A.unset(264),r.flow=A.free(),g=t.createBlock(O,S,0)}return r.leaveBreakContext(),h>=0&&(y&&s.set(1),E&&s.set(2),f&&s.set(4),T&&s.set(32)),g},t.prototype.compileThrowStatement=function(e){var t=this.currentFunction.flow;return t.set(4),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.startFunctionInstance&&e.parent&&e.parent.kind==d.NodeKind.SOURCE){for(var s=0;s<a;++s)this.compileGlobalDeclaration(i[s]);return 0}var o=new Array,h=this.currentFunction.flow,m=this.resolver;for(s=0;s<a;++s){var g=i[s],y=g.name.text,E=null,f=0;if(g.type){if(!(E=m.resolveType(g.type,h.contextualTypeArguments)))continue;g.initializer&&(f=this.compileExpression(g.initializer,E,1,0))}else{if(!g.initializer){this.error(c.DiagnosticCode.Type_expected,g.name.range.atEnd);continue}if(f=this.compileExpressionRetainType(g.initializer,_.Type.void,0),this.currentType==_.Type.void){this.error(c.DiagnosticCode.Type_0_is_not_assignable_to_type_1,g.range,this.currentType.toString(),"<auto>");continue}E=this.currentType}var T=!1;if(g.is(p.CommonFlags.CONST))if(f)if(f=this.module.precomputeExpression(f),l.getExpressionId(f)==l.ExpressionId.Const){var I=new u.Local(r,y,-1,E);switch(l.getExpressionType(f)){case 1:I=I.withConstantIntegerValue(i64_new(l.getConstValueI32(f),0));break;case 2:I=I.withConstantIntegerValue(i64_new(l.getConstValueI64Low(f),l.getConstValueI64High(f)));break;case 3:I=I.withConstantFloatValue(l.getConstValueF32(f));break;case 4:I=I.withConstantFloatValue(l.getConstValueF64(f));break;default:return assert(!1),this.module.createUnreachable()}var v=n.flow.scopedLocals;if(v){if(v.has(y))return this.error(c.DiagnosticCode.Duplicate_identifier_0,g.name.range,y),this.module.createUnreachable()}else n.flow.scopedLocals=v=new Map;v.set(y,I),T=!0}else this.warning(c.DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable,g.range);else this.error(c.DiagnosticCode._const_declarations_must_be_initialized,g.range);if(!T){I=void 0;I=g.isAny(p.CommonFlags.LET|p.CommonFlags.CONST)||h.is(2048)?h.addScopedLocal(E,y,!1,g):n.addLocal(E,y,g),f?(o.push(this.compileAssignmentWithValue(g.name,f)),I.type.is(36)&&h.setLocalWrapped(I.index,!h.canOverflow(f,E))):I.type.is(36)&&h.setLocalWrapped(I.index,!0)}}return o.length?1==o.length?o[0]:this.module.createBlock(null,o,0):0},t.prototype.compileVoidStatement=function(e){return this.compileExpression(e.expression,_.Type.void,2,0)},t.prototype.compileWhileStatement=function(e){var t=this.module,r=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,_.Type.bool,0),this.currentType);if(!this.options.noTreeShaking||this.currentFunction.isAny(p.CommonFlags.GENERIC|p.CommonFlags.GENERIC_CONTEXT)){var n=t.precomputeExpression(r);if(l.getExpressionId(n)==l.ExpressionId.Const&&1==l.getExpressionType(n)){if(!l.getConstValueI32(n))return t.createNop()}else r=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,_.Type.bool,0),this.currentType)}var i=this.currentFunction,a=i.enterBreakContext(),s=i.flow,o=s.fork();i.flow=o;var c="break|"+a;o.breakLabel=c;var u="continue|"+a;o.continueLabel=u;var h=this.compileStatement(e.statement),d=o.isAny(29);return i.flow=o.free(),i.leaveBreakContext(),o.unset(792),s.inheritConditional(o),t.createBlock(c,[t.createLoop(u,t.createIf(r,d?h:t.createBlock(null,[h,t.createBreak(u)],0)))])},t.prototype.compileInlineConstant=function(e,t,r){assert(e.is(p.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(_.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(_.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.hasDecorator(u.DecoratorFlags.BUILTIN)||t!=_.Type.f32)return this.module.createF64(e.constantFloatValue);this.currentType=_.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 d.NodeKind.ASSERTION:i=this.compileAssertionExpression(e,t);break;case d.NodeKind.BINARY:i=this.compileBinaryExpression(e,t);break;case d.NodeKind.CALL:i=this.compileCallExpression(e,t);break;case d.NodeKind.COMMA:i=this.compileCommaExpression(e,t);break;case d.NodeKind.ELEMENTACCESS:i=this.compileElementAccessExpression(e,t);break;case d.NodeKind.FUNCTION:i=this.compileFunctionExpression(e,t);break;case d.NodeKind.IDENTIFIER:case d.NodeKind.FALSE:case d.NodeKind.NULL:case d.NodeKind.THIS:case d.NodeKind.SUPER:case d.NodeKind.TRUE:i=this.compileIdentifierExpression(e,t,0==r);break;case d.NodeKind.INSTANCEOF:i=this.compileInstanceOfExpression(e,t);break;case d.NodeKind.LITERAL:i=this.compileLiteralExpression(e,t);break;case d.NodeKind.NEW:i=this.compileNewExpression(e,t);break;case d.NodeKind.PARENTHESIZED:i=this.compileParenthesizedExpression(e,t);break;case d.NodeKind.PROPERTYACCESS:i=this.compilePropertyAccessExpression(e,t,0==r);break;case d.NodeKind.TERNARY:i=this.compileTernaryExpression(e,t);break;case d.NodeKind.UNARYPOSTFIX:i=this.compileUnaryPostfixExpression(e,t);break;case d.NodeKind.UNARYPREFIX:i=this.compileUnaryPrefixExpression(e,t);break;default:this.error(c.DiagnosticCode.Operation_not_supported,e.range),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==_.Type.void?_.Type.i32:t,0,r)},t.prototype.precomputeExpression=function(e,t,r,n){return this.module.precomputeExpression(this.compileExpression(e,t,r,n))},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):(t.isAssignableTo(r)||1==n&&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(l.UnaryOp.PromoteF32,e)):11==r.kind&&(e=s.createUnary(l.UnaryOp.DemoteF64,e)):r.is(4)?11==t.kind?r==_.Type.bool?(e=s.createBinary(l.BinaryOp.NeF32,e,s.createF32(0)),i=0):e=r.is(1)?r.is(64)?s.createUnary(l.UnaryOp.TruncF32ToI64,e):s.createUnary(l.UnaryOp.TruncF32ToI32,e):r.is(64)?s.createUnary(l.UnaryOp.TruncF32ToU64,e):s.createUnary(l.UnaryOp.TruncF32ToU32,e):r==_.Type.bool?(e=s.createBinary(l.BinaryOp.NeF64,e,s.createF64(0)),i=0):e=r.is(1)?r.is(64)?s.createUnary(l.UnaryOp.TruncF64ToI64,e):s.createUnary(l.UnaryOp.TruncF64ToI32,e):r.is(64)?s.createUnary(l.UnaryOp.TruncF64ToU64,e):s.createUnary(l.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)?l.UnaryOp.ConvertI64ToF32:l.UnaryOp.ConvertU64ToF32,e):s.createUnary(t.is(1)?l.UnaryOp.ConvertI32ToF32:l.UnaryOp.ConvertU32ToF32,e):t.is(64)?s.createUnary(t.is(1)?l.UnaryOp.ConvertI64ToF64:l.UnaryOp.ConvertU64ToF64,e):s.createUnary(t.is(1)?l.UnaryOp.ConvertI32ToF64:l.UnaryOp.ConvertU32ToF64,e):t.is(64)?r==_.Type.bool?(e=s.createBinary(l.BinaryOp.NeI64,e,s.createI64(0)),i=0):r.is(64)||(e=s.createUnary(l.UnaryOp.WrapI64,e)):r.is(64)?(e=s.createUnary(t.is(1)?l.UnaryOp.ExtendI32:l.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.resolver.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,p=this.module,d=e.left,m=e.right,g=!1,y=e.operator;switch(y){case h.Token.LESSTHAN:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.LT)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,d),i=this.convertExpression(i,a,a=s,1,1,m),s.kind){case 0:case 1:case 2:o=p.createBinary(l.BinaryOp.LtI32,r,i);break;case 3:o=p.createBinary(l.BinaryOp.LtI64,r,i);break;case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.LtI64:l.BinaryOp.LtI32,r,i);break;case 5:case 6:case 7:case 10:o=p.createBinary(l.BinaryOp.LtU32,r,i);break;case 9:o=p.createBinary(this.options.isWasm64?l.BinaryOp.LtU64:l.BinaryOp.LtU32,r,i);break;case 8:o=p.createBinary(l.BinaryOp.LtU64,r,i);break;case 11:o=p.createBinary(l.BinaryOp.LtF32,r,i);break;case 12:o=p.createBinary(l.BinaryOp.LtF64,r,i);break;default:assert(!1),o=p.createUnreachable()}this.currentType=_.Type.bool;break;case h.Token.GREATERTHAN:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.GT)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,d),i=this.convertExpression(i,a,a=s,1,1,m),s.kind){case 0:case 1:case 2:o=p.createBinary(l.BinaryOp.GtI32,r,i);break;case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.GtI64:l.BinaryOp.GtI32,r,i);break;case 3:o=p.createBinary(l.BinaryOp.GtI64,r,i);break;case 5:case 6:case 7:case 10:o=p.createBinary(l.BinaryOp.GtU32,r,i);break;case 9:o=p.createBinary(this.options.isWasm64?l.BinaryOp.GtU64:l.BinaryOp.GtU32,r,i);break;case 8:o=p.createBinary(l.BinaryOp.GtU64,r,i);break;case 11:o=p.createBinary(l.BinaryOp.GtF32,r,i);break;case 12:o=p.createBinary(l.BinaryOp.GtF64,r,i);break;default:assert(!1),o=p.createUnreachable()}this.currentType=_.Type.bool;break;case h.Token.LESSTHAN_EQUALS:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.LE)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,d),i=this.convertExpression(i,a,a=s,1,1,m),s.kind){case 0:case 1:case 2:o=p.createBinary(l.BinaryOp.LeI32,r,i);break;case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.LeI64:l.BinaryOp.LeI32,r,i);break;case 3:o=p.createBinary(l.BinaryOp.LeI64,r,i);break;case 5:case 6:case 7:case 10:o=p.createBinary(l.BinaryOp.LeU32,r,i);break;case 9:o=p.createBinary(this.options.isWasm64?l.BinaryOp.LeU64:l.BinaryOp.LeU32,r,i);break;case 8:o=p.createBinary(l.BinaryOp.LeU64,r,i);break;case 11:o=p.createBinary(l.BinaryOp.LeF32,r,i);break;case 12:o=p.createBinary(l.BinaryOp.LeF64,r,i);break;default:assert(!1),o=p.createUnreachable()}this.currentType=_.Type.bool;break;case h.Token.GREATERTHAN_EQUALS:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.GE)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,d),i=this.convertExpression(i,a,a=s,1,1,m),s.kind){case 0:case 1:case 2:o=p.createBinary(l.BinaryOp.GeI32,r,i);break;case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.GeI64:l.BinaryOp.GeI32,r,i);break;case 3:o=p.createBinary(l.BinaryOp.GeI64,r,i);break;case 5:case 6:case 7:case 10:o=p.createBinary(l.BinaryOp.GeU32,r,i);break;case 9:o=p.createBinary(this.options.isWasm64?l.BinaryOp.GeU64:l.BinaryOp.GeU32,r,i);break;case 8:o=p.createBinary(l.BinaryOp.GeU64,r,i);break;case 11:o=p.createBinary(l.BinaryOp.GeF32,r,i);break;case 12:o=p.createBinary(l.BinaryOp.GeF64,r,i);break;default:assert(!1),o=p.createUnreachable()}this.currentType=_.Type.bool;break;case h.Token.EQUALS_EQUALS_EQUALS:case h.Token.EQUALS_EQUALS:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,y==h.Token.EQUALS_EQUALS&&this.currentType.is(256))if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.EQ)){o=this.compileBinaryOverload(v,d,r,m,e);break}if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,h.operatorTokenToString(e.operator),n.toString(),a.toString()),this.currentType=t,p.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,d),i=this.convertExpression(i,a,a=s,1,1,m),s.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:o=p.createBinary(l.BinaryOp.EqI32,r,i);break;case 9:case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.EqI64:l.BinaryOp.EqI32,r,i);break;case 3:case 8:o=p.createBinary(l.BinaryOp.EqI64,r,i);break;case 11:o=p.createBinary(l.BinaryOp.EqF32,r,i);break;case 12:o=p.createBinary(l.BinaryOp.EqF64,r,i);break;default:assert(!1),o=p.createUnreachable()}this.currentType=_.Type.bool;break;case h.Token.EXCLAMATION_EQUALS_EQUALS:case h.Token.EXCLAMATION_EQUALS:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,y==h.Token.EXCLAMATION_EQUALS&&this.currentType.is(256))if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.NE)){o=this.compileBinaryOverload(v,d,r,m,e);break}if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.Type.commonCompatible(n,a,!1)))return this.error(c.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2,e.range,h.operatorTokenToString(e.operator),n.toString(),a.toString()),this.currentType=t,p.createUnreachable();switch(r=this.convertExpression(r,n,n=s,1,1,d),i=this.convertExpression(i,a,a=s,1,1,m),s.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:o=p.createBinary(l.BinaryOp.NeI32,r,i);break;case 9:case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.NeI64:l.BinaryOp.NeI32,r,i);break;case 3:case 8:o=p.createBinary(l.BinaryOp.NeI64,r,i);break;case 11:o=p.createBinary(l.BinaryOp.NeF32,r,i);break;case 12:o=p.createBinary(l.BinaryOp.NeF64,r,i);break;default:assert(!1),o=p.createUnreachable()}this.currentType=_.Type.bool;break;case h.Token.EQUALS:return this.compileAssignment(d,m,t);case h.Token.PLUS_EQUALS:g=!0;case h.Token.PLUS:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.ADD)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(g)i=this.compileExpression(m,n,1,0);else{if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,d),i=this.convertExpression(i,a,a=s,1,0,m)}switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:case 2:case 7:o=p.createBinary(l.BinaryOp.AddI32,r,i);break;case 9:case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.AddI64:l.BinaryOp.AddI32,r,i);break;case 3:case 8:o=p.createBinary(l.BinaryOp.AddI64,r,i);break;case 11:o=p.createBinary(l.BinaryOp.AddF32,r,i);break;case 12:o=p.createBinary(l.BinaryOp.AddF64,r,i);break;default:assert(!1),o=p.createUnreachable()}break;case h.Token.MINUS_EQUALS:g=!0;case h.Token.MINUS:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.SUB)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(g)i=this.compileExpression(m,n,1,0),a=this.currentType;else{if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,d),i=this.convertExpression(i,a,a=s,1,0,m)}switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:case 2:case 7:o=p.createBinary(l.BinaryOp.SubI32,r,i);break;case 9:case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.SubI64:l.BinaryOp.SubI32,r,i);break;case 3:case 8:o=p.createBinary(l.BinaryOp.SubI64,r,i);break;case 11:o=p.createBinary(l.BinaryOp.SubF32,r,i);break;case 12:o=p.createBinary(l.BinaryOp.SubF64,r,i);break;default:assert(!1),o=p.createUnreachable()}break;case h.Token.ASTERISK_EQUALS:g=!0;case h.Token.ASTERISK:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.MUL)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(g)r=this.ensureSmallIntegerWrap(r,n),i=this.compileExpression(m,n,1,1);else{if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,d),i=this.convertExpression(i,a,a=s,1,0,m)}switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:case 2:case 7:o=p.createBinary(l.BinaryOp.MulI32,r,i);break;case 9:case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.MulI64:l.BinaryOp.MulI32,r,i);break;case 3:case 8:o=p.createBinary(l.BinaryOp.MulI64,r,i);break;case 11:o=p.createBinary(l.BinaryOp.MulF32,r,i);break;case 12:o=p.createBinary(l.BinaryOp.MulF64,r,i);break;default:assert(!1),o=p.createUnreachable()}break;case h.Token.ASTERISK_ASTERISK_EQUALS:g=!0;case h.Token.ASTERISK_ASTERISK:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.POW)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}var E=void 0;if(11==this.currentType.kind){if(i=this.compileExpression(m,_.Type.f32,1,0),a=this.currentType,!(E=this.f32PowInstance)){if(!(f=this.program.elementsLookup.get("Mathf"))){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Mathf"),o=p.createUnreachable();break}if(!(T=f.members?f.members.get("pow"):null)){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Mathf.pow"),o=p.createUnreachable();break}assert(T.kind==u.ElementKind.FUNCTION_PROTOTYPE),this.f32PowInstance=E=this.resolver.resolveFunction(T,null)}}else if(r=this.convertExpression(r,this.currentType,_.Type.f64,1,0,d),n=this.currentType,i=this.compileExpression(m,_.Type.f64,1,0),a=this.currentType,!(E=this.f64PowInstance)){if(!(f=this.program.elementsLookup.get("Math"))){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Math"),o=p.createUnreachable();break}if(!(T=f.members?f.members.get("pow"):null)){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Math.pow"),o=p.createUnreachable();break}assert(T.kind==u.ElementKind.FUNCTION_PROTOTYPE),this.f64PowInstance=E=this.resolver.resolveFunction(T,null)}o=E&&this.compileFunction(E)?this.makeCallDirect(E,[r,i]):p.createUnreachable();break;case h.Token.SLASH_EQUALS:g=!0;case h.Token.SLASH:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.DIV)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(g)r=this.ensureSmallIntegerWrap(r,n),i=this.compileExpression(m,n,1,1),a=this.currentType;else{if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();r=this.convertExpression(r,n,n=s,1,1,d),i=this.convertExpression(i,a,a=s,1,1,m)}switch(this.currentType.kind){case 0:case 1:case 2:o=p.createBinary(l.BinaryOp.DivI32,r,i);break;case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.DivI64:l.BinaryOp.DivI32,r,i);break;case 3:o=p.createBinary(l.BinaryOp.DivI64,r,i);break;case 5:case 6:case 10:case 7:o=p.createBinary(l.BinaryOp.DivU32,r,i);break;case 9:o=p.createBinary(this.options.isWasm64?l.BinaryOp.DivU64:l.BinaryOp.DivU32,r,i);break;case 8:o=p.createBinary(l.BinaryOp.DivU64,r,i);break;case 11:o=p.createBinary(l.BinaryOp.DivF32,r,i);break;case 12:o=p.createBinary(l.BinaryOp.DivF64,r,i);break;default:assert(!1),o=p.createUnreachable()}break;case h.Token.PERCENT_EQUALS:g=!0;case h.Token.PERCENT:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.REM)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(g)r=this.ensureSmallIntegerWrap(r,n),i=this.compileExpression(m,n,1,1),a=this.currentType;else{if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();r=this.convertExpression(r,n,n=s,1,1,d),i=this.convertExpression(i,a,a=s,1,1,m)}switch(this.currentType.kind){case 0:case 1:case 2:o=p.createBinary(l.BinaryOp.RemI32,r,i);break;case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.RemI64:l.BinaryOp.RemI32,r,i);break;case 3:o=p.createBinary(l.BinaryOp.RemI64,r,i);break;case 5:case 6:case 10:case 7:o=p.createBinary(l.BinaryOp.RemU32,r,i);break;case 9:o=p.createBinary(this.options.isWasm64?l.BinaryOp.RemU64:l.BinaryOp.RemU32,r,i);break;case 8:o=p.createBinary(l.BinaryOp.RemU64,r,i);break;case 11:if(!(E=this.f32ModInstance)){if(!(f=this.program.elementsLookup.get("Mathf"))){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Mathf"),o=p.createUnreachable();break}if(!(T=f.members?f.members.get("mod"):null)){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Mathf.mod"),o=p.createUnreachable();break}assert(T.kind==u.ElementKind.FUNCTION_PROTOTYPE),this.f32ModInstance=E=this.resolver.resolveFunction(T,null)}o=E&&this.compileFunction(E)?this.makeCallDirect(E,[r,i]):p.createUnreachable();break;case 12:if(!(E=this.f64ModInstance)){var f,T;if(!(f=this.program.elementsLookup.get("Math"))){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Math"),o=p.createUnreachable();break}if(!(T=f.members?f.members.get("mod"):null)){this.error(c.DiagnosticCode.Cannot_find_name_0,e.range,"Math.mod"),o=p.createUnreachable();break}assert(T.kind==u.ElementKind.FUNCTION_PROTOTYPE),this.f64ModInstance=E=this.resolver.resolveFunction(T,null)}o=E&&this.compileFunction(E)?this.makeCallDirect(E,[r,i]):p.createUnreachable();break;default:assert(!1),o=p.createUnreachable()}break;case h.Token.LESSTHAN_LESSTHAN_EQUALS:g=!0;case h.Token.LESSTHAN_LESSTHAN:if(r=this.compileExpressionRetainType(d,t.intType,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.BITWISE_SHL)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}switch(i=this.compileExpression(m,n,1,0),a=this.currentType,this.currentType.kind){case 0:case 1:case 5:case 6:case 10:case 2:case 7:o=p.createBinary(l.BinaryOp.ShlI32,r,i);break;case 3:case 8:o=p.createBinary(l.BinaryOp.ShlI64,r,i);break;case 9:case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.ShlI64:l.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,h.operatorTokenToString(e.operator),this.currentType.toString()),p.createUnreachable();default:assert(!1),o=p.createUnreachable()}break;case h.Token.GREATERTHAN_GREATERTHAN_EQUALS:g=!0;case h.Token.GREATERTHAN_GREATERTHAN:if(r=this.compileExpressionRetainType(d,t.intType,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.BITWISE_SHR)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}switch(r=this.ensureSmallIntegerWrap(r,n),i=this.compileExpression(m,n,1,1),a=this.currentType,this.currentType.kind){case 0:case 1:case 2:o=p.createBinary(l.BinaryOp.ShrI32,r,i);break;case 3:o=p.createBinary(l.BinaryOp.ShrI64,r,i);break;case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.ShrI64:l.BinaryOp.ShrI32,r,i);break;case 5:case 6:case 10:case 7:o=p.createBinary(l.BinaryOp.ShrU32,r,i);break;case 8:o=p.createBinary(l.BinaryOp.ShrU64,r,i);break;case 9:o=p.createBinary(this.options.isWasm64?l.BinaryOp.ShrU64:l.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,h.operatorTokenToString(e.operator),this.currentType.toString()),p.createUnreachable();default:assert(!1),o=p.createUnreachable()}break;case h.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS:g=!0;case h.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN:if(r=this.compileExpressionRetainType(d,t.intType,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.BITWISE_SHR_U)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}switch(r=this.ensureSmallIntegerWrap(r,n),i=this.compileExpression(m,n,1,0),a=this.currentType,this.currentType.kind){case 5:case 6:case 10:o=p.createBinary(l.BinaryOp.ShrU32,r,i);case 0:case 1:case 2:case 7:o=p.createBinary(l.BinaryOp.ShrU32,r,i);break;case 3:case 8:o=p.createBinary(l.BinaryOp.ShrU64,r,i);break;case 9:case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.ShrU64:l.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,h.operatorTokenToString(e.operator),this.currentType.toString()),p.createUnreachable();default:assert(!1),o=p.createUnreachable()}break;case h.Token.AMPERSAND_EQUALS:g=!0;case h.Token.AMPERSAND:if(r=this.compileExpressionRetainType(d,t.intType,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.BITWISE_AND)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(g)i=this.compileExpression(m,n,1,0),a=this.currentType;else{if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,d),i=this.convertExpression(i,a,a=s,1,0,m)}switch(this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 10:case 7:o=p.createBinary(l.BinaryOp.AndI32,r,i);break;case 3:case 8:o=p.createBinary(l.BinaryOp.AndI64,r,i);break;case 9:case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.AndI64:l.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,h.operatorTokenToString(e.operator),this.currentType.toString()),p.createUnreachable();default:assert(!1),o=p.createUnreachable()}break;case h.Token.BAR_EQUALS:g=!0;case h.Token.BAR:if(r=this.compileExpressionRetainType(d,t.intType,0),n=this.currentType,this.currentType.is(256)){if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.BITWISE_OR)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(g)i=this.compileExpression(m,n,1,0),a=this.currentType;else{if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,d),i=this.convertExpression(i,a,a=s,1,0,m)}switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:o=p.createBinary(l.BinaryOp.OrI32,r,i);break;case 2:case 7:o=p.createBinary(l.BinaryOp.OrI32,r,i);break;case 3:case 8:o=p.createBinary(l.BinaryOp.OrI64,r,i);break;case 9:case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.OrI64:l.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,h.operatorTokenToString(e.operator),this.currentType.toString()),p.createUnreachable();default:assert(!1),o=p.createUnreachable()}break;case h.Token.CARET_EQUALS:g=!0;case h.Token.CARET:if(r=this.compileExpressionRetainType(d,t.intType,0),n=this.currentType,this.currentType.is(256)){var I,v;if(I=n.classReference)if(v=I.lookupOverload(u.OperatorKind.BITWISE_XOR)){o=this.compileBinaryOverload(v,d,r,m,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable()}if(g)i=this.compileExpression(m,n,1,0),a=this.currentType;else{if(i=this.compileExpressionRetainType(m,n,0),a=this.currentType,!(s=_.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,p.createUnreachable();r=this.convertExpression(r,n,n=s,1,0,d),i=this.convertExpression(i,a,a=s,1,0,m)}switch(this.currentType.kind){case 0:case 1:case 5:case 6:case 10:o=p.createBinary(l.BinaryOp.XorI32,r,i);break;case 2:case 7:o=p.createBinary(l.BinaryOp.XorI32,r,i);break;case 3:case 8:o=p.createBinary(l.BinaryOp.XorI64,r,i);break;case 9:case 4:o=p.createBinary(this.options.isWasm64?l.BinaryOp.XorI64:l.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,h.operatorTokenToString(e.operator),this.currentType.toString()),p.createUnreachable();default:assert(!1),o=p.createUnreachable()}break;case h.Token.AMPERSAND_AMPERSAND:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,i=this.compileExpression(m,n,1,0),a=this.currentType,o=p.cloneExpression(r,!0,0))this.makeIsTrueish(r,this.currentType),o=p.createIf(this.makeIsTrueish(r,this.currentType),i,o);else{var A=this.currentFunction.flow,C=this.currentFunction.getAndFreeTempLocal(this.currentType,!A.canOverflow(r,this.currentType));o=p.createIf(this.makeIsTrueish(p.createTeeLocal(C.index,r),this.currentType),i,p.createGetLocal(assert(C).index,this.currentType.toNativeType()))}break;case h.Token.BAR_BAR:if(r=this.compileExpressionRetainType(d,t,0),n=this.currentType,i=this.compileExpression(m,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,C=this.currentFunction.getAndFreeTempLocal(this.currentType,!A.canOverflow(r,this.currentType));o=p.createIf(this.makeIsTrueish(p.createTeeLocal(C.index,r),this.currentType),p.createGetLocal(assert(C).index,this.currentType.toNativeType()),i)}break;default:assert(!1),o=this.module.createUnreachable()}return g?this.compileAssignmentWithValue(d,o,t!=_.Type.void):o},t.prototype.compileUnaryOverload=function(e,t,r,n){var i,a=0;return e.is(p.CommonFlags.INSTANCE)?(a=r,i=[]):i=[t],this.compileCallDirect(e,i,n,a,e.hasDecorator(u.DecoratorFlags.INLINE))},t.prototype.compileBinaryOverload=function(e,t,r,n,i){var a,s=0;if(e.is(p.CommonFlags.INSTANCE)){var o=assert(e.parent);assert(o.kind==u.ElementKind.CLASS),s=r,a=[n]}else a=[t,n];return this.compileCallDirect(e,a,i,s,e.hasDecorator(u.DecoratorFlags.INLINE))},t.prototype.compileAssignment=function(e,t,r){var n,i=this.program.resolver,a=this.currentFunction,s=i.resolveExpression(e,a);if(!s)return this.module.createUnreachable();switch(s.kind){case u.ElementKind.GLOBAL:if(!this.compileGlobal(s))return this.module.createUnreachable();assert(s.type!=_.Type.void);case u.ElementKind.LOCAL:case u.ElementKind.FIELD:n=s.type;break;case u.ElementKind.PROPERTY:var o=s.setterPrototype;if(o){var l=this.resolver.resolveFunction(o,null);if(!l)return this.module.createUnreachable();assert(1==l.signature.parameterTypes.length),n=l.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 u.ElementKind.CLASS:if(i.currentElementExpression){var p=a.flow.is(4096),h=s.lookupOverload(u.OperatorKind.INDEXED_SET,p);if(!h)return s.lookupOverload(u.OperatorKind.INDEXED_GET,p)?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()}assert(n!=_.Type.void);var d=this.compileExpression(t,n,1,0);return this.compileAssignmentWithValue(e,d,r!=_.Type.void)},t.prototype.compileAssignmentWithValue=function(e,t,r){void 0===r&&(r=!1);var n=this.module,i=this.resolver.resolveExpression(e,this.currentFunction);if(!i)return n.createUnreachable();switch(i.kind){case u.ElementKind.LOCAL:var a=i.type;if(assert(a!=_.Type.void),this.currentType=r?a:_.Type.void,i.is(p.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();var s=this.currentFunction.flow;return a.is(36)&&s.setLocalWrapped(i.index,!s.canOverflow(t,a)),r?n.createTeeLocal(i.index,t):n.createSetLocal(i.index,t);case u.ElementKind.GLOBAL:if(!this.compileGlobal(i))return n.createUnreachable();a=i.type;if(assert(a!=_.Type.void),this.currentType=r?a:_.Type.void,i.is(p.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 o=a.toNativeType(),l=i.internalName;return n.createBlock(null,[n.createSetGlobal(l,t),n.createGetGlobal(l,o)],o)}return n.createSetGlobal(i.internalName,t);case u.ElementKind.FIELD:var h=i.declaration;if(i.is(p.CommonFlags.READONLY)&&!this.currentFunction.is(p.CommonFlags.CONSTRUCTOR)&&null!=h&&null==h.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 d=assert(this.resolver.currentThisExpression),m=this.compileExpressionRetainType(d,this.options.usizeType,0);a=i.type;this.currentType=r?a:_.Type.void;o=a.toNativeType();if(10==a.kind&&(t=this.ensureSmallIntegerWrap(t,a)),r){s=(L=this.currentFunction).flow;var g=L.getAndFreeTempLocal(a,!s.canOverflow(t,a)).index;return n.createBlock(null,[n.createSetLocal(g,t),n.createStore(a.byteSize,m,n.createGetLocal(g,o),o,i.memoryOffset),n.createGetLocal(g,o)],o)}return n.createStore(a.byteSize,m,t,o,i.memoryOffset);case u.ElementKind.PROPERTY:var y=i.setterPrototype;if(y){var E=this.resolver.resolveFunction(y,null);if(!E)return n.createUnreachable();if(!r){if(E.is(p.CommonFlags.INSTANCE)){d=assert(this.resolver.currentThisExpression),m=this.compileExpressionRetainType(d,this.options.usizeType,0);return this.makeCallDirect(E,[m,t])}return this.makeCallDirect(E,[t])}var f=i.getterPrototype;assert(null!=f);var T=this.resolver.resolveFunction(f,null);if(!T)return n.createUnreachable();var I=(R=T.signature.returnType).toNativeType();if(E.is(p.CommonFlags.INSTANCE)){d=assert(this.resolver.currentThisExpression),m=this.compileExpressionRetainType(d,this.options.usizeType,0),g=this.currentFunction.getAndFreeTempLocal(R,!1).index;return n.createBlock(null,[this.makeCallDirect(E,[n.createTeeLocal(g,m),t]),this.makeCallDirect(T,[n.createGetLocal(g,I)])],I)}return n.createBlock(null,[this.makeCallDirect(E,[t]),this.makeCallDirect(T)],I)}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 u.ElementKind.CLASS:var v=this.resolver.currentElementExpression;if(v){var A=this.currentFunction.flow.is(4096),C=i.lookupOverload(u.OperatorKind.INDEXED_GET,A);if(!C)return this.error(c.DiagnosticCode.Index_signature_is_missing_in_type_0,e.range,i.internalName),n.createUnreachable();var N=i.lookupOverload(u.OperatorKind.INDEXED_SET,A);if(!N)return this.error(c.DiagnosticCode.Index_signature_in_type_0_only_permits_reading,e.range,i.internalName),this.currentType=r?C.signature.returnType:_.Type.void,n.createUnreachable();var O=i.type,S=(d=assert(this.resolver.currentThisExpression),m=this.compileExpressionRetainType(d,this.options.usizeType,0),this.compileExpression(v,_.Type.i32,1,0));if(r){var L,b=(L=this.currentFunction).getTempLocal(O,!1),k=L.getAndFreeTempLocal(this.currentType,!1),R=C.signature.returnType;return this.currentFunction.freeTempLocal(b),n.createBlock(null,[this.makeCallDirect(N,[n.createTeeLocal(b.index,m),n.createTeeLocal(k.index,S),t]),this.makeCallDirect(C,[n.createGetLocal(b.index,b.type.toNativeType()),n.createGetLocal(k.index,k.type.toNativeType())])],R.toNativeType())}return this.makeCallDirect(N,[m,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.resolver.resolveExpression(e.expression,a);if(!s)return i.createUnreachable();switch(s.kind){case u.ElementKind.FUNCTION_PROTOTYPE:var o=s,l=e.typeArguments;if(o.hasDecorator(u.DecoratorFlags.BUILTIN))return this.compileCallExpressionBuiltin(o,e,t);var h=null;if(l){if(!o.is(p.CommonFlags.GENERIC))return this.error(c.DiagnosticCode.Type_0_is_not_generic,e.expression.range,o.internalName),i.createUnreachable();h=this.resolver.resolveFunctionInclTypeArguments(o,l,this.currentFunction.flow.contextualTypeArguments,e)}else{if(o.is(p.CommonFlags.GENERIC)){for(var m=new Map,g=assert(o.declaration.typeParameters),y=g.length,E=0;E<y;++E)m.set(g[E].name.text,null);var f=o.declaration.signature.parameters,T=f.length,I=e.arguments,v=I.length,A=new Array(v);for(E=0;E<T;++E){var C=f[E].type,N=C.kind==d.NodeKind.TYPE?C.name.text:null,O=E<v?I[E]:o.declaration.signature.parameters[E].initializer;if(!O)return this.error(c.DiagnosticCode.Expected_0_arguments_but_got_1,e.range,T.toString(10),v.toString(10)),i.createUnreachable();if(null!==N&&m.has(N)){if(k=m.get(N)){A[E]=this.compileExpressionRetainType(O,k,0);var S=void 0;if(!(S=_.Type.commonCompatible(k,this.currentType,!0))&&!(S=_.Type.commonCompatible(k,this.currentType,!1)))return this.error(c.DiagnosticCode.Type_0_is_not_assignable_to_type_1,f[E].type.range,this.currentType.toString(),k.toString()),i.createUnreachable();k=S}else A[E]=this.compileExpressionRetainType(O,_.Type.i32,0),k=this.currentType;m.set(N,k)}else{var L=this.resolver.resolveType(f[E].type,this.currentFunction.flow.contextualTypeArguments);if(!L)return i.createUnreachable();A[E]=this.compileExpression(O,L,1,0)}}var b=new Array(y);for(E=0;E<y;++E){var k=assert(m.get(g[E].name.text));b[E]=k}return(h=this.resolver.resolveFunction(o,b,this.currentFunction.flow.contextualTypeArguments))?this.makeCallDirect(h,A):this.module.createUnreachable()}h=this.resolver.resolveFunction(o,null,this.currentFunction.flow.contextualTypeArguments)}if(!h)return this.module.createUnreachable();var R=0;return h.is(p.CommonFlags.INSTANCE)&&(R=this.compileExpressionRetainType(assert(this.resolver.currentThisExpression),this.options.usizeType,0)),this.compileCallDirect(h,e.arguments,e,R,h.hasDecorator(u.DecoratorFlags.INLINE));case u.ElementKind.LOCAL:if(r=s.type.signatureReference){n=s.is(p.CommonFlags.INLINED)?i.createI32(i64_low(s.constantIntegerValue)):i.createGetLocal(s.index,1);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 u.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 u.ElementKind.FIELD:if(r=(F=s.type).signatureReference){var x=assert(this.resolver.currentThisExpression);R=this.compileExpressionRetainType(x,this.options.usizeType,0);n=i.createLoad(4,!1,R,1,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,F.toString()),i.createUnreachable();case u.ElementKind.FUNCTION_TARGET:r=s.signature,n=this.compileExpression(e.expression,s.type,1,0);break;case u.ElementKind.PROPERTY:var F;if(n=this.compileGetter(s,e.expression),!(r=(F=this.currentType).signatureReference))return this.error(c.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures,e.range,F.toString()),i.createUnreachable();break;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=null,i=t.typeArguments;t.typeArguments&&(e.is(p.CommonFlags.GENERIC)||this.error(c.DiagnosticCode.Type_0_is_not_generic,t.range,e.internalName),n=this.resolver.resolveTypeArguments(assert(e.declaration.typeParameters),i,this.currentFunction.flow.contextualTypeArguments,t));var a=o.compileCall(this,e,n,t.arguments,r,t);return a||(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){if(assert(!e.is(p.CommonFlags.TRAMPOLINE)),!this.currentInlineFunctions.includes(e)){this.currentInlineFunctions.push(e);var o=this.compileCallInlineUnchecked(e,t,r,n);return this.currentInlineFunctions.pop(),o}this.warning(c.DiagnosticCode.Function_0_cannot_be_inlined_into_itself,r.range,e.internalName)}var l=n?a+1:a,u=new Array(l),h=0;n&&(u[0]=n,h=1);for(var d=s.parameterTypes,_=0;_<a;++_,++h)u[h]=this.compileExpression(t[_],d[_],1,0);return assert(h==l),this.makeCallDirect(e,u)},t.prototype.compileCallInlineUnchecked=function(e,t,r,n){var a,s;void 0===n&&(n=0);var o=t.length,h=e.signature,m=this.currentFunction,g=this.module,y=e.prototype.declaration,E=m.flow,f=e.internalName+"|inlined."+(e.nextInlineId++).toString(10),T=e.signature.returnType,I=u.Flow.create(m);I.set(2048),I.returnLabel=f,I.returnType=T,I.contextualTypeArguments=e.contextualTypeArguments;var v=[];if(n){var A=assert(e.parent);if(assert(A.kind==u.ElementKind.CLASS),l.getExpressionId(n)==l.ExpressionId.GetLocal){I.addScopedLocalAlias(l.getGetLocalIndex(n),A.type,"this"),(C=A.base)&&I.addScopedLocalAlias(l.getGetLocalIndex(n),C.type,"super")}else{var C,N=I.addScopedLocal(A.type,"this",!1);v.push(g.createSetLocal(N.index,n)),(C=A.base)&&I.addScopedLocalAlias(N.index,C.type,"super")}}for(var O=h.parameterTypes,S=0;S<o;++S){var L=this.compileExpression(t[S],O[S],1,0);if(l.getExpressionId(L)==l.ExpressionId.GetLocal)I.addScopedLocalAlias(l.getGetLocalIndex(L),O[S],h.getParameterName(S));else{var b=I.addScopedLocal(O[S],h.getParameterName(S),!I.canOverflow(L,O[S]));v.push(g.createSetLocal(b.index,L))}}m.flow=I;var k=h.parameterTypes.length;for(S=o;S<k;++S){var R=this.compileExpression(assert(y.signature.parameters[S].initializer),O[S],1,1);b=I.addScopedLocal(O[S],h.getParameterName(S),!I.canOverflow(R,O[S]));v.push(g.createSetLocal(b.index,R))}var x=assert(y.body);if(x.kind==d.NodeKind.BLOCK)for(var F=x.statements,D=(S=0,F.length);S<D;++S){var B=this.compileStatement(F[S]);if(l.getExpressionId(B)!=l.ExpressionId.Nop&&(v.push(B),I.isAny(29)))break}else v.push(this.compileStatement(x));var U=I.scopedLocals;if(U){try{for(var P=i(U.values()),w=P.next();!w.done;w=P.next()){var M=w.value;M.is(p.CommonFlags.SCOPED)&&m.freeTempLocal(M)}}catch(e){a={error:e}}finally{try{w&&!w.done&&(s=P.return)&&s.call(P)}finally{if(a)throw a.error}}I.scopedLocals=null}return I.finalize(),this.currentFunction.flow=E,this.currentType=T,T==_.Type.void||I.isAny(29)?I.is(1)?g.createBlock(f,v,T.toNativeType()):v.length>1?g.createBlock(null,v,T.toNativeType()):v.length?v[0]:g.createNop():(this.error(c.DiagnosticCode.A_function_whose_declared_type_is_not_void_must_return_a_value,y.signature.returnType.range),g.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.parameters,s=r.returnType,o=r.thisType,h=e.is(p.CommonFlags.INSTANCE),d=r.requiredParameters,m=d,g=i.length,y=g;h&&(++m,++y);var E=assert(y-m),f=new Array(m),T=0,I=this.module;h&&(f[0]=I.createGetLocal(0,this.options.nativeSizeType),T=1);for(var v=0;v<d;++v,++T)f[T]=I.createGetLocal(T,i[v].toNativeType());assert(T==m);var A=new _.Signature(i,s,o),C=n+"|trampoline";A.requiredParameters=g,(t=new u.Function(e.prototype,C,A,e.parent,e.contextualTypeArguments)).set(e.flags|p.CommonFlags.TRAMPOLINE|p.CommonFlags.COMPILED),e.trampoline=t;var N=this.currentFunction;this.currentFunction=t;var O=E+1,S=new Array(O),L="of"+E.toString(10);for(v=0;v<O;++v){var b=v.toString(10)+L;S[v]=b}var k=I.createBlock(S[0],[I.createBlock("outOfRange",[I.createSwitch(S,"outOfRange",d?I.createBinary(l.BinaryOp.SubI32,I.createGetGlobal("~argc",1),I.createI32(d)):I.createGetGlobal("~argc",1))]),I.createUnreachable()]);for(v=0;v<E;++v,++T){var R=i[d+v],x=a[d+v],F=x.initializer,D=void 0;F?D=I.createSetLocal(T,this.compileExpression(F,R,1,1)):(this.error(c.DiagnosticCode.Optional_parameter_must_have_an_initializer,x.range),D=I.createUnreachable()),k=I.createBlock(S[v+1],[k,D]),f[T]=I.createGetLocal(T,R.toNativeType())}this.currentFunction=N,assert(T==y);var B=I.addFunction(C,this.ensureFunctionType(A.parameterTypes,A.returnType,A.thisType),_.typesToNativeTypes(t.additionalLocals),I.createBlock(null,[k,I.createCall(n,f,s.toNativeType())],s.toNativeType()));return t.finalize(I,B),t},t.prototype.ensureArgcVar=function(){if(!this.argcVar){var e=this.module;this.argcVar=e.addGlobal("~argc",1,!0,e.createI32(0))}return"~argc"},t.prototype.ensureArgcSet=function(){if(!this.argcSet){var e=this.module;this.argcSet=e.addFunction("~setargc",this.ensureFunctionType([_.Type.u32],_.Type.void),null,e.createSetGlobal(this.ensureArgcVar(),e.createGetLocal(0,1))),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(p.CommonFlags.INSTANCE)&&(++i,++s,--n),assert(r>=i);var o=this.module;if(!this.compileFunction(e))return o.createUnreachable();var c=e.signature.returnType,l=e.is(p.CommonFlags.MODULE_IMPORT);if(r<s){t||((t=new Array(s)).length=0);for(var u=e.signature.parameterTypes,h=e.prototype.declaration.signature.parameters,_=!0,m=n;m<a;++m){var g=h[m].initializer;if(null===g||!d.nodeIsConstantValue(g.kind)){_=!1;break}}if(_)for(m=n;m<a;++m)t.push(this.compileExpression(h[m].initializer,u[m],1,0));else{for(m=n;m<a;++m)t.push(u[m].toNativeZero(o));if(!l){var y=e;if(e=this.ensureTrampoline(e),!this.compileFunction(e))return o.createUnreachable();e.flow.flags=y.flow.flags,this.program.instancesLookup.set(e.internalName,e);var E=c.toNativeType();return this.currentType=c,o.createBlock(null,[o.createSetGlobal(this.ensureArgcVar(),o.createI32(n)),o.createCall(e.internalName,t,E)],E)}}}return this.currentType=c,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 l=e.parameterTypes,p=0;p<a;++p,++c)o[c]=this.compileExpression(r[p],l[p],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 l=e.parameterTypes,p=i;p<s;++p)r.push(l[p].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],_.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.resolver.resolveElementAccess(e,this.currentFunction);if(!r)return this.module.createUnreachable();switch(r.kind){case u.ElementKind.CLASS:var n=this.currentFunction.flow.is(4096),i=r.lookupOverload(u.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 u.FunctionPrototype(this.program,i,a.internalName+p.INNER_DELIMITER+i,r,null,u.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 l=this.ensureFunctionTableEntry(c);return l<0?this.module.createUnreachable():this.module.createI32(l)},t.prototype.compileIdentifierExpression=function(e,t,r){var n=this.module,i=this.currentFunction;switch(e.kind){case d.NodeKind.NULL:var a=this.options;return t.classReference||(this.currentType=a.usizeType),a.isWasm64?n.createI64(0):n.createI32(0);case d.NodeKind.TRUE:return this.currentType=_.Type.bool,n.createI32(1);case d.NodeKind.FALSE:return this.currentType=_.Type.bool,n.createI32(0);case d.NodeKind.THIS:if((l=i.flow).is(2048))if(h=l.getScopedLocal("this"))return this.currentType=h.type,n.createGetLocal(h.index,h.type.toNativeType());if(i.is(p.CommonFlags.INSTANCE)){var s=assert(i.parent);assert(s.kind==u.ElementKind.CLASS);var o=s.type;return i.is(p.CommonFlags.CONSTRUCTOR)&&!l.is(32)?(l.set(32),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 d.NodeKind.SUPER:var l,h;if((l=i.flow).is(2048))if(h=l.getScopedLocal("this"))if(m=assert(h.type.classReference).base)return this.currentType=m.type,n.createGetLocal(h.index,m.type.toNativeType());if(i.is(p.CommonFlags.INSTANCE)){var m;s=assert(i.parent);if(assert(s.kind==u.ElementKind.CLASS),m=s.base){var g=m.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 y=this.resolver.resolveIdentifier(e,this.currentEnum||i);if(!y)return n.createUnreachable();switch(y.kind){case u.ElementKind.LOCAL:var E=y.type;if(assert(E!=_.Type.void),y.is(p.CommonFlags.INLINED))return this.compileInlineConstant(y,t,r);var f=y.index;return assert(f>=0),this.currentType=E,this.module.createGetLocal(f,E.toNativeType());case u.ElementKind.GLOBAL:if(!this.compileGlobal(y))return this.module.createUnreachable();var T=y.type;return assert(T!=_.Type.void),y.is(p.CommonFlags.INLINED)?this.compileInlineConstant(y,t,r):(this.currentType=T,this.module.createGetGlobal(y.internalName,T.toNativeType()));case u.ElementKind.ENUMVALUE:return y.is(p.CommonFlags.COMPILED)?(this.currentType=_.Type.i32,y.is(p.CommonFlags.INLINED)?this.module.createI32(y.constantValue):this.module.createGetGlobal(y.internalName,1)):(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=_.Type.i32,this.module.createUnreachable());case u.ElementKind.FUNCTION_PROTOTYPE:var I=this.resolver.resolveFunction(y,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.compileInstanceOfExpression=function(e,t){var r=this.module,n=this.compileExpressionRetainType(e.expression,this.options.usizeType,0),i=this.currentType,a=this.resolver.resolveType(e.isType);return this.currentType=_.Type.bool,a?i.is(512)&&!a.is(512)?i.nonNullableType.isAssignableTo(a)?r.createBinary(i.is(64)?l.BinaryOp.NeI64:l.BinaryOp.NeI32,n,i.toNativeZero(r)):r.createI32(0):r.createI32(i.isAssignableTo(a,!0)?1:0):r.createUnreachable()},t.prototype.compileLiteralExpression=function(e,t,r){void 0===r&&(r=!1);var n=this.module;switch(e.literalKind){case d.LiteralKind.ARRAY:assert(!r);var i=t.classReference;return i&&i.prototype==this.program.arrayPrototype?this.compileArrayLiteral(assert(i.typeArguments)[0],e.elementExpressions,!1,e):(this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable());case d.LiteralKind.FLOAT:var a=e.value;return r&&(a=-a),t==_.Type.f32?n.createF32(a):(this.currentType=_.Type.f64,n.createF64(a));case d.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:if(i64_is_i32(s))return n.createI32(i64_low(s));break;case 7:if(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:if(!this.options.isWasm64){if(i64_is_i32(s))return n.createI32(i64_low(s));break}return n.createI64(i64_low(s),i64_high(s));case 9:if(!this.options.isWasm64){if(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=_.Type.i32,n.createI32(i64_low(s))):i64_is_u32(s)?(this.currentType=_.Type.u32,n.createI32(i64_low(s))):(this.currentType=_.Type.i64,n.createI64(i64_low(s),i64_high(s)));case d.LiteralKind.STRING:return assert(!r),this.compileStringLiteral(e);case d.LiteralKind.OBJECT:return assert(!r),this.compileObjectLiteral(e,t)}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.currentType=t,n.createUnreachable()},t.prototype.ensureStaticString=function(e){var t,r=this.program,n=r.hasGC,i=r.gcHeaderSize,a=assert(r.stringInstance),s=this.stringSegments;if(s.has(e))t=s.get(e);else{var c=e.length,l=a.currentMemoryOffset+1&-2,p=l+2*c,u=void 0,h=void 0;n?(u=new Uint8Array(i+p),h=i,m.writeI32(o.ensureGCHook(this,a),u,r.gcHookOffset)):(u=new Uint8Array(p),h=0),m.writeI32(c,u,h+a.offsetof("length")),h+=l;for(var d=0;d<c;++d)m.writeI16(e.charCodeAt(d),u,h+(d<<1));t=this.addMemorySegment(u),s.set(e,t)}var _=t.offset;return n&&(_=i64_add(_,i64_new(i))),this.currentType=a.type,this.options.isWasm64?this.module.createI64(i64_low(_),i64_high(_)):(assert(i64_is_u32(_)),this.module.createI32(i64_low(_)))},t.prototype.compileStringLiteral=function(e){return this.ensureStaticString(e.value)},t.prototype.ensureStaticArray=function(e,t){var r,n,i=this.program,a=i.hasGC,s=i.gcHeaderSize,c=t.length,p=e.byteSize,u=c*p,h=this.options.usizeType.byteSize,d=assert(i.arrayBufferInstance),_=d.currentMemoryOffset+7&-8,g=1<<32-clz(_+u-1);a?(r=new Uint8Array(s+g),n=s,m.writeI32(o.ensureGCHook(this,d),r,i.gcHookOffset)):(r=new Uint8Array(g),n=0),m.writeI32(u,r,n+d.offsetof("byteLength")),n+=_;var y=e.toNativeType();switch(y){case 1:switch(p){case 1:for(var E=0;E<c;++E){var f=t[E];assert(l.getExpressionType(f)==y),assert(l.getExpressionId(f)==l.ExpressionId.Const),m.writeI8(l.getConstValueI32(f),r,n),n+=1}break;case 2:for(E=0;E<c;++E){f=t[E];assert(l.getExpressionType(f)==y),assert(l.getExpressionId(f)==l.ExpressionId.Const),m.writeI16(l.getConstValueI32(f),r,n),n+=2}break;case 4:for(E=0;E<c;++E){f=t[E];assert(l.getExpressionType(f)==y),assert(l.getExpressionId(f)==l.ExpressionId.Const),m.writeI32(l.getConstValueI32(f),r,n),n+=4}break;default:assert(!1)}break;case 2:for(E=0;E<c;++E){f=t[E];assert(l.getExpressionType(f)==y),assert(l.getExpressionId(f)==l.ExpressionId.Const),m.writeI64(i64_new(l.getConstValueI64Low(f),l.getConstValueI64High(f)),r,n),n+=8}break;case 3:for(E=0;E<c;++E){f=t[E];assert(l.getExpressionType(f)==y),assert(l.getExpressionId(f)==l.ExpressionId.Const),m.writeF32(l.getConstValueF32(f),r,n),n+=4}break;case 4:for(E=0;E<c;++E){f=t[E];assert(l.getExpressionType(f)==y),assert(l.getExpressionId(f)==l.ExpressionId.Const),m.writeF64(l.getConstValueF64(f),r,n),n+=8}break;default:assert(!1)}var T=this.addMemorySegment(r).offset;a&&(T=i64_add(T,i64_new(s)));var I=assert(i.arrayPrototype),v=assert(this.resolver.resolveClass(I,[e])),A=v.currentMemoryOffset+7&-8;a?(r=new Uint8Array(s+A),n=s,m.writeI32(o.ensureGCHook(this,v),r,i.gcHookOffset)):(r=new Uint8Array(A),n=0);var C=this.addMemorySegment(r).offset;return a&&(C=i64_add(C,i64_new(s))),this.currentType=v.type,8==h?(m.writeI64(T,r,n+v.offsetof("buffer_")),m.writeI32(c,r,n+v.offsetof("length_")),this.module.createI64(i64_low(C),i64_high(C))):(assert(i64_is_u32(T)),m.writeI32(i64_low(T),r,n+v.offsetof("buffer_")),m.writeI32(c,r,n+v.offsetof("length_")),assert(i64_is_u32(C)),this.module.createI32(i64_low(C)))},t.prototype.compileArrayLiteral=function(e,t,r,n){for(var i=this.module,a=t.length,s=new Array(a),o=new Array(a),p=e.toNativeType(),h=!0,d=0;d<a;++d){var _=t[d]?this.compileExpression(t[d],e,1,0):e.toNativeZero(i);s[d]=_,h&&(_=i.precomputeExpression(s[d]),l.getExpressionId(_)==l.ExpressionId.Const?(assert(l.getExpressionType(_)==p),o[d]=_):(r&&this.warning(c.DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable,n.range),h=!1))}if(h)return this.ensureStaticArray(e,o);var m=assert(this.program.arrayPrototype);if(!m||m.kind!=u.ElementKind.CLASS_PROTOTYPE)return i.createUnreachable();var g=this.resolver.resolveClass(m,[e]);if(!g)return i.createUnreachable();var y=g.type;this.currentType=y;var E=g.lookupOverload(u.OperatorKind.INDEXED_SET,!0);if(!E)return this.error(c.DiagnosticCode.Index_signature_in_type_0_only_permits_reading,n.range,g.internalName),i.createUnreachable();var f=y.toNativeType(),T=this.currentFunction,I=T.addLocal(y),v=new Array(2+a),A=0;v[A++]=i.createSetLocal(I.index,this.makeCallDirect(assert(g.constructorInstance),[i.createI32(0),i.createI32(a)]));for(d=0;d<a;++d)v[A++]=this.makeCallDirect(E,[i.createGetLocal(I.index,f),i.createI32(d),s[d]]);return assert(A+1==v.length),v[A]=i.createGetLocal(I.index,f),T.freeTempLocal(I),this.currentType=y,i.createBlock(null,v,f)},t.prototype.compileObjectLiteral=function(e,t){var r=this.module,n=t.classReference;if(!n||n.is(p.CommonFlags.ABSTRACT))return this.error(c.DiagnosticCode.Type_0_is_not_assignable_to_type_1,e.range,"<object>",t.toString()),r.createUnreachable();var i=n.constructorInstance;if(i){if(i.signature.requiredParameters)return this.error(c.DiagnosticCode.Constructor_of_class_0_must_not_require_any_arguments,e.range,n.toString()),r.createUnreachable();if(i.is(p.CommonFlags.PRIVATE))return this.error(c.DiagnosticCode.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration,e.range,n.toString()),r.createUnreachable();if(i.is(p.CommonFlags.PROTECTED))return this.error(c.DiagnosticCode.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration,e.range,n.toString()),r.createUnreachable()}var a=e.names,s=a.length,l=e.values,h=n.members,d=!1,_=new Array(s+2),m=this.currentFunction.getTempLocal(this.options.usizeType);assert(s==l.length);for(var g=0,y=s;g<y;++g){var E=h?h.get(a[g].text):null;if(E&&E.kind==u.ElementKind.FIELD){var f=E.type;_[g+1]=this.module.createStore(f.byteSize,this.module.createGetLocal(m.index,this.options.nativeSizeType),this.compileExpression(l[g],E.type,1,0),f.toNativeType(),E.memoryOffset)}else this.error(c.DiagnosticCode.Property_0_does_not_exist_on_type_1,a[g].range,a[g].text,n.toString()),d=!0}return this.currentType=n.type.nonNullableType,d?r.createUnreachable():(_[0]=r.createSetLocal(m.index,o.compileAllocate(this,n,e)),_[_.length-1]=r.createGetLocal(m.index,this.options.nativeSizeType),r.createBlock(null,_,this.options.nativeSizeType))},t.prototype.compileNewExpression=function(e,t){var r=this.module,n=(this.options,this.currentFunction),i=this.resolver.resolveExpression(e.expression,n);if(!i)return r.createUnreachable();if(i.kind!=u.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 a,s=i,o=null,l=e.typeArguments;return(o=!l&&null!==(a=t.classReference)&&a.is(p.CommonFlags.GENERIC)?this.resolver.resolveClass(s,a.typeArguments,n.flow.contextualTypeArguments):this.resolver.resolveClassInclTypeArguments(s,l,n.flow.contextualTypeArguments,e))?this.compileInstantiate(o,e.arguments,e):r.createUnreachable()},t.prototype.compileInstantiate=function(e,t,r){var n,i=e,a=null;do{if(a=i.constructorInstance)break}while(i=i.base);return a?n=this.compileCallDirect(a,t,r,this.options.usizeType.toNativeZero(this.module)):(t.length&&this.error(c.DiagnosticCode.Expected_0_arguments_but_got_1,r.range,"0",t.length.toString(10)),n=this.makeAllocate(e,r)),this.currentType=e.type,n},t.prototype.compileParenthesizedExpression=function(e,t){return this.compileExpression(e.expression,t,0,0)},t.prototype.compilePropertyAccessExpression=function(e,t,r){var n=this.module,i=this.resolver.resolvePropertyAccess(e,this.currentFunction);if(!i)return n.createUnreachable();switch(i.kind){case u.ElementKind.GLOBAL:if(!this.compileGlobal(i))return n.createUnreachable();var a=i.type;return assert(a!=_.Type.void),i.is(p.CommonFlags.INLINED)?this.compileInlineConstant(i,t,r):(this.currentType=a,n.createGetGlobal(i.internalName,a.toNativeType()));case u.ElementKind.ENUMVALUE:var s=i.parent;return assert(null!==s&&s.kind==u.ElementKind.ENUM),this.compileEnum(s)?(this.currentType=_.Type.i32,i.is(p.CommonFlags.INLINED)?n.createI32(i.constantValue):n.createGetGlobal(i.internalName,1)):(this.currentType=_.Type.i32,this.module.createUnreachable());case u.ElementKind.FIELD:var o=assert(this.resolver.currentThisExpression);assert(i.memoryOffset>=0);var l=this.compileExpressionRetainType(o,this.options.usizeType,0);return this.currentType=i.type,n.createLoad(i.type.byteSize,i.type.is(5),l,i.type.toNativeType(),i.memoryOffset);case u.ElementKind.PROPERTY:return this.compileGetter(i,e);case u.ElementKind.FUNCTION_PROTOTYPE:return this.error(c.DiagnosticCode.Cannot_access_method_0_without_calling_it_as_it_requires_this_to_be_set,e.range,i.simpleName),n.createUnreachable()}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable()},t.prototype.compileGetter=function(e,t){var r=e.getterPrototype;if(r){var n=this.resolver.resolveFunction(r,null);if(!n)return this.module.createUnreachable();var i=n.signature;if(!this.checkCallSignature(i,0,n.is(p.CommonFlags.INSTANCE),t))return this.module.createUnreachable();var a=0!=(n.decoratorFlags&u.DecoratorFlags.INLINE);if(n.is(p.CommonFlags.INSTANCE)){var s=assert(n.parent);assert(s.kind==u.ElementKind.CLASS);var o=assert(this.resolver.currentThisExpression),l=this.compileExpressionRetainType(o,this.options.usizeType,0);//!!!
|
||
return this.currentType=i.returnType,this.compileCallDirect(n,[],t,l,a)}return this.currentType=i.returnType,this.compileCallDirect(n,[],t,0,a)}return this.error(c.DiagnosticCode.Property_0_does_not_exist_on_type_1,t.range,e.simpleName,e.parent.toString()),this.module.createUnreachable()},t.prototype.compileTernaryExpression=function(e,t){var r=e.ifThen,n=e.ifElse,i=this.currentFunction,a=i.flow,s=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,_.Type.bool,0),this.currentType);if(!this.options.noTreeShaking||this.currentFunction.isAny(p.CommonFlags.GENERIC|p.CommonFlags.GENERIC_CONTEXT)){var o=this.module.precomputeExpression(s);if(l.getExpressionId(o)==l.ExpressionId.Const&&1==l.getExpressionType(o))return l.getConstValueI32(o)?this.compileExpressionRetainType(r,t,0):this.compileExpressionRetainType(n,t,0);s=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,_.Type.bool,0),this.currentType)}var u=a.fork();i.flow=u;var h=this.compileExpressionRetainType(r,t,0),d=this.currentType;u.free();var m=a.fork();i.flow=m;var g=this.compileExpressionRetainType(n,t,0),y=this.currentType;i.flow=m.free(),a.inheritMutual(u,m);var E=_.Type.commonCompatible(d,y,!1);return E?(h=this.convertExpression(h,d,E,1,0,r),g=this.convertExpression(g,y,E,1,0,n),this.currentType=E,this.module.createIf(s,h,g)):(this.error(c.DiagnosticCode.Type_0_is_not_assignable_to_type_1,e.range,d.toString(),y.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==_.Type.void?_.Type.i32:t,0,0);if(l.getExpressionId(i)==l.ExpressionId.Unreachable)return i;var a,s=this.currentType,o=null;switch(t!=_.Type.void&&(o=n.getTempLocal(s,!1),i=r.createTeeLocal(o.index,i)),e.operator){case h.Token.PLUS_PLUS:switch(s.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:a=r.createBinary(l.BinaryOp.AddI32,i,r.createI32(1));break;case 9:if(this.currentType.is(256)){if(d=this.currentType.classReference)if(m=d.lookupOverload(u.OperatorKind.POSTFIX_INC)){a=this.compileUnaryOverload(m,e.operand,i,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),r.createUnreachable()}case 4:var p=this.options;a=r.createBinary(p.isWasm64?l.BinaryOp.AddI64:l.BinaryOp.AddI32,i,s.toNativeOne(r));break;case 3:case 8:a=r.createBinary(l.BinaryOp.AddI64,i,r.createI64(1));break;case 11:a=r.createBinary(l.BinaryOp.AddF32,i,r.createF32(1));break;case 12:a=r.createBinary(l.BinaryOp.AddF64,i,r.createF64(1));break;default:return assert(!1),r.createUnreachable()}break;case h.Token.MINUS_MINUS:switch(s.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:a=r.createBinary(l.BinaryOp.SubI32,i,r.createI32(1));break;case 9:if(this.currentType.is(256)){var d,m;if(d=this.currentType.classReference)if(m=d.lookupOverload(u.OperatorKind.POSTFIX_DEC)){a=this.compileUnaryOverload(m,e.operand,i,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),r.createUnreachable()}case 4:p=this.options;a=r.createBinary(p.isWasm64?l.BinaryOp.SubI64:l.BinaryOp.SubI32,i,s.toNativeOne(r));break;case 3:case 8:a=r.createBinary(l.BinaryOp.SubI64,i,r.createI64(1));break;case 11:a=r.createBinary(l.BinaryOp.SubF32,i,r.createF32(1));break;case 12:a=r.createBinary(l.BinaryOp.SubF64,i,r.createF64(1));break;default:return assert(!1),r.createUnreachable()}break;default:return assert(!1),r.createUnreachable()}if(!o)return this.currentType=_.Type.void,this.compileAssignmentWithValue(e.operand,a,!1);var g=this.compileAssignmentWithValue(e.operand,a,!1);this.currentType=o.type,n.freeTempLocal(o);var y=o.type.toNativeType();return r.createBlock(null,[g,r.createGetLocal(o.index,y)],y)},t.prototype.compileUnaryPrefixExpression=function(e,t){var r,n=this.module,i=!1;switch(e.operator){case h.Token.PLUS:if(r=this.compileExpression(e.operand,t==_.Type.void?_.Type.i32:t,0,0),this.currentType.is(256)){if(a=this.currentType.classReference)if(s=a.lookupOverload(u.OperatorKind.PLUS)){r=this.compileUnaryOverload(s,e.operand,r,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable()}break;case h.Token.MINUS:if(e.operand.kind==d.NodeKind.LITERAL&&(e.operand.literalKind==d.LiteralKind.INTEGER||e.operand.literalKind==d.LiteralKind.FLOAT)){r=this.compileLiteralExpression(e.operand,t,!0),this.options.sourceMap&&this.addDebugLocation(r,e.range);break}if(r=this.compileExpression(e.operand,t==_.Type.void?_.Type.i32:t,0,0),this.currentType.is(256)){if(a=this.currentType.classReference)if(s=a.lookupOverload(u.OperatorKind.MINUS)){r=this.compileUnaryOverload(s,e.operand,r,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable()}switch(this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:r=n.createBinary(l.BinaryOp.SubI32,n.createI32(0),r);break;case 9:case 4:r=n.createBinary(this.options.isWasm64?l.BinaryOp.SubI64:l.BinaryOp.SubI32,this.currentType.toNativeZero(n),r);break;case 3:case 8:r=n.createBinary(l.BinaryOp.SubI64,n.createI64(0),r);break;case 11:r=n.createUnary(l.UnaryOp.NegF32,r);break;case 12:r=n.createUnary(l.UnaryOp.NegF64,r);break;default:assert(!1),r=n.createUnreachable()}break;case h.Token.PLUS_PLUS:if(i=!0,r=this.compileExpression(e.operand,t==_.Type.void?_.Type.i32:t,0,0),this.currentType.is(256)){if(a=this.currentType.classReference)if(s=a.lookupOverload(u.OperatorKind.PREFIX_INC)){r=this.compileUnaryOverload(s,e.operand,r,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable()}switch(this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:r=n.createBinary(l.BinaryOp.AddI32,r,this.module.createI32(1));break;case 9:case 4:r=n.createBinary(this.options.isWasm64?l.BinaryOp.AddI64:l.BinaryOp.AddI32,r,this.currentType.toNativeOne(n));break;case 3:case 8:r=n.createBinary(l.BinaryOp.AddI64,r,n.createI64(1));break;case 11:r=n.createBinary(l.BinaryOp.AddF32,r,n.createF32(1));break;case 12:r=n.createBinary(l.BinaryOp.AddF64,r,n.createF64(1));break;default:assert(!1),r=n.createUnreachable()}break;case h.Token.MINUS_MINUS:if(i=!0,r=this.compileExpression(e.operand,t==_.Type.void?_.Type.i32:t,0,0),this.currentType.is(256)){if(a=this.currentType.classReference)if(s=a.lookupOverload(u.OperatorKind.PREFIX_DEC)){r=this.compileUnaryOverload(s,e.operand,r,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable()}switch(this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:r=n.createBinary(l.BinaryOp.SubI32,r,n.createI32(1));break;case 9:case 4:r=n.createBinary(this.options.isWasm64?l.BinaryOp.SubI64:l.BinaryOp.SubI32,r,this.currentType.toNativeOne(n));break;case 3:case 8:r=n.createBinary(l.BinaryOp.SubI64,r,n.createI64(1));break;case 11:r=n.createBinary(l.BinaryOp.SubF32,r,n.createF32(1));break;case 12:r=n.createBinary(l.BinaryOp.SubF64,r,n.createF64(1));break;default:assert(!1),r=n.createUnreachable()}break;case h.Token.EXCLAMATION:if(r=this.compileExpression(e.operand,t==_.Type.void?_.Type.i32:t,0,0),this.currentType.is(256))if(a=this.currentType.classReference)if(s=a.lookupOverload(u.OperatorKind.NOT)){r=this.compileUnaryOverload(s,e.operand,r,e);break}r=this.makeIsFalseish(r,this.currentType),this.currentType=_.Type.bool;break;case h.Token.TILDE:if(r=this.compileExpression(e.operand,t==_.Type.void?_.Type.i32:t.is(8)?_.Type.i64:t,0,0),this.currentType.is(256)){var a,s;if(a=this.currentType.classReference)if(s=a.lookupOverload(u.OperatorKind.BITWISE_NOT)){r=this.compileUnaryOverload(s,e.operand,r,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable()}switch(r=this.convertExpression(r,this.currentType,this.currentType.intType,1,0,e.operand),this.currentType.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:r=n.createBinary(l.BinaryOp.XorI32,r,n.createI32(-1));break;case 9:case 4:r=n.createBinary(this.options.isWasm64?l.BinaryOp.XorI64:l.BinaryOp.XorI32,r,this.currentType.toNativeNegOne(n));break;case 3:case 8:r=n.createBinary(l.BinaryOp.XorI64,r,n.createI64(-1,-1));break;default:assert(!1),r=n.createUnreachable()}break;case h.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!=_.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(l.UnaryOp.ExtendI8ToI32,e):r.createBinary(l.BinaryOp.ShrI32,r.createBinary(l.BinaryOp.ShlI32,e,r.createI32(24)),r.createI32(24)));break;case 1:n.canOverflow(e,t)&&(e=this.options.hasFeature(1)?r.createUnary(l.UnaryOp.ExtendI16ToI32,e):r.createBinary(l.BinaryOp.ShrI32,r.createBinary(l.BinaryOp.ShlI32,e,r.createI32(16)),r.createI32(16)));break;case 5:n.canOverflow(e,t)&&(e=r.createBinary(l.BinaryOp.AndI32,e,r.createI32(255)));break;case 6:n.canOverflow(e,t)&&(e=r.createBinary(l.BinaryOp.AndI32,e,r.createI32(65535)));break;case 10:n.canOverflow(e,t)&&(e=r.createBinary(l.BinaryOp.NeI32,e,r.createI32(0)))}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(l.UnaryOp.EqzI32,e);case 3:case 8:return r.createUnary(l.UnaryOp.EqzI64,e);case 9:case 4:return r.createUnary(64==t.size?l.UnaryOp.EqzI64:l.UnaryOp.EqzI32,e);case 11:return r.createBinary(l.BinaryOp.EqF32,e,r.createF32(0));case 12:return r.createBinary(l.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(l.BinaryOp.NeI64,e,r.createI64(0));case 9:case 4:return 64==t.size?r.createBinary(l.BinaryOp.NeI64,e,r.createI64(0)):e;case 11:return r.createBinary(l.BinaryOp.NeF32,e,r.createF32(0));case 12:return r.createBinary(l.BinaryOp.NeF64,e,r.createF64(0));default:return assert(!1),r.createI32(0)}},t.prototype.makeAllocate=function(e,t){var r,n,a=this.module,s=this.currentFunction,c=this.options.nativeSizeType,l=s.getTempLocal(e.type,!1),h=new Array;if(h.push(a.createSetLocal(l.index,o.compileAllocate(this,e,t))),e.members)try{for(var d=i(e.members.values()),_=d.next();!_.done;_=d.next()){var m=_.value;if(m.kind==u.ElementKind.FIELD){var g=m,y=g.type,E=y.toNativeType(),f=g.prototype.declaration;if(assert(!g.isAny(p.CommonFlags.CONST)),f.initializer)h.push(a.createStore(y.byteSize,a.createGetLocal(l.index,c),this.compileExpression(f.initializer,y,1,0),E,g.memoryOffset));else{var T=g.prototype.declaration.parameterIndex;h.push(a.createStore(y.byteSize,a.createGetLocal(l.index,c),T>=0?a.createGetLocal(1+T,E):y.toNativeZero(a),E,g.memoryOffset))}}}}catch(e){r={error:e}}finally{try{_&&!_.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}return h.push(a.createGetLocal(l.index,c)),s.freeTempLocal(l),this.currentType=e.type,a.createBlock(null,h,c)},t.prototype.makeConditionalAllocate=function(e,t){var r=this.module,n=this.options.nativeSizeType;return this.currentType=e.type,r.createIf(2==n?r.createBinary(l.BinaryOp.NeI64,r.createGetLocal(0,2),r.createI64(0)):r.createGetLocal(0,1),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 T(e,t){if(y=t.range.source.simplePath,E=t.programLevelInternalName,e.hasDecorator(u.DecoratorFlags.EXTERNAL)){var r=e.program,n=assert(d.findDecorator(d.DecoratorKind.EXTERNAL,t.decorators)),i=n.arguments;if(i&&i.length){var a=i[0];a.kind==d.NodeKind.LITERAL&&a.literalKind==d.LiteralKind.STRING?(E=a.value,i.length>=2&&((a=i[1]).kind==d.NodeKind.LITERAL&&a.literalKind==d.LiteralKind.STRING?(y=E,E=a.value,i.length>2&&r.error(c.DiagnosticCode.Expected_0_arguments_but_got_1,n.range,"2",i.length.toString())):r.error(c.DiagnosticCode.String_literal_expected,a.range))):r.error(c.DiagnosticCode.String_literal_expected,a.range)}else r.error(c.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,n.range,"1","0")}}t.Compiler=f},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.User_defined_0=102]="User_defined_0",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.An_allocator_must_be_declared_to_allocate_memory_Try_importing_allocator_arena_or_allocator_tlsf=214]="An_allocator_must_be_declared_to_allocate_memory_Try_importing_allocator_arena_or_allocator_tlsf",e[e.Optional_parameter_must_have_an_initializer=215]="Optional_parameter_must_have_an_initializer",e[e.Constructor_of_class_0_must_not_require_any_arguments=216]="Constructor_of_class_0_must_not_require_any_arguments",e[e.Function_0_cannot_be_inlined_into_itself=217]="Function_0_cannot_be_inlined_into_itself",e[e.Cannot_access_method_0_without_calling_it_as_it_requires_this_to_be_set=218]="Cannot_access_method_0_without_calling_it_as_it_requires_this_to_be_set",e[e.Optional_properties_are_not_supported=219]="Optional_properties_are_not_supported",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.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.Enum_member_must_have_initializer=1061]="Enum_member_must_have_initializer",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.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract=1245]="Method_0_cannot_have_an_implementation_because_it_is_marked_abstract",e[e.A_definite_assignment_assertion_is_not_permitted_in_this_context=1255]="A_definite_assignment_assertion_is_not_permitted_in_this_context",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.In_const_enum_declarations_member_initializer_must_be_constant_expression=2474]="In_const_enum_declarations_member_initializer_must_be_constant_expression",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.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration=2673]="Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration",e[e.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration=2674]="Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration",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",e[e.Numeric_separators_are_not_allowed_here=6188]="Numeric_separators_are_not_allowed_here",e[e.Multiple_consecutive_numeric_separators_are_not_permitted=6189]="Multiple_consecutive_numeric_separators_are_not_permitted"}(t.DiagnosticCode||(t.DiagnosticCode={})),t.diagnosticCodeToString=function(e){switch(e){case 100:return"Operation not supported.";case 101:return"Operation is unsafe.";case 102:return"User-defined: {0}";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 214:return"An allocator must be declared to allocate memory. Try importing allocator/arena or allocator/tlsf.";case 215:return"Optional parameter must have an initializer.";case 216:return"Constructor of class '{0}' must not require any arguments.";case 217:return"Function '{0}' cannot be inlined into itself.";case 218:return"Cannot access method '{0}' without calling it as it requires 'this' to be set.";case 219:return"Optional properties are not supported.";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 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 1061:return"Enum member must have initializer.";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 1245:return"Method '{0}' cannot have an implementation because it is marked abstract.";case 1255:return"A definite assignment assertion '!' is not permitted in this context.";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 2474:return"In 'const' enum declarations member initializer must be constant expression.";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 2673:return"Constructor of class '{0}' is private and only accessible within the class declaration.";case 2674:return"Constructor of class '{0}' is protected and only accessible within the class declaration.";case 2694:return"Namespace '{0}' has no exported member '{1}'.";case 6054:return"File '{0}' not found.";case 6188:return"Numeric separators are not allowed here.";case 6189:return"Multiple consecutive numeric separators are not permitted.";default:return""}}},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),i=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}},a=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),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 s,o=r(1),c=r(4),l=r(3),p=r(6),u=r(0);!function(e){e[e.REPORT=0]="REPORT",e[e.SWALLOW=1]="SWALLOW"}(s=t.ReportMode||(t.ReportMode={}));var h=function(e){function t(t){var r=e.call(this,t.diagnostics)||this;return r.currentThisExpression=null,r.currentElementExpression=null,r.program=t,r}return n(t,e),t.prototype.resolveType=function(e,t,r){if(void 0===t&&(t=null),void 0===r&&(r=s.REPORT),e.kind==l.NodeKind.SIGNATURE){var n=this.resolveSignature(e,t,r);return n?e.isNullable?n.type.asNullable():n.type:null}assert(e.kind==l.NodeKind.TYPE);var i=e,a=i.name.text,h=a,d=i.range.source.internalPath+u.PATH_DELIMITER+a,_=this.program.elementsLookup,m=void 0;if((m=_.get(d))||(m=_.get(h)))switch(m.kind){case c.ElementKind.ENUM:return null!==i.typeArguments&&i.typeArguments.length?(r==s.REPORT&&this.error(o.DiagnosticCode.Type_0_is_not_generic,e.range,m.internalName),null):p.Type.i32;case c.ElementKind.CLASS_PROTOTYPE:var g=this.resolveClassInclTypeArguments(m,i.typeArguments,t,e);return g?e.isNullable?g.type.asNullable():g.type:null}var y=this.program.typeAliases.get(a);if(y)return this.resolveType(y.type,t,r);var E=i.typeArguments;if(E){for(var f=E.length,T=new Array(f),I=0;I<f;++I){var v=this.resolveType(E[I],t,r);if(!v)return null;T[I]=v}if(f){var A=p.typesToString(T);A.length&&(d+="<"+A+">",h+="<"+A+">")}else if(t){var C=t.get(h);if(C)return C}}var N=this.program.typesLookup,O=void 0;return(O=N.get(d))||(O=N.get(h))?O:(r==s.REPORT&&this.error(o.DiagnosticCode.Cannot_find_name_0,i.name.range,h),null)},t.prototype.resolveSignature=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r=s.REPORT);var n=e.explicitThisType,i=null;if(n&&!(i=this.resolveType(n,t,r)))return null;for(var a=e.parameters,o=a.length,c=new Array(o),u=new Array(o),h=0,d=!1,_=0;_<o;++_){var m=a[_];switch(m.parameterKind){case l.ParameterKind.DEFAULT:h=_+1;break;case l.ParameterKind.REST:assert(_==o),d=!0}var g=this.resolveType(assert(m.type),t,r);if(!g)return null;c[_]=g,u[_]=m.name.text}var y,E=e.returnType;if(E){if(!(y=this.resolveType(E,t,r)))return null}else y=p.Type.void;var f=new p.Signature(c,y,i);return f.parameterNames=u,f.requiredParameters=h,f.hasRest=d,f},t.prototype.resolveTypeArguments=function(e,t,r,n,i){void 0===r&&(r=null),void 0===n&&(n=null),void 0===i&&(i=s.REPORT);var a=e.length,c=t?t.length:0;if(a!=c)return c?this.error(o.DiagnosticCode.Expected_0_type_arguments_but_got_1,l.Range.join(t[0].range,t[c-1].range),a.toString(10),c.toString(10)):n&&this.error(o.DiagnosticCode.Expected_0_type_arguments_but_got_1,n.range.atEnd,a.toString(10),"0"),null;for(var p=new Array(a),u=0;u<a;++u){var h=this.resolveType(t[u],r,i);if(!h)return null;p[u]=h}return p},t.prototype.resolveIdentifier=function(e,t,r){void 0===r&&(r=s.REPORT);var n,i=e.text;if(t){switch(t.kind){case c.ElementKind.FUNCTION:if(n=t.flow.getScopedLocal(i))return this.currentThisExpression=null,this.currentElementExpression=null,n;t=t.prototype.parent;break;case c.ElementKind.CLASS:t=t.prototype.parent}for(;t;){var a=t.members;if(a&&(n=a.get(i)))return this.currentThisExpression=null,this.currentElementExpression=null,n;t=t.parent}}var l=this.program.elementsLookup;return(n=l.get(e.range.source.internalPath+u.PATH_DELIMITER+i))?(this.currentThisExpression=null,this.currentElementExpression=null,n):(n=l.get(i))?(this.currentThisExpression=null,this.currentElementExpression=null,n):(r==s.REPORT&&this.error(o.DiagnosticCode.Cannot_find_name_0,e.range,i),null)},t.prototype.ensureResolvedLazyGlobal=function(e,t){if(void 0===t&&(t=s.REPORT),e.is(u.CommonFlags.RESOLVED))return!0;var r=assert(e.declaration).type;if(!r)return!1;var n=this.resolveType(r,null,t);return!!n&&(e.type=n,e.set(u.CommonFlags.RESOLVED),!0)},t.prototype.resolvePropertyAccess=function(e,t,r){void 0===r&&(r=s.REPORT);var n=e.expression,i=this.resolveExpression(n,t,r);if(!i)return null;var a=e.property.text;switch(i.kind){case c.ElementKind.GLOBAL:if(!this.ensureResolvedLazyGlobal(i,r))return null;case c.ElementKind.LOCAL:case c.ElementKind.FIELD:var l=i.type;if(assert(l!=p.Type.void),!(u=l.classReference))return this.error(o.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.property.range,a,i.type.toString()),null;i=u;break;case c.ElementKind.PROPERTY:var u,h=this.resolveFunction(assert(i.getterPrototype),null,null,r);if(!h)return null;if(!(u=h.signature.returnType.classReference))return this.error(o.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.property.range,a,h.signature.returnType.toString()),null;i=u;break;case c.ElementKind.CLASS:var d=this.currentElementExpression;if(d){var _=i.lookupOverload(c.OperatorKind.INDEXED_GET);if(!_)return this.error(o.DiagnosticCode.Index_signature_is_missing_in_type_0,d.range,i.internalName),null;var m=_.signature.returnType;if(!(i=m.classReference))return this.error(o.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.property.range,a,m.toString()),null}}switch(i.kind){case c.ElementKind.CLASS_PROTOTYPE:case c.ElementKind.CLASS:for(;;){var g=void 0;if((y=i.members)&&(g=y.get(a)))return this.currentThisExpression=n,this.currentElementExpression=null,g;if(i.kind==c.ElementKind.CLASS_PROTOTYPE){if(!i.basePrototype)break;i=i.basePrototype}else{if(i.kind!=c.ElementKind.CLASS)break;if(!i.base)break;i=i.base}}break;default:var y;if(y=i.members)if(g=y.get(a))return this.currentThisExpression=n,this.currentElementExpression=null,g}return this.error(o.DiagnosticCode.Property_0_does_not_exist_on_type_1,e.property.range,a,i.internalName),null},t.prototype.resolveElementAccess=function(e,t,r){void 0===r&&(r=s.REPORT);var n=e.expression,i=this.resolveExpression(n,t,r);if(!i)return null;switch(i.kind){case c.ElementKind.GLOBAL:if(!this.ensureResolvedLazyGlobal(i,r))return null;case c.ElementKind.LOCAL:case c.ElementKind.FIELD:if(i=i.type.classReference)return this.currentThisExpression=n,this.currentElementExpression=e.elementExpression,i;break;case c.ElementKind.CLASS:var a=i.lookupOverload(c.OperatorKind.INDEXED_GET);return a?n.kind==l.NodeKind.ELEMENTACCESS?(i=a.signature.returnType.classReference)?(this.currentThisExpression=n,this.currentElementExpression=e.elementExpression,i):null:(this.currentThisExpression=n,this.currentElementExpression=e.elementExpression,i):(r==s.REPORT&&this.error(o.DiagnosticCode.Index_signature_is_missing_in_type_0,e.range,i.internalName),null)}return r==s.REPORT&&this.error(o.DiagnosticCode.Operation_not_supported,n.range),null},t.prototype.resolveExpression=function(e,t,r){for(void 0===r&&(r=s.REPORT);e.kind==l.NodeKind.PARENTHESIZED;)e=e.expression;switch(e.kind){case l.NodeKind.ASSERTION:var n=this.resolveType(e.toType,t.flow.contextualTypeArguments,r);if(n)if(d=n.classReference)return this.currentThisExpression=null,this.currentElementExpression=null,d;return null;case l.NodeKind.BINARY:throw new Error("not implemented");case l.NodeKind.THIS:if(t.flow.is(2048))if(i=t.flow.getScopedLocal("this"))return this.currentThisExpression=null,this.currentElementExpression=null,i;return(a=t.parent)?(this.currentThisExpression=null,this.currentElementExpression=null,a):(r==s.REPORT&&this.error(o.DiagnosticCode._this_cannot_be_referenced_in_current_location,e.range),null);case l.NodeKind.SUPER:var i,a;if(t.flow.is(2048))if(i=t.flow.getScopedLocal("super"))return this.currentThisExpression=null,this.currentElementExpression=null,i;return(a=t.parent)&&a.kind==c.ElementKind.CLASS&&(a=a.base)?(this.currentThisExpression=null,this.currentElementExpression=null,a):(r==s.REPORT&&this.error(o.DiagnosticCode._super_can_only_be_referenced_in_a_derived_class,e.range),null);case l.NodeKind.IDENTIFIER:return this.resolveIdentifier(e,t,r);case l.NodeKind.LITERAL:switch(e.literalKind){case l.LiteralKind.STRING:return this.currentThisExpression=e,this.currentElementExpression=null,this.program.stringInstance}break;case l.NodeKind.PROPERTYACCESS:return this.resolvePropertyAccess(e,t,r);case l.NodeKind.ELEMENTACCESS:return this.resolveElementAccess(e,t,r);case l.NodeKind.CALL:var p=e.expression,u=this.resolveExpression(p,t,r);if(!u)return null;if(u.kind==c.ElementKind.FUNCTION_PROTOTYPE){var h=this.resolveFunctionInclTypeArguments(u,e.typeArguments,t.flow.contextualTypeArguments,e,r);if(!h)return null;var d,_=h.signature.returnType;if(d=_.classReference)return d;var m=_.signatureReference;if(m){var g=m.cachedFunctionTarget;return g||(g=new c.FunctionTarget(this.program,m),m.cachedFunctionTarget=g),g}return r==s.REPORT&&this.error(o.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures,p.range,u.internalName),null}}return r==s.REPORT&&this.error(o.DiagnosticCode.Operation_not_supported,e.range),null},t.prototype.resolveFunction=function(e,t,r,n){var o,h;void 0===r&&(r=null),void 0===n&&(n=s.REPORT);var d=e.classTypeArguments,_=d?p.typesToString(d):"",m=t?p.typesToString(t):"",g=e.instances.get(_);if(g){var y=g.get(m);if(y)return y}var E=e.declaration,f=e.is(u.CommonFlags.INSTANCE),T=e.classPrototype,I=r;if(r=new Map,I)try{for(var v=i(I),A=v.next();!A.done;A=v.next()){var C=a(A.value,2),N=C[0],O=C[1];r.set(N,O)}}catch(e){o={error:e}}finally{try{A&&!A.done&&(h=v.return)&&h.call(v)}finally{if(o)throw o.error}}if(d){assert(e.is(u.CommonFlags.INSTANCE));var S=assert(T).declaration.typeParameters,L=S.length;assert(L==d.length);for(var b=0;b<L;++b)r.set(S[b].name.text,d[b])}else assert(!d);var k,R=E.signature,x=E.typeParameters;if(t&&(k=t.length)){assert(x&&k==x.length);for(b=0;b<k;++b)r.set(x[b].name.text,t[b])}else assert(!x||0==x.length);var F=null,D=null;if(f){if(!(F=this.resolveClass(assert(T),d,r,n)))return null;D=F.type,r.set("this",D)}var B,U=R.parameters,P=U.length,w=new Array(P),M=new Array(P),G=0;for(b=0;b<P;++b){var K=U[b];K.parameterKind==l.ParameterKind.DEFAULT&&(G=b+1);var z=assert(K.type),V=this.resolveType(z,r,n);if(!V)return null;w[b]=V,M[b]=K.name.text}if(e.is(u.CommonFlags.SET))B=p.Type.void;else if(e.is(u.CommonFlags.CONSTRUCTOR))B=assert(F).type;else{z=assert(R.returnType);var H=this.resolveType(z,r,n);if(!H)return null;B=H}var X=new p.Signature(w,B,D);X.parameterNames=M,X.requiredParameters=G;var W=e.internalName;m.length&&(W+="<"+m+">");var Y=new c.Function(e,W,X,F||T,r);return g||e.instances.set(_,g=new Map),g.set(m,Y),this.program.instancesLookup.set(W,Y),Y},t.prototype.resolveFunctionPartially=function(e,t,r){void 0===r&&(r=s.REPORT),assert(e.is(u.CommonFlags.INSTANCE));var n=assert(e.classPrototype);if(!t||!t.length)return e;var i=e.simpleName,a=p.typesToString(t),o=new c.FunctionPrototype(this.program,i,n.internalName+"<"+a+">"+u.INSTANCE_DELIMITER+i,e.declaration,n,e.decoratorFlags);return o.flags=e.flags,o.operatorKind=e.operatorKind,o.classTypeArguments=t,o.instances=e.instances,o},t.prototype.resolveFunctionInclTypeArguments=function(e,t,r,n,i){void 0===i&&(i=s.REPORT);var a=null;return!e.is(u.CommonFlags.GENERIC)||(assert(null!=t&&0!=t.length),a=this.resolveTypeArguments(assert(e.declaration.typeParameters),t,r,n,i))?this.resolveFunction(e,a,r,i):null},t.prototype.resolveClass=function(e,t,r,n){var h,d,_,m,g,y,E,f;void 0===r&&(r=null),void 0===n&&(n=s.REPORT);var T=t?p.typesToString(t):"",I=e.instances.get(T);if(I)return I;var v=r;if(r=new Map,v)try{for(var A=i(v),C=A.next();!C.done;C=A.next()){var N=a(C.value,2),O=N[0],S=N[1];r.set(O,S)}}catch(e){h={error:e}}finally{try{C&&!C.done&&(d=A.return)&&d.call(A)}finally{if(h)throw h.error}}var L=e.declaration;if(t){var b=L.typeParameters,k=b.length,R=t.length;assert(R==k);for(var x=0;x<R;++x)r.set(b[x].name.text,t[x])}else assert(0==L.typeParameters.length);var F=null;if(L.extendsType){var D=this.resolveType(L.extendsType,r,n);if(!D)return null;if(!(F=D.classReference))return n==s.REPORT&&this.program.error(o.DiagnosticCode.A_class_may_only_extend_another_class,L.extendsType.range),null;if(F.hasDecorator(c.DecoratorFlags.SEALED))return n==s.REPORT&&this.program.error(o.DiagnosticCode.Class_0_is_sealed_and_cannot_be_extended,L.extendsType.range,F.internalName),null;if(F.hasDecorator(c.DecoratorFlags.UNMANAGED)!=e.hasDecorator(c.DecoratorFlags.UNMANAGED))return n==s.REPORT&&this.program.error(o.DiagnosticCode.Unmanaged_classes_cannot_extend_managed_classes_and_vice_versa,l.Range.join(L.name.range,L.extendsType.range)),null}var B=e.simpleName,U=e.internalName;T.length&&(B+="<"+T+">",U+="<"+T+">"),(I=new c.Class(e,B,U,t,F)).contextualTypeArguments=r,e.instances.set(T,I),this.program.instancesLookup.set(U,I);var P=0;if(F){if(F.members){I.members||(I.members=new Map);try{for(var w=i(F.members.values()),M=w.next();!M.done;M=w.next()){var G=M.value;I.members.set(G.simpleName,G)}}catch(e){_={error:e}}finally{try{M&&!M.done&&(m=w.return)&&m.call(w)}finally{if(_)throw _.error}}}P=F.currentMemoryOffset}if(e.constructorPrototype){var K=this.resolveFunctionPartially(e.constructorPrototype,t,n);if(!K)return null;I.constructorInstance=this.resolveFunction(K,null,null,n)}if(e.instanceMembers)try{for(var z=i(e.instanceMembers.values()),V=z.next();!V.done;V=z.next()){var H=V.value;switch(H.kind){case c.ElementKind.FIELD_PROTOTYPE:I.members||(I.members=new Map);var X=H.declaration,W=null;if(X.type)W=this.resolveType(X.type,I.contextualTypeArguments,n);else{if(null!==F&&null!==F.members){var Y=F.members.get(H.simpleName);Y&&!Y.is(u.CommonFlags.PRIVATE)&&(assert(Y.kind==c.ElementKind.FIELD),W=Y.type)}W||n==s.REPORT&&this.error(o.DiagnosticCode.Type_expected,X.name.range.atEnd)}if(!W)break;var Q=new c.Field(H,U+u.INSTANCE_DELIMITER+H.simpleName,W,X,I);switch(W.byteSize){case 1:break;case 2:1&P&&++P;break;case 4:3&P&&(P=1+(3|P));break;case 8:7&P&&(P=1+(7|P));break;default:assert(!1)}Q.memoryOffset=P,P+=W.byteSize,I.members.set(H.simpleName,Q);break;case c.ElementKind.FUNCTION_PROTOTYPE:I.members||(I.members=new Map);var q=this.resolveFunctionPartially(H,t,n);if(!q)return null;q.internalName=U+u.INSTANCE_DELIMITER+q.simpleName,I.members.set(H.simpleName,q);break;case c.ElementKind.PROPERTY:I.members||(I.members=new Map);var j=assert(H.getterPrototype),Z=H.setterPrototype,J=new c.Property(this.program,H.simpleName,U+u.INSTANCE_DELIMITER+H.simpleName,e),$=this.resolveFunctionPartially(j,t,n);if(!$)return null;if($.internalName=U+u.INSTANCE_DELIMITER+$.simpleName,J.getterPrototype=$,Z){var ee=this.resolveFunctionPartially(Z,t,n);if(!ee)return null;ee.internalName=U+u.INSTANCE_DELIMITER+ee.simpleName,J.setterPrototype=ee}I.members.set(H.simpleName,J);break;default:assert(!1)}}}catch(e){g={error:e}}finally{try{V&&!V.done&&(y=z.return)&&y.call(z)}finally{if(g)throw g.error}}I.currentMemoryOffset=P;try{for(var te=i(e.overloadPrototypes),re=te.next();!re.done;re=te.next()){var ne=a(re.value,2),ie=ne[0],ae=ne[1];assert(ie!=c.OperatorKind.INVALID);var se=void 0;if(ae.is(u.CommonFlags.INSTANCE)){var oe=this.resolveFunctionPartially(ae,t,n);if(!oe)continue;se=this.resolveFunction(oe,null,null,n)}else se=this.resolveFunction(ae,null,null,n);if(se){var ce=I.overloads;ce||(I.overloads=ce=new Map),ce.set(ie,se)}}}catch(e){E={error:e}}finally{try{re&&!re.done&&(f=te.return)&&f.call(te)}finally{if(E)throw E.error}}return I},t.prototype.resolveClassInclTypeArguments=function(e,t,r,n,i){void 0===i&&(i=s.REPORT);var a=null;if(e.is(u.CommonFlags.GENERIC)){var c=e.declaration.typeParameters,l=c.length;assert(l>0);var p=null!==t?t.length:0;if(l!=p)return i==s.REPORT&&this.error(o.DiagnosticCode.Expected_0_type_arguments_but_got_1,n.range,l.toString(10),p.toString(10)),null;if(!(a=this.resolveTypeArguments(c,t,r,n,i)))return null}else if(null!==t&&t.length)return i==s.REPORT&&this.error(o.DiagnosticCode.Type_0_is_not_generic,n.range,e.internalName),null;return this.resolveClass(e,a,r,i)},t}(o.DiagnosticEmitter);t.Resolver=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(5),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(0==c?(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.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 1:return void this.push(n.getConstValueI32(e).toString(10));case 2:return void this.push(i64_to_string(i64_new(n.getConstValueI64Low(e),n.getConstValueI64High(e))));case 3:return void this.push(n.getConstValueF32(e).toString(10));case 4: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("memory.size()");case n.HostOp.GrowMemory:return this.push("memory.grow("),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 0:return"void";case 1:return"i32";case 2:return"i64";case 3:return"f32";case 4:return"f64";case 5:throw new Error("unreachable type");case-1:throw new Error("auto type");default:throw new Error("unexpected type")}}t.Decompiler=i},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),i=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}},a=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),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 s=r(0),o=r(4),c=r(2),l=function(){function e(e,t){void 0===t&&(t=!1),this.todo=[],this.seen=new Set,this.program=e,this.includePrivate}return e.prototype.walk=function(){var e,t;try{for(var r=i(this.program.moduleLevelExports.values()),n=r.next();!n.done;n=r.next()){var a=n.value;this.visitElement(a.element)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}for(var s=this.todo;0<s.length;)this.visitElement(s[0])},e.prototype.visitElement=function(e){if((!e.is(s.CommonFlags.PRIVATE)||this.includePrivate)&&!this.seen.has(e))switch(this.seen.add(e),e.kind){case o.ElementKind.GLOBAL:e.is(s.CommonFlags.COMPILED)&&this.visitGlobal(e);break;case o.ElementKind.ENUM:e.is(s.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(s.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,n,a,c,l,p,u,h;var d=t.members;if(d)try{for(var _=i(d.values()),m=_.next();!m.done;m=_.next()){var g=m.value;switch(g.kind){case o.ElementKind.FUNCTION_PROTOTYPE:try{for(var y=i(g.instances.values()),E=y.next();!E.done;E=y.next()){var f=E.value;try{for(var T=i(f.values()),I=T.next();!I.done;I=T.next()){var v=I.value;if(v.is(s.CommonFlags.COMPILED))return!0}}catch(e){l={error:e}}finally{try{I&&!I.done&&(p=T.return)&&p.call(T)}finally{if(l)throw l.error}}}}catch(e){a={error:e}}finally{try{E&&!E.done&&(c=y.return)&&c.call(y)}finally{if(a)throw a.error}}break;case o.ElementKind.CLASS_PROTOTYPE:try{for(var A=i(g.instances.values()),C=A.next();!C.done;C=A.next()){var v=C.value;if(v.is(s.CommonFlags.COMPILED))return!0}}catch(e){u={error:e}}finally{try{C&&!C.done&&(h=A.return)&&h.call(A)}finally{if(u)throw u.error}}break;default:if(g.is(s.CommonFlags.COMPILED)||e(g))return!0}}}catch(e){r={error:e}}finally{try{m&&!m.done&&(n=_.return)&&n.call(_)}finally{if(r)throw r.error}}return!1})(e)&&this.visitNamespace(e);break;default:assert(!1)}},e.prototype.visitFunctionInstances=function(e){var t,r,n,a;try{for(var o=i(e.instances.values()),c=o.next();!c.done;c=o.next()){var l=c.value;try{for(var p=i(l.values()),u=p.next();!u.done;u=p.next()){var h=u.value;h.is(s.CommonFlags.COMPILED)&&this.visitFunction(h)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(a=p.return)&&a.call(p)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}},e.prototype.visitClassInstances=function(e){var t,r;try{for(var n=i(e.instances.values()),a=n.next();!a.done;a=n.next()){var o=a.value;o.is(s.CommonFlags.COMPILED)&&this.visitClass(o)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},e}(),p=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 n(t,e),t.build=function(e){return new t(e).build()},t.prototype.visitGlobal=function(e){var t=this.sb,r=e.is(s.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,r,n,l,p=this.sb;c.indent(p,this.indentLevel++),p.push("interface "),p.push(e.simpleName),p.push(" {\n");var u=e.members;if(u){try{for(var h=i(u),d=h.next();!d.done;d=h.next()){var _=a(d.value,2),m=_[0];if((f=_[1]).kind==o.ElementKind.ENUMVALUE){var g=f.is(s.CommonFlags.INLINED);c.indent(p,this.indentLevel),g?p.push("const "):p.push("readonly "),p.push("unsigned long "),p.push(m),g&&(p.push(" = "),p.push(f.constantValue.toString(10))),p.push(";\n")}}}catch(e){t={error:e}}finally{try{d&&!d.done&&(r=h.return)&&r.call(h)}finally{if(t)throw t.error}}try{for(var y=i(u.values()),E=y.next();!E.done;E=y.next()){var f;(f=E.value).kind!=o.ElementKind.ENUMVALUE&&this.visitElement(f)}}catch(e){n={error:e}}finally{try{E&&!E.done&&(l=y.return)&&l.call(y)}finally{if(n)throw n.error}}}c.indent(p,--this.indentLevel),p.push("}\n")},t.prototype.visitFunction=function(e){var t,r,n=this.sb,a=e.signature;c.indent(n,this.indentLevel),n.push(this.typeToString(a.returnType)),n.push(" "),n.push(e.simpleName),n.push("(");for(var s=a.parameterTypes,o=s.length,l=0;l<o;++l)l&&n.push(", "),n.push(this.typeToString(s[l])),n.push(" "),n.push(a.getParameterName(l));n.push(");\n");var p=e.members;if(p&&p.size){c.indent(n,this.indentLevel),n.push("interface "),n.push(e.simpleName),n.push(" {\n");try{for(var u=i(p.values()),h=u.next();!h.done;h=u.next()){var d=h.value;this.visitElement(d)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}c.indent(n,--this.indentLevel),n.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,r,n=this.sb;c.indent(n,this.indentLevel++),n.push("interface "),n.push(e.simpleName),n.push(" {\n");var a=e.members;if(a)try{for(var s=i(a.values()),o=s.next();!o.done;o=s.next()){var l=o.value;this.visitElement(l)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}c.indent(n,--this.indentLevel),n.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}(l);t.IDLBuilder=p;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 n(t,e),t.build=function(e){return new t(e).build()},t.prototype.visitGlobal=function(e){var t=this.sb,r=e.is(s.CommonFlags.INLINED);c.indent(t,this.indentLevel),e.is(s.CommonFlags.STATIC)?r?t.push("static readonly "):t.push("static "):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,r,n=this.sb;c.indent(n,this.indentLevel++),n.push("enum "),n.push(e.simpleName),n.push(" {\n");var l=e.members;if(l){var p=l.size;try{for(var u=i(l),h=u.next();!h.done;h=u.next()){var d=a(h.value,2),_=d[0],m=d[1];m.kind==o.ElementKind.ENUMVALUE&&(c.indent(n,this.indentLevel),n.push(_),m.is(s.CommonFlags.INLINED)&&(n.push(" = "),n.push(m.constantValue.toString(10))),n.push(",\n"),--p)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}p&&this.visitNamespace(e)}c.indent(n,--this.indentLevel),n.push("}\n")},t.prototype.visitFunction=function(e){if(!e.isAny(s.CommonFlags.PRIVATE|s.CommonFlags.SET)){var t=this.sb,r=e.signature;if(c.indent(t,this.indentLevel),e.is(s.CommonFlags.PROTECTED)&&t.push("protected "),e.is(s.CommonFlags.STATIC)&&t.push("static "),e.is(s.CommonFlags.GET))return t.push(e.prototype.declaration.name.text),t.push(": "),t.push(this.typeToString(r.returnType)),void t.push(";\n");e.isAny(s.CommonFlags.STATIC|s.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(s.CommonFlags.CONSTRUCTOR|s.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,r,n,a,l=this.sb,p=e.kind==o.ElementKind.INTERFACE;c.indent(l,this.indentLevel++),p?l.push("interface "):(e.is(s.CommonFlags.ABSTRACT)&&l.push("abstract "),l.push("class ")),l.push(e.simpleName);var u=e.base;u&&u.is(s.CommonFlags.COMPILED|s.CommonFlags.MODULE_EXPORT)&&(l.push(" extends "),l.push(u.simpleName)),l.push(" {\n");var h=e.prototype.members;if(h)try{for(var d=i(h.values()),_=d.next();!_.done;_=d.next()){var m=_.value;this.visitElement(m)}}catch(e){t={error:e}}finally{try{_&&!_.done&&(r=d.return)&&r.call(d)}finally{if(t)throw t.error}}var g=e.constructorInstance;if(g&&this.visitFunction(g),h=e.members)try{for(var y=i(h.values()),E=y.next();!E.done;E=y.next()){m=E.value;this.visitElement(m)}}catch(e){n={error:e}}finally{try{E&&!E.done&&(a=y.return)&&a.call(y)}finally{if(n)throw n.error}}c.indent(l,--this.indentLevel),l.push("}\n")},t.prototype.visitInterface=function(e){this.visitClass(e)},t.prototype.visitField=function(e){if(!e.is(s.CommonFlags.PRIVATE)){var t=this.sb;c.indent(t,this.indentLevel),e.is(s.CommonFlags.PROTECTED)&&t.push("protected "),e.is(s.CommonFlags.STATIC)&&t.push("static "),e.is(s.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 a=this.sb;c.indent(a,this.indentLevel++),a.push("namespace "),a.push(e.simpleName),a.push(" {\n");try{for(var s=i(n.values()),o=s.next();!o.done;o=s.next()){var l=o.value;this.visitElement(l)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}c.indent(a,--this.indentLevel),a.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"),e.push("export default ASModule;\n"),this.sb.join("")},t}(l);t.TSDBuilder=u},function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),a=r(4),s=r(8),o=r(1),c=r(2),l=r(3),p=function(e){function t(){var t=e.call(this)||this;return t.backlog=new Array,t.seenlog=new Set,t.donelog=new Set,t.onComment=null,t.tryParseSignatureIsSignature=!1,t.parseParametersThis=null,t.program=new a.Program(t.diagnostics),t}return n(t,e),t.prototype.parseFile=function(e,t,r){var n=c.normalizePath(t),a=l.mangleInternalPath(n);if(!this.donelog.has(a)){this.donelog.add(a),this.seenlog.add(a);var o=new l.Source(n,e,r?l.SourceKind.ENTRY:t.startsWith(i.LIBRARY_PREFIX)&&t.indexOf(i.PATH_DELIMITER,i.LIBRARY_PREFIX.length)<0?l.SourceKind.LIBRARY:l.SourceKind.DEFAULT),p=this.program;p.sources.push(o);var u=new s.Tokenizer(o,p.diagnostics);u.onComment=this.onComment,o.tokenizer=u;for(var h=o.statements;!u.skip(s.Token.ENDOFFILE);){var d=this.parseTopLevelStatement(u);d&&(d.parent=o,h.push(d))}u.finish()}},t.prototype.parseTopLevelStatement=function(e,t){void 0===t&&(t=null);for(var r=i.CommonFlags.NONE,n=-1,a=null;e.skip(s.Token.AT);){n<0&&(n=e.tokenPos);var c=this.parseDecorator(e);c?(a||(a=[]),a.push(c)):this.skipStatement(e)}var l=0,p=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|=i.CommonFlags.EXPORT,l=e.tokenPos,p=e.pos);var u=null!=t&&t.is(i.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|=i.CommonFlags.DECLARE|i.CommonFlags.AMBIENT):u&&(r|=i.CommonFlags.AMBIENT);var h=null,d=e.peek();switch(n<0&&(n=e.nextTokenPos),d){case s.Token.CONST:if(e.next(),r|=i.CommonFlags.CONST,e.skip(s.Token.ENUM)){h=this.parseEnum(e,r,a,n);break}h=this.parseVariable(e,r,a,n),a=null;break;case s.Token.LET:r|=i.CommonFlags.LET;case s.Token.VAR:e.next(),h=this.parseVariable(e,r,a,n),a=null;break;case s.Token.ENUM:e.next(),h=this.parseEnum(e,r,a,n),a=null;break;case s.Token.FUNCTION:e.next(),h=this.parseFunction(e,r,a,n),a=null;break;case s.Token.ABSTRACT:var _=e.mark();if(e.next(),!e.skip(s.Token.CLASS)){e.reset(_),h=this.parseStatement(e,!0);break}e.discard(_),r|=i.CommonFlags.ABSTRACT;case s.Token.CLASS:case s.Token.INTERFACE:e.next(),h=this.parseClassOrInterface(e,r,a,n),a=null;break;case s.Token.NAMESPACE:_=e.mark();e.next(),e.peek(!1,s.IdentifierHandling.PREFER)==s.Token.IDENTIFIER?(e.discard(_),h=this.parseNamespace(e,r,a,n),a=null):(e.reset(_),h=this.parseStatement(e,!0));break;case s.Token.IMPORT:e.next(),h=(r|=i.CommonFlags.IMPORT)&i.CommonFlags.EXPORT?this.parseExportImport(e,n):this.parseImport(e);break;case s.Token.TYPE:_=e.mark();e.next(),e.peek(!1,s.IdentifierHandling.PREFER)==s.Token.IDENTIFIER?(e.discard(_),h=this.parseTypeDeclaration(e,r,a,n),a=null):(e.reset(_),h=this.parseStatement(e,!0));break;default:r&i.CommonFlags.EXPORT?h=this.parseExport(e,r,n):(p&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(l,p),"export"),t||(h=this.parseStatement(e,!0)))}if(a)for(var m=0,g=a.length;m<g;++m)this.error(o.DiagnosticCode.Decorators_are_not_valid_here,a[m].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.donelog.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.OPENPAREN){var c=e.skip(s.Token.OPENPAREN),p=this.tryParseSignature(e);if(p){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"),p.isNullable=!0}return p}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.VOID)n=l.Node.createType(l.Node.createIdentifierExpression("void",e.range()),[],!1,e.range(a,e.pos));else if(i==s.Token.THIS)n=l.Node.createType(l.Node.createThisExpression(e.range()),[],!1,e.range(a,e.pos));else if(i==s.Token.TRUE||i==s.Token.FALSE)n=l.Node.createType(l.Node.createIdentifierExpression("bool",e.range()),[],!1,e.range(a,e.pos));else if(i==s.Token.STRINGLITERAL)e.readString(),n=l.Node.createType(l.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=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),d=new Array,_=!1;if(e.skip(s.Token.LESSTHAN)){do{var m=this.parseType(e,!0,r);if(!m)return null;d.push(m)}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=l.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 y=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=l.Node.createType(l.Node.createIdentifierExpression("Array",y),[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 p=l.ParameterKind.DEFAULT;if(e.skip(s.Token.DOT_DOT_DOT)&&(c=!0,e.discard(r),p=l.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!=l.NodeKind.TYPE)return this.error(o.DiagnosticCode.Operation_not_supported,u.range),this.tryParseSignatureIsSignature=!0,null;a=u}else{if(!e.skipIdentifier())return c?this.error(o.DiagnosticCode.Identifier_expected,e.range()):e.reset(r),this.tryParseSignatureIsSignature=c,null;var h=l.Node.createIdentifierExpression(e.readIdentifier(),e.range(e.tokenPos,e.pos));if(e.skip(s.Token.QUESTION)&&(c=!0,e.discard(r),p==l.ParameterKind.REST?this.error(o.DiagnosticCode.A_rest_parameter_cannot_be_optional,e.range()):p=l.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 l.ParameterNode;_.parameterKind=p,_.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 c?this.error(o.DiagnosticCode._0_expected,e.range(),")"):e.reset(r),this.tryParseSignatureIsSignature=c,null}return e.skip(s.Token.EQUALS_GREATERTHAN)?(c=!0,e.discard(r),(t=this.parseType(e))?(this.tryParseSignatureIsSignature=!0,l.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.skipIdentifier()){for(var r=e.readIdentifier(),n=l.Node.createIdentifierExpression(r,e.range(t,e.pos));e.skip(s.Token.DOT);){if(!e.skipIdentifier())return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;r=e.readIdentifier(),n=l.Node.createPropertyAccessExpression(n,l.Node.createIdentifierExpression(r,e.range()),e.range(t,e.pos))}var i=void 0;if(!e.skip(s.Token.OPENPAREN))return l.Node.createDecorator(n,null,e.range(t,e.pos));if(i=this.parseArguments(e))return l.Node.createDecorator(n,i,e.range(t,e.pos))}else this.error(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=l.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.skipIdentifier())return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;var n=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),a=t;e.skip(s.Token.EXCLAMATION)&&(a|=i.CommonFlags.DEFINITE_ASSIGNMENT);var c=null;e.skip(s.Token.COLON)&&(c=this.parseType(e));var p=null;if(e.skip(s.Token.EQUALS)){if(a&i.CommonFlags.AMBIENT&&this.error(o.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts,e.range()),!(p=this.parseExpression(e,2)))return null}else a&i.CommonFlags.CONST?a&i.CommonFlags.AMBIENT||this.error(o.DiagnosticCode._const_declarations_must_be_initialized,n.range):c||this.error(o.DiagnosticCode.Type_expected,e.range(e.pos));var u=s.Range.join(n.range,e.range());return a&i.CommonFlags.DEFINITE_ASSIGNMENT&&p&&this.error(o.DiagnosticCode.A_definite_assignment_assertion_is_not_permitted_in_this_context,u),l.Node.createVariableDeclaration(n,c,p,r,a,u)},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 a=l.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 p=this.parseEnumValue(e,i.CommonFlags.NONE);if(!p)return null;if(c.push(p),!e.skip(s.Token.COMMA)){if(e.skip(s.Token.CLOSEBRACE))break;return this.error(o.DiagnosticCode._0_expected,e.range(),"}"),null}}var u=l.Node.createEnumDeclaration(a,c,r,t,e.range(n,e.pos));return e.skip(s.Token.SEMICOLON),u},t.prototype.parseEnumValue=function(e,t){if(!e.skipIdentifier())return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;var r=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),n=null;return e.skip(s.Token.EQUALS)&&!(n=this.parseExpression(e,2))?null:l.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=l.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=l.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!=l.NodeKind.TYPE)return this.error(o.DiagnosticCode.Operation_not_supported,n.range),null;r=n}return l.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);var r=new Array,n=null,i=!1,a=!1,c=null;if(this.parseParametersThis=null,e.skip(s.Token.THIS)){if(!e.skip(s.Token.COLON))return this.error(o.DiagnosticCode._0_expected,e.range(),":"),null;if(!(c=this.parseType(e)))return null;if(c.kind==l.NodeKind.TYPE?this.parseParametersThis=c:this.error(o.DiagnosticCode.Operation_not_supported,c.range),!e.skip(s.Token.COMMA))return e.skip(s.Token.CLOSEPAREN)?r:(this.error(o.DiagnosticCode._0_expected,e.range(),")"),null)}for(;!e.skip(s.Token.CLOSEPAREN);){var p=this.parseParameter(e,t);if(!p)return null;switch(n&&!a&&(this.error(o.DiagnosticCode.A_rest_parameter_must_be_last_in_a_parameter_list,n.name.range),a=!0),p.parameterKind){default:i&&this.error(o.DiagnosticCode.A_required_parameter_cannot_follow_an_optional_parameter,p.name.range);break;case l.ParameterKind.OPTIONAL:i=!0;break;case l.ParameterKind.REST:n=p}if(r.push(p),!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,a=null,c=i.CommonFlags.NONE;if(t&&(e.skip(s.Token.PUBLIC)?(a=e.range(),c|=i.CommonFlags.PUBLIC):e.skip(s.Token.PROTECTED)?(a=e.range(),c|=i.CommonFlags.PROTECTED):e.skip(s.Token.PRIVATE)&&(a=e.range(),c|=i.CommonFlags.PRIVATE),e.peek()==s.Token.READONLY)){var p=e.mark();e.next(),e.peek()!=s.Token.COLON?(e.discard(p),a||(a=e.range()),c|=i.CommonFlags.READONLY):e.reset(p)}if(e.skip(s.Token.DOT_DOT_DOT)&&(c?this.error(o.DiagnosticCode.A_parameter_property_cannot_be_declared_using_a_rest_parameter,e.range()):a=e.range(),r=!0),e.skipIdentifier()){r||(a=e.range());var u=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),h=null;if((n=e.skip(s.Token.QUESTION))&&r&&this.error(o.DiagnosticCode.A_rest_parameter_cannot_be_optional,u.range),e.skip(s.Token.COLON)){if(!(h=this.parseType(e)))return null}else h=l.Node.createOmittedType(e.range(e.pos));var d=null;if(e.skip(s.Token.EQUALS)&&(r&&this.error(o.DiagnosticCode.A_rest_parameter_cannot_have_an_initializer,u.range),n?this.error(o.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer,u.range):n=!0,!(d=this.parseExpression(e,2))))return null;var _=l.Node.createParameter(u,h,d,r?l.ParameterKind.REST:n?l.ParameterKind.OPTIONAL:l.ParameterKind.DEFAULT,s.Range.join(a,e.range()));return _.flags|=c,_}return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null},t.prototype.parseFunction=function(e,t,r,n){if(!e.skipIdentifier())return this.error(o.DiagnosticCode.Identifier_expected,e.range(e.pos)),null;var a=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),c=-1,p=null;if(e.skip(s.Token.LESSTHAN)){if(c=e.tokenPos,!(p=this.parseTypeParameters(e)))return null;t|=i.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=this.parseParametersThis,d=0!=(t&i.CommonFlags.SET);d&&(1!=u.length&&this.error(o.DiagnosticCode.A_set_accessor_must_have_exactly_one_parameter,a.range),u.length&&u[0].initializer&&this.error(o.DiagnosticCode.A_set_accessor_parameter_cannot_have_an_initializer,a.range)),t&i.CommonFlags.GET&&u.length&&this.error(o.DiagnosticCode.A_get_accessor_cannot_have_parameters,a.range);var _=null;if(e.skip(s.Token.COLON)&&!(_=this.parseType(e,!0,d)))return null;_||(_=l.Node.createOmittedType(e.range(e.pos)),d||this.error(o.DiagnosticCode.Type_expected,_.range));var m=l.Node.createSignature(u,_,h,!1,e.range(c,e.pos)),g=null;if(e.skip(s.Token.OPENBRACE)){if(t&i.CommonFlags.AMBIENT&&this.error(o.DiagnosticCode.An_implementation_cannot_be_declared_in_ambient_contexts,e.range()),!(g=this.parseBlockStatement(e,!1)))return null}else t&i.CommonFlags.AMBIENT||this.error(o.DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration,e.range(e.pos));var y=l.Node.createFunctionDeclaration(a,p,m,g,r,t,e.range(n,e.pos));return e.skip(s.Token.SEMICOLON),y},t.prototype.parseFunctionExpression=function(e){var t,r=e.tokenPos,n=!1;if(e.token==s.Token.FUNCTION){if(t=e.skipIdentifier()?l.Node.createIdentifierExpression(e.readIdentifier(),e.range()):l.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=l.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,a,c){void 0===a&&(a=-1),void 0===c&&(c=-1),a<0&&(a=t.range.start),c<0&&(c=a);var p=null;if(e.skip(s.Token.COLON)){if(!(p=this.parseType(e)))return null}else p=l.Node.createOmittedType(e.range(e.pos)),this.error(o.DiagnosticCode.Type_expected,p.range);if(n&&!e.skip(s.Token.EQUALS_GREATERTHAN))return this.error(o.DiagnosticCode._0_expected,e.range(e.pos),"=>"),null;var u,h=l.Node.createSignature(r,p,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=l.Node.createFunctionDeclaration(t,null,h,u,null,n?i.CommonFlags.ARROW:i.CommonFlags.NONE,e.range(a,e.pos));return l.Node.createFunctionExpression(d)},t.prototype.parseClassOrInterface=function(e,t,r,n){var a=e.token==s.Token.INTERFACE;if(!e.skipIdentifier())return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;var c,p=l.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.skip(s.Token.LESSTHAN)){if(!(c=this.parseTypeParameters(e)))return null;t|=i.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!=l.NodeKind.TYPE)return this.error(o.DiagnosticCode.Operation_not_supported,h.range),null;u=h}var d=null;if(e.skip(s.Token.IMPLEMENTS)){a&&this.error(o.DiagnosticCode.Interface_declaration_cannot_have_implements_clause,e.range());do{var _=this.parseType(e);if(!_)return null;a||(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 m,g=new Array;if(a?(assert(!d),m=l.Node.createInterfaceDeclaration(p,c,u,g,r,t,e.range(n,e.pos))):m=l.Node.createClassDeclaration(p,c,u,d,g,r,t,e.range(n,e.pos)),!e.skip(s.Token.CLOSEBRACE))do{var y=this.parseClassMember(e,m);if(!y)return null;y.parent=m,g.push(y)}while(!e.skip(s.Token.CLOSEBRACE));return m},t.prototype.parseClassExpression=function(e){var t,r=e.tokenPos;if(t=e.skipIdentifier()?l.Node.createIdentifierExpression(e.readIdentifier(),e.range()):l.Node.createEmptyIdentifierExpression(e.range(e.pos)),!e.skip(s.Token.OPENBRACE))return this.error(o.DiagnosticCode._0_expected,e.range(e.pos),"{"),null;var n=new Array,a=l.Node.createClassDeclaration(t,[],null,null,n,null,i.CommonFlags.NONE,e.range(r,e.pos));if(!e.skip(s.Token.CLOSEBRACE))do{var c=this.parseClassMember(e,a);if(!c)return null;c.parent=a,n.push(c)}while(!e.skip(s.Token.CLOSEBRACE));return l.Node.createClassExpression(a)},t.prototype.parseClassMember=function(e,t){for(var r=e.pos,n=t.kind==l.NodeKind.INTERFACEDECLARATION,a=new Array;e.skip(s.Token.AT);){var c=this.parseDecorator(e);if(!c)break;n&&this.error(o.DiagnosticCode.Decorators_are_not_valid_here,c.range),a.push(c)}var p=t.flags&i.CommonFlags.AMBIENT;n&&(p|=i.CommonFlags.VIRTUAL),e.skip(s.Token.PUBLIC)?(n&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(),"public"),p|=i.CommonFlags.PUBLIC):e.skip(s.Token.PRIVATE)?(n&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(),"private"),p|=i.CommonFlags.PRIVATE):e.skip(s.Token.PROTECTED)&&(n&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(),"protected"),p|=i.CommonFlags.PROTECTED);var u=0,h=0,d=0,_=0;e.skip(s.Token.STATIC)?(n&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(),"static"),p|=i.CommonFlags.STATIC,u=e.tokenPos,h=e.pos):(p|=i.CommonFlags.INSTANCE,e.skip(s.Token.ABSTRACT)&&(n&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(),"abstract"),p|=i.CommonFlags.ABSTRACT,d=e.tokenPos,_=e.pos),t.flags&i.CommonFlags.GENERIC&&(p|=i.CommonFlags.GENERIC_CONTEXT));var m=0,g=0;e.skip(s.Token.READONLY)&&(p|=i.CommonFlags.READONLY,m=e.tokenPos,g=e.pos);var y=e.mark(),E=!1,f=!1,T=!1,I=0,v=0;if(n||(e.skip(s.Token.GET)?e.peek(!0,s.IdentifierHandling.PREFER)!=s.Token.IDENTIFIER||e.nextTokenOnNewLine?e.reset(y):(p|=i.CommonFlags.GET,f=!0,I=e.tokenPos,v=e.pos,p&i.CommonFlags.READONLY&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(m,g),"readonly")):e.skip(s.Token.SET)?e.peek(!0,s.IdentifierHandling.PREFER)!=s.Token.IDENTIFIER||e.nextTokenOnNewLine?e.reset(y):(p|=i.CommonFlags.SET|i.CommonFlags.SET,T=!0,I=e.tokenPos,v=e.pos,p&i.CommonFlags.READONLY&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(m,g),"readonly")):e.skip(s.Token.CONSTRUCTOR)&&(E=!0,(p|=i.CommonFlags.CONSTRUCTOR)&i.CommonFlags.STATIC&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(u,h),"static"),p&i.CommonFlags.ABSTRACT&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(d,_),"abstract"),p&i.CommonFlags.READONLY&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(m,g),"readonly"))),!E&&!e.skipIdentifier())return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;var A=E?l.Node.createConstructorExpression(e.range()):l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),C=null;if(e.skip(s.Token.LESSTHAN)){var N=e.tokenPos;if(!(C=this.parseTypeParameters(e)))return null;E?this.error(o.DiagnosticCode.Type_parameters_cannot_appear_on_a_constructor_declaration,e.range(N,e.pos)):f||T?this.error(o.DiagnosticCode.An_accessor_cannot_have_type_parameters,e.range(N,e.pos)):p|=i.CommonFlags.GENERIC}if(e.skip(s.Token.OPENPAREN)){var O=e.tokenPos,S=this.parseParameters(e,E);if(!S)return null;var L=this.parseParametersThis;if(E)for(var b=0,k=S.length;b<k;++b){var R=S[b];if(R.isAny(i.CommonFlags.PUBLIC|i.CommonFlags.PROTECTED|i.CommonFlags.PRIVATE|i.CommonFlags.READONLY)){var x=l.Node.createFieldDeclaration(R.name,R.type,null,null,R.flags|i.CommonFlags.INSTANCE,R.range);x.parameterIndex=b,x.parent=t,R.implicitFieldDeclaration=x,t.members.push(x)}}else f?S.length&&this.error(o.DiagnosticCode.A_get_accessor_cannot_have_parameters,A.range):T&&(1!=S.length&&this.error(o.DiagnosticCode.A_set_accessor_must_have_exactly_one_parameter,A.range),S.length&&S[0].initializer&&this.error(o.DiagnosticCode.A_set_accessor_parameter_cannot_have_an_initializer,A.range));var F=null;if(e.skip(s.Token.COLON)){if(A.kind==l.NodeKind.CONSTRUCTOR?this.error(o.DiagnosticCode.Type_annotation_cannot_appear_on_a_constructor_declaration,e.range()):T&&this.error(o.DiagnosticCode.A_set_accessor_cannot_have_a_return_type_annotation,e.range()),!(F=this.parseType(e,A.kind==l.NodeKind.CONSTRUCTOR||T)))return null}else F=l.Node.createOmittedType(e.range(e.pos)),T||A.kind==l.NodeKind.CONSTRUCTOR||this.error(o.DiagnosticCode.Type_expected,F.range);var D=l.Node.createSignature(S,F,L,!1,e.range(O,e.pos)),B=null;if(e.skip(s.Token.OPENBRACE)){if(p&i.CommonFlags.AMBIENT?this.error(o.DiagnosticCode.An_implementation_cannot_be_declared_in_ambient_contexts,e.range()):p&i.CommonFlags.ABSTRACT&&this.error(o.DiagnosticCode.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract,e.range(),A.text),!(B=this.parseBlockStatement(e,!1)))return null}else p&i.CommonFlags.AMBIENT||n||this.error(o.DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration,e.range());var U=l.Node.createMethodDeclaration(A,C,D,B,a,p,e.range(r,e.pos));return e.skip(s.Token.SEMICOLON),U}if(E)this.error(o.DiagnosticCode.Constructor_implementation_is_missing,A.range);else{if(!f&&!T){p&i.CommonFlags.ABSTRACT&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(d,_),"abstract"),p&i.CommonFlags.GET&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(0,0),"get"),p&i.CommonFlags.SET&&this.error(o.DiagnosticCode._0_modifier_cannot_be_used_here,e.range(I,v),"set");var P=null;if(e.skip(s.Token.QUESTION)&&this.error(o.DiagnosticCode.Optional_properties_are_not_supported,e.range(r,e.pos)),e.skip(s.Token.EXCLAMATION)&&(p|=i.CommonFlags.DEFINITE_ASSIGNMENT),e.skip(s.Token.COLON)){if(!(P=this.parseType(e)))return null}else this.error(o.DiagnosticCode.Type_expected,e.range());var w=null;if(e.skip(s.Token.EQUALS)&&!(w=this.parseExpression(e)))return null;var M=e.range(r,e.pos);p&i.CommonFlags.DEFINITE_ASSIGNMENT&&(p&i.CommonFlags.STATIC||n||w)&&this.error(o.DiagnosticCode.A_definite_assignment_assertion_is_not_permitted_in_this_context,M);var G=l.Node.createFieldDeclaration(A,P,w,a,p,M);return e.skip(s.Token.SEMICOLON),G}this.error(o.DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration,A.range)}return null},t.prototype.parseNamespace=function(e,t,r,n){if(e.skipIdentifier()){var i=l.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.skip(s.Token.OPENBRACE)){for(var a=new Array,c=l.Node.createNamespaceDeclaration(i,a,r,t,e.range(n,e.pos));!e.skip(s.Token.CLOSEBRACE);){var p=this.parseTopLevelStatement(e,c);if(!p)return null;p.parent=c,a.push(p)}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){var n=null;if(e.skip(s.Token.OPENBRACE)){for(var i=new Array;!e.skip(s.Token.CLOSEBRACE);){var a=this.parseExportMember(e);if(!a)return null;if(i.push(a),!e.skip(s.Token.COMMA)){if(e.skip(s.Token.CLOSEBRACE))break;return this.error(o.DiagnosticCode._0_expected,e.range(),"}"),null}}if(e.skip(s.Token.FROM)){if(!e.skip(s.Token.STRINGLITERAL))return this.error(o.DiagnosticCode.String_literal_expected,e.range()),null;n=l.Node.createStringLiteralExpression(e.readString(),e.range())}return null===(p=(c=l.Node.createExportStatement(i,n,t,e.range(r,e.pos))).internalPath)||this.seenlog.has(p)||(this.backlog.push(p),this.seenlog.add(p)),e.skip(s.Token.SEMICOLON),c}if(e.skip(s.Token.ASTERISK))if(e.skip(s.Token.FROM)){if(e.skip(s.Token.STRINGLITERAL)){n=l.Node.createStringLiteralExpression(e.readString(),e.range());var c=l.Node.createExportStatement(null,n,t,e.range(r,e.pos)),p=assert(c.internalPath),u=e.source;return u.exportPaths||(u.exportPaths=new Set),u.exportPaths.add(p),this.seenlog.has(p)||(this.backlog.push(p),this.seenlog.add(p)),e.skip(s.Token.SEMICOLON),c}this.error(o.DiagnosticCode.String_literal_expected,e.range())}else this.error(o.DiagnosticCode._0_expected,e.range(),"from");else this.error(o.DiagnosticCode._0_expected,e.range(),"{");return null},t.prototype.parseExportMember=function(e){if(e.skipIdentifier()){var t=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),r=null;if(e.skip(s.Token.AS)){if(!e.skipIdentifier(s.IdentifierHandling.ALWAYS))return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;r=l.Node.createIdentifierExpression(e.readIdentifier(),e.range())}return l.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))for(r=new Array;!e.skip(s.Token.CLOSEBRACE);){var a=this.parseImportDeclaration(e);if(!a)return null;if(r.push(a),!e.skip(s.Token.COMMA)){if(e.skip(s.Token.CLOSEBRACE))break;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.skipIdentifier())return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;n=l.Node.createIdentifierExpression(e.readIdentifier(),e.range())}else i=!0;if(i||e.skip(s.Token.FROM)){if(e.skip(s.Token.STRINGLITERAL)){var c=l.Node.createStringLiteralExpression(e.readString(),e.range()),p=void 0;n?(assert(!r),p=l.Node.createImportStatementWithWildcard(n,c,e.range(t,e.pos))):p=l.Node.createImportStatement(r,c,e.range(t,e.pos));var u=p.internalPath;return this.seenlog.has(u)||(this.backlog.push(u),this.seenlog.add(u)),e.skip(s.Token.SEMICOLON),p}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.skipIdentifier(s.IdentifierHandling.ALWAYS)){var t=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),r=null;if(e.skip(s.Token.AS)){if(!e.skipIdentifier())return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;r=l.Node.createIdentifierExpression(e.readIdentifier(),e.range())}return l.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.skipIdentifier()){var r=l.Node.createIdentifierExpression(e.readIdentifier(),e.range());if(e.skip(s.Token.EQUALS)){if(e.skipIdentifier()){var n=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),i=l.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,i.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,i.CommonFlags.LET,null,e.tokenPos);break;case s.Token.VAR:n=this.parseVariable(e,i.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 l.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.VOID:n=this.parseVoidStatement(e);break;case s.Token.WHILE:n=this.parseWhileStatement(e);break;case s.Token.TYPE:if(e.peek(!1,s.IdentifierHandling.PREFER)==s.Token.IDENTIFIER){n=this.parseTypeDeclaration(e,i.CommonFlags.NONE,null,e.tokenPos);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);if(a)e.discard(i),n.push(a);else{if(e.token==s.Token.ENDOFFILE)return null;e.reset(i),this.skipStatement(e)}}var o=l.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(s.IdentifierHandling.PREFER),t=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()));var r=l.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(s.IdentifierHandling.PREFER),t=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()));var r=l.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=l.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=l.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,i.CommonFlags.CONST,null,e.tokenPos);else if(e.skip(s.Token.LET))r=this.parseVariable(e,i.CommonFlags.LET,null,e.tokenPos);else if(e.skip(s.Token.VAR))r=this.parseVariable(e,i.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 a=null;if(!e.skip(s.Token.CLOSEPAREN)){if(!(a=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?l.Node.createForStatement(r,n?n.expression:null,a,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:l.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=l.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 l.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 l.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=l.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.skipIdentifier())return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;if(i=l.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 p=l.Node.createTryStatement(n,i,a,c,e.range(r,e.pos));return e.skip(s.Token.SEMICOLON),p}return this.error(o.DiagnosticCode._0_expected,e.range(),"{"),null},t.prototype.parseTypeDeclaration=function(e,t,r,n){if(e.skipIdentifier()){var a=l.Node.createIdentifierExpression(e.readIdentifier(),e.range()),c=null;if(e.skip(s.Token.LESSTHAN)){if(!(c=this.parseTypeParameters(e)))return null;t|=i.CommonFlags.GENERIC}if(e.skip(s.Token.EQUALS)){var p=this.parseType(e);if(!p)return null;var u=l.Node.createTypeDeclaration(a,c,p,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,21);if(!r)return null;var n=l.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=l.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(s.IdentifierHandling.PREFER),r=e.tokenPos,n=function(e){switch(e){case s.Token.DOT_DOT_DOT:return 2;case s.Token.YIELD:return 3;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 17;case s.Token.NEW:return 20}return 0}(t);if(0!=n){var a=void 0;return t==s.Token.NEW?(a=this.parseExpression(e,19))?a.kind==l.NodeKind.CALL?l.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,n))?(t!=s.Token.PLUS_PLUS&&t!=s.Token.MINUS_MINUS||a.kind!=l.NodeKind.IDENTIFIER&&a.kind!=l.NodeKind.ELEMENTACCESS&&a.kind!=l.NodeKind.PROPERTYACCESS&&this.error(o.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access,a.range),l.Node.createUnaryPrefixExpression(t,a,e.range(r,e.pos))):null}var c=null;switch(t){case s.Token.NULL:return l.Node.createNullExpression(e.range());case s.Token.TRUE:return l.Node.createTrueExpression(e.range());case s.Token.FALSE:return l.Node.createFalseExpression(e.range());case s.Token.OPENPAREN:if(e.skip(s.Token.CLOSEPAREN))return this.parseFunctionExpressionCommon(e,l.Node.createEmptyIdentifierExpression(e.range(r)),[],!0);var p=e.mark(),u=!0;do{switch(e.next(s.IdentifierHandling.PREFER)){case s.Token.DOT_DOT_DOT:return e.reset(p),this.parseFunctionExpression(e);case s.Token.IDENTIFIER:switch(e.readIdentifier(),e.next()){case s.Token.CLOSEPAREN:if(!e.skip(s.Token.COLON)&&!e.skip(s.Token.EQUALS_GREATERTHAN)){u=!1;break}case s.Token.COLON:return e.reset(p),this.parseFunctionExpression(e);case s.Token.QUESTION:if(e.skip(s.Token.COLON)||e.skip(s.Token.COMMA)||e.skip(s.Token.CLOSEPAREN))return e.reset(p),this.parseFunctionExpression(e);u=!1;break;case s.Token.COMMA:break;default:u=!1}break;default:u=!1}}while(u);return e.reset(p),(c=this.parseExpression(e))?e.skip(s.Token.CLOSEPAREN)?l.Node.createParenthesizedExpression(c,e.range(r,e.pos)):(this.error(o.DiagnosticCode._0_expected,e.range(),")"),null):null;case s.Token.OPENBRACKET:for(var h=new Array;!e.skip(s.Token.CLOSEBRACKET);){if(e.peek()==s.Token.COMMA)c=null;else if(!(c=this.parseExpression(e,2)))return null;if(h.push(c),!e.skip(s.Token.COMMA)){if(e.skip(s.Token.CLOSEBRACKET))break;return this.error(o.DiagnosticCode._0_expected,e.range(),"]"),null}}return l.Node.createArrayLiteralExpression(h,e.range(r,e.pos));case s.Token.OPENBRACE:for(var d=e.tokenPos,_=new Array,m=new Array,g=void 0;!e.skip(s.Token.CLOSEBRACE);){if(e.skipIdentifier())g=l.Node.createIdentifierExpression(e.readIdentifier(),e.range());else{if(!e.skip(s.Token.STRINGLITERAL))return this.error(o.DiagnosticCode.Identifier_expected,e.range()),null;(g=l.Node.createIdentifierExpression(e.readString(),e.range())).set(i.CommonFlags.QUOTED)}if(_.push(g),e.skip(s.Token.COLON)){var y=this.parseExpression(e,2);if(!y)return null;m.push(y)}else{if(g.is(i.CommonFlags.QUOTED))return this.error(o.DiagnosticCode._0_expected,e.range(),":"),null;m.push(g)}if(!e.skip(s.Token.COMMA)){if(e.skip(s.Token.CLOSEBRACE))break;return this.error(o.DiagnosticCode._0_expected,e.range(),"}"),null}}return l.Node.createObjectLiteralExpression(_,m,e.range(d,e.pos));case s.Token.LESSTHAN:var E=this.parseType(e);return E?e.skip(s.Token.GREATERTHAN)?(c=this.parseExpression(e,19))?l.Node.createAssertionExpression(l.AssertionKind.PREFIX,c,E,e.range(r,e.pos)):null:(this.error(o.DiagnosticCode._0_expected,e.range(),">"),null):null;case s.Token.IDENTIFIER:return l.Node.createIdentifierExpression(e.readIdentifier(),e.range(r,e.pos));case s.Token.THIS:return l.Node.createThisExpression(e.range(r,e.pos));case s.Token.CONSTRUCTOR:return l.Node.createConstructorExpression(e.range(r,e.pos));case s.Token.SUPER:return l.Node.createSuperExpression(e.range(r,e.pos));case s.Token.STRINGLITERAL:return l.Node.createStringLiteralExpression(e.readString(),e.range(r,e.pos));case s.Token.INTEGERLITERAL:return l.Node.createIntegerLiteralExpression(e.readInteger(),e.range(r,e.pos));case s.Token.FLOATLITERAL:return l.Node.createFloatLiteralExpression(e.readFloat(),e.range(r,e.pos));case s.Token.SLASH:var f=e.readRegexpPattern();return e.skip(s.Token.SLASH)?l.Node.createRegexpLiteralExpression(f,e.readRegexpFlags(),e.range(r,e.pos)):(this.error(o.DiagnosticCode._0_expected,e.range(),"/"),null);case s.Token.FUNCTION:return this.parseFunctionExpression(e);case s.Token.CLASS:return this.parseClassExpression(e);default:return t==s.Token.ENDOFFILE?this.error(o.DiagnosticCode.Unexpected_end_of_text,e.range(r)):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,2);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=1),assert(0!=t);var r=this.parseExpressionStart(e);if(!r)return null;for(var n,i,a=(r=this.maybeParseCallExpression(e,r)).range.start,c=null;(i=u(n=e.peek()))>=t;){switch(e.next(),n){case s.Token.AS:var p=this.parseType(e);if(!p)return null;r=l.Node.createAssertionExpression(l.AssertionKind.AS,r,p,e.range(a,e.pos));break;case s.Token.INSTANCEOF:var d=this.parseType(e);if(!d)return null;r=l.Node.createInstanceOfExpression(r,d,e.range(a,e.pos));break;case s.Token.OPENBRACKET:if(!(c=this.parseExpression(e)))return null;if(!e.skip(s.Token.CLOSEBRACKET))return this.error(o.DiagnosticCode._0_expected,e.range(),"]"),null;r=l.Node.createElementAccessExpression(r,c,e.range(a,e.pos));break;case s.Token.PLUS_PLUS:case s.Token.MINUS_MINUS:r.kind!=l.NodeKind.IDENTIFIER&&r.kind!=l.NodeKind.ELEMENTACCESS&&r.kind!=l.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=l.Node.createUnaryPostfixExpression(n,r,e.range(a,e.pos));break;case s.Token.QUESTION:var _=this.parseExpression(e);if(!_)return null;if(!e.skip(s.Token.COLON))return this.error(o.DiagnosticCode._0_expected,e.range(),":"),null;var m=this.parseExpression(e,t>1?2:1);if(!m)return null;r=l.Node.createTernaryExpression(r,_,m,e.range(a,e.pos));break;case s.Token.COMMA:var g=[r];do{if(!(r=this.parseExpression(e,2)))return null;g.push(r)}while(e.skip(s.Token.COMMA));r=l.Node.createCommaExpression(g,e.range(a,e.pos));break;default:if(n==s.Token.DOT){if(e.skipIdentifier())c=l.Node.createIdentifierExpression(e.readIdentifier(),e.range());else if(!(c=this.parseExpression(e,h(n)?i:i+1)))return null;if(c.kind==l.NodeKind.IDENTIFIER)r=l.Node.createPropertyAccessExpression(r,c,e.range(a,e.pos));else{if(c.kind!=l.NodeKind.CALL)return this.error(o.DiagnosticCode.Identifier_expected,c.range),null;if(!(r=this.joinPropertyCall(e,a,r,c)))return null}}else{if(!(c=this.parseExpression(e,h(n)?i:i+1)))return null;r=l.Node.createBinaryExpression(n,r,c,e.range(a,e.pos))}}r=this.maybeParseCallExpression(e,r)}return r},t.prototype.joinPropertyCall=function(e,t,r,n){var i=n.expression;switch(i.kind){case l.NodeKind.IDENTIFIER:n.expression=l.Node.createPropertyAccessExpression(r,i,e.range(t,e.pos));break;case l.NodeKind.CALL:var a=this.joinPropertyCall(e,t,r,i);if(!a)return null;n.expression=a,n.range=e.range(t,e.pos);break;default:return this.error(o.DiagnosticCode.Identifier_expected,n.range),null}return n},t.prototype.maybeParseCallExpression=function(e,t){if(l.nodeIsCallable(t.kind))for(var r=null;e.skip(s.Token.OPENPAREN)||l.nodeIsGenericCallable(t.kind)&&null!==(r=this.tryParseTypeArgumentsBeforeArguments(e));){var n=this.parseArguments(e);if(!n)break;t=l.Node.createCallExpression(t,r,n,e.range(t.range.start,e.pos))}return t},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.prototype.skipBlock=function(e){var t=1,r=!0;do{switch(e.next()){case s.Token.ENDOFFILE:this.error(o.DiagnosticCode._0_expected,e.range(),"}"),r=!1;break;case s.Token.OPENBRACE:++t;break;case s.Token.CLOSEBRACE:--t||(r=!1);break;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()}}while(r)},t}(o.DiagnosticEmitter);function u(e){switch(e){case s.Token.COMMA:return 1;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 4;case s.Token.QUESTION:return 5;case s.Token.BAR_BAR:return 6;case s.Token.AMPERSAND_AMPERSAND:return 7;case s.Token.BAR:return 8;case s.Token.CARET:return 9;case s.Token.AMPERSAND:return 10;case s.Token.EQUALS_EQUALS:case s.Token.EXCLAMATION_EQUALS:case s.Token.EQUALS_EQUALS_EQUALS:case s.Token.EXCLAMATION_EQUALS_EQUALS:return 11;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 12;case s.Token.LESSTHAN_LESSTHAN:case s.Token.GREATERTHAN_GREATERTHAN:case s.Token.GREATERTHAN_GREATERTHAN_GREATERTHAN:return 13;case s.Token.PLUS:case s.Token.MINUS:return 14;case s.Token.ASTERISK:case s.Token.SLASH:case s.Token.PERCENT:return 15;case s.Token.ASTERISK_ASTERISK:return 16;case s.Token.PLUS_PLUS:case s.Token.MINUS_MINUS:return 18;case s.Token.DOT:case s.Token.NEW:case s.Token.OPENBRACKET:return 20}return 0}function h(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=p,function(e){e[e.NONE=0]="NONE",e[e.COMMA=1]="COMMA",e[e.SPREAD=2]="SPREAD",e[e.YIELD=3]="YIELD",e[e.ASSIGNMENT=4]="ASSIGNMENT",e[e.CONDITIONAL=5]="CONDITIONAL",e[e.LOGICAL_OR=6]="LOGICAL_OR",e[e.LOGICAL_AND=7]="LOGICAL_AND",e[e.BITWISE_OR=8]="BITWISE_OR",e[e.BITWISE_XOR=9]="BITWISE_XOR",e[e.BITWISE_AND=10]="BITWISE_AND",e[e.EQUALITY=11]="EQUALITY",e[e.RELATIONAL=12]="RELATIONAL",e[e.SHIFT=13]="SHIFT",e[e.ADDITIVE=14]="ADDITIVE",e[e.MULTIPLICATIVE=15]="MULTIPLICATIVE",e[e.EXPONENTIATED=16]="EXPONENTIATED",e[e.UNARY_PREFIX=17]="UNARY_PREFIX",e[e.UNARY_POSTFIX=18]="UNARY_POSTFIX",e[e.CALL=19]="CALL",e[e.MEMBERACCESS=20]="MEMBERACCESS",e[e.GROUPING=21]="GROUPING"}(t.Precedence||(t.Precedence={}))},function(e,t,r){r(16),e.exports=r(28)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(17),r(19),r(20),r(21);var n=r(5);n.Module.prototype.toText=function(){return binaryen.wrapModule(this.ref).emitStackIR()},n.Module.prototype.toAsmjs=function(){return binaryen.wrapModule(this.ref).emitAsmjs()}},function(e,t,r){(function(e){const t=e.Binaryen||r(18);for(var n in e.binaryen=t,t)(n.startsWith("_Binaryen")||n.startsWith("_Relooper"))&&(e[n]=t[n]);e.__memory_allocate=t._malloc,e.__memory_free=t._free,e.__memory_copy=t._memmove,e.__store=function(e,r){t.HEAPU8[e]=r},e.__load=function(e){return t.HEAPU8[e]}}).call(this,r(7))},function(t,r){t.exports=e},function(e,t,r){(function(e){var t="undefined"!=typeof window&&window||void 0!==e&&e||self;t.ASC_TARGET=0;var r=new Float64Array(1),n=new Uint32Array(r.buffer);function i(){Error.captureStackTrace?Error.captureStackTrace(this,i):this.stack=this.name+": "+this.message+"\n"+(new Error).stack}function a(e){this.message=e||"assertion failed",Error.captureStackTrace?Error.captureStackTrace(this,a):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)},{EPSILON:{value:Math.fround(1.1920929e-7),writable:!1},MIN_VALUE:{value:Math.fround(1.4012985e-45),writable:!1},MAX_VALUE:{value:Math.fround(3.4028235e38),writable:!1},MIN_NORMAL_VALUE:{value:Math.fround(1.17549435e-38),writable:!1},MIN_SAFE_INTEGER:{value:-16777215,writable:!1},MAX_SAFE_INTEGER:{value:16777215,writable:!1},POSITIVE_INFINITY:{value:1/0,writable:!1},NEGATIVE_INFINITY:{value:-1/0,writable:!1},NaN:{value:NaN,writable:!1}}),Object.defineProperties(t.f64=function(e){return+e},{EPSILON:{value:2.220446049250313e-16,writable:!1},MIN_VALUE:{value:5e-324,writable:!1},MAX_VALUE:{value:1.7976931348623157e308,writable:!1},MIN_NORMAL_VALUE:{value:2.2250738585072014e-308,writable:!1},MIN_SAFE_INTEGER:{value:-9007199254740991,writable:!1},MAX_SAFE_INTEGER:{value:9007199254740991,writable:!1},POSITIVE_INFINITY:{value:1/0,writable:!1},NEGATIVE_INFINITY:{value:-1/0,writable:!1},NaN:{value:NaN,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},i.prototype=Object.create(Error.prototype),i.prototype.name="UnreachableError",i.prototype.message="unreachable",t.unreachable=function(){throw new i},a.prototype=Object.create(Error.prototype),a.prototype.name="AssertionError",t.assert=function(e,t){if(e)return e;throw new a(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)},t.JSMath=Math,t.JSMath.signbit=function(e){return r[0]=e,Boolean(n[1]>>>31&e==e)},t.memory=(()=>{var e=new Uint8Array(0),r=0;return{allocate:t.__memory_allocate||function(t){if(!(t>>>=0))return 0;if(r+t>e.length){var n=e;(e=new Uint8Array(Math.max(65536,e.length+t,2*e.length))).set(n)}var i=r;return 7&(r+=t)&&(r=1+(7|r)),i},free:t.__memory_free||function(e){},copy:t.__memory_copy||function(t,r,n){e.copyWithin(t,r,r+n)}}})(),t.store=t.__store||function(e,t,r){HEAP[e+(0|r)]=t},t.load=t.__load||function(e,t){return HEAP[e+(0|t)]}}).call(this,r(7))},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(7))},function(e,t,r){(function(e){const t=e.Long||r(22);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(7))},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=l(e,(0|e)<0?-1:0,!0),i&&(s[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(n=a[e])?n:(r=l(e,e<0?-1:0,!1),i&&(a[e]=r),r)}function c(e,t){if(isNaN(e))return t?E:y;if(t){if(e<0)return E;if(e>=_)return A}else{if(e<=-m)return C;if(e+1>=m)return v}return e<0?c(-e,t).neg():l(e%d|0,e/d|0,t)}function l(e,t,r){return new n(e,t,r)}n.fromInt=o,n.fromNumber=c,n.fromBits=l;var p=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 y;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(p(r,8)),a=y,s=0;s<e.length;s+=8){var o=Math.min(8,e.length-s),l=parseInt(e.substring(s,s+o),r);if(o<8){var h=c(p(r,o));a=a.mul(h).add(c(l))}else a=(a=a.mul(i)).add(c(l))}return a.unsigned=t,a}function h(e,t){return"number"==typeof e?c(e,t):"string"==typeof e?u(e,t):l(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}n.fromString=u,n.fromValue=h;var d=4294967296,_=d*d,m=_/2,g=o(1<<24),y=o(0);n.ZERO=y;var E=o(0,!0);n.UZERO=E;var f=o(1);n.ONE=f;var T=o(1,!0);n.UONE=T;var I=o(-1);n.NEG_ONE=I;var v=l(-1,2147483647,!1);n.MAX_VALUE=v;var A=l(-1,-1,!0);n.MAX_UNSIGNED_VALUE=A;var C=l(0,-2147483648,!1);n.MIN_VALUE=C;var N=n.prototype;N.toInt=function(){return this.unsigned?this.low>>>0:this.low},N.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},N.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(C)){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(p(e,6),this.unsigned),a=this,s="";;){var o=a.div(i),l=(a.sub(o.mul(i)).toInt()>>>0).toString(e);if((a=o).isZero())return l+s;for(;l.length<6;)l="0"+l;s=""+l+s}},N.getHighBits=function(){return this.high},N.getHighBitsUnsigned=function(){return this.high>>>0},N.getLowBits=function(){return this.low},N.getLowBitsUnsigned=function(){return this.low>>>0},N.getNumBitsAbs=function(){if(this.isNegative())return this.eq(C)?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},N.isZero=function(){return 0===this.high&&0===this.low},N.eqz=N.isZero,N.isNegative=function(){return!this.unsigned&&this.high<0},N.isPositive=function(){return this.unsigned||this.high>=0},N.isOdd=function(){return 1==(1&this.low)},N.isEven=function(){return 0==(1&this.low)},N.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)},N.eq=N.equals,N.notEquals=function(e){return!this.eq(e)},N.neq=N.notEquals,N.ne=N.notEquals,N.lessThan=function(e){return this.comp(e)<0},N.lt=N.lessThan,N.lessThanOrEqual=function(e){return this.comp(e)<=0},N.lte=N.lessThanOrEqual,N.le=N.lessThanOrEqual,N.greaterThan=function(e){return this.comp(e)>0},N.gt=N.greaterThan,N.greaterThanOrEqual=function(e){return this.comp(e)>=0},N.gte=N.greaterThanOrEqual,N.ge=N.greaterThanOrEqual,N.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},N.comp=N.compare,N.negate=function(){return!this.unsigned&&this.eq(C)?C:this.not().add(f)},N.neg=N.negate,N.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,p=0,u=0,d=0,_=0;return d+=(_+=a+(65535&e.low))>>>16,u+=(d+=n+c)>>>16,p+=(u+=r+o)>>>16,p+=t+s,l((d&=65535)<<16|(_&=65535),(p&=65535)<<16|(u&=65535),this.unsigned)},N.subtract=function(e){return i(e)||(e=h(e)),this.add(e.neg())},N.sub=N.subtract,N.multiply=function(e){if(this.isZero())return y;if(i(e)||(e=h(e)),r)return l(r.mul(this.low,this.high,e.low,e.high),r.get_high(),this.unsigned);if(e.isZero())return y;if(this.eq(C))return e.isOdd()?C:y;if(e.eq(C))return this.isOdd()?C:y;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,p=65535&e.high,u=e.low>>>16,d=65535&e.low,_=0,m=0,E=0,f=0;return E+=(f+=s*d)>>>16,m+=(E+=a*d)>>>16,E&=65535,m+=(E+=s*u)>>>16,_+=(m+=n*d)>>>16,m&=65535,_+=(m+=a*u)>>>16,m&=65535,_+=(m+=s*p)>>>16,_+=t*d+n*u+a*p+s*o,l((E&=65535)<<16|(f&=65535),(_&=65535)<<16|(m&=65535),this.unsigned)},N.mul=N.multiply,N.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?l((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?E:y;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return E;if(e.gt(this.shru(1)))return T;a=E}else{if(this.eq(C))return e.eq(f)||e.eq(I)?C:e.eq(C)?f:(t=this.shr(1).div(e).shl(1)).eq(y)?e.isNegative()?f:I:(n=this.sub(e.mul(t)),a=t.add(n.div(e)));else if(e.eq(C))return this.unsigned?E:y;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=y}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:p(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=f),a=a.add(u),n=n.sub(d)}return a},N.div=N.divide,N.modulo=function(e){return i(e)||(e=h(e)),r?l((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))},N.mod=N.modulo,N.rem=N.modulo,N.not=function(){return l(~this.low,~this.high,this.unsigned)},N.and=function(e){return i(e)||(e=h(e)),l(this.low&e.low,this.high&e.high,this.unsigned)},N.or=function(e){return i(e)||(e=h(e)),l(this.low|e.low,this.high|e.high,this.unsigned)},N.xor=function(e){return i(e)||(e=h(e)),l(this.low^e.low,this.high^e.high,this.unsigned)},N.shiftLeft=function(e){return i(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?l(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):l(0,this.low<<e-32,this.unsigned)},N.shl=N.shiftLeft,N.shiftRight=function(e){return i(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?l(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):l(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},N.shr=N.shiftRight,N.shiftRightUnsigned=function(e){if(i(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?l(this.low>>>e|t<<32-e,t>>>e,this.unsigned):l(32===e?t:t>>>e-32,0,this.unsigned)},N.shru=N.shiftRightUnsigned,N.shr_u=N.shiftRightUnsigned,N.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},N.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},N.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},N.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]},N.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){"use strict";var n=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 i=r(1),a=r(3),s=r(6),o=r(5),c=r(4),l=r(11),p=r(0);function u(e,t,r,n,p,u){var g,y,E,f,T=e.module;switch(t.internalName){case"isInteger":var I=d(e,r,n,u);return e.currentType=s.Type.bool,I?I.is(4)&&!I.is(256)?T.createI32(1):T.createI32(0):T.createUnreachable();case"isFloat":I=d(e,r,n,u);return e.currentType=s.Type.bool,I?I.is(8)?T.createI32(1):T.createI32(0):T.createUnreachable();case"isSigned":I=d(e,r,n,u);return e.currentType=s.Type.bool,I?I.is(1)?T.createI32(1):T.createI32(0):T.createUnreachable();case"isReference":I=d(e,r,n,u);return e.currentType=s.Type.bool,I?(e.currentType=s.Type.bool,I.is(256)?T.createI32(1):T.createI32(0)):T.createUnreachable();case"isString":I=d(e,r,n,u);if(e.currentType=s.Type.bool,!I)return T.createUnreachable();if(R=I.classReference){var v=e.program.stringInstance;if(v&&R.isAssignableTo(v))return T.createI32(1)}return T.createI32(0);case"isArray":I=d(e,r,n,u);return e.currentType=s.Type.bool,I?null!==(R=I.classReference)&&null!==R.lookupOverload(c.OperatorKind.INDEXED_GET)?T.createI32(1):T.createI32(0):T.createUnreachable();case"isDefined":if(e.currentType=s.Type.bool,r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length)return e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();var A=e.resolver.resolveExpression(n[0],e.currentFunction,l.ReportMode.SWALLOW);return T.createI32(A?1:0);case"isConstant":if(e.currentType=s.Type.bool,r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length)return e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();var C=e.compileExpressionRetainType(n[0],s.Type.i32,0);return e.currentType=s.Type.bool,T.createI32(o.getExpressionId(C)==o.ExpressionId.Const?1:0);case"isManaged":if(!e.program.hasGC)return e.currentType=s.Type.bool,T.createI32(0);I=d(e,r,n,u);return e.currentType=s.Type.bool,I?null===(R=I.classReference)||R.hasDecorator(c.DecoratorFlags.UNMANAGED)?T.createI32(0):T.createI32(1):T.createUnreachable();case"clz":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,1)}else g=e.compileExpression(n[0],s.Type.i32,0,1);switch(e.currentType.kind){case 0:case 1:case 5:case 6:f=T.createUnary(o.UnaryOp.ClzI32,g);break;case 10:case 2:case 7:f=T.createUnary(o.UnaryOp.ClzI32,g);break;case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}case 4:f=T.createUnary(e.options.isWasm64?o.UnaryOp.ClzI64:o.UnaryOp.ClzI32,g);break;case 3:case 8:f=T.createUnary(o.UnaryOp.ClzI64,g);break;default:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"ctz":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],0,1)}else g=e.compileExpression(n[0],s.Type.i32,0,1);switch(e.currentType.kind){case 0:case 1:case 5:case 6:f=T.createUnary(o.UnaryOp.CtzI32,g);break;case 10:case 2:case 7:f=T.createUnary(o.UnaryOp.CtzI32,g);break;case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}case 4:f=T.createUnary(e.options.isWasm64?o.UnaryOp.CtzI64:o.UnaryOp.CtzI32,g);break;case 3:case 8:f=T.createUnary(o.UnaryOp.CtzI64,g);break;default:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"popcnt":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,1)}else g=e.compileExpression(n[0],s.Type.i32,0,1);switch(e.currentType.kind){case 0:case 1:case 5:case 6:f=T.createUnary(o.UnaryOp.PopcntI32,g);break;case 10:case 2:case 7:f=T.createUnary(o.UnaryOp.PopcntI32,g);break;case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}case 4:f=T.createUnary(e.options.isWasm64?o.UnaryOp.PopcntI64:o.UnaryOp.PopcntI32,g);break;case 3:case 8:f=T.createUnary(o.UnaryOp.PopcntI64,g);break;default:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"rotl":if(2!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,1)}else g=e.compileExpression(n[0],s.Type.i32,0,1);switch(y=e.compileExpression(n[1],e.currentType,1,0),e.currentType.kind){case 0:case 1:case 5:case 6:case 10:f=e.ensureSmallIntegerWrap(T.createBinary(o.BinaryOp.RotlI32,g,y),e.currentType);case 2:case 7:f=T.createBinary(o.BinaryOp.RotlI32,g,y);break;case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}case 4:f=T.createBinary(e.options.isWasm64?o.BinaryOp.RotlI64:o.BinaryOp.RotlI32,g,y);break;case 3:case 8:f=T.createBinary(o.BinaryOp.RotlI64,g,y);break;default:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"rotr":if(2!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,1)}else g=e.compileExpression(n[0],s.Type.i32,0,1);switch(y=e.compileExpression(n[1],e.currentType,1,0),e.currentType.kind){case 0:case 1:case 5:case 6:case 10:f=e.ensureSmallIntegerWrap(T.createBinary(o.BinaryOp.RotrI32,g,y),e.currentType);break;case 2:case 7:f=T.createBinary(o.BinaryOp.RotrI32,g,y);break;case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}case 4:f=T.createBinary(e.options.isWasm64?o.BinaryOp.RotrI64:o.BinaryOp.RotrI32,g,y);break;case 3:case 8:f=T.createBinary(o.BinaryOp.RotrI64,g,y);break;default:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"abs":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,1)}else g=e.compileExpression(n[0],s.Type.f64,0,1);switch(e.currentType.kind){case 0:case 1:case 2:var N=e.currentFunction.getAndFreeTempLocal(s.Type.i32,!1);f=T.createSelect(T.createTeeLocal(N.index,g),T.createBinary(o.BinaryOp.SubI32,T.createI32(0),T.createGetLocal(N.index,1)),T.createBinary(o.BinaryOp.GtI32,T.createGetLocal(N.index,1),T.createI32(0)));break;case 4:N=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);f=T.createSelect(T.createTeeLocal(N.index,g),T.createBinary(e.options.isWasm64?o.BinaryOp.SubI64:o.BinaryOp.SubI32,e.options.usizeType.toNativeZero(T),T.createGetLocal(N.index,e.options.nativeSizeType)),T.createBinary(e.options.isWasm64?o.BinaryOp.GtI64:o.BinaryOp.GtI32,T.createGetLocal(N.index,e.options.nativeSizeType),e.options.usizeType.toNativeZero(T)));break;case 3:N=e.currentFunction.getAndFreeTempLocal(s.Type.i64,!1);f=T.createSelect(T.createTeeLocal(N.index,g),T.createBinary(o.BinaryOp.SubI64,T.createI64(0,0),T.createGetLocal(N.index,2)),T.createBinary(o.BinaryOp.GtI64,T.createGetLocal(N.index,2),T.createI64(0,0)));break;case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}case 5:case 6:case 7:case 8:case 10:f=g;break;case 11:f=T.createUnary(o.UnaryOp.AbsF32,g);break;case 12:f=T.createUnary(o.UnaryOp.AbsF64,g);break;case 13:f=T.createUnreachable();break;default:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"max":if(2!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,1)}else g=e.compileExpression(n[0],s.Type.f64,0,1);switch(y=e.compileExpression(n[1],e.currentType,1,1),e.currentType.kind){case 0:case 1:case 2:var O=e.currentFunction.flow,S=e.currentFunction.getTempLocal(e.currentType,!O.canOverflow(g,e.currentType)),L=e.currentFunction.getAndFreeTempLocal(e.currentType,!O.canOverflow(y,e.currentType));e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(o.BinaryOp.GtI32,T.createGetLocal(S.index,1),T.createGetLocal(L.index,1)));break;case 5:case 6:case 7:case 10:O=e.currentFunction.flow,S=e.currentFunction.getTempLocal(e.currentType,!O.canOverflow(g,e.currentType)),L=e.currentFunction.getAndFreeTempLocal(e.currentType,!O.canOverflow(y,e.currentType));e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(o.BinaryOp.GtU32,T.createGetLocal(S.index,1),T.createGetLocal(L.index,1)));break;case 3:S=e.currentFunction.getTempLocal(s.Type.i64,!1),L=e.currentFunction.getAndFreeTempLocal(s.Type.i64,!1);e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(o.BinaryOp.GtI64,T.createGetLocal(S.index,2),T.createGetLocal(L.index,2)));break;case 8:S=e.currentFunction.getTempLocal(s.Type.i64,!1),L=e.currentFunction.getAndFreeTempLocal(s.Type.i64,!1);e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(o.BinaryOp.GtU64,T.createGetLocal(S.index,2),T.createGetLocal(L.index,2)));break;case 4:S=e.currentFunction.getTempLocal(e.options.usizeType,!1),L=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(e.options.isWasm64?o.BinaryOp.GtI64:o.BinaryOp.GtI32,T.createGetLocal(S.index,e.options.nativeSizeType),T.createGetLocal(L.index,e.options.nativeSizeType)));break;case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}S=e.currentFunction.getTempLocal(e.options.usizeType,!1),L=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(e.options.isWasm64?o.BinaryOp.GtU64:o.BinaryOp.GtU32,T.createGetLocal(S.index,e.options.nativeSizeType),T.createGetLocal(L.index,e.options.nativeSizeType)));break;case 11:f=T.createBinary(o.BinaryOp.MaxF32,g,y);break;case 12:f=T.createBinary(o.BinaryOp.MaxF64,g,y);break;default:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"min":if(2!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,1)}else g=e.compileExpression(n[0],s.Type.f64,0,1);switch(y=e.compileExpression(n[1],e.currentType,1,1),e.currentType.kind){case 0:case 1:case 2:O=e.currentFunction.flow,S=e.currentFunction.getTempLocal(e.currentType,!O.canOverflow(g,e.currentType)),L=e.currentFunction.getAndFreeTempLocal(e.currentType,!O.canOverflow(y,e.currentType));e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(o.BinaryOp.LtI32,T.createGetLocal(S.index,1),T.createGetLocal(L.index,1)));break;case 5:case 6:case 7:case 10:O=e.currentFunction.flow,S=e.currentFunction.getTempLocal(e.currentType,!O.canOverflow(g,e.currentType)),L=e.currentFunction.getAndFreeTempLocal(e.currentType,!O.canOverflow(y,e.currentType));e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(o.BinaryOp.LtU32,T.createGetLocal(S.index,1),T.createGetLocal(L.index,1)));break;case 3:S=e.currentFunction.getTempLocal(s.Type.i64,!1),L=e.currentFunction.getAndFreeTempLocal(s.Type.i64,!1);e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(o.BinaryOp.LtI64,T.createGetLocal(S.index,2),T.createGetLocal(L.index,2)));break;case 8:S=e.currentFunction.getTempLocal(s.Type.i64,!1),L=e.currentFunction.getAndFreeTempLocal(s.Type.i64,!1);e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(o.BinaryOp.LtU64,T.createGetLocal(S.index,2),T.createGetLocal(L.index,2)));break;case 4:S=e.currentFunction.getTempLocal(e.options.usizeType,!1),L=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(e.options.isWasm64?o.BinaryOp.LtI64:o.BinaryOp.LtI32,T.createGetLocal(S.index,e.options.nativeSizeType),T.createGetLocal(L.index,e.options.nativeSizeType)));break;case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}S=e.currentFunction.getTempLocal(e.options.usizeType,!1),L=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);e.currentFunction.freeTempLocal(S),f=T.createSelect(T.createTeeLocal(S.index,g),T.createTeeLocal(L.index,y),T.createBinary(e.options.isWasm64?o.BinaryOp.LtU64:o.BinaryOp.LtU32,T.createGetLocal(S.index,e.options.nativeSizeType),T.createGetLocal(L.index,e.options.nativeSizeType)));break;case 11:f=T.createBinary(o.BinaryOp.MinF32,g,y);break;case 12:f=T.createBinary(o.BinaryOp.MinF64,g,y);break;default:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"ceil":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,0)}else g=e.compileExpression(n[0],s.Type.f64,0,0);switch(e.currentType.kind){case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}default:f=g;break;case 11:f=T.createUnary(o.UnaryOp.CeilF32,g);break;case 12:f=T.createUnary(o.UnaryOp.CeilF64,g);break;case 13:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"floor":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,0)}else g=e.compileExpression(n[0],s.Type.f64,0,0);switch(e.currentType.kind){case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}default:f=g;break;case 11:f=T.createUnary(o.UnaryOp.FloorF32,g);break;case 12:f=T.createUnary(o.UnaryOp.FloorF64,g);break;case 13:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"copysign":if(2!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,0)}else g=e.compileExpression(n[0],s.Type.f64,0,0);switch(y=e.compileExpression(n[1],e.currentType,1,0),e.currentType.kind){case 11:f=T.createBinary(o.BinaryOp.CopysignF32,g,y);break;case 12:f=T.createBinary(o.BinaryOp.CopysignF64,g,y);break;default:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"nearest":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,0)}else g=e.compileExpression(n[0],s.Type.f64,0,0);switch(e.currentType.kind){case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}default:f=g;break;case 11:f=T.createUnary(o.UnaryOp.NearestF32,g);break;case 12:f=T.createUnary(o.UnaryOp.NearestF64,g);break;case 13:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"reinterpret":if(1!=n.length)return r&&1==r.length||(r&&r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0")),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();if(!r||1!=r.length)return r&&r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),T.createUnreachable();switch(r[0].kind){case 2:case 7:g=e.compileExpression(n[0],s.Type.f32,1,0),f=T.createUnary(o.UnaryOp.ReinterpretF32,g);break;case 3:case 8:g=e.compileExpression(n[0],s.Type.f64,1,0),f=T.createUnary(o.UnaryOp.ReinterpretF64,g);break;case 9:if(r[0].is(256))return e.error(i.DiagnosticCode.Operation_not_supported,u.range),e.currentType=r[0],T.createUnreachable();case 4:g=e.compileExpression(n[0],e.options.isWasm64?s.Type.f64:s.Type.f32,1,0),f=T.createUnary(e.options.isWasm64?o.UnaryOp.ReinterpretF64:o.UnaryOp.ReinterpretF32,g);break;case 11:g=e.compileExpression(n[0],s.Type.i32,1,0),f=T.createUnary(o.UnaryOp.ReinterpretI32,g);break;case 12:g=e.compileExpression(n[0],s.Type.i64,1,0),f=T.createUnary(o.UnaryOp.ReinterpretI64,g);break;default:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return e.currentType=r[0],f;case"sqrt":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,0)}else g=e.compileExpression(n[0],s.Type.f64,0,0);switch(e.currentType.kind){case 11:f=T.createUnary(o.UnaryOp.SqrtF32,g);break;case 12:f=T.createUnary(o.UnaryOp.SqrtF64,g);break;default:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"trunc":if(1!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();if(r&&r.length){if(e.currentType=r[0],1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,0)}else g=e.compileExpression(n[0],s.Type.f64,0,0);switch(e.currentType.kind){case 9:if(e.currentType.is(256)){e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable();break}default:f=g;break;case 11:f=T.createUnary(o.UnaryOp.TruncF32,g);break;case 12:f=T.createUnary(o.UnaryOp.TruncF64,g);break;case 13:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"load":return n.length<1||n.length>2?(r&&1==r.length||e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),n.length<1?e.error(i.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,u.range,"1",n.length.toString(10)):e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"2",n.length.toString(10)),T.createUnreachable()):r&&1==r.length?(g=e.compileExpression(n[0],e.options.usizeType,1,0),(x=2==n.length?_(e,n[1]):0)<0?T.createUnreachable():(e.currentType=r[0],T.createLoad(r[0].byteSize,r[0].is(5),g,r[0].is(4)&&p.is(4)&&p.size>r[0].size?(e.currentType=p).toNativeType():(e.currentType=r[0]).toNativeType(),x))):(r&&r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),T.createUnreachable());case"store":if(e.currentType=s.Type.void,n.length<2||n.length>3)return r&&1==r.length||e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),n.length<2?e.error(i.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,u.range,"2",n.length.toString(10)):e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"3",n.length.toString(10)),T.createUnreachable();if(!r||1!=r.length)return e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),T.createUnreachable();g=e.compileExpression(n[0],e.options.usizeType,1,0),y=e.compileExpression(n[1],r[0],r[0].is(4)?0:1,0);I=void 0;return r[0].is(4)&&(!e.currentType.is(4)||e.currentType.size<r[0].size)?(y=e.convertExpression(y,e.currentType,r[0],1,0,n[1]),I=r[0]):I=e.currentType,(x=3==n.length?_(e,n[2]):0)<0?T.createUnreachable():(e.currentType=s.Type.void,T.createStore(r[0].byteSize,g,y,I.toNativeType(),x));case"sizeof":if(e.currentType=e.options.usizeType,0!=n.length)return r&&1==r.length||e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"0",n.length.toString(10)),T.createUnreachable();r&&1==r.length||e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0");var b=r[0].byteSize;return e.options.isWasm64?p.is(4)&&p.size<=32?(e.currentType=s.Type.u32,f=T.createI32(b)):f=T.createI64(b,0):p.is(4)&&64==p.size?(e.currentType=s.Type.u64,f=T.createI64(b,0)):f=T.createI32(b),f;case"alignof":if(e.currentType=e.options.usizeType,0!=n.length)return r&&1==r.length||e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"0",n.length.toString(10)),T.createUnreachable();if(!r||1!=r.length)return e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),T.createUnreachable();var k=void 0;switch(b=r[0].byteSize){case 1:k=0;break;case 2:k=1;break;case 4:k=2;break;case 8:k=3;break;default:return assert(!1),T.createUnreachable()}return e.options.isWasm64?p.is(4)&&p.size<=32?(e.currentType=s.Type.u32,f=T.createI32(k)):f=T.createI64(k,0):p.is(4)&&64==p.size?(e.currentType=s.Type.u64,f=T.createI64(k,0)):f=T.createI32(k),f;case"offsetof":if(e.currentType=e.options.usizeType,n.length>1)return r&&1==r.length||e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();if(!r||1!=r.length)return e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),T.createUnreachable();var R;if(!(R=r[0].classReference))return e.error(i.DiagnosticCode.Operation_not_supported,u.range),T.createUnreachable();var x=void 0;if(n.length){if(n[0].kind!=a.NodeKind.LITERAL||n[0].literalKind!=a.LiteralKind.STRING)return e.error(i.DiagnosticCode.String_literal_expected,n[0].range),T.createUnreachable();var F=n[0].value,D=R.members?R.members.get(F):null;if(!D||D.kind!=c.ElementKind.FIELD)return e.error(i.DiagnosticCode.Type_0_has_no_property_1,n[0].range,R.internalName,F),T.createUnreachable();x=D.memoryOffset}else x=R.currentMemoryOffset;return e.options.isWasm64?p.is(4)&&p.size<=32?(e.currentType=s.Type.u32,T.createI32(x)):T.createI64(x):p.is(4)&&64==p.size?(e.currentType=s.Type.u64,T.createI64(x)):T.createI32(x);case"select":if(3!=n.length)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"3",n.length.toString(10)),T.createUnreachable();if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,0)}else g=e.compileExpressionRetainType(n[0],s.Type.i32,0);I=e.currentType;switch(y=e.compileExpression(n[1],I,1,0),E=e.makeIsTrueish(e.compileExpressionRetainType(n[2],s.Type.bool,0),e.currentType),e.currentType=I,e.currentType.kind){case 0:case 1:case 5:case 6:case 10:default:f=T.createSelect(g,y,E);break;case 13:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=T.createUnreachable()}return f;case"unreachable":return 0!=n.length&&e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"0",n.length.toString(10)),r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),T.createUnreachable();case"memory.size":return e.currentType=s.Type.i32,0!=n.length&&e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"0",n.length.toString(10)),r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),T.createHost(o.HostOp.CurrentMemory);case"memory.grow":return e.currentType=s.Type.i32,1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"0",n.length.toString(10)),g=T.createUnreachable()):g=e.compileExpression(n[0],s.Type.i32,1,0),r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),T.createHost(o.HostOp.GrowMemory,null,[g]);case"memory.copy":if(r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),3!=n.length)return e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"3",n.length.toString(10)),e.currentType=s.Type.void,T.createUnreachable();throw g=e.compileExpression(n[0],e.options.usizeType,1,0),y=e.compileExpression(n[1],e.options.usizeType,1,0),E=e.compileExpression(n[2],e.options.usizeType,1,0),e.currentType=s.Type.void,new Error("not implemented");case"memory.fill":if(r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),3!=n.length)return e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"3",n.length.toString(10)),e.currentType=s.Type.void,T.createUnreachable();throw g=e.compileExpression(n[0],e.options.usizeType,1,0),y=e.compileExpression(n[1],s.Type.u32,1,0),E=e.compileExpression(n[2],e.options.usizeType,1,0),e.currentType=s.Type.void,new Error("not implemented");case"changetype":return r&&1==r.length?1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=r[0],T.createUnreachable()):(g=e.compileExpressionRetainType(n[0],r[0],0),e.currentType=r[0],e.currentType.size!=r[0].size?(e.error(i.DiagnosticCode.Operation_not_supported,u.range),T.createUnreachable()):g):(r&&r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),T.createUnreachable());case"assert":if(n.length<1||n.length>2)return r&&(r.length&&(e.currentType=r[0].nonNullableType),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),n.length<1?e.error(i.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,u.range,"1",n.length.toString(10)):n.length>2&&e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"2",n.length.toString(10)),T.createUnreachable();if(r){if(r.length&&(e.currentType=r[0].nonNullableType),1!=r.length)return e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();g=e.compileExpression(n[0],r[0],1,1)}else g=e.compileExpressionRetainType(n[0],s.Type.bool,1);I=e.currentType;if(e.currentType=I.nonNullableType,e.options.noAssert)return p==s.Type.void?(e.currentType=s.Type.void,T.createNop()):g;var B=m(e,2==n.length?n[1]:null,u);if(e.currentType=I.nonNullableType,p==s.Type.void){switch(e.currentType.kind){default:f=T.createIf(T.createUnary(o.UnaryOp.EqzI32,g),B);break;case 3:case 8:f=T.createIf(T.createUnary(o.UnaryOp.EqzI64,g),B);break;case 4:case 9:f=T.createIf(T.createUnary(e.options.isWasm64?o.UnaryOp.EqzI64:o.UnaryOp.EqzI32,g),B);break;case 11:f=T.createIf(T.createBinary(o.BinaryOp.EqF32,g,T.createF32(0)),B);break;case 12:f=T.createIf(T.createBinary(o.BinaryOp.EqF64,g,T.createF64(0)),B);break;case 13:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=B}e.currentType=s.Type.void}else switch(e.currentType.kind){case 0:case 1:case 5:case 6:case 10:O=e.currentFunction.flow,N=e.currentFunction.getAndFreeTempLocal(e.currentType,!O.canOverflow(g,e.currentType));f=T.createIf(T.createTeeLocal(N.index,g),T.createGetLocal(N.index,1),B);break;case 2:case 7:default:N=e.currentFunction.getAndFreeTempLocal(s.Type.i32,!1);f=T.createIf(T.createTeeLocal(N.index,g),T.createGetLocal(N.index,1),B);break;case 3:case 8:N=e.currentFunction.getAndFreeTempLocal(s.Type.i64,!1);f=T.createIf(T.createUnary(o.UnaryOp.EqzI64,T.createTeeLocal(N.index,g)),B,T.createGetLocal(N.index,2));break;case 4:case 9:N=e.currentFunction.getAndFreeTempLocal(e.options.usizeType,!1);f=T.createIf(T.createUnary(e.options.isWasm64?o.UnaryOp.EqzI64:o.UnaryOp.EqzI32,T.createTeeLocal(N.index,g)),B,T.createGetLocal(N.index,e.options.nativeSizeType));break;case 11:N=e.currentFunction.getAndFreeTempLocal(s.Type.f32,!1);f=T.createIf(T.createBinary(o.BinaryOp.EqF32,T.createTeeLocal(N.index,g),T.createF32(0)),B,T.createGetLocal(N.index,3));break;case 12:N=e.currentFunction.getAndFreeTempLocal(s.Type.f64,!1);f=T.createIf(T.createBinary(o.BinaryOp.EqF64,T.createTeeLocal(N.index,g),T.createF64(0)),B,T.createGetLocal(N.index,4));break;case 13:e.error(i.DiagnosticCode.Operation_not_supported,u.range),f=B}return f;case"unchecked":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable()):((O=e.currentFunction.flow).set(4096),f=e.compileExpressionRetainType(n[0],p,0),O.unset(4096),f);case"call_indirect":if(n.length<1)return r&&(r.length&&(e.currentType=r[0]),1!=r.length&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10))),e.error(i.DiagnosticCode.Expected_at_least_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),T.createUnreachable();var U=void 0;if(r){if(1!=r.length)return r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r.length.toString(10)),T.createUnreachable();U=r[0]}else U=p;if(g=e.compileExpressionRetainType(n[0],s.Type.u32,0),7!=e.currentType.kind)return e.error(i.DiagnosticCode.Operation_not_supported,n[0].range),T.createUnreachable();for(var P=n.length-1,w=new Array(P),M=new Array(P+1),G=U.toNativeType(),K=new Array(P),z=0;z<P;++z){w[z]=e.compileExpressionRetainType(n[1+z],s.Type.i32,0);var V=e.currentType;M[z]=V.toSignatureString(),K[z]=V.toNativeType()}M[P]=U.toSignatureString();var H=M.join(""),X=T.getFunctionTypeBySignature(G,K);return X||(X=T.addFunctionType(H,G,K)),e.currentType=U,T.createCallIndirect(g,w,H);case"instantiate":if(!r||1!=r.length)return r&&r.length&&(e.currentType=r[0]),e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,u.range,"1",r?r.length.toString(10):"0"),T.createUnreachable();var W=r[0].classReference;return W?e.compileInstantiate(W,n,u):(e.error(i.DiagnosticCode.Operation_not_supported,u.range),T.createUnreachable());case"ERROR":return e.error(i.DiagnosticCode.User_defined_0,u.range,(n.length?n[0]:u).range.toString()),T.createUnreachable();case"WARNING":return e.warning(i.DiagnosticCode.User_defined_0,u.range,(n.length?n[0]:u).range.toString()),T.createNop();case"INFO":return e.info(i.DiagnosticCode.User_defined_0,u.range,(n.length?n[0]:u).range.toString()),T.createNop();case"i8":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.i8,T.createUnreachable()):e.compileExpression(n[0],s.Type.i8,2,0);case"i16":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.i16,T.createUnreachable()):e.compileExpression(n[0],s.Type.i16,2,0);case"i32":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.i32,T.createUnreachable()):e.compileExpression(n[0],s.Type.i32,2,0);case"i64":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.i64,T.createUnreachable()):e.compileExpression(n[0],s.Type.i64,2,0);case"isize":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=e.options.isWasm64?s.Type.isize64:s.Type.isize32,T.createUnreachable()):e.compileExpression(n[0],e.options.isWasm64?s.Type.isize64:s.Type.isize32,2,0);case"u8":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.u8,T.createUnreachable()):e.compileExpression(n[0],s.Type.u8,2,0);case"u16":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.u16,T.createUnreachable()):e.compileExpression(n[0],s.Type.u16,2,0);case"u32":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.u32,T.createUnreachable()):e.compileExpression(n[0],s.Type.u32,2,0);case"u64":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.u64,T.createUnreachable()):e.compileExpression(n[0],s.Type.u64,2,0);case"usize":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=e.options.usizeType,T.createUnreachable()):e.compileExpression(n[0],e.options.usizeType,2,0);case"bool":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.bool,T.createUnreachable()):e.compileExpression(n[0],s.Type.bool,2,0);case"f32":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.f32,T.createUnreachable()):e.compileExpression(n[0],s.Type.f32,2,0);case"f64":return r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length?(e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.f64,T.createUnreachable()):e.compileExpression(n[0],s.Type.f64,2,0);case"iterateRoots":if(r&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),1!=n.length)return e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,u.range,"1",n.length.toString(10)),e.currentType=s.Type.void,T.createUnreachable();var Y=e.compileExpressionRetainType(n[0],s.Type.u32,0),Q=(I=e.currentType).signatureReference;return e.currentType=s.Type.void,I.is(256)&&Q&&1==Q.parameterTypes.length&&Q.parameterTypes[0]==e.options.usizeType?(e.currentType=s.Type.void,e.needsIterateRoots=!0,T.createCall("~iterateRoots",[Y],0)):(e.error(i.DiagnosticCode.Type_0_is_not_assignable_to_type_1,u.range,I.toString(),"(ref: usize) => void"),T.createUnreachable())}var q=function(e,t,r,n,i){switch(t.internalName){case"i32.clz":return h("clz",e,s.Type.i32,r,s.Type.i32,i);case"i64.clz":return h("clz",e,s.Type.i64,r,s.Type.i64,i);case"i32.ctz":return h("ctz",e,s.Type.i32,r,s.Type.i32,i);case"i64.ctz":return h("ctz",e,s.Type.i64,r,s.Type.i64,i);case"i32.popcnt":return h("popcnt",e,s.Type.i32,r,s.Type.i32,i);case"i64.popcnt":return h("popcnt",e,s.Type.i64,r,s.Type.i64,i);case"i32.rotl":return h("rotl",e,s.Type.i32,r,s.Type.i32,i);case"i64.rotl":return h("rotl",e,s.Type.i64,r,s.Type.i64,i);case"i32.rotr":return h("rotr",e,s.Type.i32,r,s.Type.i32,i);case"i64.rotr":return h("rotr",e,s.Type.i64,r,s.Type.i64,i);case"f32.abs":return h("abs",e,s.Type.f32,r,s.Type.f32,i);case"f64.abs":return h("abs",e,s.Type.f64,r,s.Type.f64,i);case"f32.max":return h("max",e,s.Type.f32,r,s.Type.f32,i);case"f64.max":return h("max",e,s.Type.f64,r,s.Type.f64,i);case"f32.min":return h("min",e,s.Type.f32,r,s.Type.f32,i);case"f64.min":return h("min",e,s.Type.f64,r,s.Type.f64,i);case"f32.ceil":return h("ceil",e,s.Type.f32,r,s.Type.f32,i);case"f64.ceil":return h("ceil",e,s.Type.f64,r,s.Type.f64,i);case"f32.floor":return h("floor",e,s.Type.f32,r,s.Type.f32,i);case"f64.floor":return h("floor",e,s.Type.f64,r,s.Type.f64,i);case"f32.copysign":return h("copysign",e,s.Type.f32,r,s.Type.f32,i);case"f64.copysign":return h("copysign",e,s.Type.f64,r,s.Type.f64,i);case"f32.nearest":return h("nearest",e,s.Type.f32,r,s.Type.f32,i);case"f64.nearest":return h("nearest",e,s.Type.f64,r,s.Type.f64,i);case"i32.reinterpret_f32":return h("reinterpret",e,s.Type.i32,r,s.Type.f32,i);case"i64.reinterpret_f64":return h("reinterpret",e,s.Type.i64,r,s.Type.f64,i);case"f32.reinterpret_i32":return h("reinterpret",e,s.Type.f32,r,s.Type.i32,i);case"f64.reinterpret_i64":return h("reinterpret",e,s.Type.f64,r,s.Type.i64,i);case"f32.sqrt":return h("sqrt",e,s.Type.f32,r,s.Type.f32,i);case"f64.sqrt":return h("sqrt",e,s.Type.f64,r,s.Type.f64,i);case"f32.trunc":return h("trunc",e,s.Type.f32,r,s.Type.f32,i);case"f64.trunc":return h("trunc",e,s.Type.f64,r,s.Type.f64,i);case"i32.load8_s":return h("load",e,s.Type.i8,r,s.Type.i32,i);case"i32.load8_u":return h("load",e,s.Type.u8,r,s.Type.u32,i);case"i32.load16_s":return h("load",e,s.Type.i16,r,s.Type.i32,i);case"i32.load16_u":return h("load",e,s.Type.u16,r,s.Type.u32,i);case"i32.load":return h("load",e,s.Type.i32,r,s.Type.i32,i);case"i64.load8_s":return h("load",e,s.Type.i8,r,s.Type.i64,i);case"i64.load8_u":return h("load",e,s.Type.u8,r,s.Type.u64,i);case"i64.load16_s":return h("load",e,s.Type.i16,r,s.Type.i64,i);case"i64.load16_u":return h("load",e,s.Type.u16,r,s.Type.u64,i);case"i64.load32_s":return h("load",e,s.Type.i32,r,s.Type.i64,i);case"i64.load32_u":return h("load",e,s.Type.u32,r,s.Type.u64,i);case"i64.load":return h("load",e,s.Type.i64,r,s.Type.i64,i);case"f32.load":return h("load",e,s.Type.f32,r,s.Type.f32,i);case"f64.load":return h("load",e,s.Type.f64,r,s.Type.f64,i);case"i32.store8":return h("store",e,s.Type.i8,r,s.Type.i32,i);case"i32.store16":return h("store",e,s.Type.i16,r,s.Type.i32,i);case"i32.store":return h("store",e,s.Type.i32,r,s.Type.i32,i);case"i64.store8":return h("store",e,s.Type.i8,r,s.Type.i64,i);case"i64.store16":return h("store",e,s.Type.i16,r,s.Type.i64,i);case"i64.store32":return h("store",e,s.Type.i32,r,s.Type.i64,i);case"i64.store":return h("store",e,s.Type.i64,r,s.Type.i64,i);case"f32.store":return h("store",e,s.Type.f32,r,s.Type.f32,i);case"f64.store":return h("store",e,s.Type.f64,r,s.Type.f64,i)}return 0}(e,t,n,0,u);return q?(r&&r.length&&e.error(i.DiagnosticCode.Type_0_is_not_generic,u.range,t.internalName),q):(e.error(i.DiagnosticCode.Operation_not_supported,u.range),T.createUnreachable())}function h(e,t,r,n,i,a){var s=assert(t.program.elementsLookup.get(e));return assert(s.kind==c.ElementKind.FUNCTION_PROTOTYPE),u(t,s,[r],n,i,a)}function d(e,t,r,n){if(0==r.length)return t&&1==t.length?t[0]:(e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,n.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(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,n.range,"1",t.length.toString(10)),null;e.compileExpressionRetainType(r[0],s.Type.i32,0)}else e.compileExpressionRetainType(r[0],s.Type.i32,0);return e.currentType}return t&&t.length>1&&e.error(i.DiagnosticCode.Expected_0_type_arguments_but_got_1,n.range,"1",t.length.toString(10)),e.error(i.DiagnosticCode.Expected_0_arguments_but_got_1,n.range,"1",r.length.toString(10)),null}function _(e,t){var r,n;return e.options.isWasm64?(r=e.precomputeExpression(t,s.Type.usize64,1,0),(o.getExpressionId(r)!=o.ExpressionId.Const||2!=o.getExpressionType(r)||0!=o.getConstValueI64High(r)||(n=o.getConstValueI64Low(r))<0)&&(e.error(i.DiagnosticCode.Operation_not_supported,t.range),n=-1)):(r=e.precomputeExpression(t,s.Type.usize32,1,0),(o.getExpressionId(r)!=o.ExpressionId.Const||1!=o.getExpressionType(r)||(n=o.getConstValueI32(r))<0)&&(e.error(i.DiagnosticCode.Operation_not_supported,t.range),n=-1)),n}function m(e,t,r){var n=e.program,i=e.module,a=n.typesLookup.get("string");if(!a)return i.createUnreachable();var o=n.abortInstance;if(!o||!e.compileFunction(o))return i.createUnreachable();var c=null!=t?e.compileExpression(t,a,1,0):a.toNativeZero(i),l=e.ensureStaticString(r.range.source.normalizedPath);return e.currentType=s.Type.void,i.createBlock(null,[i.createCall(o.internalName,[c,l,i.createI32(r.range.line),i.createI32(r.range.column)],0),i.createUnreachable()])}function g(e,t){var r,i,a=e.program;assert(t.type.isManaged(a));var l=t.gcHookIndex;if(-1!=l)return l;var u=t.members;if(t.prototype.declaration.range.source.isLibrary&&null!==u&&u.has("__gc")){var h=assert(u.get("__gc"));assert(h.kind==c.ElementKind.FUNCTION_PROTOTYPE);var d=assert(a.resolver.resolveFunction(h,null));assert(d.is(p.CommonFlags.PRIVATE|p.CommonFlags.INSTANCE)),assert(!d.isAny(p.CommonFlags.AMBIENT|p.CommonFlags.VIRTUAL)),assert(0==d.signature.parameterTypes.length),assert(d.signature.returnType==s.Type.void),d.internalName=t.internalName+"~gc",assert(e.compileFunction(d));var _=e.ensureFunctionTableEntry(d);return t.gcHookIndex=_,_}var m=e.module,y=e.options,E=y.nativeSizeType,f=y.usizeType.byteSize,T=new Array;T.push(m.createIf(m.createUnary(y.isWasm64?o.UnaryOp.EqzI64:o.UnaryOp.EqzI32,m.createGetLocal(0,E)),m.createReturn()));var I=e.functionTable,v=I.length;I.push("<placeholder>"),t.gcHookIndex=v;var A=t.base;if(A?(assert(A.type.isManaged(a)),T.push(m.createCallIndirect(m.createI32(g(e,A.type.classReference)),[m.createGetLocal(0,E)],2==E?"Iv":"iv"))):T.push(m.createCall(assert(a.gcMarkInstance).internalName,[m.createGetLocal(0,E)],0)),u)try{for(var C=n(u.values()),N=C.next();!N.done;N=C.next()){var O=N.value;if(O.kind==c.ElementKind.FIELD)if(O.parent===t)if(O.type.isManaged(a)){var S=O.memoryOffset;assert(S>=0),T.push(m.createCall(assert(a.gcMarkInstance).internalName,[m.createLoad(f,!1,m.createGetLocal(0,E),E,S)],0))}}}catch(e){r={error:e}}finally{try{N&&!N.done&&(i=C.return)&&i.call(C)}finally{if(r)throw r.error}}var L=t.internalName+"~gc";return m.addFunction(L,e.ensureFunctionType(null,s.Type.void,y.usizeType),null,m.createBlock(null,T)),I[v]=L,v}t.compileCall=u,t.compileAllocate=function(e,t,r){var n=e.program;assert(t.program==n);var a=e.module,s=e.options;if(n.hasGC&&t.type.isManaged(n)){var o=assert(n.gcAllocateInstance);return e.compileFunction(o)?(e.currentType=t.type,a.createCall(o.internalName,[s.isWasm64?a.createI64(t.currentMemoryOffset):a.createI32(t.currentMemoryOffset),a.createI32(g(e,t))],s.nativeSizeType)):a.createUnreachable()}return(o=n.memoryAllocateInstance)?e.compileFunction(o)?(e.currentType=t.type,a.createCall(o.internalName,[s.isWasm64?a.createI64(t.currentMemoryOffset):a.createI32(t.currentMemoryOffset)],s.nativeSizeType)):a.createUnreachable():(n.error(i.DiagnosticCode.Cannot_find_name_0,r.range,"memory.allocate"),a.createUnreachable())},t.compileAbort=m,t.compileIterateRoots=function(e){var t,r,i=e.module,a=new Array;try{for(var o=n(e.program.elementsLookup.values()),l=o.next();!l.done;l=o.next()){var u=l.value;if(u.kind==c.ElementKind.GLOBAL){var h=u,d=h.type.classReference;if(h.is(p.CommonFlags.COMPILED)&&null!==d&&!d.hasDecorator(c.DecoratorFlags.UNMANAGED))if(h.is(p.CommonFlags.INLINED)){var _=h.constantIntegerValue;a.push(i.createCallIndirect(i.createGetLocal(0,1),[e.options.isWasm64?i.createI64(i64_low(_),i64_high(_)):i.createI32(i64_low(_))],"iv"))}else a.push(i.createCallIndirect(i.createGetLocal(0,1),[i.createGetGlobal(h.internalName,e.options.nativeSizeType)],"iv"))}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}var m=e.ensureFunctionType([s.Type.i32],s.Type.void);i.addFunction("~iterateRoots",m,[],a.length?i.createBlock(null,a):i.createNop())},t.ensureGCHook=g},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&&function(e){return!(e<0||e>65535)&&a(e,n)}(e)},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&&function(e){return!(e<0||e>65535)&&a(e,i)}(e)};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=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});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";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.readI8=function(e,t){return e[t]},t.writeI8=function(e,t,r){t[r]=e},t.readI16=function(e,t){return e[t]|e[t+1]<<8},t.writeI16=function(e,t,r){t[r]=e,t[r+1]=e>>>8},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";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0});var i=r(9),a=r(12),s=r(13),o=r(1);t.formatDiagnostic=o.formatDiagnosticMessage;var c=r(14);t.parseFile=function(e,t,r,n){return void 0===r&&(r=!1),void 0===n&&(n=null),n||(n=new c.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==o.DiagnosticCategory.INFO},t.isWarning=function(e){return e.category==o.DiagnosticCategory.WARNING},t.isError=function(e){return e.category==o.DiagnosticCategory.ERROR},t.createOptions=function(){return new i.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.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_SIGN_EXTENSION=1,t.FEATURE_MUTABLE_GLOBAL=2,t.enableFeature=function(e,t){e.features|=t},t.setOptimizeLevelHints=function(e,t,r){e.optimizeLevelHint=t,e.shrinkLevelHint=r},t.finishParsing=function(e){return e.finish()},t.compileProgram=function(e,t){return void 0===t&&(t=null),new i.Compiler(e,t).compile()},t.decompileModule=function(e){var t=new a.Decompiler;return t.decompile(e),t.finish()},t.buildIDL=function(e){return s.IDLBuilder.build(e)},t.buildTSD=function(e){return s.TSDBuilder.build(e)};var l=r(0);t.LIBRARY_PREFIX=l.LIBRARY_PREFIX,n(r(3)),n(r(0)),n(r(9)),n(r(12)),n(r(13)),n(r(10)),n(r(1)),n(r(5)),n(r(14)),n(r(4)),n(r(11)),n(r(8)),n(r(6)),n(r(2))}])});
|
||
//# sourceMappingURL=assemblyscript.js.map
|