diff --git a/lib/turboscript.js b/lib/turboscript.js index cd44fee..38f4017 100644 --- a/lib/turboscript.js +++ b/lib/turboscript.js @@ -6793,7 +6793,7 @@ function compileString(source, options) { } } exports.compileString = compileString; -exports.version = "1.0.1-beta"; +exports.version = "1.0.2-beta"; exports.default = { version: exports.version, main: exports.main, diff --git a/lib/turboscript.min.js b/lib/turboscript.min.js index 59be675..d6cbeaf 100644 --- a/lib/turboscript.min.js +++ b/lib/turboscript.min.js @@ -1 +1 @@ -!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory(require("fs")):"function"==typeof define&&define.amd?define(["fs"],factory):"object"==typeof exports?exports.turboscript=factory(require("fs")):root.turboscript=factory(root.fs)}(this,function(__WEBPACK_EXTERNAL_MODULE_55__){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=52)}([function(module,exports,__webpack_require__){"use strict";function assert(truth){if(!truth){if(terminal_1.Terminal.error("Assertion failed"),"undefined"==typeof process)throw"Assertion failed";process.exit(1)}}Object.defineProperty(exports,"__esModule",{value:!0});var terminal_1=__webpack_require__(1);exports.assert=assert},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var env_1=__webpack_require__(21),color_1=__webpack_require__(20),Terminal=function(){function Terminal(){}return Terminal.write=function(text){Terminal.history+=text,Terminal.silent||(env_1.isNode?process.stdout.write(text):console.log("%c"+text,"background: "+Terminal.browserStyles.background+";color: "+Terminal.browserStyles.text+";font-weight: "+(Terminal.browserStyles.bold?"700":"100")+";"))},Terminal.time=function(name){Terminal.silent||console.time(name)},Terminal.timeEnd=function(name){Terminal.silent||console.timeEnd(name)},Terminal.setBGColor=function(color){env_1.isNode?process.stdout.isTTY&&process.stdout.write("[48;5;"+(null===color?"":color)+"m"):Terminal.browserStyles.background=color_1.HexColor[color]},Terminal.setTextColor=function(color){env_1.isNode?process.stdout.isTTY&&process.stdout.write("[38;5;"+color+"m"):Terminal.browserStyles.text=color_1.HexColor[color]},Terminal.setBoldText=function(){env_1.isNode?process.stdout.isTTY&&process.stdout.write(""):Terminal.browserStyles.bold=!0},Terminal.clearColor=function(){env_1.isNode?process.stdout.isTTY&&process.stdout.write(""):(Terminal.browserStyles.text=color_1.HexColor[color_1.Color.DEFAULT_TEXT],Terminal.browserStyles.background=color_1.HexColor[color_1.Color.DEFAULT_BG],Terminal.browserStyles.bold=!1)},Terminal.error=function(text){Terminal.setBGColor(color_1.Color.RED),Terminal.setTextColor(color_1.Color.WHITE),Terminal.write(" ERROR "),Terminal.clearColor(),Terminal.setTextColor(color_1.Color.RED),Terminal.write(" "),Terminal.write(text),Terminal.write("\n"),Terminal.clearColor()},Terminal.warn=function(text){Terminal.setBGColor(color_1.Color.ORANGE),Terminal.setTextColor(color_1.Color.WHITE),Terminal.write(" WARN "),Terminal.clearColor(),Terminal.setTextColor(color_1.Color.ORANGE),Terminal.write(" "),Terminal.write(text),Terminal.write("\n"),Terminal.clearColor()},Terminal}();Terminal.silent=!1,Terminal.history="",Terminal.browserStyles={text:color_1.HexColor[color_1.Color.DEFAULT_TEXT],background:color_1.HexColor[color_1.Color.DEFAULT_BG],bold:!1},exports.Terminal=Terminal},function(module,exports,__webpack_require__){"use strict";function createRange(source,start,end){assert_1.assert(start<=end);var range=new SourceRange;return range.source=source,range.start=start,range.end=end,range}function spanRanges(left,right){return assert_1.assert(left.source==right.source),assert_1.assert(left.start<=right.start),assert_1.assert(left.end<=right.end),createRange(left.source,left.start,right.end)}function writeLogToTerminal(log){for(var diagnostic=log.first;null!=diagnostic;){if(void 0!==diagnostic.range){var location_2=diagnostic.range.source.indexToLineColumn(diagnostic.range.start),diagnosticMessage=diagnostic.sourceName(location_2);terminal_1.Terminal.setBoldText(),terminal_1.Terminal.write(diagnosticMessage),diagnosticMessage=diagnostic.kind==DiagnosticKind.ERROR?"ERROR: ":"WARN: ",terminal_1.Terminal.setTextColor(diagnostic.kind==DiagnosticKind.ERROR?color_1.Color.RED:color_1.Color.ORANGE),terminal_1.Terminal.write(diagnosticMessage),terminal_1.Terminal.setBoldText(),terminal_1.Terminal.write(diagnostic.message+"\n"),terminal_1.Terminal.clearColor(),terminal_1.Terminal.write(diagnostic.lineContents()),diagnosticMessage=diagnostic.sourceRange(location_2),terminal_1.Terminal.setTextColor(color_1.Color.RED),terminal_1.Terminal.write(diagnosticMessage)}else terminal_1.Terminal.setTextColor(color_1.Color.RED),terminal_1.Terminal.write(diagnostic.message+"\n");diagnostic=diagnostic.next}terminal_1.Terminal.clearColor()}Object.defineProperty(exports,"__esModule",{value:!0});var color_1=__webpack_require__(20),assert_1=__webpack_require__(0),terminal_1=__webpack_require__(1),LineColumn=function(){function LineColumn(){}return LineColumn}();exports.LineColumn=LineColumn;var Source=function(){function Source(){}return Source.prototype.indexToLineColumn=function(index){for(var contents=this.contents,column=0,line=0,i=0;i57343)&&(column+=1),i+=1}var location=new LineColumn;return location.line=line,location.column=column,location},Source}();exports.Source=Source;var SourceRange=function(){function SourceRange(){}return SourceRange.prototype.toString=function(){return this.source.contents.slice(this.start,this.end)},SourceRange.prototype.equals=function(other){return this.source==other.source&&this.start==other.start&&this.end==other.end},SourceRange.prototype.enclosingLine=function(){for(var contents=this.source.contents,start=this.start,end=this.start;start>0&&"\n"!=contents[start-1];)start-=1;for(var length=contents.length;end0;)rangeStr+=" ",column-=1;if(range.end-range.start<=1)rangeStr+="^";else for(var i=range.start;i=SymbolKind.TYPE_CLASS&&kind<=SymbolKind.TYPE_NATIVE}function isFunction(kind){return kind>=SymbolKind.FUNCTION_INSTANCE&&kind<=SymbolKind.FUNCTION_GLOBAL}function isVariable(kind){return kind>=SymbolKind.VARIABLE_ARGUMENT&&kind<=SymbolKind.VARIABLE_LOCAL}Object.defineProperty(exports,"__esModule",{value:!0});var SymbolKind,node_1=__webpack_require__(5),utils_1=__webpack_require__(6),assert_1=__webpack_require__(0);!function(SymbolKind){SymbolKind[SymbolKind.TYPE_MODULE=0]="TYPE_MODULE",SymbolKind[SymbolKind.TYPE_INTERFACE=1]="TYPE_INTERFACE",SymbolKind[SymbolKind.TYPE_CLASS=2]="TYPE_CLASS",SymbolKind[SymbolKind.TYPE_GENERIC=3]="TYPE_GENERIC",SymbolKind[SymbolKind.TYPE_TEMPLATE=4]="TYPE_TEMPLATE",SymbolKind[SymbolKind.TYPE_ENUM=5]="TYPE_ENUM",SymbolKind[SymbolKind.TYPE_GLOBAL=6]="TYPE_GLOBAL",SymbolKind[SymbolKind.TYPE_NATIVE=7]="TYPE_NATIVE",SymbolKind[SymbolKind.FUNCTION_INSTANCE=8]="FUNCTION_INSTANCE",SymbolKind[SymbolKind.FUNCTION_GLOBAL=9]="FUNCTION_GLOBAL",SymbolKind[SymbolKind.VARIABLE_ARGUMENT=10]="VARIABLE_ARGUMENT",SymbolKind[SymbolKind.VARIABLE_CONSTANT=11]="VARIABLE_CONSTANT",SymbolKind[SymbolKind.VARIABLE_GLOBAL=12]="VARIABLE_GLOBAL",SymbolKind[SymbolKind.VARIABLE_INSTANCE=13]="VARIABLE_INSTANCE",SymbolKind[SymbolKind.VARIABLE_LOCAL=14]="VARIABLE_LOCAL"}(SymbolKind=exports.SymbolKind||(exports.SymbolKind={})),exports.isModule=isModule,exports.isType=isType,exports.isFunction=isFunction,exports.isVariable=isVariable;var SymbolState;!function(SymbolState){SymbolState[SymbolState.UNINITIALIZED=0]="UNINITIALIZED",SymbolState[SymbolState.INITIALIZING=1]="INITIALIZING",SymbolState[SymbolState.INITIALIZED=2]="INITIALIZED"}(SymbolState=exports.SymbolState||(exports.SymbolState={})),exports.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL=1,exports.SYMBOL_FLAG_IS_BINARY_OPERATOR=2,exports.SYMBOL_FLAG_IS_REFERENCE=4,exports.SYMBOL_FLAG_IS_UNARY_OPERATOR=8,exports.SYMBOL_FLAG_IS_UNSIGNED=16,exports.SYMBOL_FLAG_NATIVE_INTEGER=32,exports.SYMBOL_FLAG_NATIVE_LONG=64,exports.SYMBOL_FLAG_NATIVE_FLOAT=128,exports.SYMBOL_FLAG_NATIVE_DOUBLE=256,exports.SYMBOL_FLAG_USED=512,exports.SYMBOL_FLAG_IS_ARRAY=1024,exports.SYMBOL_FLAG_IS_GENERIC=2048,exports.SYMBOL_FLAG_IS_TEMPLATE=4096;var Symbol=function(){function Symbol(){this.state=SymbolState.UNINITIALIZED,this.byteSize=0,this.maxAlignment=0}return Object.defineProperty(Symbol.prototype,"internalName",{get:function(){return null!=this.rename?this.rename:this.name},enumerable:!0,configurable:!0}),Symbol.prototype.clone=function(){var symbol=new Symbol;return symbol.kind=this.kind,symbol.name=this.name,symbol.node=this.node,symbol.range=this.range,symbol.scope=this.scope,symbol.resolvedType=this.resolvedType,symbol.byteSize=this.byteSize,symbol.state=this.state,symbol.maxAlignment=this.maxAlignment,symbol.flags=this.flags,symbol.rename=this.rename,symbol},Symbol.prototype.isEnumValue=function(){return this.node.parent.kind==node_1.NodeKind.ENUM},Symbol.prototype.isUnsafe=function(){return null!=this.node&&this.node.isUnsafe()},Symbol.prototype.isGetter=function(){return this.node.isGet()},Symbol.prototype.isSetter=function(){return this.node.isSet()},Symbol.prototype.isBinaryOperator=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_IS_BINARY_OPERATOR)},Symbol.prototype.isUnaryOperator=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_IS_UNARY_OPERATOR)},Symbol.prototype.shouldConvertInstanceToGlobal=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL)},Symbol.prototype.isUsed=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_USED)},Symbol.prototype.parent=function(){var parent=this.node.parent;return parent.kind==node_1.NodeKind.CLASS?parent.symbol:null},Symbol.prototype.resolvedTypeUnderlyingIfEnumValue=function(context){return this.isEnumValue()?this.resolvedType.underlyingType(context):this.resolvedType},Symbol.prototype.determineClassLayout=function(context){if(assert_1.assert(this.kind==SymbolKind.TYPE_CLASS),0==this.byteSize){for(var offset=0,child=this.node.firstChild,maxAlignment=1;null!=child;){if(child.kind==node_1.NodeKind.VARIABLE){var type=child.symbol.resolvedType;if(type!=context.errorType){var alignmentOf=type.variableAlignmentOf(context);offset=utils_1.alignToNextMultipleOf(offset,alignmentOf),alignmentOf>maxAlignment&&(maxAlignment=alignmentOf),child.symbol.offset=offset,offset+=type.variableSizeOf(context)}}child=child.nextSibling}0==offset&&(offset=1),offset=utils_1.alignToNextMultipleOf(offset,maxAlignment),this.byteSize=offset,this.maxAlignment=maxAlignment}},Symbol}();exports.Symbol=Symbol},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});!function(CompileTarget){CompileTarget[CompileTarget.NONE=0]="NONE",CompileTarget[CompileTarget.AUTO=1]="AUTO",CompileTarget[CompileTarget.CPP=2]="CPP",CompileTarget[CompileTarget.JAVASCRIPT=3]="JAVASCRIPT",CompileTarget[CompileTarget.WEBASSEMBLY=4]="WEBASSEMBLY"}(exports.CompileTarget||(exports.CompileTarget={}))},function(module,exports,__webpack_require__){"use strict";function isUnary(kind){return kind>=NodeKind.ADDRESS_OF&&kind<=NodeKind.PREFIX_INCREMENT}function isUnaryPostfix(kind){return kind>=NodeKind.POSTFIX_DECREMENT&&kind<=NodeKind.POSTFIX_INCREMENT}function isBinary(kind){return kind>=NodeKind.ADD&&kind<=NodeKind.SUBTRACT}function invertedBinaryKind(kind){return kind==NodeKind.EQUAL?NodeKind.NOT_EQUAL:kind==NodeKind.NOT_EQUAL?NodeKind.EQUAL:kind==NodeKind.GREATER_THAN?NodeKind.LESS_THAN_EQUAL:kind==NodeKind.GREATER_THAN_EQUAL?NodeKind.LESS_THAN:kind==NodeKind.LESS_THAN?NodeKind.GREATER_THAN_EQUAL:kind==NodeKind.LESS_THAN_EQUAL?NodeKind.GREATER_THAN:kind}function isExpression(node){return node.kind>=NodeKind.ALIGN_OF&&node.kind<=NodeKind.SUBTRACT}function isCompactNodeKind(kind){return kind==NodeKind.CONSTANTS||kind==NodeKind.EXPRESSION||kind==NodeKind.VARIABLES}function appendFlag(first,flag,range){var link=new NodeFlag;if(link.flag=flag,link.range=range,null==first)return link;for(var secondToLast=first;null!=secondToLast.next;)secondToLast=secondToLast.next;return secondToLast.next=link,first}function allFlags(link){for(var all=0;null!=link;)all|=link.flag,link=link.next;return all}function rangeForFlag(link,flag){for(;null!=link;){if(link.flag==flag)return link.range;link=link.next}return null}function createNew(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.NEW,node.appendChild(type),node}function createDelete(value){assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.DELETE,null!=value&&node.appendChild(value),node}function createHook(test,primary,secondary){assert_1.assert(isExpression(test)),assert_1.assert(isExpression(primary)),assert_1.assert(isExpression(secondary));var node=new Node;return node.kind=NodeKind.HOOK,node.appendChild(test),node.appendChild(primary),node.appendChild(secondary),node}function createIndex(target){assert_1.assert(isExpression(target));var node=new Node;return node.kind=NodeKind.INDEX,node.appendChild(target),node}function createNull(){var node=new Node;return node.kind=NodeKind.NULL,node}function createUndefined(){var node=new Node;return node.kind=NodeKind.UNDEFINED,node}function createThis(){var node=new Node;return node.kind=NodeKind.THIS,node}function createAddressOf(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.ADDRESS_OF,node.appendChild(value),node}function createDereference(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.DEREFERENCE,node.appendChild(value),node}function createAlignOf(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.ALIGN_OF,node.appendChild(type),node}function createSizeOf(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.SIZE_OF,node.appendChild(type),node}function createboolean(value){var node=new Node;return node.kind=NodeKind.BOOLEAN,node.intValue=value?1:0,node}function createInt(value){var node=new Node;return node.kind=NodeKind.INT32,node.intValue=value,node}function createLong(value){var node=new Node;return node.kind=NodeKind.INT64,node.longValue=value,node}function createFloat(value){var node=new Node;return node.kind=NodeKind.FLOAT32,node.floatValue=value,node}function createDouble(value){var node=new Node;return node.kind=NodeKind.FLOAT64,node.doubleValue=value,node}function createString(value){var node=new Node;return node.kind=NodeKind.STRING,node.stringValue=value,node}function createArray(type){var node=new Node;return node.kind=NodeKind.ARRAY,node.resolvedType=type,node}function createName(value){var node=new Node;return node.kind=NodeKind.NAME,node.referenceValue=value,node}function createType(type){assert_1.assert(null!=type);var node=new Node;return node.kind=NodeKind.TYPE,node.resolvedType=type,node}function createAny(){var node=new Node;return node.kind=NodeKind.ANY,node}function createEmpty(){var node=new Node;return node.kind=NodeKind.EMPTY,node}function createExpression(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.EXPRESSION,node.appendChild(value),node}function createBlock(){var node=new Node;return node.kind=NodeKind.BLOCK,node}function createModule(name){var node=new Node;return node.kind=NodeKind.MODULE,node.stringValue=name,node}function createClass(name){var node=new Node;return node.kind=NodeKind.CLASS,node.stringValue=name,node}function createEnum(name){var node=new Node;return node.kind=NodeKind.ENUM,node.stringValue=name,node}function createIf(value,trueBranch,falseBranch){assert_1.assert(isExpression(value)),assert_1.assert(trueBranch.kind==NodeKind.BLOCK),assert_1.assert(null==falseBranch||falseBranch.kind==NodeKind.BLOCK);var node=new Node;return node.kind=NodeKind.IF,node.appendChild(value),node.appendChild(trueBranch),null!=falseBranch&&node.appendChild(falseBranch),node}function createWhile(value,body){assert_1.assert(isExpression(value)),assert_1.assert(body.kind==NodeKind.BLOCK);var node=new Node;return node.kind=NodeKind.WHILE,node.appendChild(value),node.appendChild(body),node}function createReturn(value){assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.RETURN,null!=value&&node.appendChild(value),node}function createImports(){var node=new Node;return node.kind=NodeKind.IMPORTS,node}function createImport(name){var node=new Node;return node.kind=NodeKind.IMPORT,node.stringValue=name,node}function createImportFrom(name){var node=new Node;return node.kind=NodeKind.IMPORT_FROM,node.stringValue=name,node}function createVariables(){var node=new Node;return node.kind=NodeKind.VARIABLES,node}function createConstants(){var node=new Node;return node.kind=NodeKind.CONSTANTS,node}function createParameters(){var node=new Node;return node.kind=NodeKind.PARAMETERS,node}function createExtends(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.EXTENDS,node.appendChild(type),node}function createImplements(){var node=new Node;return node.kind=NodeKind.IMPLEMENTS,node}function createParameter(name){var node=new Node;return node.kind=NodeKind.PARAMETER,node.stringValue=name,node}function createVariable(name,type,value){assert_1.assert(null==type||isExpression(type)),assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.VARIABLE,node.stringValue=name,node.appendChild(null!=type?type:createEmpty()),null!=value&&node.appendChild(value),node}function createFunction(name){var node=new Node;return node.kind=NodeKind.FUNCTION,node.stringValue=name,node}function createUnary(kind,value){assert_1.assert(isUnary(kind)),assert_1.assert(isExpression(value));var node=new Node;return node.kind=kind,node.appendChild(value),node}function createBinary(kind,left,right){assert_1.assert(isBinary(kind)),assert_1.assert(isExpression(left)),assert_1.assert(isExpression(right));var node=new Node;return node.kind=kind,node.appendChild(left),node.appendChild(right),node}function createCall(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.CALL,node.appendChild(value),node}function createCast(value,type){assert_1.assert(isExpression(value)),assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.CAST,node.appendChild(value),node.appendChild(type),node}function createDot(value,name){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.DOT,node.stringValue=name,node.appendChild(value),node}function createSymbolReference(symbol){var node=createName(symbol.name);return node.symbol=symbol,node.resolvedType=symbol.resolvedType,node}function createMemberReference(value,symbol){var node=createDot(value,symbol.name);return node.symbol=symbol,node.resolvedType=symbol.resolvedType,node}function createParseError(){var node=new Node;return node.kind=NodeKind.PARSE_ERROR,node}function createJSNumber(){var node=new Node;return node.kind=NodeKind.JS_NUMBER,node}function createJSObject(){var node=new Node;return node.kind=NodeKind.JS_OBJECT,node}function createJSString(){var node=new Node;return node.kind=NodeKind.JS_STRING,node}function createJSArray(){var node=new Node;return node.kind=NodeKind.JS_ARRAY,node}Object.defineProperty(exports,"__esModule",{value:!0});var NodeKind,symbol_1=__webpack_require__(3),assert_1=__webpack_require__(0);!function(NodeKind){NodeKind[NodeKind.EXTENDS=0]="EXTENDS",NodeKind[NodeKind.FILE=1]="FILE",NodeKind[NodeKind.GLOBAL=2]="GLOBAL",NodeKind[NodeKind.IMPLEMENTS=3]="IMPLEMENTS",NodeKind[NodeKind.PARAMETER=4]="PARAMETER",NodeKind[NodeKind.PARAMETERS=5]="PARAMETERS",NodeKind[NodeKind.VARIABLE=6]="VARIABLE",NodeKind[NodeKind.IMPORT=7]="IMPORT",NodeKind[NodeKind.IMPORT_FROM=8]="IMPORT_FROM",NodeKind[NodeKind.BLOCK=9]="BLOCK",NodeKind[NodeKind.BREAK=10]="BREAK",NodeKind[NodeKind.MODULE=11]="MODULE",NodeKind[NodeKind.IMPORTS=12]="IMPORTS",NodeKind[NodeKind.CLASS=13]="CLASS",NodeKind[NodeKind.CONSTANTS=14]="CONSTANTS",NodeKind[NodeKind.CONTINUE=15]="CONTINUE",NodeKind[NodeKind.EMPTY=16]="EMPTY",NodeKind[NodeKind.ENUM=17]="ENUM",NodeKind[NodeKind.EXPRESSION=18]="EXPRESSION",NodeKind[NodeKind.FUNCTION=19]="FUNCTION",NodeKind[NodeKind.IF=20]="IF",NodeKind[NodeKind.RETURN=21]="RETURN",NodeKind[NodeKind.UNSAFE=22]="UNSAFE",NodeKind[NodeKind.JAVASCRIPT=23]="JAVASCRIPT",NodeKind[NodeKind.START=24]="START",NodeKind[NodeKind.VARIABLES=25]="VARIABLES",NodeKind[NodeKind.WHILE=26]="WHILE",NodeKind[NodeKind.ALIGN_OF=27]="ALIGN_OF",NodeKind[NodeKind.BOOLEAN=28]="BOOLEAN",NodeKind[NodeKind.CALL=29]="CALL",NodeKind[NodeKind.CAST=30]="CAST",NodeKind[NodeKind.DOT=31]="DOT",NodeKind[NodeKind.HOOK=32]="HOOK",NodeKind[NodeKind.INDEX=33]="INDEX",NodeKind[NodeKind.POINTER_INDEX=34]="POINTER_INDEX",NodeKind[NodeKind.ANY=35]="ANY",NodeKind[NodeKind.INT32=36]="INT32",NodeKind[NodeKind.INT64=37]="INT64",NodeKind[NodeKind.FLOAT32=38]="FLOAT32",NodeKind[NodeKind.FLOAT64=39]="FLOAT64",NodeKind[NodeKind.ARRAY=40]="ARRAY",NodeKind[NodeKind.GENERIC=41]="GENERIC",NodeKind[NodeKind.NAME=42]="NAME",NodeKind[NodeKind.NEW=43]="NEW",NodeKind[NodeKind.DELETE=44]="DELETE",NodeKind[NodeKind.NULL=45]="NULL",NodeKind[NodeKind.UNDEFINED=46]="UNDEFINED",NodeKind[NodeKind.PARSE_ERROR=47]="PARSE_ERROR",NodeKind[NodeKind.SIZE_OF=48]="SIZE_OF",NodeKind[NodeKind.STRING=49]="STRING",NodeKind[NodeKind.THIS=50]="THIS",NodeKind[NodeKind.TYPE=51]="TYPE",NodeKind[NodeKind.ADDRESS_OF=52]="ADDRESS_OF",NodeKind[NodeKind.COMPLEMENT=53]="COMPLEMENT",NodeKind[NodeKind.DEREFERENCE=54]="DEREFERENCE",NodeKind[NodeKind.NEGATIVE=55]="NEGATIVE",NodeKind[NodeKind.NOT=56]="NOT",NodeKind[NodeKind.POINTER_TYPE=57]="POINTER_TYPE",NodeKind[NodeKind.POSITIVE=58]="POSITIVE",NodeKind[NodeKind.POSTFIX_DECREMENT=59]="POSTFIX_DECREMENT",NodeKind[NodeKind.POSTFIX_INCREMENT=60]="POSTFIX_INCREMENT",NodeKind[NodeKind.PREFIX_DECREMENT=61]="PREFIX_DECREMENT",NodeKind[NodeKind.PREFIX_INCREMENT=62]="PREFIX_INCREMENT",NodeKind[NodeKind.ADD=63]="ADD",NodeKind[NodeKind.ASSIGN=64]="ASSIGN",NodeKind[NodeKind.BITWISE_AND=65]="BITWISE_AND",NodeKind[NodeKind.BITWISE_OR=66]="BITWISE_OR",NodeKind[NodeKind.BITWISE_XOR=67]="BITWISE_XOR",NodeKind[NodeKind.DIVIDE=68]="DIVIDE",NodeKind[NodeKind.EQUAL=69]="EQUAL",NodeKind[NodeKind.EXPONENT=70]="EXPONENT",NodeKind[NodeKind.GREATER_THAN=71]="GREATER_THAN",NodeKind[NodeKind.GREATER_THAN_EQUAL=72]="GREATER_THAN_EQUAL",NodeKind[NodeKind.LESS_THAN=73]="LESS_THAN",NodeKind[NodeKind.LESS_THAN_EQUAL=74]="LESS_THAN_EQUAL",NodeKind[NodeKind.LOGICAL_AND=75]="LOGICAL_AND",NodeKind[NodeKind.LOGICAL_OR=76]="LOGICAL_OR",NodeKind[NodeKind.MULTIPLY=77]="MULTIPLY",NodeKind[NodeKind.NOT_EQUAL=78]="NOT_EQUAL",NodeKind[NodeKind.REMAINDER=79]="REMAINDER",NodeKind[NodeKind.SHIFT_LEFT=80]="SHIFT_LEFT",NodeKind[NodeKind.SHIFT_RIGHT=81]="SHIFT_RIGHT",NodeKind[NodeKind.SUBTRACT=82]="SUBTRACT",NodeKind[NodeKind.JS_NUMBER=83]="JS_NUMBER",NodeKind[NodeKind.JS_OBJECT=84]="JS_OBJECT",NodeKind[NodeKind.JS_STRING=85]="JS_STRING",NodeKind[NodeKind.JS_ARRAY=86]="JS_ARRAY"}(NodeKind=exports.NodeKind||(exports.NodeKind={})),exports.isUnary=isUnary,exports.isUnaryPostfix=isUnaryPostfix,exports.isBinary=isBinary,exports.invertedBinaryKind=invertedBinaryKind,exports.isExpression=isExpression,exports.isCompactNodeKind=isCompactNodeKind,exports.NODE_FLAG_DECLARE=1,exports.NODE_FLAG_EXPORT=2,exports.NODE_FLAG_IMPORT=4,exports.NODE_FLAG_LIBRARY=8,exports.NODE_FLAG_GET=16,exports.NODE_FLAG_OPERATOR=32,exports.NODE_FLAG_POSITIVE=64,exports.NODE_FLAG_PRIVATE=128,exports.NODE_FLAG_PROTECTED=256,exports.NODE_FLAG_PUBLIC=512,exports.NODE_FLAG_SET=1024,exports.NODE_FLAG_STATIC=2048,exports.NODE_FLAG_UNSAFE=4096,exports.NODE_FLAG_JAVASCRIPT=8192,exports.NODE_FLAG_UNSIGNED_OPERATOR=16384,exports.NODE_FLAG_VIRTUAL=32768,exports.NODE_FLAG_START=65536,exports.NODE_FLAG_ANYFUNC=1<<17,exports.NODE_FLAG_GENERIC=1<<18;var NodeFlag=function(){function NodeFlag(){}return NodeFlag}();exports.NodeFlag=NodeFlag,exports.appendFlag=appendFlag,exports.allFlags=allFlags,exports.rangeForFlag=rangeForFlag;var Node=function(){function Node(){}return Object.defineProperty(Node.prototype,"hasValue",{get:function(){return this._hasValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"rawValue",{get:function(){return this._hasStringValue?'"'+this._rawValue+'"':this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"__internal_rawValue",{get:function(){return this._rawValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"intValue",{get:function(){var n=this._rawValue;return Number(n)===n&&n%1==0?this._rawValue:null},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"longValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"floatValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"doubleValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"stringValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._hasStringValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"referenceValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Node.prototype.becomeTypeOf=function(node,context){switch(node.resolvedType){case context.int64Type:this.kind!=NodeKind.NAME&&(this.kind=NodeKind.INT64),this.resolvedType=context.int64Type;break;case context.float64Type:this.kind!=NodeKind.NAME&&(this.kind=NodeKind.FLOAT64),this.resolvedType=context.float64Type}node.flags&&(this.flags=node.flags)},Node.prototype.becomeValueTypeOf=function(symbol,context){if(symbol.resolvedType.symbol)switch(symbol.resolvedType){case context.int64Type:this.resolvedType=context.int64Type,this.kind==NodeKind.NULL&&(this.longValue=0),this.kind!=NodeKind.NAME&&(this.kind=NodeKind.INT64);break;case context.float64Type:this.resolvedType=context.float64Type,this.kind==NodeKind.NULL&&(this.doubleValue=0),this.kind!=NodeKind.NAME&&(this.kind=NodeKind.FLOAT64)}},Node.prototype.clone=function(){var node=new Node;return node.kind=this.kind,void 0!==this.offset&&(node.offset=this.offset),void 0!==this.flags&&(node.flags=this.flags),void 0!==this.firstFlag&&(node.firstFlag=this.firstFlag),void 0!==this.range&&(node.range=this.range),void 0!==this.internalRange&&(node.internalRange=this.internalRange),this.hasValue&&(node.rawValue=this.__internal_rawValue),node},Node.prototype.becomeSymbolReference=function(symbol){this.kind=NodeKind.NAME,this.symbol=symbol,this.referenceValue=symbol.name,this.resolvedType=symbol.resolvedType,this.removeChildren()},Node.prototype.becomeIntegerConstant=function(value){this.kind=NodeKind.INT32,this.symbol=null,this.intValue=value,this.removeChildren()},Node.prototype.becomeLongConstant=function(value){this.kind=NodeKind.INT64,this.symbol=null,this.longValue=value,this.removeChildren()},Node.prototype.becomeFloatConstant=function(value){this.kind=NodeKind.FLOAT32,this.symbol=null,this.floatValue=value,this.removeChildren()},Node.prototype.becomeDoubleConstant=function(value){this.kind=NodeKind.FLOAT64,this.symbol=null,this.doubleValue=value,this.removeChildren()},Node.prototype.becomeBooleanConstant=function(value){this.kind=NodeKind.BOOLEAN,this.symbol=null,this.intValue=value?1:0,this.removeChildren()},Node.prototype.isNegativeInteger=function(){return this.kind==NodeKind.INT32&&this.intValue<0},Node.prototype.isNonNegativeInteger=function(){return this.kind==NodeKind.INT32&&this.intValue>=0},Node.prototype.isDeclare=function(){return 0!=(this.flags&exports.NODE_FLAG_DECLARE)},Node.prototype.isLibrary=function(){return 0!=(this.flags&exports.NODE_FLAG_LIBRARY)},Node.prototype.isVirtual=function(){return 0!=(this.flags&exports.NODE_FLAG_VIRTUAL)},Node.prototype.isExport=function(){return 0!=(this.flags&exports.NODE_FLAG_EXPORT)},Node.prototype.isImport=function(){return 0!=(this.flags&exports.NODE_FLAG_IMPORT)},Node.prototype.isExternalImport=function(){return this.isDeclare()&&!this.isLibrary()},Node.prototype.isStart=function(){return 0!=(this.flags&exports.NODE_FLAG_START)},Node.prototype.isJavaScript=function(){return 0!=(this.flags&exports.NODE_FLAG_JAVASCRIPT)},Node.prototype.isStatic=function(){return 0!=(this.flags&exports.NODE_FLAG_STATIC)},Node.prototype.isAnyfunc=function(){return 0!=(this.flags&exports.NODE_FLAG_ANYFUNC)},Node.prototype.isDeclareOrJavaScript=function(){return 0!=(this.flags&(exports.NODE_FLAG_DECLARE|exports.NODE_FLAG_JAVASCRIPT))},Node.prototype.isDeclareOrExport=function(){return 0!=(this.flags&(exports.NODE_FLAG_DECLARE|exports.NODE_FLAG_EXPORT))},Node.prototype.isGet=function(){return 0!=(this.flags&exports.NODE_FLAG_GET)},Node.prototype.isSet=function(){return 0!=(this.flags&exports.NODE_FLAG_SET)},Node.prototype.isOperator=function(){return 0!=(this.flags&exports.NODE_FLAG_OPERATOR)},Node.prototype.isPositive=function(){return 0!=(this.flags&exports.NODE_FLAG_POSITIVE)},Node.prototype.isPrivate=function(){return 0!=(this.flags&exports.NODE_FLAG_PRIVATE)},Node.prototype.isUnsafe=function(){return 0!=(this.flags&exports.NODE_FLAG_UNSAFE)},Node.prototype.isGeneric=function(){return 0!=(this.flags&exports.NODE_FLAG_GENERIC)},Node.prototype.isTemplate=function(){return this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_IS_TEMPLATE)},Node.prototype.isUnsignedOperator=function(){return 0!=(this.flags&exports.NODE_FLAG_UNSIGNED_OPERATOR)},Node.prototype.childCount=function(){for(var count=0,child=this.firstChild;null!=child;)count+=1,child=child.nextSibling;return count},Node.prototype.parameterCount=function(){var count=0,child=this.firstChild;if(child.kind==NodeKind.PARAMETERS)for(child=child.firstChild;null!=child;)count+=1,child=child.nextSibling;return count},Node.prototype.hasParameters=function(){if(this.firstChild){var child=this.firstChild;if(child.kind==NodeKind.PARAMETERS)return child.childCount()>0}return!1},Node.prototype.appendChild=function(child){child.parent=this,null==this.firstChild?(this.firstChild=child,this.firstChild.offset=0):(child.previousSibling=this.lastChild,this.lastChild.nextSibling=child,child.offset=this.lastChild.offset+1),this.lastChild=child},Node.prototype.insertChildBefore=function(after,before){if(null!=before){if(assert_1.assert(before!=after),assert_1.assert(null==before.parent),assert_1.assert(null==before.previousSibling),assert_1.assert(null==before.nextSibling),assert_1.assert(null==after||after.parent==this),null==after)return void this.appendChild(before);before.parent=this,before.previousSibling=after.previousSibling,before.nextSibling=after,null!=after.previousSibling?(assert_1.assert(after==after.previousSibling.nextSibling),after.previousSibling.nextSibling=before):(assert_1.assert(after==this.firstChild),this.firstChild=before),after.previousSibling=before}},Node.prototype.insertChildAfter=function(before,after){if(null!=after){if(assert_1.assert(before!=after),assert_1.assert(null==after.parent),assert_1.assert(null==after.previousSibling),assert_1.assert(null==after.nextSibling),assert_1.assert(null==before||before.parent==this),null==before)return void this.appendChild(after);after.parent=this,after.previousSibling=before,after.nextSibling=before.nextSibling,null!=before.nextSibling&&(assert_1.assert(before==before.nextSibling.previousSibling),before.nextSibling.previousSibling=after),before.nextSibling=after}},Node.prototype.remove=function(){return assert_1.assert(null!=this.parent),null!=this.previousSibling?(assert_1.assert(this.previousSibling.nextSibling==this),this.previousSibling.nextSibling=this.nextSibling):(assert_1.assert(this.parent.firstChild==this),this.parent.firstChild=this.nextSibling),null!=this.nextSibling?(assert_1.assert(this.nextSibling.previousSibling==this),this.nextSibling.previousSibling=this.previousSibling):(assert_1.assert(this.parent.lastChild==this),this.parent.lastChild=this.previousSibling),this.parent=null,this.previousSibling=null,this.nextSibling=null,this},Node.prototype.removeChildren=function(){for(;null!=this.lastChild;)this.lastChild.remove()},Node.prototype.replaceWith=function(node){assert_1.assert(node!=this),assert_1.assert(null!=this.parent),assert_1.assert(null==node.parent),assert_1.assert(null==node.previousSibling),assert_1.assert(null==node.nextSibling),node.parent=this.parent,node.previousSibling=this.previousSibling,node.nextSibling=this.nextSibling,null!=this.previousSibling?(assert_1.assert(this.previousSibling.nextSibling==this),this.previousSibling.nextSibling=node):(assert_1.assert(this.parent.firstChild==this),this.parent.firstChild=node),null!=this.nextSibling?(assert_1.assert(this.nextSibling.previousSibling==this),this.nextSibling.previousSibling=node):(assert_1.assert(this.parent.lastChild==this),this.parent.lastChild=node),this.parent=null,this.previousSibling=null,this.nextSibling=null},Node.prototype.isType=function(){return this.kind==NodeKind.TYPE||this.kind==NodeKind.POINTER_TYPE||null!=this.symbol&&symbol_1.isType(this.symbol.kind)},Node.prototype.isCallValue=function(){return this.parent.kind==NodeKind.CALL&&this==this.parent.callValue()},Node.prototype.isAssignTarget=function(){return this.parent.kind==NodeKind.ASSIGN&&this==this.parent.binaryLeft()},Node.prototype.withRange=function(range){return this.range=range,this},Node.prototype.withInternalRange=function(range){return this.internalRange=range,this},Node.prototype.functionFirstArgument=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2);var child=this.firstChild;return child.kind==NodeKind.PARAMETERS&&(child=child.nextSibling),child},Node.prototype.functionLastArgument=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2);var child=this.firstChild;child.kind==NodeKind.PARAMETERS&&(child=child.nextSibling);for(var lastArgument=null;null!=child;){var nextChild=child.nextSibling;nextChild.kind!==NodeKind.VARIABLE?(lastArgument=child,child=null):child=nextChild}return lastArgument},Node.prototype.functionFirstArgumentIgnoringThis=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(null!=this.symbol);var child=this.functionFirstArgument();return this.symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE&&(child=child.nextSibling),child},Node.prototype.functionReturnType=function(){return assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(isExpression(this.lastChild.previousSibling)),this.lastChild.previousSibling},Node.prototype.constructorNode=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>0),assert_1.assert(this.resolvedType.symbol.node.kind==NodeKind.CLASS),this.resolvedType.symbol.node.constructorFunctionNode},Node.prototype.functionBody=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(this.lastChild.kind==NodeKind.BLOCK||this.lastChild.kind==NodeKind.EMPTY);var body=this.lastChild;return body.kind==NodeKind.BLOCK?body:null},Node.prototype.newType=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.deleteType=function(){return assert_1.assert(this.kind==NodeKind.DELETE),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.callValue=function(){return assert_1.assert(this.kind==NodeKind.CALL),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.castValue=function(){return assert_1.assert(this.kind==NodeKind.CAST),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.castType=function(){return assert_1.assert(this.kind==NodeKind.CAST),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.alignOfType=function(){return assert_1.assert(this.kind==NodeKind.ALIGN_OF),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.sizeOfType=function(){return assert_1.assert(this.kind==NodeKind.SIZE_OF),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.dotTarget=function(){return assert_1.assert(this.kind==NodeKind.DOT),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.returnValue=function(){return assert_1.assert(this.kind==NodeKind.RETURN),assert_1.assert(this.childCount()<=1),assert_1.assert(null==this.firstChild||isExpression(this.firstChild)),this.firstChild},Node.prototype.ifReturnNode=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(null!==this.firstChild),assert_1.assert(null!==this.firstChild.nextSibling),this.firstChild.nextSibling.returnNode||null},Node.prototype.deleteValue=function(){return assert_1.assert(this.kind==NodeKind.DELETE),assert_1.assert(this.childCount()<=1),assert_1.assert(null==this.firstChild||isExpression(this.firstChild)),this.firstChild},Node.prototype.extendsType=function(){return assert_1.assert(this.kind==NodeKind.EXTENDS),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.firstGenericType=function(){return assert_1.assert(this.firstChild.kind==NodeKind.PARAMETERS),assert_1.assert(this.firstChild.childCount()>0),this.firstChild.firstChild},Node.prototype.variableType=function(){assert_1.assert(this.kind==NodeKind.VARIABLE),assert_1.assert(this.childCount()<=2),assert_1.assert(isExpression(this.firstChild)||this.firstChild.kind==NodeKind.EMPTY);var type=this.firstChild;return type.kind!=NodeKind.EMPTY?type:null},Node.prototype.variableValue=function(){return assert_1.assert(this.kind==NodeKind.VARIABLE),assert_1.assert(this.childCount()<=2),assert_1.assert(null==this.firstChild.nextSibling||isExpression(this.firstChild.nextSibling)),this.firstChild.nextSibling},Node.prototype.hasVariableValue=function(){return assert_1.assert(this.kind==NodeKind.VARIABLE),void 0!=this.firstChild&&void 0!=this.firstChild.nextSibling},Node.prototype.expressionValue=function(){return assert_1.assert(this.kind==NodeKind.EXPRESSION),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.binaryLeft=function(){return assert_1.assert(isBinary(this.kind)),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.binaryRight=function(){return assert_1.assert(isBinary(this.kind)),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.unaryValue=function(){return assert_1.assert(isUnary(this.kind)),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.pointer=function(){return assert_1.assert(this.kind==NodeKind.POINTER_INDEX),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.pointerOffset=function(){return assert_1.assert(this.firstChild),assert_1.assert(this.firstChild.nextSibling),this.firstChild.nextSibling.intValue},Node.prototype.whileValue=function(){return assert_1.assert(this.kind==NodeKind.WHILE),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.whileBody=function(){return assert_1.assert(this.kind==NodeKind.WHILE),assert_1.assert(2==this.childCount()),assert_1.assert(this.lastChild.kind==NodeKind.BLOCK),this.lastChild},Node.prototype.hookValue=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.hookTrue=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.firstChild.nextSibling)),this.firstChild.nextSibling},Node.prototype.hookFalse=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.indexTarget=function(){return assert_1.assert(this.kind==NodeKind.INDEX),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.ifValue=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.ifTrue=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(this.firstChild.nextSibling.kind==NodeKind.BLOCK),this.firstChild.nextSibling},Node.prototype.ifFalse=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(null==this.firstChild.nextSibling.nextSibling||this.firstChild.nextSibling.nextSibling.kind==NodeKind.BLOCK),this.firstChild.nextSibling.nextSibling||null},Node.prototype.expandCallIntoOperatorTree=function(){if(this.kind!=NodeKind.CALL)return!1;var value=this.callValue(),symbol=value.symbol;if(value.kind==NodeKind.DOT&&symbol.node.isOperator()&&symbol.node.isDeclare()){var binaryKind=NodeKind.NULL;if("%"==symbol.name?binaryKind=NodeKind.REMAINDER:"&"==symbol.name?binaryKind=NodeKind.BITWISE_AND:"*"==symbol.name?binaryKind=NodeKind.MULTIPLY:"**"==symbol.name?binaryKind=NodeKind.EXPONENT:"/"==symbol.name?binaryKind=NodeKind.DIVIDE:"<"==symbol.name?binaryKind=NodeKind.LESS_THAN:"<<"==symbol.name?binaryKind=NodeKind.SHIFT_LEFT:"=="==symbol.name?binaryKind=NodeKind.EQUAL:">"==symbol.name?binaryKind=NodeKind.GREATER_THAN:">>"==symbol.name?binaryKind=NodeKind.SHIFT_RIGHT:"[]"==symbol.name?binaryKind=NodeKind.INDEX:"^"==symbol.name?binaryKind=NodeKind.BITWISE_XOR:"|"==symbol.name&&(binaryKind=NodeKind.BITWISE_OR),binaryKind!=NodeKind.NULL)return this.kind=binaryKind,value.remove(),this.insertChildBefore(this.firstChild,value.dotTarget().remove()),!0;if("[]="==symbol.name){this.kind=NodeKind.ASSIGN;var target=createIndex(value.remove().dotTarget().remove());return target.appendChild(this.firstChild.remove()),this.insertChildBefore(this.firstChild,target),!0}}return!1},Node.prototype.arrayLength=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),assert_1.assert(this.firstChild.resolvedType.isArray()),this.firstChild.nextSibling},Node}();exports.Node=Node,exports.createNew=createNew,exports.createDelete=createDelete,exports.createHook=createHook,exports.createIndex=createIndex,exports.createNull=createNull,exports.createUndefined=createUndefined,exports.createThis=createThis,exports.createAddressOf=createAddressOf,exports.createDereference=createDereference,exports.createAlignOf=createAlignOf,exports.createSizeOf=createSizeOf,exports.createboolean=createboolean,exports.createInt=createInt,exports.createLong=createLong,exports.createFloat=createFloat,exports.createDouble=createDouble,exports.createString=createString,exports.createArray=createArray,exports.createName=createName,exports.createType=createType,exports.createAny=createAny,exports.createEmpty=createEmpty,exports.createExpression=createExpression,exports.createBlock=createBlock,exports.createModule=createModule,exports.createClass=createClass,exports.createEnum=createEnum,exports.createIf=createIf,exports.createWhile=createWhile,exports.createReturn=createReturn,exports.createImports=createImports,exports.createImport=createImport,exports.createImportFrom=createImportFrom,exports.createVariables=createVariables,exports.createConstants=createConstants,exports.createParameters=createParameters,exports.createExtends=createExtends,exports.createImplements=createImplements,exports.createParameter=createParameter,exports.createVariable=createVariable,exports.createFunction=createFunction,exports.createUnary=createUnary,exports.createBinary=createBinary,exports.createCall=createCall,exports.createCast=createCast,exports.createDot=createDot,exports.createSymbolReference=createSymbolReference,exports.createMemberReference=createMemberReference,exports.createParseError=createParseError,exports.createJSNumber=createJSNumber,exports.createJSObject=createJSObject,exports.createJSString=createJSString,exports.createJSArray=createJSArray},function(module,exports,__webpack_require__){"use strict";function toHex(value,size){if(void 0===size&&(size=7),void 0==value||null==value)return"";for(var hex=value.toString(16),zero=[],i=0;i0&&0==(value&value-1)}function alignToNextMultipleOf(offset,alignment){return assert_1.assert(isPositivePowerOf2(alignment)),offset+alignment-1&-alignment}Object.defineProperty(exports,"__esModule",{value:!0});var assert_1=__webpack_require__(0);exports.toHex=toHex,exports.isPositivePowerOf2=isPositivePowerOf2,exports.alignToNextMultipleOf=alignToNextMultipleOf},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmType;!function(WasmType){WasmType[WasmType.VOID=0]="VOID",WasmType[WasmType.I32=127]="I32",WasmType[WasmType.I64=126]="I64",WasmType[WasmType.F32=125]="F32",WasmType[WasmType.F64=124]="F64",WasmType[WasmType.anyfunc=112]="anyfunc",WasmType[WasmType.func=96]="func",WasmType[WasmType.block_type=64]="block_type"}(WasmType=exports.WasmType||(exports.WasmType={}));var WasmWrappedType=function(){function WasmWrappedType(){}return WasmWrappedType}();exports.WasmWrappedType=WasmWrappedType;var idTostring={};idTostring[WasmType.VOID]="void",idTostring[WasmType.I32]="i32",idTostring[WasmType.I64]="i64",idTostring[WasmType.F32]="f32",idTostring[WasmType.F64]="f64",exports.WasmTypeToString=idTostring},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WasmOpcode={UNREACHABLE:0,NOP:1,BLOCK:2,LOOP:3,IF:4,IF_ELSE:5,END:11,BR:12,BR_IF:13,BR_TABLE:14,RETURN:15,CALL:16,CALL_INDIRECT:17,DROP:26,SELECT:27,GET_LOCAL:32,SET_LOCAL:33,TEE_LOCAL:34,GET_GLOBAL:35,SET_GLOBAL:36,I32_LOAD:40,I64_LOAD:41,F32_LOAD:42,F64_LOAD:43,I32_LOAD8_S:44,I32_LOAD8_U:45,I32_LOAD16_S:46,I32_LOAD16_U:47,I64_LOAD8_S:48,I64_LOAD8_U:49,I64_LOAD16_S:50,I64_LOAD16_U:51,I64_LOAD32_S:52,I64_LOAD32_U:53,I32_STORE:54,I64_STORE:55,F32_STORE:56,F64_STORE:57,I32_STORE8:58,I32_STORE16:59,I64_STORE8:60,I64_STORE16:61,I64_STORE32:62,MEMORY_SIZE:63,GROW_MEMORY:64,I32_CONST:65,I64_CONST:66,F32_CONST:67,F64_CONST:68,I32_EQZ:69,I32_EQ:70,I32_NE:71,I32_LT_S:72,I32_LT_U:73,I32_GT_S:74,I32_GT_U:75,I32_LE_S:76,I32_LE_U:77,I32_GE_S:78,I32_GE_U:79,I64_EQZ:80,I64_EQ:81,I64_NE:82,I64_LT_S:83,I64_LT_U:84,I64_GT_S:85,I64_GT_U:86,I64_LE_S:87,I64_LE_U:88,I64_GE_S:89,I64_GE_U:90,F32_EQ:91,F32_NE:92,F32_LT:93,F32_GT:94,F32_LE:95,F32_GE:96,F64_EQ:97,F64_NE:98,F64_LT:99,F64_GT:100,F64_LE:101,F64_GE:102,I32_CLZ:103,I32_CTZ:104,I32_POPCNT:105,I32_ADD:106,I32_SUB:107,I32_MUL:108,I32_DIV_S:109,I32_DIV_U:110,I32_REM_S:111,I32_REM_U:112,I32_AND:113,I32_OR:114,I32_XOR:115,I32_SHL:116,I32_SHR_S:117,I32_SHR_U:118,I32_ROTL:119,I32_ROTR:120,I64_CLZ:121,I64_CTZ:122,I64_POPCNT:123,I64_ADD:124,I64_SUB:125,I64_MUL:126,I64_DIV_S:127,I64_DIV_U:128,I64_REM_S:129,I64_REM_U:130,I64_AND:131,I64_OR:132,I64_XOR:133,I64_SHL:134,I64_SHR_S:135,I64_SHR_U:136,I64_ROTL:137,I64_ROTR:138,F32_ABS:139,F32_NEG:140,F32_CEIL:141,F32_FLOOR:142,F32_TRUNC:143,F32_NEAREST:144,F32_SQRT:145,F32_ADD:146,F32_SUB:147,F32_MUL:148,F32_DIV:149,F32_MIN:150,F32_MAX:151,F32_COPYSIGN:152,F64_ABS:153,F64_NEG:154,F64_CEIL:155,F64_FLOOR:156,F64_TRUNC:157,F64_NEAREST:158,F64_SQRT:159,F64_ADD:160,F64_SUB:161,F64_MUL:162,F64_DIV:163,F64_MIN:164,F64_MAX:165,F64_COPYSIGN:166,I32_WRAP_I64:167,I32_TRUNC_S_F32:168,I32_TRUNC_U_F32:169,I32_TRUNC_S_F64:170,I32_TRUNC_U_F64:171,I64_EXTEND_S_I32:172,I64_EXTEND_U_I32:173,I64_TRUNC_S_F32:174,I64_TRUNC_U_F32:175,I64_TRUNC_S_F64:176,I64_TRUNC_U_F64:177,F32_CONVERT_S_I32:178,F32_CONVERT_U_I32:179,F32_CONVERT_S_I64:180,F32_CONVERT_U_I64:181,F32_DEMOTE_F64:182,F64_CONVERT_S_I32:183,F64_CONVERT_U_I32:184,F64_CONVERT_S_I64:185,F64_CONVERT_U_I64:186,F64_PROMOTE_F32:187,I32_REINTERPRET_F32:188,I64_REINTERPRET_F64:189,F32_REINTERPRET_I32:190,F64_REINTERPRET_I64:191},exports.WasmOpcode[exports.WasmOpcode.UNREACHABLE]="unreachable",exports.WasmOpcode[exports.WasmOpcode.NOP]="nop",exports.WasmOpcode[exports.WasmOpcode.BLOCK]="block",exports.WasmOpcode[exports.WasmOpcode.LOOP]="loop",exports.WasmOpcode[exports.WasmOpcode.IF]="if",exports.WasmOpcode[exports.WasmOpcode.IF_ELSE]="else",exports.WasmOpcode[exports.WasmOpcode.END]="end",exports.WasmOpcode[exports.WasmOpcode.BR]="br",exports.WasmOpcode[exports.WasmOpcode.BR_IF]="br_if",exports.WasmOpcode[exports.WasmOpcode.BR_TABLE]="br_table",exports.WasmOpcode[exports.WasmOpcode.RETURN]="return",exports.WasmOpcode[exports.WasmOpcode.CALL]="call",exports.WasmOpcode[exports.WasmOpcode.CALL_INDIRECT]="call_indirect",exports.WasmOpcode[exports.WasmOpcode.DROP]="drop",exports.WasmOpcode[exports.WasmOpcode.SELECT]="select",exports.WasmOpcode[exports.WasmOpcode.GET_LOCAL]="get_local",exports.WasmOpcode[exports.WasmOpcode.SET_LOCAL]="set_local",exports.WasmOpcode[exports.WasmOpcode.TEE_LOCAL]="tee_local",exports.WasmOpcode[exports.WasmOpcode.GET_GLOBAL]="get_global",exports.WasmOpcode[exports.WasmOpcode.SET_GLOBAL]="set_global",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD]="i32.load",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD]="i64.load",exports.WasmOpcode[exports.WasmOpcode.F32_LOAD]="f32.load",exports.WasmOpcode[exports.WasmOpcode.F64_LOAD]="f64.load",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD8_S]="i32.load8_s",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD8_U]="i32_load8_u",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD16_S]="i32_load16_s",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD16_U]="i32_load16_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD8_S]="i64.load8_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD8_U]="i64.load8_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD16_S]="i64.load16_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD16_U]="i64.load16_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD32_S]="i64.load32_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD32_U]="i64.load32_u",exports.WasmOpcode[exports.WasmOpcode.I32_STORE]="i32.store",exports.WasmOpcode[exports.WasmOpcode.I64_STORE]="i64.store",exports.WasmOpcode[exports.WasmOpcode.F32_STORE]="f32.store",exports.WasmOpcode[exports.WasmOpcode.F64_STORE]="f64.store",exports.WasmOpcode[exports.WasmOpcode.I32_STORE8]="i32.store8",exports.WasmOpcode[exports.WasmOpcode.I32_STORE16]="i32.store16",exports.WasmOpcode[exports.WasmOpcode.I64_STORE8]="i64.store8",exports.WasmOpcode[exports.WasmOpcode.I64_STORE16]="i64.store16",exports.WasmOpcode[exports.WasmOpcode.I64_STORE32]="i64.store32",exports.WasmOpcode[exports.WasmOpcode.MEMORY_SIZE]="current_memory",exports.WasmOpcode[exports.WasmOpcode.GROW_MEMORY]="grow_memory",exports.WasmOpcode[exports.WasmOpcode.I32_CONST]="i32.const",exports.WasmOpcode[exports.WasmOpcode.I64_CONST]="i64.const",exports.WasmOpcode[exports.WasmOpcode.F32_CONST]="f32.const",exports.WasmOpcode[exports.WasmOpcode.F64_CONST]="f64.const",exports.WasmOpcode[exports.WasmOpcode.I32_EQZ]="i32.eqz",exports.WasmOpcode[exports.WasmOpcode.I32_EQ]="i32.eq",exports.WasmOpcode[exports.WasmOpcode.I32_NE]="i32.ne",exports.WasmOpcode[exports.WasmOpcode.I32_LT_S]="i32.lt_s",exports.WasmOpcode[exports.WasmOpcode.I32_LT_U]="i32.lt_u",exports.WasmOpcode[exports.WasmOpcode.I32_GT_S]="i32.gt_s",exports.WasmOpcode[exports.WasmOpcode.I32_GT_U]="i32.gt_u",exports.WasmOpcode[exports.WasmOpcode.I32_LE_S]="i32.le_s",exports.WasmOpcode[exports.WasmOpcode.I32_LE_U]="i32.le_u",exports.WasmOpcode[exports.WasmOpcode.I32_GE_S]="i32.ge_s",exports.WasmOpcode[exports.WasmOpcode.I32_GE_U]="i32.ge_u",exports.WasmOpcode[exports.WasmOpcode.I64_EQZ]="i64.eqz",exports.WasmOpcode[exports.WasmOpcode.I64_EQ]="i64.eq",exports.WasmOpcode[exports.WasmOpcode.I64_NE]="i64.ne",exports.WasmOpcode[exports.WasmOpcode.I64_LT_S]="i64.lt_s",exports.WasmOpcode[exports.WasmOpcode.I64_LT_U]="i64.lt_u",exports.WasmOpcode[exports.WasmOpcode.I64_GT_S]="i64.gt_s",exports.WasmOpcode[exports.WasmOpcode.I64_GT_U]="i64.gt_u",exports.WasmOpcode[exports.WasmOpcode.I64_LE_S]="i64.le_s",exports.WasmOpcode[exports.WasmOpcode.I64_LE_U]="i64.le_u",exports.WasmOpcode[exports.WasmOpcode.I64_GE_S]="i64.ge_s",exports.WasmOpcode[exports.WasmOpcode.I64_GE_U]="i64.ge_u",exports.WasmOpcode[exports.WasmOpcode.F32_EQ]="f32.eq",exports.WasmOpcode[exports.WasmOpcode.F32_NE]="f32.ne",exports.WasmOpcode[exports.WasmOpcode.F32_LT]="f32.lt",exports.WasmOpcode[exports.WasmOpcode.F32_GT]="f32.gt",exports.WasmOpcode[exports.WasmOpcode.F32_LE]="f32.le",exports.WasmOpcode[exports.WasmOpcode.F32_GE]="f32.ge",exports.WasmOpcode[exports.WasmOpcode.F64_EQ]="f64.eq",exports.WasmOpcode[exports.WasmOpcode.F64_NE]="f64.ne",exports.WasmOpcode[exports.WasmOpcode.F64_LT]="f64.lt",exports.WasmOpcode[exports.WasmOpcode.F64_GT]="f64.gt",exports.WasmOpcode[exports.WasmOpcode.F64_LE]="f64.le",exports.WasmOpcode[exports.WasmOpcode.F64_GE]="f64.ge",exports.WasmOpcode[exports.WasmOpcode.I32_CLZ]="i32.clz",exports.WasmOpcode[exports.WasmOpcode.I32_CTZ]="i32.ctz",exports.WasmOpcode[exports.WasmOpcode.I32_POPCNT]="i32.popcnt",exports.WasmOpcode[exports.WasmOpcode.I32_ADD]="i32.add",exports.WasmOpcode[exports.WasmOpcode.I32_SUB]="i32.sub",exports.WasmOpcode[exports.WasmOpcode.I32_MUL]="i32.mul",exports.WasmOpcode[exports.WasmOpcode.I32_DIV_S]="i32.div_s",exports.WasmOpcode[exports.WasmOpcode.I32_DIV_U]="i32.div_u",exports.WasmOpcode[exports.WasmOpcode.I32_REM_S]="i32.rem_s",exports.WasmOpcode[exports.WasmOpcode.I32_REM_U]="i32.rem_u",exports.WasmOpcode[exports.WasmOpcode.I32_AND]="i32.and",exports.WasmOpcode[exports.WasmOpcode.I32_OR]="i32.or",exports.WasmOpcode[exports.WasmOpcode.I32_XOR]="i32.xor",exports.WasmOpcode[exports.WasmOpcode.I32_SHL]="i32.shl",exports.WasmOpcode[exports.WasmOpcode.I32_SHR_S]="i32.shr_s",exports.WasmOpcode[exports.WasmOpcode.I32_SHR_U]="i32.shr_u",exports.WasmOpcode[exports.WasmOpcode.I32_ROTL]="i32.rotl",exports.WasmOpcode[exports.WasmOpcode.I32_ROTR]="i32.rotr",exports.WasmOpcode[exports.WasmOpcode.I64_CLZ]="i64.clz",exports.WasmOpcode[exports.WasmOpcode.I64_CTZ]="i64.ctz",exports.WasmOpcode[exports.WasmOpcode.I64_POPCNT]="i64.popcnt",exports.WasmOpcode[exports.WasmOpcode.I64_ADD]="i64.add",exports.WasmOpcode[exports.WasmOpcode.I64_SUB]="i64.sub",exports.WasmOpcode[exports.WasmOpcode.I64_MUL]="i64.mul",exports.WasmOpcode[exports.WasmOpcode.I64_DIV_S]="i64.div_s",exports.WasmOpcode[exports.WasmOpcode.I64_DIV_U]="i64.div_u",exports.WasmOpcode[exports.WasmOpcode.I64_REM_S]="i64.rem_s",exports.WasmOpcode[exports.WasmOpcode.I64_REM_U]="i64.rem_u",exports.WasmOpcode[exports.WasmOpcode.I64_AND]="i64.and",exports.WasmOpcode[exports.WasmOpcode.I64_OR]="i64.or",exports.WasmOpcode[exports.WasmOpcode.I64_XOR]="i64.xor",exports.WasmOpcode[exports.WasmOpcode.I64_SHL]="i64.shl",exports.WasmOpcode[exports.WasmOpcode.I64_SHR_S]="i64.shr_s",exports.WasmOpcode[exports.WasmOpcode.I64_SHR_U]="i64.shr_u",exports.WasmOpcode[exports.WasmOpcode.I64_ROTL]="i64.rotl",exports.WasmOpcode[exports.WasmOpcode.I64_ROTR]="i64.rotr",exports.WasmOpcode[exports.WasmOpcode.F32_ABS]="f32.abs",exports.WasmOpcode[exports.WasmOpcode.F32_NEG]="f32.neg",exports.WasmOpcode[exports.WasmOpcode.F32_CEIL]="f32.ceil",exports.WasmOpcode[exports.WasmOpcode.F32_FLOOR]="f32.floor",exports.WasmOpcode[exports.WasmOpcode.F32_TRUNC]="f32.trunc",exports.WasmOpcode[exports.WasmOpcode.F32_NEAREST]="f32.nearest",exports.WasmOpcode[exports.WasmOpcode.F32_SQRT]="f32.sqrt",exports.WasmOpcode[exports.WasmOpcode.F32_ADD]="f32.add",exports.WasmOpcode[exports.WasmOpcode.F32_SUB]="f32.sub",exports.WasmOpcode[exports.WasmOpcode.F32_MUL]="f32.mul",exports.WasmOpcode[exports.WasmOpcode.F32_DIV]="f32.div",exports.WasmOpcode[exports.WasmOpcode.F32_MIN]="f32.min",exports.WasmOpcode[exports.WasmOpcode.F32_MAX]="f32.max",exports.WasmOpcode[exports.WasmOpcode.F32_COPYSIGN]="f32.copysign",exports.WasmOpcode[exports.WasmOpcode.F64_ABS]="f64.abs",exports.WasmOpcode[exports.WasmOpcode.F64_NEG]="f64.neg",exports.WasmOpcode[exports.WasmOpcode.F64_CEIL]="f64.ceil",exports.WasmOpcode[exports.WasmOpcode.F64_FLOOR]="f64.floor",exports.WasmOpcode[exports.WasmOpcode.F64_TRUNC]="f64.trunc",exports.WasmOpcode[exports.WasmOpcode.F64_NEAREST]="f64.nearest",exports.WasmOpcode[exports.WasmOpcode.F64_SQRT]="f64.sqrt",exports.WasmOpcode[exports.WasmOpcode.F64_ADD]="f64.add",exports.WasmOpcode[exports.WasmOpcode.F64_SUB]="f64.sub",exports.WasmOpcode[exports.WasmOpcode.F64_MUL]="f64.mul",exports.WasmOpcode[exports.WasmOpcode.F64_DIV]="f64.div",exports.WasmOpcode[exports.WasmOpcode.F64_MIN]="f64.min",exports.WasmOpcode[exports.WasmOpcode.F64_MAX]="f64.max",exports.WasmOpcode[exports.WasmOpcode.F64_COPYSIGN]="f64.copysign",exports.WasmOpcode[exports.WasmOpcode.I32_WRAP_I64]="i32.wrap/i64",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_S_F32]="i32.trunc_s/f32",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_U_F32]="i32.trunc_u/f32",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_S_F64]="i32.trunc_s/f64",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_U_F64]="i32.trunc_u/f64",exports.WasmOpcode[exports.WasmOpcode.I64_EXTEND_S_I32]="i64.extend_s/i32",exports.WasmOpcode[exports.WasmOpcode.I64_EXTEND_U_I32]="i64.extend_u/i32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_S_F32]="i64.trunc_s/f32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_U_F32]="i64.trunc_u/f32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_S_F64]="i64.trunc_s/f64",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_U_F64]="i64.trunc_u/f64",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_S_I32]="f32.convert_s/i32",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_U_I32]="f32.convert_u/i32",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_S_I64]="f32.convert_s/i64",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_U_I64]="f32.convert_u/i64",exports.WasmOpcode[exports.WasmOpcode.F32_DEMOTE_F64]="f32.demote/f64",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_S_I32]="f64.convert_s/i32",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_U_I32]="f64.convert_u/i32",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_S_I64]="f64.convert_s/i64",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_U_I64]="f64.convert_u/i64",exports.WasmOpcode[exports.WasmOpcode.F64_PROMOTE_F32]="f64.promote/f32",exports.WasmOpcode[exports.WasmOpcode.I32_REINTERPRET_F32]="i32.reinterpret/f32",exports.WasmOpcode[exports.WasmOpcode.I64_REINTERPRET_F64]="i64.reinterpret/f64",exports.WasmOpcode[exports.WasmOpcode.F32_REINTERPRET_I32]="f32.reinterpret/i32",exports.WasmOpcode[exports.WasmOpcode.F64_REINTERPRET_I64]="f64.reinterpret/i64",Object.freeze(exports.WasmOpcode)},function(module,exports,__webpack_require__){"use strict";function isKeyword(kind){return kind>=TokenKind.ALIGNOF&&kind<=TokenKind.WHILE}function splitToken(first,firstKind,secondKind){var range=first.range;assert_1.assert(range.end-range.start>=2);var second=new Token;second.kind=secondKind,second.range=log_1.createRange(range.source,range.start+1,range.end),second.next=first.next,first.kind=firstKind,first.next=second,range.end=range.start+1}function tokenToString(token){return token==TokenKind.END_OF_FILE?"end of file":token==TokenKind.CHARACTER?"character literal":token==TokenKind.IDENTIFIER?"identifier":token==TokenKind.INT32?"integer32 literal":token==TokenKind.INT64?"integer64 literal":token==TokenKind.FLOAT32?"float32 literal":token==TokenKind.FLOAT64?"float64 literal":token==TokenKind.STRING?"string literal":token==TokenKind.ARRAY?"array literal":token==TokenKind.ASSIGN?"'='":token==TokenKind.BITWISE_AND?"'&'":token==TokenKind.BITWISE_OR?"'|'":token==TokenKind.BITWISE_XOR?"'^'":token==TokenKind.COLON?"':'":token==TokenKind.COMMA?"','":token==TokenKind.COMPLEMENT?"'~'":token==TokenKind.DIVIDE?"'/'":token==TokenKind.DOT?"'.'":token==TokenKind.EQUAL?"'=='":token==TokenKind.EXPONENT?"'**'":token==TokenKind.GREATER_THAN?"'>'":token==TokenKind.GREATER_THAN_EQUAL?"'>='":token==TokenKind.LEFT_BRACE?"'{'":token==TokenKind.LEFT_BRACKET?"'['":token==TokenKind.LEFT_PARENTHESIS?"'('":token==TokenKind.LESS_THAN?"'<'":token==TokenKind.LESS_THAN_EQUAL?"'<='":token==TokenKind.LOGICAL_AND?"'&&'":token==TokenKind.LOGICAL_OR?"'||'":token==TokenKind.MINUS?"'-'":token==TokenKind.MINUS_MINUS?"'--'":token==TokenKind.MULTIPLY?"'*'":token==TokenKind.NOT?"'!'":token==TokenKind.NOT_EQUAL?"'!='":token==TokenKind.PLUS?"'+'":token==TokenKind.PLUS_PLUS?"'++'":token==TokenKind.QUESTION_MARK?"'?'":token==TokenKind.REMAINDER?"'%'":token==TokenKind.RIGHT_BRACE?"'}'":token==TokenKind.RIGHT_BRACKET?"']'":token==TokenKind.RIGHT_PARENTHESIS?"')'":token==TokenKind.SEMICOLON?"';'":token==TokenKind.SHIFT_LEFT?"'<<'":token==TokenKind.SHIFT_RIGHT?"'>>'":token==TokenKind.FROM?"'from'":token==TokenKind.ALIGNOF?"'alignof'":token==TokenKind.AS?"'as'":token==TokenKind.BREAK?"'break'":token==TokenKind.MODULE?"'module'":token==TokenKind.CLASS?"'class'":token==TokenKind.CONST?"'const'":token==TokenKind.CONTINUE?"'continue'":token==TokenKind.DECLARE?"'declare'":token==TokenKind.ELSE?"'else'":token==TokenKind.ENUM?"'enum'":token==TokenKind.EXPORT?"'export'":token==TokenKind.EXTENDS?"'extends'":token==TokenKind.FALSE?"'false'":token==TokenKind.FUNCTION?"'function'":token==TokenKind.ANYFUNC?"'anyfunc'":token==TokenKind.IF?"'if'":token==TokenKind.IMPLEMENTS?"'implements'":token==TokenKind.IMPORT?"'import'":token==TokenKind.LET?"'let'":token==TokenKind.NEW?"'new'":token==TokenKind.DELETE?"'delete'":token==TokenKind.NULL?"'null'":token==TokenKind.UNDEFINED?"'undefined'":token==TokenKind.OPERATOR?"'operator'":token==TokenKind.PRIVATE?"'private'":token==TokenKind.PROTECTED?"'protected'":token==TokenKind.PUBLIC?"'public'":token==TokenKind.RETURN?"'return'":token==TokenKind.SIZEOF?"'sizeof'":token==TokenKind.STATIC?"'static'":token==TokenKind.THIS?"'this'":token==TokenKind.TRUE?"'true'":token==TokenKind.UNSAFE?"'unsafe'":token==TokenKind.JAVASCRIPT?"'@JS'":token==TokenKind.START?"'@start'":token==TokenKind.VIRTUAL?"'@virtual'":token==TokenKind.VAR?"'var'":token==TokenKind.WHILE?"'while'":token==TokenKind.PREPROCESSOR_DEFINE?"'#define'":token==TokenKind.PREPROCESSOR_ELIF?"'#elif'":token==TokenKind.PREPROCESSOR_ELSE?"'#else'":token==TokenKind.PREPROCESSOR_ENDIF?"'#endif'":token==TokenKind.PREPROCESSOR_ERROR?"'#error'":token==TokenKind.PREPROCESSOR_IF?"'#if'":token==TokenKind.PREPROCESSOR_NEWLINE?"newline":token==TokenKind.PREPROCESSOR_UNDEF?"'#undef'":token==TokenKind.PREPROCESSOR_WARNING?"'#warning'":(assert_1.assert(!1),null)}function isAlpha(c){return c>="a"&&c<="z"||c>="A"&&c<="Z"||"_"==c}function isASCII(c){return c>=32&&c<=126}function isNumber(c){return c>="0"&&c<="9"}function isDigit(c,base){return""!=c.trim()&&(16==base?isNumber(c)||c>="A"&&c<="F"||c>="a"&&c<="f":!isNaN(c))}function tokenize(source,log){for(var first=null,last=null,contents=source.contents,limit=contents.length,needsPreprocessor=!1,wantNewline=!1,i=0;i=2&&length<=10){var text=contents.slice(start,i);2==length?"as"==text?kind=TokenKind.AS:"if"==text&&(kind=TokenKind.IF):3==length?"let"==text?kind=TokenKind.LET:"new"==text?kind=TokenKind.NEW:"var"==text?kind=TokenKind.VAR:"@JS"==text&&(kind=TokenKind.JAVASCRIPT):4==length?"else"==text?kind=TokenKind.ELSE:"enum"==text?kind=TokenKind.ENUM:"null"==text?kind=TokenKind.NULL:"this"==text?kind=TokenKind.THIS:"true"==text?kind=TokenKind.TRUE:"from"==text&&(kind=TokenKind.FROM):5==length?"break"==text?kind=TokenKind.BREAK:"class"==text?kind=TokenKind.CLASS:"const"==text?kind=TokenKind.CONST:"false"==text?kind=TokenKind.FALSE:"while"==text&&(kind=TokenKind.WHILE):6==length?"export"==text?kind=TokenKind.EXPORT:"module"==text?kind=TokenKind.MODULE:"import"==text?kind=TokenKind.IMPORT:"public"==text?kind=TokenKind.PUBLIC:"return"==text?kind=TokenKind.RETURN:"sizeof"==text?kind=TokenKind.SIZEOF:"static"==text?kind=TokenKind.STATIC:"unsafe"==text?kind=TokenKind.UNSAFE:"@start"==text?kind=TokenKind.START:"delete"==text&&(kind=TokenKind.DELETE):7==length?"alignof"==text?kind=TokenKind.ALIGNOF:"declare"==text?kind=TokenKind.DECLARE:"extends"==text?kind=TokenKind.EXTENDS:"private"==text?kind=TokenKind.PRIVATE:"anyfunc"==text&&(kind=TokenKind.ANYFUNC):"continue"==text?kind=TokenKind.CONTINUE:"@virtual"==text?kind=TokenKind.VIRTUAL:"function"==text?kind=TokenKind.FUNCTION:"implements"==text?kind=TokenKind.IMPLEMENTS:"protected"==text&&(kind=TokenKind.PROTECTED)}}else if(isNumber(c)){var isFloat=!1;if(i"==c)kind=TokenKind.GREATER_THAN,i"==c?(kind=TokenKind.SHIFT_RIGHT,i+=1):"="==c&&(kind=TokenKind.GREATER_THAN_EQUAL,i+=1));else if("#"==c){for(;i=end&&"\n"!=contents[j];)j-=1;j0&&dot>forward&&dot>backward&&(path=path.slice(0,dot)),path+extension}Object.defineProperty(exports,"__esModule",{value:!0});var type_checker_1=__webpack_require__(46),node_1=__webpack_require__(5),log_1=__webpack_require__(2),preprocessor_1=__webpack_require__(51),scope_1=__webpack_require__(17),scanner_1=__webpack_require__(9),parser_1=__webpack_require__(19),shaking_1=__webpack_require__(49),webassembly_1=__webpack_require__(45),library_1=__webpack_require__(53),preparser_1=__webpack_require__(50),compile_target_1=__webpack_require__(4),assert_1=__webpack_require__(0),terminal_1=__webpack_require__(1),Compiler=function(){function Compiler(){}return Compiler.prototype.initialize=function(target,outputName){assert_1.assert(null==this.log),this.log=new log_1.Log,this.preprocessor=new preprocessor_1.Preprocessor,this.target=target,this.outputName=outputName,this.librarySource=this.addInput("",library_1.Library.get(target)),this.librarySource.isLibrary=!0,this.runtimeSource=library_1.Library.getRuntime(target),this.wrapperSource=library_1.Library.getWrapper(target),this.createGlobals(),target==compile_target_1.CompileTarget.CPP?this.preprocessor.define("CPP",!0):target==compile_target_1.CompileTarget.JAVASCRIPT?this.preprocessor.define("JS",!0):target==compile_target_1.CompileTarget.WEBASSEMBLY&&this.preprocessor.define("WASM",!0)},Compiler.prototype.createGlobals=function(){var context=new type_checker_1.CheckContext;context.log=this.log,context.target=this.target,context.pointerByteSize=4;var global=new node_1.Node;global.kind=node_1.NodeKind.GLOBAL;var scope=new scope_1.Scope;global.scope=scope,context.anyType=scope.defineNativeType(context.log,"any"),context.errorType=scope.defineNativeType(context.log,""),context.nullType=scope.defineNativeType(context.log,"null"),context.undefinedType=scope.defineNativeType(context.log,"undefined"),context.voidType=scope.defineNativeType(context.log,"void"),this.context=context,this.global=global},Compiler.prototype.addInput=function(name,contents){var source=new log_1.Source;return source.name=name,source.contents=contents,null==this.firstSource?this.firstSource=source:(source.prev=this.lastSource,this.lastSource.next=source),this.lastSource=source,source},Compiler.prototype.addInputBefore=function(name,contents,nextSource){var source=new log_1.Source;return source.name=name,source.contents=contents,nextSource.prev.next=source,source.prev=nextSource.prev,nextSource.prev=source,source.next=nextSource,source},Compiler.prototype.finish=function(){terminal_1.Terminal.time("pre-parsing");for(var source=this.firstSource;null!=source;){if(!preparser_1.preparse(source,this,this.log))return!1;source=source.next}for(terminal_1.Terminal.timeEnd("pre-parsing"),terminal_1.Terminal.time("scanning"),source=this.firstSource;null!=source;)source.firstToken=scanner_1.tokenize(source,this.log),source=source.next;for(terminal_1.Terminal.timeEnd("scanning"),terminal_1.Terminal.time("pre-processing"),source=this.firstSource;null!=source;)this.preprocessor.run(source,this.log),source=source.next;for(terminal_1.Terminal.timeEnd("pre-processing"),terminal_1.Terminal.time("parsing"),source=this.firstSource;null!=source;)null!=source.firstToken&&(source.file=parser_1.parse(source.firstToken,this.log)),source=source.next;terminal_1.Terminal.timeEnd("parsing"),terminal_1.Terminal.time("type-checking");var global=this.global,context=this.context,fullResolve=!0;for(source=this.firstSource;null!=source;){var file=source.file;if(null!=file)for(source.isLibrary?(file.flags|=node_1.NODE_FLAG_LIBRARY,type_checker_1.initialize(context,file,global.scope,type_checker_1.CheckMode.INITIALIZE),type_checker_1.resolve(context,file,global.scope)):type_checker_1.initialize(context,file,global.scope,type_checker_1.CheckMode.NORMAL);null!=file.firstChild;){var child=file.firstChild;child.remove(),global.appendChild(child)}if(source.isLibrary&&this.log.hasErrors()){fullResolve=!1;break}source=source.next}return fullResolve&&type_checker_1.resolve(context,global,global.scope),terminal_1.Terminal.timeEnd("type-checking"),!this.log.hasErrors()&&(terminal_1.Terminal.time("optimizing"),shaking_1.treeShaking(global),terminal_1.Terminal.timeEnd("optimizing"),terminal_1.Terminal.time("emitting"),this.target==compile_target_1.CompileTarget.WEBASSEMBLY&&webassembly_1.wasmEmit(this),terminal_1.Terminal.timeEnd("emitting"),terminal_1.Terminal.write("Done!"),!0)},Compiler}();Compiler.mallocRequired=!1,Compiler.debug=!1,exports.Compiler=Compiler,exports.replaceFileExtension=replaceFileExtension},function(module,exports,__webpack_require__){"use strict";function ByteArray_set16(array,index,value){array.set(index,value),array.set(index+1,value>>8)}function ByteArray_set32(array,index,value){array.set(index,value),array.set(index+1,value>>8),array.set(index+2,value>>16),array.set(index+3,value>>24)}function ByteArray_append32(array,value){array.append(value),array.append(value>>8),array.append(value>>16),array.append(value>>24)}function ByteArray_setString(data,index,text){var length=text.length;assert_1.assert(index>=0&&index+2*length<=data.length);for(var array=data.array,i=0;i>8,index+=2,i+=1}}Object.defineProperty(exports,"__esModule",{value:!0});var assert_1=__webpack_require__(0);exports.ByteArray_set16=ByteArray_set16,exports.ByteArray_set32=ByteArray_set32,exports.ByteArray_append32=ByteArray_append32,exports.ByteArray_setString=ByteArray_setString;var ByteArray=function(){function ByteArray(buffer,offset,length){void 0===offset&&(offset=0),void 0===length&&(length=0),this.BUFFER_EXT_SIZE=1024,this._array=null,this.log="",this.EOF_byte=-1,this.EOF_code_point=-1,void 0==buffer?(buffer=new ArrayBuffer(this.BUFFER_EXT_SIZE),this.write_position=0):this.write_position=null==buffer?0:length>0?length:buffer.byteLength,buffer&&(this.data=new DataView(buffer,offset,length>0?length:buffer.byteLength),this._array=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength)),this._position=0,this.endian=ByteArray.LITTLE_ENDIAN}return Object.defineProperty(ByteArray.prototype,"array",{get:function(){return this._array.subarray(0,this.length)},enumerable:!0,configurable:!0}),ByteArray.prototype.get=function(index){return this._array[index]},ByteArray.prototype.set=function(index,value){this._array[index]=value},ByteArray.prototype.append=function(value){var index=this.position;this.resize(index+1),this._array[index]=value,this.position++},ByteArray.prototype.resize=function(length){if(length>this.data.byteLength){var pos=this.position,len=this.length,capacity=2*length,data=new Uint8Array(capacity);data.set(this.array),this.setArray(data),this._position=pos,this.write_position=len}return this},ByteArray.prototype.copy=function(source,offset,length){return void 0===offset&&(offset=0),void 0===length&&(length=0),offset=offset>0?offset:this.length,offset+source.length>this._array.length&&this.resize(offset+source.length),this._array.set(source.array,offset),this.position=offset+source.length,this},Object.defineProperty(ByteArray.prototype,"buffer",{get:function(){return this.data.buffer},set:function(value){this.data=new DataView(value)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"dataView",{get:function(){return this.data},set:function(value){this.data=value,this.write_position=value.byteLength},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"phyPosition",{get:function(){return this._position+this.data.byteOffset},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"bufferOffset",{get:function(){return this.data.byteOffset},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"position",{get:function(){return this._position},set:function(value){this._positionthis.write_position?value:this.write_position)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"length",{get:function(){return this.write_position},set:function(value){this.validateBuffer(value)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"bytesAvailable",{get:function(){return this.data.byteLength-this._position},enumerable:!0,configurable:!0}),ByteArray.prototype.clear=function(){this._position=0},ByteArray.prototype.setArray=function(array){this._array=array,this.setBuffer(array.buffer,array.byteOffset,array.byteLength)},ByteArray.prototype.setBuffer=function(buffer,offset,length){void 0===offset&&(offset=0),void 0===length&&(length=0),buffer&&(this.data=new DataView(buffer,offset,length>0?length:buffer.byteLength))},ByteArray.prototype.writeUnsignedLEB128=function(value){var b=0;value|=0;do{b=127&value,value>>>=7,value&&(b|=128),this.append(b)}while(value)},ByteArray.prototype.writeLEB128=function(value){var b;for(value|=0;;){b=127&value,value>>=7;var signBit=0!=(64&b);if(0===value&&!signBit||-1===value&&signBit){this.append(b);break}b|=128,this.append(b)}},ByteArray.prototype.writeWasmString=function(value){var length=value.length;this.writeUnsignedLEB128(length);var index=this.length;this.resize(index+length);for(var i=0;i0?this.readUTFBytes(length):""},ByteArray.prototype.readUTFBytes=function(length){if(!this.validate(length))return null;var _bytes=new Uint8Array(this.buffer,this.bufferOffset+this.position,length);return this.position+=length,this.decodeUTF8(_bytes)},ByteArray.prototype.readStandardString=function(length){if(!this.validate(length))return null;for(var str="",i=0;i0;){var _byte=this.data.getUint8(this.position++);if(num++,0==_byte){keepEvenByte&&num%2!=0&&this.position++;break}str+=String.fromCharCode(_byte)}return str},ByteArray.prototype.writeBoolean=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_BOOLEAN,offset),this.data.setUint8(offset,value?1:0)},ByteArray.prototype.writeByte=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_INT8,offset),this.data.setInt8(offset,value)},ByteArray.prototype.writeUnsignedByte=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_UINT8,offset),this.data.setUint8(offset,value)},ByteArray.prototype.writeBytes=function(_bytes,offset,length){void 0===offset&&(offset=0),void 0===length&&(length=0),this.copy(_bytes)},ByteArray.prototype.writeDouble=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_FLOAT64,position),this.data.setFloat64(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_FLOAT64)},ByteArray.prototype.writeFloat=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_FLOAT32,position),this.data.setFloat32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_FLOAT32)},ByteArray.prototype.writeInt=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_INT32,position),this.data.setInt32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_INT32)},ByteArray.prototype.writeMultiByte=function(value,charSet){},ByteArray.prototype.writeShort=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_INT16,position),this.data.setInt16(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_INT16)},ByteArray.prototype.writeUnsignedShort=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT16,position),this.data.setUint16(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_UINT16)},ByteArray.prototype.writeUnsignedInt=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT32,position),this.data.setUint32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_UINT32)},ByteArray.prototype.writeUTF=function(value,offset){void 0===offset&&(offset=null);var utf8bytes=this.encodeUTF8(value),length=utf8bytes.length,position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT16+length,position),this.data.setUint16(position,length,this.endian===ByteArray.LITTLE_ENDIAN),offset?(offset+=ByteArray.SIZE_OF_UINT16,this.writeUint8Array(utf8bytes,offset)):(this.position+=ByteArray.SIZE_OF_UINT16,this.writeUint8Array(utf8bytes))},ByteArray.prototype.writeUTFBytes=function(value,offset){void 0===offset&&(offset=null),this.writeUint8Array(this.encodeUTF8(value),offset)},ByteArray.prototype.toString=function(){return"[ByteArray] length:"+this.length+", bytesAvailable:"+this.bytesAvailable},ByteArray.prototype.writeUint8Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;return this.validateBuffer(_bytes.length,position),this._array.set(_bytes,position),offset||(this.position+=_bytes.length),this},ByteArray.prototype.writeUint16Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_UINT16,position);for(var i=0;i<_bytes.length;i++)this.data.setUint16(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_UINT16;offset||(this.position=position)},ByteArray.prototype.writeUint32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_UINT32,position);for(var i=0;i<_bytes.length;i++)this.data.setUint32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_UINT32;offset||(this.position=position)},ByteArray.prototype.writeInt8Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length,position);for(var i=0;i<_bytes.length;i++)this.data.setInt8(position++,_bytes[i]);offset||(this.position=position)},ByteArray.prototype.writeInt16Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_INT16,position);for(var i=0;i<_bytes.length;i++)this.data.setInt16(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_INT16;offset||(this.position=position)},ByteArray.prototype.writeInt32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_INT32,position);for(var i=0;i<_bytes.length;i++)this.data.setInt32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_INT32;offset||(this.position=position)},ByteArray.prototype.writeFloat32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_FLOAT32,position);for(var i=0;i<_bytes.length;i++)this.data.setFloat32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_FLOAT32;offset||(this.position=position)},ByteArray.prototype.writeFloat64Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length,position);for(var i=0;i<_bytes.length;i++)this.data.setFloat64(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_FLOAT64;offset||(this.position=position)},ByteArray.prototype.readUint8Array=function(length,createNewBuffer){if(void 0===createNewBuffer&&(createNewBuffer=!0),!this.validate(length))return null;if(createNewBuffer){result=new Uint8Array(new ArrayBuffer(length));for(var i=0;i0&&this._position+len<=this.data.byteLength)return!0;throw"Error #2030: End of file was encountered."},ByteArray.prototype.validateBuffer=function(size,offset){void 0===offset&&(offset=0);var length=offset+size;this.resize(length)},ByteArray.prototype.encodeUTF8=function(str){for(var pos=0,codePoints=this.stringToCodePoints(str),outputBytes=[];codePoints.length>pos;){var code_point=codePoints[pos++];if(this.inRange(code_point,55296,57343))this.encoderError(code_point);else if(this.inRange(code_point,0,127))outputBytes.push(code_point);else{var count,offset;for(this.inRange(code_point,128,2047)?(count=1,offset=192):this.inRange(code_point,2048,65535)?(count=2,offset=224):this.inRange(code_point,65536,1114111)&&(count=3,offset=240),outputBytes.push(this.div(code_point,Math.pow(64,count))+offset);count>0;){var temp=this.div(code_point,Math.pow(64,count-1));outputBytes.push(128+temp%64),count-=1}}}return new Uint8Array(outputBytes)},ByteArray.prototype.decodeUTF8=function(data){for(var code_point,pos=0,result="",utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0;data.length>pos;){var _byte=data[pos++];if(_byte===this.EOF_byte)code_point=0!==utf8_bytes_needed?this.decoderError(!1):this.EOF_code_point;else if(0===utf8_bytes_needed)this.inRange(_byte,0,127)?code_point=_byte:(this.inRange(_byte,194,223)?(utf8_bytes_needed=1,utf8_lower_boundary=128,utf8_code_point=_byte-192):this.inRange(_byte,224,239)?(utf8_bytes_needed=2,utf8_lower_boundary=2048,utf8_code_point=_byte-224):this.inRange(_byte,240,244)?(utf8_bytes_needed=3,utf8_lower_boundary=65536,utf8_code_point=_byte-240):this.decoderError(!1),utf8_code_point*=Math.pow(64,utf8_bytes_needed),code_point=null);else if(this.inRange(_byte,128,191))if(utf8_bytes_seen+=1,utf8_code_point+=(_byte-128)*Math.pow(64,utf8_bytes_needed-utf8_bytes_seen),utf8_bytes_seen!==utf8_bytes_needed)code_point=null;else{var cp=utf8_code_point,lower_boundary=utf8_lower_boundary;utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0,code_point=this.inRange(cp,lower_boundary,1114111)&&!this.inRange(cp,55296,57343)?cp:this.decoderError(!1,_byte)}else utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0,pos--,code_point=this.decoderError(!1,_byte);null!==code_point&&code_point!==this.EOF_code_point&&(code_point<=65535?code_point>0&&(result+=String.fromCharCode(code_point)):(code_point-=65536,result+=String.fromCharCode(55296+(code_point>>10&1023)),result+=String.fromCharCode(56320+(1023&code_point))))}return result},ByteArray.prototype.encoderError=function(code_point){throw"EncodingError! The code point "+code_point+" could not be encoded."},ByteArray.prototype.decoderError=function(fatal,opt_code_point){if(fatal)throw"DecodingError";return opt_code_point||65533},ByteArray.prototype.inRange=function(a,min,max){return min<=a&&a<=max},ByteArray.prototype.div=function(n,d){return Math.floor(n/d)},ByteArray.prototype.stringToCodePoints=function(string){for(var cps=[],i=0,n=string.length;i=0},Type.prototype.isTypedArray=function(){return null!=this.symbol&&("Float32Array"==this.symbol.name||"Float64Array"==this.symbol.name||"Int8Array"==this.symbol.name||"Int16Array"==this.symbol.name||"Int32Array"==this.symbol.name||"Uint8Array"==this.symbol.name||"Uint16Array"==this.symbol.name||"Uint32Array"==this.symbol.name)},Type.prototype.isReference=function(){return null!=this.pointerTo||null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_IS_REFERENCE)},Type.prototype.underlyingType=function(context){return this.isEnum()?context.int32Type:null!=this.pointerTo?context.uint32Type:this},Type.prototype.integerBitCount=function(context){return null!=this.symbol?8*this.symbol.byteSize:0},Type.prototype.integerBitMask=function(context){return-1>>32-this.integerBitCount(context)},Type.prototype.allocationSizeOf=function(context){return null==this.symbol?context.pointerByteSize:this.symbol.byteSize},Type.prototype.allocationAlignmentOf=function(context){return this.allocationSizeOf(context)},Type.prototype.variableSizeOf=function(context){return this.isReference()?context.pointerByteSize:this.symbol.byteSize},Type.prototype.variableAlignmentOf=function(context){return this.variableSizeOf(context)},Type.prototype.pointerType=function(){var type=this.cachedPointerType;return null==type&&(type=new Type,type.pointerTo=this,this.cachedPointerType=type),type},Type.prototype.toString=function(){return null==this.cachedToString&&(this.cachedToString=null!=this.pointerTo?"*"+this.pointerTo.toString():this.symbol.name),this.cachedToString},Type.prototype.findMember=function(name,hint){var symbol=this.symbol;return null!=symbol&&null!=symbol.scope?symbol.scope.findLocal(name,hint):null},Type.prototype.hasInstanceMembers=function(){var symbol=this.symbol;return null!=symbol&&(symbol.kind==symbol_1.SymbolKind.TYPE_TEMPLATE||symbol.kind==symbol_1.SymbolKind.TYPE_CLASS||symbol.kind==symbol_1.SymbolKind.TYPE_NATIVE)},Type}();exports.Type=Type},function(module,exports,__webpack_require__){"use strict";function isRightAssociative(precedence){return precedence==Precedence.ASSIGN||precedence==Precedence.EXPONENT}function parse(firstToken,log){var context=new ParserContext;context.current=firstToken,context.log=log;var file=new node_1.Node;return file.kind=node_1.NodeKind.FILE,context.parseStatements(file)?file:null}Object.defineProperty(exports,"__esModule",{value:!0});var Precedence,scanner_1=__webpack_require__(9),log_1=__webpack_require__(2),node_1=__webpack_require__(5),assert_1=__webpack_require__(0),terminal_1=__webpack_require__(1);!function(Precedence){Precedence[Precedence.LOWEST=0]="LOWEST",Precedence[Precedence.ASSIGN=1]="ASSIGN",Precedence[Precedence.LOGICAL_OR=2]="LOGICAL_OR",Precedence[Precedence.LOGICAL_AND=3]="LOGICAL_AND",Precedence[Precedence.BITWISE_OR=4]="BITWISE_OR",Precedence[Precedence.BITWISE_XOR=5]="BITWISE_XOR",Precedence[Precedence.BITWISE_AND=6]="BITWISE_AND",Precedence[Precedence.EQUAL=7]="EQUAL",Precedence[Precedence.COMPARE=8]="COMPARE",Precedence[Precedence.SHIFT=9]="SHIFT",Precedence[Precedence.ADD=10]="ADD",Precedence[Precedence.MULTIPLY=11]="MULTIPLY",Precedence[Precedence.EXPONENT=12]="EXPONENT",Precedence[Precedence.UNARY_PREFIX=13]="UNARY_PREFIX",Precedence[Precedence.UNARY_POSTFIX=14]="UNARY_POSTFIX",Precedence[Precedence.MEMBER=15]="MEMBER"}(Precedence=exports.Precedence||(exports.Precedence={}));var ParseKind;!function(ParseKind){ParseKind[ParseKind.EXPRESSION=0]="EXPRESSION",ParseKind[ParseKind.TYPE=1]="TYPE"}(ParseKind||(ParseKind={}));var StatementMode;!function(StatementMode){StatementMode[StatementMode.NORMAL=0]="NORMAL",StatementMode[StatementMode.FILE=1]="FILE"}(StatementMode||(StatementMode={}));var ParserContext=function(){function ParserContext(){}return ParserContext.prototype.peek=function(kind){return this.current.kind==kind},ParserContext.prototype.eat=function(kind){return!!this.peek(kind)&&(this.advance(),!0)},ParserContext.prototype.advance=function(){this.peek(scanner_1.TokenKind.END_OF_FILE)||(this.previous=this.current,this.current=this.current.next)},ParserContext.prototype.unexpectedToken=function(){this.lastError!=this.current&&(this.lastError=this.current,this.log.error(this.current.range,"Unexpected "+scanner_1.tokenToString(this.current.kind)))},ParserContext.prototype.expect=function(kind){if(!this.peek(kind)){if(this.lastError!=this.current){this.lastError=this.current;var previousLine=this.previous.range.enclosingLine(),currentLine=this.current.range.enclosingLine();kind==scanner_1.TokenKind.IDENTIFIER||previousLine.equals(currentLine)?this.log.error(this.current.range,"Expected "+scanner_1.tokenToString(kind)+" but found "+scanner_1.tokenToString(this.current.kind)):this.log.error(previousLine.rangeAtEnd(),"Expected "+scanner_1.tokenToString(kind))}return!1}return this.advance(),!0},ParserContext.prototype.parseUnaryPrefix=function(kind,mode){assert_1.assert(node_1.isUnary(kind));var token=this.current;this.advance();var value=this.parseExpression(Precedence.UNARY_PREFIX,mode);return null==value?null:node_1.createUnary(kind,value).withRange(log_1.spanRanges(token.range,value.range)).withInternalRange(token.range)},ParserContext.prototype.parseBinary=function(kind,left,localPrecedence,operatorPrecedence){if(localPrecedence>=operatorPrecedence)return left;var token=this.current;this.advance();var precedence=isRightAssociative(operatorPrecedence)?operatorPrecedence-1:operatorPrecedence,right=this.parseExpression(precedence,ParseKind.EXPRESSION);return null==right?null:node_1.createBinary(kind,left,right).withRange(log_1.spanRanges(left.range,right.range)).withInternalRange(token.range)},ParserContext.prototype.parseUnaryPostfix=function(kind,value,localPrecedence){if(localPrecedence>=Precedence.UNARY_POSTFIX)return value;var token=this.current;return this.advance(),node_1.createUnary(kind,value).withRange(log_1.spanRanges(value.range,token.range)).withInternalRange(token.range)},ParserContext.prototype.parseQuotedString=function(range){assert_1.assert(range.end-range.start>=2);for(var text=range.source.contents,end=range.start+1,limit=range.end-1,start=end,quotedString="";end')":end.kind==scanner_1.TokenKind.GREATER_THAN_EQUAL?"(it is automatically derived from '<')":""))):this.unexpectedToken()}else{if(null==parent&&(assert_1.assert(token.kind==scanner_1.TokenKind.FUNCTION),this.advance()),nameRange=this.current.range,!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;name=nameRange.toString()}var node=node_1.createFunction(name);if(node.firstFlag=firstFlag,node.flags=node_1.allFlags(firstFlag),isOperator&&(node.flags=node.flags|node_1.NODE_FLAG_OPERATOR),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;node.appendChild(parameters)}if(!this.expect(scanner_1.TokenKind.LEFT_PARENTHESIS))return null;if(!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))for(;;){var firstArgumentFlag=this.parseFlags(),argument=this.current;if(!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;var type=void 0,value=null,range=argument.range;if(this.expect(scanner_1.TokenKind.COLON)){if(type=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;type.appendChild(parameters)}if(null!=type)range=log_1.spanRanges(range,type.range);else{if(!this.peek(scanner_1.TokenKind.COMMA)&&!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;type=node_1.createParseError()}}else(this.peek(scanner_1.TokenKind.COMMA)||this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))&&(type=node_1.createParseError());for(var firstType=type;this.eat(scanner_1.TokenKind.BITWISE_OR);){var aliasType=this.parseType();if(this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;aliasType.appendChild(parameters)}if(null!=aliasType)range=log_1.spanRanges(range,aliasType.range);else{if(!this.peek(scanner_1.TokenKind.COMMA)&&!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;aliasType=node_1.createParseError()}type.appendChild(aliasType),type=aliasType}this.eat(scanner_1.TokenKind.ASSIGN)&&(value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION));var variable=node_1.createVariable(argument.range.toString(),firstType,value);if(variable.firstFlag=firstArgumentFlag,variable.flags=node_1.allFlags(firstArgumentFlag),node.appendChild(variable.withRange(range).withInternalRange(argument.range)),!this.eat(scanner_1.TokenKind.COMMA))break}if(!this.expect(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;var returnType;if(node.isAnyfunc())returnType=node_1.createAny();else if("constructor"==node.stringValue)returnType=new node_1.Node,returnType.kind=node_1.NodeKind.NAME,returnType.stringValue=parent.stringValue;else if(this.expect(scanner_1.TokenKind.COLON)){if(returnType=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;returnType.appendChild(parameters)}if(null==returnType){if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;returnType=node_1.createParseError()}for(var firstType=returnType;this.eat(scanner_1.TokenKind.BITWISE_OR);){var aliasType=this.parseType();if(this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;aliasType.appendChild(parameters)}if(null==aliasType){if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;aliasType=node_1.createParseError()}firstType.appendChild(aliasType),firstType=aliasType}}else{if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;returnType=node_1.createParseError()}node.appendChild(returnType);var block=null,semicolon=this.current;if(this.eat(scanner_1.TokenKind.SEMICOLON))block=node_1.createEmpty().withRange(semicolon.range);else if(null==(block=this.parseBlock()))return null;return null!=parent&&parent.appendChild(node),node.appendChild(block),node.withRange(log_1.spanRanges(token.range,block.range)).withInternalRange(nameRange)},ParserContext.prototype.parseVariables=function(firstFlag,parent){var token=this.current;null==parent&&(assert_1.assert(token.kind==scanner_1.TokenKind.CONST||token.kind==scanner_1.TokenKind.LET||token.kind==scanner_1.TokenKind.VAR),this.advance());var node=token.kind==scanner_1.TokenKind.CONST?node_1.createConstants():node_1.createVariables();for(node.firstFlag=firstFlag;;){var name_3=this.current;if(!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;var type=null;if(this.eat(scanner_1.TokenKind.COLON)){if(type=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;type.appendChild(parameters)}if(null==type)return null}var value=null;if(this.eat(scanner_1.TokenKind.ASSIGN)&&null==(value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION)))return null;var range=null!=value?log_1.spanRanges(name_3.range,value.range):null!=type?log_1.spanRanges(name_3.range,type.range):name_3.range,variable=node_1.createVariable(name_3.range.toString(),type,value);if(variable.firstFlag=firstFlag,variable.flags=node_1.allFlags(firstFlag),(null!=parent?parent:node).appendChild(variable.withRange(range).withInternalRange(name_3.range)),!this.eat(scanner_1.TokenKind.COMMA))break}var semicolon=this.current;return this.expect(scanner_1.TokenKind.SEMICOLON),node.withRange(log_1.spanRanges(token.range,semicolon.range))},ParserContext.prototype.parseLoopJump=function(kind){var token=this.current;this.advance(),this.expect(scanner_1.TokenKind.SEMICOLON);var node=new node_1.Node;return node.kind=kind,node.withRange(token.range)},ParserContext.prototype.parseFlags=function(){for(var firstFlag=null,lastFlag=null;;){var token=this.current,flag=void 0;if(this.eat(scanner_1.TokenKind.DECLARE))flag=node_1.NODE_FLAG_DECLARE;else if(this.eat(scanner_1.TokenKind.EXPORT))flag=node_1.NODE_FLAG_EXPORT;else if(this.eat(scanner_1.TokenKind.PRIVATE))flag=node_1.NODE_FLAG_PRIVATE;else if(this.eat(scanner_1.TokenKind.PROTECTED))flag=node_1.NODE_FLAG_PROTECTED;else if(this.eat(scanner_1.TokenKind.PUBLIC))flag=node_1.NODE_FLAG_PUBLIC;else if(this.eat(scanner_1.TokenKind.STATIC))flag=node_1.NODE_FLAG_STATIC;else if(this.eat(scanner_1.TokenKind.ANYFUNC))flag=node_1.NODE_FLAG_ANYFUNC;else if(this.eat(scanner_1.TokenKind.UNSAFE))flag=node_1.NODE_FLAG_UNSAFE;else if(this.eat(scanner_1.TokenKind.JAVASCRIPT))flag=node_1.NODE_FLAG_JAVASCRIPT;else if(this.eat(scanner_1.TokenKind.START))flag=node_1.NODE_FLAG_START;else{if(!this.eat(scanner_1.TokenKind.VIRTUAL))return firstFlag;flag=node_1.NODE_FLAG_VIRTUAL}var link=new node_1.NodeFlag;link.flag=flag,link.range=token.range,null==firstFlag?firstFlag=link:lastFlag.next=link,lastFlag=link}},ParserContext.prototype.parseUnsafe=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_UNSAFE,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseJavaScript=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_JAVASCRIPT,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseStart=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_START,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseVirtual=function(firstFlag){var token=this.current;this.advance();var node=this.parseFunction(firstFlag,null);return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_VIRTUAL,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseStatement=function(mode){var firstFlag=mode==StatementMode.FILE?this.parseFlags():null;if(this.peek(scanner_1.TokenKind.IMPORT)&&null==firstFlag)return this.parseImports();if(this.peek(scanner_1.TokenKind.JAVASCRIPT)&&null==firstFlag)return this.parseJavaScript();if(this.peek(scanner_1.TokenKind.START)&&null==firstFlag)return this.parseStart();if(this.peek(scanner_1.TokenKind.CONST)||this.peek(scanner_1.TokenKind.LET)||this.peek(scanner_1.TokenKind.VAR))return this.parseVariables(firstFlag,null);if(this.peek(scanner_1.TokenKind.FUNCTION))return this.parseFunction(firstFlag,null);if(this.peek(scanner_1.TokenKind.VIRTUAL))return this.parseVirtual(firstFlag);if(this.peek(scanner_1.TokenKind.MODULE))return this.parseModule(firstFlag);if(this.peek(scanner_1.TokenKind.CLASS))return this.parseClass(firstFlag);if(this.peek(scanner_1.TokenKind.ENUM))return this.parseEnum(firstFlag);if(null!=firstFlag)return this.unexpectedToken(),null;if(this.peek(scanner_1.TokenKind.LEFT_BRACE))return this.parseBlock();if(this.peek(scanner_1.TokenKind.BREAK))return this.parseLoopJump(node_1.NodeKind.BREAK);if(this.peek(scanner_1.TokenKind.CONTINUE))return this.parseLoopJump(node_1.NodeKind.CONTINUE);if(this.peek(scanner_1.TokenKind.IF))return this.parseIf();if(this.peek(scanner_1.TokenKind.WHILE))return this.parseWhile();if(this.peek(scanner_1.TokenKind.DELETE))return this.parseDelete();if(this.peek(scanner_1.TokenKind.RETURN))return this.parseReturn();if(this.peek(scanner_1.TokenKind.SEMICOLON))return this.parseEmpty();var value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION);if(null==value)return null;var semicolon=this.current;return this.expect(scanner_1.TokenKind.SEMICOLON),node_1.createExpression(value).withRange(log_1.spanRanges(value.range,semicolon.range))},ParserContext.prototype.parseStatements=function(parent){for(;!this.peek(scanner_1.TokenKind.END_OF_FILE)&&!this.peek(scanner_1.TokenKind.RIGHT_BRACE);){var child=this.parseStatement(parent.kind==node_1.NodeKind.FILE?StatementMode.FILE:StatementMode.NORMAL);if(null==child)return!1;child.kind===node_1.NodeKind.RETURN&&(parent.returnNode=child),parent.appendChild(child)}return!0},ParserContext.prototype.parseInt=function(range,node){var source=range.source,contents=source.contents;return node.intValue=parseInt(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext.prototype.parseFloat=function(range,node){var source=range.source,contents=source.contents;return node.floatValue=parseFloat(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext.prototype.parseDouble=function(range,node){var source=range.source,contents=source.contents;return node.doubleValue=parseFloat(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext}();exports.parse=parse},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Color={DEFAULT_TEXT:12,DEFAULT_BG:8,BLACK:0,WHITE:255,BOLD:1,RED:1,GREEN:2,YELLOW:3,BLUE:4,MAGENTA:5,ORANGE:208};var hexColor={};hexColor[exports.Color.DEFAULT_TEXT]="#000000",hexColor[exports.Color.DEFAULT_BG]="#FFFFFF",hexColor[exports.Color.BLACK]="#000000",hexColor[exports.Color.WHITE]="#FFFFFF",hexColor[exports.Color.BOLD]="",hexColor[exports.Color.RED]="#FF0000",hexColor[exports.Color.GREEN]="#00FF00",hexColor[exports.Color.BLUE]="#0000FF",hexColor[exports.Color.YELLOW]="#FFF600",hexColor[exports.Color.MAGENTA]="#FF00FF",hexColor[exports.Color.ORANGE]="#FF8C00",exports.HexColor=hexColor},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isBrowser=new Function("try {return this===window;}catch(e){ return false;}")(),exports.isNode=new Function("try {return this===global;}catch(e){return false;}")()},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var env_1=__webpack_require__(21),terminal_1=__webpack_require__(1);if(void 0===Map)var Map=function(){var _this=this;this.get=function(key){return _this[key]},this.set=function(key,value){return _this[key]=value}};var fs=null,virtualFileSystem={fileMap:new Map,readFileSync:function(path,options){return fs.fileMap.get(path)},writeFileSync:function(path,data,options){return fs.fileMap.set(path,data)}};env_1.isBrowser?(fs=virtualFileSystem,window.Buffer=function(){function NodeBuffer(array){this.array=array}return NodeBuffer}()):env_1.isNode?fs=__webpack_require__(55):terminal_1.Terminal.error("----\x3e Unknown host environment!!!. Where are we?");var FileSystem=function(){function FileSystem(){}return FileSystem.readTextFile=function(path){try{return fs.readFileSync(path,"utf8").replace(/\r\n/g,"\n")}catch(e){var virtualFile=virtualFileSystem.readFileSync(path,"utf8").replace(/\r\n/g,"\n");return void 0===virtualFile?null:virtualFile}},FileSystem.writeTextFile=function(path,contents,virtual){void 0===virtual&&(virtual=!1);try{return virtual?virtualFileSystem.writeFileSync(path,contents):fs.writeFileSync(path,contents),!0}catch(e){return!1}},FileSystem.readBinaryFile=function(path){try{return fs.readFileSync(path)}catch(e){var virtualFile=virtualFileSystem.readFileSync(path);return void 0===virtualFile?null:virtualFile}},FileSystem.writeBinaryFile=function(path,contents,virtual){void 0===virtual&&(virtual=!1);try{return virtual?virtualFileSystem.writeFileSync(path,new Buffer(contents.array.subarray(0,contents.length))):fs.writeFileSync(path,new Buffer(contents.array.subarray(0,contents.length))),!0}catch(e){return!1}},FileSystem}();exports.FileSystem=FileSystem},function(module,exports,__webpack_require__){"use strict";function main_addArgument(text){var argument=new CommandLineArgument;argument.text=text,null==firstArgument?firstArgument=argument:lastArgument.next=argument,lastArgument=argument}function main_reset(){firstArgument=null,lastArgument=null}function printUsage(){terminal_1.Terminal.write("\nUsage: tc [FLAGS] [INPUTS]\n\n --help Print this message.\n --out [PATH] Emit code to PATH (the target format is the file extension).\n --wasm Explicit webassembly output \n --define [NAME] Define the flag NAME in all input files.\n\nExamples:\n\n tc src/*.tbs --out main.wasm\n")}function main_entry(){var output,target=compile_target_1.CompileTarget.NONE,argument=firstArgument,inputCount=0;if(null==firstArgument)return printUsage(),1;for(;null!=argument;){var text=argument.text;if(text.startsWith("-")){if("-h"==text||"-help"==text||"--help"==text||"/?"==text)return printUsage(),0;if("--cpp"==text)target=compile_target_1.CompileTarget.CPP;else if("--js"==text)target=compile_target_1.CompileTarget.JAVASCRIPT;else if("--wasm"==text)target=compile_target_1.CompileTarget.WEBASSEMBLY;else if("--define"==text&&null!=argument.next)argument=argument.next;else{if("--out"!=text||null==argument.next)return terminal_1.Terminal.error("Invalid flag: "+text),1;argument=argument.next,output=argument.text}}else inputCount+=1;argument=argument.next}if(0==inputCount)return terminal_1.Terminal.error("No input files"),1;if(null==output)return terminal_1.Terminal.error("Missing an output file (use the --out flag)"),1;if(target==compile_target_1.CompileTarget.NONE){if(!output.endsWith(".wasm"))return terminal_1.Terminal.error("Missing a target (use either --asmjs or --wasm)"),1;target=compile_target_1.CompileTarget.WEBASSEMBLY}var compiler=new compiler_1.Compiler;for(compiler.initialize(target,output),argument=firstArgument;null!=argument;){var text=argument.text;if("--define"==text)argument=argument.next,compiler.preprocessor.define(argument.text,!0);else if("--out"==text)argument=argument.next;else if(!text.startsWith("-")){var contents=filesystem_1.FileSystem.readTextFile(text);if(null==contents)return terminal_1.Terminal.error("Cannot read from "+text),1;compiler.addInput(text,contents)}argument=argument.next}if(compiler.finish(),log_1.writeLogToTerminal(compiler.log),!compiler.log.hasErrors()){if(target==compile_target_1.CompileTarget.CPP&&filesystem_1.FileSystem.writeTextFile(output,compiler.outputCPP)&&filesystem_1.FileSystem.writeTextFile(compiler_1.replaceFileExtension(output,".h"),compiler.outputH)||target==compile_target_1.CompileTarget.JAVASCRIPT&&filesystem_1.FileSystem.writeTextFile(output,compiler.outputJS)||target==compile_target_1.CompileTarget.WEBASSEMBLY&&filesystem_1.FileSystem.writeBinaryFile(output,compiler.outputWASM)&&filesystem_1.FileSystem.writeTextFile(compiler_1.replaceFileExtension(output,".wast"),compiler.outputWAST)&&filesystem_1.FileSystem.writeTextFile(output+".log",compiler.outputWASM.log))return terminal_1.Terminal.write("\n"),0;terminal_1.Terminal.error("Cannot write to "+output)}return terminal_1.Terminal.write("\n"),1}function compileString(source,options){void 0===options&&(options=compiler_options_1.defaultCompilerOptions),terminal_1.Terminal.silent=options.silent;var input="/virtual/inline.tbs";filesystem_1.FileSystem.writeTextFile(input,source,!0);var compiler=new compiler_1.Compiler;return compiler.initialize(options.target,"/virtual/inline.wasm"),compiler.addInput(input,source),compiler.finish(),terminal_1.Terminal.silent=!1,compiler.log.hasErrors()?(options.silent&&!options.logError||log_1.writeLogToTerminal(compiler.log),{success:!1,log:compiler.log}):{success:!0,wasm:compiler.outputWASM.array,wast:"WebAssembly text format output is not yet supported!\nPlease check wasm binary data."}}Object.defineProperty(exports,"__esModule",{value:!0});var log_1=__webpack_require__(2),compiler_1=__webpack_require__(11),compile_target_1=__webpack_require__(4),terminal_1=__webpack_require__(1),filesystem_1=__webpack_require__(22),compiler_options_1=__webpack_require__(47),CommandLineArgument=function(){function CommandLineArgument(){}return CommandLineArgument}();exports.CommandLineArgument=CommandLineArgument;var firstArgument,lastArgument;exports.main_addArgument=main_addArgument,exports.main_reset=main_reset,exports.printUsage=printUsage,exports.main_entry=main_entry,exports.main={addArgument:main_addArgument,reset:main_reset,entry:main_entry},exports.compileString=compileString,exports.version="1.0.1-beta",exports.default={version:exports.version,main:exports.main,compileString:compileString}},function(module,exports){module.exports="declare class Math {\n static abs(x: float32): float32;\n static acos(x: float64): float64;\n static asin(x: float64): float64;\n static atan(x: float64): float64;\n static atan2(y: float64, x: float64): float64;\n static ceil(x: float32): float32;\n static cos(x: float64): float64;\n static exp(x: float64): float64;\n static floor(x: float32): float32;\n static log(x: float64): float64;\n // static max(...values: float64[]): float64;\n static max(a: float64, b:float64): float64;\n // static min(...values: float64[]): float64;\n static min(a: float64, b:float64): float64;\n static pow(x: float64, y: float64): float64;\n static random(): float64; // 'random' is not a standard Math builtin\n // static round(x: float64): float64; //'round' is not a standard Math builtin\n static sin(x: float64): float64;\n static sqrt(x: float32): float32;\n static tan(x: float64): float64;\n static imul(a: int32, b:int32): int32;\n}\n\nfunction absf32(x:float32):float32{\n return Math.abs(x) as float32;\n}\n\nfunction sqrtf32(x:float32):float32{\n return Math.sqrt(x);\n}\n\nfunction powf32(x:float32, y:float32):float32{\n return Math.pow(x as float64, y as float64) as float32;\n}\n\nfunction minf32(x:float32, y:float32):float32{\n return Math.min(x as float64, y as float64) as float32;\n}\nfunction maxf32(x:float32, y:float32):float32{\n return Math.max(x as float64, y as float64) as float32;\n}\n\ndeclare function modf32(a:float32, b:float32):float32;\ndeclare function modf64(a:float64, b:float64):float64;\n"},function(module,exports){module.exports="class Array {\n\n bytesLength: int32;\n elementSize: int32;\n\n constructor(bytesLength: int32, elementSize: int32) {\n this.bytesLength = bytesLength;\n this.elementSize = elementSize;\n }\n\n operator [] (index: int32): T {\n let stripe = index * this.elementSize;\n if (stripe >= 0 && stripe < this.bytesLength) {\n return *((this as *uint8 + 8 + stripe) as *T);\n }\n return null as T;\n }\n\n operator []= (index: int32, value: T): void {\n let stripe = index * this.elementSize;\n if (stripe >= 0 && stripe < this.bytesLength) {\n *((this as *uint8 + 8 + stripe) as *T) = value;\n }\n }\n\n get length(): int32 {\n return this.bytesLength / this.elementSize;\n }\n}\n\n//declare type Int32Array = Array< int32 >\n//declare type Uint32Array = Array< uint32 >\n//declare type Int64Array = Array< int64 >\n//declare type Uint64Array = Array< uint64 >\n//declare type Float32Array = Array< float32 >\n//declare type Float64Array = Array< float64 >\n"},function(module,exports){module.exports="var originalHeapPointer: *uint8 = null;\nvar currentHeapPointer: *uint8 = null;\n\nvar freeMemory: int32 = 0;\nvar numFreeChunks: int32 = 0;\nvar firstFree: int32 = 0;\nvar lastFree: int32 = 0;\n\nconst PREV_INUSE:int32 = 1;\nconst IS_MMAPPED:int32 = 2;\nconst NON_MAIN_ARENA:int32 = 4;\nconst SIZE_BITS:int32 = PREV_INUSE|IS_MMAPPED|NON_MAIN_ARENA;\n\n//An allocated chunk looks like this:\n/*\n chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of previous chunk, if allocated | |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of chunk, in bytes |P|\n mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | User data starts here... .\n . .\n . (malloc_usable_size() bytes) .\n . |\nnextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of chunk |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n*/\n//Free chunks are stored in circular doubly-linked lists, and look like this:\n/*\n chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of previous chunk |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n `head:' | Size of chunk, in bytes |P|\n mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Forward pointer to next chunk in list |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Back pointer to previous chunk in list |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Unused space (may be 0 bytes long) .\n . .\n . |\nnextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n `foot:' | Size of chunk, in bytes |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n*/\n\n// function init_malloc():void{\n// numFreeChunks = 0;\n// firstFree = 0;\n// lastFree = 0;\n// originalHeapPointer = 40 as *uint8;//this will override by compiler\n// currentHeapPointer = 40 as *uint8;//this will override by compiler\n// }\n\nexport function malloc(size: int32): *uint8 {\n\n //All loc variable should declare here before assigning named value\n var alignment:int32 = 8;\n\n size = (size + (alignment - 1)) & ~(alignment - 1) as int32;\n var chunkSize = size + 8;\n\n var freeChunk = getFreeChunk(chunkSize);\n if(freeChunk as int32 > 0){\n return freeChunk;\n }\n\n var offset:int32 = currentHeapPointer as int32;\n offset = offset + 7;\n offset = offset & ~7;\n // offset = ((currentHeapPointer as int32 + 7) & ~(7) as int32) as *uint8;\n\n var top = offset + chunkSize;\n\n var ptr = (offset + 4) as *uint8; //skip prev size\n setHeadSize(ptr, chunkSize);\n setInuse((ptr + 4) as *uint8);\n setFoot(ptr, chunkSize);\n\n currentHeapPointer = (top + 4) as *uint8;\n\n offset = offset + 8;\n\n // Make sure the memory starts off at zero\n ptr = offset as *uint8;\n while ((ptr as int32) < (top as int32)) {\n *(ptr as *int32) = 0;\n ptr = ptr + 4;\n }\n\n return offset as *uint8;\n}\nexport function free(ptr:*uint8):void{\n\n var chunkptr:*uint8 = null;\n var tmp1:int32 = 0;\n\n clearInuse(ptr);\n if(firstFree == 0){\n firstFree = ptr as int32;\n }\n\n tmp1 = freeMemory as int32;\n tmp1 = tmp1 + getChunkSize(ptr) as int32;\n freeMemory = tmp1 as int32;\n\n chunkptr = ptr + 4;\n if(lastFree > 0){\n *(chunkptr as *int32) = lastFree;//backward pointer to prev chunk\n *(lastFree as *int32) = ptr as int32;//forward pointer to next chunk of prev chunk\n }else{\n *(chunkptr as *int32) = 0;//no backward pointer, this is the first free chunk\n }\n\n *(ptr as *int32) = 0;//no forward pointer\n\n lastFree = ptr as int32;\n numFreeChunks = numFreeChunks + 1;\n}\n/*export*/function getFreeChunk(size: int32):*uint8{\n\n var freeChunk:*uint8 = null;\n var tmp1:int32 = 0;\n var tmp2:int32 = 0;\n var tmp3:int32 = 0;\n var tmp4:int32 = 0;\n\n tmp1 = firstFree;\n tmp2 = lastFree;\n tmp3 = freeMemory;\n\n if(numFreeChunks > 0){\n freeChunk = findChunk(size);\n if(freeChunk as int32 > 0){\n if(freeChunk as int32 == tmp1){\n firstFree = nextFree(freeChunk) as int32;\n }\n if(freeChunk as int32 == tmp2){\n lastFree = 0;\n }\n numFreeChunks = numFreeChunks - 1;\n setInuse(freeChunk);\n tmp4 = getChunkSize(freeChunk);\n tmp3 = tmp3 - tmp4;\n freeMemory = tmp3;\n }\n }\n return freeChunk;\n}\n/*export*/function findChunk(size: int32):*uint8{\n var chunk:*uint8 = null;\n var tmp1:int32 = 0;\n\n chunk = firstFree as *uint8;\n while(chunk != null){\n tmp1= getChunkSize(chunk);\n if(tmp1 == size){\n return chunk;\n }\n chunk = *(chunk as *int32) as *uint8;\n }\n return null;\n}\n/*export*/ function getHeapPtr(): int32 {\n return currentHeapPointer as int32;\n}\n/*export*/ function getFreeMemory(): int32 {\n return freeMemory;\n}\n/*export*/ function getOriginalHeapPtr(): int32 {\n return originalHeapPointer as int32;\n}\nfunction getNumFreeChunks():int32{\n return numFreeChunks as int32;\n}\n/*export*/function getFirstFree():int32{\n return firstFree;\n}\n/*export*/function getLastFree():int32{\n return lastFree;\n}\n/*export*/function prevFree(ptr:*uint8):int32{\n return *(ptr as *int32 + 4) as int32;\n}\n/*export*/function nextFree(ptr:*uint8):int32{\n return *(ptr as *int32) as int32;\n}\n/* Set size at head, without disturbing its use bit */\nfunction setHeadSize(ptr:*uint8, s:int32):void {\n *(ptr as *int32) = (*(ptr as *int32) & SIZE_BITS) | s;\n}\n\n/* Set size/use field */\nfunction setHead(ptr:*uint8, s:int32):void {\n *(ptr as *int32) = s;\n}\n\n/* Set size at footer (only when chunk is not in use) */\nfunction setFoot(ptr:*uint8, s:int32):void {\n var chunkptr:int32 = 0;\n var size:int32 = 0;\n size = *(ptr as *int32);\n chunkptr = (ptr as int32) + size;\n *(chunkptr as *int32) = s;\n}\n\n/*export*/function getPrevInuse(ptr:*uint8):int32 {\n var chunkptr:int32 = 0;\n chunkptr = (ptr as int32) - 8;\n return *(chunkptr as *int32) & (PREV_INUSE);\n}\n/*export*/function setInuse(ptr:*uint8):void{\n var chunkptr:int32 = 0;\n chunkptr = (ptr as int32) - 4;\n *(chunkptr as *int32) = *(chunkptr as *int32) | PREV_INUSE;\n}\n/*export*/function getInuse(ptr:*uint8):int32{\n var chunkptr:int32 = 0;\n chunkptr = (ptr as int32) - 4;\n return *(chunkptr as *int32) & (PREV_INUSE);\n}\n/*export*/function clearInuse(ptr:*uint8):void{\n var chunkptr:int32 = 0;\n chunkptr = (ptr as int32) - 4;\n *(chunkptr as *int32) = *(chunkptr as *int32) & ~(PREV_INUSE);\n}\n/*export*/function getChunkSize(ptr:*uint8):int32{\n var chunkptr:int32 = 0;\n chunkptr = (ptr as int32) - 4;\n return *(chunkptr as *int32) & ~(PREV_INUSE) as int32;\n}\n/* malloc */\n// var SIZE_SZ:int32 = 4;\n// var MALLOC_ALIGNMENT:int32 = 8;//2 * SIZE_SZ;\n// var MALLOC_ALIGN_MASK:int32 = MALLOC_ALIGNMENT - 1;\n//\n// var PREV_INUSE:int32 = 0x1;\n// var IS_MMAPPED:int32 = 0x2;\n// var NON_MAIN_ARENA:int32 = 0x4;\n// var SIZE_BITS:int32 = PREV_INUSE|IS_MMAPPED|NON_MAIN_ARENA;\n//\n// class chunk{\n// prevSize:int32;\n// size:int32;\n// forward:int32;\n// backward:int32;\n// forwardLarge:int32;\n// backwardLarge:int32;\n// }\n// function prev_inuse(p:*chunk):int32 {\n// return (p as chunk).size & PREV_INUSE;\n// }\n// function chunksize(p:*chunk):int32 {\n// return (p as chunk).size & ~(SIZE_BITS);\n// }\n// /* Ptr to next physical malloc_chunk. */\n// function next_chunk(p:*chunk):*chunk {\n// ((*p as int32) + (p as chunk).size & ~(SIZE_BITS)) as *chunk;\n// }\n//\n// /* Ptr to previous physical malloc_chunk */\n// function prev_chunk(p:*chunk):*chunk {\n// ((*p as int32) - (p as chunk).prevSize) as *chunk;\n// }\n//\n// /* Treat space at ptr + offset as a chunk */\n// function chunk_at_offset(p:*chunk, s:int32):*chunk{\n// return ((*p as int32) + s) as *chunk;\n// }\n//\n// /* extract p's inuse bit */\n// function inuse(p:*chunk):int32{\n// return ((*p as int32) + (((p as chunk).size & ~SIZE_BITS) as chunk).size) & PREV_INUSE;\n// }\n//\n// /* set/clear chunk as being inuse without otherwise disturbing */\n// function set_inuse(p:*chunk):int32{\n// return ((*p as int32) + (((p as chunk).size & ~SIZE_BITS) as chunk).size) = ((*p as int32) + (((p as chunk).size & ~SIZE_BITS) as chunk).size) | PREV_INUSE;\n// }\n//\n// function clear_inuse(p:*chunk):int32{\n// return ((*p as int32) + (((p as chunk).size & ~SIZE_BITS) as chunk).size) = ((*p as int32) + (((p as chunk).size & ~SIZE_BITS) as chunk).size) & ~(PREV_INUSE);\n// }\n\nfunction memcpy(target: *uint8, source: *uint8, length: int32): void {\n // No-op if either of the inputs are null\n if (source == null || target == null) {\n return;\n }\n\n // Optimized aligned copy\n if (length >= 16 && (source as int32) % 4 == (target as int32) % 4) {\n // Pick off the beginning\n while ((target as int32) % 4 != 0) {\n *target = *source;\n target = target + 1;\n source = source + 1;\n length = length - 1;\n }\n\n // Pick off the end\n while (length % 4 != 0) {\n length = length - 1;\n *(target + length) = *(source + length);\n }\n\n // Zip over the middle\n var end = target + length;\n while (target < end) {\n *(target as *int32) = *(source as *int32);\n target = target + 4;\n source = source + 4;\n }\n }\n\n // Slow unaligned copy\n else {\n var end = target + length;\n while (target < end) {\n *target = *source;\n target = target + 1;\n source = source + 1;\n }\n }\n}\n\nfunction memcmp(a: *uint8, b: *uint8, length: int32): int32 {\n // No-op if either of the inputs are null\n if (a == null || b == null) {\n return 0;\n }\n\n // Return the first non-zero difference\n while (length > 0) {\n var delta = *a as int32 - *b as int32;\n if (delta != 0) {\n return delta;\n }\n a = a + 1;\n b = b + 1;\n length = length - 1;\n }\n\n // Both inputs are identical\n return 0;\n}"},function(module,exports){module.exports="const PI:float64 = 3.141592653589793;\n\nconst MAX_UNSIGNED_INTEGER_32:uint32 = 4294967295;\n\nconst MIN_INTEGER_32:int32 = -2147483648;\nconst MAX_INTEGER_32:int32 = 2147483647;\n\nconst MAX_UNSIGNED_INTEGER_64:int32 = 18446744073709551615;\n\n// −(2^63) to 2^63 − 1\n// const MIN_INTEGER_64:int32 = -powi64(2, 63);\n// const MAX_INTEGER_64:int32 = powi64(2, 63) - 1;\n\n// float remainder\n\n // export function modf64(x:float64, y:float64):float64{\n //\n // let ir:int32,iy:int32;\n // let r:float64,w:float64;\n //\n // if (y == 0 || isNaN(y) || !isFinite(x)) {\n // return (x * y) / (x * y);\n // }\n //\n // r = abs(x);\n // y = abs(y);\n // (void)frexp(y,&iy);\n // while (r >= y) {\n // (void)frexp(r,&ir);\n // w = ldexp(y,ir-iy);\n // r -= w <= r ? w : w*(double)0.5;\n // }\n // return x >= (double)0 ? r : -r;\n // }\n // }"},function(module,exports){module.exports="// Native types\nconst NaN: float64 = 0.0 / 0.0;\nconst Infinity: float64 = 1.0 / 0.0;\n\nfunction isNaN(value: float32): boolean {\n return value != value;\n}\n\nfunction isFinite(value: float32): boolean {\n return !isNaN(value) && value != Infinity && value != -Infinity;\n}\n\ndeclare class boolean {\n toString(): string;\n}\n\ndeclare class int8 {\n toString(): string;\n}\n\ndeclare class uint8 {\n toString(): string;\n}\n\ndeclare class int16 {\n toString(): string;\n}\n\ndeclare class uint16 {\n toString(): string;\n}\n\ndeclare class int32 {\n toString(): string;\n}\n\ndeclare class uint32 {\n toString(): string;\n}\n\ndeclare class int64 {\n toString(): string;\n}\n\ndeclare class uint64 {\n toString(): string;\n}\n\ndeclare class float32 {\n toString(): string;\n}\n\ndeclare class float64 {\n toString(): string;\n}\n\ndeclare class string {\n charAt(index: int32): string;\n\n charCodeAt(index: int32): uint16;\n\n get length(): int32;\n\n indexOf(text: string): int32;\n\n lastIndexOf(text: string): int32;\n\n operator == (other: string):boolean;\n operator [] (index: int32): uint16 { return this.charCodeAt(index); }\n slice(start: int32, end: int32): string;\n\n // startsWith(text: string): boolean { return this.slice(0, text.length) == text; }\n // endsWith(text: string): boolean { return this.slice(-text.length, this.length) == text; }\n}\n"},function(module,exports){module.exports='//part of asm module, we have global, foreign, buffer somewhere above this code\n\nvar HEAP8 = new global.Int8Array(buffer);\nvar HEAP16 = new global.Int16Array(buffer);\nvar HEAP32 = new global.Int32Array(buffer);\nvar HEAPU8 = new global.Uint8Array(buffer);\nvar HEAPU16 = new global.Uint16Array(buffer);\nvar HEAPU32 = new global.Uint32Array(buffer);\nvar HEAPF32 = new global.Float32Array(buffer);\nvar HEAPF64 = new global.Float64Array(buffer);\n\nvar NULL = 0;\nvar STACKTOP=env.STACKTOP|0;\nvar STACK_MAX=env.STACK_MAX|0;\n\n// var PREV_INUSE = 0x1;\n// var PREV_INUSE = 0x1;\n// var IS_MMAPPED = 0x2;\n// var NON_MAIN_ARENA = 0x4;\n// var SIZE_BITS = 0x7;//(PREV_INUSE|IS_MMAPPED|NON_MAIN_ARENA) | 0;\n// var firstFreeChunk = 0;\n// var lastFreeChunk = 0;\n// var numFreeChunks = 0;\n// var freeMemory = 0;\n//var internal_alloc = 0;\n\n// var _now = (typeof global.performance != \'undefined\' && typeof global.performance.now == \'function\' ?\n// global.performance.now.bind(global.performance) :\n// global.Date.now.bind(global.Date));\n// var _now = global.performance;\n// Map of class type IDs to type objects.\n// var _idToType = 8;\n\n// function init() {\n// HEAP32[2 >> 2] = buffer.byteLength | 0;\n\n // if (global.isShared) {\n // internal_alloc = alloc_sab;\n // global.Atomics.store(HEAP32, 1 | 0, 16 | 0);\n // }\n // else {\n // internal_alloc = alloc_ab;\n // HEAP32[1>>2] = 16 | 0;\n // }\n// }\n\n\n// function malloc(nbytes, alignment) {\n// nbytes |= 0;\n// alignment |= 0;\n// var ptr = alloc_sab(nbytes, alignment);\n// if (ptr == 0)\n// throw new Error("Out of memory");\n// return ptr|0;\n// }\n// function free(ptr) {\n// ptr |= 0;\n// clearInuse(ptr);\n// if (firstFreeChunk == 0) {\n// firstFreeChunk = ptr;\n// }\n//\n// freeMemory = freeMemory + getChunkSize(ptr);\n//\n// var chunkptr = ptr + 4;\n// if (lastFreeChunk > 0) {\n// HEAPU32[chunkptr>>2] = lastFreeChunk;//backward pointer to prev chunk\n// HEAPU32[lastFreeChunk>>2] = ptr;//forward pointer to next chunk of prev chunk\n// } else {\n// HEAPU32[chunkptr>>2] = 0;//no backward pointer, this is the first free chunk\n// }\n//\n// HEAPU32[ptr>>2] = 0;//no forward pointer\n//\n// lastFreeChunk = ptr;\n// numFreeChunks = numFreeChunks + 1;\n// }\n// function identify(ptr) {\n// if (ptr == 0)\n// return 0;\n// return _idToType[HEAP32[ptr >> 2]];\n// }\n// function _badType(self) {\n// var t = identify(self);\n// return new global.Error("Observed type: " + (t ? t.NAME : "*invalid*") + ", address=" + self);\n// }\n// Synchronic layout is 8 bytes (2 x int32) of metadata followed by\n// the type-specific payload. The two int32 words are the number\n// of waiters and the wait word (generation count).\n//\n// In the following:\n//\n// self is the base address for the Synchronic.\n// mem is the array to use for the value\n// idx is the index in mem of the value: (ptr+8)>>log2(mem.BYTES_PER_ELEMENT)\n//\n// _synchronicLoad is just Atomics.load, expand it in-line.\n/*function _synchronicStore(self, mem, idx, value) {\n global.Atomics.store(mem, idx, value);\n _notify(self);\n return value;\n}\nfunction _synchronicCompareExchange(self, mem, idx, oldval, newval) {\n var v = global.Atomics.compareExchange(mem, idx, oldval, newval);\n if (v == oldval)\n _notify(self);\n return v;\n}\nfunction _synchronicAdd(self, mem, idx, value) {\n var v = global.Atomics.add(mem, idx, value);\n _notify(self);\n return v;\n}\nfunction _synchronicSub(self, mem, idx, value) {\n var v = global.Atomics.sub(mem, idx, value);\n _notify(self);\n return v;\n}\nfunction _synchronicAnd(self, mem, idx, value) {\n var v = global.Atomics.and(mem, idx, value);\n _notify(self);\n return v;\n}\nfunction _synchronicOr(self, mem, idx, value) {\n var v = global.Atomics.or(mem, idx, value);\n _notify(self);\n return v;\n}\nfunction _synchronicXor(self, mem, idx, value) {\n var v = global.Atomics.xor(mem, idx, value);\n _notify(self);\n return v;\n}\nfunction _synchronicLoadWhenNotEqual(self, mem, idx, value) {\n for (; ;) {\n var tag = global.Atomics.load(HEAP32, (self + 4) >> 2);\n var v = global.Atomics.load(mem, idx);\n if (v !== value)\n break;\n _waitForUpdate(self, tag, Number.POSITIVE_INFINITY);\n }\n return v;\n}\n\nfunction _synchronicLoadWhenEqual(self, mem, idx, value) {\n for (; ;) {\n var tag = global.Atomics.load(HEAP32, (self + 4) >> 2);\n var v = global.Atomics.load(mem, idx);\n if (v === value)\n break;\n _waitForUpdate(self, tag, Number.POSITIVE_INFINITY);\n }\n return v;\n}\nfunction _synchronicExpectUpdate(self, mem, idx, value, timeout) {\n var now = global.performance();\n var limit = now + timeout;\n for (; ;) {\n var tag = global.Atomics.load(HEAP32, (self + 4) >> 2);\n var v = global.Atomics.load(mem, idx);\n if (v !== value || now >= limit)\n break;\n _waitForUpdate(self, tag, limit - now);\n now = global.performance();\n }\n}\nfunction _waitForUpdate(self, tag, timeout) {\n // Spin for a int16 time before going into the futexWait.\n //\n // Hard to know what a good count should be - it is machine\n // dependent, for sure, and "typical" applications should\n // influence the choice. If the count is high without\n // hindering an eventual drop into futexWait then it will just\n // decrease performance. If the count is low it is pointless.\n // (This is why Synchronic really wants a native implementation.)\n //\n // data points from a 2.6GHz i7 MacBook Pro:\n //\n // - the simple send-integer benchmark (test-sendint.html),\n // which is the very simplest case we can really imagine,\n // gets noisy timings with an iteration count below 4000\n //\n // - the simple send-object benchmark (test-sendmsg.html)\n // gets a boost when the count is at least 10000\n //\n // 10000 is perhaps 5us (CPI=1, naive) and seems like a\n // reasonable cutoff, for now - but note, it is reasonable FOR\n // THIS SYSTEM ONLY, which is a big flaw.\n //\n // The better fix might well be to add some kind of spin/nanosleep\n // functionality to futexWait, see https://bugzil.la/1134973.\n // That functionality can be platform-dependent and even\n // adaptive, with JIT support.\n var i = 10000;\n do {\n // May want this to be a relaxed load, though on x86 it won\'t matter.\n if (global.Atomics.load(HEAP32, (self + 4) >> 2) != tag)\n return;\n } while (--i > 0);\n global.Atomics.add(HEAP32, self >> 2, 1);\n global.Atomics.wait(HEAP32, (self + 4) >> 2, tag, timeout);\n global.Atomics.sub(HEAP32, self >> 2, 1);\n}\nfunction _notify(self) {\n global.Atomics.add(HEAP32, (self + 4) >> 2, 1);\n // Would it be appropriate & better to wake n waiters, where n\n // is the number loaded in the load()? I almost think so,\n // since our futexes are fair.\n if (global.Atomics.load(HEAP32, self >> 2) > 0)\n global.Atomics.wake(HEAP32, (self + 4) >> 2, Number.POSITIVE_INFINITY);\n}*/\n\n// function getFreeChunk(nbytes) {\n// nbytes = nbytes | 0;\n// if (numFreeChunks > (0 | 0)) {\n// var freeChunk = findChunk(nbytes);\n// if (freeChunk > (0 | 0)) {\n// if (freeChunk == firstFreeChunk) {\n// firstFreeChunk = nextFree(freeChunk);\n// }\n// if (freeChunk == lastFreeChunk) {\n// lastFreeChunk = (0 | 0);\n// }\n// numFreeChunks = numFreeChunks - (1 | 0);\n// setInuse(freeChunk);\n// freeMemory = freeMemory - getChunkSize(freeChunk);\n// return freeChunk;\n// }\n// }\n// return 0 | 0;\n// }\n// function findChunk(nbytes) {\n// nbytes = nbytes | 0;\n// var chunk = firstFreeChunk;\n// while (chunk != 0) {\n// if (getChunkSize(chunk) == nbytes) {\n// return chunk;\n// }\n// chunk = HEAPU32[chunk>>2];\n// }\n// return 0;\n// }\n// function prevFree(ptr) {\n// return HEAPU32[(ptr + 4)>>2];\n// }\n// function nextFree(ptr) {\n// return HEAPU32[ptr>>2];\n// }\n// /* Set size at head, without disturbing its use bit */\n// function setHeadSize(ptr, s) {\n// HEAPU32[ptr>>2] = (HEAPU32[ptr>>2] & SIZE_BITS) | s;\n// }\n//\n// /* Set size/use field */\n// function setHead(ptr, s) {\n// HEAPU32[ptr>>2] = s;\n// }\n//\n// /* Set size at footer (only when chunk is not in use) */\n// function setFoot(ptr, s) {\n// HEAPU32[(ptr + s)>>2] = s;\n// }\n//\n// function getPrevInuse(ptr) {\n// return HEAPU32[(ptr - 8)>>2] & (PREV_INUSE);\n// }\n// function setInuse(ptr) {\n// HEAPU32[(ptr - 4)>>2] |= PREV_INUSE;\n// }\n// function getInuse(ptr) {\n// return HEAPU32[(ptr - 4)>>2] & PREV_INUSE;\n// }\n// function clearInuse(ptr) {\n// HEAPU32[(ptr - 4)>>2] &= ~PREV_INUSE;\n// }\n// function getChunkSize(ptr) {\n// return HEAPU32[(ptr - 4)>>2] & ~(PREV_INUSE);\n// }\n//\n// function alloc_sab(nbytes, alignment) {\n// nbytes = nbytes | 0;\n// alignment = alignment | 0;\n// if (numFreeChunks > 0) {\n// var chunk = getFreeChunk(nbytes);\n// if (chunk > (0 | 0)) {\n// return chunk;\n// }\n// }\n//\n// do {\n// var ptr = global.Atomics.load(HEAP32, 1);\n// var q = (ptr + (alignment - 1)) & ~(alignment - 1);\n// var top = q + nbytes;\n// if (top >= HEAP32[2>>2])\n// return 0;\n// } while (global.Atomics.compareExchange(HEAP32, 1, ptr, top) != ptr);\n//\n// return q;\n// }\n// function alloc_ab(nbytes, alignment) {\n// nbytes = nbytes | 0;\n// alignment = alignment | 0;\n//\n// var ptr = HEAP32[1>>2] | 0;\n// ptr = ((ptr + (alignment - 1)) & ~(alignment - 1)) | 0;\n// var top = (ptr + nbytes) | 0;\n// if (top >= HEAP32[2>>2])\n// return 0 | 0;\n// HEAP32[1>>2] = top | 0;\n// return ptr | 0;\n// }'},function(module,exports){module.exports="declare class boolean {\n toString(): string;\n}\n\ndeclare class int8 {\n toString(): string;\n}\n\ndeclare class uint8 {\n toString(): string;\n}\n\ndeclare class int16 {\n toString(): string;\n}\n\ndeclare class uint16 {\n toString(): string;\n}\n\ndeclare class int32 {\n toString(): string;\n}\n\ndeclare class uint32 {\n toString(): string;\n}\n\ndeclare class int64 {\n toString(): string;\n}\n\ndeclare class uint64 {\n toString(): string;\n}\n\ndeclare class float32 {\n toString(): string;\n}\n\ndeclare class float64 {\n toString(): string;\n}\n\ndeclare class string {\n charAt(index: int32): string;\n charCodeAt(index: int32): uint16;\n get length(): int32;\n indexOf(text: string): int32;\n lastIndexOf(text: string): int32;\n operator == (other: string): boolean;\n operator [] (index: int32): uint16 { return this.charCodeAt(index); }\n slice(start: int32, end: int32): string;\n\n startsWith(text: string): boolean { return this.slice(0, text.length) == text; }\n endsWith(text: string): boolean { return this.slice(-text.length, this.length) == text; }\n}"},function(module,exports){module.exports="function TurboWrapper(exports, buffer) {\n\n var HEAP8 = new Int8Array(buffer);\n var HEAP16 = new Int16Array(buffer);\n var HEAP32 = new Int32Array(buffer);\n var HEAPU8 = new Uint8Array(buffer);\n var HEAPU16 = new Uint16Array(buffer);\n var HEAPU32 = new Uint32Array(buffer);\n var HEAPF32 = new Float32Array(buffer);\n var HEAPF64 = new Float64Array(buffer);\n\n return {\n exports: exports,\n RAW_MEMORY: buffer,\n\n getMemoryUsage: function () {\n const top = Atomics.load(HEAP32, 2);\n // top -= freeMemory;\n return Math.fround(top / (1024 * 1024));\n }\n }\n}\nfunction initTurbo(MB) {\n var buffer = new SharedArrayBuffer(MB * 1024 * 1024);\n\n if (buffer.byteLength < 16) {\n throw new Error(\"The memory is too small even for metadata\");\n }\n\n return TurboWrapper(TurboModule(\n typeof global !== 'undefined' ? global : window,\n typeof env !== 'undefined' ? env : {\n STACKTOP: 8,\n STACK_MAX: 8\n },\n buffer\n ), buffer);\n}"},function(module,exports){module.exports="// WebAssembly builtin functions\ndeclare function rotl(value: int64, shift: int64): int64;\ndeclare function rotl32(value: int32, shift: int32): int32;\ndeclare function rotr(value: int64, shift: int64): int64;\ndeclare function rotr32(value: int32, shift: int32): int32;\ndeclare function clz(value: int64): int64;\ndeclare function clz32(value: int32): int32;\ndeclare function ctz(value: int64): int64;\ndeclare function ctz32(value: int32): int32;\ndeclare function popcnt(value: int64): int64;\ndeclare function popcnt32(value: int32): int32;\ndeclare function abs(value: float64): float64;\ndeclare function abs32(value: float32): float32;\ndeclare function ceil(value: float64): float64;\ndeclare function ceil32(value: float32): float32;\ndeclare function floor(value: float64): float64;\ndeclare function floor32(value: float32): float32;\ndeclare function sqrt(value: float64): float64;\ndeclare function sqrt32(value: float32): float32;\ndeclare function trunc(value: float64): float64;\ndeclare function trunc32(value: float32): float32;\ndeclare function nearest(value: float64): float64;\ndeclare function nearest32(value: float32): float32;\ndeclare function min(left: float64, right: float64): float64;\ndeclare function min32(left: float32, right: float32): float32;\ndeclare function max(left: float64, right: float64): float64;\ndeclare function max32(left: float32, right: float32): float32;\ndeclare function copysign(left: float64, right: float64): float64;\ndeclare function copysign32(left: float32, right: float32): float32;\ndeclare function reinterpret_i32(value: float32): int32;\ndeclare function reinterpret_i64(value: float64): int64;\ndeclare function reinterpret_f32(value: int32): float32;\ndeclare function reinterpret_f64(value: int64): float64;\ndeclare function current_memory(): int32;\ndeclare function grow_memory(value: int32): int32;\n"},function(module,exports){module.exports="/**\n * Created by n.vinayakan on 30.05.17.\n * WebAssembly start function where global variable expressions initializer\n */\n@start\nfunction __WASM_INITIALIZER(): void {\n // 🔥 WARNING 🔥\n // DON'T RETURN ANYTHING FROM THIS FUNCTION\n // Global variable initialization expressions will be appended to this function\n numFreeChunks = 0;\n firstFree = 0;\n lastFree = 0;\n // originalHeapPointer = 40 as *uint8;//this will override by compiler\n // currentHeapPointer = 40 as *uint8;//this will override by compiler\n}\n"},function(module,exports,__webpack_require__){"use strict";function append(array,offset,value,msg){void 0===offset&&(offset=0),void 0===value&&(value=null),void 0===msg&&(msg=null),array.log+=(null!=value?utils_1.toHex(offset+array.position)+": "+utils_1.toHex(value,2)+" ; ":"")+(null!=msg?msg+"\n":"\n"),value&&array.append(value)}function logOpcode(array,offset,opcode,inline_value){void 0===offset&&(offset=0),array.log+=utils_1.toHex(offset+array.position)+": "+utils_1.toHex(opcode,2)+" ; "+opcode_1.WasmOpcode[opcode]+" "+(inline_value||"")+"\n"}Object.defineProperty(exports,"__esModule",{value:!0});var wasm_stack_tracer_1=__webpack_require__(44),utils_1=__webpack_require__(6),opcode_1=__webpack_require__(8),section_buffer_1=__webpack_require__(35),logger_1=__webpack_require__(10),wasm_section_1=__webpack_require__(14),wasm_runtime_local_1=__webpack_require__(15),wasm_type_1=__webpack_require__(7),terminal_1=__webpack_require__(1),index_1=__webpack_require__(16),WasmAssembler=function(){function WasmAssembler(){this.sectionList=[],this.importList=[],this.functionList=[],this.currentSection=null,this.currentFunction=null,this.stackTracer=new wasm_stack_tracer_1.WasmStackTracer,this.textOutput=";; Experimental wast emitter\n(module\n"}return WasmAssembler.prototype.sealFunctions=function(){var runtimeFunctions=[];this.importList.forEach(function(_import){var fn=new wasm_stack_tracer_1.WasmRuntimeFunction;fn.module=_import.module,fn.name=_import.name,fn.signature=_import.signature,fn.isImport=!0,runtimeFunctions.push(fn)}),this.functionList.forEach(function(_wasmFunc){var fn=new wasm_stack_tracer_1.WasmRuntimeFunction;fn.name=index_1.getWasmFunctionName(_wasmFunc.symbol),fn.signature=_wasmFunc.signature,fn.isImport=!1,fn.locals=[],_wasmFunc.localEntries.forEach(function(local){fn.locals.push(new wasm_runtime_local_1.WasmRuntimeProperty(local.type,local.name))}),runtimeFunctions.push(fn)}),this.stackTracer.functions=runtimeFunctions},WasmAssembler.prototype.startSection=function(array,id,name){var section=new section_buffer_1.SectionBuffer(id,name);return section.offset=array.length,logger_1.log(array,0,null," - section: "+wasm_section_1.WasmSection[id]+" [0x"+utils_1.toHex(id,2)+"]"),this.currentSection=section,this.sectionList.push(section),section},WasmAssembler.prototype.endSection=function(array,section){this.currentSection=null,section.publish(array)},WasmAssembler.prototype.dropStack=function(array,max){if(void 0===max&&(max=1),this.stackTracer.context.stack.length>0){terminal_1.Terminal.warn("Dropping stack items, '"+this.stackTracer.context.fn.name+"' func stack contains "+this.stackTracer.context.stack.length+" items");for(var item=this.stackTracer.context.stack.pop(!0);void 0!==item&&max>0;)terminal_1.Terminal.warn(wasm_type_1.WasmType[item.type]),array.append(opcode_1.WasmOpcode.DROP),this.currentSection.code.append("drop\n"),item=this.stackTracer.context.stack.pop(!0),max--}},WasmAssembler.prototype.appendOpcode=function(array,offset,opcode,inline_value,skip){void 0===offset&&(offset=0),void 0===skip&&(skip=!1),logOpcode(array,offset,opcode,inline_value),array.append(opcode);var opcodeWithoutOperand=this.stackTracer.pushOpcode(opcode);if(null!==opcodeWithoutOperand&&!skip){var isEnd=opcode===opcode_1.WasmOpcode.END,indent=this.isBlock(opcode)?1:isEnd?-1:0;isEnd&&this.currentSection.code.clearIndent(1),this.currentSection.code.append(opcodeWithoutOperand+"\n",indent)}},WasmAssembler.prototype.isBlock=function(opcode){return opcode===opcode_1.WasmOpcode.BLOCK||opcode===opcode_1.WasmOpcode.LOOP||opcode===opcode_1.WasmOpcode.IF||opcode===opcode_1.WasmOpcode.IF_ELSE},WasmAssembler.prototype.writeUnsignedLEB128=function(array,value){array.writeUnsignedLEB128(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.currentSection.code.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeLEB128=function(array,value){array.writeLEB128(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.currentSection.code.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeFloat=function(array,value){array.writeFloat(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.currentSection.code.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeDouble=function(array,value){array.writeDouble(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.currentSection.code.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeWasmString=function(array,value){array.writeWasmString(value)},WasmAssembler.prototype.finish=function(){var _this=this;this.textOutput+=" ",this.sectionList.forEach(function(section){_this.textOutput+=section.code.finish()}),this.textOutput+=")\n"},WasmAssembler}();exports.WasmAssembler=WasmAssembler,exports.append=append,exports.logOpcode=logOpcode},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var logger_1=__webpack_require__(10),bytearray_1=__webpack_require__(12),stringbuilder_1=__webpack_require__(54),SectionBuffer=function(){function SectionBuffer(id,name){this.id=id,this.name=name,this.data=new bytearray_1.ByteArray,this.code=new stringbuilder_1.StringBuilder(2),this.code.indent=1}return SectionBuffer.prototype.publish=function(array){if(logger_1.log(array,0,this.id,"section code"),array.writeUnsignedLEB128(this.id),0==this.id){var strData=new bytearray_1.ByteArray;strData.writeWasmString(this.name),logger_1.log(array,0,this.data.length,"section size"),array.writeUnsignedLEB128(this.data.length+strData.length),array.copy(strData)}else logger_1.log(array,0,this.data.length,"section size"),array.writeUnsignedLEB128(this.data.length);array.log+=this.data.log,array.copy(this.data)},SectionBuffer}();exports.SectionBuffer=SectionBuffer},function(module,exports,__webpack_require__){"use strict";function getBuiltinOpcode(name){switch(name){case"rotl":return opcode_1.WasmOpcode.I64_ROTL;case"rotl32":return opcode_1.WasmOpcode.I32_ROTL;case"rotr":return opcode_1.WasmOpcode.I64_ROTR;case"rotr32":return opcode_1.WasmOpcode.I32_ROTR;case"clz":return opcode_1.WasmOpcode.I64_CLZ;case"clz32":return opcode_1.WasmOpcode.I32_CLZ;case"ctz":return opcode_1.WasmOpcode.I64_CTZ;case"ctz32":return opcode_1.WasmOpcode.I32_CTZ;case"popcnt":return opcode_1.WasmOpcode.I64_POPCNT;case"popcnt32":return opcode_1.WasmOpcode.I32_POPCNT;case"abs":return opcode_1.WasmOpcode.F64_ABS;case"abs32":return opcode_1.WasmOpcode.F32_ABS;case"ceil":return opcode_1.WasmOpcode.F64_CEIL;case"ceil32":return opcode_1.WasmOpcode.F32_CEIL;case"floor":return opcode_1.WasmOpcode.F64_FLOOR;case"floor32":return opcode_1.WasmOpcode.F32_FLOOR;case"sqrt":return opcode_1.WasmOpcode.F64_SQRT;case"sqrt32":return opcode_1.WasmOpcode.F32_SQRT;case"trunc":return opcode_1.WasmOpcode.F64_TRUNC;case"trunc32":return opcode_1.WasmOpcode.F32_TRUNC;case"nearest":return opcode_1.WasmOpcode.F64_NEAREST;case"nearest32":return opcode_1.WasmOpcode.F32_NEAREST;case"min":return opcode_1.WasmOpcode.F64_MIN;case"min32":return opcode_1.WasmOpcode.F32_MIN;case"max":return opcode_1.WasmOpcode.F64_MAX;case"max32":return opcode_1.WasmOpcode.F32_MAX;case"copysign":return opcode_1.WasmOpcode.F64_COPYSIGN;case"copysign32":return opcode_1.WasmOpcode.F32_COPYSIGN;case"reinterpret_i32":return opcode_1.WasmOpcode.F32_REINTERPRET_I32;case"reinterpret_i64":return opcode_1.WasmOpcode.F64_REINTERPRET_I64;case"reinterpret_f32":return opcode_1.WasmOpcode.I32_REINTERPRET_F32;case"reinterpret_f64":return opcode_1.WasmOpcode.I64_REINTERPRET_F64;case"current_memory":return opcode_1.WasmOpcode.MEMORY_SIZE;case"grow_memory":return opcode_1.WasmOpcode.GROW_MEMORY;default:throw"No builtin function named '"+name+"'"}}function isBuiltin(name){return exports.builtins.indexOf(name)>-1}Object.defineProperty(exports,"__esModule",{value:!0});var opcode_1=__webpack_require__(8);exports.builtins=["rotl","rotl32","rotr","rotr32","clz","clz32","ctz","ctz32","popcnt","popcnt32","abs","abs32","ceil","ceil32","floor","floor32","sqrt","sqrt32","trunc","trunc32","nearest","nearest32","min","min32","max","max32","copysign","copysign32","reinterpret_i32","reinterpret_i64","reinterpret_f32","reinterpret_f64","current_memory","grow_memory"],exports.getBuiltinOpcode=getBuiltinOpcode,exports.isBuiltin=isBuiltin},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});!function(WasmExternalKind){WasmExternalKind[WasmExternalKind.Function=0]="Function",WasmExternalKind[WasmExternalKind.Table=1]="Table",WasmExternalKind[WasmExternalKind.Memory=2]="Memory",WasmExternalKind[WasmExternalKind.Global=3]="Global"}(exports.WasmExternalKind||(exports.WasmExternalKind={}))},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmFunction=function(){function WasmFunction(){this.localCount=0,this.localVariables=[]}return WasmFunction}();exports.WasmFunction=WasmFunction},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmGlobalEntry=function(){function WasmGlobalEntry(type,immutable,name){this.type=type,this.immutable=immutable,this.name=name}return WasmGlobalEntry}();exports.WasmGlobalEntry=WasmGlobalEntry;var WasmGlobal=function(){function WasmGlobal(){}return WasmGlobal}();exports.WasmGlobal=WasmGlobal},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmImport=function(){function WasmImport(){}return WasmImport}();exports.WasmImport=WasmImport},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmLocalEntry=function(){function WasmLocalEntry(type,name,isArgument){void 0===isArgument&&(isArgument=!1),this.type=type,this.name=name,this.isArgument=isArgument}return WasmLocalEntry}();exports.WasmLocalEntry=WasmLocalEntry;var WasmLocal=function(){function WasmLocal(){}return WasmLocal}();exports.WasmLocal=WasmLocal},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmSharedOffset=function(){function WasmSharedOffset(){this.nextLocalOffset=0,this.localCount=0}return WasmSharedOffset}();exports.WasmSharedOffset=WasmSharedOffset},function(module,exports,__webpack_require__){"use strict";function wasmAreSignaturesEqual(a,b){assert_1.assert(null!=a.returnType),assert_1.assert(null!=b.returnType),assert_1.assert(null==a.returnType.next),assert_1.assert(null==b.returnType.next);for(var x=a.argumentTypes,y=b.argumentTypes;null!=x&&null!=y;){if(x.id!=y.id)return!1;x=x.next,y=y.next}return null==x&&null==y&&a.returnType.id==b.returnType.id}Object.defineProperty(exports,"__esModule",{value:!0});var assert_1=__webpack_require__(0),WasmSignature=function(){function WasmSignature(){}return WasmSignature}();exports.WasmSignature=WasmSignature,exports.wasmAreSignaturesEqual=wasmAreSignaturesEqual},function(module,exports,__webpack_require__){"use strict";function getOprandType(opcode){switch(opcode){case opcode_1.WasmOpcode.I32_CONST:case opcode_1.WasmOpcode.I32_ADD:case opcode_1.WasmOpcode.I32_MUL:case opcode_1.WasmOpcode.I32_SUB:case opcode_1.WasmOpcode.I32_DIV_S:case opcode_1.WasmOpcode.I32_DIV_U:case opcode_1.WasmOpcode.I32_REM_S:case opcode_1.WasmOpcode.I32_REM_U:case opcode_1.WasmOpcode.I32_GE_S:case opcode_1.WasmOpcode.I32_GE_U:case opcode_1.WasmOpcode.I32_LE_S:case opcode_1.WasmOpcode.I32_LE_U:case opcode_1.WasmOpcode.I32_GT_S:case opcode_1.WasmOpcode.I32_GT_U:case opcode_1.WasmOpcode.I32_LT_S:case opcode_1.WasmOpcode.I32_LT_U:case opcode_1.WasmOpcode.I32_EQ:case opcode_1.WasmOpcode.I32_NE:case opcode_1.WasmOpcode.I32_EQZ:case opcode_1.WasmOpcode.I32_AND:case opcode_1.WasmOpcode.I32_OR:case opcode_1.WasmOpcode.I32_XOR:case opcode_1.WasmOpcode.I32_CTZ:case opcode_1.WasmOpcode.I32_CLZ:case opcode_1.WasmOpcode.I32_ROTL:case opcode_1.WasmOpcode.I32_ROTR:case opcode_1.WasmOpcode.I32_SHL:case opcode_1.WasmOpcode.I32_SHR_S:case opcode_1.WasmOpcode.I32_SHR_U:case opcode_1.WasmOpcode.I32_POPCNT:case opcode_1.WasmOpcode.I32_LOAD:case opcode_1.WasmOpcode.I32_LOAD8_S:case opcode_1.WasmOpcode.I32_LOAD8_U:case opcode_1.WasmOpcode.I32_LOAD16_S:case opcode_1.WasmOpcode.I32_LOAD16_U:case opcode_1.WasmOpcode.I32_STORE16:case opcode_1.WasmOpcode.I32_STORE8:case opcode_1.WasmOpcode.I32_STORE:case opcode_1.WasmOpcode.I32_REINTERPRET_F32:case opcode_1.WasmOpcode.I32_TRUNC_S_F32:case opcode_1.WasmOpcode.I32_TRUNC_U_F32:case opcode_1.WasmOpcode.I32_TRUNC_S_F64:case opcode_1.WasmOpcode.I32_TRUNC_U_F64:case opcode_1.WasmOpcode.I32_WRAP_I64:return wasm_type_1.WasmType.I32;case opcode_1.WasmOpcode.I64_CONST:case opcode_1.WasmOpcode.I64_ADD:case opcode_1.WasmOpcode.I64_MUL:case opcode_1.WasmOpcode.I64_SUB:case opcode_1.WasmOpcode.I64_DIV_S:case opcode_1.WasmOpcode.I64_DIV_U:case opcode_1.WasmOpcode.I64_CLZ:case opcode_1.WasmOpcode.I64_ROTL:case opcode_1.WasmOpcode.I64_AND:case opcode_1.WasmOpcode.I64_CTZ:case opcode_1.WasmOpcode.I64_EQ:case opcode_1.WasmOpcode.I64_EQZ:case opcode_1.WasmOpcode.I64_GE_S:case opcode_1.WasmOpcode.I64_GE_U:case opcode_1.WasmOpcode.I64_LE_S:case opcode_1.WasmOpcode.I64_LE_U:case opcode_1.WasmOpcode.I64_GT_S:case opcode_1.WasmOpcode.I64_GT_U:case opcode_1.WasmOpcode.I64_LT_S:case opcode_1.WasmOpcode.I64_LT_U:case opcode_1.WasmOpcode.I64_LOAD:case opcode_1.WasmOpcode.I64_LOAD8_S:case opcode_1.WasmOpcode.I64_LOAD8_U:case opcode_1.WasmOpcode.I64_LOAD16_S:case opcode_1.WasmOpcode.I64_LOAD16_U:case opcode_1.WasmOpcode.I64_NE:case opcode_1.WasmOpcode.I64_XOR:case opcode_1.WasmOpcode.I64_STORE16:case opcode_1.WasmOpcode.I64_STORE8:case opcode_1.WasmOpcode.I64_STORE:case opcode_1.WasmOpcode.I64_SHR_S:case opcode_1.WasmOpcode.I64_SHR_U:case opcode_1.WasmOpcode.I64_SHL:case opcode_1.WasmOpcode.I64_ROTR:case opcode_1.WasmOpcode.I64_REM_S:case opcode_1.WasmOpcode.I64_REM_U:case opcode_1.WasmOpcode.I64_POPCNT:case opcode_1.WasmOpcode.I64_OR:case opcode_1.WasmOpcode.I64_REINTERPRET_F64:case opcode_1.WasmOpcode.I64_TRUNC_S_F32:case opcode_1.WasmOpcode.I64_TRUNC_U_F32:case opcode_1.WasmOpcode.I64_TRUNC_S_F64:case opcode_1.WasmOpcode.I64_TRUNC_U_F64:case opcode_1.WasmOpcode.I64_EXTEND_S_I32:case opcode_1.WasmOpcode.I64_EXTEND_U_I32:return wasm_type_1.WasmType.I64;case opcode_1.WasmOpcode.F32_CONST:case opcode_1.WasmOpcode.F32_ADD:case opcode_1.WasmOpcode.F32_SUB:case opcode_1.WasmOpcode.F32_MUL:case opcode_1.WasmOpcode.F32_DIV:case opcode_1.WasmOpcode.F32_SQRT:case opcode_1.WasmOpcode.F32_NEG:case opcode_1.WasmOpcode.F32_NE:case opcode_1.WasmOpcode.F32_ABS:case opcode_1.WasmOpcode.F32_CEIL:case opcode_1.WasmOpcode.F32_EQ:case opcode_1.WasmOpcode.F32_FLOOR:case opcode_1.WasmOpcode.F32_NEAREST:case opcode_1.WasmOpcode.F32_MIN:case opcode_1.WasmOpcode.F32_MAX:case opcode_1.WasmOpcode.F32_GE:case opcode_1.WasmOpcode.F32_GT:case opcode_1.WasmOpcode.F32_LT:case opcode_1.WasmOpcode.F32_LE:case opcode_1.WasmOpcode.F32_COPYSIGN:case opcode_1.WasmOpcode.F32_LOAD:case opcode_1.WasmOpcode.F32_STORE:case opcode_1.WasmOpcode.F32_TRUNC:case opcode_1.WasmOpcode.F32_DEMOTE_F64:case opcode_1.WasmOpcode.F32_CONVERT_S_I32:case opcode_1.WasmOpcode.F32_CONVERT_U_I32:case opcode_1.WasmOpcode.F32_CONVERT_S_I64:case opcode_1.WasmOpcode.F32_CONVERT_U_I64:case opcode_1.WasmOpcode.F32_REINTERPRET_I32:return wasm_type_1.WasmType.F32;case opcode_1.WasmOpcode.F64_CONST:case opcode_1.WasmOpcode.F64_ADD:case opcode_1.WasmOpcode.F64_SUB:case opcode_1.WasmOpcode.F64_MUL:case opcode_1.WasmOpcode.F64_DIV:case opcode_1.WasmOpcode.F64_SQRT:case opcode_1.WasmOpcode.F64_NEG:case opcode_1.WasmOpcode.F64_NE:case opcode_1.WasmOpcode.F64_ABS:case opcode_1.WasmOpcode.F64_CEIL:case opcode_1.WasmOpcode.F64_EQ:case opcode_1.WasmOpcode.F64_FLOOR:case opcode_1.WasmOpcode.F64_NEAREST:case opcode_1.WasmOpcode.F64_MIN:case opcode_1.WasmOpcode.F64_MAX:case opcode_1.WasmOpcode.F64_GE:case opcode_1.WasmOpcode.F64_GT:case opcode_1.WasmOpcode.F64_LT:case opcode_1.WasmOpcode.F64_LE:case opcode_1.WasmOpcode.F64_COPYSIGN:case opcode_1.WasmOpcode.F64_LOAD:case opcode_1.WasmOpcode.F64_STORE:case opcode_1.WasmOpcode.F64_TRUNC:case opcode_1.WasmOpcode.F64_PROMOTE_F32:case opcode_1.WasmOpcode.F64_CONVERT_S_I32:case opcode_1.WasmOpcode.F64_CONVERT_U_I32:case opcode_1.WasmOpcode.F64_CONVERT_S_I64:case opcode_1.WasmOpcode.F64_CONVERT_U_I64:case opcode_1.WasmOpcode.F64_REINTERPRET_I64:return wasm_type_1.WasmType.F64;case opcode_1.WasmOpcode.CALL:case opcode_1.WasmOpcode.END:case opcode_1.WasmOpcode.RETURN:case opcode_1.WasmOpcode.GET_GLOBAL:case opcode_1.WasmOpcode.GET_LOCAL:case opcode_1.WasmOpcode.SET_LOCAL:case opcode_1.WasmOpcode.SET_GLOBAL:case opcode_1.WasmOpcode.BLOCK:case opcode_1.WasmOpcode.LOOP:case opcode_1.WasmOpcode.IF:case opcode_1.WasmOpcode.IF_ELSE:case opcode_1.WasmOpcode.BR:case opcode_1.WasmOpcode.BR_IF:case opcode_1.WasmOpcode.BR_TABLE:case opcode_1.WasmOpcode.NOP:return null;default:terminal_1.Terminal.warn("Unhandled Opcode "+opcode+" => "+opcode_1.WasmOpcode[opcode])}return null}Object.defineProperty(exports,"__esModule",{value:!0});var wasm_type_1=__webpack_require__(7),opcode_1=__webpack_require__(8),wasm_runtime_local_1=__webpack_require__(15),bytearray_1=__webpack_require__(12),terminal_1=__webpack_require__(1),clz32=Math.clz32||function(value){},WasmStackItem=function(){function WasmStackItem(type,value){this.type=type,this.value=value}return WasmStackItem}();exports.WasmStackItem=WasmStackItem;var WasmStack=function(){function WasmStack(){this.list=[]}return Object.defineProperty(WasmStack.prototype,"length",{get:function(){return this.list.length},enumerable:!0,configurable:!0}),WasmStack.prototype.push=function(item){this.list.push(item)},WasmStack.prototype.pop=function(silent){if(void 0===silent&&(silent=!1),0===this.list.length&&!silent){terminal_1.Terminal.warn("Stack is empty")}return this.list.pop()},WasmStack.prototype.clear=function(){this.list=[]},WasmStack}();exports.WasmStack=WasmStack;var WasmRuntimeFunction=function(){function WasmRuntimeFunction(){}return Object.defineProperty(WasmRuntimeFunction.prototype,"returnType",{get:function(){return this.signature.returnType.id},enumerable:!0,configurable:!0}),WasmRuntimeFunction.prototype.execute=function(){for(var param=[],_i=0;_i0&&this.context.fn.returnType===wasm_type_1.WasmType.VOID){var error="Function '"+this.context.fn.name+"' does not return anything but stack is not empty. Stack contains "+this.context.stack.length+" items";terminal_1.Terminal.error(error)}this.context=null},WasmStackTracer.prototype.callFunction=function(index){var fn=this.functions[index];if(void 0===fn)throw"Function not defined at index "+index;for(var returnType=fn.returnType,i=0;ib.value?1:0)),opcode_1.WasmOpcode[opcode];case opcode_1.WasmOpcode.I32_GE_S:case opcode_1.WasmOpcode.I32_GE_U:case opcode_1.WasmOpcode.I64_GE_S:case opcode_1.WasmOpcode.I64_GE_U:case opcode_1.WasmOpcode.F32_GE:case opcode_1.WasmOpcode.F64_GE:var a=this.context.stack.pop(),b=this.context.stack.pop();return this.context.stack.push(new WasmStackItem(type,a.value>=b.value?1:0)),opcode_1.WasmOpcode[opcode];case opcode_1.WasmOpcode.I32_LT_S:case opcode_1.WasmOpcode.I32_LT_U:case opcode_1.WasmOpcode.I64_LT_S:case opcode_1.WasmOpcode.I64_LT_U:case opcode_1.WasmOpcode.F32_LT:case opcode_1.WasmOpcode.F64_LT:var a=this.context.stack.pop(),b=this.context.stack.pop();return this.context.stack.push(new WasmStackItem(type,a.value "+opcode_1.WasmOpcode[opcode])}return null},WasmStackTracer}();exports.WasmStackTracer=WasmStackTracer},function(module,exports,__webpack_require__){"use strict";function wasmAssignLocalVariableOffsets(fn,node,shared,bitness){if(node.kind==node_1.NodeKind.VARIABLE){assert_1.assert(node.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL),shared.nextLocalOffset=shared.nextLocalOffset+1,shared.localCount=shared.localCount+1;var local=new wasm_local_1.WasmLocal;local.symbol=node.symbol,local.type=index_1.symbolToValueType(local.symbol,bitness),null==fn.firstLocal?fn.firstLocal=local:fn.lastLocal.next=local,fn.lastLocal=local,node.symbol.offset=fn.argumentEntries.length+fn.localVariables.length,fn.localVariables.push(new wasm_local_1.WasmLocalEntry(local.type,local.symbol.name))}for(var child=node.firstChild;null!=child;)wasmAssignLocalVariableOffsets(fn,child,shared,bitness),child=child.nextSibling}function wasmEmit(compiler,bitness){void 0===bitness&&(bitness=bitness_1.Bitness.x32);var module=new WasmModule(bitness);module.context=compiler.context,module.memoryInitializer=new bytearray_1.ByteArray,module.startFunctionIndex=-1,module.mallocFunctionIndex=-1,module.freeFunctionIndex=-1,module.currentHeapPointer=-1,module.originalHeapPointer=-1,module.prepareToEmit(compiler.global),module.assembler.sealFunctions(),compiler.outputWASM=new bytearray_1.ByteArray,module.emitModule(compiler.outputWASM),compiler.outputWAST=module.assembler.textOutput}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(3),bytearray_1=__webpack_require__(12),utils_1=__webpack_require__(6),node_1=__webpack_require__(5),opcode_1=__webpack_require__(8),builtins_helper_1=__webpack_require__(36),assert_1=__webpack_require__(0),wasm_type_1=__webpack_require__(7),logger_1=__webpack_require__(10),wasm_signature_1=__webpack_require__(43),bitness_1=__webpack_require__(13),wasm_section_1=__webpack_require__(14),wasm_external_kind_1=__webpack_require__(37),wasm_global_1=__webpack_require__(39),wasm_function_1=__webpack_require__(38),wasm_import_1=__webpack_require__(40),wasm_local_1=__webpack_require__(41),wasm_shared_offset_1=__webpack_require__(42),wasm_assembler_1=__webpack_require__(34),terminal_1=__webpack_require__(1),index_1=__webpack_require__(16),WasmModule=function(){function WasmModule(bitness){this.bitness=bitness,this.importCount=0,this.globalCount=0,this.functionCount=0,this.signatureCount=0,this.assembler=new wasm_assembler_1.WasmAssembler}return WasmModule.prototype.growMemoryInitializer=function(){for(var array=this.memoryInitializer,current=array.length,length=this.context.nextGlobalVariableOffset;current0&§ion.code.append(" (param");null!=type;)logger_1.log(section.data,array.position,type.id,wasm_type_1.WasmType[type.id]),this.assembler.writeUnsignedLEB128(section.data,type.id),section.code.append(" "+wasm_type_1.WasmTypeToString[type.id]),type=type.next;count>0&§ion.code.append(")");signature.returnType.id>0?(logger_1.log(section.data,array.position,"01","num results"),this.assembler.writeUnsignedLEB128(section.data,1),logger_1.log(section.data,array.position,signature.returnType.id,wasm_type_1.WasmType[signature.returnType.id]),this.assembler.writeUnsignedLEB128(section.data,signature.returnType.id),section.code.append(" (result "+wasm_type_1.WasmTypeToString[signature.returnType.id]+")")):this.assembler.writeUnsignedLEB128(section.data,0),section.code.append("))\n"),signature=signature.next}this.assembler.endSection(array,section)}},WasmModule.prototype.emitImportTable=function(array){if(this.firstImport){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Import,"import_table");logger_1.log(section.data,array.position,this.importCount,"num imports"),this.assembler.writeUnsignedLEB128(section.data,this.importCount);for(var current=this.firstImport,count=0;null!=current;)logger_1.log(section.data,array.position,null,"import func ("+count+") "+current.module+" "+current.name),this.assembler.currentSection.code.append('(import "'+current.module+'" "'+current.name+'" (func (;'+count+";) (type "+current.signatureIndex+")))\n"),this.assembler.writeWasmString(section.data,current.module),this.assembler.writeWasmString(section.data,current.name),this.assembler.writeUnsignedLEB128(section.data,wasm_external_kind_1.WasmExternalKind.Function),this.assembler.writeUnsignedLEB128(section.data,current.signatureIndex),current=current.next,count++;this.assembler.endSection(array,section)}},WasmModule.prototype.emitFunctionDeclarations=function(array){if(this.firstFunction){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Function,"function_declarations");logger_1.log(section.data,array.position,this.functionCount,"num functions"),this.assembler.writeUnsignedLEB128(section.data,this.functionCount);for(var fn=this.firstFunction,count=this.importCount;null!=fn;)logger_1.log(section.data,array.position,fn.signatureIndex,"func "+count+" sig "+index_1.getWasmFunctionName(fn.symbol)),this.assembler.writeUnsignedLEB128(section.data,fn.signatureIndex),fn=fn.next,count++;this.assembler.endSection(array,section)}},WasmModule.prototype.emitTables=function(array){},WasmModule.prototype.emitMemory=function(array){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Memory,"memory");logger_1.log(section.data,array.position,"01","num memories"),this.assembler.writeUnsignedLEB128(section.data,1),logger_1.log(section.data,array.position,"00","memory flags"),this.assembler.writeUnsignedLEB128(section.data,0),logger_1.log(section.data,array.position,1,"memory initial pages"),this.assembler.writeUnsignedLEB128(section.data,1),section.code.append("(memory (;0;) 1)\n"),this.assembler.endSection(array,section)},WasmModule.prototype.emitGlobalDeclarations=function(array){if(this.firstGlobal){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Global,"global");this.assembler.writeUnsignedLEB128(section.data,this.globalCount),this.assembler.stackTracer.setGlobals(this.globalEntries);for(var global=this.firstGlobal,count=0;global;){var dataType=index_1.typeToDataType(global.symbol.resolvedType,this.bitness),value=global.symbol.node.variableValue();section.data.append(wasm_type_1.WasmType[dataType]),this.assembler.writeUnsignedLEB128(section.data,1);var rawValue=0;switch(value&&(value.kind===node_1.NodeKind.NULL||value.kind===node_1.NodeKind.UNDEFINED?rawValue=0:void 0!==value.rawValue?rawValue=value.rawValue:this.addGlobalToStartFunction(global)),this.assembler.appendOpcode(section.data,array.position,opcode_1.WasmOpcode[dataType+"_CONST"],rawValue),dataType){case"I32":case"I64":this.assembler.writeUnsignedLEB128(section.data,rawValue);break;case"F32":this.assembler.writeFloat(section.data,rawValue);break;case"F64":this.assembler.writeDouble(section.data,rawValue)}var wasmTypeStr=wasm_type_1.WasmTypeToString[wasm_type_1.WasmType[dataType]];section.code.append("(global (;"+count+++";) (mut "+wasmTypeStr+") ("+wasmTypeStr+".const "+rawValue+"))\n"),this.assembler.appendOpcode(section.data,array.position,opcode_1.WasmOpcode.END),global=global.next}this.assembler.endSection(array,section)}},WasmModule.prototype.addGlobalToStartFunction=function(global){var value=global.symbol.node.variableValue(),startFn=this.startFunction;this.emitNode(startFn.body,0,value),this.assembler.appendOpcode(startFn.body,0,opcode_1.WasmOpcode.SET_GLOBAL),this.assembler.writeUnsignedLEB128(startFn.body,global.symbol.offset)},WasmModule.prototype.emitExportTable=function(array){for(var exportedCount=0,fn=this.firstFunction;null!=fn;)fn.isExported&&(exportedCount+=1),fn=fn.next;if(0!=exportedCount){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Export,"export_table");logger_1.log(section.data,array.position,exportedCount,"num exports"),this.assembler.writeUnsignedLEB128(section.data,exportedCount+1);logger_1.log(section.data,array.position,"memory".length,"export name length"),logger_1.log(section.data,null,null,utils_1.toHex(section.data.position+array.position+4)+": memory // export name"),this.assembler.writeWasmString(section.data,"memory"),logger_1.log(section.data,array.position,wasm_external_kind_1.WasmExternalKind.Function,"export kind"),this.assembler.writeUnsignedLEB128(section.data,wasm_external_kind_1.WasmExternalKind.Memory),logger_1.log(section.data,array.position,0,"export memory index"),this.assembler.writeUnsignedLEB128(section.data,0),section.code.append('(export "memory" (memory 0))\n');var i=this.importCount;for(fn=this.firstFunction;null!=fn;){if(fn.isExported){var fnName=index_1.getWasmFunctionName(fn.symbol);logger_1.log(section.data,array.position,fnName.length,"export name length"),logger_1.log(section.data,null,null,utils_1.toHex(section.data.position+array.position+4)+": "+fnName+" // export name"),this.assembler.writeWasmString(section.data,fnName),logger_1.log(section.data,array.position,wasm_external_kind_1.WasmExternalKind.Function,"export kind"),this.assembler.writeUnsignedLEB128(section.data,wasm_external_kind_1.WasmExternalKind.Function),logger_1.log(section.data,array.position,i,"export func index"),this.assembler.writeUnsignedLEB128(section.data,i),section.code.append('(export "'+fnName+'" (func $'+fnName+"))\n")}fn=fn.next,i+=1}this.assembler.endSection(array,section)}},WasmModule.prototype.emitStartFunctionDeclaration=function(array){if(-1!=this.startFunctionIndex){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Start,"start_function");logger_1.log(section.data,array.position,this.startFunctionIndex,"start function index"),section.code.append("(start "+(this.importCount+this.startFunctionIndex)+")\n"),this.assembler.writeUnsignedLEB128(section.data,this.importCount+this.startFunctionIndex),this.assembler.endSection(array,section)}},WasmModule.prototype.emitElements=function(array){},WasmModule.prototype.emitFunctionBodies=function(array){if(this.firstFunction){var offset=array.position,section=this.assembler.startSection(array,wasm_section_1.WasmSection.Code,"function_bodies");logger_1.log(section.data,offset,this.functionCount,"num functions"),this.assembler.writeUnsignedLEB128(section.data,this.functionCount);for(var count=0,fn=this.firstFunction,this_1=this;null!=fn;)!function(){this_1.currentFunction=fn;var sectionOffset=offset+section.data.position,wasmFunctionName=index_1.getWasmFunctionName(fn.symbol),bodyData=new bytearray_1.ByteArray;logger_1.log(bodyData,sectionOffset,fn.localCount?fn.localCount:0,"local var count"),this_1.assembler.stackTracer.startFunction(this_1.importCount+count),section.code.append("(func $"+wasmFunctionName+" (type "+fn.signatureIndex+")"),fn.argumentEntries.forEach(function(argumentEntry){section.code.append(" (param $"+argumentEntry.name+" "+wasm_type_1.WasmTypeToString[argumentEntry.type]+") ")}),fn.signature.returnType.id!==wasm_type_1.WasmType.VOID&§ion.code.append("(result "+wasm_type_1.WasmTypeToString[fn.signature.returnType.id]+")"),section.code.append("\n",1),fn.localVariables.length>0?(bodyData.writeUnsignedLEB128(fn.localVariables.length),fn.localVariables.forEach(function(localVariableEntry){logger_1.log(bodyData,sectionOffset,1,"local index"),bodyData.writeUnsignedLEB128(1),logger_1.log(bodyData,sectionOffset,localVariableEntry.type,wasm_type_1.WasmType[localVariableEntry.type]),bodyData.append(localVariableEntry.type),section.code.append("(local $"+localVariableEntry.name+" "+wasm_type_1.WasmTypeToString[localVariableEntry.type]+") ")}),section.code.append("\n")):bodyData.writeUnsignedLEB128(0);var lastChild=void 0;fn.isConstructor&&this_1.emitConstructor(bodyData,sectionOffset,fn);for(var child=fn.symbol.node.functionBody().firstChild;null!=child;)lastChild=child,this_1.emitNode(bodyData,sectionOffset,child),child=child.nextSibling;fn.body?bodyData.copy(fn.body):lastChild&&lastChild.kind!==node_1.NodeKind.RETURN&&fn.returnType!=wasm_type_1.WasmType.VOID&&this_1.assembler.appendOpcode(bodyData,sectionOffset,opcode_1.WasmOpcode.RETURN),fn.returnType===wasm_type_1.WasmType.VOID&&this_1.assembler.dropStack(bodyData),this_1.assembler.appendOpcode(bodyData,sectionOffset,opcode_1.WasmOpcode.END,null,!0),this_1.assembler.stackTracer.endFunction(),section.data.writeUnsignedLEB128(bodyData.length),logger_1.log(section.data,offset,null," - func body "+(this_1.importCount+count++)+" ("+wasmFunctionName+")"),logger_1.log(section.data,offset,bodyData.length,"func body size"),section.data.log+=bodyData.log,section.data.copy(bodyData),section.code.indent-=1,section.code.removeLastLinebreak(),section.code.append(")\n"),fn=fn.next}();this.assembler.endSection(array,section)}},WasmModule.prototype.emitDataSegments=function(array){this.growMemoryInitializer();var memoryInitializer=this.memoryInitializer,initializerLength=memoryInitializer.length,initialHeapPointer=utils_1.alignToNextMultipleOf(8+initializerLength,8);memoryInitializer.writeUnsignedInt(initialHeapPointer,this.originalHeapPointer),memoryInitializer.writeUnsignedInt(initialHeapPointer,this.currentHeapPointer);var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Data,"data_segments");logger_1.log(section.data,array.position,1,"num data segments"),this.assembler.writeUnsignedLEB128(section.data,1),logger_1.log(section.data,array.position,null," - data segment header 0"),logger_1.log(section.data,array.position,0,"memory index"),this.assembler.writeUnsignedLEB128(section.data,0),this.assembler.appendOpcode(section.data,array.position,opcode_1.WasmOpcode.I32_CONST),logger_1.log(section.data,array.position,8,"i32 literal"),this.assembler.writeUnsignedLEB128(section.data,8),this.assembler.appendOpcode(section.data,array.position,opcode_1.WasmOpcode.END),logger_1.log(section.data,array.position,initializerLength,"data segment size"),this.assembler.writeUnsignedLEB128(section.data,initializerLength),logger_1.log(section.data,array.position,null," - data segment data 0"),section.code.append('(data (i32.const 8) " ');for(var value,i=0;i0);var lengthNode=node.arrayLength();if(lengthNode.kind==node_1.NodeKind.INT32){var length_2=size*lengthNode.intValue;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,length_2),this.assembler.writeLEB128(array,length_2)}else this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(array,size),this.emitNode(array,byteOffset,lengthNode),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_MUL);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(array,size);var callIndex=this.getWasmFunctionCallIndex(callSymbol);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.CALL),logger_1.log(array,byteOffset,callIndex,"call func index ("+callIndex+")"),this.assembler.writeUnsignedLEB128(array,callIndex)}else if(type.resolvedType.isTypedArray());else{for(var child=node.firstChild.nextSibling;null!=child;)this.emitNode(array,byteOffset,child),child=child.nextSibling;var callIndex=this.getWasmFunctionCallIndex(callSymbol);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.CALL,callIndex),this.assembler.writeUnsignedLEB128(array,callIndex)}},WasmModule.prototype.emitConstructor=function(array,byteOffset,fn){var constructorNode=fn.symbol.node,type=constructorNode.parent.symbol,size=type.resolvedType.allocationSizeOf(this.context);if(assert_1.assert(size>0),type.resolvedType.isArray())this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.GET_LOCAL,0),this.assembler.writeUnsignedLEB128(array,0),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(array,size),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_ADD);else if(type.resolvedType.isTypedArray()){var elementSize=index_1.getTypedArrayElementSize(type.resolvedType.symbol.name);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.GET_LOCAL,0),this.assembler.writeUnsignedLEB128(array,0),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,elementSize),this.assembler.writeLEB128(array,elementSize),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_SHL),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(array,size),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_ADD)}else this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(array,size);var mallocIndex=this.calculateWasmFunctionIndex(this.mallocFunctionIndex);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.CALL,mallocIndex),this.assembler.writeUnsignedLEB128(array,mallocIndex),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,fn.signature.argumentCount),this.assembler.writeUnsignedLEB128(array,fn.signature.argumentCount)},WasmModule.prototype.emitNode=function(array,byteOffset,node){if(assert_1.assert(!node_1.isExpression(node)||null!=node.resolvedType),node.kind==node_1.NodeKind.BLOCK){var skipBlock=node.parent.kind===node_1.NodeKind.IF;skipBlock||(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.BLOCK),void 0!==node.returnNode?(logger_1.log(array,byteOffset,this.currentFunction.returnType,wasm_type_1.WasmType[this.currentFunction.returnType]),array.append(this.currentFunction.returnType),this.assembler.currentSection.code.removeLastLinebreak(),this.assembler.currentSection.code.append(" (result "+wasm_type_1.WasmTypeToString[this.currentFunction.returnType]+")\n",1)):(logger_1.log(array,byteOffset,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]),array.append(wasm_type_1.WasmType.block_type)));for(var child=node.firstChild;null!=child;)this.emitNode(array,byteOffset,child),child=child.nextSibling;skipBlock||(this.assembler.currentSection.code.clearIndent(1),this.assembler.currentSection.code.indent-=1,this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.END))}else if(node.kind==node_1.NodeKind.WHILE){var value=node.whileValue(),body=node.whileBody();if(value.kind==node_1.NodeKind.BOOLEAN&&0==value.intValue)return 0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.BLOCK),logger_1.log(array,0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]),array.append(wasm_type_1.WasmType.block_type),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.LOOP),logger_1.log(array,0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]),array.append(wasm_type_1.WasmType.block_type),value.kind!=node_1.NodeKind.BOOLEAN&&(this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_EQZ),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.BR_IF),this.assembler.writeUnsignedLEB128(array,1));for(var child=body.firstChild;null!=child;)this.emitNode(array,byteOffset,child),child=child.nextSibling;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.BR),this.assembler.writeUnsignedLEB128(array,0),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.END),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.BREAK||node.kind==node_1.NodeKind.CONTINUE){for(var label=0,parent_1=node.parent;null!=parent_1&&parent_1.kind!=node_1.NodeKind.WHILE;)parent_1.kind==node_1.NodeKind.BLOCK&&(label+=1),parent_1=parent_1.parent;assert_1.assert(label>0),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.BR),this.assembler.writeUnsignedLEB128(array,label-(node.kind==node_1.NodeKind.BREAK?0:1))}else{if(node.kind==node_1.NodeKind.EMPTY)return 0;if(node.kind==node_1.NodeKind.EXPRESSION)this.emitNode(array,byteOffset,node.expressionValue());else if(node.kind==node_1.NodeKind.RETURN){var value=node.returnValue();null!=value&&this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.RETURN)}else{if(node.kind==node_1.NodeKind.VARIABLES){for(var count=0,child=node.firstChild;null!=child;)assert_1.assert(child.kind==node_1.NodeKind.VARIABLE),count+=this.emitNode(array,byteOffset,child),child=child.nextSibling;return count}if(node.kind==node_1.NodeKind.IF){var branch=node.ifFalse();this.emitNode(array,byteOffset,node.ifValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.IF);var returnNode=node.ifReturnNode(),needEmptyElse=!1;if(null==returnNode&&null===branch)wasm_assembler_1.append(array,0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]);else if(null!==returnNode){var returnType=index_1.symbolToValueType(returnNode.resolvedType.symbol);wasm_assembler_1.append(array,0,returnType,wasm_type_1.WasmType[returnType]),this.assembler.currentSection.code.removeLastLinebreak(),this.assembler.currentSection.code.append(" (result "+wasm_type_1.WasmTypeToString[returnType]+")\n"),null==branch&&(needEmptyElse=!0)}else wasm_assembler_1.append(array,0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]);if(this.emitNode(array,byteOffset,node.ifTrue()),null!=branch)this.assembler.currentSection.code.indent-=1,this.assembler.currentSection.code.clearIndent(1),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.IF_ELSE),this.emitNode(array,byteOffset,branch);else if(needEmptyElse){this.assembler.currentSection.code.indent-=1,this.assembler.currentSection.code.clearIndent(1),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.IF_ELSE);var dataType=index_1.typeToDataType(returnNode.resolvedType,this.bitness);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode[dataType+"_CONST"]),"I32"===dataType||"I64"===dataType?this.assembler.writeUnsignedLEB128(array,0):"F32"===dataType?this.assembler.writeFloat(array,0):"F64"===dataType&&this.assembler.writeDouble(array,0)}this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.HOOK){this.emitNode(array,byteOffset,node.hookValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.IF);var trueValue=node.hookTrue(),trueValueType=index_1.symbolToValueType(trueValue.resolvedType.symbol);wasm_assembler_1.append(array,0,trueValueType,wasm_type_1.WasmType[trueValueType]),this.emitNode(array,byteOffset,trueValue),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.IF_ELSE),this.emitNode(array,byteOffset,node.hookFalse()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.VARIABLE){var value=node.variableValue();if("this"==node.symbol.name&&"constructor"==this.currentFunction.symbol.name);else if(node.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL){value&&value.kind!=node_1.NodeKind.NAME&&value.kind!=node_1.NodeKind.CALL&&value.kind!=node_1.NodeKind.NEW&&value.kind!=node_1.NodeKind.DOT&&value.rawValue?node.symbol.resolvedType.isFloat()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,value.floatValue),this.assembler.writeFloat(array,value.floatValue)):node.symbol.resolvedType.isDouble()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,value.doubleValue),this.assembler.writeDouble(array,value.doubleValue)):node.symbol.resolvedType.isLong()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,value.longValue),this.assembler.writeLEB128(array,value.longValue)):(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,value.intValue),this.assembler.writeLEB128(array,value.intValue)):null!=value?this.emitNode(array,byteOffset,value):node.symbol.resolvedType.isFloat()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,0),this.assembler.writeFloat(array,0)):node.symbol.resolvedType.isDouble()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,0),this.assembler.writeDouble(array,0)):node.symbol.resolvedType.isLong()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(array,0)):(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(array,0));var skipSetLocal=value&&node_1.isUnaryPostfix(value.kind);0==skipSetLocal&&(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,node.symbol.offset),this.assembler.writeUnsignedLEB128(array,node.symbol.offset))}else assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.NAME){var symbol=node.symbol;symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT||symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL?"this"===symbol.name&&"constructor"===this.currentFunction.symbol.name?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.GET_LOCAL,this.currentFunction.signature.argumentCount),this.assembler.writeUnsignedLEB128(array,this.currentFunction.signature.argumentCount)):(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.GET_LOCAL,symbol.offset),this.assembler.writeUnsignedLEB128(array,symbol.offset)):symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.GET_GLOBAL,symbol.offset),this.assembler.writeUnsignedLEB128(array,symbol.offset)):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.DEREFERENCE)this.emitLoadFromMemory(array,byteOffset,node.resolvedType.underlyingType(this.context),node.unaryValue(),0);else if(node.kind==node_1.NodeKind.POINTER_INDEX)this.emitLoadFromMemory(array,byteOffset,node.resolvedType.underlyingType(this.context),node.pointer(),node.pointerOffset());else if(node.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(array,0);else if(node.kind==node_1.NodeKind.INT32||node.kind==node_1.NodeKind.BOOLEAN)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,node.intValue),this.assembler.writeLEB128(array,node.intValue||0);else if(node.kind==node_1.NodeKind.INT64)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,node.longValue),this.assembler.writeLEB128(array,node.longValue);else if(node.kind==node_1.NodeKind.FLOAT32)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,node.floatValue),this.assembler.writeFloat(array,node.floatValue);else if(node.kind==node_1.NodeKind.FLOAT64)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,node.doubleValue),this.assembler.writeDouble(array,node.doubleValue);else if(node.kind==node_1.NodeKind.STRING){var value=8+node.intValue;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,value),this.assembler.writeLEB128(array,value)}else if(node.kind==node_1.NodeKind.CALL){var value=node.callValue(),symbol=value.symbol;if(assert_1.assert(symbol_1.isFunction(symbol.kind)),!symbol.node.isExternalImport()&&symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var dotTarget=value.dotTarget();this.emitNode(array,byteOffset,dotTarget),dotTarget.kind==node_1.NodeKind.NEW&&this.emitInstance(array,byteOffset,dotTarget)}for(var child=value.nextSibling;null!=child;)this.emitNode(array,byteOffset,child),child=child.nextSibling;var wasmFunctionName=index_1.getWasmFunctionName(symbol);if(builtins_helper_1.isBuiltin(wasmFunctionName))this.assembler.appendOpcode(array,byteOffset,builtins_helper_1.getBuiltinOpcode(symbol.name));else{var callIndex=this.getWasmFunctionCallIndex(symbol);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.CALL,callIndex),this.assembler.writeUnsignedLEB128(array,callIndex)}}else if(node.kind==node_1.NodeKind.NEW)this.emitInstance(array,byteOffset,node);else if(node.kind==node_1.NodeKind.DELETE){var value=node.deleteValue();this.emitNode(array,byteOffset,value);var freeIndex=this.calculateWasmFunctionIndex(this.freeFunctionIndex);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.CALL,freeIndex),this.assembler.writeUnsignedLEB128(array,freeIndex)}else if(node.kind==node_1.NodeKind.POSITIVE)this.emitNode(array,byteOffset,node.unaryValue());else if(node.kind==node_1.NodeKind.NEGATIVE){var resolvedType=node.unaryValue().resolvedType;resolvedType.isFloat()?(this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_NEG)):resolvedType.isDouble()?(this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_NEG)):resolvedType.isInteger()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(array,0),this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_SUB)):resolvedType.isLong()&&(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(array,0),this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_SUB))}else if(node.kind==node_1.NodeKind.COMPLEMENT)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,-1),this.assembler.writeLEB128(array,-1),this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_XOR);else if(node.kind==node_1.NodeKind.NOT)this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_EQZ);else if(node.kind==node_1.NodeKind.CAST){var value=node.castValue(),context=this.context,from=value.resolvedType.underlyingType(context),type=node.resolvedType.underlyingType(context);from.variableSizeOf(context),type.variableSizeOf(context);if(from!=context.nullType&&from!=context.booleanType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.int64Type&&type!=context.uint64Type)if(from!=context.nullType&&from!=context.booleanType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.float32Type)if(from!=context.nullType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.float64Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.int32Type&&type!=context.uint32Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.float32Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.float64Type)if(from!=context.float32Type||type!=context.uint8Type&&type!=context.int8Type&&type!=context.uint16Type&&type!=context.int16Type&&type!=context.uint32Type&&type!=context.int32Type)if(from!=context.float32Type||type!=context.int64Type&&type!=context.uint64Type)if(from==context.float32Type&&type==context.float64Type)if(value.kind==node_1.NodeKind.FLOAT32){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(array,doubleValue)}else this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_PROMOTE_F32);else if(from!=context.float64Type||type!=context.uint8Type&&type!=context.int8Type&&type!=context.uint16Type&&type!=context.int16Type&&type!=context.uint32Type&&type!=context.int32Type)if(from!=context.float64Type||type!=context.int64Type&&type!=context.uint64Type)if(from==context.float64Type&&type==context.float32Type)if(value.kind==node_1.NodeKind.FLOAT64){var floatValue=value.floatValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(array,floatValue)}else this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_DEMOTE_F64);else this.emitNode(array,byteOffset,value);else if(value.kind==node_1.NodeKind.FLOAT64){var longValue=value.longValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,longValue),this.assembler.writeLEB128(array,longValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_TRUNC_U_F64:opcode_1.WasmOpcode.I64_TRUNC_S_F64)}else if(value.kind==node_1.NodeKind.FLOAT64){var intValue=value.intValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(array,intValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.I32_TRUNC_U_F64:opcode_1.WasmOpcode.I32_TRUNC_S_F64)}else if(value.kind==node_1.NodeKind.FLOAT32){var longValue=value.longValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,longValue),this.assembler.writeLEB128(array,longValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_TRUNC_U_F32:opcode_1.WasmOpcode.I64_TRUNC_S_F32)}else if(value.kind==node_1.NodeKind.FLOAT32){var intValue=value.intValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(array,intValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.I32_TRUNC_U_F32:opcode_1.WasmOpcode.I32_TRUNC_S_F32)}else if(value.kind==node_1.NodeKind.INT64){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(array,doubleValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.F64_CONVERT_U_I64:opcode_1.WasmOpcode.F64_CONVERT_S_I64)}else if(value.kind==node_1.NodeKind.INT32){var floatValue=value.floatValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(array,floatValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.F32_CONVERT_U_I64:opcode_1.WasmOpcode.F32_CONVERT_S_I64)}else if(value.kind==node_1.NodeKind.INT64){var intValue=value.intValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(array,intValue)}else this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_WRAP_I64);else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,0),this.assembler.writeDouble(array,0);else if(value.kind==node_1.NodeKind.BOOLEAN){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(array,doubleValue)}else if(value.kind==node_1.NodeKind.INT32){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(array,doubleValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.F64_CONVERT_U_I32:opcode_1.WasmOpcode.F64_CONVERT_S_I32)}else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,0),this.assembler.writeFloat(array,0);else if(value.kind==node_1.NodeKind.BOOLEAN){var floatValue=value.intValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(array,floatValue)}else if(value.kind==node_1.NodeKind.INT32){var floatValue=value.floatValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(array,floatValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.F32_CONVERT_U_I32:opcode_1.WasmOpcode.F32_CONVERT_S_I32)}else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(array,0);else if(value.kind==node_1.NodeKind.BOOLEAN){var intValue=value.intValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,intValue),this.assembler.writeLEB128(array,intValue)}else if(value.kind==node_1.NodeKind.INT32)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,value.longValue),this.assembler.writeLEB128(array,value.longValue);else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_EXTEND_U_I32:opcode_1.WasmOpcode.I64_EXTEND_S_I32)}}else if(node.kind==node_1.NodeKind.DOT){var symbol=node.symbol;symbol.kind==symbol_1.SymbolKind.VARIABLE_INSTANCE?this.emitLoadFromMemory(array,byteOffset,symbol.resolvedType,node.dotTarget(),symbol.offset):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.ASSIGN){var left=node.binaryLeft(),right=node.binaryRight(),symbol=left.symbol;left.kind==node_1.NodeKind.DEREFERENCE?this.emitStoreToMemory(array,byteOffset,left.resolvedType.underlyingType(this.context),left.unaryValue(),0,right):left.kind==node_1.NodeKind.POINTER_INDEX?this.emitStoreToMemory(array,byteOffset,left.resolvedType.underlyingType(this.context),left.pointer(),left.pointerOffset(),right):symbol.kind==symbol_1.SymbolKind.VARIABLE_INSTANCE?this.emitStoreToMemory(array,byteOffset,symbol.resolvedType,left.dotTarget(),symbol.offset,right):symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.emitNode(array,byteOffset,right),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_GLOBAL),this.assembler.writeUnsignedLEB128(array,symbol.offset)):symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT||symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL?(this.emitNode(array,byteOffset,right),node_1.isUnaryPostfix(right.kind)||(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,symbol.offset),this.assembler.writeUnsignedLEB128(array,symbol.offset))):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.LOGICAL_AND)this.emitNode(array,byteOffset,node.binaryLeft()),this.emitNode(array,byteOffset,node.binaryRight()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_AND),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(array,1),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_EQ);else if(node.kind==node_1.NodeKind.LOGICAL_OR)this.emitNode(array,byteOffset,node.binaryLeft()),this.emitNode(array,byteOffset,node.binaryRight()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_OR),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST),logger_1.log(array,byteOffset,1,"i32 literal"),this.assembler.writeLEB128(array,1),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_EQ);else if(node_1.isUnary(node.kind)){var kind=node.kind;if(kind==node_1.NodeKind.POSTFIX_INCREMENT||kind==node_1.NodeKind.POSTFIX_DECREMENT){var value=node.unaryValue(),dataType=index_1.typeToDataType(value.resolvedType,this.bitness);if(node.parent.kind==node_1.NodeKind.VARIABLE)this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,node.parent.symbol.offset),this.assembler.writeUnsignedLEB128(array,node.parent.symbol.offset);else if(node.parent.kind==node_1.NodeKind.ASSIGN){this.emitNode(array,byteOffset,value);var left=node.parent.binaryLeft();this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,left.symbol.offset),this.assembler.writeUnsignedLEB128(array,left.symbol.offset)}if(this.emitNode(array,byteOffset,value),node.parent.kind!=node_1.NodeKind.RETURN){assert_1.assert(value.resolvedType.isInteger()||value.resolvedType.isLong()||value.resolvedType.isFloat()||value.resolvedType.isDouble());var size=value.resolvedType.pointerTo?value.resolvedType.pointerTo.allocationSizeOf(this.context):value.resolvedType.allocationSizeOf(this.context);1==size||2==size?value.kind==node_1.NodeKind.INT32||value.resolvedType.isInteger()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(array,1)):terminal_1.Terminal.error("Wrong type"):4==size?value.kind==node_1.NodeKind.INT32||value.resolvedType.isInteger()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(array,1)):value.kind==node_1.NodeKind.FLOAT32||value.resolvedType.isFloat()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,1),this.assembler.writeFloat(array,1)):terminal_1.Terminal.error("Wrong type"):8==size&&(value.kind==node_1.NodeKind.INT64||value.resolvedType.isLong()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,1),this.assembler.writeLEB128(array,1)):value.kind==node_1.NodeKind.FLOAT64||value.resolvedType.isDouble()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,1),this.assembler.writeDouble(array,1)):terminal_1.Terminal.error("Wrong type"));var operation=kind==node_1.NodeKind.POSTFIX_INCREMENT?"ADD":"SUB";this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode[dataType+"_"+operation]),value.symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_GLOBAL,value.symbol.offset),this.assembler.writeLEB128(array,value.symbol.offset)):value.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL||value.symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,value.symbol.offset),this.assembler.writeLEB128(array,value.symbol.offset)):(value.symbol.kind,symbol_1.SymbolKind.VARIABLE_INSTANCE)}}}else{var isUnsigned=node.isUnsignedOperator(),left=node.binaryLeft(),right=node.binaryRight(),isFloat=left.resolvedType.isFloat()||right.resolvedType.isFloat(),isDouble=left.resolvedType.isDouble()||right.resolvedType.isDouble(),dataTypeLeft=index_1.typeToDataType(left.resolvedType,this.bitness);index_1.typeToDataType(right.resolvedType,this.bitness);if(node.kind==node_1.NodeKind.ADD){if(this.emitNode(array,byteOffset,left),null==left.resolvedType.pointerTo)this.emitNode(array,byteOffset,right);else{assert_1.assert(right.resolvedType.isInteger()||right.resolvedType.isLong()||right.resolvedType.isFloat()||right.resolvedType.isDouble());var size=left.resolvedType.pointerTo.allocationSizeOf(this.context);if(2==size)if(right.kind==node_1.NodeKind.INT32){var _value=right.intValue<<1;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,_value),this.assembler.writeLEB128(array,_value)}else this.emitNode(array,byteOffset,right),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(array,1),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_SHL);else if(4==size)if(right.kind==node_1.NodeKind.INT32){var _value=right.intValue<<2;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,_value),this.assembler.writeLEB128(array,_value)}else right.kind==node_1.NodeKind.FLOAT32?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,right.floatValue),this.assembler.writeFloat(array,right.floatValue)):(this.emitNode(array,byteOffset,right),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,2),this.assembler.writeLEB128(array,2),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_SHL));else 8==size?right.kind==node_1.NodeKind.INT64?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,right.longValue),this.assembler.writeLEB128(array,right.longValue)):right.kind==node_1.NodeKind.FLOAT64&&(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,right.doubleValue),this.assembler.writeDouble(array,right.doubleValue)):this.emitNode(array,byteOffset,right)}this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode[dataTypeLeft+"_ADD"])}else if(node.kind==node_1.NodeKind.BITWISE_AND){if(isFloat||isDouble)throw"Cannot do bitwise operations on floating point number";this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_AND"])}else if(node.kind==node_1.NodeKind.BITWISE_OR){if(isFloat||isDouble)throw"Cannot do bitwise operations on floating point number";this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_OR"])}else if(node.kind==node_1.NodeKind.BITWISE_XOR)this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_XOR"]);else if(node.kind==node_1.NodeKind.EQUAL)this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_EQ"]);else if(node.kind==node_1.NodeKind.MULTIPLY)this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_MUL"]);else if(node.kind==node_1.NodeKind.NOT_EQUAL)this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_NE"]);else if(node.kind==node_1.NodeKind.SHIFT_LEFT){if(isFloat||isDouble)throw"Cannot do bitwise operations on floating point number";this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_SHL"])}else if(node.kind==node_1.NodeKind.SUBTRACT)this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_SUB"]);else if(node.kind==node_1.NodeKind.DIVIDE){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_DIV"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_DIV_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_DIV_S"];this.emitBinaryExpression(array,byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.GREATER_THAN){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_GT"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_GT_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_GT_S"];this.emitBinaryExpression(array,byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.GREATER_THAN_EQUAL){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_GE"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_GE_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_GE_S"];this.emitBinaryExpression(array,byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.LESS_THAN){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_LT"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_LT_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_LT_S"];this.emitBinaryExpression(array,byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.LESS_THAN_EQUAL){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_LE"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_LE_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_LE_S"];this.emitBinaryExpression(array,byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.REMAINDER){if(isFloat||isDouble)throw"Floating point remainder is not yet supported in WebAssembly. Please import javascript function to handle this";this.emitBinaryExpression(array,byteOffset,node,isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_REM_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_REM_S"])}else if(node.kind==node_1.NodeKind.SHIFT_RIGHT){if(isFloat||isDouble)throw"Cannot do bitwise operations on floating point number";this.emitBinaryExpression(array,byteOffset,node,isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_SHR_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_SHR_S"])}else assert_1.assert(!1)}}}return 1},WasmModule.prototype.calculateWasmFunctionIndex=function(index){return this.importCount+index},WasmModule.prototype.getWasmFunctionCallIndex=function(symbol){return symbol.node.isExternalImport()?symbol.offset:this.importCount+symbol.offset},WasmModule.prototype.getWasmType=function(type){var context=this.context;return type==context.booleanType||type.isClass()||type.isInteger()||this.bitness==bitness_1.Bitness.x32&&type.isReference()?wasm_type_1.WasmType.I32:type.isLong()||this.bitness==bitness_1.Bitness.x64&&type.isReference()?wasm_type_1.WasmType.I64:type.isDouble()?wasm_type_1.WasmType.F64:type.isFloat()?wasm_type_1.WasmType.F32:type==context.voidType?wasm_type_1.WasmType.VOID:(assert_1.assert(!1),wasm_type_1.WasmType.VOID)},WasmModule}();exports.wasmEmit=wasmEmit},function(module,exports,__webpack_require__){"use strict";function addScopeToSymbol(symbol,parentScope){var scope=new scope_1.Scope;scope.parent=parentScope,scope.symbol=symbol,symbol.scope=scope}function linkSymbolToNode(symbol,node){node.symbol=symbol,node.scope=symbol.scope,symbol.range=null!=node.internalRange?node.internalRange:node.range,symbol.node=node}function initialize(context,node,parentScope,mode){var kind=node.kind;if(null!=node.parent){var parentKind=node.parent.kind;kind==node_1.NodeKind.IMPORTS||kind==node_1.NodeKind.VARIABLE||kind==node_1.NodeKind.VARIABLES||kind==node_1.NodeKind.FUNCTION&&parentKind==node_1.NodeKind.CLASS||(parentKind==node_1.NodeKind.FILE||parentKind==node_1.NodeKind.GLOBAL)==(parentKind==node_1.NodeKind.MODULE||kind==node_1.NodeKind.MODULE||kind==node_1.NodeKind.CLASS||kind==node_1.NodeKind.ENUM||kind==node_1.NodeKind.FUNCTION||kind==node_1.NodeKind.CONSTANTS)||context.log.error(node.range,"This statement is not allowed here")}if(kind==node_1.NodeKind.MODULE){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;symbol.kind=symbol_1.SymbolKind.TYPE_MODULE,symbol.name=node.stringValue,symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.flags=symbol_1.SYMBOL_FLAG_IS_REFERENCE,addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL),parentScope=symbol.scope}if(kind==node_1.NodeKind.CLASS||kind==node_1.NodeKind.ENUM){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;if(symbol.kind=kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.TYPE_CLASS:symbol_1.SymbolKind.TYPE_ENUM,symbol.name=node.stringValue,symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.flags=symbol_1.SYMBOL_FLAG_IS_REFERENCE,addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL),parentScope=symbol.scope,node.parameterCount()>0){symbol.kind=symbol_1.SymbolKind.TYPE_TEMPLATE,symbol.flags|=symbol_1.SYMBOL_FLAG_IS_TEMPLATE;var genericType=node.firstGenericType(),genericSymbol=new symbol_1.Symbol;genericSymbol.kind=symbol_1.SymbolKind.TYPE_GENERIC,genericSymbol.name=genericType.stringValue,genericSymbol.resolvedType=new type_1.Type,genericSymbol.resolvedType.symbol=genericSymbol,genericSymbol.flags=symbol_1.SYMBOL_FLAG_IS_GENERIC,genericType.flags=node_1.NODE_FLAG_GENERIC,addScopeToSymbol(genericSymbol,parentScope),linkSymbolToNode(genericSymbol,genericType),parentScope.define(context.log,genericSymbol,scope_1.ScopeHint.NORMAL)}}else if(kind==node_1.NodeKind.FUNCTION){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;if(symbol.kind=node.parent.kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.FUNCTION_INSTANCE:symbol_1.SymbolKind.FUNCTION_GLOBAL,symbol.name=node.stringValue,node.isOperator()&&("+"==symbol.name||"-"==symbol.name?node.functionFirstArgument()==node.functionReturnType()?(symbol.flags=symbol_1.SYMBOL_FLAG_IS_UNARY_OPERATOR,symbol.rename="+"==symbol.name?"op_positive":"op_negative"):(symbol.flags=symbol_1.SYMBOL_FLAG_IS_BINARY_OPERATOR,symbol.rename="+"==symbol.name?"op_add":"op_subtract"):symbol.rename="%"==symbol.name?"op_remainder":"&"==symbol.name?"op_and":"*"==symbol.name?"op_multiply":"**"==symbol.name?"op_exponent":"++"==symbol.name?"op_increment":"--"==symbol.name?"op_decrement":"/"==symbol.name?"op_divide":"<"==symbol.name?"op_lessThan":"<<"==symbol.name?"op_shiftLeft":"=="==symbol.name?"op_equals":">"==symbol.name?"op_greaterThan":">>"==symbol.name?"op_shiftRight":"[]"==symbol.name?"op_get":"[]="==symbol.name?"op_set":"^"==symbol.name?"op_xor":"|"==symbol.name?"op_or":"~"==symbol.name?"op_complement":null),"constructor"==symbol.name&&(symbol.rename="_ctr"),addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,symbol.isSetter()?scope_1.ScopeHint.NOT_GETTER:symbol.isGetter()?scope_1.ScopeHint.NOT_SETTER:symbol.isBinaryOperator()?scope_1.ScopeHint.NOT_UNARY:symbol.isUnaryOperator()?scope_1.ScopeHint.NOT_BINARY:scope_1.ScopeHint.NORMAL),parentScope=symbol.scope,symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var parent_1=symbol.parent();if(initializeSymbol(context,parent_1),"constructor"==symbol.name){var body=node.functionBody();if(null!==body){var variablesNode=body.firstChild;if(variablesNode.kind!==node_1.NodeKind.VARIABLES){var _variablesNode=node_1.createVariables();body.insertChildBefore(variablesNode,_variablesNode),variablesNode=_variablesNode}var firstVariable=variablesNode.firstChild;void 0!==firstVariable?"this"!==firstVariable.stringValue?variablesNode.insertChildBefore(firstVariable,node_1.createVariable("this",node_1.createType(parent_1.resolvedType),null)):"this"===firstVariable.stringValue&&void 0===firstVariable.firstChild.resolvedType&&(firstVariable.firstChild.resolvedType=parent_1.resolvedType):variablesNode.appendChild(node_1.createVariable("this",node_1.createType(parent_1.resolvedType),null));var returnNode=node_1.createReturn(node_1.createName("this"));node.lastChild.lastChild&&node.lastChild.lastChild.kind==node_1.NodeKind.RETURN&&node.lastChild.lastChild.remove(),node.lastChild.appendChild(returnNode)}}else{var firstArgument=node.functionFirstArgument();"this"!==firstArgument.stringValue?node.insertChildBefore(firstArgument,node_1.createVariable("this",node_1.createType(parent_1.resolvedType),null)):"this"===firstArgument.stringValue&&void 0===firstArgument.firstChild.resolvedType&&(firstArgument.firstChild.resolvedType=parent_1.resolvedType)}}}else if(kind==node_1.NodeKind.VARIABLE){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;symbol.kind=node.parent.kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.VARIABLE_INSTANCE:node.parent.kind==node_1.NodeKind.FUNCTION?symbol_1.SymbolKind.VARIABLE_ARGUMENT:node.parent.kind==node_1.NodeKind.CONSTANTS||node.parent.kind==node_1.NodeKind.ENUM?symbol_1.SymbolKind.VARIABLE_CONSTANT:node.parent.kind==node_1.NodeKind.VARIABLES&&node.parent.parent.kind==node_1.NodeKind.FILE?symbol_1.SymbolKind.VARIABLE_GLOBAL:symbol_1.SymbolKind.VARIABLE_LOCAL,symbol.name=node.stringValue,symbol.scope=parentScope,linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL)}else if(kind==node_1.NodeKind.BLOCK){if(node.parent.kind!=node_1.NodeKind.FUNCTION){var scope=new scope_1.Scope;scope.parent=parentScope,parentScope=scope}node.scope=parentScope}for(var child=node.firstChild;null!=child;)mode==CheckMode.INITIALIZE&&(child.flags|=node_1.NODE_FLAG_LIBRARY),initialize(context,child,parentScope,mode),child=child.nextSibling;kind==node_1.NodeKind.FILE&&mode==CheckMode.INITIALIZE&&(context.booleanType=parentScope.findLocal("boolean",scope_1.ScopeHint.NORMAL).resolvedType,context.uint8Type=parentScope.findLocal("uint8",scope_1.ScopeHint.NORMAL).resolvedType,context.int32Type=parentScope.findLocal("int32",scope_1.ScopeHint.NORMAL).resolvedType,context.int64Type=parentScope.findLocal("int64",scope_1.ScopeHint.NORMAL).resolvedType,context.int8Type=parentScope.findLocal("int8",scope_1.ScopeHint.NORMAL).resolvedType,context.int16Type=parentScope.findLocal("int16",scope_1.ScopeHint.NORMAL).resolvedType,context.stringType=parentScope.findLocal("string",scope_1.ScopeHint.NORMAL).resolvedType,context.uint32Type=parentScope.findLocal("uint32",scope_1.ScopeHint.NORMAL).resolvedType,context.uint64Type=parentScope.findLocal("uint64",scope_1.ScopeHint.NORMAL).resolvedType,context.uint16Type=parentScope.findLocal("uint16",scope_1.ScopeHint.NORMAL).resolvedType,context.float32Type=parentScope.findLocal("float32",scope_1.ScopeHint.NORMAL).resolvedType,context.float64Type=parentScope.findLocal("float64",scope_1.ScopeHint.NORMAL).resolvedType,prepareNativeType(context.booleanType,1,0),prepareNativeType(context.uint8Type,1,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.int8Type,1,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.int16Type,2,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.uint16Type,2,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.int32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.int64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_LONG),prepareNativeType(context.uint32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.uint64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_LONG|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.stringType,4,symbol_1.SYMBOL_FLAG_IS_REFERENCE),prepareNativeType(context.float32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_FLOAT),prepareNativeType(context.float64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_DOUBLE))}function prepareNativeType(type,byteSizeAndMaxAlignment,flags){var symbol=type.symbol;symbol.kind=symbol_1.SymbolKind.TYPE_NATIVE,symbol.byteSize=byteSizeAndMaxAlignment,symbol.maxAlignment=byteSizeAndMaxAlignment,symbol.flags=flags}function forbidFlag(context,node,flag,text){if(0!=(node.flags&flag)){var range=node_1.rangeForFlag(node.firstFlag,flag);null!=range&&(node.flags=node.flags&~flag,context.log.error(range,text))}}function requireFlag(context,node,flag,text){0==(node.flags&flag)&&(node.flags=node.flags|flag,context.log.error(node.range,text))}function initializeSymbol(context,symbol){if(symbol.state==symbol_1.SymbolState.INITIALIZED)return void assert_1.assert(null!=symbol.resolvedType);assert_1.assert(symbol.state==symbol_1.SymbolState.UNINITIALIZED),symbol.state=symbol_1.SymbolState.INITIALIZING;var node=symbol.node;if(forbidFlag(context,node,node_1.NODE_FLAG_PROTECTED,"Unsupported flag 'protected'"),symbol.kind==symbol_1.SymbolKind.TYPE_MODULE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a module"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a module"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a module"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a module");else if(symbol.kind==symbol_1.SymbolKind.TYPE_CLASS||symbol.kind==symbol_1.SymbolKind.TYPE_NATIVE||symbol.kind==symbol_1.SymbolKind.TYPE_GENERIC||symbol.kind==symbol_1.SymbolKind.TYPE_TEMPLATE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a class");else if(symbol.kind==symbol_1.SymbolKind.TYPE_INTERFACE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a interface");else if(symbol.kind==symbol_1.SymbolKind.TYPE_ENUM){forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on an enum"),symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol;var underlyingSymbol=symbol.resolvedType.underlyingType(context).symbol;symbol.byteSize=underlyingSymbol.byteSize,symbol.maxAlignment=underlyingSymbol.maxAlignment}else if(symbol_1.isFunction(symbol.kind)){var body=node.functionBody(),returnType=node.functionReturnType(),oldUnsafeAllowed=context.isUnsafeAllowed;context.isUnsafeAllowed=node.isUnsafe(),resolveAsType(context,returnType,symbol.scope.parent),returnType.resolvedType.isClass()&&returnType.hasParameters()&&node.parent!=returnType.resolvedType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],returnType.resolvedType.symbol.scope);for(var argumentCount=0,child=node.functionFirstArgument();child!=returnType;)assert_1.assert(child.kind==node_1.NodeKind.VARIABLE),assert_1.assert(child.symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT),initializeSymbol(context,child.symbol),child.symbol.offset=argumentCount,argumentCount+=1,child=child.nextSibling;if(symbol.kind!=symbol_1.SymbolKind.FUNCTION_INSTANCE?(forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' here"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' here"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' here"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' here")):node.isGet()?(forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use both 'get' and 'set'"),1!=argumentCount&&context.log.error(symbol.range,"Getters must not have any arguments")):node.isSet()?(symbol.rename="set_"+symbol.name,2!=argumentCount&&context.log.error(symbol.range,"Setters must have exactly one argument")):node.isOperator()&&("~"==symbol.name||"++"==symbol.name||"--"==symbol.name?1!=argumentCount&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must not have any arguments"):"+"==symbol.name||"-"==symbol.name?argumentCount>2&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must have at most one argument"):"[]="==symbol.name?argumentCount<2&&context.log.error(symbol.range,"Operator '[]=' must have at least one argument"):2!=argumentCount&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must have exactly one argument")),symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var parent_2=symbol.parent(),shouldConvertInstanceToGlobal=!1;if(forbidFlag(context,node,node_1.NODE_FLAG_EXPORT,"Cannot use 'export' on an instance function"),forbidFlag(context,node,node_1.NODE_FLAG_DECLARE,"Cannot use 'declare' on an instance function"),parent_2.node.isDeclare()?null==body?node.flags=node.flags|node_1.NODE_FLAG_DECLARE:shouldConvertInstanceToGlobal=!0:(null==body&&context.log.error(node.lastChild.range,"Must implement this function"),parent_2.node.isExport()&&(node.flags=node.flags|node_1.NODE_FLAG_EXPORT)),shouldConvertInstanceToGlobal){symbol.kind=symbol_1.SymbolKind.FUNCTION_GLOBAL,symbol.flags=symbol.flags|symbol_1.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL,symbol.rename=parent_2.name+"_"+(null!=symbol.rename?symbol.rename:symbol.name);var argument=node.functionFirstArgument();assert_1.assert("this"==argument.symbol.name),argument.symbol.rename="__this"}}else null==body?(forbidFlag(context,node,node_1.NODE_FLAG_EXPORT,"Cannot use 'export' on an unimplemented function"),node.parent&&node.parent.isDeclare()||requireFlag(context,node,node_1.NODE_FLAG_DECLARE,"Declared functions must be prefixed with 'declare'")):forbidFlag(context,node,node_1.NODE_FLAG_DECLARE,"Cannot use 'declare' on a function with an implementation");context.isUnsafeAllowed=oldUnsafeAllowed}else if(symbol_1.isVariable(symbol.kind)){forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a variable"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a variable");var type=node.variableType(),value=node.variableValue(),oldUnsafeAllowed=context.isUnsafeAllowed;if(context.isUnsafeAllowed=context.isUnsafeAllowed||node.isUnsafe(),symbol.kind!=symbol_1.SymbolKind.VARIABLE_INSTANCE&&(forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' here"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' here")),null!=type?(resolveAsType(context,type,symbol.scope),type.resolvedType.isTemplate()&&type.hasParameters()&&node.parent!=type.resolvedType.symbol.node&&deriveConcreteClass(context,type,[type.firstChild.firstChild],type.resolvedType.symbol.scope),symbol.resolvedType=type.resolvedType):null!=value?(resolveAsExpression(context,value,symbol.scope),value.resolvedType.isTemplate()&&value.hasParameters()&&node.parent!=value.resolvedType.symbol.node&&deriveConcreteClass(context,value,[value.firstChild.firstChild],value.resolvedType.symbol.scope),symbol.resolvedType=value.resolvedType):(context.log.error(node.internalRange,"Cannot create untyped variables"),symbol.resolvedType=context.errorType),symbol.resolvedType!=context.voidType&&symbol.resolvedType!=context.nullType||(context.log.error(node.internalRange,"Cannot create a variable with type '"+symbol.resolvedType.toString()+"'"),symbol.resolvedType=context.errorType),symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT)if(null!=value)resolveAsExpression(context,value,symbol.scope),checkConversion(context,value,symbol.resolvedTypeUnderlyingIfEnumValue(context),type_1.ConversionKind.IMPLICIT),value.kind==node_1.NodeKind.INT32||value.kind==node_1.NodeKind.INT64||value.kind==node_1.NodeKind.BOOLEAN?symbol.offset=value.intValue:value.kind==node_1.NodeKind.FLOAT32||value.kind==node_1.NodeKind.FLOAT64?symbol.offset=value.floatValue:value.resolvedType!=context.errorType&&(context.log.error(value.range,"Invalid constant initializer"),symbol.resolvedType=context.errorType);else if(symbol.isEnumValue())if(null!=node.previousSibling){var previousSymbol=node.previousSibling.symbol;initializeSymbol(context,previousSymbol),symbol.offset=previousSymbol.offset+1}else symbol.offset=0;else context.log.error(node.internalRange,"Constants must be initialized");if(null==symbol.scope.symbol)for(var scope=symbol.scope.parent;null!=scope;){var shadowed=scope.findLocal(symbol.name,scope_1.ScopeHint.NORMAL);if(null!=shadowed){context.log.error(node.internalRange,"The symbol '"+symbol.name+"' shadows another symbol with the same name in a parent scope");break}if(null!=scope.symbol)break;scope=scope.parent}context.isUnsafeAllowed=oldUnsafeAllowed}else assert_1.assert(!1);assert_1.assert(null!=symbol.resolvedType),symbol.state=symbol_1.SymbolState.INITIALIZED}function deriveConcreteClass(context,type,parameters,scope){var templateNode=type.resolvedType.pointerTo?type.resolvedType.pointerTo.symbol.node:type.resolvedType.symbol.node,templateName=templateNode.stringValue,typeName=templateNode.stringValue+"<"+parameters[0].stringValue+">",rename=templateNode.stringValue+"_"+parameters[0].stringValue,symbol=scope.parent.findNested(typeName,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);if(symbol){var genericSymbol=scope.parent.findNested(type.firstChild.firstChild.stringValue,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);return type.firstChild.firstChild.symbol=genericSymbol,genericSymbol.resolvedType.pointerTo?type.firstChild.firstChild.resolvedType=genericSymbol.resolvedType.pointerType():type.firstChild.firstChild.resolvedType=genericSymbol.resolvedType,type.symbol=symbol,void(type.resolvedType.pointerTo?type.resolvedType=symbol.resolvedType.pointerType():type.resolvedType=symbol.resolvedType)}var node=templateNode.clone();if(node.stringValue=typeName,cloneChildren(templateNode.firstChild.nextSibling,node,parameters,templateName,typeName),node.offset=null,initialize(context,node,scope.parent,CheckMode.NORMAL),resolve(context,node,scope.parent),node.symbol.flags|=symbol_1.SYMBOL_FLAG_USED,type.symbol=node.symbol,node.symbol.rename=rename,type.resolvedType.pointerTo?type.resolvedType=node.symbol.resolvedType.pointerType():type.resolvedType=node.symbol.resolvedType,templateNode.parent)templateNode.replaceWith(node);else{var prevNode=templateNode.derivedNodes[templateNode.derivedNodes.length-1];prevNode.parent.insertChildAfter(prevNode,node)}void 0===templateNode.derivedNodes&&(templateNode.derivedNodes=[]),templateNode.derivedNodes.push(node),type.firstChild.firstChild.kind=node_1.NodeKind.NAME,resolve(context,type.firstChild.firstChild,scope.parent),type.stringValue=node.symbol.name}function cloneChildren(child,parentNode,parameters,templateName,typeName){for(var firstChildNode=null,lastChildNode=null;child;)if("this"==child.stringValue&&child.parent.symbol&&child.parent.symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE&&child.kind==node_1.NodeKind.TYPE)child=child.nextSibling;else{var childNode=void 0;if(child.kind!=node_1.NodeKind.PARAMETERS&&child.kind!=node_1.NodeKind.PARAMETER){if(child.isGeneric()){var offset=child.offset;child.resolvedType&&(offset=child.resolvedType.pointerTo?child.resolvedType.pointerTo.symbol.node.offset:child.resolvedType.symbol.node.offset),childNode=child.symbol&&symbol_1.isVariable(child.symbol.kind)?child.clone():parameters[offset].clone(),childNode.kind=node_1.NodeKind.NAME}else"T"==child.stringValue&&(terminal_1.Terminal.write("Generic type escaped!"),terminal_1.Terminal.write(child)),childNode=child.clone(),childNode.stringValue==templateName&&(childNode.stringValue=typeName);childNode.parent=parentNode,"constructor"==childNode.stringValue&&childNode.parent.kind==node_1.NodeKind.CLASS&&(childNode.parent.constructorFunctionNode=childNode),firstChildNode||(firstChildNode=childNode),lastChildNode&&(lastChildNode.nextSibling=childNode,childNode.previousSibling=lastChildNode),child.firstChild&&cloneChildren(child.firstChild,childNode,parameters,templateName,typeName),lastChildNode=childNode,child=child.nextSibling}else child=child.nextSibling}null!=firstChildNode&&(parentNode.firstChild=firstChildNode),null!=lastChildNode&&(parentNode.lastChild=lastChildNode)}function resolveChildren(context,node,parentScope){for(var child=node.firstChild;null!=child;)resolve(context,child,parentScope),assert_1.assert(null!=child.resolvedType),child=child.nextSibling}function resolveChildrenAsExpressions(context,node,parentScope){for(var child=node.firstChild;null!=child;)resolveAsExpression(context,child,parentScope),child=child.nextSibling}function resolveAsExpression(context,node,parentScope){assert_1.assert(node_1.isExpression(node)),resolve(context,node,parentScope),assert_1.assert(null!=node.resolvedType),node.resolvedType!=context.errorType&&(node.isType()?(context.log.error(node.range,"Expected expression but found type"),node.resolvedType=context.errorType):node.resolvedType==context.voidType&&node.parent.kind!=node_1.NodeKind.EXPRESSION&&(context.log.error(node.range,"This expression does not return a value"),node.resolvedType=context.errorType))}function resolveAsType(context,node,parentScope){assert_1.assert(node_1.isExpression(node)),resolve(context,node,parentScope),assert_1.assert(null!=node.resolvedType),node.resolvedType==context.errorType||node.isType()||(context.log.error(node.range,"Expected type but found expression"),node.resolvedType=context.errorType)}function canConvert(context,node,to,kind){var from=node.resolvedType;if(assert_1.assert(node_1.isExpression(node)),assert_1.assert(null!=from),assert_1.assert(null!=to),from.isGeneric()||to.isGeneric())return!0;if(from==to||from==context.errorType||to==context.errorType)return!0;if(from==context.nullType)return!0;if(from.isReference()||to.isReference()){if(kind==type_1.ConversionKind.EXPLICIT)return!0}else{if(from==context.booleanType)return!0;if(from.isInteger()&&to.isInteger()){to.integerBitMask(context);return!(!from.isUnsigned()||!to.isUnsigned())||(!(!from.isEnum()||to!=from.underlyingType(context))||(!node.intValue||(kind==type_1.ConversionKind.EXPLICIT||from.symbol.byteSize=0&&node.intValue<=const_1.MAX_UINT32_VALUE:node.intValue>=const_1.MIN_INT32_VALUE&&node.intValue<=const_1.MAX_INT32_VALUE))))}if(from.isInteger()&&to.isFloat()||from.isInteger()&&to.isDouble()||from.isLong()&&to.isInteger()||from.isLong()&&to.isFloat()||from.isLong()&&to.isDouble()||from.isFloat()&&to.isInteger()||from.isFloat()&&to.isLong()||from.isDouble()&&to.isInteger()||from.isDouble()&&to.isLong()||from.isDouble()&&to.isFloat())return kind!=type_1.ConversionKind.IMPLICIT;if(from.isInteger()&&to.isLong()||from.isFloat()&&to.isDouble()||from.isFloat()&&to.isFloat()||from.isDouble()&&to.isDouble())return!0}return!1}function checkConversion(context,node,to,kind){canConvert(context,node,to,kind)||(context.log.error(node.range,"Cannot convert from type '"+node.resolvedType.toString()+"' to type '"+to.toString()+"' "+(kind==type_1.ConversionKind.IMPLICIT&&canConvert(context,node,to,type_1.ConversionKind.EXPLICIT)?"without a cast":"")),node.resolvedType=context.errorType)}function checkStorage(context,target){assert_1.assert(node_1.isExpression(target)),target.resolvedType==context.errorType||target.kind==node_1.NodeKind.INDEX||target.kind==node_1.NodeKind.POINTER_INDEX||target.kind==node_1.NodeKind.DEREFERENCE||(target.kind==node_1.NodeKind.NAME||target.kind==node_1.NodeKind.DOT)&&(null==target.symbol||symbol_1.isVariable(target.symbol.kind)&&target.symbol.kind!=symbol_1.SymbolKind.VARIABLE_CONSTANT)||(context.log.error(target.range,"Cannot store to this location"),target.resolvedType=context.errorType)}function createDefaultValueForType(context,type){return type.isLong()?node_1.createLong(0):type.isInteger()?node_1.createInt(0):type.isDouble()?node_1.createDouble(0):type.isFloat()?node_1.createFloat(0):type==context.booleanType?node_1.createboolean(!1):type.isClass()?node_1.createNull():type.isGeneric()?node_1.createNull():(assert_1.assert(type.isReference()),node_1.createNull())}function simplifyBinary(node){var left=node.binaryLeft(),right=node.binaryRight();if(node.kind!=node_1.NodeKind.ADD&&node.kind!=node_1.NodeKind.MULTIPLY&&node.kind!=node_1.NodeKind.BITWISE_AND&&node.kind!=node_1.NodeKind.BITWISE_OR&&node.kind!=node_1.NodeKind.BITWISE_XOR||left.kind!=node_1.NodeKind.INT32||right.kind==node_1.NodeKind.INT32||(node.appendChild(left.remove()),left=node.binaryLeft(),right=node.binaryRight()),(node.kind==node_1.NodeKind.MULTIPLY||(node.kind==node_1.NodeKind.DIVIDE||node.kind==node_1.NodeKind.REMAINDER)&&node.resolvedType.isUnsigned())&&right.kind==node_1.NodeKind.INT32&&utils_1.isPositivePowerOf2(right.intValue)){for(var shift=-1,value=right.intValue;0!=value;)value>>=1,shift+=1;node.kind==node_1.NodeKind.MULTIPLY?(node.kind=node_1.NodeKind.SHIFT_LEFT,right.intValue=shift):node.kind==node_1.NodeKind.DIVIDE?(node.kind=node_1.NodeKind.SHIFT_RIGHT,right.intValue=shift):node.kind==node_1.NodeKind.REMAINDER?(node.kind=node_1.NodeKind.BITWISE_AND,right.intValue=right.intValue-1):assert_1.assert(!1)}else node.kind==node_1.NodeKind.ADD&&right.kind==node_1.NodeKind.NEGATIVE?(node.kind=node_1.NodeKind.SUBTRACT,right.replaceWith(right.unaryValue().remove())):node.kind==node_1.NodeKind.ADD&&right.isNegativeInteger()&&(node.kind=node_1.NodeKind.SUBTRACT,right.intValue=-right.intValue)}function binaryHasUnsignedArguments(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isUnsigned()&&rightType.isUnsigned()||leftType.isUnsigned()&&right.isNonNegativeInteger()||left.isNonNegativeInteger()&&rightType.isUnsigned()}function isBinaryLong(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isLong()||rightType.isLong()}function isBinaryDouble(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isDouble()||rightType.isDouble()}function isSymbolAccessAllowed(context,symbol,node,range){if(symbol.isUnsafe()&&!context.isUnsafeAllowed)return context.log.error(range,"Cannot use symbol '"+symbol.name+"' outside an 'unsafe' block"),!1;if(null!=symbol.node&&symbol.node.isPrivate()){var parent_3=symbol.parent();if(null!=parent_3&&context.enclosingClass!=parent_3)return context.log.error(range,"Cannot access private symbol '"+symbol.name+"' here"),!1}return!(symbol_1.isFunction(symbol.kind)&&(symbol.isSetter()?!node.isAssignTarget():!node.isCallValue()))||(symbol.isSetter()?context.log.error(range,"Cannot use setter '"+symbol.name+"' here"):context.log.error(range,"Must call function '"+symbol.name+"'"),!1)}function resolve(context,node,parentScope){var kind=node.kind;if(assert_1.assert(kind==node_1.NodeKind.FILE||null!=parentScope),null==node.resolvedType)if(node.resolvedType=context.errorType,kind==node_1.NodeKind.FILE||kind==node_1.NodeKind.GLOBAL)resolveChildren(context,node,parentScope);else if(kind==node_1.NodeKind.MODULE){var oldEnclosingModule=context.enclosingModule;initializeSymbol(context,node.symbol),context.enclosingModule=node.symbol,resolveChildren(context,node,node.scope),context.enclosingModule=oldEnclosingModule}else if(kind==node_1.NodeKind.IMPORT||kind==node_1.NodeKind.IMPORT_FROM);else if(kind==node_1.NodeKind.CLASS){var oldEnclosingClass=context.enclosingClass;initializeSymbol(context,node.symbol),context.enclosingClass=node.symbol,resolveChildren(context,node,node.scope),node.symbol.kind==symbol_1.SymbolKind.TYPE_CLASS&&node.symbol.determineClassLayout(context),context.enclosingClass=oldEnclosingClass}else if(kind==node_1.NodeKind.ENUM)initializeSymbol(context,node.symbol),resolveChildren(context,node,node.scope);else if(kind==node_1.NodeKind.FUNCTION){var body=node.functionBody();if(initializeSymbol(context,node.symbol),"constructor"==node.stringValue&&node.parent.kind==node_1.NodeKind.CLASS&&(node.parent.constructorFunctionNode=node),null!=body){var oldReturnType=context.currentReturnType,oldUnsafeAllowed=context.isUnsafeAllowed,returnType=node.functionReturnType();returnType.resolvedType.isTemplate()&&returnType.hasParameters()&&node.parent!=returnType.resolvedType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],returnType.resolvedType.symbol.scope),context.currentReturnType=returnType.resolvedType,context.isUnsafeAllowed=node.isUnsafe(),resolveChildren(context,body,node.scope),oldReturnType&&oldReturnType.isTemplate()&&returnType.hasParameters()&&node.parent!=oldReturnType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],oldReturnType.symbol.scope),context.currentReturnType=oldReturnType,context.isUnsafeAllowed=oldUnsafeAllowed}}else if(kind==node_1.NodeKind.PARAMETER)var symbol=node.symbol;else if(kind==node_1.NodeKind.VARIABLE){var symbol=node.symbol;initializeSymbol(context,symbol);var oldUnsafeAllowed=context.isUnsafeAllowed;context.isUnsafeAllowed=context.isUnsafeAllowed||node.isUnsafe();var value=node.variableValue();null!=value?(resolveAsExpression(context,value,parentScope),checkConversion(context,value,symbol.resolvedTypeUnderlyingIfEnumValue(context),type_1.ConversionKind.IMPLICIT),symbol.resolvedType!=value.resolvedType&&value.becomeValueTypeOf(symbol,context),symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL&&value.kind!=node_1.NodeKind.INT32&&value.kind!=node_1.NodeKind.BOOLEAN&&(value.kind,node_1.NodeKind.NULL)):symbol.resolvedType!=context.errorType&&(value=createDefaultValueForType(context,symbol.resolvedType),resolveAsExpression(context,value,parentScope),node.appendChild(value)),symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL&&symbol.resolvedType!=context.errorType&&(symbol.offset=context.allocateGlobalVariableOffset(symbol.resolvedType.variableSizeOf(context),symbol.resolvedType.variableAlignmentOf(context))),context.isUnsafeAllowed=oldUnsafeAllowed}else if(kind==node_1.NodeKind.BREAK||kind==node_1.NodeKind.CONTINUE){for(var found=!1,n=node;null!=n;){if(n.kind==node_1.NodeKind.WHILE){found=!0;break}n=n.parent}found||context.log.error(node.range,"Cannot use this statement outside of a loop")}else if(kind==node_1.NodeKind.BLOCK){var oldUnsafeAllowed=context.isUnsafeAllowed;node.isUnsafe()&&(context.isUnsafeAllowed=!0),resolveChildren(context,node,node.scope),context.isUnsafeAllowed=oldUnsafeAllowed}else if(kind==node_1.NodeKind.IMPORTS||kind==node_1.NodeKind.CONSTANTS||kind==node_1.NodeKind.VARIABLES)resolveChildren(context,node,parentScope);else if(kind==node_1.NodeKind.ANY)node.kind=node_1.NodeKind.TYPE,node.resolvedType=context.anyType;else if(kind==node_1.NodeKind.INT32)node.resolvedType=node.intValue<0&&!node.isPositive()?context.uint32Type:context.int32Type;else if(kind==node_1.NodeKind.INT64)node.resolvedType=node.intValue<0&&!node.isPositive()?context.uint64Type:context.int64Type;else if(kind==node_1.NodeKind.FLOAT32)node.resolvedType=context.float32Type;else if(kind==node_1.NodeKind.FLOAT64)node.resolvedType=context.float64Type;else if(kind==node_1.NodeKind.STRING)node.resolvedType=context.stringType;else if(kind==node_1.NodeKind.BOOLEAN)node.resolvedType=context.booleanType;else if(kind==node_1.NodeKind.NULL)node.resolvedType=context.nullType;else if(kind==node_1.NodeKind.INDEX){resolveChildrenAsExpressions(context,node,parentScope);var target=node.indexTarget(),type=target.resolvedType;if(type!=context.errorType){var symbol=type.hasInstanceMembers()?type.findMember("[]",scope_1.ScopeHint.NORMAL):null;null==symbol?void 0!==target.resolvedType.pointerTo?(node.kind=node_1.NodeKind.POINTER_INDEX,node.resolvedType=target.resolvedType.pointerTo.symbol.resolvedType):context.log.error(node.internalRange,"Cannot index into type '"+target.resolvedType.toString()+"'"):(assert_1.assert(symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE||symbol.kind==symbol_1.SymbolKind.FUNCTION_GLOBAL&&symbol.shouldConvertInstanceToGlobal()),node.kind=node_1.NodeKind.CALL,target.remove(),node.insertChildBefore(node.firstChild,node_1.createMemberReference(target,symbol)),node.resolvedType=null,resolveAsExpression(context,node,parentScope))}}else if(kind==node_1.NodeKind.ALIGN_OF){var type=node.alignOfType();resolveAsType(context,type,parentScope),node.resolvedType=context.int32Type,type.resolvedType!=context.errorType&&node.becomeIntegerConstant(type.resolvedType.allocationAlignmentOf(context))}else if(kind==node_1.NodeKind.SIZE_OF){var type=node.sizeOfType();resolveAsType(context,type,parentScope),node.resolvedType=context.int32Type,type.resolvedType!=context.errorType&&node.becomeIntegerConstant(type.resolvedType.allocationSizeOf(context))}else if(kind==node_1.NodeKind.THIS){var symbol=parentScope.findNested("this",scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);null==symbol?context.log.error(node.range,"Cannot use 'this' here"):node.becomeSymbolReference(symbol)}else if(kind==node_1.NodeKind.PARSE_ERROR)node.resolvedType=context.errorType;else if(kind==node_1.NodeKind.NAME){var name_1=node.stringValue,symbol=parentScope.findNested(name_1,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);if(null==symbol){var errorMessage="No symbol named '"+name_1+"' here";symbol=parentScope.findNested(name_1,scope_1.ScopeHint.NORMAL,scope_1.FindNested.ALLOW_INSTANCE_ERRORS),null!=symbol?errorMessage+=", did you mean 'this."+symbol.name+"'?":"number"==name_1?errorMessage+=", you cannot use generic number type from TypeScript!":"bool"==name_1&&(errorMessage+=", did you mean 'boolean'?"),context.log.error(node.range,errorMessage)}else symbol.state==symbol_1.SymbolState.INITIALIZING?context.log.error(node.range,"Cyclic reference to symbol '"+name_1+"' here"):isSymbolAccessAllowed(context,symbol,node,node.range)&&(initializeSymbol(context,symbol),node.symbol=symbol,node.resolvedType=symbol.resolvedType,node.resolvedType.isGeneric()&&(node.flags|=node_1.NODE_FLAG_GENERIC),symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT&&(symbol.resolvedType==context.booleanType?node.becomeBooleanConstant(0!=symbol.offset):symbol.resolvedType==context.float32Type?node.becomeFloatConstant(symbol.offset):symbol.resolvedType==context.float64Type?node.becomeDoubleConstant(symbol.offset):symbol.resolvedType==context.int64Type?node.becomeLongConstant(symbol.offset):node.becomeIntegerConstant(symbol.offset)))}else if(kind==node_1.NodeKind.CAST){var value=node.castValue(),type=node.castType();resolveAsExpression(context,value,parentScope),resolveAsType(context,type,parentScope);var castedType=type.resolvedType;if(checkConversion(context,value,castedType,type_1.ConversionKind.EXPLICIT),node.resolvedType=castedType,value.kind==node_1.NodeKind.INT32&&castedType.isInteger()){var result=value.intValue,shift=32-castedType.integerBitCount(context);node.becomeIntegerConstant(castedType.isUnsigned()?castedType.integerBitMask(context)&result:result<>shift)}else value.kind==node_1.NodeKind.INT32&&castedType.isFloat()?node.becomeFloatConstant(value.intValue):value.kind==node_1.NodeKind.INT32&&castedType.isDouble()?node.becomeDoubleConstant(value.intValue):value.kind==node_1.NodeKind.FLOAT32&&castedType.isInteger()&&node.becomeIntegerConstant(Math.round(value.floatValue))}else if(kind==node_1.NodeKind.DOT){var target=node.dotTarget();if(resolve(context,target,parentScope),target.resolvedType!=context.errorType)if(target.isType()&&(target.resolvedType.isEnum()||target.resolvedType.hasInstanceMembers())||!target.isType()&&target.resolvedType.hasInstanceMembers()){var name_2=node.stringValue;if(name_2.length>0){var symbol=target.resolvedType.findMember(name_2,node.isAssignTarget()?scope_1.ScopeHint.PREFER_SETTER:scope_1.ScopeHint.PREFER_GETTER);if(null==symbol)context.log.error(node.internalRange,"No member named '"+name_2+"' on type '"+target.resolvedType.toString()+"'");else{if(symbol.isGetter())return void(node.parent.stringValue===node.stringValue&&node.parent.kind===node_1.NodeKind.CALL?(node.parent.resolvedType=null,node.symbol=symbol,node.resolvedType=symbol.resolvedType,resolveAsExpression(context,node.parent,parentScope)):(node.kind=node_1.NodeKind.CALL,node.appendChild(node_1.createMemberReference(target.remove(),symbol)),node.resolvedType=null,resolveAsExpression(context,node,parentScope)));isSymbolAccessAllowed(context,symbol,node,node.internalRange)&&(initializeSymbol(context,symbol),node.symbol=symbol,node.resolvedType=symbol.resolvedType,symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT&&node.becomeIntegerConstant(symbol.offset))}}}else context.log.error(node.internalRange,"The type '"+target.resolvedType.toString()+"' has no members")}else if(kind==node_1.NodeKind.CALL){var value=node.callValue();if(resolveAsExpression(context,value,parentScope),value.resolvedType!=context.errorType){var symbol=value.symbol;if(null!=symbol&&symbol_1.isFunction(symbol.kind)){if(initializeSymbol(context,symbol),symbol.shouldConvertInstanceToGlobal()){var name_3=node_1.createSymbolReference(symbol);node.insertChildBefore(value,name_3.withRange(value.internalRange)),node.insertChildBefore(value,value.dotTarget().remove()),value.remove(),value=name_3}for(var returnType=symbol.node.functionReturnType(),argumentVariable=symbol.node.functionFirstArgumentIgnoringThis(),argumentValue=value.nextSibling;argumentVariable!=returnType&&null!=argumentValue;)resolveAsExpression(context,argumentValue,parentScope),checkConversion(context,argumentValue,argumentVariable.symbol.resolvedType,type_1.ConversionKind.IMPLICIT),argumentVariable=argumentVariable.nextSibling,argumentValue=argumentValue.nextSibling;if(returnType.resolvedType!=context.anyType)if(argumentVariable==returnType||argumentVariable.hasVariableValue()){if(null!=argumentValue){for(;null!=argumentValue;)resolveAsExpression(context,argumentValue,parentScope),argumentValue=argumentValue.nextSibling;context.log.error(node.internalRange,"Too many arguments for function '"+symbol.name+"'")}}else context.log.error(node.internalRange,"Not enough arguments for function '"+symbol.name+"'");returnType.resolvedType.isArray()&&terminal_1.Terminal.write(returnType),node.resolvedType=returnType.resolvedType}else context.log.error(value.range,"Cannot call value of type '"+value.resolvedType.toString()+"'")}}else if(kind==node_1.NodeKind.DELETE){var value=node.deleteType();null!=value?(resolveAsExpression(context,value,parentScope),null!=value.resolvedType&&value.resolvedType!=context.voidType||context.log.error(value.range,"Unexpected delete value 'void'")):context.log.error(node.range,"Expected delete value '"+context.currentReturnType.toString()+"'")}else if(kind==node_1.NodeKind.RETURN){var value=node.returnValue();null!=value?(resolveAsExpression(context,value,parentScope),null!=context.currentReturnType&&(context.currentReturnType!=context.voidType?(value.resolvedType.isTemplate()&&value.hasParameters()&&node.parent!=value.resolvedType.symbol.node&&deriveConcreteClass(context,value,[value.firstChild.firstChild],value.resolvedType.symbol.scope),checkConversion(context,value,context.currentReturnType,type_1.ConversionKind.IMPLICIT)):context.log.error(value.range,"Unexpected return value in function returning 'void'")),node.parent.returnNode=node):null!=context.currentReturnType&&context.currentReturnType!=context.voidType&&context.log.error(node.range,"Expected return value in function returning '"+context.currentReturnType.toString()+"'")}else if(kind==node_1.NodeKind.EMPTY);else if(kind==node_1.NodeKind.PARAMETERS);else if(kind==node_1.NodeKind.EXTENDS)resolveAsType(context,node.extendsType(),parentScope);else if(kind==node_1.NodeKind.IMPLEMENTS){for(var child=node.firstChild;null!=child;)resolveAsType(context,child,parentScope),child=child.nextSibling;context.log.error(node.range,"Interfaces are not implemented yet")}else if(kind==node_1.NodeKind.EXPRESSION)resolveAsExpression(context,node.expressionValue(),parentScope);else if(kind==node_1.NodeKind.WHILE){var value=node.whileValue(),body=node.whileBody();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,body,parentScope)}else if(kind==node_1.NodeKind.IF){var value=node.ifValue(),yes=node.ifTrue(),no=node.ifFalse();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,yes,parentScope),null!=no&&resolve(context,no,parentScope)}else if(kind==node_1.NodeKind.HOOK){var value=node.hookValue(),yes=node.hookTrue(),no=node.hookFalse();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,yes,parentScope),resolve(context,no,parentScope),checkConversion(context,yes,no.resolvedType,type_1.ConversionKind.IMPLICIT);var commonType=(yes.resolvedType==context.nullType?no:yes).resolvedType;yes.resolvedType==commonType||yes.resolvedType==context.nullType&&commonType.isReference()||no.resolvedType==commonType||no.resolvedType==context.nullType&&commonType.isReference()||context.log.error(log_1.spanRanges(yes.range,no.range),"Type '"+yes.resolvedType.toString()+"' is not the same as type '"+no.resolvedType.toString()+"'"),node.resolvedType=commonType}else if(kind==node_1.NodeKind.ASSIGN){var left=node.binaryLeft(),right=node.binaryRight();if(left.kind==node_1.NodeKind.INDEX){resolveChildrenAsExpressions(context,left,parentScope);var target=left.indexTarget(),type=target.resolvedType;if(type!=context.errorType){var symbol=type.hasInstanceMembers()?type.findMember("[]=",scope_1.ScopeHint.NORMAL):null;if(null!=symbol){for(assert_1.assert(symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE),node.kind=node_1.NodeKind.CALL,target.remove(),left.remove();null!=left.lastChild;)node.insertChildBefore(node.firstChild,left.lastChild.remove());return node.insertChildBefore(node.firstChild,node_1.createMemberReference(target,symbol)),node.internalRange=log_1.spanRanges(left.internalRange,right.range),node.resolvedType=null,void resolveAsExpression(context,node,parentScope)}void 0!=target.resolvedType.pointerTo?(left.kind=node_1.NodeKind.POINTER_INDEX,left.resolvedType=target.resolvedType.pointerTo.symbol.resolvedType):context.log.error(left.internalRange,"Cannot index into type '"+target.resolvedType.toString()+"'")}}if(left.resolvedType||resolveAsExpression(context,left,parentScope),null!=left.symbol&&left.symbol.isSetter())return node.kind=node_1.NodeKind.CALL,node.internalRange=left.internalRange,node.resolvedType=null,void resolveAsExpression(context,node,parentScope);resolveAsExpression(context,right,parentScope),checkConversion(context,right,left.resolvedType,type_1.ConversionKind.IMPLICIT),checkStorage(context,left),node.resolvedType=left.resolvedType}else if(kind==node_1.NodeKind.NEW){compiler_1.Compiler.mallocRequired=!0;var type=node.newType();resolveAsType(context,type,parentScope),type.resolvedType.isTemplate()&&type.hasParameters()&&node.parent!=type.resolvedType.symbol.node&&deriveConcreteClass(context,type,[type.firstChild.firstChild],type.resolvedType.symbol.scope),type.resolvedType!=context.errorType&&(type.resolvedType.isClass()?node.resolvedType=type.resolvedType:context.log.error(type.range,"Cannot construct type '"+type.resolvedType.toString()+"'"));for(var child=type.nextSibling,constructorNode=node.constructorNode(),argumentVariable=constructorNode.functionFirstArgument();null!=child;)resolveAsExpression(context,child,parentScope),checkConversion(context,child,argumentVariable.symbol.resolvedType,type_1.ConversionKind.IMPLICIT),child=child.nextSibling,argumentVariable=argumentVariable.nextSibling}else if(kind==node_1.NodeKind.POINTER_TYPE){var value=node.unaryValue();if(resolveAsType(context,value,parentScope),context.target==compile_target_1.CompileTarget.JAVASCRIPT)context.log.error(node.internalRange,"Cannot use pointers when compiling to JavaScript");else{var type=value.resolvedType;type!=context.errorType&&(node.resolvedType=type.pointerType())}}else if(kind==node_1.NodeKind.POINTER_INDEX);else if(kind==node_1.NodeKind.DEREFERENCE){var value=node.unaryValue();resolveAsExpression(context,value,parentScope);var type=value.resolvedType;type!=context.errorType&&(null==type.pointerTo?context.log.error(node.internalRange,"Cannot dereference type '"+type.toString()+"'"):node.resolvedType=type.pointerTo)}else if(kind==node_1.NodeKind.ADDRESS_OF){var value=node.unaryValue();resolveAsExpression(context,value,parentScope),context.log.error(node.internalRange,"The address-of operator is not supported")}else if(node_1.isUnary(kind)){var value=node.unaryValue();if(resolveAsExpression(context,value,parentScope),kind==node_1.NodeKind.NOT)checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),node.resolvedType=context.booleanType;else if(value.resolvedType.isLong()){if(value.resolvedType.isUnsigned()?(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR,node.resolvedType=context.uint64Type):node.resolvedType=context.int64Type,value.kind==node_1.NodeKind.INT64){var input=value.longValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeLongConstant(output)}}else if(value.resolvedType.isInteger()){if(value.resolvedType.isUnsigned()?(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR,node.resolvedType=context.uint32Type):node.resolvedType=context.int32Type,value.kind==node_1.NodeKind.INT32){var input=value.intValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeIntegerConstant(output)}}else if(value.resolvedType.isDouble()){if(node.resolvedType=context.float64Type,value.kind==node_1.NodeKind.FLOAT64){var input=value.doubleValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeDoubleConstant(output)}}else if(value.resolvedType.isFloat()){if(node.resolvedType=context.float32Type,value.kind==node_1.NodeKind.FLOAT32){var input=value.floatValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeFloatConstant(output)}}else if(value.resolvedType!=context.errorType){var name_4=node.internalRange.toString(),symbol=value.resolvedType.findMember(name_4,scope_1.ScopeHint.NOT_BINARY);null!=symbol?(node.appendChild(node_1.createMemberReference(value.remove(),symbol).withRange(node.range).withInternalRange(node.internalRange)),node.kind=node_1.NodeKind.CALL,node.resolvedType=null,resolveAsExpression(context,node,parentScope)):context.log.error(node.internalRange,"Cannot use unary operator '"+name_4+"' with type '"+value.resolvedType.toString()+"'")}}else if(node_1.isBinary(kind)){var left=node.binaryLeft(),right=node.binaryRight();resolveAsExpression(context,left,parentScope),resolveAsExpression(context,right,parentScope);var leftType=left.resolvedType;(leftType.isDouble()&&right.resolvedType.isFloat()||leftType.isLong()&&right.resolvedType.isInteger())&&right.becomeTypeOf(left,context);var rightType=right.resolvedType;if(kind==node_1.NodeKind.LOGICAL_OR||kind==node_1.NodeKind.LOGICAL_AND)checkConversion(context,left,context.booleanType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,context.booleanType,type_1.ConversionKind.IMPLICIT),node.resolvedType=context.booleanType;else if(kind==node_1.NodeKind.ADD&&null!=leftType.pointerTo&&rightType.isInteger())node.resolvedType=leftType;else if(kind!=node_1.NodeKind.LESS_THAN&&kind!=node_1.NodeKind.LESS_THAN_EQUAL&&kind!=node_1.NodeKind.GREATER_THAN&&kind!=node_1.NodeKind.GREATER_THAN_EQUAL||null==leftType.pointerTo&&null==rightType.pointerTo){if((leftType.isInteger()||leftType.isLong()||leftType.isFloat()||leftType.isDouble()||leftType.isGeneric()&&rightType.isGeneric())&&kind!=node_1.NodeKind.EQUAL&&kind!=node_1.NodeKind.NOT_EQUAL){var isFloat=!1,isFloat64=!1;(leftType.isFloat()||leftType.isDouble())&&(isFloat=!0,isFloat64=leftType.isDouble());var isUnsigned=binaryHasUnsignedArguments(node);if(kind==node_1.NodeKind.ADD||kind==node_1.NodeKind.SUBTRACT||kind==node_1.NodeKind.MULTIPLY||kind==node_1.NodeKind.DIVIDE||kind==node_1.NodeKind.REMAINDER||kind==node_1.NodeKind.BITWISE_AND||kind==node_1.NodeKind.BITWISE_OR||kind==node_1.NodeKind.BITWISE_XOR||kind==node_1.NodeKind.SHIFT_LEFT||kind==node_1.NodeKind.SHIFT_RIGHT){var isLong=isBinaryLong(node),commonType=void 0;if(commonType=isFloat?isBinaryDouble(node)?context.float64Type:context.float32Type:isUnsigned?isLong?context.uint64Type:context.uint32Type:isLong?context.int64Type:context.int32Type,isUnsigned&&(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR),checkConversion(context,left,commonType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,commonType,type_1.ConversionKind.IMPLICIT),node.resolvedType=commonType,commonType==context.int64Type&&(left.kind==node_1.NodeKind.INT32?(left.kind=node_1.NodeKind.INT64,left.resolvedType=context.int64Type):right.kind==node_1.NodeKind.INT32&&(right.kind=node_1.NodeKind.INT64,right.resolvedType=context.int64Type)),left.kind!=node_1.NodeKind.INT32&&left.kind!=node_1.NodeKind.INT64||right.kind!=node_1.NodeKind.INT32&&right.kind!=node_1.NodeKind.INT64)if(left.kind!=node_1.NodeKind.FLOAT32&&left.kind!=node_1.NodeKind.FLOAT64||right.kind!=node_1.NodeKind.FLOAT32&&right.kind!=node_1.NodeKind.FLOAT64)simplifyBinary(node);else{var inputLeft=left.floatValue,inputRight=right.floatValue,output=0;if(kind==node_1.NodeKind.ADD)output=inputLeft+inputRight;else if(kind==node_1.NodeKind.BITWISE_AND)output=inputLeft&inputRight;else if(kind==node_1.NodeKind.BITWISE_OR)output=inputLeft|inputRight;else if(kind==node_1.NodeKind.BITWISE_XOR)output=inputLeft^inputRight;else if(kind==node_1.NodeKind.DIVIDE)output=inputLeft/inputRight;else if(kind==node_1.NodeKind.MULTIPLY)output=inputLeft*inputRight;else if(kind==node_1.NodeKind.REMAINDER)output=inputLeft%inputRight;else if(kind==node_1.NodeKind.SHIFT_LEFT)output=inputLeft<>inputRight;else{if(kind!=node_1.NodeKind.SUBTRACT)return;output=inputLeft-inputRight}left.kind==node_1.NodeKind.FLOAT32?node.becomeFloatConstant(output):node.becomeDoubleConstant(output)}else{var inputLeft=left.intValue,inputRight=right.intValue,output=0;if(kind==node_1.NodeKind.ADD)output=inputLeft+inputRight;else if(kind==node_1.NodeKind.BITWISE_AND)output=inputLeft&inputRight;else if(kind==node_1.NodeKind.BITWISE_OR)output=inputLeft|inputRight;else if(kind==node_1.NodeKind.BITWISE_XOR)output=inputLeft^inputRight;else if(kind==node_1.NodeKind.DIVIDE)output=inputLeft/inputRight;else if(kind==node_1.NodeKind.MULTIPLY)output=inputLeft*inputRight;else if(kind==node_1.NodeKind.REMAINDER)output=inputLeft%inputRight;else if(kind==node_1.NodeKind.SHIFT_LEFT)output=inputLeft<>inputRight;else{if(kind!=node_1.NodeKind.SUBTRACT)return;output=inputLeft-inputRight}left.kind==node_1.NodeKind.INT32?node.becomeIntegerConstant(output):node.becomeLongConstant(output)}}else if(kind==node_1.NodeKind.LESS_THAN||kind==node_1.NodeKind.LESS_THAN_EQUAL||kind==node_1.NodeKind.GREATER_THAN||kind==node_1.NodeKind.GREATER_THAN_EQUAL){var expectedType=isFloat?isFloat64?context.float64Type:context.float32Type:isUnsigned?context.uint32Type:context.int32Type;isUnsigned&&(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR),leftType!=rightType&&(checkConversion(context,left,expectedType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,expectedType,type_1.ConversionKind.IMPLICIT)),node.resolvedType=context.booleanType}else context.log.error(node.internalRange,"This operator is not currently supported")}else if(leftType!=context.errorType){var name_5=node.internalRange.toString(),symbol=leftType.findMember(kind==node_1.NodeKind.NOT_EQUAL?"==":kind==node_1.NodeKind.LESS_THAN_EQUAL?">":kind==node_1.NodeKind.GREATER_THAN_EQUAL?"<":name_5,scope_1.ScopeHint.NOT_UNARY);if(null!=symbol){if(left=node_1.createMemberReference(left.remove(),symbol).withRange(node.range).withInternalRange(node.internalRange),right.remove(),kind==node_1.NodeKind.NOT_EQUAL||kind==node_1.NodeKind.LESS_THAN_EQUAL||kind==node_1.NodeKind.GREATER_THAN_EQUAL){var call=node_1.createCall(left);call.appendChild(right),node.kind=node_1.NodeKind.NOT,node.appendChild(call.withRange(node.range).withInternalRange(node.range))}else node.appendChild(left),node.appendChild(right),node.kind=node_1.NodeKind.CALL;node.resolvedType=null,resolveAsExpression(context,node,parentScope)}else kind==node_1.NodeKind.EQUAL||kind==node_1.NodeKind.NOT_EQUAL?(node.resolvedType=context.booleanType,leftType==context.errorType||rightType==context.errorType||leftType==rightType||canConvert(context,right,leftType,type_1.ConversionKind.IMPLICIT)||canConvert(context,left,rightType,type_1.ConversionKind.IMPLICIT)||context.log.error(node.internalRange,"Cannot compare type '"+leftType.toString()+"' with type '"+rightType.toString()+"'")):context.log.error(node.internalRange,"Cannot use binary operator '"+name_5+"' with type '"+leftType.toString()+"'")}}else node.resolvedType=context.booleanType,leftType!=rightType&&context.log.error(node.internalRange,"Cannot compare type '"+leftType.toString()+"' with type '"+rightType.toString()+"'")}else kind==node_1.NodeKind.TYPE||(terminal_1.Terminal.error("Unexpected kind: "+node_1.NodeKind[kind]),assert_1.assert(!1))}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(3),type_1=__webpack_require__(18),node_1=__webpack_require__(5),compile_target_1=__webpack_require__(4),log_1=__webpack_require__(2),scope_1=__webpack_require__(17),utils_1=__webpack_require__(6),const_1=__webpack_require__(48),assert_1=__webpack_require__(0),compiler_1=__webpack_require__(11),terminal_1=__webpack_require__(1),CheckContext=function(){function CheckContext(){}return CheckContext.prototype.allocateGlobalVariableOffset=function(sizeOf,alignmentOf){var offset=utils_1.alignToNextMultipleOf(this.nextGlobalVariableOffset,alignmentOf);return this.nextGlobalVariableOffset=offset+sizeOf,offset},CheckContext}();exports.CheckContext=CheckContext,exports.addScopeToSymbol=addScopeToSymbol,exports.linkSymbolToNode=linkSymbolToNode;var CheckMode;!function(CheckMode){CheckMode[CheckMode.NORMAL=0]="NORMAL",CheckMode[CheckMode.INITIALIZE=1]="INITIALIZE"}(CheckMode=exports.CheckMode||(exports.CheckMode={})),exports.initialize=initialize,exports.forbidFlag=forbidFlag,exports.requireFlag=requireFlag,exports.initializeSymbol=initializeSymbol,exports.resolveChildren=resolveChildren,exports.resolveChildrenAsExpressions=resolveChildrenAsExpressions,exports.resolveAsExpression=resolveAsExpression,exports.resolveAsType=resolveAsType,exports.canConvert=canConvert,exports.checkConversion=checkConversion,exports.checkStorage=checkStorage,exports.createDefaultValueForType=createDefaultValueForType,exports.simplifyBinary=simplifyBinary,exports.binaryHasUnsignedArguments=binaryHasUnsignedArguments,exports.isBinaryLong=isBinaryLong,exports.isBinaryDouble=isBinaryDouble,exports.isSymbolAccessAllowed=isSymbolAccessAllowed,exports.resolve=resolve},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var compile_target_1=__webpack_require__(4);exports.defaultCompilerOptions={target:compile_target_1.CompileTarget.WEBASSEMBLY,silent:!0,logError:!0}},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MIN_INT32_VALUE=-Math.pow(2,31),exports.MAX_INT32_VALUE=Math.pow(2,31)-1,exports.MIN_UINT32_VALUE=0,exports.MAX_UINT32_VALUE=Math.pow(2,32)-1,exports.MIN_INT64_VALUE=-Math.pow(2,63),exports.MAX_INT64_VALUE=Math.pow(2,63)-1,exports.MIN_UINT64_VALUE=0,exports.MAX_UINT64_VALUE=Math.pow(2,64)-1},function(module,exports,__webpack_require__){"use strict";function treeShakingMarkAllUsed(node){var symbol=node.symbol;if(null==symbol||symbol.isUsed()||!symbol_1.isFunction(symbol.kind)||null==symbol.node||(symbol.flags=symbol.flags|symbol_1.SYMBOL_FLAG_USED,treeShakingMarkAllUsed(symbol.node),node!=symbol.node)){if(node.kind==node_1.NodeKind.NEW){var type=node.newType().resolvedType;null!=type.symbol&&(type.symbol.flags|=symbol_1.SYMBOL_FLAG_USED,type.symbol.node.constructorFunctionNode.symbol.flags=symbol_1.SYMBOL_FLAG_USED)}for(var child=node.firstChild;null!=child;)treeShakingMarkAllUsed(child),child=child.nextSibling}}function treeShakingSearchForUsed(node){if(node.kind==node_1.NodeKind.FUNCTION&&(node.isExport()||node.isStart())){if(("malloc"===node.symbol.name||"free"===node.symbol.name)&&!compiler_1.Compiler.mallocRequired)return;treeShakingMarkAllUsed(node)}else if(node.kind==node_1.NodeKind.GLOBAL||node.kind==node_1.NodeKind.CLASS){for(var child=node.firstChild;null!=child;)treeShakingSearchForUsed(child),child=child.nextSibling;node.kind==node_1.NodeKind.CLASS&&node.isExport()&&(node.symbol.flags=node.symbol.flags|symbol_1.SYMBOL_FLAG_USED)}}function treeShakingRemoveUnused(node){if(node.kind==node_1.NodeKind.FUNCTION&&!node.symbol.isUsed()&&node.range.source.isLibrary)node.remove();else if(node.kind==node_1.NodeKind.GLOBAL||node.kind==node_1.NodeKind.CLASS){for(var child=node.firstChild;null!=child;){var next=child.nextSibling;treeShakingRemoveUnused(child),child=next}node.kind!=node_1.NodeKind.CLASS||node.symbol.isUsed()||node.isDeclare()||!node.range.source.isLibrary||node.remove()}}function treeShaking(node){treeShakingSearchForUsed(node),treeShakingRemoveUnused(node)}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(3),node_1=__webpack_require__(5),compiler_1=__webpack_require__(11);exports.treeShakingMarkAllUsed=treeShakingMarkAllUsed,exports.treeShakingSearchForUsed=treeShakingSearchForUsed,exports.treeShakingRemoveUnused=treeShakingRemoveUnused,exports.treeShaking=treeShaking},function(module,exports,__webpack_require__){"use strict";function preparse(source,compiler,log){for(var contents=source.contents,limit=contents.length,pathSeparator=source.name.indexOf("/")>-1?"/":source.name.indexOf("\\")>-1?"\\":"/",basePath=source.name.substring(0,source.name.lastIndexOf(pathSeparator)),wantNewline=!1,captureImportFrom=!1,captureImportPath=!1,i=0;i=2&&length_1<=10){var text=contents.slice(start,i);"import"==text?captureImportFrom=!0:"from"==text&&captureImportFrom&&(captureImportFrom=!1,captureImportPath=!0)}}else if(captureImportPath&&('"'==c||"'"==c||"`"==c))for(captureImportPath=!1;i0;)this._text+=this.indentStr,i-=1},StringBuilder.prototype.appendChar=function(c){return this._text+=c,this},StringBuilder.prototype.appendSlice=function(text,start,end){return this._text+=text.slice(start,end),this},StringBuilder.prototype.breakChunk=function(){return this.chunks.push(this._text),this._text="",this.chunks.length-1},StringBuilder.prototype.appendLine=function(text,indent){return void 0===indent&&(indent=0),this.indent+=indent,this.emitIndent(),this._text+=text+"\n",this},StringBuilder.prototype.appendRaw=function(text){return this._text+=text+"\n",this},StringBuilder.prototype.append=function(text,indent){var _this=this;return void 0===indent&&(indent=0),this.indent+=indent,text.split("\n").forEach(function(line,i){i>0&&(_this._text+="\n",_this.emitIndent()),_this._text+=line}),this},StringBuilder.prototype.removeLastChar=function(){this._text=this._text.substring(0,this._text.length-1)},StringBuilder.prototype.removeLastLinebreak=function(){this._text=this._text.substring(0,this._text.lastIndexOf("\n"))},StringBuilder.prototype.finish=function(){if(this.next=stringBuilderPool,stringBuilderPool=this,this.chunks.length>0){var code_1="";return this.chunks.forEach(function(chunk){code_1+=chunk}),code_1+this._text}return this._text},StringBuilder}();exports.StringBuilder=StringBuilder},function(module,exports){module.exports=require("fs")}])}); \ No newline at end of file +!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory(require("fs")):"function"==typeof define&&define.amd?define(["fs"],factory):"object"==typeof exports?exports.turboscript=factory(require("fs")):root.turboscript=factory(root.fs)}(this,function(__WEBPACK_EXTERNAL_MODULE_55__){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=52)}([function(module,exports,__webpack_require__){"use strict";function assert(truth){if(!truth){if(terminal_1.Terminal.error("Assertion failed"),"undefined"==typeof process)throw"Assertion failed";process.exit(1)}}Object.defineProperty(exports,"__esModule",{value:!0});var terminal_1=__webpack_require__(1);exports.assert=assert},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var env_1=__webpack_require__(21),color_1=__webpack_require__(20),Terminal=function(){function Terminal(){}return Terminal.write=function(text){Terminal.history+=text,Terminal.silent||(env_1.isNode?process.stdout.write(text):console.log("%c"+text,"background: "+Terminal.browserStyles.background+";color: "+Terminal.browserStyles.text+";font-weight: "+(Terminal.browserStyles.bold?"700":"100")+";"))},Terminal.time=function(name){Terminal.silent||console.time(name)},Terminal.timeEnd=function(name){Terminal.silent||console.timeEnd(name)},Terminal.setBGColor=function(color){env_1.isNode?process.stdout.isTTY&&process.stdout.write("[48;5;"+(null===color?"":color)+"m"):Terminal.browserStyles.background=color_1.HexColor[color]},Terminal.setTextColor=function(color){env_1.isNode?process.stdout.isTTY&&process.stdout.write("[38;5;"+color+"m"):Terminal.browserStyles.text=color_1.HexColor[color]},Terminal.setBoldText=function(){env_1.isNode?process.stdout.isTTY&&process.stdout.write(""):Terminal.browserStyles.bold=!0},Terminal.clearColor=function(){env_1.isNode?process.stdout.isTTY&&process.stdout.write(""):(Terminal.browserStyles.text=color_1.HexColor[color_1.Color.DEFAULT_TEXT],Terminal.browserStyles.background=color_1.HexColor[color_1.Color.DEFAULT_BG],Terminal.browserStyles.bold=!1)},Terminal.error=function(text){Terminal.setBGColor(color_1.Color.RED),Terminal.setTextColor(color_1.Color.WHITE),Terminal.write(" ERROR "),Terminal.clearColor(),Terminal.setTextColor(color_1.Color.RED),Terminal.write(" "),Terminal.write(text),Terminal.write("\n"),Terminal.clearColor()},Terminal.warn=function(text){Terminal.setBGColor(color_1.Color.ORANGE),Terminal.setTextColor(color_1.Color.WHITE),Terminal.write(" WARN "),Terminal.clearColor(),Terminal.setTextColor(color_1.Color.ORANGE),Terminal.write(" "),Terminal.write(text),Terminal.write("\n"),Terminal.clearColor()},Terminal}();Terminal.silent=!1,Terminal.history="",Terminal.browserStyles={text:color_1.HexColor[color_1.Color.DEFAULT_TEXT],background:color_1.HexColor[color_1.Color.DEFAULT_BG],bold:!1},exports.Terminal=Terminal},function(module,exports,__webpack_require__){"use strict";function createRange(source,start,end){assert_1.assert(start<=end);var range=new SourceRange;return range.source=source,range.start=start,range.end=end,range}function spanRanges(left,right){return assert_1.assert(left.source==right.source),assert_1.assert(left.start<=right.start),assert_1.assert(left.end<=right.end),createRange(left.source,left.start,right.end)}function writeLogToTerminal(log){for(var diagnostic=log.first;null!=diagnostic;){if(void 0!==diagnostic.range){var location_2=diagnostic.range.source.indexToLineColumn(diagnostic.range.start),diagnosticMessage=diagnostic.sourceName(location_2);terminal_1.Terminal.setBoldText(),terminal_1.Terminal.write(diagnosticMessage),diagnosticMessage=diagnostic.kind==DiagnosticKind.ERROR?"ERROR: ":"WARN: ",terminal_1.Terminal.setTextColor(diagnostic.kind==DiagnosticKind.ERROR?color_1.Color.RED:color_1.Color.ORANGE),terminal_1.Terminal.write(diagnosticMessage),terminal_1.Terminal.setBoldText(),terminal_1.Terminal.write(diagnostic.message+"\n"),terminal_1.Terminal.clearColor(),terminal_1.Terminal.write(diagnostic.lineContents()),diagnosticMessage=diagnostic.sourceRange(location_2),terminal_1.Terminal.setTextColor(color_1.Color.RED),terminal_1.Terminal.write(diagnosticMessage)}else terminal_1.Terminal.setTextColor(color_1.Color.RED),terminal_1.Terminal.write(diagnostic.message+"\n");diagnostic=diagnostic.next}terminal_1.Terminal.clearColor()}Object.defineProperty(exports,"__esModule",{value:!0});var color_1=__webpack_require__(20),assert_1=__webpack_require__(0),terminal_1=__webpack_require__(1),LineColumn=function(){function LineColumn(){}return LineColumn}();exports.LineColumn=LineColumn;var Source=function(){function Source(){}return Source.prototype.indexToLineColumn=function(index){for(var contents=this.contents,column=0,line=0,i=0;i57343)&&(column+=1),i+=1}var location=new LineColumn;return location.line=line,location.column=column,location},Source}();exports.Source=Source;var SourceRange=function(){function SourceRange(){}return SourceRange.prototype.toString=function(){return this.source.contents.slice(this.start,this.end)},SourceRange.prototype.equals=function(other){return this.source==other.source&&this.start==other.start&&this.end==other.end},SourceRange.prototype.enclosingLine=function(){for(var contents=this.source.contents,start=this.start,end=this.start;start>0&&"\n"!=contents[start-1];)start-=1;for(var length=contents.length;end0;)rangeStr+=" ",column-=1;if(range.end-range.start<=1)rangeStr+="^";else for(var i=range.start;i=SymbolKind.TYPE_CLASS&&kind<=SymbolKind.TYPE_NATIVE}function isFunction(kind){return kind>=SymbolKind.FUNCTION_INSTANCE&&kind<=SymbolKind.FUNCTION_GLOBAL}function isVariable(kind){return kind>=SymbolKind.VARIABLE_ARGUMENT&&kind<=SymbolKind.VARIABLE_LOCAL}Object.defineProperty(exports,"__esModule",{value:!0});var SymbolKind,node_1=__webpack_require__(5),utils_1=__webpack_require__(6),assert_1=__webpack_require__(0);!function(SymbolKind){SymbolKind[SymbolKind.TYPE_MODULE=0]="TYPE_MODULE",SymbolKind[SymbolKind.TYPE_INTERFACE=1]="TYPE_INTERFACE",SymbolKind[SymbolKind.TYPE_CLASS=2]="TYPE_CLASS",SymbolKind[SymbolKind.TYPE_GENERIC=3]="TYPE_GENERIC",SymbolKind[SymbolKind.TYPE_TEMPLATE=4]="TYPE_TEMPLATE",SymbolKind[SymbolKind.TYPE_ENUM=5]="TYPE_ENUM",SymbolKind[SymbolKind.TYPE_GLOBAL=6]="TYPE_GLOBAL",SymbolKind[SymbolKind.TYPE_NATIVE=7]="TYPE_NATIVE",SymbolKind[SymbolKind.FUNCTION_INSTANCE=8]="FUNCTION_INSTANCE",SymbolKind[SymbolKind.FUNCTION_GLOBAL=9]="FUNCTION_GLOBAL",SymbolKind[SymbolKind.VARIABLE_ARGUMENT=10]="VARIABLE_ARGUMENT",SymbolKind[SymbolKind.VARIABLE_CONSTANT=11]="VARIABLE_CONSTANT",SymbolKind[SymbolKind.VARIABLE_GLOBAL=12]="VARIABLE_GLOBAL",SymbolKind[SymbolKind.VARIABLE_INSTANCE=13]="VARIABLE_INSTANCE",SymbolKind[SymbolKind.VARIABLE_LOCAL=14]="VARIABLE_LOCAL"}(SymbolKind=exports.SymbolKind||(exports.SymbolKind={})),exports.isModule=isModule,exports.isType=isType,exports.isFunction=isFunction,exports.isVariable=isVariable;var SymbolState;!function(SymbolState){SymbolState[SymbolState.UNINITIALIZED=0]="UNINITIALIZED",SymbolState[SymbolState.INITIALIZING=1]="INITIALIZING",SymbolState[SymbolState.INITIALIZED=2]="INITIALIZED"}(SymbolState=exports.SymbolState||(exports.SymbolState={})),exports.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL=1,exports.SYMBOL_FLAG_IS_BINARY_OPERATOR=2,exports.SYMBOL_FLAG_IS_REFERENCE=4,exports.SYMBOL_FLAG_IS_UNARY_OPERATOR=8,exports.SYMBOL_FLAG_IS_UNSIGNED=16,exports.SYMBOL_FLAG_NATIVE_INTEGER=32,exports.SYMBOL_FLAG_NATIVE_LONG=64,exports.SYMBOL_FLAG_NATIVE_FLOAT=128,exports.SYMBOL_FLAG_NATIVE_DOUBLE=256,exports.SYMBOL_FLAG_USED=512,exports.SYMBOL_FLAG_IS_ARRAY=1024,exports.SYMBOL_FLAG_IS_GENERIC=2048,exports.SYMBOL_FLAG_IS_TEMPLATE=4096;var Symbol=function(){function Symbol(){this.state=SymbolState.UNINITIALIZED,this.byteSize=0,this.maxAlignment=0}return Object.defineProperty(Symbol.prototype,"internalName",{get:function(){return null!=this.rename?this.rename:this.name},enumerable:!0,configurable:!0}),Symbol.prototype.clone=function(){var symbol=new Symbol;return symbol.kind=this.kind,symbol.name=this.name,symbol.node=this.node,symbol.range=this.range,symbol.scope=this.scope,symbol.resolvedType=this.resolvedType,symbol.byteSize=this.byteSize,symbol.state=this.state,symbol.maxAlignment=this.maxAlignment,symbol.flags=this.flags,symbol.rename=this.rename,symbol},Symbol.prototype.isEnumValue=function(){return this.node.parent.kind==node_1.NodeKind.ENUM},Symbol.prototype.isUnsafe=function(){return null!=this.node&&this.node.isUnsafe()},Symbol.prototype.isGetter=function(){return this.node.isGet()},Symbol.prototype.isSetter=function(){return this.node.isSet()},Symbol.prototype.isBinaryOperator=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_IS_BINARY_OPERATOR)},Symbol.prototype.isUnaryOperator=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_IS_UNARY_OPERATOR)},Symbol.prototype.shouldConvertInstanceToGlobal=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL)},Symbol.prototype.isUsed=function(){return 0!=(this.flags&exports.SYMBOL_FLAG_USED)},Symbol.prototype.parent=function(){var parent=this.node.parent;return parent.kind==node_1.NodeKind.CLASS?parent.symbol:null},Symbol.prototype.resolvedTypeUnderlyingIfEnumValue=function(context){return this.isEnumValue()?this.resolvedType.underlyingType(context):this.resolvedType},Symbol.prototype.determineClassLayout=function(context){if(assert_1.assert(this.kind==SymbolKind.TYPE_CLASS),0==this.byteSize){for(var offset=0,child=this.node.firstChild,maxAlignment=1;null!=child;){if(child.kind==node_1.NodeKind.VARIABLE){var type=child.symbol.resolvedType;if(type!=context.errorType){var alignmentOf=type.variableAlignmentOf(context);offset=utils_1.alignToNextMultipleOf(offset,alignmentOf),alignmentOf>maxAlignment&&(maxAlignment=alignmentOf),child.symbol.offset=offset,offset+=type.variableSizeOf(context)}}child=child.nextSibling}0==offset&&(offset=1),offset=utils_1.alignToNextMultipleOf(offset,maxAlignment),this.byteSize=offset,this.maxAlignment=maxAlignment}},Symbol}();exports.Symbol=Symbol},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});!function(CompileTarget){CompileTarget[CompileTarget.NONE=0]="NONE",CompileTarget[CompileTarget.AUTO=1]="AUTO",CompileTarget[CompileTarget.CPP=2]="CPP",CompileTarget[CompileTarget.JAVASCRIPT=3]="JAVASCRIPT",CompileTarget[CompileTarget.WEBASSEMBLY=4]="WEBASSEMBLY"}(exports.CompileTarget||(exports.CompileTarget={}))},function(module,exports,__webpack_require__){"use strict";function isUnary(kind){return kind>=NodeKind.ADDRESS_OF&&kind<=NodeKind.PREFIX_INCREMENT}function isUnaryPostfix(kind){return kind>=NodeKind.POSTFIX_DECREMENT&&kind<=NodeKind.POSTFIX_INCREMENT}function isBinary(kind){return kind>=NodeKind.ADD&&kind<=NodeKind.SUBTRACT}function invertedBinaryKind(kind){return kind==NodeKind.EQUAL?NodeKind.NOT_EQUAL:kind==NodeKind.NOT_EQUAL?NodeKind.EQUAL:kind==NodeKind.GREATER_THAN?NodeKind.LESS_THAN_EQUAL:kind==NodeKind.GREATER_THAN_EQUAL?NodeKind.LESS_THAN:kind==NodeKind.LESS_THAN?NodeKind.GREATER_THAN_EQUAL:kind==NodeKind.LESS_THAN_EQUAL?NodeKind.GREATER_THAN:kind}function isExpression(node){return node.kind>=NodeKind.ALIGN_OF&&node.kind<=NodeKind.SUBTRACT}function isCompactNodeKind(kind){return kind==NodeKind.CONSTANTS||kind==NodeKind.EXPRESSION||kind==NodeKind.VARIABLES}function appendFlag(first,flag,range){var link=new NodeFlag;if(link.flag=flag,link.range=range,null==first)return link;for(var secondToLast=first;null!=secondToLast.next;)secondToLast=secondToLast.next;return secondToLast.next=link,first}function allFlags(link){for(var all=0;null!=link;)all|=link.flag,link=link.next;return all}function rangeForFlag(link,flag){for(;null!=link;){if(link.flag==flag)return link.range;link=link.next}return null}function createNew(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.NEW,node.appendChild(type),node}function createDelete(value){assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.DELETE,null!=value&&node.appendChild(value),node}function createHook(test,primary,secondary){assert_1.assert(isExpression(test)),assert_1.assert(isExpression(primary)),assert_1.assert(isExpression(secondary));var node=new Node;return node.kind=NodeKind.HOOK,node.appendChild(test),node.appendChild(primary),node.appendChild(secondary),node}function createIndex(target){assert_1.assert(isExpression(target));var node=new Node;return node.kind=NodeKind.INDEX,node.appendChild(target),node}function createNull(){var node=new Node;return node.kind=NodeKind.NULL,node}function createUndefined(){var node=new Node;return node.kind=NodeKind.UNDEFINED,node}function createThis(){var node=new Node;return node.kind=NodeKind.THIS,node}function createAddressOf(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.ADDRESS_OF,node.appendChild(value),node}function createDereference(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.DEREFERENCE,node.appendChild(value),node}function createAlignOf(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.ALIGN_OF,node.appendChild(type),node}function createSizeOf(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.SIZE_OF,node.appendChild(type),node}function createboolean(value){var node=new Node;return node.kind=NodeKind.BOOLEAN,node.intValue=value?1:0,node}function createInt(value){var node=new Node;return node.kind=NodeKind.INT32,node.intValue=value,node}function createLong(value){var node=new Node;return node.kind=NodeKind.INT64,node.longValue=value,node}function createFloat(value){var node=new Node;return node.kind=NodeKind.FLOAT32,node.floatValue=value,node}function createDouble(value){var node=new Node;return node.kind=NodeKind.FLOAT64,node.doubleValue=value,node}function createString(value){var node=new Node;return node.kind=NodeKind.STRING,node.stringValue=value,node}function createArray(type){var node=new Node;return node.kind=NodeKind.ARRAY,node.resolvedType=type,node}function createName(value){var node=new Node;return node.kind=NodeKind.NAME,node.referenceValue=value,node}function createType(type){assert_1.assert(null!=type);var node=new Node;return node.kind=NodeKind.TYPE,node.resolvedType=type,node}function createAny(){var node=new Node;return node.kind=NodeKind.ANY,node}function createEmpty(){var node=new Node;return node.kind=NodeKind.EMPTY,node}function createExpression(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.EXPRESSION,node.appendChild(value),node}function createBlock(){var node=new Node;return node.kind=NodeKind.BLOCK,node}function createModule(name){var node=new Node;return node.kind=NodeKind.MODULE,node.stringValue=name,node}function createClass(name){var node=new Node;return node.kind=NodeKind.CLASS,node.stringValue=name,node}function createEnum(name){var node=new Node;return node.kind=NodeKind.ENUM,node.stringValue=name,node}function createIf(value,trueBranch,falseBranch){assert_1.assert(isExpression(value)),assert_1.assert(trueBranch.kind==NodeKind.BLOCK),assert_1.assert(null==falseBranch||falseBranch.kind==NodeKind.BLOCK);var node=new Node;return node.kind=NodeKind.IF,node.appendChild(value),node.appendChild(trueBranch),null!=falseBranch&&node.appendChild(falseBranch),node}function createWhile(value,body){assert_1.assert(isExpression(value)),assert_1.assert(body.kind==NodeKind.BLOCK);var node=new Node;return node.kind=NodeKind.WHILE,node.appendChild(value),node.appendChild(body),node}function createReturn(value){assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.RETURN,null!=value&&node.appendChild(value),node}function createImports(){var node=new Node;return node.kind=NodeKind.IMPORTS,node}function createImport(name){var node=new Node;return node.kind=NodeKind.IMPORT,node.stringValue=name,node}function createImportFrom(name){var node=new Node;return node.kind=NodeKind.IMPORT_FROM,node.stringValue=name,node}function createVariables(){var node=new Node;return node.kind=NodeKind.VARIABLES,node}function createConstants(){var node=new Node;return node.kind=NodeKind.CONSTANTS,node}function createParameters(){var node=new Node;return node.kind=NodeKind.PARAMETERS,node}function createExtends(type){assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.EXTENDS,node.appendChild(type),node}function createImplements(){var node=new Node;return node.kind=NodeKind.IMPLEMENTS,node}function createParameter(name){var node=new Node;return node.kind=NodeKind.PARAMETER,node.stringValue=name,node}function createVariable(name,type,value){assert_1.assert(null==type||isExpression(type)),assert_1.assert(null==value||isExpression(value));var node=new Node;return node.kind=NodeKind.VARIABLE,node.stringValue=name,node.appendChild(null!=type?type:createEmpty()),null!=value&&node.appendChild(value),node}function createFunction(name){var node=new Node;return node.kind=NodeKind.FUNCTION,node.stringValue=name,node}function createUnary(kind,value){assert_1.assert(isUnary(kind)),assert_1.assert(isExpression(value));var node=new Node;return node.kind=kind,node.appendChild(value),node}function createBinary(kind,left,right){assert_1.assert(isBinary(kind)),assert_1.assert(isExpression(left)),assert_1.assert(isExpression(right));var node=new Node;return node.kind=kind,node.appendChild(left),node.appendChild(right),node}function createCall(value){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.CALL,node.appendChild(value),node}function createCast(value,type){assert_1.assert(isExpression(value)),assert_1.assert(isExpression(type));var node=new Node;return node.kind=NodeKind.CAST,node.appendChild(value),node.appendChild(type),node}function createDot(value,name){assert_1.assert(isExpression(value));var node=new Node;return node.kind=NodeKind.DOT,node.stringValue=name,node.appendChild(value),node}function createSymbolReference(symbol){var node=createName(symbol.name);return node.symbol=symbol,node.resolvedType=symbol.resolvedType,node}function createMemberReference(value,symbol){var node=createDot(value,symbol.name);return node.symbol=symbol,node.resolvedType=symbol.resolvedType,node}function createParseError(){var node=new Node;return node.kind=NodeKind.PARSE_ERROR,node}function createJSNumber(){var node=new Node;return node.kind=NodeKind.JS_NUMBER,node}function createJSObject(){var node=new Node;return node.kind=NodeKind.JS_OBJECT,node}function createJSString(){var node=new Node;return node.kind=NodeKind.JS_STRING,node}function createJSArray(){var node=new Node;return node.kind=NodeKind.JS_ARRAY,node}Object.defineProperty(exports,"__esModule",{value:!0});var NodeKind,symbol_1=__webpack_require__(3),assert_1=__webpack_require__(0);!function(NodeKind){NodeKind[NodeKind.EXTENDS=0]="EXTENDS",NodeKind[NodeKind.FILE=1]="FILE",NodeKind[NodeKind.GLOBAL=2]="GLOBAL",NodeKind[NodeKind.IMPLEMENTS=3]="IMPLEMENTS",NodeKind[NodeKind.PARAMETER=4]="PARAMETER",NodeKind[NodeKind.PARAMETERS=5]="PARAMETERS",NodeKind[NodeKind.VARIABLE=6]="VARIABLE",NodeKind[NodeKind.IMPORT=7]="IMPORT",NodeKind[NodeKind.IMPORT_FROM=8]="IMPORT_FROM",NodeKind[NodeKind.BLOCK=9]="BLOCK",NodeKind[NodeKind.BREAK=10]="BREAK",NodeKind[NodeKind.MODULE=11]="MODULE",NodeKind[NodeKind.IMPORTS=12]="IMPORTS",NodeKind[NodeKind.CLASS=13]="CLASS",NodeKind[NodeKind.CONSTANTS=14]="CONSTANTS",NodeKind[NodeKind.CONTINUE=15]="CONTINUE",NodeKind[NodeKind.EMPTY=16]="EMPTY",NodeKind[NodeKind.ENUM=17]="ENUM",NodeKind[NodeKind.EXPRESSION=18]="EXPRESSION",NodeKind[NodeKind.FUNCTION=19]="FUNCTION",NodeKind[NodeKind.IF=20]="IF",NodeKind[NodeKind.RETURN=21]="RETURN",NodeKind[NodeKind.UNSAFE=22]="UNSAFE",NodeKind[NodeKind.JAVASCRIPT=23]="JAVASCRIPT",NodeKind[NodeKind.START=24]="START",NodeKind[NodeKind.VARIABLES=25]="VARIABLES",NodeKind[NodeKind.WHILE=26]="WHILE",NodeKind[NodeKind.ALIGN_OF=27]="ALIGN_OF",NodeKind[NodeKind.BOOLEAN=28]="BOOLEAN",NodeKind[NodeKind.CALL=29]="CALL",NodeKind[NodeKind.CAST=30]="CAST",NodeKind[NodeKind.DOT=31]="DOT",NodeKind[NodeKind.HOOK=32]="HOOK",NodeKind[NodeKind.INDEX=33]="INDEX",NodeKind[NodeKind.POINTER_INDEX=34]="POINTER_INDEX",NodeKind[NodeKind.ANY=35]="ANY",NodeKind[NodeKind.INT32=36]="INT32",NodeKind[NodeKind.INT64=37]="INT64",NodeKind[NodeKind.FLOAT32=38]="FLOAT32",NodeKind[NodeKind.FLOAT64=39]="FLOAT64",NodeKind[NodeKind.ARRAY=40]="ARRAY",NodeKind[NodeKind.GENERIC=41]="GENERIC",NodeKind[NodeKind.NAME=42]="NAME",NodeKind[NodeKind.NEW=43]="NEW",NodeKind[NodeKind.DELETE=44]="DELETE",NodeKind[NodeKind.NULL=45]="NULL",NodeKind[NodeKind.UNDEFINED=46]="UNDEFINED",NodeKind[NodeKind.PARSE_ERROR=47]="PARSE_ERROR",NodeKind[NodeKind.SIZE_OF=48]="SIZE_OF",NodeKind[NodeKind.STRING=49]="STRING",NodeKind[NodeKind.THIS=50]="THIS",NodeKind[NodeKind.TYPE=51]="TYPE",NodeKind[NodeKind.ADDRESS_OF=52]="ADDRESS_OF",NodeKind[NodeKind.COMPLEMENT=53]="COMPLEMENT",NodeKind[NodeKind.DEREFERENCE=54]="DEREFERENCE",NodeKind[NodeKind.NEGATIVE=55]="NEGATIVE",NodeKind[NodeKind.NOT=56]="NOT",NodeKind[NodeKind.POINTER_TYPE=57]="POINTER_TYPE",NodeKind[NodeKind.POSITIVE=58]="POSITIVE",NodeKind[NodeKind.POSTFIX_DECREMENT=59]="POSTFIX_DECREMENT",NodeKind[NodeKind.POSTFIX_INCREMENT=60]="POSTFIX_INCREMENT",NodeKind[NodeKind.PREFIX_DECREMENT=61]="PREFIX_DECREMENT",NodeKind[NodeKind.PREFIX_INCREMENT=62]="PREFIX_INCREMENT",NodeKind[NodeKind.ADD=63]="ADD",NodeKind[NodeKind.ASSIGN=64]="ASSIGN",NodeKind[NodeKind.BITWISE_AND=65]="BITWISE_AND",NodeKind[NodeKind.BITWISE_OR=66]="BITWISE_OR",NodeKind[NodeKind.BITWISE_XOR=67]="BITWISE_XOR",NodeKind[NodeKind.DIVIDE=68]="DIVIDE",NodeKind[NodeKind.EQUAL=69]="EQUAL",NodeKind[NodeKind.EXPONENT=70]="EXPONENT",NodeKind[NodeKind.GREATER_THAN=71]="GREATER_THAN",NodeKind[NodeKind.GREATER_THAN_EQUAL=72]="GREATER_THAN_EQUAL",NodeKind[NodeKind.LESS_THAN=73]="LESS_THAN",NodeKind[NodeKind.LESS_THAN_EQUAL=74]="LESS_THAN_EQUAL",NodeKind[NodeKind.LOGICAL_AND=75]="LOGICAL_AND",NodeKind[NodeKind.LOGICAL_OR=76]="LOGICAL_OR",NodeKind[NodeKind.MULTIPLY=77]="MULTIPLY",NodeKind[NodeKind.NOT_EQUAL=78]="NOT_EQUAL",NodeKind[NodeKind.REMAINDER=79]="REMAINDER",NodeKind[NodeKind.SHIFT_LEFT=80]="SHIFT_LEFT",NodeKind[NodeKind.SHIFT_RIGHT=81]="SHIFT_RIGHT",NodeKind[NodeKind.SUBTRACT=82]="SUBTRACT",NodeKind[NodeKind.JS_NUMBER=83]="JS_NUMBER",NodeKind[NodeKind.JS_OBJECT=84]="JS_OBJECT",NodeKind[NodeKind.JS_STRING=85]="JS_STRING",NodeKind[NodeKind.JS_ARRAY=86]="JS_ARRAY"}(NodeKind=exports.NodeKind||(exports.NodeKind={})),exports.isUnary=isUnary,exports.isUnaryPostfix=isUnaryPostfix,exports.isBinary=isBinary,exports.invertedBinaryKind=invertedBinaryKind,exports.isExpression=isExpression,exports.isCompactNodeKind=isCompactNodeKind,exports.NODE_FLAG_DECLARE=1,exports.NODE_FLAG_EXPORT=2,exports.NODE_FLAG_IMPORT=4,exports.NODE_FLAG_LIBRARY=8,exports.NODE_FLAG_GET=16,exports.NODE_FLAG_OPERATOR=32,exports.NODE_FLAG_POSITIVE=64,exports.NODE_FLAG_PRIVATE=128,exports.NODE_FLAG_PROTECTED=256,exports.NODE_FLAG_PUBLIC=512,exports.NODE_FLAG_SET=1024,exports.NODE_FLAG_STATIC=2048,exports.NODE_FLAG_UNSAFE=4096,exports.NODE_FLAG_JAVASCRIPT=8192,exports.NODE_FLAG_UNSIGNED_OPERATOR=16384,exports.NODE_FLAG_VIRTUAL=32768,exports.NODE_FLAG_START=65536,exports.NODE_FLAG_ANYFUNC=1<<17,exports.NODE_FLAG_GENERIC=1<<18;var NodeFlag=function(){function NodeFlag(){}return NodeFlag}();exports.NodeFlag=NodeFlag,exports.appendFlag=appendFlag,exports.allFlags=allFlags,exports.rangeForFlag=rangeForFlag;var Node=function(){function Node(){}return Object.defineProperty(Node.prototype,"hasValue",{get:function(){return this._hasValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"rawValue",{get:function(){return this._hasStringValue?'"'+this._rawValue+'"':this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"__internal_rawValue",{get:function(){return this._rawValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"intValue",{get:function(){var n=this._rawValue;return Number(n)===n&&n%1==0?this._rawValue:null},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"longValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"floatValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"doubleValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"stringValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._hasStringValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Object.defineProperty(Node.prototype,"referenceValue",{get:function(){return this._rawValue},set:function(newValue){this._hasValue=!0,this._rawValue=newValue},enumerable:!0,configurable:!0}),Node.prototype.becomeTypeOf=function(node,context){switch(node.resolvedType){case context.int64Type:this.kind!=NodeKind.NAME&&(this.kind=NodeKind.INT64),this.resolvedType=context.int64Type;break;case context.float64Type:this.kind!=NodeKind.NAME&&(this.kind=NodeKind.FLOAT64),this.resolvedType=context.float64Type}node.flags&&(this.flags=node.flags)},Node.prototype.becomeValueTypeOf=function(symbol,context){if(symbol.resolvedType.symbol)switch(symbol.resolvedType){case context.int64Type:this.resolvedType=context.int64Type,this.kind==NodeKind.NULL&&(this.longValue=0),this.kind!=NodeKind.NAME&&(this.kind=NodeKind.INT64);break;case context.float64Type:this.resolvedType=context.float64Type,this.kind==NodeKind.NULL&&(this.doubleValue=0),this.kind!=NodeKind.NAME&&(this.kind=NodeKind.FLOAT64)}},Node.prototype.clone=function(){var node=new Node;return node.kind=this.kind,void 0!==this.offset&&(node.offset=this.offset),void 0!==this.flags&&(node.flags=this.flags),void 0!==this.firstFlag&&(node.firstFlag=this.firstFlag),void 0!==this.range&&(node.range=this.range),void 0!==this.internalRange&&(node.internalRange=this.internalRange),this.hasValue&&(node.rawValue=this.__internal_rawValue),node},Node.prototype.becomeSymbolReference=function(symbol){this.kind=NodeKind.NAME,this.symbol=symbol,this.referenceValue=symbol.name,this.resolvedType=symbol.resolvedType,this.removeChildren()},Node.prototype.becomeIntegerConstant=function(value){this.kind=NodeKind.INT32,this.symbol=null,this.intValue=value,this.removeChildren()},Node.prototype.becomeLongConstant=function(value){this.kind=NodeKind.INT64,this.symbol=null,this.longValue=value,this.removeChildren()},Node.prototype.becomeFloatConstant=function(value){this.kind=NodeKind.FLOAT32,this.symbol=null,this.floatValue=value,this.removeChildren()},Node.prototype.becomeDoubleConstant=function(value){this.kind=NodeKind.FLOAT64,this.symbol=null,this.doubleValue=value,this.removeChildren()},Node.prototype.becomeBooleanConstant=function(value){this.kind=NodeKind.BOOLEAN,this.symbol=null,this.intValue=value?1:0,this.removeChildren()},Node.prototype.isNegativeInteger=function(){return this.kind==NodeKind.INT32&&this.intValue<0},Node.prototype.isNonNegativeInteger=function(){return this.kind==NodeKind.INT32&&this.intValue>=0},Node.prototype.isDeclare=function(){return 0!=(this.flags&exports.NODE_FLAG_DECLARE)},Node.prototype.isLibrary=function(){return 0!=(this.flags&exports.NODE_FLAG_LIBRARY)},Node.prototype.isVirtual=function(){return 0!=(this.flags&exports.NODE_FLAG_VIRTUAL)},Node.prototype.isExport=function(){return 0!=(this.flags&exports.NODE_FLAG_EXPORT)},Node.prototype.isImport=function(){return 0!=(this.flags&exports.NODE_FLAG_IMPORT)},Node.prototype.isExternalImport=function(){return this.isDeclare()&&!this.isLibrary()},Node.prototype.isStart=function(){return 0!=(this.flags&exports.NODE_FLAG_START)},Node.prototype.isJavaScript=function(){return 0!=(this.flags&exports.NODE_FLAG_JAVASCRIPT)},Node.prototype.isStatic=function(){return 0!=(this.flags&exports.NODE_FLAG_STATIC)},Node.prototype.isAnyfunc=function(){return 0!=(this.flags&exports.NODE_FLAG_ANYFUNC)},Node.prototype.isDeclareOrJavaScript=function(){return 0!=(this.flags&(exports.NODE_FLAG_DECLARE|exports.NODE_FLAG_JAVASCRIPT))},Node.prototype.isDeclareOrExport=function(){return 0!=(this.flags&(exports.NODE_FLAG_DECLARE|exports.NODE_FLAG_EXPORT))},Node.prototype.isGet=function(){return 0!=(this.flags&exports.NODE_FLAG_GET)},Node.prototype.isSet=function(){return 0!=(this.flags&exports.NODE_FLAG_SET)},Node.prototype.isOperator=function(){return 0!=(this.flags&exports.NODE_FLAG_OPERATOR)},Node.prototype.isPositive=function(){return 0!=(this.flags&exports.NODE_FLAG_POSITIVE)},Node.prototype.isPrivate=function(){return 0!=(this.flags&exports.NODE_FLAG_PRIVATE)},Node.prototype.isUnsafe=function(){return 0!=(this.flags&exports.NODE_FLAG_UNSAFE)},Node.prototype.isGeneric=function(){return 0!=(this.flags&exports.NODE_FLAG_GENERIC)},Node.prototype.isTemplate=function(){return this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_IS_TEMPLATE)},Node.prototype.isUnsignedOperator=function(){return 0!=(this.flags&exports.NODE_FLAG_UNSIGNED_OPERATOR)},Node.prototype.childCount=function(){for(var count=0,child=this.firstChild;null!=child;)count+=1,child=child.nextSibling;return count},Node.prototype.parameterCount=function(){var count=0,child=this.firstChild;if(child.kind==NodeKind.PARAMETERS)for(child=child.firstChild;null!=child;)count+=1,child=child.nextSibling;return count},Node.prototype.hasParameters=function(){if(this.firstChild){var child=this.firstChild;if(child.kind==NodeKind.PARAMETERS)return child.childCount()>0}return!1},Node.prototype.appendChild=function(child){child.parent=this,null==this.firstChild?(this.firstChild=child,this.firstChild.offset=0):(child.previousSibling=this.lastChild,this.lastChild.nextSibling=child,child.offset=this.lastChild.offset+1),this.lastChild=child},Node.prototype.insertChildBefore=function(after,before){if(null!=before){if(assert_1.assert(before!=after),assert_1.assert(null==before.parent),assert_1.assert(null==before.previousSibling),assert_1.assert(null==before.nextSibling),assert_1.assert(null==after||after.parent==this),null==after)return void this.appendChild(before);before.parent=this,before.previousSibling=after.previousSibling,before.nextSibling=after,null!=after.previousSibling?(assert_1.assert(after==after.previousSibling.nextSibling),after.previousSibling.nextSibling=before):(assert_1.assert(after==this.firstChild),this.firstChild=before),after.previousSibling=before}},Node.prototype.insertChildAfter=function(before,after){if(null!=after){if(assert_1.assert(before!=after),assert_1.assert(null==after.parent),assert_1.assert(null==after.previousSibling),assert_1.assert(null==after.nextSibling),assert_1.assert(null==before||before.parent==this),null==before)return void this.appendChild(after);after.parent=this,after.previousSibling=before,after.nextSibling=before.nextSibling,null!=before.nextSibling&&(assert_1.assert(before==before.nextSibling.previousSibling),before.nextSibling.previousSibling=after),before.nextSibling=after}},Node.prototype.remove=function(){return assert_1.assert(null!=this.parent),null!=this.previousSibling?(assert_1.assert(this.previousSibling.nextSibling==this),this.previousSibling.nextSibling=this.nextSibling):(assert_1.assert(this.parent.firstChild==this),this.parent.firstChild=this.nextSibling),null!=this.nextSibling?(assert_1.assert(this.nextSibling.previousSibling==this),this.nextSibling.previousSibling=this.previousSibling):(assert_1.assert(this.parent.lastChild==this),this.parent.lastChild=this.previousSibling),this.parent=null,this.previousSibling=null,this.nextSibling=null,this},Node.prototype.removeChildren=function(){for(;null!=this.lastChild;)this.lastChild.remove()},Node.prototype.replaceWith=function(node){assert_1.assert(node!=this),assert_1.assert(null!=this.parent),assert_1.assert(null==node.parent),assert_1.assert(null==node.previousSibling),assert_1.assert(null==node.nextSibling),node.parent=this.parent,node.previousSibling=this.previousSibling,node.nextSibling=this.nextSibling,null!=this.previousSibling?(assert_1.assert(this.previousSibling.nextSibling==this),this.previousSibling.nextSibling=node):(assert_1.assert(this.parent.firstChild==this),this.parent.firstChild=node),null!=this.nextSibling?(assert_1.assert(this.nextSibling.previousSibling==this),this.nextSibling.previousSibling=node):(assert_1.assert(this.parent.lastChild==this),this.parent.lastChild=node),this.parent=null,this.previousSibling=null,this.nextSibling=null},Node.prototype.isType=function(){return this.kind==NodeKind.TYPE||this.kind==NodeKind.POINTER_TYPE||null!=this.symbol&&symbol_1.isType(this.symbol.kind)},Node.prototype.isCallValue=function(){return this.parent.kind==NodeKind.CALL&&this==this.parent.callValue()},Node.prototype.isAssignTarget=function(){return this.parent.kind==NodeKind.ASSIGN&&this==this.parent.binaryLeft()},Node.prototype.withRange=function(range){return this.range=range,this},Node.prototype.withInternalRange=function(range){return this.internalRange=range,this},Node.prototype.functionFirstArgument=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2);var child=this.firstChild;return child.kind==NodeKind.PARAMETERS&&(child=child.nextSibling),child},Node.prototype.functionLastArgument=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2);var child=this.firstChild;child.kind==NodeKind.PARAMETERS&&(child=child.nextSibling);for(var lastArgument=null;null!=child;){var nextChild=child.nextSibling;nextChild.kind!==NodeKind.VARIABLE?(lastArgument=child,child=null):child=nextChild}return lastArgument},Node.prototype.functionFirstArgumentIgnoringThis=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(null!=this.symbol);var child=this.functionFirstArgument();return this.symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE&&(child=child.nextSibling),child},Node.prototype.functionReturnType=function(){return assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(isExpression(this.lastChild.previousSibling)),this.lastChild.previousSibling},Node.prototype.constructorNode=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>0),assert_1.assert(this.resolvedType.symbol.node.kind==NodeKind.CLASS),this.resolvedType.symbol.node.constructorFunctionNode},Node.prototype.functionBody=function(){assert_1.assert(this.kind==NodeKind.FUNCTION),assert_1.assert(this.childCount()>=2),assert_1.assert(this.lastChild.kind==NodeKind.BLOCK||this.lastChild.kind==NodeKind.EMPTY);var body=this.lastChild;return body.kind==NodeKind.BLOCK?body:null},Node.prototype.newType=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.deleteType=function(){return assert_1.assert(this.kind==NodeKind.DELETE),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.callValue=function(){return assert_1.assert(this.kind==NodeKind.CALL),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.castValue=function(){return assert_1.assert(this.kind==NodeKind.CAST),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.castType=function(){return assert_1.assert(this.kind==NodeKind.CAST),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.alignOfType=function(){return assert_1.assert(this.kind==NodeKind.ALIGN_OF),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.sizeOfType=function(){return assert_1.assert(this.kind==NodeKind.SIZE_OF),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.dotTarget=function(){return assert_1.assert(this.kind==NodeKind.DOT),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.returnValue=function(){return assert_1.assert(this.kind==NodeKind.RETURN),assert_1.assert(this.childCount()<=1),assert_1.assert(null==this.firstChild||isExpression(this.firstChild)),this.firstChild},Node.prototype.ifReturnNode=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(null!==this.firstChild),assert_1.assert(null!==this.firstChild.nextSibling),this.firstChild.nextSibling.returnNode||null},Node.prototype.deleteValue=function(){return assert_1.assert(this.kind==NodeKind.DELETE),assert_1.assert(this.childCount()<=1),assert_1.assert(null==this.firstChild||isExpression(this.firstChild)),this.firstChild},Node.prototype.extendsType=function(){return assert_1.assert(this.kind==NodeKind.EXTENDS),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.firstGenericType=function(){return assert_1.assert(this.firstChild.kind==NodeKind.PARAMETERS),assert_1.assert(this.firstChild.childCount()>0),this.firstChild.firstChild},Node.prototype.variableType=function(){assert_1.assert(this.kind==NodeKind.VARIABLE),assert_1.assert(this.childCount()<=2),assert_1.assert(isExpression(this.firstChild)||this.firstChild.kind==NodeKind.EMPTY);var type=this.firstChild;return type.kind!=NodeKind.EMPTY?type:null},Node.prototype.variableValue=function(){return assert_1.assert(this.kind==NodeKind.VARIABLE),assert_1.assert(this.childCount()<=2),assert_1.assert(null==this.firstChild.nextSibling||isExpression(this.firstChild.nextSibling)),this.firstChild.nextSibling},Node.prototype.hasVariableValue=function(){return assert_1.assert(this.kind==NodeKind.VARIABLE),void 0!=this.firstChild&&void 0!=this.firstChild.nextSibling},Node.prototype.expressionValue=function(){return assert_1.assert(this.kind==NodeKind.EXPRESSION),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.binaryLeft=function(){return assert_1.assert(isBinary(this.kind)),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.binaryRight=function(){return assert_1.assert(isBinary(this.kind)),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.unaryValue=function(){return assert_1.assert(isUnary(this.kind)),assert_1.assert(1==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.pointer=function(){return assert_1.assert(this.kind==NodeKind.POINTER_INDEX),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.pointerOffset=function(){return assert_1.assert(this.firstChild),assert_1.assert(this.firstChild.nextSibling),this.firstChild.nextSibling.intValue},Node.prototype.whileValue=function(){return assert_1.assert(this.kind==NodeKind.WHILE),assert_1.assert(2==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.whileBody=function(){return assert_1.assert(this.kind==NodeKind.WHILE),assert_1.assert(2==this.childCount()),assert_1.assert(this.lastChild.kind==NodeKind.BLOCK),this.lastChild},Node.prototype.hookValue=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.hookTrue=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.firstChild.nextSibling)),this.firstChild.nextSibling},Node.prototype.hookFalse=function(){return assert_1.assert(this.kind==NodeKind.HOOK),assert_1.assert(3==this.childCount()),assert_1.assert(isExpression(this.lastChild)),this.lastChild},Node.prototype.indexTarget=function(){return assert_1.assert(this.kind==NodeKind.INDEX),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.ifValue=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(isExpression(this.firstChild)),this.firstChild},Node.prototype.ifTrue=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(this.firstChild.nextSibling.kind==NodeKind.BLOCK),this.firstChild.nextSibling},Node.prototype.ifFalse=function(){return assert_1.assert(this.kind==NodeKind.IF),assert_1.assert(2==this.childCount()||3==this.childCount()),assert_1.assert(null==this.firstChild.nextSibling.nextSibling||this.firstChild.nextSibling.nextSibling.kind==NodeKind.BLOCK),this.firstChild.nextSibling.nextSibling||null},Node.prototype.expandCallIntoOperatorTree=function(){if(this.kind!=NodeKind.CALL)return!1;var value=this.callValue(),symbol=value.symbol;if(value.kind==NodeKind.DOT&&symbol.node.isOperator()&&symbol.node.isDeclare()){var binaryKind=NodeKind.NULL;if("%"==symbol.name?binaryKind=NodeKind.REMAINDER:"&"==symbol.name?binaryKind=NodeKind.BITWISE_AND:"*"==symbol.name?binaryKind=NodeKind.MULTIPLY:"**"==symbol.name?binaryKind=NodeKind.EXPONENT:"/"==symbol.name?binaryKind=NodeKind.DIVIDE:"<"==symbol.name?binaryKind=NodeKind.LESS_THAN:"<<"==symbol.name?binaryKind=NodeKind.SHIFT_LEFT:"=="==symbol.name?binaryKind=NodeKind.EQUAL:">"==symbol.name?binaryKind=NodeKind.GREATER_THAN:">>"==symbol.name?binaryKind=NodeKind.SHIFT_RIGHT:"[]"==symbol.name?binaryKind=NodeKind.INDEX:"^"==symbol.name?binaryKind=NodeKind.BITWISE_XOR:"|"==symbol.name&&(binaryKind=NodeKind.BITWISE_OR),binaryKind!=NodeKind.NULL)return this.kind=binaryKind,value.remove(),this.insertChildBefore(this.firstChild,value.dotTarget().remove()),!0;if("[]="==symbol.name){this.kind=NodeKind.ASSIGN;var target=createIndex(value.remove().dotTarget().remove());return target.appendChild(this.firstChild.remove()),this.insertChildBefore(this.firstChild,target),!0}}return!1},Node.prototype.arrayLength=function(){return assert_1.assert(this.kind==NodeKind.NEW),assert_1.assert(this.childCount()>=1),assert_1.assert(isExpression(this.firstChild)),assert_1.assert(this.firstChild.resolvedType.isArray()),this.firstChild.nextSibling},Node}();exports.Node=Node,exports.createNew=createNew,exports.createDelete=createDelete,exports.createHook=createHook,exports.createIndex=createIndex,exports.createNull=createNull,exports.createUndefined=createUndefined,exports.createThis=createThis,exports.createAddressOf=createAddressOf,exports.createDereference=createDereference,exports.createAlignOf=createAlignOf,exports.createSizeOf=createSizeOf,exports.createboolean=createboolean,exports.createInt=createInt,exports.createLong=createLong,exports.createFloat=createFloat,exports.createDouble=createDouble,exports.createString=createString,exports.createArray=createArray,exports.createName=createName,exports.createType=createType,exports.createAny=createAny,exports.createEmpty=createEmpty,exports.createExpression=createExpression,exports.createBlock=createBlock,exports.createModule=createModule,exports.createClass=createClass,exports.createEnum=createEnum,exports.createIf=createIf,exports.createWhile=createWhile,exports.createReturn=createReturn,exports.createImports=createImports,exports.createImport=createImport,exports.createImportFrom=createImportFrom,exports.createVariables=createVariables,exports.createConstants=createConstants,exports.createParameters=createParameters,exports.createExtends=createExtends,exports.createImplements=createImplements,exports.createParameter=createParameter,exports.createVariable=createVariable,exports.createFunction=createFunction,exports.createUnary=createUnary,exports.createBinary=createBinary,exports.createCall=createCall,exports.createCast=createCast,exports.createDot=createDot,exports.createSymbolReference=createSymbolReference,exports.createMemberReference=createMemberReference,exports.createParseError=createParseError,exports.createJSNumber=createJSNumber,exports.createJSObject=createJSObject,exports.createJSString=createJSString,exports.createJSArray=createJSArray},function(module,exports,__webpack_require__){"use strict";function toHex(value,size){if(void 0===size&&(size=7),void 0==value||null==value)return"";for(var hex=value.toString(16),zero=[],i=0;i0&&0==(value&value-1)}function alignToNextMultipleOf(offset,alignment){return assert_1.assert(isPositivePowerOf2(alignment)),offset+alignment-1&-alignment}Object.defineProperty(exports,"__esModule",{value:!0});var assert_1=__webpack_require__(0);exports.toHex=toHex,exports.isPositivePowerOf2=isPositivePowerOf2,exports.alignToNextMultipleOf=alignToNextMultipleOf},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmType;!function(WasmType){WasmType[WasmType.VOID=0]="VOID",WasmType[WasmType.I32=127]="I32",WasmType[WasmType.I64=126]="I64",WasmType[WasmType.F32=125]="F32",WasmType[WasmType.F64=124]="F64",WasmType[WasmType.anyfunc=112]="anyfunc",WasmType[WasmType.func=96]="func",WasmType[WasmType.block_type=64]="block_type"}(WasmType=exports.WasmType||(exports.WasmType={}));var WasmWrappedType=function(){function WasmWrappedType(){}return WasmWrappedType}();exports.WasmWrappedType=WasmWrappedType;var idTostring={};idTostring[WasmType.VOID]="void",idTostring[WasmType.I32]="i32",idTostring[WasmType.I64]="i64",idTostring[WasmType.F32]="f32",idTostring[WasmType.F64]="f64",exports.WasmTypeToString=idTostring},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WasmOpcode={UNREACHABLE:0,NOP:1,BLOCK:2,LOOP:3,IF:4,IF_ELSE:5,END:11,BR:12,BR_IF:13,BR_TABLE:14,RETURN:15,CALL:16,CALL_INDIRECT:17,DROP:26,SELECT:27,GET_LOCAL:32,SET_LOCAL:33,TEE_LOCAL:34,GET_GLOBAL:35,SET_GLOBAL:36,I32_LOAD:40,I64_LOAD:41,F32_LOAD:42,F64_LOAD:43,I32_LOAD8_S:44,I32_LOAD8_U:45,I32_LOAD16_S:46,I32_LOAD16_U:47,I64_LOAD8_S:48,I64_LOAD8_U:49,I64_LOAD16_S:50,I64_LOAD16_U:51,I64_LOAD32_S:52,I64_LOAD32_U:53,I32_STORE:54,I64_STORE:55,F32_STORE:56,F64_STORE:57,I32_STORE8:58,I32_STORE16:59,I64_STORE8:60,I64_STORE16:61,I64_STORE32:62,MEMORY_SIZE:63,GROW_MEMORY:64,I32_CONST:65,I64_CONST:66,F32_CONST:67,F64_CONST:68,I32_EQZ:69,I32_EQ:70,I32_NE:71,I32_LT_S:72,I32_LT_U:73,I32_GT_S:74,I32_GT_U:75,I32_LE_S:76,I32_LE_U:77,I32_GE_S:78,I32_GE_U:79,I64_EQZ:80,I64_EQ:81,I64_NE:82,I64_LT_S:83,I64_LT_U:84,I64_GT_S:85,I64_GT_U:86,I64_LE_S:87,I64_LE_U:88,I64_GE_S:89,I64_GE_U:90,F32_EQ:91,F32_NE:92,F32_LT:93,F32_GT:94,F32_LE:95,F32_GE:96,F64_EQ:97,F64_NE:98,F64_LT:99,F64_GT:100,F64_LE:101,F64_GE:102,I32_CLZ:103,I32_CTZ:104,I32_POPCNT:105,I32_ADD:106,I32_SUB:107,I32_MUL:108,I32_DIV_S:109,I32_DIV_U:110,I32_REM_S:111,I32_REM_U:112,I32_AND:113,I32_OR:114,I32_XOR:115,I32_SHL:116,I32_SHR_S:117,I32_SHR_U:118,I32_ROTL:119,I32_ROTR:120,I64_CLZ:121,I64_CTZ:122,I64_POPCNT:123,I64_ADD:124,I64_SUB:125,I64_MUL:126,I64_DIV_S:127,I64_DIV_U:128,I64_REM_S:129,I64_REM_U:130,I64_AND:131,I64_OR:132,I64_XOR:133,I64_SHL:134,I64_SHR_S:135,I64_SHR_U:136,I64_ROTL:137,I64_ROTR:138,F32_ABS:139,F32_NEG:140,F32_CEIL:141,F32_FLOOR:142,F32_TRUNC:143,F32_NEAREST:144,F32_SQRT:145,F32_ADD:146,F32_SUB:147,F32_MUL:148,F32_DIV:149,F32_MIN:150,F32_MAX:151,F32_COPYSIGN:152,F64_ABS:153,F64_NEG:154,F64_CEIL:155,F64_FLOOR:156,F64_TRUNC:157,F64_NEAREST:158,F64_SQRT:159,F64_ADD:160,F64_SUB:161,F64_MUL:162,F64_DIV:163,F64_MIN:164,F64_MAX:165,F64_COPYSIGN:166,I32_WRAP_I64:167,I32_TRUNC_S_F32:168,I32_TRUNC_U_F32:169,I32_TRUNC_S_F64:170,I32_TRUNC_U_F64:171,I64_EXTEND_S_I32:172,I64_EXTEND_U_I32:173,I64_TRUNC_S_F32:174,I64_TRUNC_U_F32:175,I64_TRUNC_S_F64:176,I64_TRUNC_U_F64:177,F32_CONVERT_S_I32:178,F32_CONVERT_U_I32:179,F32_CONVERT_S_I64:180,F32_CONVERT_U_I64:181,F32_DEMOTE_F64:182,F64_CONVERT_S_I32:183,F64_CONVERT_U_I32:184,F64_CONVERT_S_I64:185,F64_CONVERT_U_I64:186,F64_PROMOTE_F32:187,I32_REINTERPRET_F32:188,I64_REINTERPRET_F64:189,F32_REINTERPRET_I32:190,F64_REINTERPRET_I64:191},exports.WasmOpcode[exports.WasmOpcode.UNREACHABLE]="unreachable",exports.WasmOpcode[exports.WasmOpcode.NOP]="nop",exports.WasmOpcode[exports.WasmOpcode.BLOCK]="block",exports.WasmOpcode[exports.WasmOpcode.LOOP]="loop",exports.WasmOpcode[exports.WasmOpcode.IF]="if",exports.WasmOpcode[exports.WasmOpcode.IF_ELSE]="else",exports.WasmOpcode[exports.WasmOpcode.END]="end",exports.WasmOpcode[exports.WasmOpcode.BR]="br",exports.WasmOpcode[exports.WasmOpcode.BR_IF]="br_if",exports.WasmOpcode[exports.WasmOpcode.BR_TABLE]="br_table",exports.WasmOpcode[exports.WasmOpcode.RETURN]="return",exports.WasmOpcode[exports.WasmOpcode.CALL]="call",exports.WasmOpcode[exports.WasmOpcode.CALL_INDIRECT]="call_indirect",exports.WasmOpcode[exports.WasmOpcode.DROP]="drop",exports.WasmOpcode[exports.WasmOpcode.SELECT]="select",exports.WasmOpcode[exports.WasmOpcode.GET_LOCAL]="get_local",exports.WasmOpcode[exports.WasmOpcode.SET_LOCAL]="set_local",exports.WasmOpcode[exports.WasmOpcode.TEE_LOCAL]="tee_local",exports.WasmOpcode[exports.WasmOpcode.GET_GLOBAL]="get_global",exports.WasmOpcode[exports.WasmOpcode.SET_GLOBAL]="set_global",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD]="i32.load",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD]="i64.load",exports.WasmOpcode[exports.WasmOpcode.F32_LOAD]="f32.load",exports.WasmOpcode[exports.WasmOpcode.F64_LOAD]="f64.load",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD8_S]="i32.load8_s",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD8_U]="i32_load8_u",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD16_S]="i32_load16_s",exports.WasmOpcode[exports.WasmOpcode.I32_LOAD16_U]="i32_load16_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD8_S]="i64.load8_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD8_U]="i64.load8_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD16_S]="i64.load16_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD16_U]="i64.load16_u",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD32_S]="i64.load32_s",exports.WasmOpcode[exports.WasmOpcode.I64_LOAD32_U]="i64.load32_u",exports.WasmOpcode[exports.WasmOpcode.I32_STORE]="i32.store",exports.WasmOpcode[exports.WasmOpcode.I64_STORE]="i64.store",exports.WasmOpcode[exports.WasmOpcode.F32_STORE]="f32.store",exports.WasmOpcode[exports.WasmOpcode.F64_STORE]="f64.store",exports.WasmOpcode[exports.WasmOpcode.I32_STORE8]="i32.store8",exports.WasmOpcode[exports.WasmOpcode.I32_STORE16]="i32.store16",exports.WasmOpcode[exports.WasmOpcode.I64_STORE8]="i64.store8",exports.WasmOpcode[exports.WasmOpcode.I64_STORE16]="i64.store16",exports.WasmOpcode[exports.WasmOpcode.I64_STORE32]="i64.store32",exports.WasmOpcode[exports.WasmOpcode.MEMORY_SIZE]="current_memory",exports.WasmOpcode[exports.WasmOpcode.GROW_MEMORY]="grow_memory",exports.WasmOpcode[exports.WasmOpcode.I32_CONST]="i32.const",exports.WasmOpcode[exports.WasmOpcode.I64_CONST]="i64.const",exports.WasmOpcode[exports.WasmOpcode.F32_CONST]="f32.const",exports.WasmOpcode[exports.WasmOpcode.F64_CONST]="f64.const",exports.WasmOpcode[exports.WasmOpcode.I32_EQZ]="i32.eqz",exports.WasmOpcode[exports.WasmOpcode.I32_EQ]="i32.eq",exports.WasmOpcode[exports.WasmOpcode.I32_NE]="i32.ne",exports.WasmOpcode[exports.WasmOpcode.I32_LT_S]="i32.lt_s",exports.WasmOpcode[exports.WasmOpcode.I32_LT_U]="i32.lt_u",exports.WasmOpcode[exports.WasmOpcode.I32_GT_S]="i32.gt_s",exports.WasmOpcode[exports.WasmOpcode.I32_GT_U]="i32.gt_u",exports.WasmOpcode[exports.WasmOpcode.I32_LE_S]="i32.le_s",exports.WasmOpcode[exports.WasmOpcode.I32_LE_U]="i32.le_u",exports.WasmOpcode[exports.WasmOpcode.I32_GE_S]="i32.ge_s",exports.WasmOpcode[exports.WasmOpcode.I32_GE_U]="i32.ge_u",exports.WasmOpcode[exports.WasmOpcode.I64_EQZ]="i64.eqz",exports.WasmOpcode[exports.WasmOpcode.I64_EQ]="i64.eq",exports.WasmOpcode[exports.WasmOpcode.I64_NE]="i64.ne",exports.WasmOpcode[exports.WasmOpcode.I64_LT_S]="i64.lt_s",exports.WasmOpcode[exports.WasmOpcode.I64_LT_U]="i64.lt_u",exports.WasmOpcode[exports.WasmOpcode.I64_GT_S]="i64.gt_s",exports.WasmOpcode[exports.WasmOpcode.I64_GT_U]="i64.gt_u",exports.WasmOpcode[exports.WasmOpcode.I64_LE_S]="i64.le_s",exports.WasmOpcode[exports.WasmOpcode.I64_LE_U]="i64.le_u",exports.WasmOpcode[exports.WasmOpcode.I64_GE_S]="i64.ge_s",exports.WasmOpcode[exports.WasmOpcode.I64_GE_U]="i64.ge_u",exports.WasmOpcode[exports.WasmOpcode.F32_EQ]="f32.eq",exports.WasmOpcode[exports.WasmOpcode.F32_NE]="f32.ne",exports.WasmOpcode[exports.WasmOpcode.F32_LT]="f32.lt",exports.WasmOpcode[exports.WasmOpcode.F32_GT]="f32.gt",exports.WasmOpcode[exports.WasmOpcode.F32_LE]="f32.le",exports.WasmOpcode[exports.WasmOpcode.F32_GE]="f32.ge",exports.WasmOpcode[exports.WasmOpcode.F64_EQ]="f64.eq",exports.WasmOpcode[exports.WasmOpcode.F64_NE]="f64.ne",exports.WasmOpcode[exports.WasmOpcode.F64_LT]="f64.lt",exports.WasmOpcode[exports.WasmOpcode.F64_GT]="f64.gt",exports.WasmOpcode[exports.WasmOpcode.F64_LE]="f64.le",exports.WasmOpcode[exports.WasmOpcode.F64_GE]="f64.ge",exports.WasmOpcode[exports.WasmOpcode.I32_CLZ]="i32.clz",exports.WasmOpcode[exports.WasmOpcode.I32_CTZ]="i32.ctz",exports.WasmOpcode[exports.WasmOpcode.I32_POPCNT]="i32.popcnt",exports.WasmOpcode[exports.WasmOpcode.I32_ADD]="i32.add",exports.WasmOpcode[exports.WasmOpcode.I32_SUB]="i32.sub",exports.WasmOpcode[exports.WasmOpcode.I32_MUL]="i32.mul",exports.WasmOpcode[exports.WasmOpcode.I32_DIV_S]="i32.div_s",exports.WasmOpcode[exports.WasmOpcode.I32_DIV_U]="i32.div_u",exports.WasmOpcode[exports.WasmOpcode.I32_REM_S]="i32.rem_s",exports.WasmOpcode[exports.WasmOpcode.I32_REM_U]="i32.rem_u",exports.WasmOpcode[exports.WasmOpcode.I32_AND]="i32.and",exports.WasmOpcode[exports.WasmOpcode.I32_OR]="i32.or",exports.WasmOpcode[exports.WasmOpcode.I32_XOR]="i32.xor",exports.WasmOpcode[exports.WasmOpcode.I32_SHL]="i32.shl",exports.WasmOpcode[exports.WasmOpcode.I32_SHR_S]="i32.shr_s",exports.WasmOpcode[exports.WasmOpcode.I32_SHR_U]="i32.shr_u",exports.WasmOpcode[exports.WasmOpcode.I32_ROTL]="i32.rotl",exports.WasmOpcode[exports.WasmOpcode.I32_ROTR]="i32.rotr",exports.WasmOpcode[exports.WasmOpcode.I64_CLZ]="i64.clz",exports.WasmOpcode[exports.WasmOpcode.I64_CTZ]="i64.ctz",exports.WasmOpcode[exports.WasmOpcode.I64_POPCNT]="i64.popcnt",exports.WasmOpcode[exports.WasmOpcode.I64_ADD]="i64.add",exports.WasmOpcode[exports.WasmOpcode.I64_SUB]="i64.sub",exports.WasmOpcode[exports.WasmOpcode.I64_MUL]="i64.mul",exports.WasmOpcode[exports.WasmOpcode.I64_DIV_S]="i64.div_s",exports.WasmOpcode[exports.WasmOpcode.I64_DIV_U]="i64.div_u",exports.WasmOpcode[exports.WasmOpcode.I64_REM_S]="i64.rem_s",exports.WasmOpcode[exports.WasmOpcode.I64_REM_U]="i64.rem_u",exports.WasmOpcode[exports.WasmOpcode.I64_AND]="i64.and",exports.WasmOpcode[exports.WasmOpcode.I64_OR]="i64.or",exports.WasmOpcode[exports.WasmOpcode.I64_XOR]="i64.xor",exports.WasmOpcode[exports.WasmOpcode.I64_SHL]="i64.shl",exports.WasmOpcode[exports.WasmOpcode.I64_SHR_S]="i64.shr_s",exports.WasmOpcode[exports.WasmOpcode.I64_SHR_U]="i64.shr_u",exports.WasmOpcode[exports.WasmOpcode.I64_ROTL]="i64.rotl",exports.WasmOpcode[exports.WasmOpcode.I64_ROTR]="i64.rotr",exports.WasmOpcode[exports.WasmOpcode.F32_ABS]="f32.abs",exports.WasmOpcode[exports.WasmOpcode.F32_NEG]="f32.neg",exports.WasmOpcode[exports.WasmOpcode.F32_CEIL]="f32.ceil",exports.WasmOpcode[exports.WasmOpcode.F32_FLOOR]="f32.floor",exports.WasmOpcode[exports.WasmOpcode.F32_TRUNC]="f32.trunc",exports.WasmOpcode[exports.WasmOpcode.F32_NEAREST]="f32.nearest",exports.WasmOpcode[exports.WasmOpcode.F32_SQRT]="f32.sqrt",exports.WasmOpcode[exports.WasmOpcode.F32_ADD]="f32.add",exports.WasmOpcode[exports.WasmOpcode.F32_SUB]="f32.sub",exports.WasmOpcode[exports.WasmOpcode.F32_MUL]="f32.mul",exports.WasmOpcode[exports.WasmOpcode.F32_DIV]="f32.div",exports.WasmOpcode[exports.WasmOpcode.F32_MIN]="f32.min",exports.WasmOpcode[exports.WasmOpcode.F32_MAX]="f32.max",exports.WasmOpcode[exports.WasmOpcode.F32_COPYSIGN]="f32.copysign",exports.WasmOpcode[exports.WasmOpcode.F64_ABS]="f64.abs",exports.WasmOpcode[exports.WasmOpcode.F64_NEG]="f64.neg",exports.WasmOpcode[exports.WasmOpcode.F64_CEIL]="f64.ceil",exports.WasmOpcode[exports.WasmOpcode.F64_FLOOR]="f64.floor",exports.WasmOpcode[exports.WasmOpcode.F64_TRUNC]="f64.trunc",exports.WasmOpcode[exports.WasmOpcode.F64_NEAREST]="f64.nearest",exports.WasmOpcode[exports.WasmOpcode.F64_SQRT]="f64.sqrt",exports.WasmOpcode[exports.WasmOpcode.F64_ADD]="f64.add",exports.WasmOpcode[exports.WasmOpcode.F64_SUB]="f64.sub",exports.WasmOpcode[exports.WasmOpcode.F64_MUL]="f64.mul",exports.WasmOpcode[exports.WasmOpcode.F64_DIV]="f64.div",exports.WasmOpcode[exports.WasmOpcode.F64_MIN]="f64.min",exports.WasmOpcode[exports.WasmOpcode.F64_MAX]="f64.max",exports.WasmOpcode[exports.WasmOpcode.F64_COPYSIGN]="f64.copysign",exports.WasmOpcode[exports.WasmOpcode.I32_WRAP_I64]="i32.wrap/i64",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_S_F32]="i32.trunc_s/f32",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_U_F32]="i32.trunc_u/f32",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_S_F64]="i32.trunc_s/f64",exports.WasmOpcode[exports.WasmOpcode.I32_TRUNC_U_F64]="i32.trunc_u/f64",exports.WasmOpcode[exports.WasmOpcode.I64_EXTEND_S_I32]="i64.extend_s/i32",exports.WasmOpcode[exports.WasmOpcode.I64_EXTEND_U_I32]="i64.extend_u/i32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_S_F32]="i64.trunc_s/f32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_U_F32]="i64.trunc_u/f32",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_S_F64]="i64.trunc_s/f64",exports.WasmOpcode[exports.WasmOpcode.I64_TRUNC_U_F64]="i64.trunc_u/f64",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_S_I32]="f32.convert_s/i32",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_U_I32]="f32.convert_u/i32",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_S_I64]="f32.convert_s/i64",exports.WasmOpcode[exports.WasmOpcode.F32_CONVERT_U_I64]="f32.convert_u/i64",exports.WasmOpcode[exports.WasmOpcode.F32_DEMOTE_F64]="f32.demote/f64",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_S_I32]="f64.convert_s/i32",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_U_I32]="f64.convert_u/i32",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_S_I64]="f64.convert_s/i64",exports.WasmOpcode[exports.WasmOpcode.F64_CONVERT_U_I64]="f64.convert_u/i64",exports.WasmOpcode[exports.WasmOpcode.F64_PROMOTE_F32]="f64.promote/f32",exports.WasmOpcode[exports.WasmOpcode.I32_REINTERPRET_F32]="i32.reinterpret/f32",exports.WasmOpcode[exports.WasmOpcode.I64_REINTERPRET_F64]="i64.reinterpret/f64",exports.WasmOpcode[exports.WasmOpcode.F32_REINTERPRET_I32]="f32.reinterpret/i32",exports.WasmOpcode[exports.WasmOpcode.F64_REINTERPRET_I64]="f64.reinterpret/i64",Object.freeze(exports.WasmOpcode)},function(module,exports,__webpack_require__){"use strict";function isKeyword(kind){return kind>=TokenKind.ALIGNOF&&kind<=TokenKind.WHILE}function splitToken(first,firstKind,secondKind){var range=first.range;assert_1.assert(range.end-range.start>=2);var second=new Token;second.kind=secondKind,second.range=log_1.createRange(range.source,range.start+1,range.end),second.next=first.next,first.kind=firstKind,first.next=second,range.end=range.start+1}function tokenToString(token){return token==TokenKind.END_OF_FILE?"end of file":token==TokenKind.CHARACTER?"character literal":token==TokenKind.IDENTIFIER?"identifier":token==TokenKind.INT32?"integer32 literal":token==TokenKind.INT64?"integer64 literal":token==TokenKind.FLOAT32?"float32 literal":token==TokenKind.FLOAT64?"float64 literal":token==TokenKind.STRING?"string literal":token==TokenKind.ARRAY?"array literal":token==TokenKind.ASSIGN?"'='":token==TokenKind.BITWISE_AND?"'&'":token==TokenKind.BITWISE_OR?"'|'":token==TokenKind.BITWISE_XOR?"'^'":token==TokenKind.COLON?"':'":token==TokenKind.COMMA?"','":token==TokenKind.COMPLEMENT?"'~'":token==TokenKind.DIVIDE?"'/'":token==TokenKind.DOT?"'.'":token==TokenKind.EQUAL?"'=='":token==TokenKind.EXPONENT?"'**'":token==TokenKind.GREATER_THAN?"'>'":token==TokenKind.GREATER_THAN_EQUAL?"'>='":token==TokenKind.LEFT_BRACE?"'{'":token==TokenKind.LEFT_BRACKET?"'['":token==TokenKind.LEFT_PARENTHESIS?"'('":token==TokenKind.LESS_THAN?"'<'":token==TokenKind.LESS_THAN_EQUAL?"'<='":token==TokenKind.LOGICAL_AND?"'&&'":token==TokenKind.LOGICAL_OR?"'||'":token==TokenKind.MINUS?"'-'":token==TokenKind.MINUS_MINUS?"'--'":token==TokenKind.MULTIPLY?"'*'":token==TokenKind.NOT?"'!'":token==TokenKind.NOT_EQUAL?"'!='":token==TokenKind.PLUS?"'+'":token==TokenKind.PLUS_PLUS?"'++'":token==TokenKind.QUESTION_MARK?"'?'":token==TokenKind.REMAINDER?"'%'":token==TokenKind.RIGHT_BRACE?"'}'":token==TokenKind.RIGHT_BRACKET?"']'":token==TokenKind.RIGHT_PARENTHESIS?"')'":token==TokenKind.SEMICOLON?"';'":token==TokenKind.SHIFT_LEFT?"'<<'":token==TokenKind.SHIFT_RIGHT?"'>>'":token==TokenKind.FROM?"'from'":token==TokenKind.ALIGNOF?"'alignof'":token==TokenKind.AS?"'as'":token==TokenKind.BREAK?"'break'":token==TokenKind.MODULE?"'module'":token==TokenKind.CLASS?"'class'":token==TokenKind.CONST?"'const'":token==TokenKind.CONTINUE?"'continue'":token==TokenKind.DECLARE?"'declare'":token==TokenKind.ELSE?"'else'":token==TokenKind.ENUM?"'enum'":token==TokenKind.EXPORT?"'export'":token==TokenKind.EXTENDS?"'extends'":token==TokenKind.FALSE?"'false'":token==TokenKind.FUNCTION?"'function'":token==TokenKind.ANYFUNC?"'anyfunc'":token==TokenKind.IF?"'if'":token==TokenKind.IMPLEMENTS?"'implements'":token==TokenKind.IMPORT?"'import'":token==TokenKind.LET?"'let'":token==TokenKind.NEW?"'new'":token==TokenKind.DELETE?"'delete'":token==TokenKind.NULL?"'null'":token==TokenKind.UNDEFINED?"'undefined'":token==TokenKind.OPERATOR?"'operator'":token==TokenKind.PRIVATE?"'private'":token==TokenKind.PROTECTED?"'protected'":token==TokenKind.PUBLIC?"'public'":token==TokenKind.RETURN?"'return'":token==TokenKind.SIZEOF?"'sizeof'":token==TokenKind.STATIC?"'static'":token==TokenKind.THIS?"'this'":token==TokenKind.TRUE?"'true'":token==TokenKind.UNSAFE?"'unsafe'":token==TokenKind.JAVASCRIPT?"'@JS'":token==TokenKind.START?"'@start'":token==TokenKind.VIRTUAL?"'@virtual'":token==TokenKind.VAR?"'var'":token==TokenKind.WHILE?"'while'":token==TokenKind.PREPROCESSOR_DEFINE?"'#define'":token==TokenKind.PREPROCESSOR_ELIF?"'#elif'":token==TokenKind.PREPROCESSOR_ELSE?"'#else'":token==TokenKind.PREPROCESSOR_ENDIF?"'#endif'":token==TokenKind.PREPROCESSOR_ERROR?"'#error'":token==TokenKind.PREPROCESSOR_IF?"'#if'":token==TokenKind.PREPROCESSOR_NEWLINE?"newline":token==TokenKind.PREPROCESSOR_UNDEF?"'#undef'":token==TokenKind.PREPROCESSOR_WARNING?"'#warning'":(assert_1.assert(!1),null)}function isAlpha(c){return c>="a"&&c<="z"||c>="A"&&c<="Z"||"_"==c}function isASCII(c){return c>=32&&c<=126}function isNumber(c){return c>="0"&&c<="9"}function isDigit(c,base){return""!=c.trim()&&(16==base?isNumber(c)||c>="A"&&c<="F"||c>="a"&&c<="f":!isNaN(c))}function tokenize(source,log){for(var first=null,last=null,contents=source.contents,limit=contents.length,needsPreprocessor=!1,wantNewline=!1,i=0;i=2&&length<=10){var text=contents.slice(start,i);2==length?"as"==text?kind=TokenKind.AS:"if"==text&&(kind=TokenKind.IF):3==length?"let"==text?kind=TokenKind.LET:"new"==text?kind=TokenKind.NEW:"var"==text?kind=TokenKind.VAR:"@JS"==text&&(kind=TokenKind.JAVASCRIPT):4==length?"else"==text?kind=TokenKind.ELSE:"enum"==text?kind=TokenKind.ENUM:"null"==text?kind=TokenKind.NULL:"this"==text?kind=TokenKind.THIS:"true"==text?kind=TokenKind.TRUE:"from"==text&&(kind=TokenKind.FROM):5==length?"break"==text?kind=TokenKind.BREAK:"class"==text?kind=TokenKind.CLASS:"const"==text?kind=TokenKind.CONST:"false"==text?kind=TokenKind.FALSE:"while"==text&&(kind=TokenKind.WHILE):6==length?"export"==text?kind=TokenKind.EXPORT:"module"==text?kind=TokenKind.MODULE:"import"==text?kind=TokenKind.IMPORT:"public"==text?kind=TokenKind.PUBLIC:"return"==text?kind=TokenKind.RETURN:"sizeof"==text?kind=TokenKind.SIZEOF:"static"==text?kind=TokenKind.STATIC:"unsafe"==text?kind=TokenKind.UNSAFE:"@start"==text?kind=TokenKind.START:"delete"==text&&(kind=TokenKind.DELETE):7==length?"alignof"==text?kind=TokenKind.ALIGNOF:"declare"==text?kind=TokenKind.DECLARE:"extends"==text?kind=TokenKind.EXTENDS:"private"==text?kind=TokenKind.PRIVATE:"anyfunc"==text&&(kind=TokenKind.ANYFUNC):"continue"==text?kind=TokenKind.CONTINUE:"@virtual"==text?kind=TokenKind.VIRTUAL:"function"==text?kind=TokenKind.FUNCTION:"implements"==text?kind=TokenKind.IMPLEMENTS:"protected"==text&&(kind=TokenKind.PROTECTED)}}else if(isNumber(c)){var isFloat=!1;if(i"==c)kind=TokenKind.GREATER_THAN,i"==c?(kind=TokenKind.SHIFT_RIGHT,i+=1):"="==c&&(kind=TokenKind.GREATER_THAN_EQUAL,i+=1));else if("#"==c){for(;i=end&&"\n"!=contents[j];)j-=1;j0&&dot>forward&&dot>backward&&(path=path.slice(0,dot)),path+extension}Object.defineProperty(exports,"__esModule",{value:!0});var type_checker_1=__webpack_require__(46),node_1=__webpack_require__(5),log_1=__webpack_require__(2),preprocessor_1=__webpack_require__(51),scope_1=__webpack_require__(17),scanner_1=__webpack_require__(9),parser_1=__webpack_require__(19),shaking_1=__webpack_require__(49),webassembly_1=__webpack_require__(45),library_1=__webpack_require__(53),preparser_1=__webpack_require__(50),compile_target_1=__webpack_require__(4),assert_1=__webpack_require__(0),terminal_1=__webpack_require__(1),Compiler=function(){function Compiler(){}return Compiler.prototype.initialize=function(target,outputName){assert_1.assert(null==this.log),this.log=new log_1.Log,this.preprocessor=new preprocessor_1.Preprocessor,this.target=target,this.outputName=outputName,this.librarySource=this.addInput("",library_1.Library.get(target)),this.librarySource.isLibrary=!0,this.runtimeSource=library_1.Library.getRuntime(target),this.wrapperSource=library_1.Library.getWrapper(target),this.createGlobals(),target==compile_target_1.CompileTarget.CPP?this.preprocessor.define("CPP",!0):target==compile_target_1.CompileTarget.JAVASCRIPT?this.preprocessor.define("JS",!0):target==compile_target_1.CompileTarget.WEBASSEMBLY&&this.preprocessor.define("WASM",!0)},Compiler.prototype.createGlobals=function(){var context=new type_checker_1.CheckContext;context.log=this.log,context.target=this.target,context.pointerByteSize=4;var global=new node_1.Node;global.kind=node_1.NodeKind.GLOBAL;var scope=new scope_1.Scope;global.scope=scope,context.anyType=scope.defineNativeType(context.log,"any"),context.errorType=scope.defineNativeType(context.log,""),context.nullType=scope.defineNativeType(context.log,"null"),context.undefinedType=scope.defineNativeType(context.log,"undefined"),context.voidType=scope.defineNativeType(context.log,"void"),this.context=context,this.global=global},Compiler.prototype.addInput=function(name,contents){var source=new log_1.Source;return source.name=name,source.contents=contents,null==this.firstSource?this.firstSource=source:(source.prev=this.lastSource,this.lastSource.next=source),this.lastSource=source,source},Compiler.prototype.addInputBefore=function(name,contents,nextSource){var source=new log_1.Source;return source.name=name,source.contents=contents,nextSource.prev.next=source,source.prev=nextSource.prev,nextSource.prev=source,source.next=nextSource,source},Compiler.prototype.finish=function(){terminal_1.Terminal.time("pre-parsing");for(var source=this.firstSource;null!=source;){if(!preparser_1.preparse(source,this,this.log))return!1;source=source.next}for(terminal_1.Terminal.timeEnd("pre-parsing"),terminal_1.Terminal.time("scanning"),source=this.firstSource;null!=source;)source.firstToken=scanner_1.tokenize(source,this.log),source=source.next;for(terminal_1.Terminal.timeEnd("scanning"),terminal_1.Terminal.time("pre-processing"),source=this.firstSource;null!=source;)this.preprocessor.run(source,this.log),source=source.next;for(terminal_1.Terminal.timeEnd("pre-processing"),terminal_1.Terminal.time("parsing"),source=this.firstSource;null!=source;)null!=source.firstToken&&(source.file=parser_1.parse(source.firstToken,this.log)),source=source.next;terminal_1.Terminal.timeEnd("parsing"),terminal_1.Terminal.time("type-checking");var global=this.global,context=this.context,fullResolve=!0;for(source=this.firstSource;null!=source;){var file=source.file;if(null!=file)for(source.isLibrary?(file.flags|=node_1.NODE_FLAG_LIBRARY,type_checker_1.initialize(context,file,global.scope,type_checker_1.CheckMode.INITIALIZE),type_checker_1.resolve(context,file,global.scope)):type_checker_1.initialize(context,file,global.scope,type_checker_1.CheckMode.NORMAL);null!=file.firstChild;){var child=file.firstChild;child.remove(),global.appendChild(child)}if(source.isLibrary&&this.log.hasErrors()){fullResolve=!1;break}source=source.next}return fullResolve&&type_checker_1.resolve(context,global,global.scope),terminal_1.Terminal.timeEnd("type-checking"),!this.log.hasErrors()&&(terminal_1.Terminal.time("optimizing"),shaking_1.treeShaking(global),terminal_1.Terminal.timeEnd("optimizing"),terminal_1.Terminal.time("emitting"),this.target==compile_target_1.CompileTarget.WEBASSEMBLY&&webassembly_1.wasmEmit(this),terminal_1.Terminal.timeEnd("emitting"),terminal_1.Terminal.write("Done!"),!0)},Compiler}();Compiler.mallocRequired=!1,Compiler.debug=!1,exports.Compiler=Compiler,exports.replaceFileExtension=replaceFileExtension},function(module,exports,__webpack_require__){"use strict";function ByteArray_set16(array,index,value){array.set(index,value),array.set(index+1,value>>8)}function ByteArray_set32(array,index,value){array.set(index,value),array.set(index+1,value>>8),array.set(index+2,value>>16),array.set(index+3,value>>24)}function ByteArray_append32(array,value){array.append(value),array.append(value>>8),array.append(value>>16),array.append(value>>24)}function ByteArray_setString(data,index,text){var length=text.length;assert_1.assert(index>=0&&index+2*length<=data.length);for(var array=data.array,i=0;i>8,index+=2,i+=1}}Object.defineProperty(exports,"__esModule",{value:!0});var assert_1=__webpack_require__(0);exports.ByteArray_set16=ByteArray_set16,exports.ByteArray_set32=ByteArray_set32,exports.ByteArray_append32=ByteArray_append32,exports.ByteArray_setString=ByteArray_setString;var ByteArray=function(){function ByteArray(buffer,offset,length){void 0===offset&&(offset=0),void 0===length&&(length=0),this.BUFFER_EXT_SIZE=1024,this._array=null,this.log="",this.EOF_byte=-1,this.EOF_code_point=-1,void 0==buffer?(buffer=new ArrayBuffer(this.BUFFER_EXT_SIZE),this.write_position=0):this.write_position=null==buffer?0:length>0?length:buffer.byteLength,buffer&&(this.data=new DataView(buffer,offset,length>0?length:buffer.byteLength),this._array=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength)),this._position=0,this.endian=ByteArray.LITTLE_ENDIAN}return Object.defineProperty(ByteArray.prototype,"array",{get:function(){return this._array.subarray(0,this.length)},enumerable:!0,configurable:!0}),ByteArray.prototype.get=function(index){return this._array[index]},ByteArray.prototype.set=function(index,value){this._array[index]=value},ByteArray.prototype.append=function(value){var index=this.position;this.resize(index+1),this._array[index]=value,this.position++},ByteArray.prototype.resize=function(length){if(length>this.data.byteLength){var pos=this.position,len=this.length,capacity=2*length,data=new Uint8Array(capacity);data.set(this.array),this.setArray(data),this._position=pos,this.write_position=len}return this},ByteArray.prototype.copy=function(source,offset,length){return void 0===offset&&(offset=0),void 0===length&&(length=0),offset=offset>0?offset:this.length,offset+source.length>this._array.length&&this.resize(offset+source.length),this._array.set(source.array,offset),this.position=offset+source.length,this},Object.defineProperty(ByteArray.prototype,"buffer",{get:function(){return this.data.buffer},set:function(value){this.data=new DataView(value)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"dataView",{get:function(){return this.data},set:function(value){this.data=value,this.write_position=value.byteLength},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"phyPosition",{get:function(){return this._position+this.data.byteOffset},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"bufferOffset",{get:function(){return this.data.byteOffset},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"position",{get:function(){return this._position},set:function(value){this._positionthis.write_position?value:this.write_position)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"length",{get:function(){return this.write_position},set:function(value){this.validateBuffer(value)},enumerable:!0,configurable:!0}),Object.defineProperty(ByteArray.prototype,"bytesAvailable",{get:function(){return this.data.byteLength-this._position},enumerable:!0,configurable:!0}),ByteArray.prototype.clear=function(){this._position=0},ByteArray.prototype.setArray=function(array){this._array=array,this.setBuffer(array.buffer,array.byteOffset,array.byteLength)},ByteArray.prototype.setBuffer=function(buffer,offset,length){void 0===offset&&(offset=0),void 0===length&&(length=0),buffer&&(this.data=new DataView(buffer,offset,length>0?length:buffer.byteLength))},ByteArray.prototype.writeUnsignedLEB128=function(value){var b=0;value|=0;do{b=127&value,value>>>=7,value&&(b|=128),this.append(b)}while(value)},ByteArray.prototype.writeLEB128=function(value){var b;for(value|=0;;){b=127&value,value>>=7;var signBit=0!=(64&b);if(0===value&&!signBit||-1===value&&signBit){this.append(b);break}b|=128,this.append(b)}},ByteArray.prototype.writeWasmString=function(value){var length=value.length;this.writeUnsignedLEB128(length);var index=this.length;this.resize(index+length);for(var i=0;i0?this.readUTFBytes(length):""},ByteArray.prototype.readUTFBytes=function(length){if(!this.validate(length))return null;var _bytes=new Uint8Array(this.buffer,this.bufferOffset+this.position,length);return this.position+=length,this.decodeUTF8(_bytes)},ByteArray.prototype.readStandardString=function(length){if(!this.validate(length))return null;for(var str="",i=0;i0;){var _byte=this.data.getUint8(this.position++);if(num++,0==_byte){keepEvenByte&&num%2!=0&&this.position++;break}str+=String.fromCharCode(_byte)}return str},ByteArray.prototype.writeBoolean=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_BOOLEAN,offset),this.data.setUint8(offset,value?1:0)},ByteArray.prototype.writeByte=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_INT8,offset),this.data.setInt8(offset,value)},ByteArray.prototype.writeUnsignedByte=function(value,offset){void 0===offset&&(offset=null),offset=offset||this.position++,this.validateBuffer(ByteArray.SIZE_OF_UINT8,offset),this.data.setUint8(offset,value)},ByteArray.prototype.writeBytes=function(_bytes,offset,length){void 0===offset&&(offset=0),void 0===length&&(length=0),this.copy(_bytes)},ByteArray.prototype.writeDouble=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_FLOAT64,position),this.data.setFloat64(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_FLOAT64)},ByteArray.prototype.writeFloat=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_FLOAT32,position),this.data.setFloat32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_FLOAT32)},ByteArray.prototype.writeInt=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_INT32,position),this.data.setInt32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_INT32)},ByteArray.prototype.writeMultiByte=function(value,charSet){},ByteArray.prototype.writeShort=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_INT16,position),this.data.setInt16(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_INT16)},ByteArray.prototype.writeUnsignedShort=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT16,position),this.data.setUint16(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_UINT16)},ByteArray.prototype.writeUnsignedInt=function(value,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT32,position),this.data.setUint32(position,value,this.endian==ByteArray.LITTLE_ENDIAN),offset||(this.position+=ByteArray.SIZE_OF_UINT32)},ByteArray.prototype.writeUTF=function(value,offset){void 0===offset&&(offset=null);var utf8bytes=this.encodeUTF8(value),length=utf8bytes.length,position=null!=offset?offset:this.position;this.validateBuffer(ByteArray.SIZE_OF_UINT16+length,position),this.data.setUint16(position,length,this.endian===ByteArray.LITTLE_ENDIAN),offset?(offset+=ByteArray.SIZE_OF_UINT16,this.writeUint8Array(utf8bytes,offset)):(this.position+=ByteArray.SIZE_OF_UINT16,this.writeUint8Array(utf8bytes))},ByteArray.prototype.writeUTFBytes=function(value,offset){void 0===offset&&(offset=null),this.writeUint8Array(this.encodeUTF8(value),offset)},ByteArray.prototype.toString=function(){return"[ByteArray] length:"+this.length+", bytesAvailable:"+this.bytesAvailable},ByteArray.prototype.writeUint8Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;return this.validateBuffer(_bytes.length,position),this._array.set(_bytes,position),offset||(this.position+=_bytes.length),this},ByteArray.prototype.writeUint16Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_UINT16,position);for(var i=0;i<_bytes.length;i++)this.data.setUint16(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_UINT16;offset||(this.position=position)},ByteArray.prototype.writeUint32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_UINT32,position);for(var i=0;i<_bytes.length;i++)this.data.setUint32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_UINT32;offset||(this.position=position)},ByteArray.prototype.writeInt8Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length,position);for(var i=0;i<_bytes.length;i++)this.data.setInt8(position++,_bytes[i]);offset||(this.position=position)},ByteArray.prototype.writeInt16Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_INT16,position);for(var i=0;i<_bytes.length;i++)this.data.setInt16(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_INT16;offset||(this.position=position)},ByteArray.prototype.writeInt32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_INT32,position);for(var i=0;i<_bytes.length;i++)this.data.setInt32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_INT32;offset||(this.position=position)},ByteArray.prototype.writeFloat32Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length*ByteArray.SIZE_OF_FLOAT32,position);for(var i=0;i<_bytes.length;i++)this.data.setFloat32(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_FLOAT32;offset||(this.position=position)},ByteArray.prototype.writeFloat64Array=function(_bytes,offset){void 0===offset&&(offset=null);var position=null!=offset?offset:this.position;this.validateBuffer(_bytes.length,position);for(var i=0;i<_bytes.length;i++)this.data.setFloat64(position,_bytes[i],this.endian===ByteArray.LITTLE_ENDIAN),position+=ByteArray.SIZE_OF_FLOAT64;offset||(this.position=position)},ByteArray.prototype.readUint8Array=function(length,createNewBuffer){if(void 0===createNewBuffer&&(createNewBuffer=!0),!this.validate(length))return null;if(createNewBuffer){result=new Uint8Array(new ArrayBuffer(length));for(var i=0;i0&&this._position+len<=this.data.byteLength)return!0;throw"Error #2030: End of file was encountered."},ByteArray.prototype.validateBuffer=function(size,offset){void 0===offset&&(offset=0);var length=offset+size;this.resize(length)},ByteArray.prototype.encodeUTF8=function(str){for(var pos=0,codePoints=this.stringToCodePoints(str),outputBytes=[];codePoints.length>pos;){var code_point=codePoints[pos++];if(this.inRange(code_point,55296,57343))this.encoderError(code_point);else if(this.inRange(code_point,0,127))outputBytes.push(code_point);else{var count,offset;for(this.inRange(code_point,128,2047)?(count=1,offset=192):this.inRange(code_point,2048,65535)?(count=2,offset=224):this.inRange(code_point,65536,1114111)&&(count=3,offset=240),outputBytes.push(this.div(code_point,Math.pow(64,count))+offset);count>0;){var temp=this.div(code_point,Math.pow(64,count-1));outputBytes.push(128+temp%64),count-=1}}}return new Uint8Array(outputBytes)},ByteArray.prototype.decodeUTF8=function(data){for(var code_point,pos=0,result="",utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0;data.length>pos;){var _byte=data[pos++];if(_byte===this.EOF_byte)code_point=0!==utf8_bytes_needed?this.decoderError(!1):this.EOF_code_point;else if(0===utf8_bytes_needed)this.inRange(_byte,0,127)?code_point=_byte:(this.inRange(_byte,194,223)?(utf8_bytes_needed=1,utf8_lower_boundary=128,utf8_code_point=_byte-192):this.inRange(_byte,224,239)?(utf8_bytes_needed=2,utf8_lower_boundary=2048,utf8_code_point=_byte-224):this.inRange(_byte,240,244)?(utf8_bytes_needed=3,utf8_lower_boundary=65536,utf8_code_point=_byte-240):this.decoderError(!1),utf8_code_point*=Math.pow(64,utf8_bytes_needed),code_point=null);else if(this.inRange(_byte,128,191))if(utf8_bytes_seen+=1,utf8_code_point+=(_byte-128)*Math.pow(64,utf8_bytes_needed-utf8_bytes_seen),utf8_bytes_seen!==utf8_bytes_needed)code_point=null;else{var cp=utf8_code_point,lower_boundary=utf8_lower_boundary;utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0,code_point=this.inRange(cp,lower_boundary,1114111)&&!this.inRange(cp,55296,57343)?cp:this.decoderError(!1,_byte)}else utf8_code_point=0,utf8_bytes_needed=0,utf8_bytes_seen=0,utf8_lower_boundary=0,pos--,code_point=this.decoderError(!1,_byte);null!==code_point&&code_point!==this.EOF_code_point&&(code_point<=65535?code_point>0&&(result+=String.fromCharCode(code_point)):(code_point-=65536,result+=String.fromCharCode(55296+(code_point>>10&1023)),result+=String.fromCharCode(56320+(1023&code_point))))}return result},ByteArray.prototype.encoderError=function(code_point){throw"EncodingError! The code point "+code_point+" could not be encoded."},ByteArray.prototype.decoderError=function(fatal,opt_code_point){if(fatal)throw"DecodingError";return opt_code_point||65533},ByteArray.prototype.inRange=function(a,min,max){return min<=a&&a<=max},ByteArray.prototype.div=function(n,d){return Math.floor(n/d)},ByteArray.prototype.stringToCodePoints=function(string){for(var cps=[],i=0,n=string.length;i=0},Type.prototype.isTypedArray=function(){return null!=this.symbol&&("Float32Array"==this.symbol.name||"Float64Array"==this.symbol.name||"Int8Array"==this.symbol.name||"Int16Array"==this.symbol.name||"Int32Array"==this.symbol.name||"Uint8Array"==this.symbol.name||"Uint16Array"==this.symbol.name||"Uint32Array"==this.symbol.name)},Type.prototype.isReference=function(){return null!=this.pointerTo||null!=this.symbol&&0!=(this.symbol.flags&symbol_1.SYMBOL_FLAG_IS_REFERENCE)},Type.prototype.underlyingType=function(context){return this.isEnum()?context.int32Type:null!=this.pointerTo?context.uint32Type:this},Type.prototype.integerBitCount=function(context){return null!=this.symbol?8*this.symbol.byteSize:0},Type.prototype.integerBitMask=function(context){return-1>>32-this.integerBitCount(context)},Type.prototype.allocationSizeOf=function(context){return null==this.symbol?context.pointerByteSize:this.symbol.byteSize},Type.prototype.allocationAlignmentOf=function(context){return this.allocationSizeOf(context)},Type.prototype.variableSizeOf=function(context){return this.isReference()?context.pointerByteSize:this.symbol.byteSize},Type.prototype.variableAlignmentOf=function(context){return this.variableSizeOf(context)},Type.prototype.pointerType=function(){var type=this.cachedPointerType;return null==type&&(type=new Type,type.pointerTo=this,this.cachedPointerType=type),type},Type.prototype.toString=function(){return null==this.cachedToString&&(this.cachedToString=null!=this.pointerTo?"*"+this.pointerTo.toString():this.symbol.name),this.cachedToString},Type.prototype.findMember=function(name,hint){var symbol=this.symbol;return null!=symbol&&null!=symbol.scope?symbol.scope.findLocal(name,hint):null},Type.prototype.hasInstanceMembers=function(){var symbol=this.symbol;return null!=symbol&&(symbol.kind==symbol_1.SymbolKind.TYPE_TEMPLATE||symbol.kind==symbol_1.SymbolKind.TYPE_CLASS||symbol.kind==symbol_1.SymbolKind.TYPE_NATIVE)},Type}();exports.Type=Type},function(module,exports,__webpack_require__){"use strict";function isRightAssociative(precedence){return precedence==Precedence.ASSIGN||precedence==Precedence.EXPONENT}function parse(firstToken,log){var context=new ParserContext;context.current=firstToken,context.log=log;var file=new node_1.Node;return file.kind=node_1.NodeKind.FILE,context.parseStatements(file)?file:null}Object.defineProperty(exports,"__esModule",{value:!0});var Precedence,scanner_1=__webpack_require__(9),log_1=__webpack_require__(2),node_1=__webpack_require__(5),assert_1=__webpack_require__(0),terminal_1=__webpack_require__(1);!function(Precedence){Precedence[Precedence.LOWEST=0]="LOWEST",Precedence[Precedence.ASSIGN=1]="ASSIGN",Precedence[Precedence.LOGICAL_OR=2]="LOGICAL_OR",Precedence[Precedence.LOGICAL_AND=3]="LOGICAL_AND",Precedence[Precedence.BITWISE_OR=4]="BITWISE_OR",Precedence[Precedence.BITWISE_XOR=5]="BITWISE_XOR",Precedence[Precedence.BITWISE_AND=6]="BITWISE_AND",Precedence[Precedence.EQUAL=7]="EQUAL",Precedence[Precedence.COMPARE=8]="COMPARE",Precedence[Precedence.SHIFT=9]="SHIFT",Precedence[Precedence.ADD=10]="ADD",Precedence[Precedence.MULTIPLY=11]="MULTIPLY",Precedence[Precedence.EXPONENT=12]="EXPONENT",Precedence[Precedence.UNARY_PREFIX=13]="UNARY_PREFIX",Precedence[Precedence.UNARY_POSTFIX=14]="UNARY_POSTFIX",Precedence[Precedence.MEMBER=15]="MEMBER"}(Precedence=exports.Precedence||(exports.Precedence={}));var ParseKind;!function(ParseKind){ParseKind[ParseKind.EXPRESSION=0]="EXPRESSION",ParseKind[ParseKind.TYPE=1]="TYPE"}(ParseKind||(ParseKind={}));var StatementMode;!function(StatementMode){StatementMode[StatementMode.NORMAL=0]="NORMAL",StatementMode[StatementMode.FILE=1]="FILE"}(StatementMode||(StatementMode={}));var ParserContext=function(){function ParserContext(){}return ParserContext.prototype.peek=function(kind){return this.current.kind==kind},ParserContext.prototype.eat=function(kind){return!!this.peek(kind)&&(this.advance(),!0)},ParserContext.prototype.advance=function(){this.peek(scanner_1.TokenKind.END_OF_FILE)||(this.previous=this.current,this.current=this.current.next)},ParserContext.prototype.unexpectedToken=function(){this.lastError!=this.current&&(this.lastError=this.current,this.log.error(this.current.range,"Unexpected "+scanner_1.tokenToString(this.current.kind)))},ParserContext.prototype.expect=function(kind){if(!this.peek(kind)){if(this.lastError!=this.current){this.lastError=this.current;var previousLine=this.previous.range.enclosingLine(),currentLine=this.current.range.enclosingLine();kind==scanner_1.TokenKind.IDENTIFIER||previousLine.equals(currentLine)?this.log.error(this.current.range,"Expected "+scanner_1.tokenToString(kind)+" but found "+scanner_1.tokenToString(this.current.kind)):this.log.error(previousLine.rangeAtEnd(),"Expected "+scanner_1.tokenToString(kind))}return!1}return this.advance(),!0},ParserContext.prototype.parseUnaryPrefix=function(kind,mode){assert_1.assert(node_1.isUnary(kind));var token=this.current;this.advance();var value=this.parseExpression(Precedence.UNARY_PREFIX,mode);return null==value?null:node_1.createUnary(kind,value).withRange(log_1.spanRanges(token.range,value.range)).withInternalRange(token.range)},ParserContext.prototype.parseBinary=function(kind,left,localPrecedence,operatorPrecedence){if(localPrecedence>=operatorPrecedence)return left;var token=this.current;this.advance();var precedence=isRightAssociative(operatorPrecedence)?operatorPrecedence-1:operatorPrecedence,right=this.parseExpression(precedence,ParseKind.EXPRESSION);return null==right?null:node_1.createBinary(kind,left,right).withRange(log_1.spanRanges(left.range,right.range)).withInternalRange(token.range)},ParserContext.prototype.parseUnaryPostfix=function(kind,value,localPrecedence){if(localPrecedence>=Precedence.UNARY_POSTFIX)return value;var token=this.current;return this.advance(),node_1.createUnary(kind,value).withRange(log_1.spanRanges(value.range,token.range)).withInternalRange(token.range)},ParserContext.prototype.parseQuotedString=function(range){assert_1.assert(range.end-range.start>=2);for(var text=range.source.contents,end=range.start+1,limit=range.end-1,start=end,quotedString="";end')":end.kind==scanner_1.TokenKind.GREATER_THAN_EQUAL?"(it is automatically derived from '<')":""))):this.unexpectedToken()}else{if(null==parent&&(assert_1.assert(token.kind==scanner_1.TokenKind.FUNCTION),this.advance()),nameRange=this.current.range,!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;name=nameRange.toString()}var node=node_1.createFunction(name);if(node.firstFlag=firstFlag,node.flags=node_1.allFlags(firstFlag),isOperator&&(node.flags=node.flags|node_1.NODE_FLAG_OPERATOR),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;node.appendChild(parameters)}if(!this.expect(scanner_1.TokenKind.LEFT_PARENTHESIS))return null;if(!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))for(;;){var firstArgumentFlag=this.parseFlags(),argument=this.current;if(!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;var type=void 0,value=null,range=argument.range;if(this.expect(scanner_1.TokenKind.COLON)){if(type=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;type.appendChild(parameters)}if(null!=type)range=log_1.spanRanges(range,type.range);else{if(!this.peek(scanner_1.TokenKind.COMMA)&&!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;type=node_1.createParseError()}}else(this.peek(scanner_1.TokenKind.COMMA)||this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))&&(type=node_1.createParseError());for(var firstType=type;this.eat(scanner_1.TokenKind.BITWISE_OR);){var aliasType=this.parseType();if(this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;aliasType.appendChild(parameters)}if(null!=aliasType)range=log_1.spanRanges(range,aliasType.range);else{if(!this.peek(scanner_1.TokenKind.COMMA)&&!this.peek(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;aliasType=node_1.createParseError()}type.appendChild(aliasType),type=aliasType}this.eat(scanner_1.TokenKind.ASSIGN)&&(value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION));var variable=node_1.createVariable(argument.range.toString(),firstType,value);if(variable.firstFlag=firstArgumentFlag,variable.flags=node_1.allFlags(firstArgumentFlag),node.appendChild(variable.withRange(range).withInternalRange(argument.range)),!this.eat(scanner_1.TokenKind.COMMA))break}if(!this.expect(scanner_1.TokenKind.RIGHT_PARENTHESIS))return null;var returnType;if(node.isAnyfunc())returnType=node_1.createAny();else if("constructor"==node.stringValue)returnType=new node_1.Node,returnType.kind=node_1.NodeKind.NAME,returnType.stringValue=parent.stringValue;else if(this.expect(scanner_1.TokenKind.COLON)){if(returnType=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;returnType.appendChild(parameters)}if(null==returnType){if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;returnType=node_1.createParseError()}for(var firstType=returnType;this.eat(scanner_1.TokenKind.BITWISE_OR);){var aliasType=this.parseType();if(this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;aliasType.appendChild(parameters)}if(null==aliasType){if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;aliasType=node_1.createParseError()}firstType.appendChild(aliasType),firstType=aliasType}}else{if(!this.peek(scanner_1.TokenKind.SEMICOLON)&&!this.peek(scanner_1.TokenKind.LEFT_BRACE))return null;returnType=node_1.createParseError()}node.appendChild(returnType);var block=null,semicolon=this.current;if(this.eat(scanner_1.TokenKind.SEMICOLON))block=node_1.createEmpty().withRange(semicolon.range);else if(null==(block=this.parseBlock()))return null;return null!=parent&&parent.appendChild(node),node.appendChild(block),node.withRange(log_1.spanRanges(token.range,block.range)).withInternalRange(nameRange)},ParserContext.prototype.parseVariables=function(firstFlag,parent){var token=this.current;null==parent&&(assert_1.assert(token.kind==scanner_1.TokenKind.CONST||token.kind==scanner_1.TokenKind.LET||token.kind==scanner_1.TokenKind.VAR),this.advance());var node=token.kind==scanner_1.TokenKind.CONST?node_1.createConstants():node_1.createVariables();for(node.firstFlag=firstFlag;;){var name_3=this.current;if(!this.expect(scanner_1.TokenKind.IDENTIFIER))return null;var type=null;if(this.eat(scanner_1.TokenKind.COLON)){if(type=this.parseType(),this.peek(scanner_1.TokenKind.LESS_THAN)){var parameters=this.parseParameters();if(null==parameters)return null;type.appendChild(parameters)}if(null==type)return null}var value=null;if(this.eat(scanner_1.TokenKind.ASSIGN)&&null==(value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION)))return null;var range=null!=value?log_1.spanRanges(name_3.range,value.range):null!=type?log_1.spanRanges(name_3.range,type.range):name_3.range,variable=node_1.createVariable(name_3.range.toString(),type,value);if(variable.firstFlag=firstFlag,variable.flags=node_1.allFlags(firstFlag),(null!=parent?parent:node).appendChild(variable.withRange(range).withInternalRange(name_3.range)),!this.eat(scanner_1.TokenKind.COMMA))break}var semicolon=this.current;return this.expect(scanner_1.TokenKind.SEMICOLON),node.withRange(log_1.spanRanges(token.range,semicolon.range))},ParserContext.prototype.parseLoopJump=function(kind){var token=this.current;this.advance(),this.expect(scanner_1.TokenKind.SEMICOLON);var node=new node_1.Node;return node.kind=kind,node.withRange(token.range)},ParserContext.prototype.parseFlags=function(){for(var firstFlag=null,lastFlag=null;;){var token=this.current,flag=void 0;if(this.eat(scanner_1.TokenKind.DECLARE))flag=node_1.NODE_FLAG_DECLARE;else if(this.eat(scanner_1.TokenKind.EXPORT))flag=node_1.NODE_FLAG_EXPORT;else if(this.eat(scanner_1.TokenKind.PRIVATE))flag=node_1.NODE_FLAG_PRIVATE;else if(this.eat(scanner_1.TokenKind.PROTECTED))flag=node_1.NODE_FLAG_PROTECTED;else if(this.eat(scanner_1.TokenKind.PUBLIC))flag=node_1.NODE_FLAG_PUBLIC;else if(this.eat(scanner_1.TokenKind.STATIC))flag=node_1.NODE_FLAG_STATIC;else if(this.eat(scanner_1.TokenKind.ANYFUNC))flag=node_1.NODE_FLAG_ANYFUNC;else if(this.eat(scanner_1.TokenKind.UNSAFE))flag=node_1.NODE_FLAG_UNSAFE;else if(this.eat(scanner_1.TokenKind.JAVASCRIPT))flag=node_1.NODE_FLAG_JAVASCRIPT;else if(this.eat(scanner_1.TokenKind.START))flag=node_1.NODE_FLAG_START;else{if(!this.eat(scanner_1.TokenKind.VIRTUAL))return firstFlag;flag=node_1.NODE_FLAG_VIRTUAL}var link=new node_1.NodeFlag;link.flag=flag,link.range=token.range,null==firstFlag?firstFlag=link:lastFlag.next=link,lastFlag=link}},ParserContext.prototype.parseUnsafe=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_UNSAFE,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseJavaScript=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_JAVASCRIPT,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseStart=function(){var token=this.current;this.advance();var node=this.parseBlock();return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_START,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseVirtual=function(firstFlag){var token=this.current;this.advance();var node=this.parseFunction(firstFlag,null);return null==node?null:(node.flags=node.flags|node_1.NODE_FLAG_VIRTUAL,node.withRange(log_1.spanRanges(token.range,node.range)))},ParserContext.prototype.parseStatement=function(mode){var firstFlag=mode==StatementMode.FILE?this.parseFlags():null;if(this.peek(scanner_1.TokenKind.IMPORT)&&null==firstFlag)return this.parseImports();if(this.peek(scanner_1.TokenKind.JAVASCRIPT)&&null==firstFlag)return this.parseJavaScript();if(this.peek(scanner_1.TokenKind.START)&&null==firstFlag)return this.parseStart();if(this.peek(scanner_1.TokenKind.CONST)||this.peek(scanner_1.TokenKind.LET)||this.peek(scanner_1.TokenKind.VAR))return this.parseVariables(firstFlag,null);if(this.peek(scanner_1.TokenKind.FUNCTION))return this.parseFunction(firstFlag,null);if(this.peek(scanner_1.TokenKind.VIRTUAL))return this.parseVirtual(firstFlag);if(this.peek(scanner_1.TokenKind.MODULE))return this.parseModule(firstFlag);if(this.peek(scanner_1.TokenKind.CLASS))return this.parseClass(firstFlag);if(this.peek(scanner_1.TokenKind.ENUM))return this.parseEnum(firstFlag);if(null!=firstFlag)return this.unexpectedToken(),null;if(this.peek(scanner_1.TokenKind.LEFT_BRACE))return this.parseBlock();if(this.peek(scanner_1.TokenKind.BREAK))return this.parseLoopJump(node_1.NodeKind.BREAK);if(this.peek(scanner_1.TokenKind.CONTINUE))return this.parseLoopJump(node_1.NodeKind.CONTINUE);if(this.peek(scanner_1.TokenKind.IF))return this.parseIf();if(this.peek(scanner_1.TokenKind.WHILE))return this.parseWhile();if(this.peek(scanner_1.TokenKind.DELETE))return this.parseDelete();if(this.peek(scanner_1.TokenKind.RETURN))return this.parseReturn();if(this.peek(scanner_1.TokenKind.SEMICOLON))return this.parseEmpty();var value=this.parseExpression(Precedence.LOWEST,ParseKind.EXPRESSION);if(null==value)return null;var semicolon=this.current;return this.expect(scanner_1.TokenKind.SEMICOLON),node_1.createExpression(value).withRange(log_1.spanRanges(value.range,semicolon.range))},ParserContext.prototype.parseStatements=function(parent){for(;!this.peek(scanner_1.TokenKind.END_OF_FILE)&&!this.peek(scanner_1.TokenKind.RIGHT_BRACE);){var child=this.parseStatement(parent.kind==node_1.NodeKind.FILE?StatementMode.FILE:StatementMode.NORMAL);if(null==child)return!1;child.kind===node_1.NodeKind.RETURN&&(parent.returnNode=child),parent.appendChild(child)}return!0},ParserContext.prototype.parseInt=function(range,node){var source=range.source,contents=source.contents;return node.intValue=parseInt(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext.prototype.parseFloat=function(range,node){var source=range.source,contents=source.contents;return node.floatValue=parseFloat(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext.prototype.parseDouble=function(range,node){var source=range.source,contents=source.contents;return node.doubleValue=parseFloat(contents.substring(range.start,range.end)),node.flags=node_1.NODE_FLAG_POSITIVE,!0},ParserContext}();exports.parse=parse},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Color={DEFAULT_TEXT:12,DEFAULT_BG:8,BLACK:0,WHITE:255,BOLD:1,RED:1,GREEN:2,YELLOW:3,BLUE:4,MAGENTA:5,ORANGE:208};var hexColor={};hexColor[exports.Color.DEFAULT_TEXT]="#000000",hexColor[exports.Color.DEFAULT_BG]="#FFFFFF",hexColor[exports.Color.BLACK]="#000000",hexColor[exports.Color.WHITE]="#FFFFFF",hexColor[exports.Color.BOLD]="",hexColor[exports.Color.RED]="#FF0000",hexColor[exports.Color.GREEN]="#00FF00",hexColor[exports.Color.BLUE]="#0000FF",hexColor[exports.Color.YELLOW]="#FFF600",hexColor[exports.Color.MAGENTA]="#FF00FF",hexColor[exports.Color.ORANGE]="#FF8C00",exports.HexColor=hexColor},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isBrowser=new Function("try {return this===window;}catch(e){ return false;}")(),exports.isNode=new Function("try {return this===global;}catch(e){return false;}")()},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var env_1=__webpack_require__(21),terminal_1=__webpack_require__(1);if(void 0===Map)var Map=function(){var _this=this;this.get=function(key){return _this[key]},this.set=function(key,value){return _this[key]=value}};var fs=null,virtualFileSystem={fileMap:new Map,readFileSync:function(path,options){return fs.fileMap.get(path)},writeFileSync:function(path,data,options){return fs.fileMap.set(path,data)}};env_1.isBrowser?(fs=virtualFileSystem,window.Buffer=function(){function NodeBuffer(array){this.array=array}return NodeBuffer}()):env_1.isNode?fs=__webpack_require__(55):terminal_1.Terminal.error("----\x3e Unknown host environment!!!. Where are we?");var FileSystem=function(){function FileSystem(){}return FileSystem.readTextFile=function(path){try{return fs.readFileSync(path,"utf8").replace(/\r\n/g,"\n")}catch(e){var virtualFile=virtualFileSystem.readFileSync(path,"utf8").replace(/\r\n/g,"\n");return void 0===virtualFile?null:virtualFile}},FileSystem.writeTextFile=function(path,contents,virtual){void 0===virtual&&(virtual=!1);try{return virtual?virtualFileSystem.writeFileSync(path,contents):fs.writeFileSync(path,contents),!0}catch(e){return!1}},FileSystem.readBinaryFile=function(path){try{return fs.readFileSync(path)}catch(e){var virtualFile=virtualFileSystem.readFileSync(path);return void 0===virtualFile?null:virtualFile}},FileSystem.writeBinaryFile=function(path,contents,virtual){void 0===virtual&&(virtual=!1);try{return virtual?virtualFileSystem.writeFileSync(path,new Buffer(contents.array.subarray(0,contents.length))):fs.writeFileSync(path,new Buffer(contents.array.subarray(0,contents.length))),!0}catch(e){return!1}},FileSystem}();exports.FileSystem=FileSystem},function(module,exports,__webpack_require__){"use strict";function main_addArgument(text){var argument=new CommandLineArgument;argument.text=text,null==firstArgument?firstArgument=argument:lastArgument.next=argument,lastArgument=argument}function main_reset(){firstArgument=null,lastArgument=null}function printUsage(){terminal_1.Terminal.write("\nUsage: tc [FLAGS] [INPUTS]\n\n --help Print this message.\n --out [PATH] Emit code to PATH (the target format is the file extension).\n --wasm Explicit webassembly output \n --define [NAME] Define the flag NAME in all input files.\n\nExamples:\n\n tc src/*.tbs --out main.wasm\n")}function main_entry(){var output,target=compile_target_1.CompileTarget.NONE,argument=firstArgument,inputCount=0;if(null==firstArgument)return printUsage(),1;for(;null!=argument;){var text=argument.text;if(text.startsWith("-")){if("-h"==text||"-help"==text||"--help"==text||"/?"==text)return printUsage(),0;if("--cpp"==text)target=compile_target_1.CompileTarget.CPP;else if("--js"==text)target=compile_target_1.CompileTarget.JAVASCRIPT;else if("--wasm"==text)target=compile_target_1.CompileTarget.WEBASSEMBLY;else if("--define"==text&&null!=argument.next)argument=argument.next;else{if("--out"!=text||null==argument.next)return terminal_1.Terminal.error("Invalid flag: "+text),1;argument=argument.next,output=argument.text}}else inputCount+=1;argument=argument.next}if(0==inputCount)return terminal_1.Terminal.error("No input files"),1;if(null==output)return terminal_1.Terminal.error("Missing an output file (use the --out flag)"),1;if(target==compile_target_1.CompileTarget.NONE){if(!output.endsWith(".wasm"))return terminal_1.Terminal.error("Missing a target (use either --asmjs or --wasm)"),1;target=compile_target_1.CompileTarget.WEBASSEMBLY}var compiler=new compiler_1.Compiler;for(compiler.initialize(target,output),argument=firstArgument;null!=argument;){var text=argument.text;if("--define"==text)argument=argument.next,compiler.preprocessor.define(argument.text,!0);else if("--out"==text)argument=argument.next;else if(!text.startsWith("-")){var contents=filesystem_1.FileSystem.readTextFile(text);if(null==contents)return terminal_1.Terminal.error("Cannot read from "+text),1;compiler.addInput(text,contents)}argument=argument.next}if(compiler.finish(),log_1.writeLogToTerminal(compiler.log),!compiler.log.hasErrors()){if(target==compile_target_1.CompileTarget.CPP&&filesystem_1.FileSystem.writeTextFile(output,compiler.outputCPP)&&filesystem_1.FileSystem.writeTextFile(compiler_1.replaceFileExtension(output,".h"),compiler.outputH)||target==compile_target_1.CompileTarget.JAVASCRIPT&&filesystem_1.FileSystem.writeTextFile(output,compiler.outputJS)||target==compile_target_1.CompileTarget.WEBASSEMBLY&&filesystem_1.FileSystem.writeBinaryFile(output,compiler.outputWASM)&&filesystem_1.FileSystem.writeTextFile(compiler_1.replaceFileExtension(output,".wast"),compiler.outputWAST)&&filesystem_1.FileSystem.writeTextFile(output+".log",compiler.outputWASM.log))return terminal_1.Terminal.write("\n"),0;terminal_1.Terminal.error("Cannot write to "+output)}return terminal_1.Terminal.write("\n"),1}function compileString(source,options){void 0===options&&(options=compiler_options_1.defaultCompilerOptions),terminal_1.Terminal.silent=options.silent;var input="/virtual/inline.tbs";filesystem_1.FileSystem.writeTextFile(input,source,!0);var compiler=new compiler_1.Compiler;return compiler.initialize(options.target,"/virtual/inline.wasm"),compiler.addInput(input,source),compiler.finish(),terminal_1.Terminal.silent=!1,compiler.log.hasErrors()?(options.silent&&!options.logError||log_1.writeLogToTerminal(compiler.log),{success:!1,log:compiler.log}):{success:!0,wasm:compiler.outputWASM.array,wast:"WebAssembly text format output is not yet supported!\nPlease check wasm binary data."}}Object.defineProperty(exports,"__esModule",{value:!0});var log_1=__webpack_require__(2),compiler_1=__webpack_require__(11),compile_target_1=__webpack_require__(4),terminal_1=__webpack_require__(1),filesystem_1=__webpack_require__(22),compiler_options_1=__webpack_require__(47),CommandLineArgument=function(){function CommandLineArgument(){}return CommandLineArgument}();exports.CommandLineArgument=CommandLineArgument;var firstArgument,lastArgument;exports.main_addArgument=main_addArgument,exports.main_reset=main_reset,exports.printUsage=printUsage,exports.main_entry=main_entry,exports.main={addArgument:main_addArgument,reset:main_reset,entry:main_entry},exports.compileString=compileString,exports.version="1.0.2-beta",exports.default={version:exports.version,main:exports.main,compileString:compileString}},function(module,exports){module.exports="declare class Math {\n static abs(x: float32): float32;\n static acos(x: float64): float64;\n static asin(x: float64): float64;\n static atan(x: float64): float64;\n static atan2(y: float64, x: float64): float64;\n static ceil(x: float32): float32;\n static cos(x: float64): float64;\n static exp(x: float64): float64;\n static floor(x: float32): float32;\n static log(x: float64): float64;\n // static max(...values: float64[]): float64;\n static max(a: float64, b:float64): float64;\n // static min(...values: float64[]): float64;\n static min(a: float64, b:float64): float64;\n static pow(x: float64, y: float64): float64;\n static random(): float64; // 'random' is not a standard Math builtin\n // static round(x: float64): float64; //'round' is not a standard Math builtin\n static sin(x: float64): float64;\n static sqrt(x: float32): float32;\n static tan(x: float64): float64;\n static imul(a: int32, b:int32): int32;\n}\n\nfunction absf32(x:float32):float32{\n return Math.abs(x) as float32;\n}\n\nfunction sqrtf32(x:float32):float32{\n return Math.sqrt(x);\n}\n\nfunction powf32(x:float32, y:float32):float32{\n return Math.pow(x as float64, y as float64) as float32;\n}\n\nfunction minf32(x:float32, y:float32):float32{\n return Math.min(x as float64, y as float64) as float32;\n}\nfunction maxf32(x:float32, y:float32):float32{\n return Math.max(x as float64, y as float64) as float32;\n}\n\ndeclare function modf32(a:float32, b:float32):float32;\ndeclare function modf64(a:float64, b:float64):float64;\n"},function(module,exports){module.exports="class Array {\n\n bytesLength: int32;\n elementSize: int32;\n\n constructor(bytesLength: int32, elementSize: int32) {\n this.bytesLength = bytesLength;\n this.elementSize = elementSize;\n }\n\n operator [] (index: int32): T {\n let stripe = index * this.elementSize;\n if (stripe >= 0 && stripe < this.bytesLength) {\n return *((this as *uint8 + 8 + stripe) as *T);\n }\n return null as T;\n }\n\n operator []= (index: int32, value: T): void {\n let stripe = index * this.elementSize;\n if (stripe >= 0 && stripe < this.bytesLength) {\n *((this as *uint8 + 8 + stripe) as *T) = value;\n }\n }\n\n get length(): int32 {\n return this.bytesLength / this.elementSize;\n }\n}\n\n//declare type Int32Array = Array< int32 >\n//declare type Uint32Array = Array< uint32 >\n//declare type Int64Array = Array< int64 >\n//declare type Uint64Array = Array< uint64 >\n//declare type Float32Array = Array< float32 >\n//declare type Float64Array = Array< float64 >\n"},function(module,exports){module.exports="var originalHeapPointer: *uint8 = null;\nvar currentHeapPointer: *uint8 = null;\n\nvar freeMemory: int32 = 0;\nvar numFreeChunks: int32 = 0;\nvar firstFree: int32 = 0;\nvar lastFree: int32 = 0;\n\nconst PREV_INUSE:int32 = 1;\nconst IS_MMAPPED:int32 = 2;\nconst NON_MAIN_ARENA:int32 = 4;\nconst SIZE_BITS:int32 = PREV_INUSE|IS_MMAPPED|NON_MAIN_ARENA;\n\n//An allocated chunk looks like this:\n/*\n chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of previous chunk, if allocated | |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of chunk, in bytes |P|\n mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | User data starts here... .\n . .\n . (malloc_usable_size() bytes) .\n . |\nnextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of chunk |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n*/\n//Free chunks are stored in circular doubly-linked lists, and look like this:\n/*\n chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Size of previous chunk |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n `head:' | Size of chunk, in bytes |P|\n mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Forward pointer to next chunk in list |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Back pointer to previous chunk in list |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n | Unused space (may be 0 bytes long) .\n . .\n . |\nnextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n `foot:' | Size of chunk, in bytes |\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n*/\n\n// function init_malloc():void{\n// numFreeChunks = 0;\n// firstFree = 0;\n// lastFree = 0;\n// originalHeapPointer = 40 as *uint8;//this will override by compiler\n// currentHeapPointer = 40 as *uint8;//this will override by compiler\n// }\n\nexport function malloc(size: int32): *uint8 {\n\n //All loc variable should declare here before assigning named value\n var alignment:int32 = 8;\n\n size = (size + (alignment - 1)) & ~(alignment - 1) as int32;\n var chunkSize = size + 8;\n\n var freeChunk = getFreeChunk(chunkSize);\n if(freeChunk as int32 > 0){\n return freeChunk;\n }\n\n var offset:int32 = currentHeapPointer as int32;\n offset = offset + 7;\n offset = offset & ~7;\n // offset = ((currentHeapPointer as int32 + 7) & ~(7) as int32) as *uint8;\n\n var top = offset + chunkSize;\n\n var ptr = (offset + 4) as *uint8; //skip prev size\n setHeadSize(ptr, chunkSize);\n setInuse((ptr + 4) as *uint8);\n setFoot(ptr, chunkSize);\n\n currentHeapPointer = (top + 4) as *uint8;\n\n offset = offset + 8;\n\n // Make sure the memory starts off at zero\n ptr = offset as *uint8;\n while ((ptr as int32) < (top as int32)) {\n *(ptr as *int32) = 0;\n ptr = ptr + 4;\n }\n\n return offset as *uint8;\n}\nexport function free(ptr:*uint8):void{\n\n var chunkptr:*uint8 = null;\n var tmp1:int32 = 0;\n\n clearInuse(ptr);\n if(firstFree == 0){\n firstFree = ptr as int32;\n }\n\n tmp1 = freeMemory as int32;\n tmp1 = tmp1 + getChunkSize(ptr) as int32;\n freeMemory = tmp1 as int32;\n\n chunkptr = ptr + 4;\n if(lastFree > 0){\n *(chunkptr as *int32) = lastFree;//backward pointer to prev chunk\n *(lastFree as *int32) = ptr as int32;//forward pointer to next chunk of prev chunk\n }else{\n *(chunkptr as *int32) = 0;//no backward pointer, this is the first free chunk\n }\n\n *(ptr as *int32) = 0;//no forward pointer\n\n lastFree = ptr as int32;\n numFreeChunks = numFreeChunks + 1;\n}\n/*export*/function getFreeChunk(size: int32):*uint8{\n\n var freeChunk:*uint8 = null;\n var tmp1:int32 = 0;\n var tmp2:int32 = 0;\n var tmp3:int32 = 0;\n var tmp4:int32 = 0;\n\n tmp1 = firstFree;\n tmp2 = lastFree;\n tmp3 = freeMemory;\n\n if(numFreeChunks > 0){\n freeChunk = findChunk(size);\n if(freeChunk as int32 > 0){\n if(freeChunk as int32 == tmp1){\n firstFree = nextFree(freeChunk) as int32;\n }\n if(freeChunk as int32 == tmp2){\n lastFree = 0;\n }\n numFreeChunks = numFreeChunks - 1;\n setInuse(freeChunk);\n tmp4 = getChunkSize(freeChunk);\n tmp3 = tmp3 - tmp4;\n freeMemory = tmp3;\n }\n }\n return freeChunk;\n}\n/*export*/function findChunk(size: int32):*uint8{\n var chunk:*uint8 = null;\n var tmp1:int32 = 0;\n\n chunk = firstFree as *uint8;\n while(chunk != null){\n tmp1= getChunkSize(chunk);\n if(tmp1 == size){\n return chunk;\n }\n chunk = *(chunk as *int32) as *uint8;\n }\n return null;\n}\n/*export*/ function getHeapPtr(): int32 {\n return currentHeapPointer as int32;\n}\n/*export*/ function getFreeMemory(): int32 {\n return freeMemory;\n}\n/*export*/ function getOriginalHeapPtr(): int32 {\n return originalHeapPointer as int32;\n}\nfunction getNumFreeChunks():int32{\n return numFreeChunks as int32;\n}\n/*export*/function getFirstFree():int32{\n return firstFree;\n}\n/*export*/function getLastFree():int32{\n return lastFree;\n}\n/*export*/function prevFree(ptr:*uint8):int32{\n return *(ptr as *int32 + 4) as int32;\n}\n/*export*/function nextFree(ptr:*uint8):int32{\n return *(ptr as *int32) as int32;\n}\n/* Set size at head, without disturbing its use bit */\nfunction setHeadSize(ptr:*uint8, s:int32):void {\n *(ptr as *int32) = (*(ptr as *int32) & SIZE_BITS) | s;\n}\n\n/* Set size/use field */\nfunction setHead(ptr:*uint8, s:int32):void {\n *(ptr as *int32) = s;\n}\n\n/* Set size at footer (only when chunk is not in use) */\nfunction setFoot(ptr:*uint8, s:int32):void {\n var chunkptr:int32 = 0;\n var size:int32 = 0;\n size = *(ptr as *int32);\n chunkptr = (ptr as int32) + size;\n *(chunkptr as *int32) = s;\n}\n\n/*export*/function getPrevInuse(ptr:*uint8):int32 {\n var chunkptr:int32 = 0;\n chunkptr = (ptr as int32) - 8;\n return *(chunkptr as *int32) & (PREV_INUSE);\n}\n/*export*/function setInuse(ptr:*uint8):void{\n var chunkptr:int32 = 0;\n chunkptr = (ptr as int32) - 4;\n *(chunkptr as *int32) = *(chunkptr as *int32) | PREV_INUSE;\n}\n/*export*/function getInuse(ptr:*uint8):int32{\n var chunkptr:int32 = 0;\n chunkptr = (ptr as int32) - 4;\n return *(chunkptr as *int32) & (PREV_INUSE);\n}\n/*export*/function clearInuse(ptr:*uint8):void{\n var chunkptr:int32 = 0;\n chunkptr = (ptr as int32) - 4;\n *(chunkptr as *int32) = *(chunkptr as *int32) & ~(PREV_INUSE);\n}\n/*export*/function getChunkSize(ptr:*uint8):int32{\n var chunkptr:int32 = 0;\n chunkptr = (ptr as int32) - 4;\n return *(chunkptr as *int32) & ~(PREV_INUSE) as int32;\n}\n/* malloc */\n// var SIZE_SZ:int32 = 4;\n// var MALLOC_ALIGNMENT:int32 = 8;//2 * SIZE_SZ;\n// var MALLOC_ALIGN_MASK:int32 = MALLOC_ALIGNMENT - 1;\n//\n// var PREV_INUSE:int32 = 0x1;\n// var IS_MMAPPED:int32 = 0x2;\n// var NON_MAIN_ARENA:int32 = 0x4;\n// var SIZE_BITS:int32 = PREV_INUSE|IS_MMAPPED|NON_MAIN_ARENA;\n//\n// class chunk{\n// prevSize:int32;\n// size:int32;\n// forward:int32;\n// backward:int32;\n// forwardLarge:int32;\n// backwardLarge:int32;\n// }\n// function prev_inuse(p:*chunk):int32 {\n// return (p as chunk).size & PREV_INUSE;\n// }\n// function chunksize(p:*chunk):int32 {\n// return (p as chunk).size & ~(SIZE_BITS);\n// }\n// /* Ptr to next physical malloc_chunk. */\n// function next_chunk(p:*chunk):*chunk {\n// ((*p as int32) + (p as chunk).size & ~(SIZE_BITS)) as *chunk;\n// }\n//\n// /* Ptr to previous physical malloc_chunk */\n// function prev_chunk(p:*chunk):*chunk {\n// ((*p as int32) - (p as chunk).prevSize) as *chunk;\n// }\n//\n// /* Treat space at ptr + offset as a chunk */\n// function chunk_at_offset(p:*chunk, s:int32):*chunk{\n// return ((*p as int32) + s) as *chunk;\n// }\n//\n// /* extract p's inuse bit */\n// function inuse(p:*chunk):int32{\n// return ((*p as int32) + (((p as chunk).size & ~SIZE_BITS) as chunk).size) & PREV_INUSE;\n// }\n//\n// /* set/clear chunk as being inuse without otherwise disturbing */\n// function set_inuse(p:*chunk):int32{\n// return ((*p as int32) + (((p as chunk).size & ~SIZE_BITS) as chunk).size) = ((*p as int32) + (((p as chunk).size & ~SIZE_BITS) as chunk).size) | PREV_INUSE;\n// }\n//\n// function clear_inuse(p:*chunk):int32{\n// return ((*p as int32) + (((p as chunk).size & ~SIZE_BITS) as chunk).size) = ((*p as int32) + (((p as chunk).size & ~SIZE_BITS) as chunk).size) & ~(PREV_INUSE);\n// }\n\nfunction memcpy(target: *uint8, source: *uint8, length: int32): void {\n // No-op if either of the inputs are null\n if (source == null || target == null) {\n return;\n }\n\n // Optimized aligned copy\n if (length >= 16 && (source as int32) % 4 == (target as int32) % 4) {\n // Pick off the beginning\n while ((target as int32) % 4 != 0) {\n *target = *source;\n target = target + 1;\n source = source + 1;\n length = length - 1;\n }\n\n // Pick off the end\n while (length % 4 != 0) {\n length = length - 1;\n *(target + length) = *(source + length);\n }\n\n // Zip over the middle\n var end = target + length;\n while (target < end) {\n *(target as *int32) = *(source as *int32);\n target = target + 4;\n source = source + 4;\n }\n }\n\n // Slow unaligned copy\n else {\n var end = target + length;\n while (target < end) {\n *target = *source;\n target = target + 1;\n source = source + 1;\n }\n }\n}\n\nfunction memcmp(a: *uint8, b: *uint8, length: int32): int32 {\n // No-op if either of the inputs are null\n if (a == null || b == null) {\n return 0;\n }\n\n // Return the first non-zero difference\n while (length > 0) {\n var delta = *a as int32 - *b as int32;\n if (delta != 0) {\n return delta;\n }\n a = a + 1;\n b = b + 1;\n length = length - 1;\n }\n\n // Both inputs are identical\n return 0;\n}"},function(module,exports){module.exports="const PI:float64 = 3.141592653589793;\n\nconst MAX_UNSIGNED_INTEGER_32:uint32 = 4294967295;\n\nconst MIN_INTEGER_32:int32 = -2147483648;\nconst MAX_INTEGER_32:int32 = 2147483647;\n\nconst MAX_UNSIGNED_INTEGER_64:int32 = 18446744073709551615;\n\n// −(2^63) to 2^63 − 1\n// const MIN_INTEGER_64:int32 = -powi64(2, 63);\n// const MAX_INTEGER_64:int32 = powi64(2, 63) - 1;\n\n// float remainder\n\n // export function modf64(x:float64, y:float64):float64{\n //\n // let ir:int32,iy:int32;\n // let r:float64,w:float64;\n //\n // if (y == 0 || isNaN(y) || !isFinite(x)) {\n // return (x * y) / (x * y);\n // }\n //\n // r = abs(x);\n // y = abs(y);\n // (void)frexp(y,&iy);\n // while (r >= y) {\n // (void)frexp(r,&ir);\n // w = ldexp(y,ir-iy);\n // r -= w <= r ? w : w*(double)0.5;\n // }\n // return x >= (double)0 ? r : -r;\n // }\n // }"},function(module,exports){module.exports="// Native types\nconst NaN: float64 = 0.0 / 0.0;\nconst Infinity: float64 = 1.0 / 0.0;\n\nfunction isNaN(value: float32): boolean {\n return value != value;\n}\n\nfunction isFinite(value: float32): boolean {\n return !isNaN(value) && value != Infinity && value != -Infinity;\n}\n\ndeclare class boolean {\n toString(): string;\n}\n\ndeclare class int8 {\n toString(): string;\n}\n\ndeclare class uint8 {\n toString(): string;\n}\n\ndeclare class int16 {\n toString(): string;\n}\n\ndeclare class uint16 {\n toString(): string;\n}\n\ndeclare class int32 {\n toString(): string;\n}\n\ndeclare class uint32 {\n toString(): string;\n}\n\ndeclare class int64 {\n toString(): string;\n}\n\ndeclare class uint64 {\n toString(): string;\n}\n\ndeclare class float32 {\n toString(): string;\n}\n\ndeclare class float64 {\n toString(): string;\n}\n\ndeclare class string {\n charAt(index: int32): string;\n\n charCodeAt(index: int32): uint16;\n\n get length(): int32;\n\n indexOf(text: string): int32;\n\n lastIndexOf(text: string): int32;\n\n operator == (other: string):boolean;\n operator [] (index: int32): uint16 { return this.charCodeAt(index); }\n slice(start: int32, end: int32): string;\n\n // startsWith(text: string): boolean { return this.slice(0, text.length) == text; }\n // endsWith(text: string): boolean { return this.slice(-text.length, this.length) == text; }\n}\n"},function(module,exports){module.exports='//part of asm module, we have global, foreign, buffer somewhere above this code\n\nvar HEAP8 = new global.Int8Array(buffer);\nvar HEAP16 = new global.Int16Array(buffer);\nvar HEAP32 = new global.Int32Array(buffer);\nvar HEAPU8 = new global.Uint8Array(buffer);\nvar HEAPU16 = new global.Uint16Array(buffer);\nvar HEAPU32 = new global.Uint32Array(buffer);\nvar HEAPF32 = new global.Float32Array(buffer);\nvar HEAPF64 = new global.Float64Array(buffer);\n\nvar NULL = 0;\nvar STACKTOP=env.STACKTOP|0;\nvar STACK_MAX=env.STACK_MAX|0;\n\n// var PREV_INUSE = 0x1;\n// var PREV_INUSE = 0x1;\n// var IS_MMAPPED = 0x2;\n// var NON_MAIN_ARENA = 0x4;\n// var SIZE_BITS = 0x7;//(PREV_INUSE|IS_MMAPPED|NON_MAIN_ARENA) | 0;\n// var firstFreeChunk = 0;\n// var lastFreeChunk = 0;\n// var numFreeChunks = 0;\n// var freeMemory = 0;\n//var internal_alloc = 0;\n\n// var _now = (typeof global.performance != \'undefined\' && typeof global.performance.now == \'function\' ?\n// global.performance.now.bind(global.performance) :\n// global.Date.now.bind(global.Date));\n// var _now = global.performance;\n// Map of class type IDs to type objects.\n// var _idToType = 8;\n\n// function init() {\n// HEAP32[2 >> 2] = buffer.byteLength | 0;\n\n // if (global.isShared) {\n // internal_alloc = alloc_sab;\n // global.Atomics.store(HEAP32, 1 | 0, 16 | 0);\n // }\n // else {\n // internal_alloc = alloc_ab;\n // HEAP32[1>>2] = 16 | 0;\n // }\n// }\n\n\n// function malloc(nbytes, alignment) {\n// nbytes |= 0;\n// alignment |= 0;\n// var ptr = alloc_sab(nbytes, alignment);\n// if (ptr == 0)\n// throw new Error("Out of memory");\n// return ptr|0;\n// }\n// function free(ptr) {\n// ptr |= 0;\n// clearInuse(ptr);\n// if (firstFreeChunk == 0) {\n// firstFreeChunk = ptr;\n// }\n//\n// freeMemory = freeMemory + getChunkSize(ptr);\n//\n// var chunkptr = ptr + 4;\n// if (lastFreeChunk > 0) {\n// HEAPU32[chunkptr>>2] = lastFreeChunk;//backward pointer to prev chunk\n// HEAPU32[lastFreeChunk>>2] = ptr;//forward pointer to next chunk of prev chunk\n// } else {\n// HEAPU32[chunkptr>>2] = 0;//no backward pointer, this is the first free chunk\n// }\n//\n// HEAPU32[ptr>>2] = 0;//no forward pointer\n//\n// lastFreeChunk = ptr;\n// numFreeChunks = numFreeChunks + 1;\n// }\n// function identify(ptr) {\n// if (ptr == 0)\n// return 0;\n// return _idToType[HEAP32[ptr >> 2]];\n// }\n// function _badType(self) {\n// var t = identify(self);\n// return new global.Error("Observed type: " + (t ? t.NAME : "*invalid*") + ", address=" + self);\n// }\n// Synchronic layout is 8 bytes (2 x int32) of metadata followed by\n// the type-specific payload. The two int32 words are the number\n// of waiters and the wait word (generation count).\n//\n// In the following:\n//\n// self is the base address for the Synchronic.\n// mem is the array to use for the value\n// idx is the index in mem of the value: (ptr+8)>>log2(mem.BYTES_PER_ELEMENT)\n//\n// _synchronicLoad is just Atomics.load, expand it in-line.\n/*function _synchronicStore(self, mem, idx, value) {\n global.Atomics.store(mem, idx, value);\n _notify(self);\n return value;\n}\nfunction _synchronicCompareExchange(self, mem, idx, oldval, newval) {\n var v = global.Atomics.compareExchange(mem, idx, oldval, newval);\n if (v == oldval)\n _notify(self);\n return v;\n}\nfunction _synchronicAdd(self, mem, idx, value) {\n var v = global.Atomics.add(mem, idx, value);\n _notify(self);\n return v;\n}\nfunction _synchronicSub(self, mem, idx, value) {\n var v = global.Atomics.sub(mem, idx, value);\n _notify(self);\n return v;\n}\nfunction _synchronicAnd(self, mem, idx, value) {\n var v = global.Atomics.and(mem, idx, value);\n _notify(self);\n return v;\n}\nfunction _synchronicOr(self, mem, idx, value) {\n var v = global.Atomics.or(mem, idx, value);\n _notify(self);\n return v;\n}\nfunction _synchronicXor(self, mem, idx, value) {\n var v = global.Atomics.xor(mem, idx, value);\n _notify(self);\n return v;\n}\nfunction _synchronicLoadWhenNotEqual(self, mem, idx, value) {\n for (; ;) {\n var tag = global.Atomics.load(HEAP32, (self + 4) >> 2);\n var v = global.Atomics.load(mem, idx);\n if (v !== value)\n break;\n _waitForUpdate(self, tag, Number.POSITIVE_INFINITY);\n }\n return v;\n}\n\nfunction _synchronicLoadWhenEqual(self, mem, idx, value) {\n for (; ;) {\n var tag = global.Atomics.load(HEAP32, (self + 4) >> 2);\n var v = global.Atomics.load(mem, idx);\n if (v === value)\n break;\n _waitForUpdate(self, tag, Number.POSITIVE_INFINITY);\n }\n return v;\n}\nfunction _synchronicExpectUpdate(self, mem, idx, value, timeout) {\n var now = global.performance();\n var limit = now + timeout;\n for (; ;) {\n var tag = global.Atomics.load(HEAP32, (self + 4) >> 2);\n var v = global.Atomics.load(mem, idx);\n if (v !== value || now >= limit)\n break;\n _waitForUpdate(self, tag, limit - now);\n now = global.performance();\n }\n}\nfunction _waitForUpdate(self, tag, timeout) {\n // Spin for a int16 time before going into the futexWait.\n //\n // Hard to know what a good count should be - it is machine\n // dependent, for sure, and "typical" applications should\n // influence the choice. If the count is high without\n // hindering an eventual drop into futexWait then it will just\n // decrease performance. If the count is low it is pointless.\n // (This is why Synchronic really wants a native implementation.)\n //\n // data points from a 2.6GHz i7 MacBook Pro:\n //\n // - the simple send-integer benchmark (test-sendint.html),\n // which is the very simplest case we can really imagine,\n // gets noisy timings with an iteration count below 4000\n //\n // - the simple send-object benchmark (test-sendmsg.html)\n // gets a boost when the count is at least 10000\n //\n // 10000 is perhaps 5us (CPI=1, naive) and seems like a\n // reasonable cutoff, for now - but note, it is reasonable FOR\n // THIS SYSTEM ONLY, which is a big flaw.\n //\n // The better fix might well be to add some kind of spin/nanosleep\n // functionality to futexWait, see https://bugzil.la/1134973.\n // That functionality can be platform-dependent and even\n // adaptive, with JIT support.\n var i = 10000;\n do {\n // May want this to be a relaxed load, though on x86 it won\'t matter.\n if (global.Atomics.load(HEAP32, (self + 4) >> 2) != tag)\n return;\n } while (--i > 0);\n global.Atomics.add(HEAP32, self >> 2, 1);\n global.Atomics.wait(HEAP32, (self + 4) >> 2, tag, timeout);\n global.Atomics.sub(HEAP32, self >> 2, 1);\n}\nfunction _notify(self) {\n global.Atomics.add(HEAP32, (self + 4) >> 2, 1);\n // Would it be appropriate & better to wake n waiters, where n\n // is the number loaded in the load()? I almost think so,\n // since our futexes are fair.\n if (global.Atomics.load(HEAP32, self >> 2) > 0)\n global.Atomics.wake(HEAP32, (self + 4) >> 2, Number.POSITIVE_INFINITY);\n}*/\n\n// function getFreeChunk(nbytes) {\n// nbytes = nbytes | 0;\n// if (numFreeChunks > (0 | 0)) {\n// var freeChunk = findChunk(nbytes);\n// if (freeChunk > (0 | 0)) {\n// if (freeChunk == firstFreeChunk) {\n// firstFreeChunk = nextFree(freeChunk);\n// }\n// if (freeChunk == lastFreeChunk) {\n// lastFreeChunk = (0 | 0);\n// }\n// numFreeChunks = numFreeChunks - (1 | 0);\n// setInuse(freeChunk);\n// freeMemory = freeMemory - getChunkSize(freeChunk);\n// return freeChunk;\n// }\n// }\n// return 0 | 0;\n// }\n// function findChunk(nbytes) {\n// nbytes = nbytes | 0;\n// var chunk = firstFreeChunk;\n// while (chunk != 0) {\n// if (getChunkSize(chunk) == nbytes) {\n// return chunk;\n// }\n// chunk = HEAPU32[chunk>>2];\n// }\n// return 0;\n// }\n// function prevFree(ptr) {\n// return HEAPU32[(ptr + 4)>>2];\n// }\n// function nextFree(ptr) {\n// return HEAPU32[ptr>>2];\n// }\n// /* Set size at head, without disturbing its use bit */\n// function setHeadSize(ptr, s) {\n// HEAPU32[ptr>>2] = (HEAPU32[ptr>>2] & SIZE_BITS) | s;\n// }\n//\n// /* Set size/use field */\n// function setHead(ptr, s) {\n// HEAPU32[ptr>>2] = s;\n// }\n//\n// /* Set size at footer (only when chunk is not in use) */\n// function setFoot(ptr, s) {\n// HEAPU32[(ptr + s)>>2] = s;\n// }\n//\n// function getPrevInuse(ptr) {\n// return HEAPU32[(ptr - 8)>>2] & (PREV_INUSE);\n// }\n// function setInuse(ptr) {\n// HEAPU32[(ptr - 4)>>2] |= PREV_INUSE;\n// }\n// function getInuse(ptr) {\n// return HEAPU32[(ptr - 4)>>2] & PREV_INUSE;\n// }\n// function clearInuse(ptr) {\n// HEAPU32[(ptr - 4)>>2] &= ~PREV_INUSE;\n// }\n// function getChunkSize(ptr) {\n// return HEAPU32[(ptr - 4)>>2] & ~(PREV_INUSE);\n// }\n//\n// function alloc_sab(nbytes, alignment) {\n// nbytes = nbytes | 0;\n// alignment = alignment | 0;\n// if (numFreeChunks > 0) {\n// var chunk = getFreeChunk(nbytes);\n// if (chunk > (0 | 0)) {\n// return chunk;\n// }\n// }\n//\n// do {\n// var ptr = global.Atomics.load(HEAP32, 1);\n// var q = (ptr + (alignment - 1)) & ~(alignment - 1);\n// var top = q + nbytes;\n// if (top >= HEAP32[2>>2])\n// return 0;\n// } while (global.Atomics.compareExchange(HEAP32, 1, ptr, top) != ptr);\n//\n// return q;\n// }\n// function alloc_ab(nbytes, alignment) {\n// nbytes = nbytes | 0;\n// alignment = alignment | 0;\n//\n// var ptr = HEAP32[1>>2] | 0;\n// ptr = ((ptr + (alignment - 1)) & ~(alignment - 1)) | 0;\n// var top = (ptr + nbytes) | 0;\n// if (top >= HEAP32[2>>2])\n// return 0 | 0;\n// HEAP32[1>>2] = top | 0;\n// return ptr | 0;\n// }'},function(module,exports){module.exports="declare class boolean {\n toString(): string;\n}\n\ndeclare class int8 {\n toString(): string;\n}\n\ndeclare class uint8 {\n toString(): string;\n}\n\ndeclare class int16 {\n toString(): string;\n}\n\ndeclare class uint16 {\n toString(): string;\n}\n\ndeclare class int32 {\n toString(): string;\n}\n\ndeclare class uint32 {\n toString(): string;\n}\n\ndeclare class int64 {\n toString(): string;\n}\n\ndeclare class uint64 {\n toString(): string;\n}\n\ndeclare class float32 {\n toString(): string;\n}\n\ndeclare class float64 {\n toString(): string;\n}\n\ndeclare class string {\n charAt(index: int32): string;\n charCodeAt(index: int32): uint16;\n get length(): int32;\n indexOf(text: string): int32;\n lastIndexOf(text: string): int32;\n operator == (other: string): boolean;\n operator [] (index: int32): uint16 { return this.charCodeAt(index); }\n slice(start: int32, end: int32): string;\n\n startsWith(text: string): boolean { return this.slice(0, text.length) == text; }\n endsWith(text: string): boolean { return this.slice(-text.length, this.length) == text; }\n}"},function(module,exports){module.exports="function TurboWrapper(exports, buffer) {\n\n var HEAP8 = new Int8Array(buffer);\n var HEAP16 = new Int16Array(buffer);\n var HEAP32 = new Int32Array(buffer);\n var HEAPU8 = new Uint8Array(buffer);\n var HEAPU16 = new Uint16Array(buffer);\n var HEAPU32 = new Uint32Array(buffer);\n var HEAPF32 = new Float32Array(buffer);\n var HEAPF64 = new Float64Array(buffer);\n\n return {\n exports: exports,\n RAW_MEMORY: buffer,\n\n getMemoryUsage: function () {\n const top = Atomics.load(HEAP32, 2);\n // top -= freeMemory;\n return Math.fround(top / (1024 * 1024));\n }\n }\n}\nfunction initTurbo(MB) {\n var buffer = new SharedArrayBuffer(MB * 1024 * 1024);\n\n if (buffer.byteLength < 16) {\n throw new Error(\"The memory is too small even for metadata\");\n }\n\n return TurboWrapper(TurboModule(\n typeof global !== 'undefined' ? global : window,\n typeof env !== 'undefined' ? env : {\n STACKTOP: 8,\n STACK_MAX: 8\n },\n buffer\n ), buffer);\n}"},function(module,exports){module.exports="// WebAssembly builtin functions\ndeclare function rotl(value: int64, shift: int64): int64;\ndeclare function rotl32(value: int32, shift: int32): int32;\ndeclare function rotr(value: int64, shift: int64): int64;\ndeclare function rotr32(value: int32, shift: int32): int32;\ndeclare function clz(value: int64): int64;\ndeclare function clz32(value: int32): int32;\ndeclare function ctz(value: int64): int64;\ndeclare function ctz32(value: int32): int32;\ndeclare function popcnt(value: int64): int64;\ndeclare function popcnt32(value: int32): int32;\ndeclare function abs(value: float64): float64;\ndeclare function abs32(value: float32): float32;\ndeclare function ceil(value: float64): float64;\ndeclare function ceil32(value: float32): float32;\ndeclare function floor(value: float64): float64;\ndeclare function floor32(value: float32): float32;\ndeclare function sqrt(value: float64): float64;\ndeclare function sqrt32(value: float32): float32;\ndeclare function trunc(value: float64): float64;\ndeclare function trunc32(value: float32): float32;\ndeclare function nearest(value: float64): float64;\ndeclare function nearest32(value: float32): float32;\ndeclare function min(left: float64, right: float64): float64;\ndeclare function min32(left: float32, right: float32): float32;\ndeclare function max(left: float64, right: float64): float64;\ndeclare function max32(left: float32, right: float32): float32;\ndeclare function copysign(left: float64, right: float64): float64;\ndeclare function copysign32(left: float32, right: float32): float32;\ndeclare function reinterpret_i32(value: float32): int32;\ndeclare function reinterpret_i64(value: float64): int64;\ndeclare function reinterpret_f32(value: int32): float32;\ndeclare function reinterpret_f64(value: int64): float64;\ndeclare function current_memory(): int32;\ndeclare function grow_memory(value: int32): int32;\n"},function(module,exports){module.exports="/**\n * Created by n.vinayakan on 30.05.17.\n * WebAssembly start function where global variable expressions initializer\n */\n@start\nfunction __WASM_INITIALIZER(): void {\n // 🔥 WARNING 🔥\n // DON'T RETURN ANYTHING FROM THIS FUNCTION\n // Global variable initialization expressions will be appended to this function\n numFreeChunks = 0;\n firstFree = 0;\n lastFree = 0;\n // originalHeapPointer = 40 as *uint8;//this will override by compiler\n // currentHeapPointer = 40 as *uint8;//this will override by compiler\n}\n"},function(module,exports,__webpack_require__){"use strict";function append(array,offset,value,msg){void 0===offset&&(offset=0),void 0===value&&(value=null),void 0===msg&&(msg=null),array.log+=(null!=value?utils_1.toHex(offset+array.position)+": "+utils_1.toHex(value,2)+" ; ":"")+(null!=msg?msg+"\n":"\n"),value&&array.append(value)}function logOpcode(array,offset,opcode,inline_value){void 0===offset&&(offset=0),array.log+=utils_1.toHex(offset+array.position)+": "+utils_1.toHex(opcode,2)+" ; "+opcode_1.WasmOpcode[opcode]+" "+(inline_value||"")+"\n"}Object.defineProperty(exports,"__esModule",{value:!0});var wasm_stack_tracer_1=__webpack_require__(44),utils_1=__webpack_require__(6),opcode_1=__webpack_require__(8),section_buffer_1=__webpack_require__(35),logger_1=__webpack_require__(10),wasm_section_1=__webpack_require__(14),wasm_runtime_local_1=__webpack_require__(15),wasm_type_1=__webpack_require__(7),terminal_1=__webpack_require__(1),index_1=__webpack_require__(16),WasmAssembler=function(){function WasmAssembler(){this.sectionList=[],this.importList=[],this.functionList=[],this.currentSection=null,this.currentFunction=null,this.stackTracer=new wasm_stack_tracer_1.WasmStackTracer,this.textOutput=";; Experimental wast emitter\n(module\n"}return WasmAssembler.prototype.sealFunctions=function(){var runtimeFunctions=[];this.importList.forEach(function(_import){var fn=new wasm_stack_tracer_1.WasmRuntimeFunction;fn.module=_import.module,fn.name=_import.name,fn.signature=_import.signature,fn.isImport=!0,runtimeFunctions.push(fn)}),this.functionList.forEach(function(_wasmFunc){var fn=new wasm_stack_tracer_1.WasmRuntimeFunction;fn.name=index_1.getWasmFunctionName(_wasmFunc.symbol),fn.signature=_wasmFunc.signature,fn.isImport=!1,fn.locals=[],_wasmFunc.localEntries.forEach(function(local){fn.locals.push(new wasm_runtime_local_1.WasmRuntimeProperty(local.type,local.name))}),runtimeFunctions.push(fn)}),this.stackTracer.functions=runtimeFunctions},WasmAssembler.prototype.startSection=function(array,id,name){var section=new section_buffer_1.SectionBuffer(id,name);return section.offset=array.length,logger_1.log(array,0,null," - section: "+wasm_section_1.WasmSection[id]+" [0x"+utils_1.toHex(id,2)+"]"),this.currentSection=section,this.sectionList.push(section),section},WasmAssembler.prototype.endSection=function(array,section){this.currentSection=null,section.publish(array)},WasmAssembler.prototype.dropStack=function(array,max){if(void 0===max&&(max=1),this.stackTracer.context.stack.length>0){terminal_1.Terminal.warn("Dropping stack items, '"+this.stackTracer.context.fn.name+"' func stack contains "+this.stackTracer.context.stack.length+" items");for(var item=this.stackTracer.context.stack.pop(!0);void 0!==item&&max>0;)terminal_1.Terminal.warn(wasm_type_1.WasmType[item.type]),array.append(opcode_1.WasmOpcode.DROP),this.currentSection.code.append("drop\n"),item=this.stackTracer.context.stack.pop(!0),max--}},WasmAssembler.prototype.appendOpcode=function(array,offset,opcode,inline_value,skip){void 0===offset&&(offset=0),void 0===skip&&(skip=!1),logOpcode(array,offset,opcode,inline_value),array.append(opcode);var opcodeWithoutOperand=this.stackTracer.pushOpcode(opcode);if(null!==opcodeWithoutOperand&&!skip){var isEnd=opcode===opcode_1.WasmOpcode.END,indent=this.isBlock(opcode)?1:isEnd?-1:0;isEnd&&this.currentSection.code.clearIndent(1),this.currentSection.code.append(opcodeWithoutOperand+"\n",indent)}},WasmAssembler.prototype.isBlock=function(opcode){return opcode===opcode_1.WasmOpcode.BLOCK||opcode===opcode_1.WasmOpcode.LOOP||opcode===opcode_1.WasmOpcode.IF||opcode===opcode_1.WasmOpcode.IF_ELSE},WasmAssembler.prototype.writeUnsignedLEB128=function(array,value){array.writeUnsignedLEB128(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.currentSection.code.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeLEB128=function(array,value){array.writeLEB128(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.currentSection.code.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeFloat=function(array,value){array.writeFloat(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.currentSection.code.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeDouble=function(array,value){array.writeDouble(value);var opcodeAndOperand=this.stackTracer.pushValue(value);null!==opcodeAndOperand&&this.currentSection.code.append(opcodeAndOperand+"\n")},WasmAssembler.prototype.writeWasmString=function(array,value){array.writeWasmString(value)},WasmAssembler.prototype.finish=function(){var _this=this;this.textOutput+=" ",this.sectionList.forEach(function(section){_this.textOutput+=section.code.finish()}),this.textOutput+=")\n"},WasmAssembler}();exports.WasmAssembler=WasmAssembler,exports.append=append,exports.logOpcode=logOpcode},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var logger_1=__webpack_require__(10),bytearray_1=__webpack_require__(12),stringbuilder_1=__webpack_require__(54),SectionBuffer=function(){function SectionBuffer(id,name){this.id=id,this.name=name,this.data=new bytearray_1.ByteArray,this.code=new stringbuilder_1.StringBuilder(2),this.code.indent=1}return SectionBuffer.prototype.publish=function(array){if(logger_1.log(array,0,this.id,"section code"),array.writeUnsignedLEB128(this.id),0==this.id){var strData=new bytearray_1.ByteArray;strData.writeWasmString(this.name),logger_1.log(array,0,this.data.length,"section size"),array.writeUnsignedLEB128(this.data.length+strData.length),array.copy(strData)}else logger_1.log(array,0,this.data.length,"section size"),array.writeUnsignedLEB128(this.data.length);array.log+=this.data.log,array.copy(this.data)},SectionBuffer}();exports.SectionBuffer=SectionBuffer},function(module,exports,__webpack_require__){"use strict";function getBuiltinOpcode(name){switch(name){case"rotl":return opcode_1.WasmOpcode.I64_ROTL;case"rotl32":return opcode_1.WasmOpcode.I32_ROTL;case"rotr":return opcode_1.WasmOpcode.I64_ROTR;case"rotr32":return opcode_1.WasmOpcode.I32_ROTR;case"clz":return opcode_1.WasmOpcode.I64_CLZ;case"clz32":return opcode_1.WasmOpcode.I32_CLZ;case"ctz":return opcode_1.WasmOpcode.I64_CTZ;case"ctz32":return opcode_1.WasmOpcode.I32_CTZ;case"popcnt":return opcode_1.WasmOpcode.I64_POPCNT;case"popcnt32":return opcode_1.WasmOpcode.I32_POPCNT;case"abs":return opcode_1.WasmOpcode.F64_ABS;case"abs32":return opcode_1.WasmOpcode.F32_ABS;case"ceil":return opcode_1.WasmOpcode.F64_CEIL;case"ceil32":return opcode_1.WasmOpcode.F32_CEIL;case"floor":return opcode_1.WasmOpcode.F64_FLOOR;case"floor32":return opcode_1.WasmOpcode.F32_FLOOR;case"sqrt":return opcode_1.WasmOpcode.F64_SQRT;case"sqrt32":return opcode_1.WasmOpcode.F32_SQRT;case"trunc":return opcode_1.WasmOpcode.F64_TRUNC;case"trunc32":return opcode_1.WasmOpcode.F32_TRUNC;case"nearest":return opcode_1.WasmOpcode.F64_NEAREST;case"nearest32":return opcode_1.WasmOpcode.F32_NEAREST;case"min":return opcode_1.WasmOpcode.F64_MIN;case"min32":return opcode_1.WasmOpcode.F32_MIN;case"max":return opcode_1.WasmOpcode.F64_MAX;case"max32":return opcode_1.WasmOpcode.F32_MAX;case"copysign":return opcode_1.WasmOpcode.F64_COPYSIGN;case"copysign32":return opcode_1.WasmOpcode.F32_COPYSIGN;case"reinterpret_i32":return opcode_1.WasmOpcode.F32_REINTERPRET_I32;case"reinterpret_i64":return opcode_1.WasmOpcode.F64_REINTERPRET_I64;case"reinterpret_f32":return opcode_1.WasmOpcode.I32_REINTERPRET_F32;case"reinterpret_f64":return opcode_1.WasmOpcode.I64_REINTERPRET_F64;case"current_memory":return opcode_1.WasmOpcode.MEMORY_SIZE;case"grow_memory":return opcode_1.WasmOpcode.GROW_MEMORY;default:throw"No builtin function named '"+name+"'"}}function isBuiltin(name){return exports.builtins.indexOf(name)>-1}Object.defineProperty(exports,"__esModule",{value:!0});var opcode_1=__webpack_require__(8);exports.builtins=["rotl","rotl32","rotr","rotr32","clz","clz32","ctz","ctz32","popcnt","popcnt32","abs","abs32","ceil","ceil32","floor","floor32","sqrt","sqrt32","trunc","trunc32","nearest","nearest32","min","min32","max","max32","copysign","copysign32","reinterpret_i32","reinterpret_i64","reinterpret_f32","reinterpret_f64","current_memory","grow_memory"],exports.getBuiltinOpcode=getBuiltinOpcode,exports.isBuiltin=isBuiltin},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});!function(WasmExternalKind){WasmExternalKind[WasmExternalKind.Function=0]="Function",WasmExternalKind[WasmExternalKind.Table=1]="Table",WasmExternalKind[WasmExternalKind.Memory=2]="Memory",WasmExternalKind[WasmExternalKind.Global=3]="Global"}(exports.WasmExternalKind||(exports.WasmExternalKind={}))},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmFunction=function(){function WasmFunction(){this.localCount=0,this.localVariables=[]}return WasmFunction}();exports.WasmFunction=WasmFunction},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmGlobalEntry=function(){function WasmGlobalEntry(type,immutable,name){this.type=type,this.immutable=immutable,this.name=name}return WasmGlobalEntry}();exports.WasmGlobalEntry=WasmGlobalEntry;var WasmGlobal=function(){function WasmGlobal(){}return WasmGlobal}();exports.WasmGlobal=WasmGlobal},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmImport=function(){function WasmImport(){}return WasmImport}();exports.WasmImport=WasmImport},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmLocalEntry=function(){function WasmLocalEntry(type,name,isArgument){void 0===isArgument&&(isArgument=!1),this.type=type,this.name=name,this.isArgument=isArgument}return WasmLocalEntry}();exports.WasmLocalEntry=WasmLocalEntry;var WasmLocal=function(){function WasmLocal(){}return WasmLocal}();exports.WasmLocal=WasmLocal},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var WasmSharedOffset=function(){function WasmSharedOffset(){this.nextLocalOffset=0,this.localCount=0}return WasmSharedOffset}();exports.WasmSharedOffset=WasmSharedOffset},function(module,exports,__webpack_require__){"use strict";function wasmAreSignaturesEqual(a,b){assert_1.assert(null!=a.returnType),assert_1.assert(null!=b.returnType),assert_1.assert(null==a.returnType.next),assert_1.assert(null==b.returnType.next);for(var x=a.argumentTypes,y=b.argumentTypes;null!=x&&null!=y;){if(x.id!=y.id)return!1;x=x.next,y=y.next}return null==x&&null==y&&a.returnType.id==b.returnType.id}Object.defineProperty(exports,"__esModule",{value:!0});var assert_1=__webpack_require__(0),WasmSignature=function(){function WasmSignature(){}return WasmSignature}();exports.WasmSignature=WasmSignature,exports.wasmAreSignaturesEqual=wasmAreSignaturesEqual},function(module,exports,__webpack_require__){"use strict";function getOprandType(opcode){switch(opcode){case opcode_1.WasmOpcode.I32_CONST:case opcode_1.WasmOpcode.I32_ADD:case opcode_1.WasmOpcode.I32_MUL:case opcode_1.WasmOpcode.I32_SUB:case opcode_1.WasmOpcode.I32_DIV_S:case opcode_1.WasmOpcode.I32_DIV_U:case opcode_1.WasmOpcode.I32_REM_S:case opcode_1.WasmOpcode.I32_REM_U:case opcode_1.WasmOpcode.I32_GE_S:case opcode_1.WasmOpcode.I32_GE_U:case opcode_1.WasmOpcode.I32_LE_S:case opcode_1.WasmOpcode.I32_LE_U:case opcode_1.WasmOpcode.I32_GT_S:case opcode_1.WasmOpcode.I32_GT_U:case opcode_1.WasmOpcode.I32_LT_S:case opcode_1.WasmOpcode.I32_LT_U:case opcode_1.WasmOpcode.I32_EQ:case opcode_1.WasmOpcode.I32_NE:case opcode_1.WasmOpcode.I32_EQZ:case opcode_1.WasmOpcode.I32_AND:case opcode_1.WasmOpcode.I32_OR:case opcode_1.WasmOpcode.I32_XOR:case opcode_1.WasmOpcode.I32_CTZ:case opcode_1.WasmOpcode.I32_CLZ:case opcode_1.WasmOpcode.I32_ROTL:case opcode_1.WasmOpcode.I32_ROTR:case opcode_1.WasmOpcode.I32_SHL:case opcode_1.WasmOpcode.I32_SHR_S:case opcode_1.WasmOpcode.I32_SHR_U:case opcode_1.WasmOpcode.I32_POPCNT:case opcode_1.WasmOpcode.I32_LOAD:case opcode_1.WasmOpcode.I32_LOAD8_S:case opcode_1.WasmOpcode.I32_LOAD8_U:case opcode_1.WasmOpcode.I32_LOAD16_S:case opcode_1.WasmOpcode.I32_LOAD16_U:case opcode_1.WasmOpcode.I32_STORE16:case opcode_1.WasmOpcode.I32_STORE8:case opcode_1.WasmOpcode.I32_STORE:case opcode_1.WasmOpcode.I32_REINTERPRET_F32:case opcode_1.WasmOpcode.I32_TRUNC_S_F32:case opcode_1.WasmOpcode.I32_TRUNC_U_F32:case opcode_1.WasmOpcode.I32_TRUNC_S_F64:case opcode_1.WasmOpcode.I32_TRUNC_U_F64:case opcode_1.WasmOpcode.I32_WRAP_I64:return wasm_type_1.WasmType.I32;case opcode_1.WasmOpcode.I64_CONST:case opcode_1.WasmOpcode.I64_ADD:case opcode_1.WasmOpcode.I64_MUL:case opcode_1.WasmOpcode.I64_SUB:case opcode_1.WasmOpcode.I64_DIV_S:case opcode_1.WasmOpcode.I64_DIV_U:case opcode_1.WasmOpcode.I64_CLZ:case opcode_1.WasmOpcode.I64_ROTL:case opcode_1.WasmOpcode.I64_AND:case opcode_1.WasmOpcode.I64_CTZ:case opcode_1.WasmOpcode.I64_EQ:case opcode_1.WasmOpcode.I64_EQZ:case opcode_1.WasmOpcode.I64_GE_S:case opcode_1.WasmOpcode.I64_GE_U:case opcode_1.WasmOpcode.I64_LE_S:case opcode_1.WasmOpcode.I64_LE_U:case opcode_1.WasmOpcode.I64_GT_S:case opcode_1.WasmOpcode.I64_GT_U:case opcode_1.WasmOpcode.I64_LT_S:case opcode_1.WasmOpcode.I64_LT_U:case opcode_1.WasmOpcode.I64_LOAD:case opcode_1.WasmOpcode.I64_LOAD8_S:case opcode_1.WasmOpcode.I64_LOAD8_U:case opcode_1.WasmOpcode.I64_LOAD16_S:case opcode_1.WasmOpcode.I64_LOAD16_U:case opcode_1.WasmOpcode.I64_NE:case opcode_1.WasmOpcode.I64_XOR:case opcode_1.WasmOpcode.I64_STORE16:case opcode_1.WasmOpcode.I64_STORE8:case opcode_1.WasmOpcode.I64_STORE:case opcode_1.WasmOpcode.I64_SHR_S:case opcode_1.WasmOpcode.I64_SHR_U:case opcode_1.WasmOpcode.I64_SHL:case opcode_1.WasmOpcode.I64_ROTR:case opcode_1.WasmOpcode.I64_REM_S:case opcode_1.WasmOpcode.I64_REM_U:case opcode_1.WasmOpcode.I64_POPCNT:case opcode_1.WasmOpcode.I64_OR:case opcode_1.WasmOpcode.I64_REINTERPRET_F64:case opcode_1.WasmOpcode.I64_TRUNC_S_F32:case opcode_1.WasmOpcode.I64_TRUNC_U_F32:case opcode_1.WasmOpcode.I64_TRUNC_S_F64:case opcode_1.WasmOpcode.I64_TRUNC_U_F64:case opcode_1.WasmOpcode.I64_EXTEND_S_I32:case opcode_1.WasmOpcode.I64_EXTEND_U_I32:return wasm_type_1.WasmType.I64;case opcode_1.WasmOpcode.F32_CONST:case opcode_1.WasmOpcode.F32_ADD:case opcode_1.WasmOpcode.F32_SUB:case opcode_1.WasmOpcode.F32_MUL:case opcode_1.WasmOpcode.F32_DIV:case opcode_1.WasmOpcode.F32_SQRT:case opcode_1.WasmOpcode.F32_NEG:case opcode_1.WasmOpcode.F32_NE:case opcode_1.WasmOpcode.F32_ABS:case opcode_1.WasmOpcode.F32_CEIL:case opcode_1.WasmOpcode.F32_EQ:case opcode_1.WasmOpcode.F32_FLOOR:case opcode_1.WasmOpcode.F32_NEAREST:case opcode_1.WasmOpcode.F32_MIN:case opcode_1.WasmOpcode.F32_MAX:case opcode_1.WasmOpcode.F32_GE:case opcode_1.WasmOpcode.F32_GT:case opcode_1.WasmOpcode.F32_LT:case opcode_1.WasmOpcode.F32_LE:case opcode_1.WasmOpcode.F32_COPYSIGN:case opcode_1.WasmOpcode.F32_LOAD:case opcode_1.WasmOpcode.F32_STORE:case opcode_1.WasmOpcode.F32_TRUNC:case opcode_1.WasmOpcode.F32_DEMOTE_F64:case opcode_1.WasmOpcode.F32_CONVERT_S_I32:case opcode_1.WasmOpcode.F32_CONVERT_U_I32:case opcode_1.WasmOpcode.F32_CONVERT_S_I64:case opcode_1.WasmOpcode.F32_CONVERT_U_I64:case opcode_1.WasmOpcode.F32_REINTERPRET_I32:return wasm_type_1.WasmType.F32;case opcode_1.WasmOpcode.F64_CONST:case opcode_1.WasmOpcode.F64_ADD:case opcode_1.WasmOpcode.F64_SUB:case opcode_1.WasmOpcode.F64_MUL:case opcode_1.WasmOpcode.F64_DIV:case opcode_1.WasmOpcode.F64_SQRT:case opcode_1.WasmOpcode.F64_NEG:case opcode_1.WasmOpcode.F64_NE:case opcode_1.WasmOpcode.F64_ABS:case opcode_1.WasmOpcode.F64_CEIL:case opcode_1.WasmOpcode.F64_EQ:case opcode_1.WasmOpcode.F64_FLOOR:case opcode_1.WasmOpcode.F64_NEAREST:case opcode_1.WasmOpcode.F64_MIN:case opcode_1.WasmOpcode.F64_MAX:case opcode_1.WasmOpcode.F64_GE:case opcode_1.WasmOpcode.F64_GT:case opcode_1.WasmOpcode.F64_LT:case opcode_1.WasmOpcode.F64_LE:case opcode_1.WasmOpcode.F64_COPYSIGN:case opcode_1.WasmOpcode.F64_LOAD:case opcode_1.WasmOpcode.F64_STORE:case opcode_1.WasmOpcode.F64_TRUNC:case opcode_1.WasmOpcode.F64_PROMOTE_F32:case opcode_1.WasmOpcode.F64_CONVERT_S_I32:case opcode_1.WasmOpcode.F64_CONVERT_U_I32:case opcode_1.WasmOpcode.F64_CONVERT_S_I64:case opcode_1.WasmOpcode.F64_CONVERT_U_I64:case opcode_1.WasmOpcode.F64_REINTERPRET_I64:return wasm_type_1.WasmType.F64;case opcode_1.WasmOpcode.CALL:case opcode_1.WasmOpcode.END:case opcode_1.WasmOpcode.RETURN:case opcode_1.WasmOpcode.GET_GLOBAL:case opcode_1.WasmOpcode.GET_LOCAL:case opcode_1.WasmOpcode.SET_LOCAL:case opcode_1.WasmOpcode.SET_GLOBAL:case opcode_1.WasmOpcode.BLOCK:case opcode_1.WasmOpcode.LOOP:case opcode_1.WasmOpcode.IF:case opcode_1.WasmOpcode.IF_ELSE:case opcode_1.WasmOpcode.BR:case opcode_1.WasmOpcode.BR_IF:case opcode_1.WasmOpcode.BR_TABLE:case opcode_1.WasmOpcode.NOP:return null;default:terminal_1.Terminal.warn("Unhandled Opcode "+opcode+" => "+opcode_1.WasmOpcode[opcode])}return null}Object.defineProperty(exports,"__esModule",{value:!0});var wasm_type_1=__webpack_require__(7),opcode_1=__webpack_require__(8),wasm_runtime_local_1=__webpack_require__(15),bytearray_1=__webpack_require__(12),terminal_1=__webpack_require__(1),clz32=Math.clz32||function(value){},WasmStackItem=function(){function WasmStackItem(type,value){this.type=type,this.value=value}return WasmStackItem}();exports.WasmStackItem=WasmStackItem;var WasmStack=function(){function WasmStack(){this.list=[]}return Object.defineProperty(WasmStack.prototype,"length",{get:function(){return this.list.length},enumerable:!0,configurable:!0}),WasmStack.prototype.push=function(item){this.list.push(item)},WasmStack.prototype.pop=function(silent){if(void 0===silent&&(silent=!1),0===this.list.length&&!silent){terminal_1.Terminal.warn("Stack is empty")}return this.list.pop()},WasmStack.prototype.clear=function(){this.list=[]},WasmStack}();exports.WasmStack=WasmStack;var WasmRuntimeFunction=function(){function WasmRuntimeFunction(){}return Object.defineProperty(WasmRuntimeFunction.prototype,"returnType",{get:function(){return this.signature.returnType.id},enumerable:!0,configurable:!0}),WasmRuntimeFunction.prototype.execute=function(){for(var param=[],_i=0;_i0&&this.context.fn.returnType===wasm_type_1.WasmType.VOID){var error="Function '"+this.context.fn.name+"' does not return anything but stack is not empty. Stack contains "+this.context.stack.length+" items";terminal_1.Terminal.error(error)}this.context=null},WasmStackTracer.prototype.callFunction=function(index){var fn=this.functions[index];if(void 0===fn)throw"Function not defined at index "+index;for(var returnType=fn.returnType,i=0;ib.value?1:0)),opcode_1.WasmOpcode[opcode];case opcode_1.WasmOpcode.I32_GE_S:case opcode_1.WasmOpcode.I32_GE_U:case opcode_1.WasmOpcode.I64_GE_S:case opcode_1.WasmOpcode.I64_GE_U:case opcode_1.WasmOpcode.F32_GE:case opcode_1.WasmOpcode.F64_GE:var a=this.context.stack.pop(),b=this.context.stack.pop();return this.context.stack.push(new WasmStackItem(type,a.value>=b.value?1:0)),opcode_1.WasmOpcode[opcode];case opcode_1.WasmOpcode.I32_LT_S:case opcode_1.WasmOpcode.I32_LT_U:case opcode_1.WasmOpcode.I64_LT_S:case opcode_1.WasmOpcode.I64_LT_U:case opcode_1.WasmOpcode.F32_LT:case opcode_1.WasmOpcode.F64_LT:var a=this.context.stack.pop(),b=this.context.stack.pop();return this.context.stack.push(new WasmStackItem(type,a.value "+opcode_1.WasmOpcode[opcode])}return null},WasmStackTracer}();exports.WasmStackTracer=WasmStackTracer},function(module,exports,__webpack_require__){"use strict";function wasmAssignLocalVariableOffsets(fn,node,shared,bitness){if(node.kind==node_1.NodeKind.VARIABLE){assert_1.assert(node.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL),shared.nextLocalOffset=shared.nextLocalOffset+1,shared.localCount=shared.localCount+1;var local=new wasm_local_1.WasmLocal;local.symbol=node.symbol,local.type=index_1.symbolToValueType(local.symbol,bitness),null==fn.firstLocal?fn.firstLocal=local:fn.lastLocal.next=local,fn.lastLocal=local,node.symbol.offset=fn.argumentEntries.length+fn.localVariables.length,fn.localVariables.push(new wasm_local_1.WasmLocalEntry(local.type,local.symbol.name))}for(var child=node.firstChild;null!=child;)wasmAssignLocalVariableOffsets(fn,child,shared,bitness),child=child.nextSibling}function wasmEmit(compiler,bitness){void 0===bitness&&(bitness=bitness_1.Bitness.x32);var module=new WasmModule(bitness);module.context=compiler.context,module.memoryInitializer=new bytearray_1.ByteArray,module.startFunctionIndex=-1,module.mallocFunctionIndex=-1,module.freeFunctionIndex=-1,module.currentHeapPointer=-1,module.originalHeapPointer=-1,module.prepareToEmit(compiler.global),module.assembler.sealFunctions(),compiler.outputWASM=new bytearray_1.ByteArray,module.emitModule(compiler.outputWASM),compiler.outputWAST=module.assembler.textOutput}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(3),bytearray_1=__webpack_require__(12),utils_1=__webpack_require__(6),node_1=__webpack_require__(5),opcode_1=__webpack_require__(8),builtins_helper_1=__webpack_require__(36),assert_1=__webpack_require__(0),wasm_type_1=__webpack_require__(7),logger_1=__webpack_require__(10),wasm_signature_1=__webpack_require__(43),bitness_1=__webpack_require__(13),wasm_section_1=__webpack_require__(14),wasm_external_kind_1=__webpack_require__(37),wasm_global_1=__webpack_require__(39),wasm_function_1=__webpack_require__(38),wasm_import_1=__webpack_require__(40),wasm_local_1=__webpack_require__(41),wasm_shared_offset_1=__webpack_require__(42),wasm_assembler_1=__webpack_require__(34),terminal_1=__webpack_require__(1),index_1=__webpack_require__(16),WasmModule=function(){function WasmModule(bitness){this.bitness=bitness,this.importCount=0,this.globalCount=0,this.functionCount=0,this.signatureCount=0,this.assembler=new wasm_assembler_1.WasmAssembler}return WasmModule.prototype.growMemoryInitializer=function(){for(var array=this.memoryInitializer,current=array.length,length=this.context.nextGlobalVariableOffset;current0&§ion.code.append(" (param");null!=type;)logger_1.log(section.data,array.position,type.id,wasm_type_1.WasmType[type.id]),this.assembler.writeUnsignedLEB128(section.data,type.id),section.code.append(" "+wasm_type_1.WasmTypeToString[type.id]),type=type.next;count>0&§ion.code.append(")");signature.returnType.id>0?(logger_1.log(section.data,array.position,"01","num results"),this.assembler.writeUnsignedLEB128(section.data,1),logger_1.log(section.data,array.position,signature.returnType.id,wasm_type_1.WasmType[signature.returnType.id]),this.assembler.writeUnsignedLEB128(section.data,signature.returnType.id),section.code.append(" (result "+wasm_type_1.WasmTypeToString[signature.returnType.id]+")")):this.assembler.writeUnsignedLEB128(section.data,0),section.code.append("))\n"),signature=signature.next}this.assembler.endSection(array,section)}},WasmModule.prototype.emitImportTable=function(array){if(this.firstImport){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Import,"import_table");logger_1.log(section.data,array.position,this.importCount,"num imports"),this.assembler.writeUnsignedLEB128(section.data,this.importCount);for(var current=this.firstImport,count=0;null!=current;)logger_1.log(section.data,array.position,null,"import func ("+count+") "+current.module+" "+current.name),this.assembler.currentSection.code.append('(import "'+current.module+'" "'+current.name+'" (func (;'+count+";) (type "+current.signatureIndex+")))\n"),this.assembler.writeWasmString(section.data,current.module),this.assembler.writeWasmString(section.data,current.name),this.assembler.writeUnsignedLEB128(section.data,wasm_external_kind_1.WasmExternalKind.Function),this.assembler.writeUnsignedLEB128(section.data,current.signatureIndex),current=current.next,count++;this.assembler.endSection(array,section)}},WasmModule.prototype.emitFunctionDeclarations=function(array){if(this.firstFunction){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Function,"function_declarations");logger_1.log(section.data,array.position,this.functionCount,"num functions"),this.assembler.writeUnsignedLEB128(section.data,this.functionCount);for(var fn=this.firstFunction,count=this.importCount;null!=fn;)logger_1.log(section.data,array.position,fn.signatureIndex,"func "+count+" sig "+index_1.getWasmFunctionName(fn.symbol)),this.assembler.writeUnsignedLEB128(section.data,fn.signatureIndex),fn=fn.next,count++;this.assembler.endSection(array,section)}},WasmModule.prototype.emitTables=function(array){},WasmModule.prototype.emitMemory=function(array){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Memory,"memory");logger_1.log(section.data,array.position,"01","num memories"),this.assembler.writeUnsignedLEB128(section.data,1),logger_1.log(section.data,array.position,"00","memory flags"),this.assembler.writeUnsignedLEB128(section.data,0),logger_1.log(section.data,array.position,1,"memory initial pages"),this.assembler.writeUnsignedLEB128(section.data,1),section.code.append("(memory (;0;) 1)\n"),this.assembler.endSection(array,section)},WasmModule.prototype.emitGlobalDeclarations=function(array){if(this.firstGlobal){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Global,"global");this.assembler.writeUnsignedLEB128(section.data,this.globalCount),this.assembler.stackTracer.setGlobals(this.globalEntries);for(var global=this.firstGlobal,count=0;global;){var dataType=index_1.typeToDataType(global.symbol.resolvedType,this.bitness),value=global.symbol.node.variableValue();section.data.append(wasm_type_1.WasmType[dataType]),this.assembler.writeUnsignedLEB128(section.data,1);var rawValue=0;switch(value&&(value.kind===node_1.NodeKind.NULL||value.kind===node_1.NodeKind.UNDEFINED?rawValue=0:void 0!==value.rawValue?rawValue=value.rawValue:this.addGlobalToStartFunction(global)),this.assembler.appendOpcode(section.data,array.position,opcode_1.WasmOpcode[dataType+"_CONST"],rawValue),dataType){case"I32":case"I64":this.assembler.writeUnsignedLEB128(section.data,rawValue);break;case"F32":this.assembler.writeFloat(section.data,rawValue);break;case"F64":this.assembler.writeDouble(section.data,rawValue)}var wasmTypeStr=wasm_type_1.WasmTypeToString[wasm_type_1.WasmType[dataType]];section.code.append("(global (;"+count+++";) (mut "+wasmTypeStr+") ("+wasmTypeStr+".const "+rawValue+"))\n"),this.assembler.appendOpcode(section.data,array.position,opcode_1.WasmOpcode.END),global=global.next}this.assembler.endSection(array,section)}},WasmModule.prototype.addGlobalToStartFunction=function(global){var value=global.symbol.node.variableValue(),startFn=this.startFunction;this.emitNode(startFn.body,0,value),this.assembler.appendOpcode(startFn.body,0,opcode_1.WasmOpcode.SET_GLOBAL),this.assembler.writeUnsignedLEB128(startFn.body,global.symbol.offset)},WasmModule.prototype.emitExportTable=function(array){for(var exportedCount=0,fn=this.firstFunction;null!=fn;)fn.isExported&&(exportedCount+=1),fn=fn.next;if(0!=exportedCount){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Export,"export_table");logger_1.log(section.data,array.position,exportedCount,"num exports"),this.assembler.writeUnsignedLEB128(section.data,exportedCount+1);logger_1.log(section.data,array.position,"memory".length,"export name length"),logger_1.log(section.data,null,null,utils_1.toHex(section.data.position+array.position+4)+": memory // export name"),this.assembler.writeWasmString(section.data,"memory"),logger_1.log(section.data,array.position,wasm_external_kind_1.WasmExternalKind.Function,"export kind"),this.assembler.writeUnsignedLEB128(section.data,wasm_external_kind_1.WasmExternalKind.Memory),logger_1.log(section.data,array.position,0,"export memory index"),this.assembler.writeUnsignedLEB128(section.data,0),section.code.append('(export "memory" (memory 0))\n');var i=this.importCount;for(fn=this.firstFunction;null!=fn;){if(fn.isExported){var fnName=index_1.getWasmFunctionName(fn.symbol);logger_1.log(section.data,array.position,fnName.length,"export name length"),logger_1.log(section.data,null,null,utils_1.toHex(section.data.position+array.position+4)+": "+fnName+" // export name"),this.assembler.writeWasmString(section.data,fnName),logger_1.log(section.data,array.position,wasm_external_kind_1.WasmExternalKind.Function,"export kind"),this.assembler.writeUnsignedLEB128(section.data,wasm_external_kind_1.WasmExternalKind.Function),logger_1.log(section.data,array.position,i,"export func index"),this.assembler.writeUnsignedLEB128(section.data,i),section.code.append('(export "'+fnName+'" (func $'+fnName+"))\n")}fn=fn.next,i+=1}this.assembler.endSection(array,section)}},WasmModule.prototype.emitStartFunctionDeclaration=function(array){if(-1!=this.startFunctionIndex){var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Start,"start_function");logger_1.log(section.data,array.position,this.startFunctionIndex,"start function index"),section.code.append("(start "+(this.importCount+this.startFunctionIndex)+")\n"),this.assembler.writeUnsignedLEB128(section.data,this.importCount+this.startFunctionIndex),this.assembler.endSection(array,section)}},WasmModule.prototype.emitElements=function(array){},WasmModule.prototype.emitFunctionBodies=function(array){if(this.firstFunction){var offset=array.position,section=this.assembler.startSection(array,wasm_section_1.WasmSection.Code,"function_bodies");logger_1.log(section.data,offset,this.functionCount,"num functions"),this.assembler.writeUnsignedLEB128(section.data,this.functionCount);for(var count=0,fn=this.firstFunction,this_1=this;null!=fn;)!function(){this_1.currentFunction=fn;var sectionOffset=offset+section.data.position,wasmFunctionName=index_1.getWasmFunctionName(fn.symbol),bodyData=new bytearray_1.ByteArray;logger_1.log(bodyData,sectionOffset,fn.localCount?fn.localCount:0,"local var count"),this_1.assembler.stackTracer.startFunction(this_1.importCount+count),section.code.append("(func $"+wasmFunctionName+" (type "+fn.signatureIndex+")"),fn.argumentEntries.forEach(function(argumentEntry){section.code.append(" (param $"+argumentEntry.name+" "+wasm_type_1.WasmTypeToString[argumentEntry.type]+") ")}),fn.signature.returnType.id!==wasm_type_1.WasmType.VOID&§ion.code.append("(result "+wasm_type_1.WasmTypeToString[fn.signature.returnType.id]+")"),section.code.append("\n",1),fn.localVariables.length>0?(bodyData.writeUnsignedLEB128(fn.localVariables.length),fn.localVariables.forEach(function(localVariableEntry){logger_1.log(bodyData,sectionOffset,1,"local index"),bodyData.writeUnsignedLEB128(1),logger_1.log(bodyData,sectionOffset,localVariableEntry.type,wasm_type_1.WasmType[localVariableEntry.type]),bodyData.append(localVariableEntry.type),section.code.append("(local $"+localVariableEntry.name+" "+wasm_type_1.WasmTypeToString[localVariableEntry.type]+") ")}),section.code.append("\n")):bodyData.writeUnsignedLEB128(0);var lastChild=void 0;fn.isConstructor&&this_1.emitConstructor(bodyData,sectionOffset,fn);for(var child=fn.symbol.node.functionBody().firstChild;null!=child;)lastChild=child,this_1.emitNode(bodyData,sectionOffset,child),child=child.nextSibling;fn.body?bodyData.copy(fn.body):lastChild&&lastChild.kind!==node_1.NodeKind.RETURN&&fn.returnType!=wasm_type_1.WasmType.VOID&&this_1.assembler.appendOpcode(bodyData,sectionOffset,opcode_1.WasmOpcode.RETURN),fn.returnType===wasm_type_1.WasmType.VOID&&this_1.assembler.dropStack(bodyData),this_1.assembler.appendOpcode(bodyData,sectionOffset,opcode_1.WasmOpcode.END,null,!0),this_1.assembler.stackTracer.endFunction(),section.data.writeUnsignedLEB128(bodyData.length),logger_1.log(section.data,offset,null," - func body "+(this_1.importCount+count++)+" ("+wasmFunctionName+")"),logger_1.log(section.data,offset,bodyData.length,"func body size"),section.data.log+=bodyData.log,section.data.copy(bodyData),section.code.indent-=1,section.code.removeLastLinebreak(),section.code.append(")\n"),fn=fn.next}();this.assembler.endSection(array,section)}},WasmModule.prototype.emitDataSegments=function(array){this.growMemoryInitializer();var memoryInitializer=this.memoryInitializer,initializerLength=memoryInitializer.length,initialHeapPointer=utils_1.alignToNextMultipleOf(8+initializerLength,8);memoryInitializer.writeUnsignedInt(initialHeapPointer,this.originalHeapPointer),memoryInitializer.writeUnsignedInt(initialHeapPointer,this.currentHeapPointer);var section=this.assembler.startSection(array,wasm_section_1.WasmSection.Data,"data_segments");logger_1.log(section.data,array.position,1,"num data segments"),this.assembler.writeUnsignedLEB128(section.data,1),logger_1.log(section.data,array.position,null," - data segment header 0"),logger_1.log(section.data,array.position,0,"memory index"),this.assembler.writeUnsignedLEB128(section.data,0),this.assembler.appendOpcode(section.data,array.position,opcode_1.WasmOpcode.I32_CONST),logger_1.log(section.data,array.position,8,"i32 literal"),this.assembler.writeUnsignedLEB128(section.data,8),this.assembler.appendOpcode(section.data,array.position,opcode_1.WasmOpcode.END),logger_1.log(section.data,array.position,initializerLength,"data segment size"),this.assembler.writeUnsignedLEB128(section.data,initializerLength),logger_1.log(section.data,array.position,null," - data segment data 0"),section.code.append('(data (i32.const 8) " ');for(var value,i=0;i0);var lengthNode=node.arrayLength();if(lengthNode.kind==node_1.NodeKind.INT32){var length_2=size*lengthNode.intValue;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,length_2),this.assembler.writeLEB128(array,length_2)}else this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(array,size),this.emitNode(array,byteOffset,lengthNode),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_MUL);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(array,size);var callIndex=this.getWasmFunctionCallIndex(callSymbol);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.CALL),logger_1.log(array,byteOffset,callIndex,"call func index ("+callIndex+")"),this.assembler.writeUnsignedLEB128(array,callIndex)}else if(type.resolvedType.isTypedArray());else{for(var child=node.firstChild.nextSibling;null!=child;)this.emitNode(array,byteOffset,child),child=child.nextSibling;var callIndex=this.getWasmFunctionCallIndex(callSymbol);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.CALL,callIndex),this.assembler.writeUnsignedLEB128(array,callIndex)}},WasmModule.prototype.emitConstructor=function(array,byteOffset,fn){var constructorNode=fn.symbol.node,type=constructorNode.parent.symbol,size=type.resolvedType.allocationSizeOf(this.context);if(assert_1.assert(size>0),type.resolvedType.isArray())this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.GET_LOCAL,0),this.assembler.writeUnsignedLEB128(array,0),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(array,size),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_ADD);else if(type.resolvedType.isTypedArray()){var elementSize=index_1.getTypedArrayElementSize(type.resolvedType.symbol.name);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.GET_LOCAL,0),this.assembler.writeUnsignedLEB128(array,0),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,elementSize),this.assembler.writeLEB128(array,elementSize),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_SHL),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(array,size),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_ADD)}else this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,size),this.assembler.writeLEB128(array,size);var mallocIndex=this.calculateWasmFunctionIndex(this.mallocFunctionIndex);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.CALL,mallocIndex),this.assembler.writeUnsignedLEB128(array,mallocIndex),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,fn.signature.argumentCount),this.assembler.writeUnsignedLEB128(array,fn.signature.argumentCount)},WasmModule.prototype.emitNode=function(array,byteOffset,node){if(assert_1.assert(!node_1.isExpression(node)||null!=node.resolvedType),node.kind==node_1.NodeKind.BLOCK){var skipBlock=node.parent.kind===node_1.NodeKind.IF;skipBlock||(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.BLOCK),void 0!==node.returnNode?(logger_1.log(array,byteOffset,this.currentFunction.returnType,wasm_type_1.WasmType[this.currentFunction.returnType]),array.append(this.currentFunction.returnType),this.assembler.currentSection.code.removeLastLinebreak(),this.assembler.currentSection.code.append(" (result "+wasm_type_1.WasmTypeToString[this.currentFunction.returnType]+")\n",1)):(logger_1.log(array,byteOffset,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]),array.append(wasm_type_1.WasmType.block_type)));for(var child=node.firstChild;null!=child;)this.emitNode(array,byteOffset,child),child=child.nextSibling;skipBlock||(this.assembler.currentSection.code.clearIndent(1),this.assembler.currentSection.code.indent-=1,this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.END))}else if(node.kind==node_1.NodeKind.WHILE){var value=node.whileValue(),body=node.whileBody();if(value.kind==node_1.NodeKind.BOOLEAN&&0==value.intValue)return 0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.BLOCK),logger_1.log(array,0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]),array.append(wasm_type_1.WasmType.block_type),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.LOOP),logger_1.log(array,0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]),array.append(wasm_type_1.WasmType.block_type),value.kind!=node_1.NodeKind.BOOLEAN&&(this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_EQZ),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.BR_IF),this.assembler.writeUnsignedLEB128(array,1));for(var child=body.firstChild;null!=child;)this.emitNode(array,byteOffset,child),child=child.nextSibling;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.BR),this.assembler.writeUnsignedLEB128(array,0),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.END),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.BREAK||node.kind==node_1.NodeKind.CONTINUE){for(var label=0,parent_1=node.parent;null!=parent_1&&parent_1.kind!=node_1.NodeKind.WHILE;)parent_1.kind==node_1.NodeKind.BLOCK&&(label+=1),parent_1=parent_1.parent;assert_1.assert(label>0),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.BR),this.assembler.writeUnsignedLEB128(array,label-(node.kind==node_1.NodeKind.BREAK?0:1))}else{if(node.kind==node_1.NodeKind.EMPTY)return 0;if(node.kind==node_1.NodeKind.EXPRESSION)this.emitNode(array,byteOffset,node.expressionValue());else if(node.kind==node_1.NodeKind.RETURN){var value=node.returnValue();null!=value&&this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.RETURN)}else{if(node.kind==node_1.NodeKind.VARIABLES){for(var count=0,child=node.firstChild;null!=child;)assert_1.assert(child.kind==node_1.NodeKind.VARIABLE),count+=this.emitNode(array,byteOffset,child),child=child.nextSibling;return count}if(node.kind==node_1.NodeKind.IF){var branch=node.ifFalse();this.emitNode(array,byteOffset,node.ifValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.IF);var returnNode=node.ifReturnNode(),needEmptyElse=!1;if(null==returnNode&&null===branch)wasm_assembler_1.append(array,0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]);else if(null!==returnNode){var returnType=index_1.symbolToValueType(returnNode.resolvedType.symbol);wasm_assembler_1.append(array,0,returnType,wasm_type_1.WasmType[returnType]),this.assembler.currentSection.code.removeLastLinebreak(),this.assembler.currentSection.code.append(" (result "+wasm_type_1.WasmTypeToString[returnType]+")\n"),null==branch&&(needEmptyElse=!0)}else wasm_assembler_1.append(array,0,wasm_type_1.WasmType.block_type,wasm_type_1.WasmType[wasm_type_1.WasmType.block_type]);if(this.emitNode(array,byteOffset,node.ifTrue()),null!=branch)this.assembler.currentSection.code.indent-=1,this.assembler.currentSection.code.clearIndent(1),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.IF_ELSE),this.emitNode(array,byteOffset,branch);else if(needEmptyElse){this.assembler.currentSection.code.indent-=1,this.assembler.currentSection.code.clearIndent(1),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.IF_ELSE);var dataType=index_1.typeToDataType(returnNode.resolvedType,this.bitness);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode[dataType+"_CONST"]),"I32"===dataType||"I64"===dataType?this.assembler.writeUnsignedLEB128(array,0):"F32"===dataType?this.assembler.writeFloat(array,0):"F64"===dataType&&this.assembler.writeDouble(array,0)}this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.HOOK){this.emitNode(array,byteOffset,node.hookValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.IF);var trueValue=node.hookTrue(),trueValueType=index_1.symbolToValueType(trueValue.resolvedType.symbol);wasm_assembler_1.append(array,0,trueValueType,wasm_type_1.WasmType[trueValueType]),this.emitNode(array,byteOffset,trueValue),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.IF_ELSE),this.emitNode(array,byteOffset,node.hookFalse()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.END)}else if(node.kind==node_1.NodeKind.VARIABLE){var value=node.variableValue();if("this"==node.symbol.name&&"constructor"==this.currentFunction.symbol.name);else if(node.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL){value&&value.kind!=node_1.NodeKind.NAME&&value.kind!=node_1.NodeKind.CALL&&value.kind!=node_1.NodeKind.NEW&&value.kind!=node_1.NodeKind.DOT&&value.rawValue?node.symbol.resolvedType.isFloat()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,value.floatValue),this.assembler.writeFloat(array,value.floatValue)):node.symbol.resolvedType.isDouble()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,value.doubleValue),this.assembler.writeDouble(array,value.doubleValue)):node.symbol.resolvedType.isLong()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,value.longValue),this.assembler.writeLEB128(array,value.longValue)):(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,value.intValue),this.assembler.writeLEB128(array,value.intValue)):null!=value?this.emitNode(array,byteOffset,value):node.symbol.resolvedType.isFloat()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,0),this.assembler.writeFloat(array,0)):node.symbol.resolvedType.isDouble()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,0),this.assembler.writeDouble(array,0)):node.symbol.resolvedType.isLong()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(array,0)):(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(array,0));var skipSetLocal=value&&node_1.isUnaryPostfix(value.kind);0==skipSetLocal&&(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,node.symbol.offset),this.assembler.writeUnsignedLEB128(array,node.symbol.offset))}else assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.NAME){var symbol=node.symbol;symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT||symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL?"this"===symbol.name&&"constructor"===this.currentFunction.symbol.name?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.GET_LOCAL,this.currentFunction.signature.argumentCount),this.assembler.writeUnsignedLEB128(array,this.currentFunction.signature.argumentCount)):(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.GET_LOCAL,symbol.offset),this.assembler.writeUnsignedLEB128(array,symbol.offset)):symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.GET_GLOBAL,symbol.offset),this.assembler.writeUnsignedLEB128(array,symbol.offset)):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.DEREFERENCE)this.emitLoadFromMemory(array,byteOffset,node.resolvedType.underlyingType(this.context),node.unaryValue(),0);else if(node.kind==node_1.NodeKind.POINTER_INDEX)this.emitLoadFromMemory(array,byteOffset,node.resolvedType.underlyingType(this.context),node.pointer(),node.pointerOffset());else if(node.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(array,0);else if(node.kind==node_1.NodeKind.INT32||node.kind==node_1.NodeKind.BOOLEAN)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,node.intValue),this.assembler.writeLEB128(array,node.intValue||0);else if(node.kind==node_1.NodeKind.INT64)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,node.longValue),this.assembler.writeLEB128(array,node.longValue);else if(node.kind==node_1.NodeKind.FLOAT32)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,node.floatValue),this.assembler.writeFloat(array,node.floatValue);else if(node.kind==node_1.NodeKind.FLOAT64)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,node.doubleValue),this.assembler.writeDouble(array,node.doubleValue);else if(node.kind==node_1.NodeKind.STRING){var value=8+node.intValue;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,value),this.assembler.writeLEB128(array,value)}else if(node.kind==node_1.NodeKind.CALL){var value=node.callValue(),symbol=value.symbol;if(assert_1.assert(symbol_1.isFunction(symbol.kind)),!symbol.node.isExternalImport()&&symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var dotTarget=value.dotTarget();this.emitNode(array,byteOffset,dotTarget),dotTarget.kind==node_1.NodeKind.NEW&&this.emitInstance(array,byteOffset,dotTarget)}for(var child=value.nextSibling;null!=child;)this.emitNode(array,byteOffset,child),child=child.nextSibling;var wasmFunctionName=index_1.getWasmFunctionName(symbol);if(builtins_helper_1.isBuiltin(wasmFunctionName))this.assembler.appendOpcode(array,byteOffset,builtins_helper_1.getBuiltinOpcode(symbol.name));else{var callIndex=this.getWasmFunctionCallIndex(symbol);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.CALL,callIndex),this.assembler.writeUnsignedLEB128(array,callIndex)}}else if(node.kind==node_1.NodeKind.NEW)this.emitInstance(array,byteOffset,node);else if(node.kind==node_1.NodeKind.DELETE){var value=node.deleteValue();this.emitNode(array,byteOffset,value);var freeIndex=this.calculateWasmFunctionIndex(this.freeFunctionIndex);this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.CALL,freeIndex),this.assembler.writeUnsignedLEB128(array,freeIndex)}else if(node.kind==node_1.NodeKind.POSITIVE)this.emitNode(array,byteOffset,node.unaryValue());else if(node.kind==node_1.NodeKind.NEGATIVE){var resolvedType=node.unaryValue().resolvedType;resolvedType.isFloat()?(this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_NEG)):resolvedType.isDouble()?(this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_NEG)):resolvedType.isInteger()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,0),this.assembler.writeLEB128(array,0),this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_SUB)):resolvedType.isLong()&&(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(array,0),this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_SUB))}else if(node.kind==node_1.NodeKind.COMPLEMENT)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,-1),this.assembler.writeLEB128(array,-1),this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_XOR);else if(node.kind==node_1.NodeKind.NOT)this.emitNode(array,byteOffset,node.unaryValue()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_EQZ);else if(node.kind==node_1.NodeKind.CAST){var value=node.castValue(),context=this.context,from=value.resolvedType.underlyingType(context),type=node.resolvedType.underlyingType(context);from.variableSizeOf(context),type.variableSizeOf(context);if(from!=context.nullType&&from!=context.booleanType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.int64Type&&type!=context.uint64Type)if(from!=context.nullType&&from!=context.booleanType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.float32Type)if(from!=context.nullType&&from!=context.int32Type&&from!=context.uint32Type||type!=context.float64Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.int32Type&&type!=context.uint32Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.float32Type)if(from!=context.int64Type&&from!=context.uint64Type||type!=context.float64Type)if(from!=context.float32Type||type!=context.uint8Type&&type!=context.int8Type&&type!=context.uint16Type&&type!=context.int16Type&&type!=context.uint32Type&&type!=context.int32Type)if(from!=context.float32Type||type!=context.int64Type&&type!=context.uint64Type)if(from==context.float32Type&&type==context.float64Type)if(value.kind==node_1.NodeKind.FLOAT32){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(array,doubleValue)}else this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_PROMOTE_F32);else if(from!=context.float64Type||type!=context.uint8Type&&type!=context.int8Type&&type!=context.uint16Type&&type!=context.int16Type&&type!=context.uint32Type&&type!=context.int32Type)if(from!=context.float64Type||type!=context.int64Type&&type!=context.uint64Type)if(from==context.float64Type&&type==context.float32Type)if(value.kind==node_1.NodeKind.FLOAT64){var floatValue=value.floatValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(array,floatValue)}else this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_DEMOTE_F64);else this.emitNode(array,byteOffset,value);else if(value.kind==node_1.NodeKind.FLOAT64){var longValue=value.longValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,longValue),this.assembler.writeLEB128(array,longValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_TRUNC_U_F64:opcode_1.WasmOpcode.I64_TRUNC_S_F64)}else if(value.kind==node_1.NodeKind.FLOAT64){var intValue=value.intValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(array,intValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.I32_TRUNC_U_F64:opcode_1.WasmOpcode.I32_TRUNC_S_F64)}else if(value.kind==node_1.NodeKind.FLOAT32){var longValue=value.longValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,longValue),this.assembler.writeLEB128(array,longValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_TRUNC_U_F32:opcode_1.WasmOpcode.I64_TRUNC_S_F32)}else if(value.kind==node_1.NodeKind.FLOAT32){var intValue=value.intValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(array,intValue)}else{var isUnsigned=type.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.I32_TRUNC_U_F32:opcode_1.WasmOpcode.I32_TRUNC_S_F32)}else if(value.kind==node_1.NodeKind.INT64){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(array,doubleValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.F64_CONVERT_U_I64:opcode_1.WasmOpcode.F64_CONVERT_S_I64)}else if(value.kind==node_1.NodeKind.INT32){var floatValue=value.floatValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(array,floatValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.F32_CONVERT_U_I64:opcode_1.WasmOpcode.F32_CONVERT_S_I64)}else if(value.kind==node_1.NodeKind.INT64){var intValue=value.intValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,intValue),this.assembler.writeLEB128(array,intValue)}else this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_WRAP_I64);else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,0),this.assembler.writeDouble(array,0);else if(value.kind==node_1.NodeKind.BOOLEAN){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(array,doubleValue)}else if(value.kind==node_1.NodeKind.INT32){var doubleValue=value.doubleValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,doubleValue),this.assembler.writeDouble(array,doubleValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.F64_CONVERT_U_I32:opcode_1.WasmOpcode.F64_CONVERT_S_I32)}else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,0),this.assembler.writeFloat(array,0);else if(value.kind==node_1.NodeKind.BOOLEAN){var floatValue=value.intValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(array,floatValue)}else if(value.kind==node_1.NodeKind.INT32){var floatValue=value.floatValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,floatValue),this.assembler.writeFloat(array,floatValue)}else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.F32_CONVERT_U_I32:opcode_1.WasmOpcode.F32_CONVERT_S_I32)}else if(value.kind==node_1.NodeKind.NULL)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,0),this.assembler.writeLEB128(array,0);else if(value.kind==node_1.NodeKind.BOOLEAN){var intValue=value.intValue||0;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,intValue),this.assembler.writeLEB128(array,intValue)}else if(value.kind==node_1.NodeKind.INT32)this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,value.longValue),this.assembler.writeLEB128(array,value.longValue);else{var isUnsigned=value.resolvedType.isUnsigned();this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,isUnsigned?opcode_1.WasmOpcode.I64_EXTEND_U_I32:opcode_1.WasmOpcode.I64_EXTEND_S_I32)}}else if(node.kind==node_1.NodeKind.DOT){var symbol=node.symbol;symbol.kind==symbol_1.SymbolKind.VARIABLE_INSTANCE?this.emitLoadFromMemory(array,byteOffset,symbol.resolvedType,node.dotTarget(),symbol.offset):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.ASSIGN){var left=node.binaryLeft(),right=node.binaryRight(),symbol=left.symbol;left.kind==node_1.NodeKind.DEREFERENCE?this.emitStoreToMemory(array,byteOffset,left.resolvedType.underlyingType(this.context),left.unaryValue(),0,right):left.kind==node_1.NodeKind.POINTER_INDEX?this.emitStoreToMemory(array,byteOffset,left.resolvedType.underlyingType(this.context),left.pointer(),left.pointerOffset(),right):symbol.kind==symbol_1.SymbolKind.VARIABLE_INSTANCE?this.emitStoreToMemory(array,byteOffset,symbol.resolvedType,left.dotTarget(),symbol.offset,right):symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.emitNode(array,byteOffset,right),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_GLOBAL),this.assembler.writeUnsignedLEB128(array,symbol.offset)):symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT||symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL?(this.emitNode(array,byteOffset,right),node_1.isUnaryPostfix(right.kind)||(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,symbol.offset),this.assembler.writeUnsignedLEB128(array,symbol.offset))):assert_1.assert(!1)}else if(node.kind==node_1.NodeKind.LOGICAL_AND)this.emitNode(array,byteOffset,node.binaryLeft()),this.emitNode(array,byteOffset,node.binaryRight()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_AND),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(array,1),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_EQ);else if(node.kind==node_1.NodeKind.LOGICAL_OR)this.emitNode(array,byteOffset,node.binaryLeft()),this.emitNode(array,byteOffset,node.binaryRight()),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_OR),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST),logger_1.log(array,byteOffset,1,"i32 literal"),this.assembler.writeLEB128(array,1),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_EQ);else if(node_1.isUnary(node.kind)){var kind=node.kind;if(kind==node_1.NodeKind.POSTFIX_INCREMENT||kind==node_1.NodeKind.POSTFIX_DECREMENT){var value=node.unaryValue(),dataType=index_1.typeToDataType(value.resolvedType,this.bitness);if(node.parent.kind==node_1.NodeKind.VARIABLE)this.emitNode(array,byteOffset,value),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,node.parent.symbol.offset),this.assembler.writeUnsignedLEB128(array,node.parent.symbol.offset);else if(node.parent.kind==node_1.NodeKind.ASSIGN){this.emitNode(array,byteOffset,value);var left=node.parent.binaryLeft();this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,left.symbol.offset),this.assembler.writeUnsignedLEB128(array,left.symbol.offset)}if(this.emitNode(array,byteOffset,value),node.parent.kind!=node_1.NodeKind.RETURN){assert_1.assert(value.resolvedType.isInteger()||value.resolvedType.isLong()||value.resolvedType.isFloat()||value.resolvedType.isDouble());var size=value.resolvedType.pointerTo?value.resolvedType.pointerTo.allocationSizeOf(this.context):value.resolvedType.allocationSizeOf(this.context);1==size||2==size?value.kind==node_1.NodeKind.INT32||value.resolvedType.isInteger()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(array,1)):terminal_1.Terminal.error("Wrong type"):4==size?value.kind==node_1.NodeKind.INT32||value.resolvedType.isInteger()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(array,1)):value.kind==node_1.NodeKind.FLOAT32||value.resolvedType.isFloat()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,1),this.assembler.writeFloat(array,1)):terminal_1.Terminal.error("Wrong type"):8==size&&(value.kind==node_1.NodeKind.INT64||value.resolvedType.isLong()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,1),this.assembler.writeLEB128(array,1)):value.kind==node_1.NodeKind.FLOAT64||value.resolvedType.isDouble()?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,1),this.assembler.writeDouble(array,1)):terminal_1.Terminal.error("Wrong type"));var operation=kind==node_1.NodeKind.POSTFIX_INCREMENT?"ADD":"SUB";this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode[dataType+"_"+operation]),value.symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_GLOBAL,value.symbol.offset),this.assembler.writeLEB128(array,value.symbol.offset)):value.symbol.kind==symbol_1.SymbolKind.VARIABLE_LOCAL||value.symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.SET_LOCAL,value.symbol.offset),this.assembler.writeLEB128(array,value.symbol.offset)):(value.symbol.kind,symbol_1.SymbolKind.VARIABLE_INSTANCE)}}}else{var isUnsigned=node.isUnsignedOperator(),left=node.binaryLeft(),right=node.binaryRight(),isFloat=left.resolvedType.isFloat()||right.resolvedType.isFloat(),isDouble=left.resolvedType.isDouble()||right.resolvedType.isDouble(),dataTypeLeft=index_1.typeToDataType(left.resolvedType,this.bitness);index_1.typeToDataType(right.resolvedType,this.bitness);if(node.kind==node_1.NodeKind.ADD){if(this.emitNode(array,byteOffset,left),null==left.resolvedType.pointerTo)this.emitNode(array,byteOffset,right);else{assert_1.assert(right.resolvedType.isInteger()||right.resolvedType.isLong()||right.resolvedType.isFloat()||right.resolvedType.isDouble());var size=left.resolvedType.pointerTo.allocationSizeOf(this.context);if(2==size)if(right.kind==node_1.NodeKind.INT32){var _value=right.intValue<<1;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,_value),this.assembler.writeLEB128(array,_value)}else this.emitNode(array,byteOffset,right),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,1),this.assembler.writeLEB128(array,1),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_SHL);else if(4==size)if(right.kind==node_1.NodeKind.INT32){var _value=right.intValue<<2;this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,_value),this.assembler.writeLEB128(array,_value)}else right.kind==node_1.NodeKind.FLOAT32?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F32_CONST,right.floatValue),this.assembler.writeFloat(array,right.floatValue)):(this.emitNode(array,byteOffset,right),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_CONST,2),this.assembler.writeLEB128(array,2),this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I32_SHL));else 8==size?right.kind==node_1.NodeKind.INT64?(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.I64_CONST,right.longValue),this.assembler.writeLEB128(array,right.longValue)):right.kind==node_1.NodeKind.FLOAT64&&(this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode.F64_CONST,right.doubleValue),this.assembler.writeDouble(array,right.doubleValue)):this.emitNode(array,byteOffset,right)}this.assembler.appendOpcode(array,byteOffset,opcode_1.WasmOpcode[dataTypeLeft+"_ADD"])}else if(node.kind==node_1.NodeKind.BITWISE_AND){if(isFloat||isDouble)throw"Cannot do bitwise operations on floating point number";this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_AND"])}else if(node.kind==node_1.NodeKind.BITWISE_OR){if(isFloat||isDouble)throw"Cannot do bitwise operations on floating point number";this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_OR"])}else if(node.kind==node_1.NodeKind.BITWISE_XOR)this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_XOR"]);else if(node.kind==node_1.NodeKind.EQUAL)this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_EQ"]);else if(node.kind==node_1.NodeKind.MULTIPLY)this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_MUL"]);else if(node.kind==node_1.NodeKind.NOT_EQUAL)this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_NE"]);else if(node.kind==node_1.NodeKind.SHIFT_LEFT){if(isFloat||isDouble)throw"Cannot do bitwise operations on floating point number";this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_SHL"])}else if(node.kind==node_1.NodeKind.SUBTRACT)this.emitBinaryExpression(array,byteOffset,node,opcode_1.WasmOpcode[dataTypeLeft+"_SUB"]);else if(node.kind==node_1.NodeKind.DIVIDE){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_DIV"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_DIV_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_DIV_S"];this.emitBinaryExpression(array,byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.GREATER_THAN){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_GT"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_GT_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_GT_S"];this.emitBinaryExpression(array,byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.GREATER_THAN_EQUAL){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_GE"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_GE_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_GE_S"];this.emitBinaryExpression(array,byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.LESS_THAN){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_LT"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_LT_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_LT_S"];this.emitBinaryExpression(array,byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.LESS_THAN_EQUAL){var opcode=isFloat||isDouble?opcode_1.WasmOpcode[dataTypeLeft+"_LE"]:isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_LE_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_LE_S"];this.emitBinaryExpression(array,byteOffset,node,opcode)}else if(node.kind==node_1.NodeKind.REMAINDER){if(isFloat||isDouble)throw"Floating point remainder is not yet supported in WebAssembly. Please import javascript function to handle this";this.emitBinaryExpression(array,byteOffset,node,isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_REM_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_REM_S"])}else if(node.kind==node_1.NodeKind.SHIFT_RIGHT){if(isFloat||isDouble)throw"Cannot do bitwise operations on floating point number";this.emitBinaryExpression(array,byteOffset,node,isUnsigned?opcode_1.WasmOpcode[dataTypeLeft+"_SHR_U"]:opcode_1.WasmOpcode[dataTypeLeft+"_SHR_S"])}else assert_1.assert(!1)}}}return 1},WasmModule.prototype.calculateWasmFunctionIndex=function(index){return this.importCount+index},WasmModule.prototype.getWasmFunctionCallIndex=function(symbol){return symbol.node.isExternalImport()?symbol.offset:this.importCount+symbol.offset},WasmModule.prototype.getWasmType=function(type){var context=this.context;return type==context.booleanType||type.isClass()||type.isInteger()||this.bitness==bitness_1.Bitness.x32&&type.isReference()?wasm_type_1.WasmType.I32:type.isLong()||this.bitness==bitness_1.Bitness.x64&&type.isReference()?wasm_type_1.WasmType.I64:type.isDouble()?wasm_type_1.WasmType.F64:type.isFloat()?wasm_type_1.WasmType.F32:type==context.voidType?wasm_type_1.WasmType.VOID:(assert_1.assert(!1),wasm_type_1.WasmType.VOID)},WasmModule}();exports.wasmEmit=wasmEmit},function(module,exports,__webpack_require__){"use strict";function addScopeToSymbol(symbol,parentScope){var scope=new scope_1.Scope;scope.parent=parentScope,scope.symbol=symbol,symbol.scope=scope}function linkSymbolToNode(symbol,node){node.symbol=symbol,node.scope=symbol.scope,symbol.range=null!=node.internalRange?node.internalRange:node.range,symbol.node=node}function initialize(context,node,parentScope,mode){var kind=node.kind;if(null!=node.parent){var parentKind=node.parent.kind;kind==node_1.NodeKind.IMPORTS||kind==node_1.NodeKind.VARIABLE||kind==node_1.NodeKind.VARIABLES||kind==node_1.NodeKind.FUNCTION&&parentKind==node_1.NodeKind.CLASS||(parentKind==node_1.NodeKind.FILE||parentKind==node_1.NodeKind.GLOBAL)==(parentKind==node_1.NodeKind.MODULE||kind==node_1.NodeKind.MODULE||kind==node_1.NodeKind.CLASS||kind==node_1.NodeKind.ENUM||kind==node_1.NodeKind.FUNCTION||kind==node_1.NodeKind.CONSTANTS)||context.log.error(node.range,"This statement is not allowed here")}if(kind==node_1.NodeKind.MODULE){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;symbol.kind=symbol_1.SymbolKind.TYPE_MODULE,symbol.name=node.stringValue,symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.flags=symbol_1.SYMBOL_FLAG_IS_REFERENCE,addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL),parentScope=symbol.scope}if(kind==node_1.NodeKind.CLASS||kind==node_1.NodeKind.ENUM){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;if(symbol.kind=kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.TYPE_CLASS:symbol_1.SymbolKind.TYPE_ENUM,symbol.name=node.stringValue,symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.flags=symbol_1.SYMBOL_FLAG_IS_REFERENCE,addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL),parentScope=symbol.scope,node.parameterCount()>0){symbol.kind=symbol_1.SymbolKind.TYPE_TEMPLATE,symbol.flags|=symbol_1.SYMBOL_FLAG_IS_TEMPLATE;var genericType=node.firstGenericType(),genericSymbol=new symbol_1.Symbol;genericSymbol.kind=symbol_1.SymbolKind.TYPE_GENERIC,genericSymbol.name=genericType.stringValue,genericSymbol.resolvedType=new type_1.Type,genericSymbol.resolvedType.symbol=genericSymbol,genericSymbol.flags=symbol_1.SYMBOL_FLAG_IS_GENERIC,genericType.flags=node_1.NODE_FLAG_GENERIC,addScopeToSymbol(genericSymbol,parentScope),linkSymbolToNode(genericSymbol,genericType),parentScope.define(context.log,genericSymbol,scope_1.ScopeHint.NORMAL)}}else if(kind==node_1.NodeKind.FUNCTION){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;if(symbol.kind=node.parent.kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.FUNCTION_INSTANCE:symbol_1.SymbolKind.FUNCTION_GLOBAL,symbol.name=node.stringValue,node.isOperator()&&("+"==symbol.name||"-"==symbol.name?node.functionFirstArgument()==node.functionReturnType()?(symbol.flags=symbol_1.SYMBOL_FLAG_IS_UNARY_OPERATOR,symbol.rename="+"==symbol.name?"op_positive":"op_negative"):(symbol.flags=symbol_1.SYMBOL_FLAG_IS_BINARY_OPERATOR,symbol.rename="+"==symbol.name?"op_add":"op_subtract"):symbol.rename="%"==symbol.name?"op_remainder":"&"==symbol.name?"op_and":"*"==symbol.name?"op_multiply":"**"==symbol.name?"op_exponent":"++"==symbol.name?"op_increment":"--"==symbol.name?"op_decrement":"/"==symbol.name?"op_divide":"<"==symbol.name?"op_lessThan":"<<"==symbol.name?"op_shiftLeft":"=="==symbol.name?"op_equals":">"==symbol.name?"op_greaterThan":">>"==symbol.name?"op_shiftRight":"[]"==symbol.name?"op_get":"[]="==symbol.name?"op_set":"^"==symbol.name?"op_xor":"|"==symbol.name?"op_or":"~"==symbol.name?"op_complement":null),"constructor"==symbol.name&&(symbol.rename="_ctr"),addScopeToSymbol(symbol,parentScope),linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,symbol.isSetter()?scope_1.ScopeHint.NOT_GETTER:symbol.isGetter()?scope_1.ScopeHint.NOT_SETTER:symbol.isBinaryOperator()?scope_1.ScopeHint.NOT_UNARY:symbol.isUnaryOperator()?scope_1.ScopeHint.NOT_BINARY:scope_1.ScopeHint.NORMAL),parentScope=symbol.scope,symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var parent_1=symbol.parent();if(initializeSymbol(context,parent_1),"constructor"==symbol.name){var body=node.functionBody();if(null!==body){var variablesNode=body.firstChild;if(variablesNode.kind!==node_1.NodeKind.VARIABLES){var _variablesNode=node_1.createVariables();body.insertChildBefore(variablesNode,_variablesNode),variablesNode=_variablesNode}var firstVariable=variablesNode.firstChild;void 0!==firstVariable?"this"!==firstVariable.stringValue?variablesNode.insertChildBefore(firstVariable,node_1.createVariable("this",node_1.createType(parent_1.resolvedType),null)):"this"===firstVariable.stringValue&&void 0===firstVariable.firstChild.resolvedType&&(firstVariable.firstChild.resolvedType=parent_1.resolvedType):variablesNode.appendChild(node_1.createVariable("this",node_1.createType(parent_1.resolvedType),null));var returnNode=node_1.createReturn(node_1.createName("this"));node.lastChild.lastChild&&node.lastChild.lastChild.kind==node_1.NodeKind.RETURN&&node.lastChild.lastChild.remove(),node.lastChild.appendChild(returnNode)}}else{var firstArgument=node.functionFirstArgument();"this"!==firstArgument.stringValue?node.insertChildBefore(firstArgument,node_1.createVariable("this",node_1.createType(parent_1.resolvedType),null)):"this"===firstArgument.stringValue&&void 0===firstArgument.firstChild.resolvedType&&(firstArgument.firstChild.resolvedType=parent_1.resolvedType)}}}else if(kind==node_1.NodeKind.VARIABLE){assert_1.assert(null==node.symbol);var symbol=new symbol_1.Symbol;symbol.kind=node.parent.kind==node_1.NodeKind.CLASS?symbol_1.SymbolKind.VARIABLE_INSTANCE:node.parent.kind==node_1.NodeKind.FUNCTION?symbol_1.SymbolKind.VARIABLE_ARGUMENT:node.parent.kind==node_1.NodeKind.CONSTANTS||node.parent.kind==node_1.NodeKind.ENUM?symbol_1.SymbolKind.VARIABLE_CONSTANT:node.parent.kind==node_1.NodeKind.VARIABLES&&node.parent.parent.kind==node_1.NodeKind.FILE?symbol_1.SymbolKind.VARIABLE_GLOBAL:symbol_1.SymbolKind.VARIABLE_LOCAL,symbol.name=node.stringValue,symbol.scope=parentScope,linkSymbolToNode(symbol,node),parentScope.define(context.log,symbol,scope_1.ScopeHint.NORMAL)}else if(kind==node_1.NodeKind.BLOCK){if(node.parent.kind!=node_1.NodeKind.FUNCTION){var scope=new scope_1.Scope;scope.parent=parentScope,parentScope=scope}node.scope=parentScope}for(var child=node.firstChild;null!=child;)mode==CheckMode.INITIALIZE&&(child.flags|=node_1.NODE_FLAG_LIBRARY),initialize(context,child,parentScope,mode),child=child.nextSibling;kind==node_1.NodeKind.FILE&&mode==CheckMode.INITIALIZE&&(context.booleanType=parentScope.findLocal("boolean",scope_1.ScopeHint.NORMAL).resolvedType,context.uint8Type=parentScope.findLocal("uint8",scope_1.ScopeHint.NORMAL).resolvedType,context.int32Type=parentScope.findLocal("int32",scope_1.ScopeHint.NORMAL).resolvedType,context.int64Type=parentScope.findLocal("int64",scope_1.ScopeHint.NORMAL).resolvedType,context.int8Type=parentScope.findLocal("int8",scope_1.ScopeHint.NORMAL).resolvedType,context.int16Type=parentScope.findLocal("int16",scope_1.ScopeHint.NORMAL).resolvedType,context.stringType=parentScope.findLocal("string",scope_1.ScopeHint.NORMAL).resolvedType,context.uint32Type=parentScope.findLocal("uint32",scope_1.ScopeHint.NORMAL).resolvedType,context.uint64Type=parentScope.findLocal("uint64",scope_1.ScopeHint.NORMAL).resolvedType,context.uint16Type=parentScope.findLocal("uint16",scope_1.ScopeHint.NORMAL).resolvedType,context.float32Type=parentScope.findLocal("float32",scope_1.ScopeHint.NORMAL).resolvedType,context.float64Type=parentScope.findLocal("float64",scope_1.ScopeHint.NORMAL).resolvedType,prepareNativeType(context.booleanType,1,0),prepareNativeType(context.uint8Type,1,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.int8Type,1,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.int16Type,2,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.uint16Type,2,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.int32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER),prepareNativeType(context.int64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_LONG),prepareNativeType(context.uint32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_INTEGER|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.uint64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_LONG|symbol_1.SYMBOL_FLAG_IS_UNSIGNED),prepareNativeType(context.stringType,4,symbol_1.SYMBOL_FLAG_IS_REFERENCE),prepareNativeType(context.float32Type,4,symbol_1.SYMBOL_FLAG_NATIVE_FLOAT),prepareNativeType(context.float64Type,8,symbol_1.SYMBOL_FLAG_NATIVE_DOUBLE))}function prepareNativeType(type,byteSizeAndMaxAlignment,flags){var symbol=type.symbol;symbol.kind=symbol_1.SymbolKind.TYPE_NATIVE,symbol.byteSize=byteSizeAndMaxAlignment,symbol.maxAlignment=byteSizeAndMaxAlignment,symbol.flags=flags}function forbidFlag(context,node,flag,text){if(0!=(node.flags&flag)){var range=node_1.rangeForFlag(node.firstFlag,flag);null!=range&&(node.flags=node.flags&~flag,context.log.error(range,text))}}function requireFlag(context,node,flag,text){0==(node.flags&flag)&&(node.flags=node.flags|flag,context.log.error(node.range,text))}function initializeSymbol(context,symbol){if(symbol.state==symbol_1.SymbolState.INITIALIZED)return void assert_1.assert(null!=symbol.resolvedType);assert_1.assert(symbol.state==symbol_1.SymbolState.UNINITIALIZED),symbol.state=symbol_1.SymbolState.INITIALIZING;var node=symbol.node;if(forbidFlag(context,node,node_1.NODE_FLAG_PROTECTED,"Unsupported flag 'protected'"),symbol.kind==symbol_1.SymbolKind.TYPE_MODULE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a module"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a module"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a module"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a module");else if(symbol.kind==symbol_1.SymbolKind.TYPE_CLASS||symbol.kind==symbol_1.SymbolKind.TYPE_NATIVE||symbol.kind==symbol_1.SymbolKind.TYPE_GENERIC||symbol.kind==symbol_1.SymbolKind.TYPE_TEMPLATE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a class"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a class");else if(symbol.kind==symbol_1.SymbolKind.TYPE_INTERFACE)forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on a interface"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on a interface");else if(symbol.kind==symbol_1.SymbolKind.TYPE_ENUM){forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' on an enum"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' on an enum"),symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol;var underlyingSymbol=symbol.resolvedType.underlyingType(context).symbol;symbol.byteSize=underlyingSymbol.byteSize,symbol.maxAlignment=underlyingSymbol.maxAlignment}else if(symbol_1.isFunction(symbol.kind)){var body=node.functionBody(),returnType=node.functionReturnType(),oldUnsafeAllowed=context.isUnsafeAllowed;context.isUnsafeAllowed=node.isUnsafe(),resolveAsType(context,returnType,symbol.scope.parent),returnType.resolvedType.isClass()&&returnType.hasParameters()&&node.parent!=returnType.resolvedType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],returnType.resolvedType.symbol.scope);for(var argumentCount=0,child=node.functionFirstArgument();child!=returnType;)assert_1.assert(child.kind==node_1.NodeKind.VARIABLE),assert_1.assert(child.symbol.kind==symbol_1.SymbolKind.VARIABLE_ARGUMENT),initializeSymbol(context,child.symbol),child.symbol.offset=argumentCount,argumentCount+=1,child=child.nextSibling;if(symbol.kind!=symbol_1.SymbolKind.FUNCTION_INSTANCE?(forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' here"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' here"),forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' here"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' here")):node.isGet()?(forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use both 'get' and 'set'"),1!=argumentCount&&context.log.error(symbol.range,"Getters must not have any arguments")):node.isSet()?(symbol.rename="set_"+symbol.name,2!=argumentCount&&context.log.error(symbol.range,"Setters must have exactly one argument")):node.isOperator()&&("~"==symbol.name||"++"==symbol.name||"--"==symbol.name?1!=argumentCount&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must not have any arguments"):"+"==symbol.name||"-"==symbol.name?argumentCount>2&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must have at most one argument"):"[]="==symbol.name?argumentCount<2&&context.log.error(symbol.range,"Operator '[]=' must have at least one argument"):2!=argumentCount&&context.log.error(symbol.range,"Operator '"+symbol.name+"' must have exactly one argument")),symbol.resolvedType=new type_1.Type,symbol.resolvedType.symbol=symbol,symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE){var parent_2=symbol.parent(),shouldConvertInstanceToGlobal=!1;if(forbidFlag(context,node,node_1.NODE_FLAG_EXPORT,"Cannot use 'export' on an instance function"),forbidFlag(context,node,node_1.NODE_FLAG_DECLARE,"Cannot use 'declare' on an instance function"),parent_2.node.isDeclare()?null==body?node.flags=node.flags|node_1.NODE_FLAG_DECLARE:shouldConvertInstanceToGlobal=!0:(null==body&&context.log.error(node.lastChild.range,"Must implement this function"),parent_2.node.isExport()&&(node.flags=node.flags|node_1.NODE_FLAG_EXPORT)),shouldConvertInstanceToGlobal){symbol.kind=symbol_1.SymbolKind.FUNCTION_GLOBAL,symbol.flags=symbol.flags|symbol_1.SYMBOL_FLAG_CONVERT_INSTANCE_TO_GLOBAL,symbol.rename=parent_2.name+"_"+(null!=symbol.rename?symbol.rename:symbol.name);var argument=node.functionFirstArgument();assert_1.assert("this"==argument.symbol.name),argument.symbol.rename="__this"}}else null==body?(forbidFlag(context,node,node_1.NODE_FLAG_EXPORT,"Cannot use 'export' on an unimplemented function"),node.parent&&node.parent.isDeclare()||requireFlag(context,node,node_1.NODE_FLAG_DECLARE,"Declared functions must be prefixed with 'declare'")):forbidFlag(context,node,node_1.NODE_FLAG_DECLARE,"Cannot use 'declare' on a function with an implementation");context.isUnsafeAllowed=oldUnsafeAllowed}else if(symbol_1.isVariable(symbol.kind)){forbidFlag(context,node,node_1.NODE_FLAG_GET,"Cannot use 'get' on a variable"),forbidFlag(context,node,node_1.NODE_FLAG_SET,"Cannot use 'set' on a variable");var type=node.variableType(),value=node.variableValue(),oldUnsafeAllowed=context.isUnsafeAllowed;if(context.isUnsafeAllowed=context.isUnsafeAllowed||node.isUnsafe(),symbol.kind!=symbol_1.SymbolKind.VARIABLE_INSTANCE&&(forbidFlag(context,node,node_1.NODE_FLAG_PUBLIC,"Cannot use 'public' here"),forbidFlag(context,node,node_1.NODE_FLAG_PRIVATE,"Cannot use 'private' here")),null!=type?(resolveAsType(context,type,symbol.scope),type.resolvedType.isTemplate()&&type.hasParameters()&&node.parent!=type.resolvedType.symbol.node&&deriveConcreteClass(context,type,[type.firstChild.firstChild],type.resolvedType.symbol.scope),symbol.resolvedType=type.resolvedType):null!=value?(resolveAsExpression(context,value,symbol.scope),value.resolvedType.isTemplate()&&value.hasParameters()&&node.parent!=value.resolvedType.symbol.node&&deriveConcreteClass(context,value,[value.firstChild.firstChild],value.resolvedType.symbol.scope),symbol.resolvedType=value.resolvedType):(context.log.error(node.internalRange,"Cannot create untyped variables"),symbol.resolvedType=context.errorType),symbol.resolvedType!=context.voidType&&symbol.resolvedType!=context.nullType||(context.log.error(node.internalRange,"Cannot create a variable with type '"+symbol.resolvedType.toString()+"'"),symbol.resolvedType=context.errorType),symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT)if(null!=value)resolveAsExpression(context,value,symbol.scope),checkConversion(context,value,symbol.resolvedTypeUnderlyingIfEnumValue(context),type_1.ConversionKind.IMPLICIT),value.kind==node_1.NodeKind.INT32||value.kind==node_1.NodeKind.INT64||value.kind==node_1.NodeKind.BOOLEAN?symbol.offset=value.intValue:value.kind==node_1.NodeKind.FLOAT32||value.kind==node_1.NodeKind.FLOAT64?symbol.offset=value.floatValue:value.resolvedType!=context.errorType&&(context.log.error(value.range,"Invalid constant initializer"),symbol.resolvedType=context.errorType);else if(symbol.isEnumValue())if(null!=node.previousSibling){var previousSymbol=node.previousSibling.symbol;initializeSymbol(context,previousSymbol),symbol.offset=previousSymbol.offset+1}else symbol.offset=0;else context.log.error(node.internalRange,"Constants must be initialized");if(null==symbol.scope.symbol)for(var scope=symbol.scope.parent;null!=scope;){var shadowed=scope.findLocal(symbol.name,scope_1.ScopeHint.NORMAL);if(null!=shadowed){context.log.error(node.internalRange,"The symbol '"+symbol.name+"' shadows another symbol with the same name in a parent scope");break}if(null!=scope.symbol)break;scope=scope.parent}context.isUnsafeAllowed=oldUnsafeAllowed}else assert_1.assert(!1);assert_1.assert(null!=symbol.resolvedType),symbol.state=symbol_1.SymbolState.INITIALIZED}function deriveConcreteClass(context,type,parameters,scope){var templateNode=type.resolvedType.pointerTo?type.resolvedType.pointerTo.symbol.node:type.resolvedType.symbol.node,templateName=templateNode.stringValue,typeName=templateNode.stringValue+"<"+parameters[0].stringValue+">",rename=templateNode.stringValue+"_"+parameters[0].stringValue,symbol=scope.parent.findNested(typeName,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);if(symbol){var genericSymbol=scope.parent.findNested(type.firstChild.firstChild.stringValue,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);return type.firstChild.firstChild.symbol=genericSymbol,genericSymbol.resolvedType.pointerTo?type.firstChild.firstChild.resolvedType=genericSymbol.resolvedType.pointerType():type.firstChild.firstChild.resolvedType=genericSymbol.resolvedType,type.symbol=symbol,void(type.resolvedType.pointerTo?type.resolvedType=symbol.resolvedType.pointerType():type.resolvedType=symbol.resolvedType)}var node=templateNode.clone();if(node.stringValue=typeName,cloneChildren(templateNode.firstChild.nextSibling,node,parameters,templateName,typeName),node.offset=null,initialize(context,node,scope.parent,CheckMode.NORMAL),resolve(context,node,scope.parent),node.symbol.flags|=symbol_1.SYMBOL_FLAG_USED,type.symbol=node.symbol,node.symbol.rename=rename,type.resolvedType.pointerTo?type.resolvedType=node.symbol.resolvedType.pointerType():type.resolvedType=node.symbol.resolvedType,templateNode.parent)templateNode.replaceWith(node);else{var prevNode=templateNode.derivedNodes[templateNode.derivedNodes.length-1];prevNode.parent.insertChildAfter(prevNode,node)}void 0===templateNode.derivedNodes&&(templateNode.derivedNodes=[]),templateNode.derivedNodes.push(node),type.firstChild.firstChild.kind=node_1.NodeKind.NAME,resolve(context,type.firstChild.firstChild,scope.parent),type.stringValue=node.symbol.name}function cloneChildren(child,parentNode,parameters,templateName,typeName){for(var firstChildNode=null,lastChildNode=null;child;)if("this"==child.stringValue&&child.parent.symbol&&child.parent.symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE&&child.kind==node_1.NodeKind.TYPE)child=child.nextSibling;else{var childNode=void 0;if(child.kind!=node_1.NodeKind.PARAMETERS&&child.kind!=node_1.NodeKind.PARAMETER){if(child.isGeneric()){var offset=child.offset;child.resolvedType&&(offset=child.resolvedType.pointerTo?child.resolvedType.pointerTo.symbol.node.offset:child.resolvedType.symbol.node.offset),childNode=child.symbol&&symbol_1.isVariable(child.symbol.kind)?child.clone():parameters[offset].clone(),childNode.kind=node_1.NodeKind.NAME}else"T"==child.stringValue&&(terminal_1.Terminal.write("Generic type escaped!"),terminal_1.Terminal.write(child)),childNode=child.clone(),childNode.stringValue==templateName&&(childNode.stringValue=typeName);childNode.parent=parentNode,"constructor"==childNode.stringValue&&childNode.parent.kind==node_1.NodeKind.CLASS&&(childNode.parent.constructorFunctionNode=childNode),firstChildNode||(firstChildNode=childNode),lastChildNode&&(lastChildNode.nextSibling=childNode,childNode.previousSibling=lastChildNode),child.firstChild&&cloneChildren(child.firstChild,childNode,parameters,templateName,typeName),lastChildNode=childNode,child=child.nextSibling}else child=child.nextSibling}null!=firstChildNode&&(parentNode.firstChild=firstChildNode),null!=lastChildNode&&(parentNode.lastChild=lastChildNode)}function resolveChildren(context,node,parentScope){for(var child=node.firstChild;null!=child;)resolve(context,child,parentScope),assert_1.assert(null!=child.resolvedType),child=child.nextSibling}function resolveChildrenAsExpressions(context,node,parentScope){for(var child=node.firstChild;null!=child;)resolveAsExpression(context,child,parentScope),child=child.nextSibling}function resolveAsExpression(context,node,parentScope){assert_1.assert(node_1.isExpression(node)),resolve(context,node,parentScope),assert_1.assert(null!=node.resolvedType),node.resolvedType!=context.errorType&&(node.isType()?(context.log.error(node.range,"Expected expression but found type"),node.resolvedType=context.errorType):node.resolvedType==context.voidType&&node.parent.kind!=node_1.NodeKind.EXPRESSION&&(context.log.error(node.range,"This expression does not return a value"),node.resolvedType=context.errorType))}function resolveAsType(context,node,parentScope){assert_1.assert(node_1.isExpression(node)),resolve(context,node,parentScope),assert_1.assert(null!=node.resolvedType),node.resolvedType==context.errorType||node.isType()||(context.log.error(node.range,"Expected type but found expression"),node.resolvedType=context.errorType)}function canConvert(context,node,to,kind){var from=node.resolvedType;if(assert_1.assert(node_1.isExpression(node)),assert_1.assert(null!=from),assert_1.assert(null!=to),from.isGeneric()||to.isGeneric())return!0;if(from==to||from==context.errorType||to==context.errorType)return!0;if(from==context.nullType)return!0;if(from.isReference()||to.isReference()){if(kind==type_1.ConversionKind.EXPLICIT)return!0}else{if(from==context.booleanType)return!0;if(from.isInteger()&&to.isInteger()){to.integerBitMask(context);return!(!from.isUnsigned()||!to.isUnsigned())||(!(!from.isEnum()||to!=from.underlyingType(context))||(!node.intValue||(kind==type_1.ConversionKind.EXPLICIT||from.symbol.byteSize=0&&node.intValue<=const_1.MAX_UINT32_VALUE:node.intValue>=const_1.MIN_INT32_VALUE&&node.intValue<=const_1.MAX_INT32_VALUE))))}if(from.isInteger()&&to.isFloat()||from.isInteger()&&to.isDouble()||from.isLong()&&to.isInteger()||from.isLong()&&to.isFloat()||from.isLong()&&to.isDouble()||from.isFloat()&&to.isInteger()||from.isFloat()&&to.isLong()||from.isDouble()&&to.isInteger()||from.isDouble()&&to.isLong()||from.isDouble()&&to.isFloat())return kind!=type_1.ConversionKind.IMPLICIT;if(from.isInteger()&&to.isLong()||from.isFloat()&&to.isDouble()||from.isFloat()&&to.isFloat()||from.isDouble()&&to.isDouble())return!0}return!1}function checkConversion(context,node,to,kind){canConvert(context,node,to,kind)||(context.log.error(node.range,"Cannot convert from type '"+node.resolvedType.toString()+"' to type '"+to.toString()+"' "+(kind==type_1.ConversionKind.IMPLICIT&&canConvert(context,node,to,type_1.ConversionKind.EXPLICIT)?"without a cast":"")),node.resolvedType=context.errorType)}function checkStorage(context,target){assert_1.assert(node_1.isExpression(target)),target.resolvedType==context.errorType||target.kind==node_1.NodeKind.INDEX||target.kind==node_1.NodeKind.POINTER_INDEX||target.kind==node_1.NodeKind.DEREFERENCE||(target.kind==node_1.NodeKind.NAME||target.kind==node_1.NodeKind.DOT)&&(null==target.symbol||symbol_1.isVariable(target.symbol.kind)&&target.symbol.kind!=symbol_1.SymbolKind.VARIABLE_CONSTANT)||(context.log.error(target.range,"Cannot store to this location"),target.resolvedType=context.errorType)}function createDefaultValueForType(context,type){return type.isLong()?node_1.createLong(0):type.isInteger()?node_1.createInt(0):type.isDouble()?node_1.createDouble(0):type.isFloat()?node_1.createFloat(0):type==context.booleanType?node_1.createboolean(!1):type.isClass()?node_1.createNull():type.isGeneric()?node_1.createNull():(assert_1.assert(type.isReference()),node_1.createNull())}function simplifyBinary(node){var left=node.binaryLeft(),right=node.binaryRight();if(node.kind!=node_1.NodeKind.ADD&&node.kind!=node_1.NodeKind.MULTIPLY&&node.kind!=node_1.NodeKind.BITWISE_AND&&node.kind!=node_1.NodeKind.BITWISE_OR&&node.kind!=node_1.NodeKind.BITWISE_XOR||left.kind!=node_1.NodeKind.INT32||right.kind==node_1.NodeKind.INT32||(node.appendChild(left.remove()),left=node.binaryLeft(),right=node.binaryRight()),(node.kind==node_1.NodeKind.MULTIPLY||(node.kind==node_1.NodeKind.DIVIDE||node.kind==node_1.NodeKind.REMAINDER)&&node.resolvedType.isUnsigned())&&right.kind==node_1.NodeKind.INT32&&utils_1.isPositivePowerOf2(right.intValue)){for(var shift=-1,value=right.intValue;0!=value;)value>>=1,shift+=1;node.kind==node_1.NodeKind.MULTIPLY?(node.kind=node_1.NodeKind.SHIFT_LEFT,right.intValue=shift):node.kind==node_1.NodeKind.DIVIDE?(node.kind=node_1.NodeKind.SHIFT_RIGHT,right.intValue=shift):node.kind==node_1.NodeKind.REMAINDER?(node.kind=node_1.NodeKind.BITWISE_AND,right.intValue=right.intValue-1):assert_1.assert(!1)}else node.kind==node_1.NodeKind.ADD&&right.kind==node_1.NodeKind.NEGATIVE?(node.kind=node_1.NodeKind.SUBTRACT,right.replaceWith(right.unaryValue().remove())):node.kind==node_1.NodeKind.ADD&&right.isNegativeInteger()&&(node.kind=node_1.NodeKind.SUBTRACT,right.intValue=-right.intValue)}function binaryHasUnsignedArguments(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isUnsigned()&&rightType.isUnsigned()||leftType.isUnsigned()&&right.isNonNegativeInteger()||left.isNonNegativeInteger()&&rightType.isUnsigned()}function isBinaryLong(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isLong()||rightType.isLong()}function isBinaryDouble(node){var left=node.binaryLeft(),right=node.binaryRight(),leftType=left.resolvedType,rightType=right.resolvedType;return leftType.isDouble()||rightType.isDouble()}function isSymbolAccessAllowed(context,symbol,node,range){if(symbol.isUnsafe()&&!context.isUnsafeAllowed)return context.log.error(range,"Cannot use symbol '"+symbol.name+"' outside an 'unsafe' block"),!1;if(null!=symbol.node&&symbol.node.isPrivate()){var parent_3=symbol.parent();if(null!=parent_3&&context.enclosingClass!=parent_3)return context.log.error(range,"Cannot access private symbol '"+symbol.name+"' here"),!1}return!(symbol_1.isFunction(symbol.kind)&&(symbol.isSetter()?!node.isAssignTarget():!node.isCallValue()))||(symbol.isSetter()?context.log.error(range,"Cannot use setter '"+symbol.name+"' here"):context.log.error(range,"Must call function '"+symbol.name+"'"),!1)}function resolve(context,node,parentScope){var kind=node.kind;if(assert_1.assert(kind==node_1.NodeKind.FILE||null!=parentScope),null==node.resolvedType)if(node.resolvedType=context.errorType,kind==node_1.NodeKind.FILE||kind==node_1.NodeKind.GLOBAL)resolveChildren(context,node,parentScope);else if(kind==node_1.NodeKind.MODULE){var oldEnclosingModule=context.enclosingModule;initializeSymbol(context,node.symbol),context.enclosingModule=node.symbol,resolveChildren(context,node,node.scope),context.enclosingModule=oldEnclosingModule}else if(kind==node_1.NodeKind.IMPORT||kind==node_1.NodeKind.IMPORT_FROM);else if(kind==node_1.NodeKind.CLASS){var oldEnclosingClass=context.enclosingClass;initializeSymbol(context,node.symbol),context.enclosingClass=node.symbol,resolveChildren(context,node,node.scope),node.symbol.kind==symbol_1.SymbolKind.TYPE_CLASS&&node.symbol.determineClassLayout(context),context.enclosingClass=oldEnclosingClass}else if(kind==node_1.NodeKind.ENUM)initializeSymbol(context,node.symbol),resolveChildren(context,node,node.scope);else if(kind==node_1.NodeKind.FUNCTION){var body=node.functionBody();if(initializeSymbol(context,node.symbol),"constructor"==node.stringValue&&node.parent.kind==node_1.NodeKind.CLASS&&(node.parent.constructorFunctionNode=node),null!=body){var oldReturnType=context.currentReturnType,oldUnsafeAllowed=context.isUnsafeAllowed,returnType=node.functionReturnType();returnType.resolvedType.isTemplate()&&returnType.hasParameters()&&node.parent!=returnType.resolvedType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],returnType.resolvedType.symbol.scope),context.currentReturnType=returnType.resolvedType,context.isUnsafeAllowed=node.isUnsafe(),resolveChildren(context,body,node.scope),oldReturnType&&oldReturnType.isTemplate()&&returnType.hasParameters()&&node.parent!=oldReturnType.symbol.node&&deriveConcreteClass(context,returnType,[returnType.firstChild.firstChild],oldReturnType.symbol.scope),context.currentReturnType=oldReturnType,context.isUnsafeAllowed=oldUnsafeAllowed}}else if(kind==node_1.NodeKind.PARAMETER)var symbol=node.symbol;else if(kind==node_1.NodeKind.VARIABLE){var symbol=node.symbol;initializeSymbol(context,symbol);var oldUnsafeAllowed=context.isUnsafeAllowed;context.isUnsafeAllowed=context.isUnsafeAllowed||node.isUnsafe();var value=node.variableValue();null!=value?(resolveAsExpression(context,value,parentScope),checkConversion(context,value,symbol.resolvedTypeUnderlyingIfEnumValue(context),type_1.ConversionKind.IMPLICIT),symbol.resolvedType!=value.resolvedType&&value.becomeValueTypeOf(symbol,context),symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL&&value.kind!=node_1.NodeKind.INT32&&value.kind!=node_1.NodeKind.BOOLEAN&&(value.kind,node_1.NodeKind.NULL)):symbol.resolvedType!=context.errorType&&(value=createDefaultValueForType(context,symbol.resolvedType),resolveAsExpression(context,value,parentScope),node.appendChild(value)),symbol.kind==symbol_1.SymbolKind.VARIABLE_GLOBAL&&symbol.resolvedType!=context.errorType&&(symbol.offset=context.allocateGlobalVariableOffset(symbol.resolvedType.variableSizeOf(context),symbol.resolvedType.variableAlignmentOf(context))),context.isUnsafeAllowed=oldUnsafeAllowed}else if(kind==node_1.NodeKind.BREAK||kind==node_1.NodeKind.CONTINUE){for(var found=!1,n=node;null!=n;){if(n.kind==node_1.NodeKind.WHILE){found=!0;break}n=n.parent}found||context.log.error(node.range,"Cannot use this statement outside of a loop")}else if(kind==node_1.NodeKind.BLOCK){var oldUnsafeAllowed=context.isUnsafeAllowed;node.isUnsafe()&&(context.isUnsafeAllowed=!0),resolveChildren(context,node,node.scope),context.isUnsafeAllowed=oldUnsafeAllowed}else if(kind==node_1.NodeKind.IMPORTS||kind==node_1.NodeKind.CONSTANTS||kind==node_1.NodeKind.VARIABLES)resolveChildren(context,node,parentScope);else if(kind==node_1.NodeKind.ANY)node.kind=node_1.NodeKind.TYPE,node.resolvedType=context.anyType;else if(kind==node_1.NodeKind.INT32)node.resolvedType=node.intValue<0&&!node.isPositive()?context.uint32Type:context.int32Type;else if(kind==node_1.NodeKind.INT64)node.resolvedType=node.intValue<0&&!node.isPositive()?context.uint64Type:context.int64Type;else if(kind==node_1.NodeKind.FLOAT32)node.resolvedType=context.float32Type;else if(kind==node_1.NodeKind.FLOAT64)node.resolvedType=context.float64Type;else if(kind==node_1.NodeKind.STRING)node.resolvedType=context.stringType;else if(kind==node_1.NodeKind.BOOLEAN)node.resolvedType=context.booleanType;else if(kind==node_1.NodeKind.NULL)node.resolvedType=context.nullType;else if(kind==node_1.NodeKind.INDEX){resolveChildrenAsExpressions(context,node,parentScope);var target=node.indexTarget(),type=target.resolvedType;if(type!=context.errorType){var symbol=type.hasInstanceMembers()?type.findMember("[]",scope_1.ScopeHint.NORMAL):null;null==symbol?void 0!==target.resolvedType.pointerTo?(node.kind=node_1.NodeKind.POINTER_INDEX,node.resolvedType=target.resolvedType.pointerTo.symbol.resolvedType):context.log.error(node.internalRange,"Cannot index into type '"+target.resolvedType.toString()+"'"):(assert_1.assert(symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE||symbol.kind==symbol_1.SymbolKind.FUNCTION_GLOBAL&&symbol.shouldConvertInstanceToGlobal()),node.kind=node_1.NodeKind.CALL,target.remove(),node.insertChildBefore(node.firstChild,node_1.createMemberReference(target,symbol)),node.resolvedType=null,resolveAsExpression(context,node,parentScope))}}else if(kind==node_1.NodeKind.ALIGN_OF){var type=node.alignOfType();resolveAsType(context,type,parentScope),node.resolvedType=context.int32Type,type.resolvedType!=context.errorType&&node.becomeIntegerConstant(type.resolvedType.allocationAlignmentOf(context))}else if(kind==node_1.NodeKind.SIZE_OF){var type=node.sizeOfType();resolveAsType(context,type,parentScope),node.resolvedType=context.int32Type,type.resolvedType!=context.errorType&&node.becomeIntegerConstant(type.resolvedType.allocationSizeOf(context))}else if(kind==node_1.NodeKind.THIS){var symbol=parentScope.findNested("this",scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);null==symbol?context.log.error(node.range,"Cannot use 'this' here"):node.becomeSymbolReference(symbol)}else if(kind==node_1.NodeKind.PARSE_ERROR)node.resolvedType=context.errorType;else if(kind==node_1.NodeKind.NAME){var name_1=node.stringValue,symbol=parentScope.findNested(name_1,scope_1.ScopeHint.NORMAL,scope_1.FindNested.NORMAL);if(null==symbol){var errorMessage="No symbol named '"+name_1+"' here";symbol=parentScope.findNested(name_1,scope_1.ScopeHint.NORMAL,scope_1.FindNested.ALLOW_INSTANCE_ERRORS),null!=symbol?errorMessage+=", did you mean 'this."+symbol.name+"'?":"number"==name_1?errorMessage+=", you cannot use generic number type from TypeScript!":"bool"==name_1&&(errorMessage+=", did you mean 'boolean'?"),context.log.error(node.range,errorMessage)}else symbol.state==symbol_1.SymbolState.INITIALIZING?context.log.error(node.range,"Cyclic reference to symbol '"+name_1+"' here"):isSymbolAccessAllowed(context,symbol,node,node.range)&&(initializeSymbol(context,symbol),node.symbol=symbol,node.resolvedType=symbol.resolvedType,node.resolvedType.isGeneric()&&(node.flags|=node_1.NODE_FLAG_GENERIC),symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT&&(symbol.resolvedType==context.booleanType?node.becomeBooleanConstant(0!=symbol.offset):symbol.resolvedType==context.float32Type?node.becomeFloatConstant(symbol.offset):symbol.resolvedType==context.float64Type?node.becomeDoubleConstant(symbol.offset):symbol.resolvedType==context.int64Type?node.becomeLongConstant(symbol.offset):node.becomeIntegerConstant(symbol.offset)))}else if(kind==node_1.NodeKind.CAST){var value=node.castValue(),type=node.castType();resolveAsExpression(context,value,parentScope),resolveAsType(context,type,parentScope);var castedType=type.resolvedType;if(checkConversion(context,value,castedType,type_1.ConversionKind.EXPLICIT),node.resolvedType=castedType,value.kind==node_1.NodeKind.INT32&&castedType.isInteger()){var result=value.intValue,shift=32-castedType.integerBitCount(context);node.becomeIntegerConstant(castedType.isUnsigned()?castedType.integerBitMask(context)&result:result<>shift)}else value.kind==node_1.NodeKind.INT32&&castedType.isFloat()?node.becomeFloatConstant(value.intValue):value.kind==node_1.NodeKind.INT32&&castedType.isDouble()?node.becomeDoubleConstant(value.intValue):value.kind==node_1.NodeKind.FLOAT32&&castedType.isInteger()&&node.becomeIntegerConstant(Math.round(value.floatValue))}else if(kind==node_1.NodeKind.DOT){var target=node.dotTarget();if(resolve(context,target,parentScope),target.resolvedType!=context.errorType)if(target.isType()&&(target.resolvedType.isEnum()||target.resolvedType.hasInstanceMembers())||!target.isType()&&target.resolvedType.hasInstanceMembers()){var name_2=node.stringValue;if(name_2.length>0){var symbol=target.resolvedType.findMember(name_2,node.isAssignTarget()?scope_1.ScopeHint.PREFER_SETTER:scope_1.ScopeHint.PREFER_GETTER);if(null==symbol)context.log.error(node.internalRange,"No member named '"+name_2+"' on type '"+target.resolvedType.toString()+"'");else{if(symbol.isGetter())return void(node.parent.stringValue===node.stringValue&&node.parent.kind===node_1.NodeKind.CALL?(node.parent.resolvedType=null,node.symbol=symbol,node.resolvedType=symbol.resolvedType,resolveAsExpression(context,node.parent,parentScope)):(node.kind=node_1.NodeKind.CALL,node.appendChild(node_1.createMemberReference(target.remove(),symbol)),node.resolvedType=null,resolveAsExpression(context,node,parentScope)));isSymbolAccessAllowed(context,symbol,node,node.internalRange)&&(initializeSymbol(context,symbol),node.symbol=symbol,node.resolvedType=symbol.resolvedType,symbol.kind==symbol_1.SymbolKind.VARIABLE_CONSTANT&&node.becomeIntegerConstant(symbol.offset))}}}else context.log.error(node.internalRange,"The type '"+target.resolvedType.toString()+"' has no members")}else if(kind==node_1.NodeKind.CALL){var value=node.callValue();if(resolveAsExpression(context,value,parentScope),value.resolvedType!=context.errorType){var symbol=value.symbol;if(null!=symbol&&symbol_1.isFunction(symbol.kind)){if(initializeSymbol(context,symbol),symbol.shouldConvertInstanceToGlobal()){var name_3=node_1.createSymbolReference(symbol);node.insertChildBefore(value,name_3.withRange(value.internalRange)),node.insertChildBefore(value,value.dotTarget().remove()),value.remove(),value=name_3}for(var returnType=symbol.node.functionReturnType(),argumentVariable=symbol.node.functionFirstArgumentIgnoringThis(),argumentValue=value.nextSibling;argumentVariable!=returnType&&null!=argumentValue;)resolveAsExpression(context,argumentValue,parentScope),checkConversion(context,argumentValue,argumentVariable.symbol.resolvedType,type_1.ConversionKind.IMPLICIT),argumentVariable=argumentVariable.nextSibling,argumentValue=argumentValue.nextSibling;if(returnType.resolvedType!=context.anyType)if(argumentVariable==returnType||argumentVariable.hasVariableValue()){if(null!=argumentValue){for(;null!=argumentValue;)resolveAsExpression(context,argumentValue,parentScope),argumentValue=argumentValue.nextSibling;context.log.error(node.internalRange,"Too many arguments for function '"+symbol.name+"'")}}else context.log.error(node.internalRange,"Not enough arguments for function '"+symbol.name+"'");returnType.resolvedType.isArray()&&terminal_1.Terminal.write(returnType),node.resolvedType=returnType.resolvedType}else context.log.error(value.range,"Cannot call value of type '"+value.resolvedType.toString()+"'")}}else if(kind==node_1.NodeKind.DELETE){var value=node.deleteType();null!=value?(resolveAsExpression(context,value,parentScope),null!=value.resolvedType&&value.resolvedType!=context.voidType||context.log.error(value.range,"Unexpected delete value 'void'")):context.log.error(node.range,"Expected delete value '"+context.currentReturnType.toString()+"'")}else if(kind==node_1.NodeKind.RETURN){var value=node.returnValue();null!=value?(resolveAsExpression(context,value,parentScope),null!=context.currentReturnType&&(context.currentReturnType!=context.voidType?(value.resolvedType.isTemplate()&&value.hasParameters()&&node.parent!=value.resolvedType.symbol.node&&deriveConcreteClass(context,value,[value.firstChild.firstChild],value.resolvedType.symbol.scope),checkConversion(context,value,context.currentReturnType,type_1.ConversionKind.IMPLICIT)):context.log.error(value.range,"Unexpected return value in function returning 'void'")),node.parent.returnNode=node):null!=context.currentReturnType&&context.currentReturnType!=context.voidType&&context.log.error(node.range,"Expected return value in function returning '"+context.currentReturnType.toString()+"'")}else if(kind==node_1.NodeKind.EMPTY);else if(kind==node_1.NodeKind.PARAMETERS);else if(kind==node_1.NodeKind.EXTENDS)resolveAsType(context,node.extendsType(),parentScope);else if(kind==node_1.NodeKind.IMPLEMENTS){for(var child=node.firstChild;null!=child;)resolveAsType(context,child,parentScope),child=child.nextSibling;context.log.error(node.range,"Interfaces are not implemented yet")}else if(kind==node_1.NodeKind.EXPRESSION)resolveAsExpression(context,node.expressionValue(),parentScope);else if(kind==node_1.NodeKind.WHILE){var value=node.whileValue(),body=node.whileBody();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,body,parentScope)}else if(kind==node_1.NodeKind.IF){var value=node.ifValue(),yes=node.ifTrue(),no=node.ifFalse();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,yes,parentScope),null!=no&&resolve(context,no,parentScope)}else if(kind==node_1.NodeKind.HOOK){var value=node.hookValue(),yes=node.hookTrue(),no=node.hookFalse();resolveAsExpression(context,value,parentScope),checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),resolve(context,yes,parentScope),resolve(context,no,parentScope),checkConversion(context,yes,no.resolvedType,type_1.ConversionKind.IMPLICIT);var commonType=(yes.resolvedType==context.nullType?no:yes).resolvedType;yes.resolvedType==commonType||yes.resolvedType==context.nullType&&commonType.isReference()||no.resolvedType==commonType||no.resolvedType==context.nullType&&commonType.isReference()||context.log.error(log_1.spanRanges(yes.range,no.range),"Type '"+yes.resolvedType.toString()+"' is not the same as type '"+no.resolvedType.toString()+"'"),node.resolvedType=commonType}else if(kind==node_1.NodeKind.ASSIGN){var left=node.binaryLeft(),right=node.binaryRight();if(left.kind==node_1.NodeKind.INDEX){resolveChildrenAsExpressions(context,left,parentScope);var target=left.indexTarget(),type=target.resolvedType;if(type!=context.errorType){var symbol=type.hasInstanceMembers()?type.findMember("[]=",scope_1.ScopeHint.NORMAL):null;if(null!=symbol){for(assert_1.assert(symbol.kind==symbol_1.SymbolKind.FUNCTION_INSTANCE),node.kind=node_1.NodeKind.CALL,target.remove(),left.remove();null!=left.lastChild;)node.insertChildBefore(node.firstChild,left.lastChild.remove());return node.insertChildBefore(node.firstChild,node_1.createMemberReference(target,symbol)),node.internalRange=log_1.spanRanges(left.internalRange,right.range),node.resolvedType=null,void resolveAsExpression(context,node,parentScope)}void 0!=target.resolvedType.pointerTo?(left.kind=node_1.NodeKind.POINTER_INDEX,left.resolvedType=target.resolvedType.pointerTo.symbol.resolvedType):context.log.error(left.internalRange,"Cannot index into type '"+target.resolvedType.toString()+"'")}}if(left.resolvedType||resolveAsExpression(context,left,parentScope),null!=left.symbol&&left.symbol.isSetter())return node.kind=node_1.NodeKind.CALL,node.internalRange=left.internalRange,node.resolvedType=null,void resolveAsExpression(context,node,parentScope);resolveAsExpression(context,right,parentScope),checkConversion(context,right,left.resolvedType,type_1.ConversionKind.IMPLICIT),checkStorage(context,left),node.resolvedType=left.resolvedType}else if(kind==node_1.NodeKind.NEW){compiler_1.Compiler.mallocRequired=!0;var type=node.newType();resolveAsType(context,type,parentScope),type.resolvedType.isTemplate()&&type.hasParameters()&&node.parent!=type.resolvedType.symbol.node&&deriveConcreteClass(context,type,[type.firstChild.firstChild],type.resolvedType.symbol.scope),type.resolvedType!=context.errorType&&(type.resolvedType.isClass()?node.resolvedType=type.resolvedType:context.log.error(type.range,"Cannot construct type '"+type.resolvedType.toString()+"'"));for(var child=type.nextSibling,constructorNode=node.constructorNode(),argumentVariable=constructorNode.functionFirstArgument();null!=child;)resolveAsExpression(context,child,parentScope),checkConversion(context,child,argumentVariable.symbol.resolvedType,type_1.ConversionKind.IMPLICIT),child=child.nextSibling,argumentVariable=argumentVariable.nextSibling}else if(kind==node_1.NodeKind.POINTER_TYPE){var value=node.unaryValue();if(resolveAsType(context,value,parentScope),context.target==compile_target_1.CompileTarget.JAVASCRIPT)context.log.error(node.internalRange,"Cannot use pointers when compiling to JavaScript");else{var type=value.resolvedType;type!=context.errorType&&(node.resolvedType=type.pointerType())}}else if(kind==node_1.NodeKind.POINTER_INDEX);else if(kind==node_1.NodeKind.DEREFERENCE){var value=node.unaryValue();resolveAsExpression(context,value,parentScope);var type=value.resolvedType;type!=context.errorType&&(null==type.pointerTo?context.log.error(node.internalRange,"Cannot dereference type '"+type.toString()+"'"):node.resolvedType=type.pointerTo)}else if(kind==node_1.NodeKind.ADDRESS_OF){var value=node.unaryValue();resolveAsExpression(context,value,parentScope),context.log.error(node.internalRange,"The address-of operator is not supported")}else if(node_1.isUnary(kind)){var value=node.unaryValue();if(resolveAsExpression(context,value,parentScope),kind==node_1.NodeKind.NOT)checkConversion(context,value,context.booleanType,type_1.ConversionKind.IMPLICIT),node.resolvedType=context.booleanType;else if(value.resolvedType.isLong()){if(value.resolvedType.isUnsigned()?(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR,node.resolvedType=context.uint64Type):node.resolvedType=context.int64Type,value.kind==node_1.NodeKind.INT64){var input=value.longValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeLongConstant(output)}}else if(value.resolvedType.isInteger()){if(value.resolvedType.isUnsigned()?(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR,node.resolvedType=context.uint32Type):node.resolvedType=context.int32Type,value.kind==node_1.NodeKind.INT32){var input=value.intValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeIntegerConstant(output)}}else if(value.resolvedType.isDouble()){if(node.resolvedType=context.float64Type,value.kind==node_1.NodeKind.FLOAT64){var input=value.doubleValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeDoubleConstant(output)}}else if(value.resolvedType.isFloat()){if(node.resolvedType=context.float32Type,value.kind==node_1.NodeKind.FLOAT32){var input=value.floatValue,output=input;kind==node_1.NodeKind.COMPLEMENT?output=~input:kind==node_1.NodeKind.NEGATIVE&&(output=-input),node.becomeFloatConstant(output)}}else if(value.resolvedType!=context.errorType){var name_4=node.internalRange.toString(),symbol=value.resolvedType.findMember(name_4,scope_1.ScopeHint.NOT_BINARY);null!=symbol?(node.appendChild(node_1.createMemberReference(value.remove(),symbol).withRange(node.range).withInternalRange(node.internalRange)),node.kind=node_1.NodeKind.CALL,node.resolvedType=null,resolveAsExpression(context,node,parentScope)):context.log.error(node.internalRange,"Cannot use unary operator '"+name_4+"' with type '"+value.resolvedType.toString()+"'")}}else if(node_1.isBinary(kind)){var left=node.binaryLeft(),right=node.binaryRight();resolveAsExpression(context,left,parentScope),resolveAsExpression(context,right,parentScope);var leftType=left.resolvedType;(leftType.isDouble()&&right.resolvedType.isFloat()||leftType.isLong()&&right.resolvedType.isInteger())&&right.becomeTypeOf(left,context);var rightType=right.resolvedType;if(kind==node_1.NodeKind.LOGICAL_OR||kind==node_1.NodeKind.LOGICAL_AND)checkConversion(context,left,context.booleanType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,context.booleanType,type_1.ConversionKind.IMPLICIT),node.resolvedType=context.booleanType;else if(kind==node_1.NodeKind.ADD&&null!=leftType.pointerTo&&rightType.isInteger())node.resolvedType=leftType;else if(kind!=node_1.NodeKind.LESS_THAN&&kind!=node_1.NodeKind.LESS_THAN_EQUAL&&kind!=node_1.NodeKind.GREATER_THAN&&kind!=node_1.NodeKind.GREATER_THAN_EQUAL||null==leftType.pointerTo&&null==rightType.pointerTo){if((leftType.isInteger()||leftType.isLong()||leftType.isFloat()||leftType.isDouble()||leftType.isGeneric()&&rightType.isGeneric())&&kind!=node_1.NodeKind.EQUAL&&kind!=node_1.NodeKind.NOT_EQUAL){var isFloat=!1,isFloat64=!1;(leftType.isFloat()||leftType.isDouble())&&(isFloat=!0,isFloat64=leftType.isDouble());var isUnsigned=binaryHasUnsignedArguments(node);if(kind==node_1.NodeKind.ADD||kind==node_1.NodeKind.SUBTRACT||kind==node_1.NodeKind.MULTIPLY||kind==node_1.NodeKind.DIVIDE||kind==node_1.NodeKind.REMAINDER||kind==node_1.NodeKind.BITWISE_AND||kind==node_1.NodeKind.BITWISE_OR||kind==node_1.NodeKind.BITWISE_XOR||kind==node_1.NodeKind.SHIFT_LEFT||kind==node_1.NodeKind.SHIFT_RIGHT){var isLong=isBinaryLong(node),commonType=void 0;if(commonType=isFloat?isBinaryDouble(node)?context.float64Type:context.float32Type:isUnsigned?isLong?context.uint64Type:context.uint32Type:isLong?context.int64Type:context.int32Type,isUnsigned&&(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR),checkConversion(context,left,commonType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,commonType,type_1.ConversionKind.IMPLICIT),node.resolvedType=commonType,commonType==context.int64Type&&(left.kind==node_1.NodeKind.INT32?(left.kind=node_1.NodeKind.INT64,left.resolvedType=context.int64Type):right.kind==node_1.NodeKind.INT32&&(right.kind=node_1.NodeKind.INT64,right.resolvedType=context.int64Type)),left.kind!=node_1.NodeKind.INT32&&left.kind!=node_1.NodeKind.INT64||right.kind!=node_1.NodeKind.INT32&&right.kind!=node_1.NodeKind.INT64)if(left.kind!=node_1.NodeKind.FLOAT32&&left.kind!=node_1.NodeKind.FLOAT64||right.kind!=node_1.NodeKind.FLOAT32&&right.kind!=node_1.NodeKind.FLOAT64)simplifyBinary(node);else{var inputLeft=left.floatValue,inputRight=right.floatValue,output=0;if(kind==node_1.NodeKind.ADD)output=inputLeft+inputRight;else if(kind==node_1.NodeKind.BITWISE_AND)output=inputLeft&inputRight;else if(kind==node_1.NodeKind.BITWISE_OR)output=inputLeft|inputRight;else if(kind==node_1.NodeKind.BITWISE_XOR)output=inputLeft^inputRight;else if(kind==node_1.NodeKind.DIVIDE)output=inputLeft/inputRight;else if(kind==node_1.NodeKind.MULTIPLY)output=inputLeft*inputRight;else if(kind==node_1.NodeKind.REMAINDER)output=inputLeft%inputRight;else if(kind==node_1.NodeKind.SHIFT_LEFT)output=inputLeft<>inputRight;else{if(kind!=node_1.NodeKind.SUBTRACT)return;output=inputLeft-inputRight}left.kind==node_1.NodeKind.FLOAT32?node.becomeFloatConstant(output):node.becomeDoubleConstant(output)}else{var inputLeft=left.intValue,inputRight=right.intValue,output=0;if(kind==node_1.NodeKind.ADD)output=inputLeft+inputRight;else if(kind==node_1.NodeKind.BITWISE_AND)output=inputLeft&inputRight;else if(kind==node_1.NodeKind.BITWISE_OR)output=inputLeft|inputRight;else if(kind==node_1.NodeKind.BITWISE_XOR)output=inputLeft^inputRight;else if(kind==node_1.NodeKind.DIVIDE)output=inputLeft/inputRight;else if(kind==node_1.NodeKind.MULTIPLY)output=inputLeft*inputRight;else if(kind==node_1.NodeKind.REMAINDER)output=inputLeft%inputRight;else if(kind==node_1.NodeKind.SHIFT_LEFT)output=inputLeft<>inputRight;else{if(kind!=node_1.NodeKind.SUBTRACT)return;output=inputLeft-inputRight}left.kind==node_1.NodeKind.INT32?node.becomeIntegerConstant(output):node.becomeLongConstant(output)}}else if(kind==node_1.NodeKind.LESS_THAN||kind==node_1.NodeKind.LESS_THAN_EQUAL||kind==node_1.NodeKind.GREATER_THAN||kind==node_1.NodeKind.GREATER_THAN_EQUAL){var expectedType=isFloat?isFloat64?context.float64Type:context.float32Type:isUnsigned?context.uint32Type:context.int32Type;isUnsigned&&(node.flags=node.flags|node_1.NODE_FLAG_UNSIGNED_OPERATOR),leftType!=rightType&&(checkConversion(context,left,expectedType,type_1.ConversionKind.IMPLICIT),checkConversion(context,right,expectedType,type_1.ConversionKind.IMPLICIT)),node.resolvedType=context.booleanType}else context.log.error(node.internalRange,"This operator is not currently supported")}else if(leftType!=context.errorType){var name_5=node.internalRange.toString(),symbol=leftType.findMember(kind==node_1.NodeKind.NOT_EQUAL?"==":kind==node_1.NodeKind.LESS_THAN_EQUAL?">":kind==node_1.NodeKind.GREATER_THAN_EQUAL?"<":name_5,scope_1.ScopeHint.NOT_UNARY);if(null!=symbol){if(left=node_1.createMemberReference(left.remove(),symbol).withRange(node.range).withInternalRange(node.internalRange),right.remove(),kind==node_1.NodeKind.NOT_EQUAL||kind==node_1.NodeKind.LESS_THAN_EQUAL||kind==node_1.NodeKind.GREATER_THAN_EQUAL){var call=node_1.createCall(left);call.appendChild(right),node.kind=node_1.NodeKind.NOT,node.appendChild(call.withRange(node.range).withInternalRange(node.range))}else node.appendChild(left),node.appendChild(right),node.kind=node_1.NodeKind.CALL;node.resolvedType=null,resolveAsExpression(context,node,parentScope)}else kind==node_1.NodeKind.EQUAL||kind==node_1.NodeKind.NOT_EQUAL?(node.resolvedType=context.booleanType,leftType==context.errorType||rightType==context.errorType||leftType==rightType||canConvert(context,right,leftType,type_1.ConversionKind.IMPLICIT)||canConvert(context,left,rightType,type_1.ConversionKind.IMPLICIT)||context.log.error(node.internalRange,"Cannot compare type '"+leftType.toString()+"' with type '"+rightType.toString()+"'")):context.log.error(node.internalRange,"Cannot use binary operator '"+name_5+"' with type '"+leftType.toString()+"'")}}else node.resolvedType=context.booleanType,leftType!=rightType&&context.log.error(node.internalRange,"Cannot compare type '"+leftType.toString()+"' with type '"+rightType.toString()+"'")}else kind==node_1.NodeKind.TYPE||(terminal_1.Terminal.error("Unexpected kind: "+node_1.NodeKind[kind]),assert_1.assert(!1))}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(3),type_1=__webpack_require__(18),node_1=__webpack_require__(5),compile_target_1=__webpack_require__(4),log_1=__webpack_require__(2),scope_1=__webpack_require__(17),utils_1=__webpack_require__(6),const_1=__webpack_require__(48),assert_1=__webpack_require__(0),compiler_1=__webpack_require__(11),terminal_1=__webpack_require__(1),CheckContext=function(){function CheckContext(){}return CheckContext.prototype.allocateGlobalVariableOffset=function(sizeOf,alignmentOf){var offset=utils_1.alignToNextMultipleOf(this.nextGlobalVariableOffset,alignmentOf);return this.nextGlobalVariableOffset=offset+sizeOf,offset},CheckContext}();exports.CheckContext=CheckContext,exports.addScopeToSymbol=addScopeToSymbol,exports.linkSymbolToNode=linkSymbolToNode;var CheckMode;!function(CheckMode){CheckMode[CheckMode.NORMAL=0]="NORMAL",CheckMode[CheckMode.INITIALIZE=1]="INITIALIZE"}(CheckMode=exports.CheckMode||(exports.CheckMode={})),exports.initialize=initialize,exports.forbidFlag=forbidFlag,exports.requireFlag=requireFlag,exports.initializeSymbol=initializeSymbol,exports.resolveChildren=resolveChildren,exports.resolveChildrenAsExpressions=resolveChildrenAsExpressions,exports.resolveAsExpression=resolveAsExpression,exports.resolveAsType=resolveAsType,exports.canConvert=canConvert,exports.checkConversion=checkConversion,exports.checkStorage=checkStorage,exports.createDefaultValueForType=createDefaultValueForType,exports.simplifyBinary=simplifyBinary,exports.binaryHasUnsignedArguments=binaryHasUnsignedArguments,exports.isBinaryLong=isBinaryLong,exports.isBinaryDouble=isBinaryDouble,exports.isSymbolAccessAllowed=isSymbolAccessAllowed,exports.resolve=resolve},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var compile_target_1=__webpack_require__(4);exports.defaultCompilerOptions={target:compile_target_1.CompileTarget.WEBASSEMBLY,silent:!0,logError:!0}},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MIN_INT32_VALUE=-Math.pow(2,31),exports.MAX_INT32_VALUE=Math.pow(2,31)-1,exports.MIN_UINT32_VALUE=0,exports.MAX_UINT32_VALUE=Math.pow(2,32)-1,exports.MIN_INT64_VALUE=-Math.pow(2,63),exports.MAX_INT64_VALUE=Math.pow(2,63)-1,exports.MIN_UINT64_VALUE=0,exports.MAX_UINT64_VALUE=Math.pow(2,64)-1},function(module,exports,__webpack_require__){"use strict";function treeShakingMarkAllUsed(node){var symbol=node.symbol;if(null==symbol||symbol.isUsed()||!symbol_1.isFunction(symbol.kind)||null==symbol.node||(symbol.flags=symbol.flags|symbol_1.SYMBOL_FLAG_USED,treeShakingMarkAllUsed(symbol.node),node!=symbol.node)){if(node.kind==node_1.NodeKind.NEW){var type=node.newType().resolvedType;null!=type.symbol&&(type.symbol.flags|=symbol_1.SYMBOL_FLAG_USED,type.symbol.node.constructorFunctionNode.symbol.flags=symbol_1.SYMBOL_FLAG_USED)}for(var child=node.firstChild;null!=child;)treeShakingMarkAllUsed(child),child=child.nextSibling}}function treeShakingSearchForUsed(node){if(node.kind==node_1.NodeKind.FUNCTION&&(node.isExport()||node.isStart())){if(("malloc"===node.symbol.name||"free"===node.symbol.name)&&!compiler_1.Compiler.mallocRequired)return;treeShakingMarkAllUsed(node)}else if(node.kind==node_1.NodeKind.GLOBAL||node.kind==node_1.NodeKind.CLASS){for(var child=node.firstChild;null!=child;)treeShakingSearchForUsed(child),child=child.nextSibling;node.kind==node_1.NodeKind.CLASS&&node.isExport()&&(node.symbol.flags=node.symbol.flags|symbol_1.SYMBOL_FLAG_USED)}}function treeShakingRemoveUnused(node){if(node.kind==node_1.NodeKind.FUNCTION&&!node.symbol.isUsed()&&node.range.source.isLibrary)node.remove();else if(node.kind==node_1.NodeKind.GLOBAL||node.kind==node_1.NodeKind.CLASS){for(var child=node.firstChild;null!=child;){var next=child.nextSibling;treeShakingRemoveUnused(child),child=next}node.kind!=node_1.NodeKind.CLASS||node.symbol.isUsed()||node.isDeclare()||!node.range.source.isLibrary||node.remove()}}function treeShaking(node){treeShakingSearchForUsed(node),treeShakingRemoveUnused(node)}Object.defineProperty(exports,"__esModule",{value:!0});var symbol_1=__webpack_require__(3),node_1=__webpack_require__(5),compiler_1=__webpack_require__(11);exports.treeShakingMarkAllUsed=treeShakingMarkAllUsed,exports.treeShakingSearchForUsed=treeShakingSearchForUsed,exports.treeShakingRemoveUnused=treeShakingRemoveUnused,exports.treeShaking=treeShaking},function(module,exports,__webpack_require__){"use strict";function preparse(source,compiler,log){for(var contents=source.contents,limit=contents.length,pathSeparator=source.name.indexOf("/")>-1?"/":source.name.indexOf("\\")>-1?"\\":"/",basePath=source.name.substring(0,source.name.lastIndexOf(pathSeparator)),wantNewline=!1,captureImportFrom=!1,captureImportPath=!1,i=0;i=2&&length_1<=10){var text=contents.slice(start,i);"import"==text?captureImportFrom=!0:"from"==text&&captureImportFrom&&(captureImportFrom=!1,captureImportPath=!0)}}else if(captureImportPath&&('"'==c||"'"==c||"`"==c))for(captureImportPath=!1;i0;)this._text+=this.indentStr,i-=1},StringBuilder.prototype.appendChar=function(c){return this._text+=c,this},StringBuilder.prototype.appendSlice=function(text,start,end){return this._text+=text.slice(start,end),this},StringBuilder.prototype.breakChunk=function(){return this.chunks.push(this._text),this._text="",this.chunks.length-1},StringBuilder.prototype.appendLine=function(text,indent){return void 0===indent&&(indent=0),this.indent+=indent,this.emitIndent(),this._text+=text+"\n",this},StringBuilder.prototype.appendRaw=function(text){return this._text+=text+"\n",this},StringBuilder.prototype.append=function(text,indent){var _this=this;return void 0===indent&&(indent=0),this.indent+=indent,text.split("\n").forEach(function(line,i){i>0&&(_this._text+="\n",_this.emitIndent()),_this._text+=line}),this},StringBuilder.prototype.removeLastChar=function(){this._text=this._text.substring(0,this._text.length-1)},StringBuilder.prototype.removeLastLinebreak=function(){this._text=this._text.substring(0,this._text.lastIndexOf("\n"))},StringBuilder.prototype.finish=function(){if(this.next=stringBuilderPool,stringBuilderPool=this,this.chunks.length>0){var code_1="";return this.chunks.forEach(function(chunk){code_1+=chunk}),code_1+this._text}return this._text},StringBuilder}();exports.StringBuilder=StringBuilder},function(module,exports){module.exports=require("fs")}])}); \ No newline at end of file