var TypeScript;(function(e){function t(e,t){return(e&t)!=0}function h(e){return e}function g(e,t){var n="";for(var r=1;r<1<<31;r<<=1)if((t&r)!=0)for(var i in e)if(e[i]==r){n.length>0&&(n+="|"),n+=i;break}return n}e.hasFlag=t,function(e){e._map=[],e.None=0,e.Comma=1,e.SColon=2,e.Asg=4,e.BinOp=8,e.RBrack=16,e.RCurly=32,e.RParen=64,e.Dot=128,e.Colon=256,e.PrimType=512,e.AddOp=1024,e.LCurly=2048,e.PreOp=4096,e.RegExp=8192,e.LParen=16384,e.LBrack=32768,e.Scope=65536,e.In=1<<17,e.SCase=1<<18,e.Else=1<<19,e.Catch=1<<20,e.Var=1<<21,e.Stmt=1<<22,e.While=1<<23,e.ID=1<<24,e.Prefix=1<<25,e.Literal=1<<26,e.RLit=1<<27,e.Func=1<<28,e.EOF=1<<29,e.TypeScriptS=1<<30,e.ExprStart=e.SColon|e.AddOp|e.LCurly|e.PreOp|e.RegExp|e.LParen|e.LBrack|e.ID|e.Prefix|e.RLit|e.Func|e.Literal,e.StmtStart=e.ExprStart|e.SColon|e.Var|e.Stmt|e.While|e.TypeScriptS,e.Postfix=e.Dot|e.LParen|e.LBrack}(e.ErrorRecoverySet||(e.ErrorRecoverySet={}));var n=e.ErrorRecoverySet;(function(e){e._map=[],e.None=0,e.Statements=1,e.FunctionDecls=2,e.ModuleDecls=4,e.ClassDecls=8,e.InterfaceDecls=16,e.TypedFuncDecls=32,e.TypedDecls=64,e.TypedFuncSignatures=256,e.TypedSignatures=512,e.AmbientDecls=1024,e.Properties=2048,e.Block=e.Statements|e.FunctionDecls|e.TypedFuncDecls|e.TypedDecls,e.Global=e.Statements|e.FunctionDecls|e.ModuleDecls|e.ClassDecls|e.InterfaceDecls|e.AmbientDecls,e.FunctionBody=e.Statements|e.FunctionDecls,e.ModuleMembers=e.TypedFuncDecls|e.FunctionDecls|e.ModuleDecls|e.ClassDecls|e.InterfaceDecls|e.TypedDecls|e.Statements|e.AmbientDecls,e.ClassMembers=e.TypedFuncDecls|e.FunctionDecls|e.Statements|e.TypedDecls|e.Properties,e.InterfaceMembers=e.TypedFuncSignatures|e.TypedSignatures,e.QuickParse=e.Global|e.Properties})(e.AllowedElements||(e.AllowedElements={}));var r=e.AllowedElements;(function(e){e._map=[],e.None=0,e.Private=1,e.Public=2,e.Readonly=4,e.Ambient=8,e.Exported=16,e.Getter=32,e.Setter=64,e.Static=128})(e.Modifiers||(e.Modifiers={}));var i=e.Modifiers;(function(e){e._map=[],e.None=0,e.ExplicitSemicolon=1,e.AutomaticSemicolon=2,e.Writeable=4,e.Error=8,e.DotLHSPartial=16,e.DotLHS=32,e.IsStatement=64,e.StrictMode=128,e.PossibleOptionalParameter=256,e.ClassBaseConstructorCall=512,e.OptionalName=1024})(e.ASTFlags||(e.ASTFlags={}));var s=e.ASTFlags;(function(e){e._map=[],e.None=0,e.Exported=1,e.Private=2,e.Public=4,e.Ambient=8,e.Static=16,e.LocalStatic=32,e.GetAccessor=64,e.SetAccessor=128})(e.DeclFlags||(e.DeclFlags={}));var o=e.DeclFlags;(function(e){e._map=[],e.None=0,e.Exported=1,e.Private=2,e.Public=4,e.Ambient=8,e.Static=16,e.LocalStatic=32,e.GetAccessor=64,e.SetAccessor=128,e.IsEnum=256,e.ShouldEmitModuleDecl=512,e.IsWholeFile=1024,e.IsDynamic=2048})(e.ModuleFlags||(e.ModuleFlags={}));var u=e.ModuleFlags;(function(e){e._map=[],e.None=0,e.Exported=1,e.Private=2,e.Public=4,e.Ambient=8,e.Static=16,e.LocalStatic=32,e.GetAccessor=64,e.SetAccessor=128,e.Property=256,e.Readonly=512,e.ModuleMember=1024,e.InterfaceMember=2048,e.ClassMember=4096,e.BuiltIn=8192,e.TypeSetDuringScopeAssignment=16384,e.Constant=32768,e.Optional=65536,e.RecursivelyReferenced=1<<17,e.Bound=1<<18})(e.SymbolFlags||(e.SymbolFlags={}));var a=e.SymbolFlags;(function(e){e._map=[],e.None=0,e.Exported=1,e.Private=2,e.Public=4,e.Ambient=8,e.Static=16,e.LocalStatic=32,e.GetAccessor=64,e.SetAccessor=128,e.AutoInit=256,e.Property=512,e.Readonly=1024,e.Class=2048,e.ClassProperty=4096,e.ClassBodyProperty=8192,e.ClassConstructorProperty=16384,e.ClassSuperMustBeFirstCallInConstructor=32768,e.Constant=65536})(e.VarFlags||(e.VarFlags={}));var f=e.VarFlags;(function(e){e._map=[],e.None=0,e.Exported=1,e.Private=2,e.Public=4,e.Ambient=8,e.Static=16,e.LocalStatic=32,e.GetAccessor=64,e.SetAccessor=128,e.Definition=256,e.Signature=512,e.Method=1024,e.HasReturnExpression=2048,e.CallMember=4096,e.ConstructMember=8192,e.HasSelfReference=16384,e.IsFatArrowFunction=32768,e.IndexerMember=65536,e.IsFunctionExpression=1<<17,e.ClassMethod=1<<18,e.ClassPropertyMethodExported=1<<19})(e.FncFlags||(e.FncFlags={}));var l=e.FncFlags;(function(e){e._map=[],e.None=0,e.IsIndexer=1,e.IsStringIndexer=2,e.IsNumberIndexer=4})(e.SignatureFlags||(e.SignatureFlags={}));var c=e.SignatureFlags;e.ToDeclFlags=h,function(e){e._map=[],e.None=0,e.HasImplementation=1,e.HasSelfReference=2,e.MergeResult=4,e.IsEnum=8,e.BuildingName=16,e.HasBaseType=32,e.HasBaseTypeOfObject=64,e.IsClass=128}(e.TypeFlags||(e.TypeFlags={}));var p=e.TypeFlags;(function(e){e._map=[],e.SuccessfulComparison=0,e.SourceIsNullTargetIsVoidOrUndefined=1,e.RequiredPropertyIsMissing=2,e.IncompatibleSignatures=4,e.SourceSignatureHasTooManyParameters=3,e.IncompatibleReturnTypes=16,e.IncompatiblePropertyTypes=32,e.IncompatibleParameterTypes=64})(e.TypeRelationshipFlags||(e.TypeRelationshipFlags={}));var d=e.TypeRelationshipFlags;(function(e){e._map=[],e.ES3=0,e.ES5=1})(e.CodeGenTarget||(e.CodeGenTarget={}));var v=e.CodeGenTarget;(function(e){e._map=[],e.Synchronous=0,e.Asynchronous=1,e.Local=2})(e.ModuleGenTarget||(e.ModuleGenTarget={}));var m=e.ModuleGenTarget;e.codeGenTarget=v.ES3,e.moduleGenTarget=m.Synchronous,e.optimizeModuleCodeGen=!0,e.flagsToString=g})(TypeScript||(TypeScript={}));var TypeScript;(function(e){(function(e){e._map=[],e._map[0]="None",e.None=0,e._map[1]="Empty",e.Empty=1,e._map[2]="EmptyExpr",e.EmptyExpr=2,e._map[3]="True",e.True=3,e._map[4]="False",e.False=4,e._map[5]="This",e.This=5,e._map[6]="Super",e.Super=6,e._map[7]="QString",e.QString=7,e._map[8]="Regex",e.Regex=8,e._map[9]="Null",e.Null=9,e._map[10]="ArrayLit",e.ArrayLit=10,e._map[11]="ObjectLit",e.ObjectLit=11,e._map[12]="Void",e.Void=12,e._map[13]="Comma",e.Comma=13,e._map[14]="Pos",e.Pos=14,e._map[15]="Neg",e.Neg=15,e._map[16]="Delete",e.Delete=16,e._map[17]="Await",e.Await=17,e._map[18]="In",e.In=18,e._map[19]="Dot",e.Dot=19,e._map[20]="From",e.From=20,e._map[21]="Is",e.Is=21,e._map[22]="InstOf",e.InstOf=22,e._map[23]="Typeof",e.Typeof=23,e._map[24]="NumberLit",e.NumberLit=24,e._map[25]="Name",e.Name=25,e._map[26]="TypeRef",e.TypeRef=26,e._map[27]="Index",e.Index=27,e._map[28]="Call",e.Call=28,e._map[29]="New",e.New=29,e._map[30]="Asg",e.Asg=30,e._map[31]="AsgAdd",e.AsgAdd=31,e._map[32]="AsgSub",e.AsgSub=32,e._map[33]="AsgDiv",e.AsgDiv=33,e._map[34]="AsgMul",e.AsgMul=34,e._map[35]="AsgMod",e.AsgMod=35,e._map[36]="AsgAnd",e.AsgAnd=36,e._map[37]="AsgXor",e.AsgXor=37,e._map[38]="AsgOr",e.AsgOr=38,e._map[39]="AsgLsh",e.AsgLsh=39,e._map[40]="AsgRsh",e.AsgRsh=40,e._map[41]="AsgRs2",e.AsgRs2=41,e._map[42]="QMark",e.QMark=42,e._map[43]="LogOr",e.LogOr=43,e._map[44]="LogAnd",e.LogAnd=44,e._map[45]="Or",e.Or=45,e._map[46]="Xor",e.Xor=46,e._map[47]="And",e.And=47,e._map[48]="Eq",e.Eq=48,e._map[49]="Ne",e.Ne=49,e._map[50]="Eqv",e.Eqv=50,e._map[51]="NEqv",e.NEqv=51,e._map[52]="Lt",e.Lt=52,e._map[53]="Le",e.Le=53,e._map[54]="Gt",e.Gt=54,e._map[55]="Ge",e.Ge=55,e._map[56]="Add",e.Add=56,e._map[57]="Sub",e.Sub=57,e._map[58]="Mul",e.Mul=58,e._map[59]="Div",e.Div=59,e._map[60]="Mod",e.Mod=60,e._map[61]="Lsh",e.Lsh=61,e._map[62]="Rsh",e.Rsh=62,e._map[63]="Rs2",e.Rs2=63,e._map[64]="Not",e.Not=64,e._map[65]="LogNot",e.LogNot=65,e._map[66]="IncPre",e.IncPre=66,e._map[67]="DecPre",e.DecPre=67,e._map[68]="IncPost",e.IncPost=68,e._map[69]="DecPost",e.DecPost=69,e._map[70]="TypeAssertion",e.TypeAssertion=70,e._map[71]="FuncDecl",e.FuncDecl=71,e._map[72]="Member",e.Member=72,e._map[73]="VarDecl",e.VarDecl=73,e._map[74]="ArgDecl",e.ArgDecl=74,e._map[75]="Return",e.Return=75,e._map[76]="Break",e.Break=76,e._map[77]="Continue",e.Continue=77,e._map[78]="Throw",e.Throw=78,e._map[79]="For",e.For=79,e._map[80]="ForIn",e.ForIn=80,e._map[81]="If",e.If=81,e._map[82]="While",e.While=82,e._map[83]="DoWhile",e.DoWhile=83,e._map[84]="Block",e.Block=84,e._map[85]="Case",e.Case=85,e._map[86]="Switch",e.Switch=86,e._map[87]="Try",e.Try=87,e._map[88]="TryCatch",e.TryCatch=88,e._map[89]="TryFinally",e.TryFinally=89,e._map[90]="Finally",e.Finally=90,e._map[91]="Catch",e.Catch=91,e._map[92]="List",e.List=92,e._map[93]="Script",e.Script=93,e._map[94]="Class",e.Class=94,e._map[95]="Interface",e.Interface=95,e._map[96]="Module",e.Module=96,e._map[97]="Import",e.Import=97,e._map[98]="With",e.With=98,e._map[99]="Label",e.Label=99,e._map[100]="LabeledStatement",e.LabeledStatement=100,e._map[101]="EBStart",e.EBStart=101,e._map[102]="GotoEB",e.GotoEB=102,e._map[103]="EndCode",e.EndCode=103,e._map[104]="Error",e.Error=104,e._map[105]="Comment",e.Comment=105,e._map[106]="Debugger",e.Debugger=106,e.GeneralNode=e.FuncDecl,e.LastAsg=e.AsgRs2})(e.NodeType||(e.NodeType={}));var t=e.NodeType})(TypeScript||(TypeScript={}));var TypeScript;(function(e){function i(e){var t=668265261;return e=e^61^e>>>16,e+=e<<3,e^=e>>>4,e*=t,e^=e>>>15,e}function s(e,t){return t^(e>>5)+e}var t=function(){function e(){this.prototype=undefined,this.toString=undefined,this.toLocaleString=undefined,this.valueOf=undefined,this.hasOwnProperty=undefined,this.propertyIsEnumerable=undefined,this.isPrototypeOf=undefined,this.constructor=undefined}return e}();e.BlockIntrinsics=t;var n=function(){function e(){this.itemCount=0,this.table=new t}return e.prototype.getAllKeys=function(){var e=[];for(var t in this.table)this.table[t]!=undefined&&(e[e.length]=t);return e},e.prototype.add=function(e,t){return this.table[e]!=undefined?!1:(this.table[e]=t,this.itemCount++,!0)},e.prototype.addOrUpdate=function(e,t){return this.table[e]!=undefined?(this.table[e]=t,!1):(this.table[e]=t,this.itemCount++,!0)},e.prototype.map=function(e,t){for(var n in this.table){var r=this.table[n];r!=undefined&&e(n,this.table[n],t)}},e.prototype.every=function(e,t){for(var n in this.table){var r=this.table[n];if(r!=undefined&&!e(n,this.table[n],t))return!1}return!0},e.prototype.some=function(e,t){for(var n in this.table){var r=this.table[n];if(r!=undefined&&e(n,this.table[n],t))return!0}return!1},e.prototype.count=function(){return this.itemCount},e.prototype.lookup=function(e){var t=this.table[e];return t!=undefined?t:null},e}();e.StringHashTable=n;var r=function(){function e(e,t){this.primaryTable=e,this.secondaryTable=t,this.insertPrimary=!0}return e.prototype.getAllKeys=function(){return this.primaryTable.getAllKeys().concat(this.secondaryTable.getAllKeys())},e.prototype.add=function(e,t){return this.insertPrimary?this.primaryTable.add(e,t):this.secondaryTable.add(e,t)},e.prototype.addOrUpdate=function(e,t){return this.insertPrimary?this.primaryTable.addOrUpdate(e,t):this.secondaryTable.addOrUpdate(e,t)},e.prototype.map=function(e,t){this.primaryTable.map(e,t),this.secondaryTable.map(e,t)},e.prototype.every=function(e,t){return this.primaryTable.every(e,t)&&this.secondaryTable.every(e,t)},e.prototype.some=function(e,t){return this.primaryTable.some(e,t)||this.secondaryTable.some(e,t)},e.prototype.count=function(){return this.primaryTable.count()+this.secondaryTable.count()},e.prototype.lookup=function(e){var t=this.primaryTable.lookup(e);return t!=undefined?t:this.secondaryTable.lookup(e)},e}();e.DualStringHashTable=r,e.numberHashFn=i,e.combineHashes=s;var o=function(){function e(e,t){this.key=e,this.data=t}return e}();e.HashEntry=o;var u=function(){function e(e,t,n){this.size=e,this.hashFn=t,this.equalsFn=n,this.itemCount=0,this.table=new Array;for(var r=0;r0||this.innerStaticFuncs.length>0)},n}(t);e.FuncDecl=b;var w=function(){function e(e,t,n){this.filename=e,this.lineMap=t,this.unitIndex=n}return e}();e.LocationInfo=w,e.unknownLocationInfo=new w("unknown",null,-1);var E=function(t){function n(n,r){t.call(this,new i("script"),null,!1,null,n,r,null,e.NodeType.Script),this.locationInfo=null,this.requiresGlobal=!1,this.requiresInherits=!1,this.isResident=!1,this.isDeclareFile=!1,this.hasBeenTypeChecked=!1,this.topLevelMod=null,this.leftCurlyCount=0,this.rightCurlyCount=0,this.vars=n,this.scopes=r}return __extends(n,t),n.prototype.typeCheck=function(e){return e.typeCheckScript(this)},n.prototype.treeViewLabel=function(){return"Script"},n.prototype.emitRequired=function(){if(!this.isDeclareFile&&!this.isResident&&this.bod)for(var t=0,n=this.bod.members.length;t0&&(t.current.addSuccessor(n),t.current=n)},n.prototype.typeCheck=function(e){return e.checker.styleSettings.emptyBlocks||(this.stmts===null||this.stmts.members.length==0)&&e.checker.errorReporter.styleError(this,"empty block"),e.typeCheck(this.stmts),this},n}(k);e.Block=A;var O=function(t){function n(e){t.call(this,e),this.target=null,this.resolvedTarget=null,this.nty=e}return __extends(n,t),n.prototype.hasExplicitTarget=function(){return this.target},n.prototype.setResolvedTarget=function(t,n){return n.isLoop()?(this.resolvedTarget=n,!0):this.nty===e.NodeType.Continue?(t.reportParseError("continue statement applies only to loops"),!1):n.nodeType==e.NodeType.Switch||this.hasExplicitTarget()?(this.resolvedTarget=n,!0):(t.reportParseError("break statement with no label can apply only to a loop or switch statement"),!1)},n.prototype.addToControlFlow=function(n){t.prototype.addToControlFlow.call(this,n),n.unconditionalBranch(this.resolvedTarget,this.nty==e.NodeType.Continue)},n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this),this.nty==e.NodeType.Break?t.writeToOutput("break"):t.writeToOutput("continue"),this.hasExplicitTarget()&&t.writeToOutput(" "+this.target),t.writeToOutput(";"),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n}(k);e.Jump=O;var M=function(t){function n(n){t.call(this,e.NodeType.While),this.cond=n,this.body=null}return __extends(n,t),n.prototype.isStatementOrExpression=function(){return!0},n.prototype.isLoop=function(){return!0},n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this);var s=t.setInObjectLiteral(!1);t.writeToOutput("while("),t.emitJavascript(this.cond,e.TokenID.WHILE,!1),t.writeToOutput(")"),t.emitJavascriptStatements(this.body,!1,!1),t.setInObjectLiteral(s),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.typeCheck=function(e){return e.typeCheckWhile(this)},n.prototype.addToControlFlow=function(t){var n=t.current,r=new e.BasicBlock,i=new e.BasicBlock;n.addSuccessor(r),t.current=r,t.addContent(this.cond);var s=t.current,o=null;this.body&&(t.current=new e.BasicBlock,s.addSuccessor(t.current),t.pushStatement(this,r,i),t.walk(this.body,this),o=t.popStatement());if(!t.noContinuation){var u=t.current;u.addSuccessor(r)}t.current=i,s.addSuccessor(i),t.noContinuation=!1,t.walker.options.goChildren=!1},n}(k);e.WhileStatement=M;var _=function(t){function n(){t.call(this,e.NodeType.DoWhile),this.body=null,this.whileAST=null,this.cond=null}return __extends(n,t),n.prototype.isStatementOrExpression=function(){return!0},n.prototype.isLoop=function(){return!0},n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this);var s=t.setInObjectLiteral(!1);t.writeToOutput("do"),t.emitJavascriptStatements(this.body,!0,!1),t.recordSourceMappingStart(this.whileAST),t.writeToOutput("while"),t.recordSourceMappingEnd(this.whileAST),t.writeToOutput("("),t.emitJavascript(this.cond,e.TokenID.RParen,!1),t.writeToOutput(")"),t.setInObjectLiteral(s),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.typeCheck=function(e){return e.typeCheckDoWhile(this)},n.prototype.addToControlFlow=function(t){var n=t.current,r=new e.BasicBlock,i=new e.BasicBlock;n.addSuccessor(r),t.current=r;var s=null;this.body&&(t.pushStatement(this,r,i),t.walk(this.body,this),s=t.popStatement());if(!t.noContinuation){var o=t.current;o.addSuccessor(r),t.addContent(this.cond),t.current=i,o.addSuccessor(i)}else t.addUnreachable(this.cond);t.walker.options.goChildren=!1},n}(k);e.DoWhileStatement=_;var D=function(t){function n(n){t.call(this,e.NodeType.If),this.cond=n,this.elseBod=null}return __extends(n,t),n.prototype.isStatementOrExpression=function(){return!0},n.prototype.isCompoundStatement=function(){return!0},n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this);var s=t.setInObjectLiteral(!1);t.writeToOutput("if("),t.emitJavascript(this.cond,e.TokenID.IF,!1),t.writeToOutput(")"),t.emitJavascriptStatements(this.thenBod,!0,!1),this.elseBod&&(t.writeToOutput(" else"),t.emitJavascriptStatements(this.elseBod,!0,!0)),t.setInObjectLiteral(s),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.typeCheck=function(e){return e.typeCheckIf(this)},n.prototype.addToControlFlow=function(t){this.cond.addToControlFlow(t);var n=new e.BasicBlock,r=t.current;t.pushStatement(this,r,n);var i=!1;t.current=new e.BasicBlock,r.addSuccessor(t.current),t.walk(this.thenBod,this),t.noContinuation||(i=!0,t.current.addSuccessor(n)),this.elseBod?(t.current=new e.BasicBlock,t.noContinuation=!1,r.addSuccessor(t.current),t.walk(this.elseBod,this),t.noContinuation?i&&(t.noContinuation=!1):(i=!0,t.current.addSuccessor(n))):(r.addSuccessor(n),t.noContinuation=!1,i=!0);var s=t.popStatement();n.predecessors.length>0&&(t.noContinuation=!1,i=!0),i&&(t.current=n),t.walker.options.goChildren=!1},n}(k);e.IfStatement=D;var P=function(t){function n(){t.call(this,e.NodeType.Return),this.returnExpression=null}return __extends(n,t),n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this);var s=t.setInObjectLiteral(!1);this.returnExpression?(t.writeToOutput("return "),t.emitJavascript(this.returnExpression,e.TokenID.SColon,!1)):t.writeToOutput("return;"),t.setInObjectLiteral(s),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.addToControlFlow=function(e){t.prototype.addToControlFlow.call(this,e),e.returnStmt()},n.prototype.typeCheck=function(e){return e.typeCheckReturn(this)},n}(k);e.ReturnStatement=P;var H=function(t){function n(){t.call(this,e.NodeType.EndCode)}return __extends(n,t),n}(t);e.EndCode=H;var B=function(t){function n(n,r){t.call(this,e.NodeType.ForIn),this.lval=n,this.obj=r,this.lval&&this.lval.nodeType==e.NodeType.VarDecl&&(this.lval.varFlags|=e.VarFlags.AutoInit)}return __extends(n,t),n.prototype.isStatementOrExpression=function(){return!0},n.prototype.isLoop=function(){return!0},n.prototype.isFiltered=function(){if(this.body){var t=null;if(this.body.nodeType==e.NodeType.List){var n=this.body;n.members.length==1&&(t=n.members[0])}else t=this.body;if(t!==null){if(t.nodeType==e.NodeType.Block){var r=t;r.stmts!==null&&r.stmts.members.length==1&&(t=r.stmts.members[0])}if(t.nodeType==e.NodeType.If){var i=t.cond;if(i.nodeType==e.NodeType.Call){var s=i.target;if(s.nodeType==e.NodeType.Dot){var o=s;if(o.operand1.nodeType==e.NodeType.Name&&this.obj.nodeType==e.NodeType.Name&&o.operand1.text==this.obj.text){var u=o.operand2;if(u.text=="hasOwnProperty"){var a=i.args;if(a!==null&&a.members.length==1){var f=a.members[0];if(f.nodeType==e.NodeType.Name&&this.lval.nodeType==e.NodeType.Name&&this.lval.text==f.text)return!0}}}}}}}}return!1},n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this);var s=t.setInObjectLiteral(!1);t.writeToOutput("for("),t.emitJavascript(this.lval,e.TokenID.FOR,!1),t.writeToOutput(" in "),t.emitJavascript(this.obj,e.TokenID.FOR,!1),t.writeToOutput(")"),t.emitJavascriptStatements(this.body,!0,!1),t.setInObjectLiteral(s),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.typeCheck=function(e){return e.checker.styleSettings.forin&&(this.isFiltered()||e.checker.errorReporter.styleError(this,"no hasOwnProperty filter")),e.typeCheckForIn(this)},n.prototype.addToControlFlow=function(t){this.lval&&t.addContent(this.lval),this.obj&&t.addContent(this.obj);var n=t.current,r=new e.BasicBlock,i=new e.BasicBlock;n.addSuccessor(r),t.current=r,this.body&&(t.pushStatement(this,r,i),t.walk(this.body,this),t.popStatement());if(!t.noContinuation){var s=t.current;s.addSuccessor(r)}t.current=i,t.noContinuation=!1,n.addSuccessor(i),t.walker.options.goChildren=!1},n}(k);e.ForInStatement=B;var j=function(t){function n(n){t.call(this,e.NodeType.For),this.init=n}return __extends(n,t),n.prototype.isStatementOrExpression=function(){return!0},n.prototype.isLoop=function(){return!0},n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this);var s=t.setInObjectLiteral(!1);t.writeToOutput("for("),this.init&&(this.init.nodeType!=e.NodeType.List?t.emitJavascript(this.init,e.TokenID.FOR,!1):t.emitForVarList(this.init)),t.writeToOutput("; "),t.emitJavascript(this.cond,e.TokenID.FOR,!1),t.writeToOutput("; "),t.emitJavascript(this.incr,e.TokenID.FOR,!1),t.writeToOutput(")"),t.emitJavascriptStatements(this.body,!0,!1),t.setInObjectLiteral(s),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.typeCheck=function(e){return e.typeCheckFor(this)},n.prototype.addToControlFlow=function(t){this.init&&t.addContent(this.init);var n=t.current,r=new e.BasicBlock,i=new e.BasicBlock;n.addSuccessor(r),t.current=r;var s=null,o=r,u=null;this.incr&&(u=new e.BasicBlock,o=u),this.cond&&(s=t.current,t.addContent(this.cond),t.current=new e.BasicBlock,s.addSuccessor(t.current));var a=null;this.body&&(t.pushStatement(this,o,i),t.walk(this.body,this),a=t.popStatement()),this.incr&&(t.noContinuation?u.predecessors.length==0&&t.addUnreachable(this.incr):(t.current.addSuccessor(u),t.current=u,t.addContent(this.incr)));var f=t.current;t.noContinuation||f.addSuccessor(r),s&&(s.addSuccessor(i),t.noContinuation=!1),i.predecessors.length>0&&(t.noContinuation=!1,t.current=i),t.walker.options.goChildren=!1},n}(k);e.ForStatement=j;var F=function(t){function n(n){t.call(this,e.NodeType.With),this.expr=n,this.withSym=null}return __extends(n,t),n.prototype.isStatementOrExpression=function(){return!0},n.prototype.isCompoundStatement=function(){return!0},n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this),t.writeToOutput("with ("),this.expr&&t.emitJavascript(this.expr,e.TokenID.WITH,!1),t.writeToOutput(")"),t.emitJavascriptStatements(this.body,!0,!1),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.typeCheck=function(e){return e.typeCheckWith(this)},n}(k);e.WithStatement=F;var I=function(t){function n(n){t.call(this,e.NodeType.Switch),this.val=n,this.defaultCase=null}return __extends(n,t),n.prototype.isStatementOrExpression=function(){return!0},n.prototype.isCompoundStatement=function(){return!0},n.prototype.emit=function(t,n,r){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this);var i=t.setInObjectLiteral(!1);t.writeToOutput("switch("),t.emitJavascript(this.val,e.TokenID.ID,!1),t.writeLineToOutput(") {"),t.increaseIndent();var s=this.caseList.members.length;for(var o=0;o0?(t.noContinuation=!1,t.current=i):t.noContinuation=!0,t.walker.options.goChildren=!1},n}(k);e.SwitchStatement=I;var q=function(t){function n(){t.call(this,e.NodeType.Case),this.expr=null}return __extends(n,t),n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this),this.expr?(t.writeToOutput("case "),t.emitJavascript(this.expr,e.TokenID.ID,!1)):t.writeToOutput("default"),t.writeToOutput(":"),t.emitJavascriptStatements(this.body,!1,!1),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.typeCheck=function(e){return this.expr=e.typeCheck(this.expr),e.typeCheck(this.body),this.type=e.voidType,this},n.prototype.addToControlFlow=function(t){var n=new e.BasicBlock,r=t.currentSwitch[t.currentSwitch.length-1];if(this.expr){var i=new e.BasicBlock;t.current=i,r.addSuccessor(i),t.addContent(this.expr),i.addSuccessor(n)}else r.addSuccessor(n);t.current=n,this.body&&t.walk(this.body,this),t.noContinuation=!1,t.walker.options.goChildren=!1},n}(k);e.CaseStatement=q;var R=function(t){function n(n,r){t.call(this,e.NodeType.TypeRef),this.term=n,this.arrayCount=r}return __extends(n,t),n.prototype.emit=function(e,t,n,r){throw new Error("should not emit a type ref")},n.prototype.typeCheck=function(t){var n=t.inTypeRefTypeCheck;t.inTypeRefTypeCheck=!0;var r=e.getTypeLink(this,t.checker,!0);return t.checker.resolveTypeLink(t.scope,r,!1),t.checkForVoidConstructor(r.type,this),this.type=r.type,this.term&&(this.term.type=this.type),t.inTypeRefTypeCheck=n,this},n}(t);e.TypeReference=R;var U=function(t){function n(n,r){t.call(this,e.NodeType.TryFinally),this.tryNode=n,this.finallyNode=r}return __extends(n,t),n.prototype.isStatementOrExpression=function(){return!0},n.prototype.isCompoundStatement=function(){return!0},n.prototype.emit=function(t,n,r){t.recordSourceMappingStart(this),t.emitJavascript(this.tryNode,e.TokenID.TRY,!1),t.emitJavascript(this.finallyNode,e.TokenID.FINALLY,!1),t.recordSourceMappingEnd(this)},n.prototype.typeCheck=function(e){return this.tryNode=e.typeCheck(this.tryNode),this.finallyNode=e.typeCheck(this.finallyNode),this.type=e.voidType,this},n.prototype.addToControlFlow=function(t){var n=new e.BasicBlock;t.walk(this.tryNode,this);var r=new e.BasicBlock;t.current&&t.current.addSuccessor(r),t.current=r,t.pushStatement(this,null,n),t.walk(this.finallyNode,this),!t.noContinuation&&t.current&&t.current.addSuccessor(n),n.predecessors.length>0?t.current=n:t.noContinuation=!0,t.popStatement(),t.walker.options.goChildren=!1},n}(k);e.TryFinally=U;var z=function(t){function n(n,r){t.call(this,e.NodeType.TryCatch),this.tryNode=n,this.catchNode=r}return __extends(n,t),n.prototype.isStatementOrExpression=function(){return!0},n.prototype.isCompoundStatement=function(){return!0},n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this),t.emitJavascript(this.tryNode,e.TokenID.TRY,!1),t.emitJavascript(this.catchNode,e.TokenID.CATCH,!1),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.addToControlFlow=function(t){var n=t.current,r=new e.BasicBlock;n.addSuccessor(r),t.current=r;var i=new e.BasicBlock;t.pushStatement(this,null,i),t.walk(this.tryNode,this),t.noContinuation||t.current&&t.current.addSuccessor(i),t.current=new e.BasicBlock,n.addSuccessor(t.current),t.walk(this.catchNode,this),t.popStatement(),t.noContinuation||t.current&&t.current.addSuccessor(i),t.current=i,t.walker.options.goChildren=!1},n.prototype.typeCheck=function(e){return this.tryNode=e.typeCheck(this.tryNode),this.catchNode=e.typeCheck(this.catchNode),this.type=e.voidType,this},n}(k);e.TryCatch=z;var W=function(t){function n(n){t.call(this,e.NodeType.Try),this.body=n}return __extends(n,t),n.prototype.isStatementOrExpression=function(){return!0},n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this),t.writeToOutput("try "),t.emitJavascript(this.body,e.TokenID.TRY,!1),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.typeCheck=function(e){return this.body=e.typeCheck(this.body),this},n.prototype.addToControlFlow=function(e){this.body&&e.walk(this.body,this),e.walker.options.goChildren=!1,e.noContinuation=!1},n}(k);e.Try=W;var X=function(t){function n(n,r){t.call(this,e.NodeType.Catch),this.param=n,this.body=r,this.containedScope=null,this.param&&(this.param.varFlags|=e.VarFlags.AutoInit)}return __extends(n,t),n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this),t.writeToOutput(" catch ("),t.emitJavascript(this.param,e.TokenID.LParen,!1),t.writeToOutput(")"),t.emitJavascript(this.body,e.TokenID.CATCH,!1),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.addToControlFlow=function(t){if(this.param){t.addContent(this.param);var n=new e.BasicBlock;t.current.addSuccessor(n),t.current=n}this.body&&t.walk(this.body,this),t.noContinuation=!1,t.walker.options.goChildren=!1},n.prototype.typeCheck=function(t){var n=t.scope;t.scope=this.containedScope,this.param=t.typeCheck(this.param);var r=new e.ValueLocation,i=new e.VariableSymbol(this.param.id.text,this.param.minChar,t.checker.locationInfo.unitIndex,r);r.symbol=i,r.typeLink=new e.TypeLink,r.typeLink.type=t.anyType;var s=t.thisFnc;s&&s.type?r.symbol.container=s.type.symbol:r.symbol.container=null,this.param.sym=r.symbol,t.scope.enter(r.symbol.container,this.param,r.symbol,t.checker.errorReporter,!1,!1,!1),this.body=t.typeCheck(this.body);if(t.checker.inProvisionalTypecheckMode()){var o=t.scope.getTable();o.secondaryTable.table[r.symbol.name]=undefined}return this.type=t.voidType,t.scope=n,this},n}(k);e.Catch=X;var V=function(t){function n(n){t.call(this,e.NodeType.Finally),this.body=n}return __extends(n,t),n.prototype.emit=function(t,n,r,i){t.emitParensAndCommentsInPlace(this,!0),t.recordSourceMappingStart(this),t.writeToOutput("finally"),t.emitJavascript(this.body,e.TokenID.FINALLY,!1),t.recordSourceMappingEnd(this),t.emitParensAndCommentsInPlace(this,!1)},n.prototype.addToControlFlow=function(e){this.body&&e.walk(this.body,this),e.walker.options.goChildren=!1,e.noContinuation=!1},n.prototype.typeCheck=function(e){return this.body=e.typeCheck(this.body),this},n}(k);e.Finally=V;var $=function(t){function n(n,r,i){t.call(this,e.NodeType.Comment),this.content=n,this.isBlockComment=r,this.endsLine=i,this.text=null}return __extends(n,t),n.prototype.getText=function(){if(this.text==null)if(this.isBlockComment){this.text=this.content.split("\n");for(var e=0;e=0;i--)n.options.goNextSibling&&(e.members[i]=n.walk(e.members[i],e));else for(var i=0;i0&&n.options.goNextSibling&&(e.args=n.walk(e.args,e)),e.returnTypeAnnotation&&n.options.goNextSibling&&(e.returnTypeAnnotation=n.walk(e.returnTypeAnnotation,e)),e.bod&&e.bod.members.length>0&&n.options.goNextSibling&&(e.bod=n.walk(e.bod,e))}function f(e,t,n){e.id&&(e.id=n.walk(e.id,e)),e.init&&(e.init=n.walk(e.init,e)),e.typeExpr&&n.options.goNextSibling&&(e.typeExpr=n.walk(e.typeExpr,e))}function l(e,t,n){e.returnExpression&&(e.returnExpression=n.walk(e.returnExpression,e))}function c(e,t,n){e.init&&(e.init=n.walk(e.init,e)),e.cond&&n.options.goNextSibling&&(e.cond=n.walk(e.cond,e)),e.incr&&n.options.goNextSibling&&(e.incr=n.walk(e.incr,e)),e.body&&n.options.goNextSibling&&(e.body=n.walk(e.body,e))}function h(e,t,n){e.lval=n.walk(e.lval,e),n.options.goNextSibling&&(e.obj=n.walk(e.obj,e)),e.body&&n.options.goNextSibling&&(e.body=n.walk(e.body,e))}function p(e,t,n){e.cond=n.walk(e.cond,e),e.thenBod&&n.options.goNextSibling&&(e.thenBod=n.walk(e.thenBod,e)),e.elseBod&&n.options.goNextSibling&&(e.elseBod=n.walk(e.elseBod,e))}function d(e,t,n){e.cond=n.walk(e.cond,e),e.body&&n.options.goNextSibling&&(e.body=n.walk(e.body,e))}function v(e,t,n){e.cond=n.walk(e.cond,e),e.body&&n.options.goNextSibling&&(e.body=n.walk(e.body,e))}function m(e,t,n){e.stmts&&(e.stmts=n.walk(e.stmts,e))}function g(e,t,n){e.expr&&(e.expr=n.walk(e.expr,e)),e.body&&n.options.goNextSibling&&(e.body=n.walk(e.body,e))}function y(e,t,n){e.val&&(e.val=n.walk(e.val,e)),e.caseList&&n.options.goNextSibling&&(e.caseList=n.walk(e.caseList,e))}function b(e,t,n){e.body&&(e.body=n.walk(e.body,e))}function w(e,t,n){e.tryNode&&(e.tryNode=n.walk(e.tryNode,e)),e.catchNode&&n.options.goNextSibling&&(e.catchNode=n.walk(e.catchNode,e))}function E(e,t,n){e.tryNode&&(e.tryNode=n.walk(e.tryNode,e)),e.finallyNode&&n.options.goNextSibling&&(e.finallyNode=n.walk(e.finallyNode,e))}function S(e,t,n){e.body&&(e.body=n.walk(e.body,e))}function x(e,t,n){e.param&&(e.param=n.walk(e.param,e)),e.body&&n.options.goNextSibling&&(e.body=n.walk(e.body,e))}function T(e,t,n){e.name=n.walk(e.name,e),n.options.goNextSibling&&e.members&&(e.members=n.walk(e.members,e))}function N(e,t,n){T(e,t,n)}function C(e,t,n){N(e,t,n),n.options.goNextSibling&&e.baseClass&&(e.baseClass=n.walk(e.baseClass,e)),n.options.goNextSibling&&e.implementsList&&(e.implementsList=n.walk(e.implementsList,e))}function k(e,t,n){e.bod&&(e.bod=n.walk(e.bod,e))}function L(e,t,n){N(e,t,n),n.options.goNextSibling&&e.extendsList&&(e.extendsList=n.walk(e.extendsList,e)),n.options.goNextSibling&&e.implementsList&&(e.implementsList=n.walk(e.implementsList,e))}function A(e,t,n){T(e,t,n),n.options.goNextSibling&&e.alias&&(e.alias=n.walk(e.alias,e))}function O(e,t,n){e.id&&(e.id=n.walk(e.id,e)),e.alias&&(e.alias=n.walk(e.alias,e))}function M(e,t,n){e.expr&&(e.expr=n.walk(e.expr,e)),e.body&&n.options.goNextSibling&&(e.body=n.walk(e.body,e))}function _(e,t,n){}function D(e,t,n){e.labels=n.walk(e.labels,e),n.options.goNextSibling&&(e.stmt=n.walk(e.stmt,e))}e.walkNone=t,e.walkListChildren=n,e.walkUnaryExpressionChildren=r,e.walkBinaryExpressionChildren=i,e.walkTypeReferenceChildren=s,e.walkCallExpressionChildren=o,e.walkTrinaryExpressionChildren=u,e.walkFuncDeclChildren=a,e.walkBoundDeclChildren=f,e.walkReturnStatementChildren=l,e.walkForStatementChildren=c,e.walkForInStatementChildren=h,e.walkIfStatementChildren=p,e.walkWhileStatementChildren=d,e.walkDoWhileStatementChildren=v,e.walkBlockChildren=m,e.walkCaseStatementChildren=g,e.walkSwitchStatementChildren=y,e.walkTryChildren=b,e.walkTryCatchChildren=w,e.walkTryFinallyChildren=E,e.walkFinallyChildren=S,e.walkCatchChildren=x,e.walkRecordChildren=T,e.walkNamedTypeChildren=N,e.walkClassDeclChildren=C,e.walkScriptChildren=k,e.walkTypeDeclChildren=L,e.walkModuleDeclChildren=A,e.walkImportDeclChildren=O,e.walkWithStatementChildren=M,e.walkLabelChildren=_,e.walkLabeledStatementChildren=D})(o||(o={}))})(TypeScript||(TypeScript={}));var TypeScript;(function(e){function t(e){return e===null||e.length===0?null:e[e.length-1]}function n(e,t){return e>=t?e:t}function r(e,t){return e<=t?e:t}function s(e){return e===null?!1:e.minChar===-1||e.limChar===-1?!1:!0}function a(t,n,r){typeof r=="undefined"&&(r=u.Default);var i=function(e){if(e&&e.length>0)for(var t=0;t=r&&n=h&&n=d.minChar&&o.limChar<=d.limChar)&&f.path.push(o)}n=h&&i(o.postComments),e.hasFlag(r,u.DontPruneSearchBasedOnPosition)||(l.options.goChildren=h<=n&&n<=p)}return o},f=new o;return e.getAstWalkerFactory().walk(t,a,null,null,f),f.path}function f(t,r){var i=0,s=function(t,s,o){if(e.isValidAstNode(t)){t.minChar<=r&&(i=n(i,t.minChar));if(t.minChar>r||t.limCharthis.count())this.asts.pop();return e},n.prototype.push=function(e){while(this.asts.length>this.count())this.asts.pop();this.top=this.asts.length,this.asts.push(e)},n.prototype.up=function(){if(this.top<=-1)throw new Error("Invalid call to 'up'");this.top--},n.prototype.down=function(){if(this.top==this.ast.length-1)throw new Error("Invalid call to 'down'");this.top++},n.prototype.nodeType=function(){return this.ast()==null?e.NodeType.None:this.ast().nodeType},n.prototype.ast=function(){return n.reverseIndexOf(this.asts,this.asts.length-(this.top+1))},n.prototype.parent=function(){return n.reverseIndexOf(this.asts,this.asts.length-this.top)},n.prototype.count=function(){return this.top+1},n.prototype.get=function(e){return this.asts[e]},n.prototype.isNameOfClass=function(){return this.ast()===null||this.parent()===null?!1:this.ast().nodeType===e.NodeType.Name&&this.parent().nodeType===e.NodeType.Class&&this.parent().name===this.ast()},n.prototype.isNameOfInterface=function(){return this.ast()===null||this.parent()===null?!1:this.ast().nodeType===e.NodeType.Name&&this.parent().nodeType===e.NodeType.Interface&&this.parent().name===this.ast()},n.prototype.isNameOfArgument=function(){return this.ast()===null||this.parent()===null?!1:this.ast().nodeType===e.NodeType.Name&&this.parent().nodeType===e.NodeType.ArgDecl&&this.parent().id===this.ast()},n.prototype.isNameOfVariable=function(){return this.ast()===null||this.parent()===null?!1:this.ast().nodeType===e.NodeType.Name&&this.parent().nodeType===e.NodeType.VarDecl&&this.parent().id===this.ast()},n.prototype.isNameOfModule=function(){return this.ast()===null||this.parent()===null?!1:this.ast().nodeType===e.NodeType.Name&&this.parent().nodeType===e.NodeType.Module&&this.parent().name===this.ast()},n.prototype.isNameOfFunction=function(){return this.ast()===null||this.parent()===null?!1:this.ast().nodeType===e.NodeType.Name&&this.parent().nodeType===e.NodeType.FuncDecl&&this.parent().name===this.ast()},n.prototype.isChildOfScript=function(){var n=t(this.asts);return this.count()>=3&&this.asts[this.top]===n&&this.asts[this.top-1].nodeType===e.NodeType.List&&this.asts[this.top-2].nodeType===e.NodeType.Script},n.prototype.isChildOfModule=function(){var n=t(this.asts);return this.count()>=3&&this.asts[this.top]===n&&this.asts[this.top-1].nodeType===e.NodeType.List&&this.asts[this.top-2].nodeType===e.NodeType.Module},n.prototype.isChildOfClass=function(){var n=t(this.asts);return this.count()>=3&&this.asts[this.top]===n&&this.asts[this.top-1].nodeType===e.NodeType.List&&this.asts[this.top-2].nodeType===e.NodeType.Class},n.prototype.isArgumentOfClassConstructor=function(){var n=t(this.asts);return this.count()>=5&&this.asts[this.top]===n&&this.asts[this.top-1].nodeType===e.NodeType.List&&this.asts[this.top-2].nodeType===e.NodeType.FuncDecl&&this.asts[this.top-3].nodeType===e.NodeType.List&&this.asts[this.top-4].nodeType===e.NodeType.Class&&this.asts[this.top-2].isConstructor&&this.asts[this.top-2].args===this.asts[this.top-1]&&this.asts[this.top-4].constructorDecl===this.asts[this.top-2]},n.prototype.isChildOfInterface=function(){var n=t(this.asts);return this.count()>=3&&this.asts[this.top]===n&&this.asts[this.top-1].nodeType===e.NodeType.List&&this.asts[this.top-2].nodeType===e.NodeType.Interface},n.prototype.isTopLevelImplicitModule=function(){return this.count()>=1&&this.asts[this.top].nodeType===e.NodeType.Module&&e.hasFlag(this.asts[this.top].modFlags,e.ModuleFlags.IsWholeFile)},n.prototype.isBodyOfTopLevelImplicitModule=function(){return this.count()>=2&&this.asts[this.top-0].nodeType===e.NodeType.List&&this.asts[this.top-1].nodeType===e.NodeType.Module&&this.asts[this.top-1].members==this.asts[this.top-0]&&e.hasFlag(this.asts[this.top-1].modFlags,e.ModuleFlags.IsWholeFile)},n.prototype.isBodyOfScript=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Script&&this.asts[this.top-1].bod==this.asts[this.top-0]},n.prototype.isBodyOfSwitch=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Switch&&this.asts[this.top-1].caseList==this.asts[this.top-0]},n.prototype.isBodyOfModule=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Module&&this.asts[this.top-1].members==this.asts[this.top-0]},n.prototype.isBodyOfClass=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Class&&this.asts[this.top-1].members==this.asts[this.top-0]},n.prototype.isBodyOfFunction=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.FuncDecl&&this.asts[this.top-1].bod==this.asts[this.top-0]},n.prototype.isBodyOfInterface=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Interface&&this.asts[this.top-1].members==this.asts[this.top-0]},n.prototype.isBodyOfBlock=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Block&&this.asts[this.top-1].stmts==this.asts[this.top-0]},n.prototype.isBodyOfFor=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.For&&this.asts[this.top-1].body==this.asts[this.top-0]},n.prototype.isBodyOfCase=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Case&&this.asts[this.top-1].body==this.asts[this.top-0]},n.prototype.isBodyOfTry=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Try&&this.asts[this.top-1].body==this.asts[this.top-0]},n.prototype.isBodyOfCatch=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Catch&&this.asts[this.top-1].body==this.asts[this.top-0]},n.prototype.isBodyOfDoWhile=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.DoWhile&&this.asts[this.top-1].body==this.asts[this.top-0]},n.prototype.isBodyOfWhile=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.While&&this.asts[this.top-1].body==this.asts[this.top-0]},n.prototype.isBodyOfForIn=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.ForIn&&this.asts[this.top-1].body==this.asts[this.top-0]},n.prototype.isBodyOfWith=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.With&&this.asts[this.top-1].body==this.asts[this.top-0]},n.prototype.isBodyOfFinally=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Finally&&this.asts[this.top-1].body==this.asts[this.top-0]},n.prototype.isCaseOfSwitch=function(){return this.count()>=3&&this.asts[this.top-2].nodeType===e.NodeType.Switch&&this.asts[this.top-1].nodeType===e.NodeType.List&&this.asts[this.top-2].caseList==this.asts[this.top-1]},n.prototype.isDefaultCaseOfSwitch=function(){return this.count()>=3&&this.asts[this.top-2].nodeType===e.NodeType.Switch&&this.asts[this.top-1].nodeType===e.NodeType.List&&this.asts[this.top-2].caseList==this.asts[this.top-1]&&this.asts[this.top-2].defaultCase==this.asts[this.top-0]},n.prototype.isListOfObjectLit=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.ObjectLit&&this.asts[this.top-0].nodeType===e.NodeType.List&&this.asts[this.top-1].operand==this.asts[this.top-0]},n.prototype.isBodyOfObjectLit=function(){return this.isListOfObjectLit()},n.prototype.isEmptyListOfObjectLit=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.ObjectLit&&this.asts[this.top-0].nodeType===e.NodeType.List&&this.asts[this.top-1].operand==this.asts[this.top-0]&&this.asts[this.top-0].members.length==0},n.prototype.isMemberOfObjectLit=function(){return this.count()>=3&&this.asts[this.top-2].nodeType===e.NodeType.ObjectLit&&this.asts[this.top-1].nodeType===e.NodeType.List&&this.asts[this.top-0].nodeType===e.NodeType.Member&&this.asts[this.top-2].operand==this.asts[this.top-1]},n.prototype.isNameOfMemberOfObjectLit=function(){return this.count()>=4&&this.asts[this.top-3].nodeType===e.NodeType.ObjectLit&&this.asts[this.top-2].nodeType===e.NodeType.List&&this.asts[this.top-1].nodeType===e.NodeType.Member&&this.asts[this.top-0].nodeType===e.NodeType.Name&&this.asts[this.top-3].operand==this.asts[this.top-2]},n.prototype.isListOfArrayLit=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.ArrayLit&&this.asts[this.top-0].nodeType===e.NodeType.List&&this.asts[this.top-1].operand==this.asts[this.top-0]},n.prototype.isTargetOfMember=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Member&&this.asts[this.top-1].operand1===this.asts[this.top-0]},n.prototype.isMemberOfMember=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.Member&&this.asts[this.top-1].operand2===this.asts[this.top-0]},n.prototype.isItemOfList=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.List},n.prototype.isThenOfIf=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.If&&this.asts[this.top-1].thenBod==this.asts[this.top-0]},n.prototype.isElseOfIf=function(){return this.count()>=2&&this.asts[this.top-1].nodeType===e.NodeType.If&&this.asts[this.top-1].elseBod==this.asts[this.top-0]},n.prototype.isBodyOfDefaultCase=function(){return this.isBodyOfCase()},n.prototype.isSingleStatementList=function(){return this.count()>=1&&this.asts[this.top].nodeType===e.NodeType.List&&this.asts[this.top].members.length===1},n.prototype.isArgumentListOfFunction=function(){return this.count()>=2&&this.asts[this.top-0].nodeType===e.NodeType.List&&this.asts[this.top-1].nodeType===e.NodeType.FuncDecl&&this.asts[this.top-1].args===this.asts[this.top-0]},n.prototype.isArgumentOfFunction=function(){return this.count()>=3&&this.asts[this.top-1].nodeType===e.NodeType.List&&this.asts[this.top-2].nodeType===e.NodeType.FuncDecl&&this.asts[this.top-2].args===this.asts[this.top-1]},n.prototype.isArgumentListOfCall=function(){return this.count()>=2&&this.asts[this.top-0].nodeType===e.NodeType.List&&this.asts[this.top-1].nodeType===e.NodeType.Call&&this.asts[this.top-1].args===this.asts[this.top-0]},n.prototype.isArgumentListOfNew=function(){return this.count()>=2&&this.asts[this.top-0].nodeType===e.NodeType.List&&this.asts[this.top-1].nodeType===e.NodeType.New&&this.asts[this.top-1].args===this.asts[this.top-0]},n.prototype.isSynthesizedBlock=function(){return this.count()>=1&&this.asts[this.top-0].nodeType===e.NodeType.Block&&this.asts[this.top-0].visible===!1},n}();e.AstPath=i,e.isValidAstNode=s;var o=function(){function t(){this.path=new e.AstPath}return t}();e.AstPathContext=o,function(e){e._map=[],e.Default=0,e.EdgeInclusive=1,e.DontPruneSearchBasedOnPosition=2}(e.GetAstPathOptions||(e.GetAstPathOptions={}));var u=e.GetAstPathOptions;e.getAstPathToPosition=a,e.getTokenizationOffset=f,e.walkAST=l})(TypeScript||(TypeScript={}));var TypeScript;(function(e){var t=function(){function t(e){this.logger=e}return t.prototype.logScript=function(t){var n=this;this.logLinemap(t.locationInfo.lineMap);var r=[],i=function(e,i){r.push(e);var s=(r.length-1)*2;return n.logComments(t,e.preComments,s),n.logNode(t,e,s),n.logComments(t,e.postComments,s),e},s=function(e,t){return r.pop(),e};e.getAstWalkerFactory().walk(t,i,s)},t.prototype.logNode=function(e,t,n){var r=this.addPadding("",n,"| ",!0);r=r.concat("+ "+t.treeViewLabel()),r=this.addPadding(r,70," ",!1),r+=this.addLineColumn(e,t.minChar),r=this.addPadding(r,80," ",!1),r+="=> ",r+=this.addLineColumn(e,t.limChar),r=this.addPadding(r,102," ",!1),r=r.concat("["+this.addPadding(t.minChar.toString(),1," ",!0)+", "+this.addPadding(t.limChar.toString(),1," ",!0)+"]"),r=this.addPadding(r,115," ",!1),r=r.concat("sym="+t.sym),r=this.addPadding(r,135," ",!1),r=r.concat("type="+(t.type===null?"null":t.type.getTypeName())),this.logger.log(r)},t.prototype.logComments=function(e,t,n){if(t==null)return;for(var r=0;r0&&(t+=","),t+=e[n];t+="]",this.logger.log("linemap: "+t)},t.prototype.addPadding=function(e,t,n,r){var i=r?"":e;for(var s=e.length;s=0&&n.unitIndex>=5,n>0&&(i|=32),r+=t.encode(i)}while(n>0);return r},e.decode=function(n){var r=0,i=!1,s=0;for(var o=0;o>1&15):r|=(u&31)<1||e.endsLine){this.writeLineToOutput("");for(var r=1;r0&&(this.writeToOutput(", "),this.emitJavascriptList(a,", ",e.TokenID.Comma,!1,!1,!1)),this.writeToOutput(")")}else s.type&&s.type.isClassInstance()&&(this.emitIndent(),this.writeToOutput(n.name.text+"._super.constructor"),this.writeToOutput(".call(this)"))}this.recordSourceMappingEnd(n)},r.prototype.emitInnerFunction=function(n,r,i,s,o,u,a,f){typeof a=="undefined"&&(a=!1),typeof f=="undefined"&&(f=this.emitState.container);var l=n.isConstructor&&e.hasFlag(n.fncFlags,e.FncFlags.ClassMethod),c=l&&e.hasFlag(this.thisClassNode.type.instanceType.typeFlags,e.TypeFlags.HasBaseType)&&!e.hasFlag(this.thisClassNode.type.instanceType.typeFlags,e.TypeFlags.HasBaseTypeOfObject),h=c&&e.hasFlag(this.thisClassNode.varFlags,e.VarFlags.ClassSuperMustBeFirstCallInConstructor);this.emitParensAndCommentsInPlace(n,!0),this.recordSourceMappingStart(n),(!n.isAccessor()||!n.accessorSymbol.isObjectLitField)&&this.writeToOutput("function ");if(r){var p=n.getNameText();p&&!n.isAccessor()&&this.writeToOutput(p)}this.writeToOutput("("),a&&(a=this.emitFuncSignatureIdentifier(n,!1,f));var d=0,v=0,m,g=[];if(n.args){var y=this.setContainer(t.Args);d=n.args.members.length;var b=d;n.variableArgList&&b--;for(v=0;v1)return!1}else if(t.type.call.signatures.length>1)return!1;if(!this.canEmitSignature(e.ToDeclFlags(t.fncFlags),r))return!1;if(t.isConstructor)this.emitIndentToDeclFile(),this.declFile.Write("constructor ");else{var i=t.getNameText();n?(this.emitIndentToDeclFile(),t.isConstructMember()?this.declFile.Write("new"):!t.isCallMember()&&!t.isIndexerMember()&&(this.declFile.Write(i),e.hasFlag(t.name.flags,e.ASTFlags.OptionalName)&&this.declFile.Write("? "))):(this.emitDeclFlags(e.ToDeclFlags(t.fncFlags),"function"),this.declFile.Write(i))}return t.isIndexerMember()?this.declFile.Write("["):this.declFile.Write("("),!0},r.prototype.emitFuncSignatureVariableArg=function(e){if(e.variableArgList){var t=e.args.members[e.args.members.length-1];e.args.members.length>1?this.declFile.Write(", ..."):this.declFile.Write("..."),this.emitArgDecl(t)}e.isIndexerMember()?this.declFile.Write("]"):this.declFile.Write(")"),!e.isConstructor&&(e.returnTypeAnnotation||e.signature.returnType.type!=this.checker.anyType)&&this.canEmitTypeAnnotationSignature(e.signature.returnType.type)&&this.declFile.Write(": "+this.getTypeSignature(e.signature.returnType.type)),e.hasStaticDeclarations()?this.declFile.WriteLine(" {"):this.declFile.WriteLine(";")},r.prototype.emitFuncSignature=function(e,t){typeof t=="undefined"&&(t=!1);var n=this.emitFuncSignatureIdentifier(e,t);if(n){if(e.args){var r=e.args.members.length;e.variableArgList&&r--;for(var i=0;i0){this.declFile.Write(" "+t+" ");var n=e.members.length;for(var r=0;r0&&this.declFile.Write(", "),this.declFile.Write(u)}}},r.prototype.emitClassSignatureIdentifierAndHeritage=function(t){if(!this.canEmitSignature(e.ToDeclFlags(t.varFlags)))return!1;var n=t.name.text;return this.emitDeclFlags(e.ToDeclFlags(t.varFlags),"class"),this.declFile.Write(n),this.emitBaseList(t.baseClass,"extends"),this.emitBaseList(t.implementsList,"implements"),this.declFile.WriteLine(" {"),!0},r.prototype.emitClassSignatureClassBodyOfAmbientClass=function(t){var n=t.definitionMembers.members.length;for(var r=0;r0);if(n||i){var s=t.nodeType==e.NodeType.Block||t.nodeType==e.NodeType.List&&t.members.length==1&&t.members[0].nodeType==e.NodeType.Block;this.recordSourceMappingStart(t),s||(this.writeLineToOutput(" {"),this.increaseIndent()),this.emitJavascriptList(t,null,e.TokenID.SColon,!0,!1,!1),s||(this.writeLineToOutput(""),this.decreaseIndent(),this.emitIndent(),this.writeToOutput("}")),this.recordSourceMappingEnd(t)}}else this.emitJavascript(t,e.TokenID.SColon,!0);else n&&this.writeToOutput("{ }")},r.prototype.emitBareJavascriptStatements=function(t,n){if(t.nodeType!=e.NodeType.Block)if(t.nodeType==e.NodeType.List){var r=t;r.members.length==2&&r.members[0].nodeType==e.NodeType.Block&&r.members[1].nodeType==e.NodeType.EndCode?(this.emitJavascript(r.members[0],e.TokenID.SColon,!0),this.writeLineToOutput("")):this.emitJavascriptList(t,null,e.TokenID.SColon,!0,!1,n)}else this.emitJavascript(t,e.TokenID.SColon,!0);else this.emitJavascript(t,e.TokenID.SColon,!0)},r.prototype.recordSourceMappingStart=function(t){if(this.sourceMapper&&t){var n={line:-1,col:-1},r=new e.SourceMapping(t);r.emittedStartColumn=this.emitState.column,r.emittedStartLine=this.emitState.line,e.getSourceLineColFromMap(n,t.minChar,this.checker.locationInfo.lineMap),r.sourceStartColumn=n.col,r.sourceStartLine=n.line,e.getSourceLineColFromMap(n,t.limChar,this.checker.locationInfo.lineMap),r.sourceEndColumn=n.col,r.sourceEndLine=n.line,r.parent=this.sourceMapper.currentMapping,this.sourceMapper.currentMapping=this.sourceMapper.sourceMappings.length,this.sourceMapper.sourceMappings.push(r);if(r.parent>=0){var i=this.sourceMapper.sourceMappings[r.parent];i.firstChild==-1&&(i.firstChild=this.sourceMapper.currentMapping)}}},r.prototype.recordSourceMappingEnd=function(e){if(this.sourceMapper&&e){var t=this.sourceMapper.currentMapping,n=this.sourceMapper.sourceMappings[t];n.emittedEndColumn=this.emitState.column,n.emittedEndLine=this.emitState.line,this.sourceMapper.currentMapping=n.parent}},r.prototype.emitSourceMappings=function(){e.SourceMapper.EmitSourceMapping(this.allSourceMappers)},r.prototype.emitJavascriptList=function(t,n,r,i,s,o,u){if(t==null)return;if(t.nodeType!=e.NodeType.List)this.emitJavascript(t,r,i,u);else{var a=t;if(a.members.length==0)return;this.emitParensAndCommentsInPlace(t,!0);var f=a.members.length;for(var l=0;l0&&n.nodeType!=e.NodeType.List&&n.nodeType!=e.NodeType.Block&&n.nodeType!=e.NodeType.Interface&&(n.nodeType!=e.NodeType.VarDecl||(n.varFlags&e.VarFlags.Ambient)!=e.VarFlags.Ambient||n.init!=null)&&n.nodeType!=e.NodeType.EndCode&&(n.nodeType!=e.NodeType.FuncDecl||this.emitState.container!=t.Constructor)&&this.emitIndent(),o&&this.writeToOutput("("),n.emit(this,r,i,s),o&&this.writeToOutput(")"),r==e.TokenID.SColon&&n.nodeType1)for(var s=1;s0&&(this.writeToOutput(", "),this.emitJavascriptList(t.args,", ",e.TokenID.Comma,!1,!1,!1)),this.writeToOutput(")"),!0}return!1},r}();e.Emitter=r})(TypeScript||(TypeScript={}));var TypeScript;(function(e){var t=function(){function t(e){this.outfile=e,this.parser=null,this.checker=null,this.lineCol={line:0,col:0},this.emitAsComments=!0,this.hasErrors=!1,this.pushToErrorSink=!1,this.errorSink=[]}return t.prototype.getCapturedErrors=function(){return this.errorSink},t.prototype.freeCapturedErrors=function(){this.errorSink=[]},t.prototype.captureError=function(e){this.errorSink[this.errorSink.length]=e},t.prototype.setErrOut=function(e){this.outfile=e,this.emitAsComments=!1},t.prototype.emitPrefix=function(){this.emitAsComments&&this.outfile.Write("// "),this.outfile.Write(this.checker.locationInfo.filename+"("+this.lineCol.line+","+this.lineCol.col+"): ")},t.prototype.writePrefix=function(e){e?this.setError(e):(this.lineCol.line=-1,this.lineCol.col=-1),this.emitPrefix()},t.prototype.writePrefixFromSym=function(t){t&&this.checker.locationInfo.lineMap?e.getSourceLineColFromMap(this.lineCol,t.location,this.checker.locationInfo.lineMap):(this.lineCol.line=-1,this.lineCol.col=-1),this.emitPrefix()},t.prototype.setError=function(t){t&&(t.flags|=e.ASTFlags.Error,this.checker.locationInfo.lineMap&&e.getSourceLineColFromMap(this.lineCol,t.minChar,this.checker.locationInfo.lineMap))},t.prototype.reportError=function(e,t){if(this.pushToErrorSink){this.captureError(t);return}this.hasErrors=!0;var n=e.limChar-e.minChar;this.parser.errorRecovery&&this.parser.errorCallback?this.parser.errorCallback(e.minChar,n,t,this.checker.locationInfo.unitIndex):(this.writePrefix(e),this.outfile.WriteLine(t))},t.prototype.reportErrorFromSym=function(e,t){if(this.pushToErrorSink){this.captureError(t);return}this.hasErrors=!0,this.parser.errorRecovery&&this.parser.errorCallback?this.parser.errorCallback(e.location,1,t,this.checker.locationInfo.unitIndex):(this.writePrefixFromSym(e),this.outfile.WriteLine(t))},t.prototype.emitterError=function(e,t){throw this.reportError(e,t),Error("EmitError")},t.prototype.duplicateIdentifier=function(e,t){this.reportError(e,"Duplicate identifier '"+t+"'")},t.prototype.showRef=function(e,t,n){var r={line:-1,col:-1};this.parser.getSourceLineCol(r,n.location),this.reportError(e,"symbol "+t+" defined at ("+r.line+","+r.col+")")},t.prototype.unresolvedSymbol=function(e,t){this.reportError(e,"The name '"+t+"' does not exist in the current scope")},t.prototype.symbolDoesNotReferToAValue=function(e,t){this.reportError(e,"The name '"+t+"' does not refer to a value")},t.prototype.styleError=function(e,t){var n=this.pushToErrorSink;this.pushToErrorSink=!1,this.reportError(e,"STYLE: "+t),this.pushToErrorSink=n},t.prototype.simpleError=function(e,t){this.reportError(e,t)},t.prototype.simpleErrorFromSym=function(e,t){this.reportErrorFromSym(e,t)},t.prototype.invalidSuperReference=function(e){this.simpleError(e,"Keyword 'super' can only be used inside a class instance method")},t.prototype.valueCannotBeModified=function(e){this.simpleError(e,"The left-hand side of an assignment expression must be a variable, property or indexer")},t.prototype.invalidCall=function(t,n,r){var i=t.target.type,s=i.getScopedTypeName(r);if(i.construct&&n==e.NodeType.Call)this.reportError(t,"Value of type '"+s+"' is not callable. Did you mean to include 'new'?");else{var o=n==e.NodeType.Call?"callable":"newable";this.reportError(t,"Value of type '"+s+"' is not "+o)}},t.prototype.indexLHS=function(e,t){var n=e.operand1.type.getScopedTypeName(t),r=e.operand2.type.getScopedTypeName(t);this.simpleError(e,"Value of type '"+n+"' is not indexable by type '"+r+"'")},t.prototype.incompatibleTypes=function(e,t,n,r,i,s){t||(t=this.checker.anyType),n||(n=this.checker.anyType);var o=s?s.message:"";r?this.reportError(e,"Operator '"+r+"' cannot be applied to types '"+t.getScopedTypeName(i)+"' and '"+n.getScopedTypeName(i)+"'"+(o?": "+o:"")):this.reportError(e,"Cannot convert '"+t.getScopedTypeName(i)+"' to '"+n.getScopedTypeName(i)+"'"+(o?": "+o:""))},t.prototype.expectedClassOrInterface=function(e){this.simpleError(e,"Expected var, class, interface, or module")},t.prototype.unaryOperatorTypeError=function(e,t,n){this.reportError(e,"Operator '"+t+"' cannot be applied to type '"+n.getTypeName()+"'")},t}();e.ErrorReporter=t})(TypeScript||(TypeScript={}));var TypeScript;(function(e){function s(t,n,r,s,o,u){var a=r.getText(s,o);t.log("Quick parse range ("+s+","+o+'): "'+e.stringToLiteral(a,100)+'"');var f=new i;f.setErrorRecovery(null,-1,-1),f.errorCallback=u;var l=new e.TypeDecl(e.NodeType.Class,null,null,null,null,null);f.currentClassDecl=l;var c=f.quickParse(new e.StringSourceText(a),"",0);return c}(function(e){e._map=[],e.NoTypes=0,e.ArraySuffix=1,e.Primitive=2,e.Named=4,e.AllSimpleTypes=e.Primitive|e.Named,e.AllTypes=e.Primitive|e.Named|e.ArraySuffix})(e.TypeContext||(e.TypeContext={}));var t=e.TypeContext;(function(e){e._map=[],e._map[0]="None",e.None=0,e._map[1]="StartScript",e.StartScript=1,e._map[2]="StartStmtList",e.StartStmtList=2,e._map[3]="StartStatement",e.StartStatement=3,e._map[4]="StartFncDecl",e.StartFncDecl=4,e._map[5]="FncDeclName",e.FncDeclName=5,e._map[6]="FncDeclArgs",e.FncDeclArgs=6,e._map[7]="FncDeclReturnType",e.FncDeclReturnType=7,e._map[8]="ForInit",e.ForInit=8,e._map[9]="ForInitAfterVar",e.ForInitAfterVar=9,e._map[10]="ForCondStart",e.ForCondStart=10,e._map[11]="EndStmtList",e.EndStmtList=11,e._map[12]="EndScript",e.EndScript=12})(e.ParseState||(e.ParseState={}));var n=e.ParseState,r=function(){function e(e,t){this.Script=e,this.endLexState=t}return e}();e.QuickParseResult=r;var i=function(){function i(){this.varLists=[],this.scopeLists=[],this.staticsLists=[],this.scanner=new e.Scanner,this.tok=null,this.needTerminator=!1,this.inFnc=!1,this.inStaticFnc=!1,this.inInterfaceDecl=!1,this.currentClassDecl=null,this.inFncDecl=!1,this.anonId=new e.Identifier("_anonymous"),this.style_requireSemi=!1,this.style_funcInLoop=!0,this.incremental=!1,this.errorRecovery=!1,this.outfile=undefined,this.errorCallback=null,this.state=n.StartStmtList,this.cursorLine=-1,this.cursorColumn=-1,this.cursorState=n.None,this.errorMessage="",this.ambientModule=!1,this.ambientClass=!1,this.topLevel=!0,this.currentUnitIndex=-1,this.prevIDTok=null,this.stmtStack=new Array,this.hasTopLevelImportOrExport=!1,this.strictMode=!1,this.nestingLevel=0,this.prevExpr=null,this.currentClassDefinition=null,this.parsingClassConstructorDefinition=!1,this.parsingDeclareFile=!1,this.amdDependencies=[],this.inferPropertiesFromThisAssignment=!1,this.fname="",this.parseError=!1}return i.prototype.resetStmtStack=function(){this.stmtStack=new Array},i.prototype.inLoop=function(){for(var e=this.stmtStack.length-1;e>=0;e--)if(this.stmtStack[e].stmt.isLoop())return!0;return!1},i.prototype.pushStmt=function(e,t){var n={stmt:e,labels:t};this.stmtStack.push(n)},i.prototype.popStmt=function(){return this.stmtStack.pop()},i.prototype.resolveJumpTarget=function(t){var n=this.stmtStack.length;for(var r=n-1;r>=0;r--){var i=this.stmtStack[r];if(t.target){if(i.labels&&i.labels.members.length>0)for(var s=0,o=i.labels.members.length;s0)this.tok.tokenId==e.TokenID.LCurly?i++:this.tok.tokenId==e.TokenID.RCurly&&i--,this.tok=this.scanner.scan(),n=e.ErrorRecoverySet.None,r=e.lookupToken(this.tok.tokenId),r!=undefined&&(n=r.ers)},i.prototype.chkCurTok=function(e,t,n){this.tok.tokenId!=e?(this.reportParseError(t),this.errorRecovery&&this.skip(n)):this.tok=this.scanner.scan()},i.prototype.pushDeclLists=function(){this.staticsLists.push(new e.ASTList),this.varLists.push(new e.ASTList),this.scopeLists.push(new e.ASTList)},i.prototype.popDeclLists=function(){this.staticsLists.pop(),this.varLists.pop(),this.scopeLists.pop()},i.prototype.topVarList=function(){return this.varLists[this.varLists.length-1]},i.prototype.topScopeList=function(){return this.scopeLists[this.scopeLists.length-1]},i.prototype.topStaticsList=function(){return this.staticsLists[this.staticsLists.length-1]},i.prototype.parseComment=function(t){if(t){var n=new e.Comment(t.value,t.isBlock,t.endsLine);n.minChar=t.startPos,n.limChar=t.startPos+t.value.length;if(!t.isBlock&&t.value.length>3&&t.value.substring(0,3)=="///"){var r=e.getAdditionalDependencyPath(t.value);r&&this.amdDependencies.push(r)}return n}return null},i.prototype.parseCommentsInner=function(e){if(e){var t=new Array;for(var n=0;n0){var g=a.length,y=a[g-1],b=new e.ModuleDecl(y,p,this.topVarList(),this.topScopeList());if(this.parsingDeclareFile||e.hasFlag(n,e.Modifiers.Ambient))b.modFlags|=e.ModuleFlags.Ambient;b.modFlags|=e.ModuleFlags.Exported,b.minChar=l,b.limChar=v,this.popDeclLists();var w;for(var E=g-2;E>=0;E--){w=new e.ASTList,w.append(b),y=a[E],b=new e.ModuleDecl(y,w,new e.ASTList,new e.ASTList),w.minChar=b.minChar=l,w.limChar=b.limChar=v;if(this.parsingDeclareFile||e.hasFlag(n,e.Modifiers.Ambient))b.modFlags|=e.ModuleFlags.Ambient;b.modFlags|=e.ModuleFlags.Exported}w=new e.ASTList,w.append(b),w.minChar=l,w.limChar=v,m=new e.ModuleDecl(u,w,new e.ASTList,new e.ASTList)}else m=new e.ModuleDecl(u,p,this.topVarList(),this.topScopeList()),this.popDeclLists();if(this.parsingDeclareFile||e.hasFlag(n,e.Modifiers.Ambient))m.modFlags|=e.ModuleFlags.Ambient;return e.hasFlag(n,e.Modifiers.Exported)&&(m.modFlags|=e.ModuleFlags.Exported),c&&(m.modFlags|=e.ModuleFlags.IsDynamic),m.preComments=f,m.postComments=this.parseComments(),this.ambientModule=s,this.topLevel=o,m.leftCurlyCount=this.scanner.leftCurlyCount-r,m.rightCurlyCount=this.scanner.rightCurlyCount-i,m},i.prototype.parseTypeReferenceTail=function(t,n,r){var i=new e.TypeReference(r,0);i.minChar=n;while(this.tok.tokenId==e.TokenID.LBrack)this.tok=this.scanner.scan(),i.arrayCount++,this.chkCurTok(e.TokenID.RBrack,"Expected ']'",t|e.ErrorRecoverySet.LBrack);return i.limChar=this.scanner.lastTokenLimChar(),i},i.prototype.parseNamedType=function(t,n,r,i){this.tok=this.scanner.scan();if(this.tok.tokenId==e.TokenID.Dot){var s=this.scanner.pos;this.tok=this.scanner.scan();if(this.tok.tokenId==e.TokenID.ID||e.convertTokToID(this.tok,this.strictMode)){var o=new e.Identifier(this.tok.getText());o.minChar=this.scanner.startPos,o.limChar=this.scanner.pos;var u=new e.BinaryExpression(e.NodeType.Dot,r,o);return u.minChar=r.minChar,u.limChar=o.limChar,this.parseNamedType(t,n,u,i)}this.reportParseError("need identifier after '.'");if(this.errorRecovery)return r.flags|=e.ASTFlags.DotLHS,r.limChar=this.scanner.lastTokenLimChar(),r;var a=new e.MissingIdentifier;a.minChar=this.scanner.pos,a.limChar=this.scanner.pos;var f=new e.BinaryExpression(e.NodeType.Dot,r,a);return f.flags|=e.ASTFlags.Error,f.minChar=r.minChar,f.limChar=a.limChar,this.parseNamedType(t,n,f,i)}return i?this.parseTypeReferenceTail(t,n,r):r},i.prototype.parseTypeReference=function(t,n){var r=this.scanner.startPos,i=!1;switch(this.tok.tokenId){case e.TokenID.VOID:n||this.reportParseError("void not a valid type in this context");case e.TokenID.NUMBER:case e.TokenID.BOOL:case e.TokenID.ANY:case e.TokenID.STRING:var s=e.tokenTable[this.tok.tokenId].text,o=new e.Identifier(s);return o.minChar=r,o.limChar=this.scanner.pos,this.tok=this.scanner.scan(),this.parseTypeReferenceTail(t,r,o);case e.TokenID.ID:var u=this.createRef(this.tok.getText(),r);return u.limChar=this.scanner.pos,this.parseNamedType(t,r,u,!0);case e.TokenID.LCurly:this.tok=this.scanner.scan();var a=new e.ASTList;a.minChar=r;var f=this.inInterfaceDecl;this.inInterfaceDecl=!0,this.parseInterfaceMembers(t|e.ErrorRecoverySet.RCurly,a),this.inInterfaceDecl=f,this.chkCurTok(e.TokenID.RCurly,"Expected '}'",t);var l=new e.TypeDecl(e.NodeType.Interface,this.anonId,a,null,null,null);return l.minChar=r,l.limChar=a.limChar,this.parseTypeReferenceTail(t,r,l);case e.TokenID.NEW:this.tok=this.scanner.scan(),this.tok.tokenId!=e.TokenID.LParen?this.reportParseError("Expected '('"):i=!0;case e.TokenID.LParen:var c=new e.ASTList,h=this.parseFormalParameterList(t|e.ErrorRecoverySet.RParen,c,!1,!0,!1,!1,!1,null);this.chkCurTok(e.TokenID.Arrow,"Expected '=>'",t);var p=this.parseTypeReference(t,!0),d=new e.FuncDecl(null,null,!1,c,null,null,null,e.NodeType.FuncDecl);return d.returnTypeAnnotation=p,d.variableArgList=h,d.fncFlags|=e.FncFlags.Signature,i&&(d.fncFlags|=e.FncFlags.ConstructMember,d.hint="_construct",d.classDecl=null),d.minChar=r,this.parseTypeReferenceTail(t,r,d);default:this.reportParseError("Expected type name");var v=new e.TypeReference(null,0);return v.flags|=e.ASTFlags.Error,v.minChar=this.scanner.pos,v.limChar=this.scanner.pos,v}},i.prototype.parseFunctionStatements=function(r,i,s,o,u,a,f,l,c){this.pushDeclLists();var h=this.stmtStack;this.resetStmtStack();var p=null,d=!1,v=!1;if(!l){p=new e.ASTList;var m=this.scanner.startPos;this.tok.tokenId==e.TokenID.Arrow&&(o&&this.reportParseError("'=>' may not be used for class methods"),d=!0,this.tok=this.scanner.scan());if(d&&this.tok.tokenId!=e.TokenID.LCurly){var g=this.parseExpr(r|e.ErrorRecoverySet.SColon,e.OperatorPrecedence.Asg,!0,t.NoTypes),y=new e.ReturnStatement;y.returnExpression=g,p.minChar=m,p.append(y)}else{this.state=n.StartStmtList,this.chkCurTok(e.TokenID.LCurly,"Expected '{'",r|e.ErrorRecoverySet.StmtStart);var b=this.inFnc;v=d,this.inFnc=!0,this.parseStmtList(r|e.ErrorRecoverySet.RCurly|e.ErrorRecoverySet.StmtStart,p,!0,!1,a,c),p.minChar=m,p.limChar=this.scanner.pos,this.inFnc=b;var w=new e.EndCode;w.minChar=p.limChar,w.limChar=w.minChar,p.append(w)}}var E=new e.FuncDecl(i,p,s,u,this.topVarList(),this.topScopeList(),this.topStaticsList(),e.NodeType.FuncDecl);this.popDeclLists();var S=this.topScopeList();S.append(E);var x=!1,T=this.scanner.pos;return l?this.chkCurTok(e.TokenID.SColon,"Expected ';'",r):!d||v?(this.chkCurTok(e.TokenID.RCurly,"Expected '}'",r),v&&(E.fncFlags|=e.FncFlags.IsFatArrowFunction)):(E.fncFlags|=e.FncFlags.IsFatArrowFunction,this.tok.tokenId==e.TokenID.SColon&&(this.tok=this.scanner.scan())),E.minChar=f,E.limChar=T,l||(E.fncFlags|=e.FncFlags.Definition),this.stmtStack=h,E},i.prototype.transformAnonymousArgsIntoFormals=function(t,n){var r=this,i=function(n){if(n.nodeType==e.NodeType.Comma)r.transformAnonymousArgsIntoFormals(t,n);else if(n.nodeType==e.NodeType.Name||n.nodeType==e.NodeType.Asg){var i=n.nodeType==e.NodeType.Asg?n.operand1:n,s=new e.ArgDecl(i);s.preComments=i.preComments,s.postComments=i.postComments,s.minChar=i.minChar,s.limChar=i.limChar,e.hasFlag(i.flags,e.ASTFlags.PossibleOptionalParameter)&&(s.isOptional=!0),n.nodeType==e.NodeType.Asg&&(s.init=n.operand2),t.append(s)}else r.reportParseError("Invalid lambda argument")};if(n)if(n.nodeType==e.NodeType.Comma){var s=n;i(s.operand1),i(s.operand2)}else i(n)},i.prototype.parseFormalParameterList=function(n,r,i,s,o,u,a,f){r.minChar=this.scanner.startPos,o?this.tok=this.scanner.scan():f||this.chkCurTok(e.TokenID.LParen,"Expected '('",n|e.ErrorRecoverySet.RParen);var l=!1,c=!0,h=!1,p=!1,d=!1;f&&(this.transformAnonymousArgsIntoFormals(r,f),p=!0);for(;;){var v=!1,m=e.VarFlags.None,g=this.scanner.startPos;this.inferPropertiesFromThisAssignment&&this.tok.tokenId==e.TokenID.THIS&&(i||this.reportParseError("Instance property declarations using 'this' may only be used in class constructors"),this.tok=this.scanner.scan(),m|=e.VarFlags.Public|e.VarFlags.Property,this.currentClassDefinition&&(this.currentClassDefinition.varFlags|=e.VarFlags.ClassSuperMustBeFirstCallInConstructor)),this.tok.tokenId==e.TokenID.PUBLIC?(m|=e.VarFlags.Public|e.VarFlags.Property,this.currentClassDefinition&&(this.currentClassDefinition.varFlags|=e.VarFlags.ClassSuperMustBeFirstCallInConstructor)):this.tok.tokenId==e.TokenID.PRIVATE&&(m|=e.VarFlags.Private|e.VarFlags.Property,this.currentClassDefinition&&(this.currentClassDefinition.varFlags|=e.VarFlags.ClassSuperMustBeFirstCallInConstructor)),m!=e.VarFlags.None?(i||this.reportParseError("only constructor parameters can be properties"),this.tok=this.scanner.scan(),this.inferPropertiesFromThisAssignment&&this.tok.tokenId==e.TokenID.THIS&&(i||this.reportParseError("Instance property declarations using 'this' may only be used in class constructors"),this.tok=this.scanner.scan(),this.tok=this.scanner.scan())):this.tok.tokenId==e.TokenID.Ellipsis&&(l=!0,this.tok=this.scanner.scan());var y=null;if(!p&&this.tok.tokenId==e.TokenID.ID||e.convertTokToID(this.tok,this.strictMode))y=new e.Identifier(this.tok.getText()),y.minChar=this.scanner.startPos,y.limChar=this.scanner.pos;if(p||y){v=!0;var b=null,w=null;p&&r.members.length?(w=r.members[r.members.length-1],w.isOptional&&(h=!0,d=!0)):(w=new e.ArgDecl(y),u&&this.reportParseError("Property getters may not take any arguments"),a&&!c&&this.reportParseError("Property setters may only take one argument"),w.minChar=g,w.preComments=this.parseComments(),this.tok=this.scanner.scan()),this.tok.tokenId==e.TokenID.QMark&&(w.isOptional=!0,h=!0,this.tok=this.scanner.scan()),this.tok.tokenId==e.TokenID.Colon&&(this.tok=this.scanner.scan(),b=this.parseTypeReference(n,!1),f&&(d=!0)),this.tok.tokenId==e.TokenID.Asg&&(s&&this.reportParseError("Arguments in signatures may not have default values"),h=!0,this.tok=this.scanner.scan(),w.init=this.parseExpr(e.ErrorRecoverySet.Comma|n,e.OperatorPrecedence.Cma,!1,t.NoTypes)),h&&!w.isOptionalArg()&&!l&&this.reportParseError("Optional parameters may only be followed by other optional parameters"),l&&w.isOptionalArg()&&this.reportParseError("Varargs may not be optional or have default parameters"),w.postComments=this.parseComments(),w.typeExpr=b,w.limChar=this.scanner.lastTokenLimChar(),w.varFlags|=m,p?p=!1:r.append(w)}c=!1;if(this.tok.tokenId!=e.TokenID.Comma)break;if(v&&!l){this.tok=this.scanner.scan();continue}this.reportParseError("Unexpected ',' in argument list");if(this.errorRecovery){this.tok=this.scanner.scan();continue}}return o?this.chkCurTok(e.TokenID.RBrack,"Expected ']'",n|e.ErrorRecoverySet.LCurly|e.ErrorRecoverySet.SColon):(!f||d)&&this.chkCurTok(e.TokenID.RParen,"Expected ')'",n|e.ErrorRecoverySet.LCurly|e.ErrorRecoverySet.SColon),r.limChar=this.scanner.lastTokenLimChar(),l},i.prototype.parseFncDecl=function(t,r,i,s,o,u,a,f,l,c){var h=this.scanner.leftCurlyCount,p=this.scanner.rightCurlyCount,d=this.parsingClassConstructorDefinition;this.parsingClassConstructorDefinition=!1;var v=null,m=this.scanner.startPos,g=this.scanner.pos,y=this.nestingLevel;this.nestingLevel=0,!this.style_funcInLoop&&this.inLoop()&&this.reportParseStyleError("function declaration in loop");if(!s&&!a&&!u&&!c){this.tok=this.scanner.scan(),this.state=n.StartFncDecl;if(this.tok.tokenId!=e.TokenID.ID&&!e.convertTokToID(this.tok,this.strictMode)){if(r)return this.reportParseError("Function declaration must include identifier"),this.nestingLevel=y,new e.IncompleteAST(m,this.scanner.pos)}else v=new e.Identifier(this.tok.getText()),v.minChar=this.scanner.startPos,v.limChar=this.scanner.pos,this.tok=this.scanner.scan()}else o&&(v=o);this.state=n.FncDeclName;var b=new e.ASTList,w=!1,E=!1,S=e.hasFlag(l,e.Modifiers.Getter),x=e.hasFlag(l,e.Modifiers.Setter);if(this.tok.tokenId==e.TokenID.LParen||u&&this.tok.tokenId==e.TokenID.LBrack||c&&c.preProcessedLambdaArgs)w=this.parseFormalParameterList(t,b,!1,i,u,S,x,c?c.preProcessedLambdaArgs:null);this.state=n.FncDeclArgs;var T=null;this.tok.tokenId==e.TokenID.Colon&&(this.tok=this.scanner.scan(),e.hasFlag(l,e.Modifiers.Setter)&&this.reportParseError("Property setters may not declare a return type"),T=this.parseTypeReference(t,!0)),u&&b.members.length==0&&this.reportParseError("Index signatures require a parameter type to be specified"),this.state=n.FncDeclReturnType,r&&!this.parsingDeclareFile&&!f&&(!s||!(this.ambientModule||this.ambientClass||this.inInterfaceDecl))&&this.tok.tokenId==e.TokenID.SColon&&(E=!0,r=!1,i=!0);var N=this.inFncDecl;this.inFncDecl=!0;var C=this.parseFunctionStatements(t|e.ErrorRecoverySet.RCurly,v,!1,s,b,e.AllowedElements.FunctionBody,g,i,e.Modifiers.None);return this.inFncDecl=N,C.variableArgList=w,C.isOverload=E,i||(C.fncFlags|=e.FncFlags.Definition),a&&(C.fncFlags|=e.FncFlags.Static),i&&(C.fncFlags|=e.FncFlags.Signature),u&&(C.fncFlags|=e.FncFlags.IndexerMember),C.returnTypeAnnotation=T,s&&(C.fncFlags|=e.FncFlags.Method,C.fncFlags|=e.FncFlags.ClassPropertyMethodExported),C.leftCurlyCount=this.scanner.leftCurlyCount-h,C.rightCurlyCount=this.scanner.rightCurlyCount-p,this.nestingLevel=y,this.parsingClassConstructorDefinition=d,C},i.prototype.convertToTypeReference=function(t){var n;switch(t.nodeType){case e.NodeType.TypeRef:return t;case e.NodeType.Name:return n=new e.TypeReference(t,0),n.minChar=t.minChar,n.limChar=t.limChar,n;case e.NodeType.Index:var r=t;n=this.convertToTypeReference(r.operand1);if(n)return n.arrayCount++,n.minChar=r.minChar,n.limChar=r.limChar,n;var i=new e.AST(e.NodeType.Error);return i}return null},i.prototype.parseArgList=function(n){var r=new e.ASTList;r.minChar=this.scanner.startPos,this.tok=this.scanner.scan();if(this.tok.tokenId!==e.TokenID.RParen)for(;;){if(r.members.length>65535){this.reportParseError("max number of args exceeded");break}var i=this.parseExpr(e.ErrorRecoverySet.Comma|n,e.OperatorPrecedence.Cma,!1,t.NoTypes);r.append(i);if(this.tok.tokenId!=e.TokenID.Comma)break;this.tok=this.scanner.scan()}return r.limChar=this.scanner.pos,r},i.prototype.parseBaseList=function(t,n,r,i,s){var o=!0,u=t;for(;;){o&&(this.tok.tokenId==e.TokenID.IMPLEMENTS&&(i&&this.reportParseError("interfaces can not implement other types"),u=n),this.tok=this.scanner.scan(),o=!1);var a=null;if(this.tok.tokenId==e.TokenID.ID||e.convertTokToID(this.tok,this.strictMode)){var f=this.scanner.startPos;a=new e.Identifier(this.tok.getText()),a.minChar=f,a.limChar=this.scanner.pos,a=this.parseNamedType(r|e.ErrorRecoverySet.LCurly,f,a,!1)}else this.reportParseError("Expected base name"),this.errorRecovery&&(a=new e.MissingIdentifier,a.minChar=this.scanner.pos,a.limChar=this.scanner.pos,a.flags|=e.ASTFlags.Error);if(this.tok.tokenId==e.TokenID.LParen){s&&this.reportParseError("Base classes may only be initialized via a 'super' call within the constructor body");var l=this.parseArgList(r|e.ErrorRecoverySet.RParen),c=new e.CallExpression(e.NodeType.Call,a,l);this.tok=this.scanner.scan(),c.limChar=this.scanner.pos,u.append(c)}else u.append(a);!i&&u==t&&t.members.length>1&&this.reportParseError("A class may only extend one other class");if(this.tok.tokenId==e.TokenID.Comma){this.tok=this.scanner.scan();continue}if(this.tok.tokenId==e.TokenID.EXTENDS||this.tok.tokenId==e.TokenID.IMPLEMENTS){u=t,o=!0;continue}break}},i.prototype.parseClassDecl=function(t,n,r){var i=this.scanner.leftCurlyCount,s=this.scanner.rightCurlyCount;(r&e.Modifiers.Readonly)!=e.Modifiers.None&&this.reportParseError("const modifier is implicit for class");if(this.parsingDeclareFile||this.ambientModule)r|=e.Modifiers.Ambient,r|=e.Modifiers.Exported;var o=this.parsingDeclareFile||(r&e.Modifiers.Ambient)!=e.Modifiers.None,u=this.ambientClass;this.ambientClass=o,this.tok=this.scanner.scan();var a=null;this.tok.tokenId==e.TokenID.ID||e.convertTokToID(this.tok,this.strictMode)?(a=new e.Identifier(this.tok.getText()),a.minChar=this.scanner.startPos,a.limChar=this.scanner.pos,this.tok=this.scanner.scan()):(this.reportParseError("class missing name"),this.errorRecovery&&(a=new e.MissingIdentifier,a.minChar=this.scanner.pos,a.limChar=this.scanner.pos,a.flags|=e.ASTFlags.Error));var f=null,l=null,c=!1;if(this.tok.tokenId==e.TokenID.EXTENDS||this.tok.tokenId==e.TokenID.IMPLEMENTS)f=new e.ASTList,l=new e.ASTList,this.parseBaseList(f,l,t,!1,!0);var h=new e.ClassDecl(a,new e.ASTList,f,l);this.currentClassDefinition=h,this.parseClassElements(h,t,r);if(this.ambientModule||this.parsingDeclareFile||e.hasFlag(r,e.Modifiers.Exported))h.varFlags|=e.VarFlags.Exported;if(this.ambientModule||e.hasFlag(r,e.Modifiers.Ambient))h.varFlags|=e.VarFlags.Ambient;return h.varFlags|=e.VarFlags.Class,this.ambientClass=u,h.leftCurlyCount=this.scanner.leftCurlyCount-i,h.rightCurlyCount=this.scanner.rightCurlyCount-s,h},i.prototype.parseClassElements=function(t,n,r){var i=r,s=!1,o=this.scanner.startPos;this.chkCurTok(e.TokenID.LCurly,"Expected '{'",n),this.nestingLevel++;var u=this.scanner.startPos,a=!1;while(this.tok.tokenId!=e.TokenID.RCurly&&this.tok.tokenId!=e.TokenID.EOF){var f=!0,l=e.Modifiers.Public|e.Modifiers.Private;if(this.tok.tokenId==e.TokenID.GET)i&e.Modifiers.Getter&&this.reportParseError("Duplicate 'get' declaration in class body"),i&e.Modifiers.Setter&&this.reportParseError("Getter already marked as a setter"),i|=e.Modifiers.Getter;else if(this.tok.tokenId==e.TokenID.SET)i&e.Modifiers.Setter&&this.reportParseError("Duplicate 'set' declaration in class body"),i&e.Modifiers.Getter&&this.reportParseError("Setter already marked as a getter"),i|=e.Modifiers.Setter;else if(this.tok.tokenId==e.TokenID.PRIVATE)i&l&&this.reportParseError("Multiple modifiers may not be applied to class members"),i|=e.Modifiers.Private;else if(this.tok.tokenId==e.TokenID.PUBLIC)i&l&&this.reportParseError("Multiple modifiers may not be applied to class members"),i|=e.Modifiers.Public;else if(this.tok.tokenId==e.TokenID.STATIC)i&e.Modifiers.Static&&this.reportParseError("Multiple modifiers may not be applied to class members"),i|=e.Modifiers.Static;else if(this.tok.tokenId==e.TokenID.CONSTRUCTOR)i!=r&&this.reportParseError("Constructors may not have modifiers"),this.parseClassConstructorDeclaration(u,n,i),f=!1,s=!0;else if(a||this.tok.tokenId==e.TokenID.ID||e.convertTokToIDName(this.tok)){var c=a?i&e.Modifiers.Getter?"get":"set":this.tok.getText(),h=new e.Identifier(c);h.minChar=this.scanner.startPos,h.limChar=this.scanner.pos,a?(i^=i&e.Modifiers.Getter?e.Modifiers.Getter:e.Modifiers.Setter,a=!1):this.tok=this.scanner.scan();if(this.tok.tokenId==e.TokenID.LParen)this.parseClassMemberFunctionDeclaration(h,u,n,i),f=!1;else{(i&e.Modifiers.Getter||i&e.Modifiers.Setter)&&this.reportParseError("Property accessors must be functions");var p=this.parseClassMemberVariableDeclaration(h,u,!1,n,i);p.init&&p.init.nodeType==e.NodeType.FuncDecl?this.tok.tokenId==e.TokenID.RCurly&&(f=!1):p.init&&p.init.nodeType==e.NodeType.ObjectLit&&this.tok.tokenId!=e.TokenID.SColon?(f=!1,p.init.flags|=e.ASTFlags.AutomaticSemicolon):this.tok.tokenId!=e.TokenID.SColon&&(this.reportParseError("Expected ';'"),f=!1)}s=!0}else this.tok.tokenId==e.TokenID.SUPER?this.reportParseError("Base class initializers must be the first statement in a class definition"):!a&&(i&e.Modifiers.Getter||i&e.Modifiers.Setter)&&this.tok.tokenId==e.TokenID.LParen||this.tok.tokenId==e.TokenID.Asg?(a=!0,f=!1):this.tok.tokenId!=e.TokenID.SColon&&(this.reportParseError("Unexpected '"+this.tok.getText()+"' in class definition"),s=!0);f&&(this.tok=this.scanner.scan()),s&&(i=r,u=this.scanner.startPos,s=!1)}var d=this.scanner.pos;this.tok.tokenId==e.TokenID.RCurly&&(this.currentClassDefinition.definitionMembers.members.length||(this.currentClassDefinition.preComments=this.parseComments()),this.tok=this.scanner.scan()),this.nestingLevel--,this.currentClassDefinition.members.minChar=o,this.currentClassDefinition.members.limChar=d,this.currentClassDefinition.limChar=d,this.currentClassDefinition=null},i.prototype.parseClassConstructorDeclaration=function(t,n,r){this.parsingClassConstructorDefinition=!0;var i=this.parsingDeclareFile||e.hasFlag(r,e.Modifiers.Ambient),s=new e.ASTList,o=!1,u=this.parseComments();this.tok=this.scanner.scan();if(this.tok.tokenId==e.TokenID.LParen){o=this.parseFormalParameterList(n,s,!0,i,!1,!1,!1,null);if(s.members.length>0)var a=s.members[s.members.length-1]}var f=i||this.tok.tokenId==e.TokenID.SColon;if(f)for(var l=0;l'",n);if(o==null)switch(this.tok.tokenId){case e.TokenID.LParen:f=this.scanner.pos;var d=this.scanner.previousToken().tokenId;this.tok=this.scanner.scan();var v=d==e.TokenID.LParen||d==e.TokenID.Comma||d==e.TokenID.EQ||d==e.TokenID.Colon;v&&this.tok.tokenId==e.TokenID.RParen?(c=!0,this.tok=this.scanner.scan()):(o=this.parseExpr(n|e.ErrorRecoverySet.RParen,e.OperatorPrecedence.No,!0,t.NoTypes),l=this.scanner.lastTokenLimChar(),c=v&&(o.nodeType==e.NodeType.Name||o.nodeType==e.NodeType.Comma)&&(this.tok.tokenId==e.TokenID.Colon||this.tok.tokenId==e.TokenID.QMark)),o&&!c&&(this.chkCurTok(e.TokenID.RParen,"Expected ')'",n),o.isParenthesized=!0);break;case e.TokenID.NumberLit:var m=this.tok;this.tok=this.scanner.scan(),o=new e.NumberLiteral(m.value),o.minChar=f,l=this.scanner.lastTokenLimChar();break;case e.TokenID.QString:o=new e.StringLiteral(this.tok.getText()),this.tok=this.scanner.scan(),o.minChar=f,l=this.scanner.lastTokenLimChar();break;case e.TokenID.Regex:var g=this.tok;o=new e.RegexLiteral(g.regex),this.tok=this.scanner.scan(),o.minChar=f,l=this.scanner.lastTokenLimChar();break;case e.TokenID.LBrack:f=this.scanner.startPos,this.tok=this.scanner.scan(),o=this.parseArrayLiteral(e.ErrorRecoverySet.RBrack|n),o.minChar=f,l=this.scanner.pos,this.chkCurTok(e.TokenID.RBrack,"Expected ']'",n);break;case e.TokenID.LCurly:f=this.scanner.startPos,this.tok=this.scanner.scan();var y=this.parseMemberList(e.ErrorRecoverySet.RCurly|n);this.chkCurTok(e.TokenID.RCurly,"Expected '}'",n),o=new e.UnaryExpression(e.NodeType.ObjectLit,y),o.minChar=f,l=this.scanner.lastTokenLimChar(),y.minChar=f,y.limChar=l;break;case e.TokenID.LT:f=this.scanner.startPos,this.tok=this.scanner.scan();var b=this.parseTypeReference(e.ErrorRecoverySet.BinOp,!1);this.chkCurTok(e.TokenID.GT,"Expected '>'",n),o=new e.UnaryExpression(e.NodeType.TypeAssertion,this.parseExpr(n,e.OperatorPrecedence.Uni,!1,t.NoTypes)),o.castTerm=b;break;default:if(this.prevExpr&&e.hasFlag(this.prevExpr.flags,e.ASTFlags.PossibleOptionalParameter))c=!0,o=this.prevExpr;else{this.reportParseError("Check format of expression term");if(this.errorRecovery){var w=new e.MissingIdentifier;w.minChar=f,w.flags|=e.ASTFlags.Error,this.skip(n|e.ErrorRecoverySet.Postfix),this.tok.tokenId==e.TokenID.ID||e.convertTokToID(this.tok,this.strictMode)?(w.text=this.tok.getText(),this.tok=this.scanner.scan(),l=this.scanner.lastTokenLimChar()):l=this.scanner.lastTokenLimChar(),o=w}}}c&&(this.tok.tokenId==e.TokenID.Arrow||this.tok.tokenId==e.TokenID.Colon||this.tok.tokenId==e.TokenID.Comma||this.tok.tokenId==e.TokenID.RParen?(o=this.parseFncDecl(n,!1,!1,!1,null,!1,!1,!1,e.Modifiers.None,{preProcessedLambdaArgs:o}),o.fncFlags|=e.FncFlags.IsFunctionExpression,o.fncFlags|=e.FncFlags.IsFatArrowFunction,o.minChar=f,l=this.scanner.lastTokenLimChar(),o.limChar=l):o&&(o.isParenthesized=!0)),u&&i!=t.NoTypes&&(i|=t.ArraySuffix);var E=this.parsePostfixOperators(n,o,r,a,i,f,l);if(E){if(u&&E.nodeType==e.NodeType.Index){var S=E;S.operand2==null&&(E=this.convertToTypeReference(E))}return E.minChar=f,E.limChar=e.max(E.limChar,this.scanner.lastTokenLimChar()),E}return new e.AST(e.NodeType.Error)},i.prototype.parseExpr=function(n,r,i,s){var o=null,u=e.lookupToken(this.tok.tokenId),a=!0,f=null,l=this.scanner.startPos,c=this.parseComments(),h=!1;if(u!=undefined&&u.unopNodeType!=e.NodeType.None){a=!1,this.tok=this.scanner.scan();var p=this.parseExpr(e.ErrorRecoverySet.BinOp|n,u.unopPrecedence,i,t.NoTypes);if(u.unopNodeType==e.NodeType.Pos&&p.nodeType==e.NodeType.NumberLit)o=p;else if(u.unopNodeType==e.NodeType.Neg&&p.nodeType==e.NodeType.NumberLit){var d=p;d.value=-d.value,d.value==0&&(d.isNegativeZero=!0),o=p}else o=new e.UnaryExpression(u.unopNodeType,p),o.limChar=p.limChar;o.minChar=l}else{o=this.parseTerm(e.ErrorRecoverySet.BinOp|e.ErrorRecoverySet.AddOp|n,!0,s,!1);var v,m;if(o.nodeType==e.NodeType.Name)v=o,f=v.text;else if(o.nodeType==e.NodeType.Dot){var g=!1;if(this.inferPropertiesFromThisAssignment&&(this.tok.tokenId==e.TokenID.Colon||this.tok.tokenId==e.TokenID.Asg)&&this.parsingClassConstructorDefinition&&this.nestingLevel==this.currentClassDefinition.constructorNestingLevel&&o.operand1.nodeType==e.NodeType.This&&o.operand2.nodeType==e.NodeType.Name){var y=o.operand2;this.currentClassDefinition.knownMemberNames[y.text]||(o=this.parseClassMemberVariableDeclaration(y,o.minChar,!0,n,e.Modifiers.Public),g=!0)}if(!g){m=o;while(m.nodeType==e.NodeType.Dot){var b=m;m=b.operand2}m.nodeType==e.NodeType.Name&&(v=m,f=v.text)}}if(!this.scanner.lastTokenHadNewline()&&(this.tok.tokenId==e.TokenID.Inc||this.tok.tokenId==e.TokenID.Dec)){a=!1;var w=o;o=new e.UnaryExpression(this.tok.tokenId==e.TokenID.Inc?e.NodeType.IncPost:e.NodeType.DecPost,w),o.limChar=this.scanner.pos,o.minChar=w.minChar,this.tok=this.scanner.scan()}}for(;;){u=e.lookupToken(this.tok.tokenId);if(u==undefined||u.binopNodeType==e.NodeType.None)break;if(!i&&u.binopNodeType==e.NodeType.In)break;if(u.binopPrecedence==e.OperatorPrecedence.Asg){if(u.binopPrecedence0&&e.CompilerDiagnostics.Alert(this.builder);var t=this.indentStrings[this.indentAmt];if(t===undefined){t="";for(var n=0;n=97&&t<=122||t>=65&&t<=90||t==e.LexCodeDollar||t==e.LexCodeUnderscore}function o(e){return e>=48&&e<=57}function u(e){return n[e]||o(e)}function a(t){return t==e.LexCodeRBR?e.LexCodeLBR:t==e.LexCodeRC?e.LexCodeLC:t==e.LexCodeRPR?e.LexCodeLPR:0}function b(e){return E(e,!0,!1)}function w(e,t){return E(e,!1,t)}function E(t,n,r){if(!(t.tokenId<=e.TokenID.LimKeyword))return!1;var i=e.lookupToken(t.tokenId);if(i==undefined)return!1;var s=e.Reservation.Javascript|e.Reservation.JavascriptFuture;r&&(s|=e.Reservation.JavascriptFutureStrict);if(n||!e.hasFlag(i.reservation,s))return!0}function S(e,t){if(t===-1)return 0;var n=0,r=e.length-1;while(n>1;t0&&(e.line=r,e.col=t-n[r])}function T(e,t){var n={line:-1,col:-1};return x(n,t,e.locationInfo.lineMap),n.col>=0&&n.col++,n}function N(e,t,n){return e.locationInfo.lineMap[t]+(n-1)}e.LexEOF=-1,e.LexCodeNWL=10,e.LexCodeRET=13,e.LexCodeTAB=9,e.LexCodeVTAB=11,e.LexCode_e="e".charCodeAt(0),e.LexCode_E="E".charCodeAt(0),e.LexCode_x="x".charCodeAt(0),e.LexCode_X="X".charCodeAt(0),e.LexCode_a="a".charCodeAt(0),e.LexCode_A="A".charCodeAt(0),e.LexCode_f="f".charCodeAt(0),e.LexCode_F="F".charCodeAt(0),e.LexCode_g="g".charCodeAt(0),e.LexCode_m="m".charCodeAt(0),e.LexCode_i="i".charCodeAt(0),e.LexCode_0="0".charCodeAt(0),e.LexCode_9="9".charCodeAt(0),e.LexCode_8="8".charCodeAt(0),e.LexCode_7="7".charCodeAt(0),e.LexCodeBSL="\\".charCodeAt(0),e.LexCodeSHP="#".charCodeAt(0),e.LexCodeBNG="!".charCodeAt(0),e.LexCodeQUO='"'.charCodeAt(0),e.LexCodeAPO="'".charCodeAt(0),e.LexCodePCT="%".charCodeAt(0),e.LexCodeAMP="&".charCodeAt(0),e.LexCodeLPR="(".charCodeAt(0),e.LexCodeRPR=")".charCodeAt(0),e.LexCodePLS="+".charCodeAt(0),e.LexCodeMIN="-".charCodeAt(0),e.LexCodeMUL="*".charCodeAt(0),e.LexCodeSLH="/".charCodeAt(0),e.LexCodeXOR="^".charCodeAt(0),e.LexCodeCMA=",".charCodeAt(0),e.LexCodeDOT=".".charCodeAt(0),e.LexCodeLT="<".charCodeAt(0),e.LexCodeEQ="=".charCodeAt(0),e.LexCodeGT=">".charCodeAt(0),e.LexCodeQUE="?".charCodeAt(0),e.LexCodeLBR="[".charCodeAt(0),e.LexCodeRBR="]".charCodeAt(0),e.LexCodeUSC="_".charCodeAt(0),e.LexCodeLC="{".charCodeAt(0),e.LexCodeRC="}".charCodeAt(0),e.LexCodeBAR="|".charCodeAt(0),e.LexCodeTIL="~".charCodeAt(0),e.LexCodeCOL=":".charCodeAt(0),e.LexCodeSMC=";".charCodeAt(0),e.LexCodeUnderscore="_".charCodeAt(0),e.LexCodeDollar="$".charCodeAt(0),e.LexCodeSpace=32,e.LexKeywordTable=undefined;var t=new Array(128),n=new Array(128);e.LexInitialize=r,e.LexAdjustIndent=i,e.LexIsIdentifierStartChar=s,e.LexIsDigit=o,e.LexIsIdentifierChar=u,e.LexMatchingOpen=a,function(e){e._map=[],e._map[0]="Start",e.Start=0,e._map[1]="InFraction",e.InFraction=1,e._map[2]="InExponent",e.InExponent=2}(e.NumberScanState||(e.NumberScanState={}));var f=e.NumberScanState;(function(e){e._map=[],e._map[0]="Start",e.Start=0,e._map[1]="InMultilineComment",e.InMultilineComment=1})(e.LexState||(e.LexState={}));var l=e.LexState;(function(e){e._map=[],e._map[0]="Line",e.Line=0,e._map[1]="File",e.File=1})(e.LexMode||(e.LexMode={}));var c=e.LexMode;(function(e){e._map=[],e._map[0]="Line",e.Line=0,e._map[1]="Block",e.Block=1})(e.CommentStyle||(e.CommentStyle={}));var h=e.CommentStyle,p=function(){function e(e){this.text=e}return e.prototype.getText=function(e,t){return this.text.substring(e,t)},e.prototype.getLength=function(){return this.text.length},e}();e.StringSourceText=p;var d=function(){function e(e,t,n){this.segmentStart=e,this.segmentEnd=t,this.segment=n}return e.prototype.charCodeAt=function(e){return this.segment.charCodeAt(e-this.segmentStart)},e.prototype.substring=function(e,t){return this.segment.substring(e-this.segmentStart,t-this.segmentStart)},e}();e.SourceTextSegment=d;var v=function(){function e(e,t){this.seg1=e,this.seg2=t}return e.prototype.charCodeAt=function(e){return this.seg1.segmentStart<=e&&e=t?e:t},t.prototype.min=function(e,t){return e<=t?e:t},t.prototype.fetchSegment=function(t,n){if(this.agg.seg1.segmentStart<=t&&n<=this.agg.seg1.segmentEnd)return this.agg.seg1;if(this.agg.seg2.segmentStart<=t&&n<=this.agg.seg1.segmentEnd)return this.agg;var r=this.agg.seg1,i=r.segmentEnd,s=e.max(i+512,n);s=e.min(s,this.len);var o=this.sourceText.getText(i,s),u=new d(i,s,o);return this.agg.seg2=r,this.agg.seg1=u,this.agg},t.prototype.charCodeAt=function(e){return this.fetchSegment(e,e+1).charCodeAt(e)},t.prototype.substring=function(e,t){return this.fetchSegment(e,t).substring(e,t)},t}();e.ScannerTextStream=m;var g=function(){function t(){this.prevToken=null,this.curSavedToken=null,this.prevSavedToken=null,this.prevToken=null,this.currentToken=0,this.tokens=new Array,this.prevLine=1,this.line=1,this.col=0,this.lexState=l.Start,this.commentStack=new Array}return t.prototype.previousToken=function(){return this.prevToken},t.prototype.close=function(){this.currentToken=0},t.prototype.addToken=function(t,n){this.tokens[this.currentToken++]=new e.SavedToken(t,n.startPos,n.pos)},t.prototype.scan=function(){this.startLine=this.line,this.startPos=this.col;if(this.currentTokenIndex==this.currentTokens.length){if(!(this.line0)this.line--,t=0;var n=this.lineMap.length-1;this.currentTokens=this.tokensByLine[this.line];while(this.currentTokens.length==0&&this.linethis.currentTokens[this.currentTokenIndex].limChar)this.currentTokenIndex++;if(this.currentTokenIndex0&&this.commentStack[0].line==e)t==null?t=[this.commentStack.shift()]:t=t.concat([this.commentStack.shift()]);return t},t.prototype.resetComments=function(){this.commentStack=[]},t.prototype.setSourceText=function(e,t){},t}();e.SavedTokens=g;var y=function(){function i(){this.prevLine=1,this.line=1,this.col=0,this.pos=0,this.startPos=0,this.len=0,this.lineMap=[],this.ch=e.LexEOF,this.lexState=l.Start,this.mode=c.File,this.scanComments=!0,this.interveningWhitespace=!1,this.interveningWhitespacePos=0,this.leftCurlyCount=0,this.rightCurlyCount=0,this.commentStack=new Array,this.saveScan=null,this.prevTok=e.staticTokens[e.TokenID.EOF],this.startCol=this.col,this.startLine=this.line,this.lineMap[1]=0,e.LexKeywordTable||r()}return i.prototype.previousToken=function(){return this.prevTok},i.prototype.setSourceText=function(e,t){this.mode=t,this.scanComments=this.mode===c.Line,this.pos=0,this.interveningWhitespacePos=0,this.startPos=0,this.line=1,this.col=0,this.startCol=this.col,this.startLine=this.line,this.len=0,this.src=e.getText(0,e.getLength()),this.len=this.src.length,this.lineMap=[],this.lineMap[1]=0,this.commentStack=[],this.leftCurlyCount=0,this.rightCurlyCount=0},i.prototype.setSaveScan=function(e){this.saveScan=e},i.prototype.setText=function(e,t){this.setSourceText(new p(e),t)},i.prototype.setScanComments=function(e){this.scanComments=e},i.prototype.getLexState=function(){return this.lexState},i.prototype.scanLine=function(t,n){this.lexState=n;var r=new Array;this.setText(t,c.Line);var i=this.scan();while(i.tokenId!=e.TokenID.EOF)r[r.length]=i,i=this.scan();return r},i.prototype.tokenStart=function(){this.startPos=this.pos,this.startLine=this.line,this.startCol=this.col,this.interveningWhitespace=!1},i.prototype.peekChar=function(){return this.pos=e.LexCode_0&&t<=e.LexCode_9||t>=e.LexCode_A&&t<=e.LexCode_F||t>=e.LexCode_a&&t<=e.LexCode_f},i.prototype.IsOctalDigit=function(t){return t>=e.LexCode_0&&t<=e.LexCode_7||t>=e.LexCode_a&&t<=e.LexCode_f},i.prototype.scanHexDigits=function(){var t=!1;for(;;){if(!this.IsHexDigit(this.ch))return t?new e.NumberToken(parseInt(this.src.substring(this.startPos,this.pos))):null;this.nextChar(),t=!0}},i.prototype.scanOctalDigits=function(){var t=!1;for(;;){if(!this.IsOctalDigit(this.ch))return t?new e.NumberToken(parseInt(this.src.substring(this.startPos,this.pos))):null;this.nextChar(),t=!0}},i.prototype.scanDecimalNumber=function(t){var n=!1,r=this.pos,i=this.col;for(;;)if(o(this.ch))n=!0,this.nextChar();else if(this.ch==e.LexCodeDOT){if(t!=f.Start)return n?new e.NumberToken(parseFloat(this.src.substring(this.startPos,this.pos))):(this.pos=r,this.col=i,null);this.nextChar(),t=f.InFraction}else if(this.ch==e.LexCode_e||this.ch==e.LexCode_E)if(t==f.Start){if(!n)return this.pos=r,this.col=i,null;n=!1,this.nextChar(),t=f.InExponent}else{if(t!=f.InFraction)return n?new e.NumberToken(parseFloat(this.src.substring(this.startPos,this.pos))):(this.pos=r,this.col=i,null);this.nextChar(),t=f.InExponent,n=!1}else{if(this.ch!=e.LexCodePLS&&this.ch!=e.LexCodeMIN)return n?new e.NumberToken(parseFloat(this.src.substring(this.startPos,this.pos))):(this.pos=r,this.col=i,null);if(t!=f.InExponent)return t==f.InFraction?new e.NumberToken(parseFloat(this.src.substring(this.startPos,this.pos))):n?new e.NumberToken(parseFloat(this.src.substring(this.startPos,this.pos))):(this.pos=r,this.col=i,null);if(!!n)return this.pos=r,this.col=i,null;this.nextChar()}},i.prototype.scanNumber=function(){if(this.peekChar()!=e.LexCode_0)return this.scanDecimalNumber(f.Start);switch(this.peekCharAt(this.pos+1)){case e.LexCode_x:case e.LexCode_X:return this.advanceChar(2),this.scanHexDigits();case e.LexCode_8:case e.LexCode_9:case e.LexCodeDOT:return this.scanDecimalNumber(f.Start);default:return this.scanOctalDigits()}},i.prototype.scanFraction=function(){return this.scanDecimalNumber(f.InFraction)},i.prototype.newLine=function(){this.col=0,this.mode==c.File&&(this.line++,this.lineMap[this.line]=this.pos+1)},i.prototype.finishMultilineComment=function(){var t;this.lexState=l.InMultilineComment;while(this.pos0&&this.commentStack[0].line==e)t==null?t=[this.commentStack.shift()]:t=t.concat([this.commentStack.shift()]);return t},i.prototype.resetComments=function(){this.commentStack=[]},i.prototype.endsLine=function(t){return t==e.LexCodeNWL||t==e.LexCodeRET||t==8232||t==8233},i.prototype.finishSinglelineComment=function(){while(this.pos0){var i=this.src.substring(t,r),s="";this.pos=r+1,this.ch=this.peekChar();var o=this.pos;while(this.ch==e.LexCode_i||this.ch==e.LexCode_g||this.ch==e.LexCode_m)this.nextChar();if(this.pos-o>3)return null;s=this.src.substring(o,this.pos);var u=undefined;try{u=new RegExp(i,s)}catch(a){}if(u)return this.col=n+(this.pos-this.startPos),new e.RegexToken(u)}return this.pos=t,this.col=n,null},i.prototype.lastTokenHadNewline=function(){return this.prevLine!=this.startLine},i.prototype.lastTokenLimChar=function(){return this.interveningWhitespace?this.interveningWhitespacePos:this.startPos},i.prototype.advanceChar=function(e){this.pos+=e,this.col+=e,this.ch=this.peekChar()},i.prototype.nextChar=function(){this.pos++,this.col++,this.ch=this.peekChar()},i.prototype.scan=function(){if(this.lexState==l.InMultilineComment&&this.scanComments){this.ch=this.peekChar();var t=this.line;this.finishMultilineComment();if(this.startPos=e.LexCode_0&&this.ch<=e.LexCode_9)return r=this.scanNumber(),r?r:(this.nextChar(),e.staticTokens[e.TokenID.Error]);switch(this.ch){case e.LexCodeTAB:case e.LexCodeVTAB:this.interveningWhitespace||(this.interveningWhitespacePos=this.pos);if(this.mode==c.Line){do this.nextChar();while(this.ch==e.LexCodeSpace||this.ch==9);var b=this.src.substring(this.startPos,this.pos);return new e.WhitespaceToken(e.TokenID.Whitespace,b)}this.interveningWhitespace=!0;case 255:case 254:case 239:case 187:case 191:case 8232:case 8233:case e.LexCodeNWL:case e.LexCodeRET:if(this.ch==e.LexCodeNWL){this.newLine();if(this.mode==c.Line)return e.staticTokens[e.TokenID.EOF]}this.interveningWhitespace||(this.interveningWhitespacePos=this.pos),this.nextChar(),this.tokenStart(),this.interveningWhitespace=!0;break;case e.LexCodeDOT:return this.peekCharAt(this.pos+1)==e.LexCodeDOT?this.peekCharAt(this.pos+2)==e.LexCodeDOT?(this.advanceChar(3),e.staticTokens[e.TokenID.Ellipsis]):(this.nextChar(),e.staticTokens[e.TokenID.Dot]):(this.nextChar(),r=this.scanFraction(),r?r:e.staticTokens[e.TokenID.Dot]);case e.LexCodeEQ:return this.peekCharAt(this.pos+1)==e.LexCodeEQ?this.peekCharAt(this.pos+2)==e.LexCodeEQ?(this.advanceChar(3),e.staticTokens[e.TokenID.Eqv]):(this.advanceChar(2),e.staticTokens[e.TokenID.EQ]):this.peekCharAt(this.pos+1)==e.LexCodeGT?(this.advanceChar(2),e.staticTokens[e.TokenID.Arrow]):(this.nextChar(),e.staticTokens[e.TokenID.Asg]);case e.LexCodeBNG:return this.peekCharAt(this.pos+1)==e.LexCodeEQ?this.peekCharAt(this.pos+2)==e.LexCodeEQ?(this.advanceChar(3),e.staticTokens[e.TokenID.NEqv]):(this.advanceChar(2),e.staticTokens[e.TokenID.NE]):(this.nextChar(),e.staticTokens[e.TokenID.Bang]);case e.LexCodePLS:return this.peekCharAt(this.pos+1)==e.LexCodeEQ?(this.advanceChar(2),e.staticTokens[e.TokenID.AsgAdd]):this.peekCharAt(this.pos+1)==e.LexCodePLS?(this.advanceChar(2),e.staticTokens[e.TokenID.Inc]):(this.nextChar(),e.staticTokens[e.TokenID.Add]);case e.LexCodeMIN:return this.peekCharAt(this.pos+1)==e.LexCodeEQ?(this.advanceChar(2),e.staticTokens[e.TokenID.AsgSub]):this.peekCharAt(this.pos+1)==e.LexCodeMIN?(this.advanceChar(2),e.staticTokens[e.TokenID.Dec]):(this.nextChar(),e.staticTokens[e.TokenID.Sub]);case e.LexCodeMUL:return this.peekCharAt(this.pos+1)==e.LexCodeEQ?(this.advanceChar(2),e.staticTokens[e.TokenID.AsgMul]):(this.nextChar(),e.staticTokens[e.TokenID.Mult]);case e.LexCodePCT:return this.peekCharAt(this.pos+1)==e.LexCodeEQ?(this.advanceChar(2),e.staticTokens[e.TokenID.AsgMod]):(this.nextChar(),e.staticTokens[e.TokenID.Pct]);case e.LexCodeLT:return this.peekCharAt(this.pos+1)==e.LexCodeLT?this.peekCharAt(this.pos+2)==e.LexCodeEQ?(this.advanceChar(3),e.staticTokens[e.TokenID.AsgLsh]):(this.advanceChar(2),e.staticTokens[e.TokenID.Lsh]):this.peekCharAt(this.pos+1)==e.LexCodeEQ?(this.advanceChar(2),e.staticTokens[e.TokenID.LE]):(this.nextChar(),e.staticTokens[e.TokenID.LT]);case e.LexCodeGT:return this.peekCharAt(this.pos+1)==e.LexCodeGT?this.peekCharAt(this.pos+2)==e.LexCodeEQ?(this.advanceChar(3),e.staticTokens[e.TokenID.AsgRsh]):this.peekCharAt(this.pos+2)==e.LexCodeGT?this.peekCharAt(this.pos+3)==e.LexCodeEQ?(this.advanceChar(4),e.staticTokens[e.TokenID.AsgRs2]):(this.advanceChar(3),e.staticTokens[e.TokenID.Rs2]):(this.advanceChar(2),e.staticTokens[e.TokenID.Rsh]):this.peekCharAt(this.pos+1)==e.LexCodeEQ?(this.advanceChar(2),e.staticTokens[e.TokenID.GE]):(this.nextChar(),e.staticTokens[e.TokenID.GT]);case e.LexCodeXOR:return this.peekCharAt(this.pos+1)==e.LexCodeEQ?(this.advanceChar(2),e.staticTokens[e.TokenID.AsgXor]):(this.nextChar(),e.staticTokens[e.TokenID.Xor]);case e.LexCodeBAR:return this.peekCharAt(this.pos+1)==e.LexCodeEQ?(this.advanceChar(2),e.staticTokens[e.TokenID.AsgOr]):this.peekCharAt(this.pos+1)==e.LexCodeBAR?(this.advanceChar(2),e.staticTokens[e.TokenID.LogOr]):(this.nextChar(),e.staticTokens[e.TokenID.Or]);case e.LexCodeAMP:return this.peekCharAt(this.pos+1)==e.LexCodeEQ?(this.advanceChar(2),e.staticTokens[e.TokenID.AsgAnd]):this.peekCharAt(this.pos+1)==e.LexCodeAMP?(this.advanceChar(2),e.staticTokens[e.TokenID.LogAnd]):(this.nextChar(),e.staticTokens[e.TokenID.And]);default:return e.staticTokens[e.TokenID.EOF]}}}return e.staticTokens[e.TokenID.EOF]},i}();e.Scanner=y,e.convertTokToIDName=b,e.convertTokToID=w,e.getLineNumberFromPosition=S,e.getSourceLineColFromMap=x,e.getLineColumnFromPosition=T,e.getPositionFromLineColumn=N})(TypeScript||(TypeScript={}));var TypeScript;(function(e){function n(t,n,r,i,s){var o=new e.ScopeChain(null,n.scopeChain,t);o.thisType=r,o.classType=i,o.fnc=s,n.scopeChain=o}function r(e){e.scopeChain=e.scopeChain.previous}function i(e,t){return e==null||!e.isInstanceProperty()?t:e}function s(e){return e.isInstanceProperty()}function u(t,r){var i=t,s=null,o=null;i.name&&i.mod&&(i.name.sym=i.mod.symbol);var u=i.mod;if(!u)return;s=new e.SymbolTableScope(u.members,u.ambientMembers,u.enclosedTypes,u.ambientEnclosedTypes,u.symbol),u.memberScope=s,r.modDeclChain.push(i),r.typeFlow.checker.currentModDecl=i,o=new e.SymbolAggregateScope(u.symbol),o.addParentScope(s),o.addParentScope(r.scopeChain.scope),n(o,r,null,null,null),u.containedScope=o,u.symbol&&r.typeFlow.addLocalsFromScope(u.containedScope,u.symbol,i.vars,u.members.privateMembers,!0)}function a(t,r){var i=t,s=null,o=null;i.name&&i.type&&(i.name.sym=i.type.symbol);var u=t.type;if(u){var a=u.symbol;s=r.typeFlow.checker.scopeOf(u),o=new e.SymbolAggregateScope(u.symbol),o.addParentScope(s),o.addParentScope(r.scopeChain.scope),u.containedScope=o,u.memberScope=s;var f=u.instanceType;s=r.typeFlow.checker.scopeOf(f),f.memberScope=s,o=new e.SymbolAggregateScope(f.symbol),o.addParentScope(r.scopeChain.scope),n(o,r,f,u,null),f.containedScope=o}else t.type=r.typeFlow.anyType}function f(t,r){var i=t,s=null,o=null;i.name&&i.type&&(i.name.sym=i.type.symbol);var u=t.type;s=r.typeFlow.checker.scopeOf(u),u.memberScope=s,o=new e.SymbolAggregateScope(u.symbol),o.addParentScope(s),o.addParentScope(r.scopeChain.scope),n(o,r,null,null,null),u.containedScope=o}function l(t,r){var i=t,s=i.type,o=new e.ScopedMembers(new e.DualStringHashTable(new e.StringHashTable,new e.StringHashTable)),u=new e.ScopedMembers(new e.DualStringHashTable(new e.StringHashTable,new e.StringHashTable)),s=new e.Type,a=new e.WithSymbol(i.minChar,r.typeFlow.checker.locationInfo.unitIndex,s);s.members=o,s.ambientMembers=u,s.symbol=a,s.setHasImplementation(),i.type=s;var f=new e.SymbolScopeBuilder(s.members,s.ambientMembers,null,null,r.scopeChain.scope,s.symbol);n(f,r,null,null,null),s.containedScope=f}function c(t,r){var i=t,s=null,o=null;i.type&&(o=t.type.symbol);var u=e.hasFlag(i.fncFlags,e.FncFlags.Static),a=u&&r.scopeChain.fnc!=null,f=a?r.scopeChain.fnc.type.memberScope:r.scopeChain.scope;if(r.scopeChain.thisType&&(!i.isConstructor||e.hasFlag(i.fncFlags,e.FncFlags.ClassMethod))){var l=r.scopeChain.thisType;!(l.typeFlags&e.TypeFlags.IsClass)&&!e.hasFlag(i.fncFlags,e.FncFlags.ClassMethod)?!i.isMethod()||u?f=l.constructorScope:f=l.containedScope:r.scopeChain.previous.scope.container&&r.scopeChain.previous.scope.container.declAST&&r.scopeChain.previous.scope.container.declAST.nodeType==e.NodeType.FuncDecl&&r.scopeChain.previous.scope.container.declAST.isConstructor?f=l.constructorScope:u&&r.scopeChain.classType?f=r.scopeChain.classType.containedScope:f=l.containedScope,s=l.symbol}else i.isConstructor&&r.scopeChain.thisType&&(s=r.scopeChain.thisType.symbol);if(i.type==null||e.hasFlag(i.type.symbol.flags,e.SymbolFlags.TypeSetDuringScopeAssignment)){r.scopeChain.fnc&&r.scopeChain.fnc.type&&(s=r.scopeChain.fnc.type.symbol);var c=null,h=r.scopeChain.fnc,p=i.name?i.name.text:null,d=null;u?(h.type.members==null&&s.getType().memberScope&&(h.type.members=s.type.memberScope.valueMembers),c=r.scopeChain.fnc.type.memberScope,h.innerStaticFuncs[h.innerStaticFuncs.length]=i):!i.isConstructor&&s&&s.declAST&&s.declAST.nodeType==e.NodeType.FuncDecl&&s.declAST.isConstructor&&!i.isMethod()?c=r.scopeChain.thisType.constructorScope:c=r.scopeChain.scope,p&&p!="__missing"&&!i.isAccessor()&&(u?d=c.findLocal(p,!1,!1):d=c.findLocal(p,!1,!1)),r.typeFlow.checker.createFunctionSignature(i,s,c,d,d==null);if(!i.accessorSymbol&&i.fncFlags&e.FncFlags.ClassMethod&&s&&(!d||d.declAST.nodeType!=e.NodeType.FuncDecl)&&i.isAccessor()||d&&d.isAccessor())i.accessorSymbol=r.typeFlow.checker.createAccessorSymbol(i,d,s.getType(),i.isMethod()&&u,!0,c,s);i.type.symbol.flags|=e.SymbolFlags.TypeSetDuringScopeAssignment}i.name&&i.type&&(i.name.sym=i.type.symbol),i.scopeType=i.type;if(i.isOverload)return;var v=new e.StringHashTable,m=new e.ScopedMembers(new e.DualStringHashTable(v,new e.StringHashTable)),g=new e.StringHashTable,y=new e.ScopedMembers(new e.DualStringHashTable(g,new e.StringHashTable)),b=new e.StringHashTable,w=new e.ScopedMembers(new e.DualStringHashTable(b,new e.StringHashTable)),E=new e.StringHashTable,S=new e.ScopedMembers(new e.DualStringHashTable(E,new e.StringHashTable));i.unitIndex=r.typeFlow.checker.locationInfo.unitIndex;var x=new e.SymbolScopeBuilder(m,y,null,null,f,o),T=new e.SymbolScopeBuilder(w,S,null,null,f,null);i.isConstructor&&r.scopeChain.thisType&&(r.scopeChain.thisType.constructorScope=x),i.symbols=v;if(!i.isSpecialFn()){var N=i.type,C=i.signature;i.isConstructor||(N.containedScope=x,x.container=N.symbol,N.memberScope=T,T.container=N.symbol),i.enclosingFnc=r.scopeChain.fnc,N.enclosingType=u?r.scopeChain.classType:r.scopeChain.thisType;var d=t.type.symbol;(i.fncFlags&e.FncFlags.Signature)==e.FncFlags.None&&i.vars&&(r.typeFlow.addLocalsFromScope(x,d,i.vars,v,!1),r.typeFlow.addLocalsFromScope(T,d,i.statics,b,!1));if(C.parameters){var k=C.parameters.length;for(var L=0;L=1&&(s.typeFlow.checker.currentModDecl=s.modDeclChain[s.modDeclChain.length-1])}else if(t.nodeType==e.NodeType.Class)r(s);else if(t.nodeType==e.NodeType.Interface)r(s);else if(t.nodeType==e.NodeType.With)r(s);else if(t.nodeType==e.NodeType.FuncDecl){var a=t;(!a.isConstructor||e.hasFlag(a.fncFlags,e.FncFlags.ClassMethod))&&!a.isOverload&&r(s)}else if(t.nodeType==e.NodeType.Catch){var f=t;f.param&&r(s)}else o=!1;return i.options.goChildren=o,t}var t=function(){function e(e,t,n){this.scopeChain=e,this.typeFlow=t,this.modDeclChain=n}return e}();e.AssignScopeContext=t,e.pushAssignScope=n,e.popAssignScope=r,e.instanceCompare=i,e.instanceFilterStop=s;var o=function(){function e(e,t){this.select=e,this.stop=t,this.result=null}return e.prototype.reset=function(){this.result=null},e.prototype.update=function(e){return this.result=this.select(this.result,e),this.result?this.stop(this.result):!1},e}();e.ScopeSearchFilter=o,e.instanceFilter=new o(i,s),e.preAssignModuleScopes=u,e.preAssignClassScopes=a,e.preAssignInterfaceScopes=f,e.preAssignWithScopes=l,e.preAssignFuncDeclScopes=c,e.preAssignCatchScopes=h,e.preAssignScopes=p,e.postAssignScopes=d})(TypeScript||(TypeScript={}));var TypeScript;(function(e){function i(t,n,r){var i=r.state;return e.hasFlag(t.flags,i.matchFlag)&&(i.pos<0||i.pos==t.limChar)&&(i.ast=t,t.type==null&&i.pos>=0&&i.flow.inScopeTypeCheck(t,i.scope),i.type=t.type,i.options.stopWalk()),t}function s(t,n,r,i,s,o,u,a,f){var l=new e.SymbolScopeBuilder(n,r,i,s,null,t),c=new e.ScopeChain(t,o.scopeChain,l);c.thisType=u,c.classType=a,c.moduleDecl=f,o.scopeChain=c}function o(e){e.scopeChain=e.scopeChain.previous}function u(t,n,r){var i=r.state,s=t.minChar,o=t.limChar;t.nodeType==e.NodeType.Script&&i.pos>o&&(o=i.pos);if(s<=i.pos&&o>=i.pos){switch(t.nodeType){case e.NodeType.Script:var u=t;i.scopeGetter=function(){return u.bod===null?null:u.bod.enclosingScope},i.scopeStartAST=u;break;case e.NodeType.Class:i.scopeGetter=function(){return t.type===null||t.type.instanceType.containedScope===null?null:t.type.instanceType.containedScope},i.scopeStartAST=t,i.enclosingClassDecl=t;break;case e.NodeType.ObjectLit:var a=t;a.targetType&&(i.scopeGetter=function(){return a.targetType.containedScope},i.objectLiteralScopeGetter=function(){return a.targetType.memberScope},i.enclosingObjectLit=a);break;case e.NodeType.Module:i.deepestModuleDecl=t,i.scopeGetter=function(){return t.type===null?null:t.type.containedScope},i.scopeStartAST=t;break;case e.NodeType.Interface:i.scopeGetter=function(){return t.type===null?null:t.type.containedScope},i.scopeStartAST=t;break;case e.NodeType.FuncDecl:var f=t;i.skipNextFuncDeclForClass?i.skipNextFuncDeclForClass=!1:(i.scopeGetter=function(){return f.isConstructor&&e.hasFlag(f.fncFlags,e.FncFlags.ClassMethod)&&t.type&&t.type.enclosingType?t.type.enclosingType.constructorScope:f.scopeType?f.scopeType.containedScope:f.type?f.type.containedScope:null},i.scopeStartAST=t)}r.options.goChildren=!0}else r.options.goChildren=!1;return t}function a(t,n,i,s,o){var a=new r(t,n,i,s,o);return e.getAstWalkerFactory().walk(n,u,null,null,a),a.scopeStartAST===null?null:a}var t=function(){function e(e,t){this.scopeChain=e,this.checker=t,this.script=null}return e}();e.TypeCollectionContext=t;var n=function(){function t(t,n,r){this.flow=t,this.pos=n,this.matchFlag=r,this.type=null,this.ast=null,this.options=new e.AstWalkOptions}return t}();e.MemberScopeContext=n;var r=function(){function t(e,t,n,r,i){this.logger=e,this.script=t,this.text=n,this.pos=r,this.isMemberCompletion=i,this.scopeGetter=null,this.objectLiteralScopeGetter=null,this.scopeStartAST=null,this.skipNextFuncDeclForClass=!1,this.deepestModuleDecl=null,this.enclosingClassDecl=null,this.enclosingObjectLit=null,this.publicsOnly=!0,this.useFullAst=!1}return t.prototype.getScope=function(){return this.scopeGetter()},t.prototype.getObjectLiteralScope=function(){return this.objectLiteralScopeGetter()},t.prototype.getScopeAST=function(){return this.scopeStartAST},t.prototype.getScopePosition=function(){return this.scopeStartAST.minChar},t.prototype.getScriptFragmentStartAST=function(){return this.scopeStartAST},t.prototype.getScriptFragmentPosition=function(){return this.getScriptFragmentStartAST().minChar},t.prototype.getScriptFragment=function(){if(this.scriptFragment==null){var t=this.getScriptFragmentStartAST(),n=t.minChar,r=this.isMemberCompletion?this.pos:this.pos+1;this.scriptFragment=e.quickParse(this.logger,t,this.text,n,r,null).Script}return this.scriptFragment},t}();e.EnclosingScopeContext=r,e.preFindMemberScope=i,e.pushTypeCollectionScope=s,e.popTypeCollectionScope=o,e.preFindEnclosingScope=u,e.findEnclosingScopeAt=a})(TypeScript||(TypeScript={}));var TypeScript;(function(e){var t=function(){function t(){this.hasVariableArgList=!1,this.parameters=null,this.declAST=null,this.typeCheckStatus=e.TypeCheckStatus.NotStarted,this.nonOptionalParameterCount=0}return t.prototype.specializeType=function(n,r,i){var s=new t;this.hasVariableArgList&&(s.hasVariableArgList=!0),s.returnType=new e.TypeLink,this.returnType.type?s.returnType.type=this.returnType.type.specializeType(n,r,i,!1):s.returnType.type=i.anyType;if(this.parameters){s.parameters=[];for(var o=0,u=this.parameters.length;o1&&(n=!1);for(var o=0;o1&&this.signatures[o]==this.definitionSignature)continue;this.flags&e.SignatureFlags.IsIndexer?i[o]=this.signatures[o].toStringHelper(n,!0,r):i[o]=t+this.signatures[o].toStringHelper(n,!1,r)}return i},t.prototype.specializeType=function(e,n,r){var i=new t;if(this.signatures)for(var s=0,o=this.signatures.length;s0)for(var r=0;r0){for(var s=0;s=n.declAST.limChar:!1}function r(e,t){while(e.container){if(e==t||n(e.container,t))return!0;e=e.container}return!1}(function(e){e._map=[],e._map[0]="NotStarted",e.NotStarted=0,e._map[1]="Started",e.Started=1,e._map[2]="Finished",e.Finished=2})(e.TypeCheckStatus||(e.TypeCheckStatus={}));var t=e.TypeCheckStatus;e.aLexicallyEnclosesB=n,e.aEnclosesB=r;var i=function(){function t(t,n,r){this.name=t,this.location=n,this.unitIndex=r,this.bound=!1,this.flags=e.SymbolFlags.None,this.isObjectLitField=!1,this.declAST=null,this.declModule=null,this.passSymbolCreated=e.CompilerDiagnostics.analysisPass}return t.prototype.instanceScope=function(){return null},t.prototype.isVariable=function(){return!1},t.prototype.isMember=function(){return!1},t.prototype.isInferenceSymbol=function(){return!1},t.prototype.isWith=function(){return!1},t.prototype.writeable=function(){return!1},t.prototype.isType=function(){return!1},t.prototype.getType=function(){return null},t.prototype.isAccessor=function(){return!1},t.prototype.isInstanceProperty=function(){return e.hasFlag(this.flags,e.SymbolFlags.Property)&&!e.hasFlag(this.flags,e.SymbolFlags.ModuleMember)},t.prototype.getTypeName=function(e){return this.toString()},t.prototype.getOptionalNameString=function(){return e.hasFlag(this.flags,e.SymbolFlags.Optional)?"?":""},t.prototype.pathToRoot=function(){var t=new Array,n=this;while(n&&n.name!=e.globalId)t[t.length]=n,n=n.container;return t},t.prototype.findCommonAncestorPath=function(e){if(this.container==null)return new Array;var t=this.container.pathToRoot(),n;e?n=e.pathToRoot():n=new Array;var r=-1;for(var i=0,s=t.length;i=0)break}return r>=0?t.slice(0,r):t},t.prototype.scopeRelativeName=function(e){if(e==null)return this.name;var t=this.findCommonAncestorPath(e.container),n="";for(var r=0,i=t.length;r>=",e.ErrorRecoverySet.BinOp),s(t.AsgRs2,r.None,n.Asg,e.NodeType.AsgRs2,n.No,e.NodeType.None,">>>=",e.ErrorRecoverySet.BinOp),s(t.QMark,r.None,n.Que,e.NodeType.QMark,n.No,e.NodeType.None,"?",e.ErrorRecoverySet.BinOp),s(t.Colon,r.None,n.No,e.NodeType.None,n.No,e.NodeType.None,":",e.ErrorRecoverySet.Colon),s(t.LogOr,r.None,n.Lor,e.NodeType.LogOr,n.No,e.NodeType.None,"||",e.ErrorRecoverySet.BinOp),s(t.LogAnd,r.None,n.Lan,e.NodeType.LogAnd,n.No,e.NodeType.None,"&&",e.ErrorRecoverySet.BinOp),s(t.Or,r.None,n.Bor,e.NodeType.Or,n.No,e.NodeType.None,"|",e.ErrorRecoverySet.BinOp),s(t.Xor,r.None,n.Xor,e.NodeType.Xor,n.No,e.NodeType.None,"^",e.ErrorRecoverySet.BinOp),s(t.And,r.None,n.Ban,e.NodeType.And,n.No,e.NodeType.None,"&",e.ErrorRecoverySet.BinOp),s(t.EQ,r.None,n.Equ,e.NodeType.Eq,n.No,e.NodeType.None,"==",e.ErrorRecoverySet.BinOp),s(t.NE,r.None,n.Equ,e.NodeType.Ne,n.No,e.NodeType.None,"!=",e.ErrorRecoverySet.BinOp),s(t.Eqv,r.None,n.Equ,e.NodeType.Eqv,n.No,e.NodeType.None,"===",e.ErrorRecoverySet.BinOp),s(t.NEqv,r.None,n.Equ,e.NodeType.NEqv,n.No,e.NodeType.None,"!==",e.ErrorRecoverySet.BinOp),s(t.LT,r.None,n.Cmp,e.NodeType.Lt,n.No,e.NodeType.None,"<",e.ErrorRecoverySet.BinOp),s(t.LE,r.None,n.Cmp,e.NodeType.Le,n.No,e.NodeType.None,"<=",e.ErrorRecoverySet.BinOp),s(t.GT,r.None,n.Cmp,e.NodeType.Gt,n.No,e.NodeType.None,">",e.ErrorRecoverySet.BinOp),s(t.GE,r.None,n.Cmp,e.NodeType.Ge,n.No,e.NodeType.None,">=",e.ErrorRecoverySet.BinOp),s(t.Lsh,r.None,n.Shf,e.NodeType.Lsh,n.No,e.NodeType.None,"<<",e.ErrorRecoverySet.BinOp),s(t.Rsh,r.None,n.Shf,e.NodeType.Rsh,n.No,e.NodeType.None,">>",e.ErrorRecoverySet.BinOp),s(t.Rs2,r.None,n.Shf,e.NodeType.Rs2,n.No,e.NodeType.None,">>>",e.ErrorRecoverySet.BinOp),s(t.Add,r.None,n.Add,e.NodeType.Add,n.Uni,e.NodeType.Pos,"+",e.ErrorRecoverySet.AddOp),s(t.Sub,r.None,n.Add,e.NodeType.Sub,n.Uni,e.NodeType.Neg,"-",e.ErrorRecoverySet.AddOp),s(t.Mult,r.None,n.Mul,e.NodeType.Mul,n.No,e.NodeType.None,"*",e.ErrorRecoverySet.BinOp),s(t.Div,r.None,n.Mul,e.NodeType.Div,n.No,e.NodeType.None,"/",e.ErrorRecoverySet.BinOp),s(t.Pct,r.None,n.Mul,e.NodeType.Mod,n.No,e.NodeType.None,"%",e.ErrorRecoverySet.BinOp),s(t.Tilde,r.None,n.No,e.NodeType.None,n.Uni,e.NodeType.Not,"~",e.ErrorRecoverySet.PreOp),s(t.Bang,r.None,n.No,e.NodeType.None,n.Uni,e.NodeType.LogNot,"!",e.ErrorRecoverySet.PreOp),s(t.Inc,r.None,n.No,e.NodeType.None,n.Uni,e.NodeType.IncPre,"++",e.ErrorRecoverySet.PreOp),s(t.Dec,r.None,n.No,e.NodeType.None,n.Uni,e.NodeType.DecPre,"--",e.ErrorRecoverySet.PreOp),s(t.LParen,r.None,n.No,e.NodeType.None,n.No,e.NodeType.None,"(",e.ErrorRecoverySet.LParen),s(t.LBrack,r.None,n.No,e.NodeType.None,n.No,e.NodeType.None,"[",e.ErrorRecoverySet.LBrack),s(t.Dot,r.None,n.Uni,e.NodeType.None,n.No,e.NodeType.None,".",e.ErrorRecoverySet.Dot),s(t.EOF,r.None,n.No,e.NodeType.None,n.No,e.NodeType.None,"",e.ErrorRecoverySet.EOF),s(t.Arrow,r.None,n.No,e.NodeType.None,n.No,e.NodeType.None,"=>",e.ErrorRecoverySet.None),e.lookupToken=o,function(e){e._map=[],e._map[0]="Punctuation",e.Punctuation=0,e._map[1]="Keyword",e.Keyword=1,e._map[2]="Operator",e.Operator=2,e._map[3]="Comment",e.Comment=3,e._map[4]="Whitespace",e.Whitespace=4,e._map[5]="Identifier",e.Identifier=5,e._map[6]="Literal",e.Literal=6}(e.TokenClass||(e.TokenClass={}));var u=e.TokenClass,a=function(){function e(e,t,n){this.tok=e,this.minChar=t,this.limChar=n}return e}();e.SavedToken=a;var f=function(){function n(e){this.tokenId=e}return n.prototype.toString=function(){return"token: "+this.tokenId+" "+this.getText()+" ("+t._map[this.tokenId]+")"},n.prototype.print=function(e,t){t.WriteLine(this.toString()+",on line"+e)},n.prototype.getText=function(){return e.tokenTable[this.tokenId].text},n.prototype.classification=function(){if(this.tokenId<=t.LimKeyword)return u.Keyword;var n=o(this.tokenId);if(n!=undefined)if(n.unopNodeType!=e.NodeType.None||n.binopNodeType!=e.NodeType.None)return u.Operator;return u.Punctuation},n}();e.Token=f;var l=function(e){function n(n){e.call(this,t.NumberLit),this.value=n}return __extends(n,e),n.prototype.getText=function(){return this.value.toString()},n.prototype.classification=function(){return u.Literal},n}(f);e.NumberToken=l;var c=function(e){function n(t,n){e.call(this,t),this.value=n,this.tokenId=t}return __extends(n,e),n.prototype.getText=function(){return this.value},n.prototype.classification=function(){return this.tokenId==t.ID?u.Identifier:u.Literal},n}(f);e.StringToken=c;var h=function(e){function t(t,n){e.call(this,t),this.value=n,this.tokenId=t}return __extends(t,e),t.prototype.getText=function(){return this.value},t.prototype.classification=function(){return u.Whitespace},t}(f);e.WhitespaceToken=h;var p=function(e){function t(t,n,r,i,s,o){e.call(this,t),this.value=n,this.isBlock=r,this.startPos=i,this.line=s,this.endsLine=o,this.tokenID=t}return __extends(t,e),t.prototype.getText=function(){return this.value},t.prototype.classification=function(){return u.Comment},t}(f);e.CommentToken=p;var d=function(e){function n(n){e.call(this,t.Regex),this.regex=n}return __extends(n,e),n.prototype.getText=function(){return this.regex.toString()},n.prototype.classification=function(){return u.Literal},n}(f);e.RegexToken=d,e.staticTokens=new Array,e.initializeStaticTokens=v})(TypeScript||(TypeScript={}));var TypeScript;(function(e){var t=function(){function e(){this.arrayBase=null}return e.prototype.specialize=function(e,t){return this.arrayBase==null&&(this.arrayBase=e.specializeType(t.wildElm.type,this.arrayType.elementType,t,!0)),this.arrayBase},e}();e.ArrayCache=t;var n=function(){function t(){this.onlyCaptureFirstError=!1,this.flags=e.TypeRelationshipFlags.SuccessfulComparison,this.message=""}return t.prototype.addMessageToFront=function(e){this.onlyCaptureFirstError?this.setMessage(e):this.message=this.message?e+":\n "+this.message:e},t.prototype.setMessage=function(e){this.message=e},t}();e.TypeComparisonInfo=n,function(e){e._map=[],e._map[0]="Resident",e.Resident=0,e._map[1]="Transient",e.Transient=1}(e.TypeCheckCollectionMode||(e.TypeCheckCollectionMode={}));var r=e.TypeCheckCollectionMode,i=function(){function t(t){this.errorReporter=t,this.importedGlobalsTable=new e.ScopedMembers(new e.DualStringHashTable(new e.StringHashTable,new e.StringHashTable)),this.importedGlobalsTypeTable=new e.ScopedMembers(new e.DualStringHashTable(new e.StringHashTable,new e.StringHashTable)),this.globals=null,this.globalTypes=null,this.ambientGlobals=null,this.ambientGlobalTypes=null,this.residentGlobalValues=new e.StringHashTable,this.residentGlobalTypes=new e.StringHashTable,this.residentGlobalAmbientValues=new e.StringHashTable,this.residentGlobalAmbientTypes=new e.StringHashTable,this.residentTypeCheck=!0,this.mod=null,this.gloMod=null,this.wildElm=null,this.importedGlobals=new e.SymbolScopeBuilder(null,this.importedGlobalsTable,null,this.importedGlobalsTypeTable,null,null),this.dualGlobalValues=new e.DualStringHashTable(this.residentGlobalValues,new e.StringHashTable),this.dualGlobalTypes=new e.DualStringHashTable(this.residentGlobalTypes,new e.StringHashTable),this.dualAmbientGlobalValues=new e.DualStringHashTable(this.residentGlobalAmbientValues,new e.StringHashTable),this.dualAmbientGlobalTypes=new e.DualStringHashTable(this.residentGlobalAmbientTypes,new e.StringHashTable);var n=new e.ScopedMembers(new e.DualStringHashTable(this.dualGlobalValues,new e.StringHashTable)),i=new e.ScopedMembers(new e.DualStringHashTable(this.dualAmbientGlobalValues,new e.StringHashTable)),s=new e.ScopedMembers(new e.DualStringHashTable(this.dualGlobalTypes,new e.StringHashTable)),o=new e.ScopedMembers(new e.DualStringHashTable(this.dualAmbientGlobalTypes,new e.StringHashTable));this.globalScope=new e.SymbolScopeBuilder(n,i,s,o,this.importedGlobals,null),this.voidType=this.enterPrimitive(e.Primitive.Void,"void"),this.booleanType=this.enterPrimitive(e.Primitive.Boolean,"bool"),this.doubleType=this.enterPrimitive(e.Primitive.Double,"number"),this.importedGlobals.ambientEnclosedTypes.addPublicMember("number",this.doubleType.symbol),this.stringType=this.enterPrimitive(e.Primitive.String,"string"),this.anyType=this.enterPrimitive(e.Primitive.Any,"any"),this.nullType=this.enterPrimitive(e.Primitive.Null,"null"),this.undefinedType=this.enterPrimitive(e.Primitive.Undefined,"undefined"),this.setCollectionMode(r.Resident),this.wildElm=new e.TypeSymbol("_element",0,-1,new e.Type),this.importedGlobalsTypeTable.addPublicMember(this.wildElm.name,this.wildElm),this.mod=new e.ModuleType(s,o),this.mod.members=n,this.mod.ambientMembers=i,this.mod.containedScope=this.globalScope,this.gloMod=new e.TypeSymbol(e.globalId,0,-1,this.mod),this.mod.members.addPublicMember(this.gloMod.name,this.gloMod),this.defineGlobalValue("undefined",this.undefinedType)}return t.prototype.enterPrimitive=function(t,n){var r=new e.Type;r.primitiveTypeClass=t;var i=new e.TypeSymbol(n,0,-1,r);return i.typeCheckStatus=e.TypeCheckStatus.Finished,r.symbol=i,this.importedGlobals.enter(null,null,i,this.errorReporter,!0,!0,!0),r},t.prototype.setCollectionMode=function(e){this.residentTypeCheck=this.dualGlobalValues.insertPrimary=this.dualGlobalTypes.insertPrimary=this.dualAmbientGlobalValues.insertPrimary=this.dualAmbientGlobalTypes.insertPrimary=e==r.Resident},t.prototype.refreshPersistentState=function(){this.globals=new e.StringHashTable,this.globalTypes=new e.StringHashTable,this.ambientGlobals=new e.StringHashTable,this.ambientGlobalTypes=new e.StringHashTable,this.dualGlobalValues.secondaryTable=this.globals,this.dualGlobalTypes.secondaryTable=this.globalTypes,this.dualAmbientGlobalValues.secondaryTable=this.ambientGlobals,this.dualAmbientGlobalTypes.secondaryTable=this.ambientGlobalTypes},t.prototype.defineGlobalValue=function(t,n){var r=new e.ValueLocation;r.typeLink=new e.TypeLink;var i=new e.VariableSymbol(t,0,-1,r);i.setType(n),i.typeCheckStatus=e.TypeCheckStatus.Finished,i.container=this.gloMod,this.importedGlobalsTable.addPublicMember(t,i)},t}();e.PersistentGlobalTypeState=i;var s=function(){function e(e,t,n){this.contextualType=e,this.provisional=t,this.contextID=n,this.targetSig=null,this.targetThis=null,this.targetAccessorType=null}return e}();e.ContextualTypeContext=s;var o=function(){function t(e){this.checker=e,this.contextStack=[],this.hadProvisionalErrors=!1}return t.contextID=e.TypeCheckStatus.Finished+1,t.prototype.pushContextualType=function(e,n){this.contextStack.push(new s(e,n,t.contextID++)),this.checker.errorReporter.pushToErrorSink=n},t.prototype.popContextualType=function(){var e=this.contextStack.pop();return this.checker.errorReporter.pushToErrorSink=this.isProvisional(),this.hadProvisionalErrors=this.hadProvisionalErrors||e.provisional&&this.checker.errorReporter.getCapturedErrors().length,this.checker.errorReporter.freeCapturedErrors(),e},t.prototype.getContextualType=function(){return this.contextStack.length?this.contextStack[this.contextStack.length-1]:null},t.prototype.getContextID=function(){return this.contextStack.length?this.contextStack[this.contextStack.length-1].contextID:e.TypeCheckStatus.Finished},t.prototype.isProvisional=function(){return this.contextStack.length?this.contextStack[this.contextStack.length-1].provisional:!1},t}();e.ContextualTypingContextStack=o;var u=function(){function n(e){this.persistentState=e,this.errorReporter=null,this.checkControlFlow=!1,this.printControlFlowGraph=!1,this.checkControlFlowUseDef=!1,this.styleSettings=null,this.units=null,this.anon="_anonymous",this.locationInfo=null,this.typeFlow=null,this.currentCompareA=null,this.currentCompareB=null,this.currentModDecl=null,this.inBind=!1,this.inWith=!1,this.errorsOnWith=!0,this.currentContextualTypeContext=null,this.resolvingBases=!1,this.canCallDefinitionSignature=!1,this.assignableCache={},this.subtypeCache={},this.identicalCache={},this.provisionalStartedTypecheckObjects=[],this.voidType=this.persistentState.voidType,this.booleanType=this.persistentState.booleanType,this.numberType=this.persistentState.doubleType,this.stringType=this.persistentState.stringType,this.anyType=this.persistentState.anyType,this.nullType=this.persistentState.nullType,this.undefinedType=this.persistentState.undefinedType,this.globals=this.persistentState.dualGlobalValues,this.globalTypes=this.persistentState.dualGlobalTypes,this.ambientGlobals=this.persistentState.dualAmbientGlobalValues,this.ambientGlobalTypes=this.persistentState.dualAmbientGlobalTypes,this.gloModType=this.persistentState.mod,this.gloMod=this.persistentState.gloMod,this.wildElm=this.persistentState.wildElm,this.globalScope=this.persistentState.globalScope,this.typingContextStack=new o(this)}return n.prototype.setStyleOptions=function(e){this.styleSettings=e},n.prototype.setContextualType=function(e,t){this.typingContextStack.pushContextualType(e,t),this.currentContextualTypeContext=this.typingContextStack.getContextualType()},n.prototype.unsetContextualType=function(){var e=this.typingContextStack.popContextualType();return this.currentContextualTypeContext=this.typingContextStack.getContextualType(),e},n.prototype.hadProvisionalErrors=function(){return this.typingContextStack.hadProvisionalErrors},n.prototype.resetProvisionalErrors=function(){this.typingContextStack.getContextualType()||(this.typingContextStack.hadProvisionalErrors=!1)},n.prototype.typeCheckWithContextualType=function(e,t,n,r){n&&this.setContextualType(e,this.typingContextStack.isProvisional()||t),this.typeFlow.typeCheck(r),n&&this.unsetContextualType()},n.prototype.resetTargetType=function(){this.currentContextualTypeContext=this.typingContextStack.getContextualType()},n.prototype.killTargetType=function(){this.currentContextualTypeContext=null,this.errorReporter.pushToErrorSink=!1},n.prototype.hasTargetType=function(){return this.currentContextualTypeContext&&this.currentContextualTypeContext.contextualType},n.prototype.getTargetTypeContext=function(){return this.currentContextualTypeContext},n.prototype.inProvisionalTypecheckMode=function(){return this.typingContextStack.isProvisional()},n.prototype.getTypeCheckFinishedStatus=function(){return this.inProvisionalTypecheckMode()?this.typingContextStack.getContextID():e.TypeCheckStatus.Finished},n.prototype.typeStatusIsFinished=function(t){return t==e.TypeCheckStatus.Finished||this.inProvisionalTypecheckMode()&&t==this.typingContextStack.getContextID()},n.prototype.addStartedPTO=function(e){this.inProvisionalTypecheckMode()&&(this.provisionalStartedTypecheckObjects[this.provisionalStartedTypecheckObjects.length]=e)},n.prototype.cleanStartedPTO=function(){for(var t=0;t0){r=new e.ScopedMembers(new e.DualStringHashTable(new e.StringHashTable,new e.StringHashTable)),i=new e.SymbolScopeBuilder(r,null,null,null,null,n);for(var a=0;a0;S--)n.type=this.makeArrayType(n.type);r&&n.type==null&&(n.type=this.anyType),n.ast&&(n.ast.type=n.type)}},n.prototype.findMostApplicableSignature=function(e,t){if(e.length==1)return{sig:e[0].signature,ambiguous:!1};var n=e[0],r=null,i=null,s=null,o=null,u=!1;for(var a=1;a=t[f].parameters.length)continue;s=t[f].parameters[l].getType(),t[f].declAST.variableArgList&&l>=t[f].nonOptionalParameterCount-1&&s.isArray()&&(s=s.elementType);if(s==this.anyType)continue;if(n.members[l].nodeType==e.NodeType.FuncDecl){if(this.typeFlow.functionInterfaceType&&s==this.typeFlow.functionInterfaceType)continue;if(!this.canContextuallyTypeFunction(s,n.members[l],!0)){if(!this.canContextuallyTypeFunction(s,n.members[l],!1))break;this.typeFlow.typeCheck(n.members[l]);if(!this.sourceIsAssignableToTarget(n.members[l].type,s,r))break}else{this.typeCheckWithContextualType(s,!0,!0,n.members[l]),this.cleanStartedPTO(),a=this.hadProvisionalErrors(),this.sourceIsAssignableToTarget(n.members[l].type,s,r)||(r&&r.setMessage("Could not apply type '"+s.getTypeName()+"' to argument "+(l+1)+", which is of type '"+n.members[l].type.getTypeName()+"'"),o=!0),a&&(u=this.currentContextualTypeContext,this.typeCheckWithContextualType(null,!0,!0,n.members[l]),this.sourceIsAssignableToTarget(n.members[l].type,s)||(o=!0),this.cleanStartedPTO()),this.resetProvisionalErrors();if(o)break}}else if(n.members[l].nodeType==e.NodeType.ObjectLit){if(this.typeFlow.objectInterfaceType&&s==this.typeFlow.objectInterfaceType)continue;this.typeCheckWithContextualType(s,!0,!0,n.members[l]),this.cleanStartedPTO(),a=this.hadProvisionalErrors(),this.sourceIsAssignableToTarget(n.members[l].type,s,r)||(r&&r.setMessage("Could not apply type '"+s.getTypeName()+"' to argument "+(l+1)+", which is of type '"+n.members[l].type.getTypeName()+"'"),o=!0),a&&(this.typeCheckWithContextualType(null,!0,!0,n.members[l]),this.sourceIsAssignableToTarget(n.members[l].type,s)||(o=!0),this.cleanStartedPTO()),this.resetProvisionalErrors();if(o)break}else if(n.members[l].nodeType==e.NodeType.ArrayLit){if(this.typeFlow.arrayInterfaceType&&s==this.typeFlow.arrayInterfaceType)continue;this.typeCheckWithContextualType(s,!0,!0,n.members[l]),this.cleanStartedPTO(),a=this.hadProvisionalErrors();if(!this.sourceIsAssignableToTarget(n.members[l].type,s,r)){r&&r.setMessage("Could not apply type '"+s.getTypeName()+"' to argument "+(l+1)+", which is of type '"+n.members[l].type.getTypeName()+"'");break}a&&(this.typeCheckWithContextualType(null,!0,!0,n.members[l]),this.sourceIsAssignableToTarget(n.members[l].type,s)||(o=!0),this.cleanStartedPTO()),this.resetProvisionalErrors();if(o)break}}l==n.members.length&&(i[i.length]={signature:t[f],hadProvisionalErrors:a}),a=!1}return i},n.prototype.canContextuallyTypeFunction=function(e,t,n){if(t.isParenthesized||t.isMethod()||n&&t.returnTypeAnnotation||t.isInlineCallLiteral)return!1;n=n||this.typeFlow.functionInterfaceType==e;if(!n)return!0;t.signature||(this.createFunctionSignature(t,this.typeFlow.scope.container,this.typeFlow.scope,null,null),this.typeFlow.typeCheck(t));var r=t.signature,i=r.parameters.length;for(var s=0;s1?!1:!0},n.prototype.canContextuallyTypeObjectLiteral=function(t,n){if(t==this.typeFlow.objectInterfaceType)return!0;var r=n.operand;if(!r||!t.memberScope)return!1;var i=null,s=null,o="",u={};for(var a=0;ao&&!n.hasVariableArgList)return s&&(s.flags|=e.TypeRelationshipFlags.SourceSignatureHasTooManyParameters,s.addMessageToFront("Call signature expects "+o+" or fewer parameters")),!1;var a=t.returnType.type,f=n.returnType.type;if(f!=this.voidType&&!this.sourceIsRelatableToTarget(a,f,r,i,s))return s&&(s.flags|=e.TypeRelationshipFlags.IncompatibleReturnTypes),!1;var l=u=e.NodeType.Asg&&t.nodeType<=e.NodeType.LastAsg){var a=t;if(a.operand1&&a.operand1.nodeType==e.NodeType.Name){var l=a.operand1;r(l.sym,o)}}else t.nodeType==e.NodeType.FuncDecl&&(s.options.goChildren=!1);return t}var n=this,r=function(e,t){if(t.isLocalSym(e)){var r=t.getSymbolIndex(e);n.useIndexBySymbol[r]=new Array,n.defsBySymbol[r]=!0}},i=function(e,t,r){if(t.isLocalSym(e)){var i=t.getSymbolIndex(e);n.useIndexBySymbol[i]==undefined&&(n.useIndexBySymbol[i]=new Array);var s=n.useIndexBySymbol[i],o=t.getUseIndex(r);t.addUse(i,o),s.push(o)}},o=new e.AstWalkOptions;o.reverseSiblings=!0,e.getAstWalkerFactory().walk(this.bb.content,s,null,o,t)},t.prototype.initializeGen=function(e){var t=this.useIndexBySymbol.length,n=e.uses.length;this.gen=new i(n);for(var r=0;r0)for(var o=0,u=s.length;oe.packBits){this.restOfBits=new Array;var n=Math.floor(this.bitCount/e.packBits);for(var r=0;re},t.prototype.mark=function(){this.markValue++},t.prototype.addSuccessor=function(e){this.successors[this.successors.length]=e,e.predecessors[e.predecessors.length]=this},t}();e.BasicBlock=s;var o=function(){function t(e,t){this.current=e,this.exit=t,this.entry=null,this.unreachable=null,this.noContinuation=!1,this.statementStack=new Array,this.currentSwitch=new Array,this.markBase=0,this.linearBBs=new Array,this.entry=this.current}return t.prototype.walk=function(e,t){return this.walker.walk(e,t)},t.prototype.pushSwitch=function(e){this.currentSwitch.push(e)},t.prototype.popSwitch=function(){return this.currentSwitch.pop()},t.prototype.reportUnreachable=function(t){if(this.unreachable&&this.unreachable.length>0){var n=this.unreachable.length;for(var r=0;r0){var o=s.pop();if(!o.marked(i)){o.mark(),e&&e(o);var u=o.successors.length;if(u>0){n&&n();for(var a=u-1;a>=0;a--){var f=o.successors[a];f.marked(this.markBase)||(t&&t(o,f),s[s.length]=f)}r&&r()}}}},t.prototype.useDef=function(e,t){var i=this,s=new r;s.func=t;var o=function(e){e.useDef=new n(e),e.useDef.initialize(s),i.linearBBs[i.linearBBs.length]=e};this.bfs(o,null,null,null);var u,a;for(u=0,a=this.linearBBs.length;u=0&&n.unitIndex=0&&t.unitIndex=d.length-1?d[d.length-1].getType().elementType:d[P].getType(),j.sym.setType(j.type),j.sym.typeCheckStatus=this.checker.getTypeCheckFinishedStatus()}else this.typeCheck(j);g&&y&&(j=this.cast(j,y)),B.container=f,D.publicMembers.add(B.name,B)}this.scope=k}else{this.typeCheck(t.args);for(var P=0;P1?this.checker.errorReporter.simpleError(t,"Index signatures may take only one parameter"):t.args.members[0].type==this.checker.numberType?n.index.flags|=e.SignatureFlags.IsNumberIndexer:t.args.members[0].type==this.checker.stringType?n.index.flags|=e.SignatureFlags.IsStringIndexer:this.checker.errorReporter.simpleError(t,"Index signatures may only take 'string' or 'number' as their parameter"))}if(t.bod&&!t.isSignature()){if(!t.isConstructor)this.addFormals(f,i,h);else{this.addConstructorLocalArgs(t.type.symbol,t.args,h,e.hasFlag(t.fncFlags,e.FncFlags.ClassMethod));if(this.thisClassNode&&this.thisClassNode.extendsList){var I=this.scope,q=new e.ScopedMembers(h);this.scope=new e.FilteredSymbolScopeBuilder(q,s,t.type.symbol,function(t){return t.kind()==e.SymbolKind.Parameter}),this.typeCheckBaseCalls(this.thisClassNode.extendsList),this.scope=I}}var R=this.checker.currentModDecl;t.type&&t.type.symbol&&!t.isMethod()&&t.type.symbol.declModule&&(this.checker.currentModDecl=t.type.symbol.declModule),this.typeCheck(t.bod),this.checker.currentModDecl=R;if(this.checker.checkControlFlow){var U=t.buildControlFlow();this.checker.printControlFlowGraph&&U.print(this.checker.errorReporter.outfile),U.reportUnreachable(this.checker.errorReporter),this.checker.checkControlFlowUseDef&&U.useDef(this.checker.errorReporter,t.type.symbol)}if(t.isConstructor){var z=t.scopes,W=z.members.length,X,V,$=0;for(;$0){var K={getLength:function(){return t.returnStatementsWithExpressions.length},setTypeAtIndex:function(e,n){t.returnStatementsWithExpressions[e].type=n},getTypeAtIndex:function(e){return t.returnStatementsWithExpressions[e].type}},Q=t.returnStatementsWithExpressions[0].type;Q=this.checker.findBestCommonType(Q,null,K);if(Q)i.returnType.type=this.checker.widenType(Q);else{for(var G=0;G0&&t.bod.members[0].nodeType==e.NodeType.Throw;Y||this.checker.errorReporter.simpleError(t,"Function declared a non-void return type, but has no return expression")}p&&this.checker.unsetContextualType();if(t.accessorSymbol){var y=t.accessorSymbol.getType();y?(e.hasFlag(t.fncFlags,e.FncFlags.GetAccessor)&&y!=i.returnType.type||t.args.members.length>0&&y!=t.args.members[0].type)&&this.checker.errorReporter.simpleError(t,"Getter and setter types do not agree"):e.hasFlag(t.fncFlags,e.FncFlags.GetAccessor)?t.accessorSymbol.setType(i.returnType.type):t.args.members.length!=1?this.checker.errorReporter.simpleError(t,"Setters may have one and only one argument"):t.accessorSymbol.setType(t.args.members[0].type)}return this.typeCheckOverloadSignatures(n,t),t},n.prototype.typeCheckBases=function(t){var n=!1,r=t.extendsList;if(r){var i=r.length;this.inNewTargetTypeCheck=!0,i>0&&(t.typeFlags|=e.TypeFlags.HasBaseType);for(var s=0;s0){var o=new e.StringHashTable;if(i.isClassInstance())for(var u=0;u0);i.members&&i.members.publicMembers.map(function(t,o,u){var a=o;for(var f=0;f=e.NodeType.Asg&&t.nodeType<=e.NodeType.LastAsg&&this.checker.errorReporter.simpleError(t,"top-level assignment statement in conditional expression")},n.prototype.typeCheckCompoundStmtBlock=function(t,n){this.checker.styleSettings.blockInCompoundStmt&&t&&t.nodeType!=e.NodeType.Block&&this.checker.errorReporter.styleError(t,n+" requires a block")},n.prototype.typeCheckIf=function(e){return e.cond=this.typeCheck(e.cond),this.typeCheckCondExpr(e.cond),e.thenBod=this.typeCheck(e.thenBod),e.elseBod=this.typeCheck(e.elseBod),this.typeCheckCompoundStmtBlock(e.thenBod,"if statement"),this.typeCheckCompoundStmtBlock(e.elseBod,"if statement"),e.type=this.voidType,e},n.prototype.typeFromAccessorFuncDecl=function(t){return t.isAccessor()?e.hasFlag(t.fncFlags,e.FncFlags.GetAccessor)?t.type.call.signatures[0].returnType.type:t.type.call.signatures[0].parameters[0].getType():null},n.prototype.typeCheckObjectLit=function(t){var n=new e.Type;n.symbol=new e.TypeSymbol(this.checker.anon,t.minChar,this.checker.locationInfo.unitIndex,n),n.members=new e.ScopedMembers(new e.DualStringHashTable(new e.StringHashTable,new e.StringHashTable)),n.memberScope=new e.SymbolTableScope(n.members,null,null,null,null);var r=new e.SymbolAggregateScope(n.symbol);r.addParentScope(n.memberScope),r.addParentScope(this.scope),n.containedScope=r;var i=t.operand,s=this.thisType,o=!1,u=null;this.checker.hasTargetType()&&(u=this.checker.getTargetTypeContext().contextualType,u&&u.symbol&&!this.checker.typeStatusIsFinished(u.symbol.typeCheckStatus)&&u.symbol.declAST&&this.typeCheck(u.symbol.declAST),o=!0);if(i)for(var a=0,f=i.members.length;a0)for(var n=0;n=s&&(e.hasVariableArgList||t.length<=o)&&(u=e.hasVariableArgList?e.parameters.length:t.length,a=!0);var f=null;if(a||e.hasVariableArgList){e.hasVariableArgList&&(u-=1,f=e.parameters[u].parameter.typeLink.type,f=f.elementType,a=t.length>=u);var l=t.length,c=a,h=a;for(var p=0;p1,f=new e.TypeComparisonInfo,l=null,c=null;if(t.nodeType==e.NodeType.Call||t.nodeType==e.NodeType.New){var h=t;l=h.args,c=h.target;if(h.args){var p=h.args.members.length;for(var d=0;d0){var w=this.checker.findMostApplicableSignature(b,l);w.ambiguous&&this.checker.errorReporter.simpleError(c,"Ambiguous call expression - could not choose overload"),u=w.sig}else{var E="Supplied parameters do not match any signature of call target";f.message?this.checker.errorReporter.simpleError(c,E+":\n "+f.message):this.checker.errorReporter.simpleError(c,E)}}else if(s.length>1){var S=[];for(var d=0;d=i.nonOptionalParameterCount){n=!0;var s=null,o=t.args.members.length=i.nonOptionalParameterCount-1&&(s=s.elementType);switch(t.args.members[r].nodeType){case e.NodeType.FuncDecl:case e.NodeType.ObjectLit:case e.NodeType.ArrayLit:this.checker.typeCheckWithContextualType(s,this.checker.inProvisionalTypecheckMode(),!i.parameters[r].declAST.isParenthesized,t.args.members[r]);break;default:continue}}}}if(!n&&t.args){this.checker.killTargetType();for(r=0;r0?this.extendsList[0]:null},r.prototype.getArrayBase=function(e,t){return this.arrayCache.specialize(e,t)},r.prototype.isClass=function(){return this.instanceType!=null},r.prototype.isArray=function(){return this.elementType!=null},r.prototype.isClassInstance=function(){return this.symbol&&!this.elementType&&this.symbol.type.isClass()},r.prototype.getInstanceType=function(){return this.isClass()?this.instanceType:this},r.prototype.hasImplementation=function(){return e.hasFlag(this.typeFlags,e.TypeFlags.HasImplementation)},r.prototype.setHasImplementation=function(){this.typeFlags|=e.TypeFlags.HasImplementation},r.prototype.isDouble=function(){return e.hasFlag(this.primitiveTypeClass,t.Double)},r.prototype.isString=function(){return e.hasFlag(this.primitiveTypeClass,t.String)},r.prototype.isBoolean=function(){return e.hasFlag(this.primitiveTypeClass,t.Boolean)},r.prototype.isNull=function(){return e.hasFlag(this.primitiveTypeClass,t.Null)},r.prototype.getTypeName=function(){return this.getMemberTypeName("",!0,!1,null)},r.prototype.getScopedTypeName=function(e){return this.getMemberTypeName("",!0,!1,e)},r.prototype.getScopedTypeNameEx=function(e){return this.getMemberTypeNameEx("",!0,!1,e)},r.prototype.callCount=function(){var e=0;return this.call&&(e+=this.call.signatures.length),this.construct&&(e+=this.construct.signatures.length),this.index&&(e+=this.index.signatures.length),e},r.prototype.getMemberTypeName=function(e,t,n,r){var i=this.getMemberTypeNameEx(e,t,n,r);return i.toString()},r.prototype.getMemberTypeNameEx=function(t,r,s,o){if(this.elementType)return n.create(this.elementType.getMemberTypeNameEx(t,!1,!0,o),"","[]");if(this.symbol&&this.symbol.name&&this.symbol.name!="_anonymous"&&(this.call==null&&this.construct==null&&this.index==null||e.hasFlag(this.typeFlags,e.TypeFlags.BuildingName)||this.members&&!this.isClass())){var u=this.symbol.scopeRelativeName(o);return n.create(u=="null"?"any":u)}if(this.members||this.call||this.construct){if(e.hasFlag(this.typeFlags,e.TypeFlags.BuildingName))return n.create("this");this.typeFlags|=e.TypeFlags.BuildingName;var a="",f=new i,l=s,c=0,h=0,p="; ";this.members&&this.members.allMembers.map(function(t,r,i){var s=r;if(!e.hasFlag(s.flags,e.SymbolFlags.BuiltIn)){var u=s.getTypeName(o);u.length>=p.length&&u.substring(u.length-p.length)==p&&(u=u.substring(0,u.length-p.length)),f.add(n.create(u)),h++;if(s.kind()==e.SymbolKind.Type){var a=s.type;a.callCount()>1&&(l=!0)}else l=!0}},null);var d,v,m=0,g=h==0&&this.callCount()==1&&r;g||(f.delim=p);if(this.call){d=this.call.toStrings(t,g,o);for(v=0,m=d.length;v1&&r)f.prefix="{ ",f.suffix="}";return this.typeFlags&=~e.TypeFlags.BuildingName,c==0&&h==0?n.create("{}"):f}return n.create("{}")},r.prototype.checkDecl=function(e){(this.isClassInstance()||this.isClass())&&this.symbol.declAST&&e.typeFlow.inScopeTypeCheckDecl(this.symbol.declAST)},r.prototype.getMemberScope=function(e){if(this==e.anyType)return null;if(this.isDouble())return e.numberInterfaceType?e.numberInterfaceType.memberScope:null;if(this.isBoolean())return e.booleanInterfaceType?e.booleanInterfaceType.memberScope:null;if(this==e.stringType)return e.stringInterfaceType?e.stringInterfaceType.memberScope:null;if(this.elementType){if(e.arrayInterfaceType){var t=this.elementType.getArrayBase(e.arrayInterfaceType,e.checker);return t.memberScope}return null}return this.memberScope},r.prototype.isReferenceType=function(){return this.members||this.extendsList||this.construct||this.call||this.index||this.elementType},r.prototype.specializeType=function(t,n,i,s){if(t==this)return n;var o=this;return s?this.isReferenceType()&&(o=new r,this.members&&(o.members=new e.ScopedMembers(new e.DualStringHashTable(new e.StringHashTable,new e.StringHashTable)),this.members.publicMembers.map(function(e,r,s){var u=r,a=u.specializeType(t,n,i);o.members.addPublicMember(a.name,a)},null),this.members.privateMembers.map(function(e,r,s){var u=r,a=u.specializeType(t,n,i);o.members.addPrivateMember(a.name,a)},null)),this.ambientMembers&&(o.ambientMembers=new e.ScopedMembers(new e.DualStringHashTable(new e.StringHashTable,new e.StringHashTable)),this.ambientMembers.publicMembers.map(function(e,r,s){var u=r,a=u.specializeType(t,n,i);o.ambientMembers.addPublicMember(a.name,a)},null),this.ambientMembers.privateMembers.map(function(e,r,s){var u=r,a=u.specializeType(t,n,i);o.ambientMembers.addPrivateMember(a.name,a)},null)),o.containedScope=i.scopeOf(o),o.memberScope=o.containedScope):this.elementType?this.elementType==t?o=i.makeArrayType(n):this.elementType.elementType==t&&(o=i.makeArrayType(i.makeArrayType(n))):this.call&&(o=new r,o.call=this.call.specializeType(t,n,i)),o},r.prototype.hasBase=function(e){if(e==this)return!0;if(this.extendsList)for(var t=0,n=this.extendsList.length;t6&&e.substring(e.length-6,e.length)==".d.str"?e.substring(0,e.length-6):e.length>4&&e.substring(e.length-4,e.length)==".str"?e.substring(0,e.length-4):e.length>5&&e.substring(e.length-5,e.length)==".d.ts"?e.substring(0,e.length-5):e.length>3&&e.substring(e.length-3,e.length)==".ts"?e.substring(0,e.length-3):e.length>3&&e.substring(e.length-3,e.length)==".js"?e.substring(0,e.length-3):e}function u(e){return e.length>4&&e.substring(e.length-4,e.length)==".str"}function a(e){return e.length>3&&e.substring(e.length-3,e.length)==".ts"}function f(e){return e.length>6&&e.substring(e.length-6,e.length)==".d.str"}function l(e){return e.length>5&&e.substring(e.length-5,e.length)==".d.ts"}function c(e,n,i){typeof n=="undefined"&&(n=!0),typeof i=="undefined"&&(i=!1);var u=i?s(e):o(t(e)),a=u.split("/");return a.length?n?r(a[a.length-1]):a[a.length-1]:e}function h(e){var n=o(t(e)),i=b(n);if(i=="")return e;var s=n.split(i),u=s.length>1?1:0;return r(s[u])}function p(e){return o(t(e))+".str"}function d(e){return o(t(e))+".d.str"}function v(e){return o(t(e))+".ts"}function m(e){return o(t(e))+".d.ts"}function g(e){return e.charAt(0)=="."}function y(e){return e.charAt(0)=="\\"||e.charAt(0)=="/"||e.indexOf(":\\")!=-1||e.indexOf(":/")!=-1}function b(e){if(e=="")return e;var t=e.indexOf("/")!=-1;return t?w(e):""}function w(e){e=s(e);var t=e.split("/"),n=t.slice(0,t.length-1);return n.join("/")+"/"}function E(e){var t=/^(https?:\/\/[\-\w\.]+(:\d+)?\/)(.*)$/i,n=t.exec(e);if(n){var r=n[1],i=n[3];return r+S(i)}return S(e)}function S(e){e=s(e);var t=e.charAt(0)==="/",n=e.split("/");for(var r=0;r0&&n[r]===".."&&n[r-1]!==".."&&(n.splice(r-1,2),r-=2)}return(t?"/":"")+n.join("/")}function x(e){return S(e)}e.stripQuotes=t,e.isQuoted=n,e.quoteStr=r,e.swapQuotes=i,e.switchToForwardSlashes=s,e.trimModName=o,e.isSTRFile=u,e.isTSFile=a,e.isDSTRFile=f,e.isDTSFile=l,e.getPrettyName=c,e.quoteBaseName=h,e.changePathToSTR=p,e.changePathToDSTR=d,e.changePathToTS=v,e.changePathToDTS=m,e.isRelative=g,e.isRooted=y,e.getRootFilePath=b,e.filePath=w,e.normalizeURL=E,e.pathNormalizeRegExp=/\//g,e.normalizePath=S,e.normalizeImportPath=x})(TypeScript||(TypeScript={}));var TypeScript;(function(e){var t=function(){function e(e,t){this.path=e,this.content=t}return e.prototype.getText=function(e,t){return this.content.substring(e,t)},e.prototype.getLength=function(){return this.content.length},e}();e.SourceUnit=t;var n=function(){function e(e,t){this.compilationSettings=e,this.ioHost=t,this.residentCode=[],this.code=[]}return e}();e.CompilationEnvironment=n;var r=function(){function n(e){this.environment=e,this.visited={}}return n.prototype.resolveCode=function(n,r,i,s){var o={content:"",path:n},u=this.environment.ioHost,a=e.isRelative(n),f=a?!1:e.isRooted(n),l=a?u.resolvePath(r+"/"+n):f||!r||i?n:r+"/"+n;!e.isSTRFile(l)&&!e.isTSFile(l)&&(l+=".ts"),l=e.switchToForwardSlashes(e.stripQuotes(l));var c=this.environment.compilationSettings.useCaseSensitiveFileResolution?l:l.toLocaleUpperCase();if(!this.visited[c]){if(a||f||!i)try{e.CompilerDiagnostics.debugPrint(" Reading code from "+l);try{o.content=u.readFile(l)}catch(h){try{e.isSTRFile(l)?l=e.changePathToTS(l):e.isTSFile(l)&&(l=e.changePathToSTR(l)),e.CompilerDiagnostics.debugPrint(" Reading code from "+l),o.content=u.readFile(l)}catch(h){l=e.changePathToDSTR(l),e.CompilerDiagnostics.debugPrint(" Reading code from "+l);try{o.content=u.readFile(l)}catch(h){l=e.changePathToDTS(l),e.CompilerDiagnostics.debugPrint(" Reading code from "+l),o.content=u.readFile(l)}}}e.CompilerDiagnostics.debugPrint(" Found code at "+l),o.path=l,this.visited[c]=!0}catch(h){e.CompilerDiagnostics.debugPrint(" Did not find code for "+n)}else o=u.findFile(r,l),o||(e.isSTRFile(l)?l=e.changePathToTS(l):e.isTSFile(l)&&(l=e.changePathToSTR(l)),o=u.findFile(r,l)),o||(l=e.changePathToDTS(l),o=u.findFile(r,l),o||(l=e.changePathToDSTR(l),o=u.findFile(r,l))),o?(o.path=e.switchToForwardSlashes(e.stripQuotes(o.path)),e.CompilerDiagnostics.debugPrint(n+" resolved to: "+o.path),o.content=o.content,this.visited[c]=!0):e.CompilerDiagnostics.debugPrint("Could not find "+n);if(o&&o.content){var p=u.dirName(o.path),d=new t(o.path,o.content),v=e.preProcessFile(d,this.environment.compilationSettings);for(var m=0;m/igm,r=n.exec(t);if(r){var i=e.normalizePath(r[3]),s=e.normalizePath(i),o=r.length>=7&&r[6]=="true";return o&&e.CompilerDiagnostics.debugPrint(i+" is resident"),{minChar:0,limChar:0,path:e.switchToForwardSlashes(s),isResident:o}}return null}function i(e){var t=/^(\/\/\/\s*/igm,n=t.exec(e);if(n){var r=n[3];return r}return null}function s(e,t){var n=/^(\/\/\/\s*/igm,r=n.exec(e);if(r){var i=/^([a-zA-Z]+=['"]on['|"])/igm;r=i.exec(r[2]);if(r)for(var s=0;s/igm,b=y.exec(f.getText());b&&(d=b[3]=="true")}}return{settings:c,referencedFiles:h,importedFiles:p,isLibFile:d}}var t=function(){function e(){this.bitwise=!1,this.blockInCompoundStmt=!1,this.eqeqeq=!1,this.forin=!1,this.emptyBlocks=!0,this.newMustBeUsed=!1,this.requireSemi=!1,this.assignmentInCond=!1,this.eqnull=!1,this.evalOK=!0,this.innerScopeDeclEscape=!0,this.funcInLoop=!0,this.reDeclareLocal=!0,this.literalSubscript=!0,this.implicitAny=!1}return e.prototype.setOption=function(e,t){var n=this[e];return n!==undefined?(this[e]=t,!0):!1},e.prototype.parseOptions=function(e){var t=e.split(";");for(var n=0,r=t.length;n=0){var u=i.substring(o+1);i=i.substring(0,o),u=="off"&&(s=!1)}if(!this.setOption(i,s))return!1}return!0},e}();e.StyleSettings=t;var n=function(){function n(){this.styleSettings=new t,this.propagateConstants=!1,this.minWhitespace=!1,this.parseOnly=!1,this.outputMany=!0,this.errorRecovery=!1,this.emitComments=!1,this.watch=!1,this.exec=!1,this.resolve=!0,this.controlFlow=!1,this.printControlFlow=!1,this.controlFlowUseDef=!1,this.errorOnWith=!0,this.preprocess=!0,this.canCallDefinitionSignature=!1,this.inferPropertiesFromThisAssignment=!1,this.useDefaultLib=!0,this.codeGenTarget=e.CodeGenTarget.ES3,this.moduleGenTarget=e.ModuleGenTarget.Synchronous,this.outputFileName="",this.errorFileName="",this.mapSourceFiles=!1,this.generateDeclarationFiles=!1,this.useCaseSensitiveFileResolution=!1}return n.prototype.setStyleOptions=function(e){this.styleSettings.parseOptions(e)},n.prototype.outputOne=function(e){this.outputFileName=e,this.outputMany=!1},n}();e.CompilationSettings=n,e.getAdditionalDependencyPath=i,e.getStyleSettings=s,e.preProcessFile=o})(TypeScript||(TypeScript={}));var TypeScript;(function(e){var t=function(){function t(t){this.logger=t,this.astLogger=new e.AstLogger(this.logger)}return t.prototype.getEnclosingScopeContextIfSingleScopeEdit=function(t,n,r,i){this.logger.log('checkEditsInsideSingleScope("'+n+'")');if(i===null)throw new Error("editRange should be valid");if(i.isUnknown())return this.logger.log(" Bailing out because edit range is unknown"),null;var s=e.findEnclosingScopeAt(this.logger,t,r,i.minChar,!1),o=e.findEnclosingScopeAt(this.logger,t,r,i.limChar,!1);if(s==null||o==null)return this.logger.log(" Bailing out because containing scopes cannot be determined"),null;if(s.scopeStartAST!==o.scopeStartAST)return this.logger.log(" Bailing out because edit overlaps 2 disctint scopes"),null;var u=s.scopeStartAST.limChar-s.scopeStartAST.minChar+i.delta;return u<=0?(this.logger.log(" Bailing out because scope has been entirely removed from new source text"),null):s},t.prototype.attemptIncrementalUpdateUnit=function(t,n,r,i){this.logger.log('attemptIncrementalUpdateUnit("'+n+'")');if(i===null)throw new Error("editRange should be valid");var s=this.getEnclosingScopeContextIfSingleScopeEdit(t,n,r,i);if(s===null)return null;var o=s.scopeStartAST.limChar-s.scopeStartAST.minChar+i.delta;if(o>=r.getLength()/2)return this.logger.log(" Bailing out because range of scope to reparse ("+o+" characters) is greater than half the size of the source text"),null;var u=[],a=function(t,n,r,i){u.push(new e.ErrorEntry(i,t,t+n,r))},f=e.quickParse(this.logger,s.scopeStartAST,r,s.scopeStartAST.minChar,s.scopeStartAST.minChar+o,a);if(f.endLexState!=e.LexState.Start)return this.logger.log(" Bailing out because scope contains unterminated comment"),null;var l=f.Script;if(l.vars.members.length!==0)return this.logger.log(" Bailing out because new source text defines variables"),null;if(l.bod.members.length!==1)return this.logger.log(" Bailing out because new source text defines more than one scope (or none)"),null;var c=s.scopeStartAST,h=l.bod.members[0];return c.nodeType!=h.nodeType?(this.logger.log(" Bailing out because new source text does not define the same scope type as the existing scope"),null):!c.leftCurlyCount||!c.rightCurlyCount?(this.logger.log(" Bailing out because sopce doesn't have left/right curly count"),null):c.leftCurlyCount!==h.leftCurlyCount?(this.logger.log(" Bailing out because new source text contains more (or fewer) left curly braces"),null):c.rightCurlyCount!==h.rightCurlyCount?(this.logger.log(" Bailing out because new source text contains more (or fewer) right curly braces"),null):h.minChar!==0?(this.logger.log(" Bailing out because new function declaration does not start at position 0"),null):h.limChar!==o?(this.logger.log(" Bailing out because new function declaration does not end at the new end position"),null):e.UpdateUnitResult.singleScopeEdits(t,l,c,h,i,u)},t.prototype.mergeTrees=function(t){var n=this;e.timeFunction(this.logger,"mergeTrees()",function(){var r=new e.ScriptEditRange(t.scope1.minChar,t.scope1.limChar,t.editRange.delta);n.applyDeltaPosition(t.script1,r.limChar,r.delta),n.applyDeltaPosition(t.script2,0,r.minChar),n.mergeLocationInfo(t.script1,t.script2,r),n.replaceAST(t.script1,t.scope1,t.scope2)})},t.prototype.replaceAST=function(t,n,r){var i=this,s=function(t,s,o){return t===n?(r.preComments=t.preComments,r.postComments=t.postComments,i.logger.log("replaced old AST node with new one in script AST"),o.options.stopWalk(),r):(e.isValidAstNode(t)&&(t.limCharn.limChar)&&(o.options.goChildren=!1),t)};e.getAstWalkerFactory().walk(t,s)},t.prototype.mergeLocationInfo=function(e,t,n){var r=e.locationInfo.lineMap,i=t.locationInfo.lineMap;this.logger.information()&&(this.logger.log("lineMap1 (before):"),this.astLogger.logLinemap(r),this.logger.log("lineMap2 (quick parse):"),this.astLogger.logLinemap(i),this.logger.log("EditRange="+n));var s=2,o=2,u=r.length,a=i.length;while(s=n.limChar?(r[s]+=n.delta,s++):o=n&&(e.minChar+=r),e.limChar!==-1&&e.limChar>=n&&(e.limChar+=r)},s=function(e){if(e&&e.length>0)for(var t=0;tt;if(i){var s=t>>1;for(var o=0;o