UNPKG

testrumenter

Version:

Command-line utility to test JavaScript code instrumenter

1,312 lines (1,272 loc) 1.23 MB
var TypeScript; (function (TypeScript) { function hasFlag(val, flag) { return (val & flag) != 0; } TypeScript.hasFlag = hasFlag; (function (ErrorRecoverySet) { ErrorRecoverySet._map = []; ErrorRecoverySet.None = 0; ErrorRecoverySet.Comma = 1; ErrorRecoverySet.SColon = 1 << 1; ErrorRecoverySet.Asg = 1 << 2; ErrorRecoverySet.BinOp = 1 << 3; ErrorRecoverySet.RBrack = 1 << 4; ErrorRecoverySet.RCurly = 1 << 5; ErrorRecoverySet.RParen = 1 << 6; ErrorRecoverySet.Dot = 1 << 7; ErrorRecoverySet.Colon = 1 << 8; ErrorRecoverySet.PrimType = 1 << 9; ErrorRecoverySet.AddOp = 1 << 10; ErrorRecoverySet.LCurly = 1 << 11; ErrorRecoverySet.PreOp = 1 << 12; ErrorRecoverySet.RegExp = 1 << 13; ErrorRecoverySet.LParen = 1 << 14; ErrorRecoverySet.LBrack = 1 << 15; ErrorRecoverySet.Scope = 1 << 16; ErrorRecoverySet.In = 1 << 17; ErrorRecoverySet.SCase = 1 << 18; ErrorRecoverySet.Else = 1 << 19; ErrorRecoverySet.Catch = 1 << 20; ErrorRecoverySet.Var = 1 << 21; ErrorRecoverySet.Stmt = 1 << 22; ErrorRecoverySet.While = 1 << 23; ErrorRecoverySet.ID = 1 << 24; ErrorRecoverySet.Prefix = 1 << 25; ErrorRecoverySet.Literal = 1 << 26; ErrorRecoverySet.RLit = 1 << 27; ErrorRecoverySet.Func = 1 << 28; ErrorRecoverySet.EOF = 1 << 29; ErrorRecoverySet.TypeScriptS = 1 << 30; ErrorRecoverySet.ExprStart = ErrorRecoverySet.SColon | ErrorRecoverySet.AddOp | ErrorRecoverySet.LCurly | ErrorRecoverySet.PreOp | ErrorRecoverySet.RegExp | ErrorRecoverySet.LParen | ErrorRecoverySet.LBrack | ErrorRecoverySet.ID | ErrorRecoverySet.Prefix | ErrorRecoverySet.RLit | ErrorRecoverySet.Func | ErrorRecoverySet.Literal; ErrorRecoverySet.StmtStart = ErrorRecoverySet.ExprStart | ErrorRecoverySet.SColon | ErrorRecoverySet.Var | ErrorRecoverySet.Stmt | ErrorRecoverySet.While | ErrorRecoverySet.TypeScriptS; ErrorRecoverySet.Postfix = ErrorRecoverySet.Dot | ErrorRecoverySet.LParen | ErrorRecoverySet.LBrack; })(TypeScript.ErrorRecoverySet || (TypeScript.ErrorRecoverySet = {})); var ErrorRecoverySet = TypeScript.ErrorRecoverySet; (function (AllowedElements) { AllowedElements._map = []; AllowedElements.None = 0; AllowedElements.ModuleDeclarations = 1 << 2; AllowedElements.ClassDeclarations = 1 << 3; AllowedElements.InterfaceDeclarations = 1 << 4; AllowedElements.AmbientDeclarations = 1 << 10; AllowedElements.Properties = 1 << 11; AllowedElements.Global = AllowedElements.ModuleDeclarations | AllowedElements.ClassDeclarations | AllowedElements.InterfaceDeclarations | AllowedElements.AmbientDeclarations; AllowedElements.QuickParse = AllowedElements.Global | AllowedElements.Properties; })(TypeScript.AllowedElements || (TypeScript.AllowedElements = {})); var AllowedElements = TypeScript.AllowedElements; (function (Modifiers) { Modifiers._map = []; Modifiers.None = 0; Modifiers.Private = 1; Modifiers.Public = 1 << 1; Modifiers.Readonly = 1 << 2; Modifiers.Ambient = 1 << 3; Modifiers.Exported = 1 << 4; Modifiers.Getter = 1 << 5; Modifiers.Setter = 1 << 6; Modifiers.Static = 1 << 7; })(TypeScript.Modifiers || (TypeScript.Modifiers = {})); var Modifiers = TypeScript.Modifiers; (function (ASTFlags) { ASTFlags._map = []; ASTFlags.None = 0; ASTFlags.ExplicitSemicolon = 1; ASTFlags.AutomaticSemicolon = 1 << 1; ASTFlags.Writeable = 1 << 2; ASTFlags.Error = 1 << 3; ASTFlags.DotLHSPartial = 1 << 4; ASTFlags.DotLHS = 1 << 5; ASTFlags.IsStatement = 1 << 6; ASTFlags.StrictMode = 1 << 7; ASTFlags.PossibleOptionalParameter = 1 << 8; ASTFlags.ClassBaseConstructorCall = 1 << 9; ASTFlags.OptionalName = 1 << 10; ASTFlags.SkipNextRParen = 1 << 11; })(TypeScript.ASTFlags || (TypeScript.ASTFlags = {})); var ASTFlags = TypeScript.ASTFlags; (function (DeclFlags) { DeclFlags._map = []; DeclFlags.None = 0; DeclFlags.Exported = 1; DeclFlags.Private = 1 << 1; DeclFlags.Public = 1 << 2; DeclFlags.Ambient = 1 << 3; DeclFlags.Static = 1 << 4; DeclFlags.LocalStatic = 1 << 5; DeclFlags.GetAccessor = 1 << 6; DeclFlags.SetAccessor = 1 << 7; })(TypeScript.DeclFlags || (TypeScript.DeclFlags = {})); var DeclFlags = TypeScript.DeclFlags; (function (ModuleFlags) { ModuleFlags._map = []; ModuleFlags.None = 0; ModuleFlags.Exported = 1; ModuleFlags.Private = 1 << 1; ModuleFlags.Public = 1 << 2; ModuleFlags.Ambient = 1 << 3; ModuleFlags.Static = 1 << 4; ModuleFlags.LocalStatic = 1 << 5; ModuleFlags.GetAccessor = 1 << 6; ModuleFlags.SetAccessor = 1 << 7; ModuleFlags.IsEnum = 1 << 8; ModuleFlags.ShouldEmitModuleDecl = 1 << 9; ModuleFlags.IsWholeFile = 1 << 10; ModuleFlags.IsDynamic = 1 << 11; ModuleFlags.MustCaptureThis = 1 << 12; })(TypeScript.ModuleFlags || (TypeScript.ModuleFlags = {})); var ModuleFlags = TypeScript.ModuleFlags; (function (SymbolFlags) { SymbolFlags._map = []; SymbolFlags.None = 0; SymbolFlags.Exported = 1; SymbolFlags.Private = 1 << 1; SymbolFlags.Public = 1 << 2; SymbolFlags.Ambient = 1 << 3; SymbolFlags.Static = 1 << 4; SymbolFlags.LocalStatic = 1 << 5; SymbolFlags.GetAccessor = 1 << 6; SymbolFlags.SetAccessor = 1 << 7; SymbolFlags.Property = 1 << 8; SymbolFlags.Readonly = 1 << 9; SymbolFlags.ModuleMember = 1 << 10; SymbolFlags.InterfaceMember = 1 << 11; SymbolFlags.ClassMember = 1 << 12; SymbolFlags.BuiltIn = 1 << 13; SymbolFlags.TypeSetDuringScopeAssignment = 1 << 14; SymbolFlags.Constant = 1 << 15; SymbolFlags.Optional = 1 << 16; SymbolFlags.RecursivelyReferenced = 1 << 17; SymbolFlags.Bound = 1 << 18; SymbolFlags.CompilerGenerated = 1 << 19; })(TypeScript.SymbolFlags || (TypeScript.SymbolFlags = {})); var SymbolFlags = TypeScript.SymbolFlags; (function (VarFlags) { VarFlags._map = []; VarFlags.None = 0; VarFlags.Exported = 1; VarFlags.Private = 1 << 1; VarFlags.Public = 1 << 2; VarFlags.Ambient = 1 << 3; VarFlags.Static = 1 << 4; VarFlags.LocalStatic = 1 << 5; VarFlags.GetAccessor = 1 << 6; VarFlags.SetAccessor = 1 << 7; VarFlags.AutoInit = 1 << 8; VarFlags.Property = 1 << 9; VarFlags.Readonly = 1 << 10; VarFlags.Class = 1 << 11; VarFlags.ClassProperty = 1 << 12; VarFlags.ClassBodyProperty = 1 << 13; VarFlags.ClassConstructorProperty = 1 << 14; VarFlags.ClassSuperMustBeFirstCallInConstructor = 1 << 15; VarFlags.Constant = 1 << 16; VarFlags.MustCaptureThis = 1 << 17; })(TypeScript.VarFlags || (TypeScript.VarFlags = {})); var VarFlags = TypeScript.VarFlags; (function (FncFlags) { FncFlags._map = []; FncFlags.None = 0; FncFlags.Exported = 1; FncFlags.Private = 1 << 1; FncFlags.Public = 1 << 2; FncFlags.Ambient = 1 << 3; FncFlags.Static = 1 << 4; FncFlags.LocalStatic = 1 << 5; FncFlags.GetAccessor = 1 << 6; FncFlags.SetAccessor = 1 << 7; FncFlags.Definition = 1 << 8; FncFlags.Signature = 1 << 9; FncFlags.Method = 1 << 10; FncFlags.HasReturnExpression = 1 << 11; FncFlags.CallMember = 1 << 12; FncFlags.ConstructMember = 1 << 13; FncFlags.HasSelfReference = 1 << 14; FncFlags.IsFatArrowFunction = 1 << 15; FncFlags.IndexerMember = 1 << 16; FncFlags.IsFunctionExpression = 1 << 17; FncFlags.ClassMethod = 1 << 18; FncFlags.ClassPropertyMethodExported = 1 << 19; FncFlags.HasSuperReferenceInFatArrowFunction = 1 << 20; FncFlags.IsPropertyBound = 1 << 21; })(TypeScript.FncFlags || (TypeScript.FncFlags = {})); var FncFlags = TypeScript.FncFlags; (function (SignatureFlags) { SignatureFlags._map = []; SignatureFlags.None = 0; SignatureFlags.IsIndexer = 1; SignatureFlags.IsStringIndexer = 1 << 1; SignatureFlags.IsNumberIndexer = 1 << 2; })(TypeScript.SignatureFlags || (TypeScript.SignatureFlags = {})); var SignatureFlags = TypeScript.SignatureFlags; function ToDeclFlags(fncOrVarOrSymbolOrModuleFlags) { return fncOrVarOrSymbolOrModuleFlags; } TypeScript.ToDeclFlags = ToDeclFlags; (function (TypeFlags) { TypeFlags._map = []; TypeFlags.None = 0; TypeFlags.HasImplementation = 1; TypeFlags.HasSelfReference = 1 << 1; TypeFlags.MergeResult = 1 << 2; TypeFlags.IsEnum = 1 << 3; TypeFlags.BuildingName = 1 << 4; TypeFlags.HasBaseType = 1 << 5; TypeFlags.HasBaseTypeOfObject = 1 << 6; TypeFlags.IsClass = 1 << 7; })(TypeScript.TypeFlags || (TypeScript.TypeFlags = {})); var TypeFlags = TypeScript.TypeFlags; (function (TypeRelationshipFlags) { TypeRelationshipFlags._map = []; TypeRelationshipFlags.SuccessfulComparison = 0; TypeRelationshipFlags.SourceIsNullTargetIsVoidOrUndefined = 1; TypeRelationshipFlags.RequiredPropertyIsMissing = 1 << 1; TypeRelationshipFlags.IncompatibleSignatures = 1 << 2; TypeRelationshipFlags.SourceSignatureHasTooManyParameters = 3; TypeRelationshipFlags.IncompatibleReturnTypes = 1 << 4; TypeRelationshipFlags.IncompatiblePropertyTypes = 1 << 5; TypeRelationshipFlags.IncompatibleParameterTypes = 1 << 6; })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; (function (CodeGenTarget) { CodeGenTarget._map = []; CodeGenTarget.ES3 = 0; CodeGenTarget.ES5 = 1; })(TypeScript.CodeGenTarget || (TypeScript.CodeGenTarget = {})); var CodeGenTarget = TypeScript.CodeGenTarget; (function (ModuleGenTarget) { ModuleGenTarget._map = []; ModuleGenTarget.Synchronous = 0; ModuleGenTarget.Asynchronous = 1; ModuleGenTarget.Local = 1 << 1; })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); var ModuleGenTarget = TypeScript.ModuleGenTarget; TypeScript.codeGenTarget = CodeGenTarget.ES3; TypeScript.moduleGenTarget = ModuleGenTarget.Synchronous; TypeScript.optimizeModuleCodeGen = true; function flagsToString(e, flags) { var builder = ""; for(var i = 1; i < (1 << 31); i = i << 1) { if((flags & i) != 0) { for(var k in e) { if(e[k] == i) { if(builder.length > 0) { builder += "|"; } builder += k; break; } } } } return builder; } TypeScript.flagsToString = flagsToString; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { (function (NodeType) { NodeType._map = []; NodeType._map[0] = "None"; NodeType.None = 0; NodeType._map[1] = "Empty"; NodeType.Empty = 1; NodeType._map[2] = "EmptyExpr"; NodeType.EmptyExpr = 2; NodeType._map[3] = "True"; NodeType.True = 3; NodeType._map[4] = "False"; NodeType.False = 4; NodeType._map[5] = "This"; NodeType.This = 5; NodeType._map[6] = "Super"; NodeType.Super = 6; NodeType._map[7] = "QString"; NodeType.QString = 7; NodeType._map[8] = "Regex"; NodeType.Regex = 8; NodeType._map[9] = "Null"; NodeType.Null = 9; NodeType._map[10] = "ArrayLit"; NodeType.ArrayLit = 10; NodeType._map[11] = "ObjectLit"; NodeType.ObjectLit = 11; NodeType._map[12] = "Void"; NodeType.Void = 12; NodeType._map[13] = "Comma"; NodeType.Comma = 13; NodeType._map[14] = "Pos"; NodeType.Pos = 14; NodeType._map[15] = "Neg"; NodeType.Neg = 15; NodeType._map[16] = "Delete"; NodeType.Delete = 16; NodeType._map[17] = "Await"; NodeType.Await = 17; NodeType._map[18] = "In"; NodeType.In = 18; NodeType._map[19] = "Dot"; NodeType.Dot = 19; NodeType._map[20] = "From"; NodeType.From = 20; NodeType._map[21] = "Is"; NodeType.Is = 21; NodeType._map[22] = "InstOf"; NodeType.InstOf = 22; NodeType._map[23] = "Typeof"; NodeType.Typeof = 23; NodeType._map[24] = "NumberLit"; NodeType.NumberLit = 24; NodeType._map[25] = "Name"; NodeType.Name = 25; NodeType._map[26] = "TypeRef"; NodeType.TypeRef = 26; NodeType._map[27] = "Index"; NodeType.Index = 27; NodeType._map[28] = "Call"; NodeType.Call = 28; NodeType._map[29] = "New"; NodeType.New = 29; NodeType._map[30] = "Asg"; NodeType.Asg = 30; NodeType._map[31] = "AsgAdd"; NodeType.AsgAdd = 31; NodeType._map[32] = "AsgSub"; NodeType.AsgSub = 32; NodeType._map[33] = "AsgDiv"; NodeType.AsgDiv = 33; NodeType._map[34] = "AsgMul"; NodeType.AsgMul = 34; NodeType._map[35] = "AsgMod"; NodeType.AsgMod = 35; NodeType._map[36] = "AsgAnd"; NodeType.AsgAnd = 36; NodeType._map[37] = "AsgXor"; NodeType.AsgXor = 37; NodeType._map[38] = "AsgOr"; NodeType.AsgOr = 38; NodeType._map[39] = "AsgLsh"; NodeType.AsgLsh = 39; NodeType._map[40] = "AsgRsh"; NodeType.AsgRsh = 40; NodeType._map[41] = "AsgRs2"; NodeType.AsgRs2 = 41; NodeType._map[42] = "ConditionalExpression"; NodeType.ConditionalExpression = 42; NodeType._map[43] = "LogOr"; NodeType.LogOr = 43; NodeType._map[44] = "LogAnd"; NodeType.LogAnd = 44; NodeType._map[45] = "Or"; NodeType.Or = 45; NodeType._map[46] = "Xor"; NodeType.Xor = 46; NodeType._map[47] = "And"; NodeType.And = 47; NodeType._map[48] = "Eq"; NodeType.Eq = 48; NodeType._map[49] = "Ne"; NodeType.Ne = 49; NodeType._map[50] = "Eqv"; NodeType.Eqv = 50; NodeType._map[51] = "NEqv"; NodeType.NEqv = 51; NodeType._map[52] = "Lt"; NodeType.Lt = 52; NodeType._map[53] = "Le"; NodeType.Le = 53; NodeType._map[54] = "Gt"; NodeType.Gt = 54; NodeType._map[55] = "Ge"; NodeType.Ge = 55; NodeType._map[56] = "Add"; NodeType.Add = 56; NodeType._map[57] = "Sub"; NodeType.Sub = 57; NodeType._map[58] = "Mul"; NodeType.Mul = 58; NodeType._map[59] = "Div"; NodeType.Div = 59; NodeType._map[60] = "Mod"; NodeType.Mod = 60; NodeType._map[61] = "Lsh"; NodeType.Lsh = 61; NodeType._map[62] = "Rsh"; NodeType.Rsh = 62; NodeType._map[63] = "Rs2"; NodeType.Rs2 = 63; NodeType._map[64] = "Not"; NodeType.Not = 64; NodeType._map[65] = "LogNot"; NodeType.LogNot = 65; NodeType._map[66] = "IncPre"; NodeType.IncPre = 66; NodeType._map[67] = "DecPre"; NodeType.DecPre = 67; NodeType._map[68] = "IncPost"; NodeType.IncPost = 68; NodeType._map[69] = "DecPost"; NodeType.DecPost = 69; NodeType._map[70] = "TypeAssertion"; NodeType.TypeAssertion = 70; NodeType._map[71] = "FuncDecl"; NodeType.FuncDecl = 71; NodeType._map[72] = "Member"; NodeType.Member = 72; NodeType._map[73] = "VarDecl"; NodeType.VarDecl = 73; NodeType._map[74] = "ArgDecl"; NodeType.ArgDecl = 74; NodeType._map[75] = "Return"; NodeType.Return = 75; NodeType._map[76] = "Break"; NodeType.Break = 76; NodeType._map[77] = "Continue"; NodeType.Continue = 77; NodeType._map[78] = "Throw"; NodeType.Throw = 78; NodeType._map[79] = "For"; NodeType.For = 79; NodeType._map[80] = "ForIn"; NodeType.ForIn = 80; NodeType._map[81] = "If"; NodeType.If = 81; NodeType._map[82] = "While"; NodeType.While = 82; NodeType._map[83] = "DoWhile"; NodeType.DoWhile = 83; NodeType._map[84] = "Block"; NodeType.Block = 84; NodeType._map[85] = "Case"; NodeType.Case = 85; NodeType._map[86] = "Switch"; NodeType.Switch = 86; NodeType._map[87] = "Try"; NodeType.Try = 87; NodeType._map[88] = "TryCatch"; NodeType.TryCatch = 88; NodeType._map[89] = "TryFinally"; NodeType.TryFinally = 89; NodeType._map[90] = "Finally"; NodeType.Finally = 90; NodeType._map[91] = "Catch"; NodeType.Catch = 91; NodeType._map[92] = "List"; NodeType.List = 92; NodeType._map[93] = "Script"; NodeType.Script = 93; NodeType._map[94] = "ClassDeclaration"; NodeType.ClassDeclaration = 94; NodeType._map[95] = "InterfaceDeclaration"; NodeType.InterfaceDeclaration = 95; NodeType._map[96] = "ModuleDeclaration"; NodeType.ModuleDeclaration = 96; NodeType._map[97] = "ImportDeclaration"; NodeType.ImportDeclaration = 97; NodeType._map[98] = "With"; NodeType.With = 98; NodeType._map[99] = "Label"; NodeType.Label = 99; NodeType._map[100] = "LabeledStatement"; NodeType.LabeledStatement = 100; NodeType._map[101] = "EBStart"; NodeType.EBStart = 101; NodeType._map[102] = "GotoEB"; NodeType.GotoEB = 102; NodeType._map[103] = "EndCode"; NodeType.EndCode = 103; NodeType._map[104] = "Error"; NodeType.Error = 104; NodeType._map[105] = "Comment"; NodeType.Comment = 105; NodeType._map[106] = "Debugger"; NodeType.Debugger = 106; NodeType.GeneralNode = NodeType.FuncDecl; NodeType.LastAsg = NodeType.AsgRs2; })(TypeScript.NodeType || (TypeScript.NodeType = {})); var NodeType = TypeScript.NodeType; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { var BlockIntrinsics = (function () { function BlockIntrinsics() { 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 BlockIntrinsics; })(); TypeScript.BlockIntrinsics = BlockIntrinsics; var StringHashTable = (function () { function StringHashTable() { this.itemCount = 0; this.table = (new BlockIntrinsics()); } StringHashTable.prototype.getAllKeys = function () { var result = []; for(var k in this.table) { if(this.table[k] != undefined) { result[result.length] = k; } } return result; }; StringHashTable.prototype.add = function (key, data) { if(this.table[key] != undefined) { return false; } this.table[key] = data; this.itemCount++; return true; }; StringHashTable.prototype.addOrUpdate = function (key, data) { if(this.table[key] != undefined) { this.table[key] = data; return false; } this.table[key] = data; this.itemCount++; return true; }; StringHashTable.prototype.map = function (fn, context) { for(var k in this.table) { var data = this.table[k]; if(data != undefined) { fn(k, this.table[k], context); } } }; StringHashTable.prototype.every = function (fn, context) { for(var k in this.table) { var data = this.table[k]; if(data != undefined) { if(!fn(k, this.table[k], context)) { return false; } } } return true; }; StringHashTable.prototype.some = function (fn, context) { for(var k in this.table) { var data = this.table[k]; if(data != undefined) { if(fn(k, this.table[k], context)) { return true; } } } return false; }; StringHashTable.prototype.count = function () { return this.itemCount; }; StringHashTable.prototype.lookup = function (key) { var data = this.table[key]; if(data != undefined) { return data; } else { return (null); } }; return StringHashTable; })(); TypeScript.StringHashTable = StringHashTable; var DualStringHashTable = (function () { function DualStringHashTable(primaryTable, secondaryTable) { this.primaryTable = primaryTable; this.secondaryTable = secondaryTable; this.insertPrimary = true; } DualStringHashTable.prototype.getAllKeys = function () { return this.primaryTable.getAllKeys().concat(this.secondaryTable.getAllKeys()); }; DualStringHashTable.prototype.add = function (key, data) { if(this.insertPrimary) { return this.primaryTable.add(key, data); } else { return this.secondaryTable.add(key, data); } }; DualStringHashTable.prototype.addOrUpdate = function (key, data) { if(this.insertPrimary) { return this.primaryTable.addOrUpdate(key, data); } else { return this.secondaryTable.addOrUpdate(key, data); } }; DualStringHashTable.prototype.map = function (fn, context) { this.primaryTable.map(fn, context); this.secondaryTable.map(fn, context); }; DualStringHashTable.prototype.every = function (fn, context) { return this.primaryTable.every(fn, context) && this.secondaryTable.every(fn, context); }; DualStringHashTable.prototype.some = function (fn, context) { return this.primaryTable.some(fn, context) || this.secondaryTable.some(fn, context); }; DualStringHashTable.prototype.count = function () { return this.primaryTable.count() + this.secondaryTable.count(); }; DualStringHashTable.prototype.lookup = function (key) { var data = this.primaryTable.lookup(key); if(data != undefined) { return data; } else { return this.secondaryTable.lookup(key); } }; return DualStringHashTable; })(); TypeScript.DualStringHashTable = DualStringHashTable; function numberHashFn(key) { var c2 = 668265261; key = (key ^ 61) ^ (key >>> 16); key = key + (key << 3); key = key ^ (key >>> 4); key = key * c2; key = key ^ (key >>> 15); return key; } TypeScript.numberHashFn = numberHashFn; function combineHashes(key1, key2) { return key2 ^ ((key1 >> 5) + key1); } TypeScript.combineHashes = combineHashes; var HashEntry = (function () { function HashEntry(key, data) { this.key = key; this.data = data; } return HashEntry; })(); TypeScript.HashEntry = HashEntry; var HashTable = (function () { function HashTable(size, hashFn, equalsFn) { this.size = size; this.hashFn = hashFn; this.equalsFn = equalsFn; this.itemCount = 0; this.table = new Array(); for(var i = 0; i < this.size; i++) { this.table[i] = null; } } HashTable.prototype.add = function (key, data) { var current; var entry = new HashEntry(key, data); var val = this.hashFn(key); val = val % this.size; for(current = this.table[val]; current != null; current = current.next) { if(this.equalsFn(key, current.key)) { return false; } } entry.next = this.table[val]; this.table[val] = entry; this.itemCount++; return true; }; HashTable.prototype.remove = function (key) { var current; var val = this.hashFn(key); val = val % this.size; var result = null; var prevEntry = null; for(current = this.table[val]; current != null; current = current.next) { if(this.equalsFn(key, current.key)) { result = current.data; this.itemCount--; if(prevEntry) { prevEntry.next = current.next; } else { this.table[val] = current.next; } break; } prevEntry = current; } return result; }; HashTable.prototype.count = function () { return this.itemCount; }; HashTable.prototype.lookup = function (key) { var current; var val = this.hashFn(key); val = val % this.size; for(current = this.table[val]; current != null; current = current.next) { if(this.equalsFn(key, current.key)) { return (current.data); } } return (null); }; return HashTable; })(); TypeScript.HashTable = HashTable; var SimpleHashTable = (function () { function SimpleHashTable() { this.keys = []; this.values = []; } SimpleHashTable.prototype.lookup = function (key, findValue) { var searchArray = this.keys; if(findValue) { searchArray = this.values; } for(var i = 0; i < searchArray.length; i++) { if(searchArray[i] == key) { return { key: this.keys[i], data: this.values[i] }; } } return null; }; SimpleHashTable.prototype.add = function (key, data) { var lookupData = this.lookup(key); if(lookupData) { return false; } this.keys[this.keys.length] = key; this.values[this.values.length] = data; return true; }; return SimpleHashTable; })(); TypeScript.SimpleHashTable = SimpleHashTable; })(TypeScript || (TypeScript = {})); var __extends = this.__extends || function (d, b) { function __() { this.constructor = d; } __.prototype = b.prototype; d.prototype = new __(); }; var TypeScript; (function (TypeScript) { var ASTSpan = (function () { function ASTSpan() { this.minChar = -1; this.limChar = -1; } return ASTSpan; })(); TypeScript.ASTSpan = ASTSpan; var AST = (function (_super) { __extends(AST, _super); function AST(nodeType) { _super.call(this); this.nodeType = nodeType; this.type = null; this.flags = TypeScript.ASTFlags.Writeable; this.passCreated = TypeScript.CompilerDiagnostics.analysisPass; this.preComments = null; this.postComments = null; this.docComments = null; this.isParenthesized = false; } AST.prototype.isExpression = function () { return false; }; AST.prototype.isStatementOrExpression = function () { return false; }; AST.prototype.isCompoundStatement = function () { return false; }; AST.prototype.isLeaf = function () { return this.isStatementOrExpression() && (!this.isCompoundStatement()); }; AST.prototype.isDeclaration = function () { return false; }; AST.prototype.typeCheck = function (typeFlow) { switch(this.nodeType) { case TypeScript.NodeType.Error: case TypeScript.NodeType.EmptyExpr: { this.type = typeFlow.anyType; break; } case TypeScript.NodeType.This: { return typeFlow.typeCheckThis(this); } case TypeScript.NodeType.Null: { this.type = typeFlow.nullType; break; } case TypeScript.NodeType.False: case TypeScript.NodeType.True: { this.type = typeFlow.booleanType; break; } case TypeScript.NodeType.Super: { return typeFlow.typeCheckSuper(this); } case TypeScript.NodeType.EndCode: case TypeScript.NodeType.Empty: case TypeScript.NodeType.Void: { this.type = typeFlow.voidType; break; } default: { throw new Error("please implement in derived class"); } } return this; }; AST.prototype.emit = function (emitter, tokenId, startLine) { emitter.emitParensAndCommentsInPlace(this, true); switch(this.nodeType) { case TypeScript.NodeType.This: { emitter.recordSourceMappingStart(this); if(emitter.thisFnc && (TypeScript.hasFlag(emitter.thisFnc.fncFlags, TypeScript.FncFlags.IsFatArrowFunction))) { emitter.writeToOutput("_this"); } else { emitter.writeToOutput("this"); } emitter.recordSourceMappingEnd(this); break; } case TypeScript.NodeType.Null: { emitter.recordSourceMappingStart(this); emitter.writeToOutput("null"); emitter.recordSourceMappingEnd(this); break; } case TypeScript.NodeType.False: { emitter.recordSourceMappingStart(this); emitter.writeToOutput("false"); emitter.recordSourceMappingEnd(this); break; } case TypeScript.NodeType.True: { emitter.recordSourceMappingStart(this); emitter.writeToOutput("true"); emitter.recordSourceMappingEnd(this); break; } case TypeScript.NodeType.Super: { emitter.recordSourceMappingStart(this); emitter.emitSuperReference(); emitter.recordSourceMappingEnd(this); break; } case TypeScript.NodeType.EndCode: case TypeScript.NodeType.Error: case TypeScript.NodeType.EmptyExpr: { break; } case TypeScript.NodeType.Empty: { emitter.recordSourceMappingStart(this); emitter.recordSourceMappingEnd(this); break; } case TypeScript.NodeType.Void: { emitter.recordSourceMappingStart(this); emitter.writeToOutput("void "); emitter.recordSourceMappingEnd(this); break; } default: { throw new Error("please implement in derived class"); } } emitter.emitParensAndCommentsInPlace(this, false); }; AST.prototype.print = function (context) { context.startLine(); var lineCol = { line: -1, col: -1 }; var limLineCol = { line: -1, col: -1 }; if(context.parser !== null) { context.parser.getSourceLineCol(lineCol, this.minChar); context.parser.getSourceLineCol(limLineCol, this.limChar); context.write("(" + lineCol.line + "," + lineCol.col + ")--" + "(" + limLineCol.line + "," + limLineCol.col + "): "); } var lab = this.printLabel(); if(TypeScript.hasFlag(this.flags, TypeScript.ASTFlags.Error)) { lab += " (Error)"; } context.writeLine(lab); }; AST.prototype.printLabel = function () { if(TypeScript.nodeTypeTable[this.nodeType] !== undefined) { return TypeScript.nodeTypeTable[this.nodeType]; } else { return (TypeScript.NodeType)._map[this.nodeType]; } }; AST.prototype.addToControlFlow = function (context) { context.walker.options.goChildren = false; context.addContent(this); }; AST.prototype.netFreeUses = function (container, freeUses) { }; AST.prototype.treeViewLabel = function () { return (TypeScript.NodeType)._map[this.nodeType]; }; AST.getResolvedIdentifierName = function getResolvedIdentifierName(name) { if(!name) { return ""; } var resolved = ""; var start = 0; var i = 0; while(i <= name.length - 6) { if(name.charAt(i) == '\\' && name.charAt(i + 1) == 'u') { var charCode = parseInt(name.substr(i + 2, 4), 16); resolved += name.substr(start, i - start); resolved += String.fromCharCode(charCode); i += 6; start = i; continue; } i++; } resolved += name.substring(start); return resolved; } AST.prototype.getDocComments = function () { if(!this.isDeclaration() || !this.preComments || this.preComments.length == 0) { return []; } if(!this.docComments) { var preCommentsLength = this.preComments.length; var docComments = []; for(var i = preCommentsLength - 1; i >= 0; i--) { if(this.preComments[i].isDocComment()) { var prevDocComment = docComments.length > 0 ? docComments[docComments.length - 1] : null; if(prevDocComment == null || (this.preComments[i].limLine == prevDocComment.minLine || this.preComments[i].limLine + 1 == prevDocComment.minLine)) { docComments.push(this.preComments[i]); continue; } } break; } this.docComments = docComments.reverse(); } return this.docComments; }; return AST; })(ASTSpan); TypeScript.AST = AST; var IncompleteAST = (function (_super) { __extends(IncompleteAST, _super); function IncompleteAST(min, lim) { _super.call(this, TypeScript.NodeType.Error); this.minChar = min; this.limChar = lim; } return IncompleteAST; })(AST); TypeScript.IncompleteAST = IncompleteAST; var ASTList = (function (_super) { __extends(ASTList, _super); function ASTList() { _super.call(this, TypeScript.NodeType.List); this.enclosingScope = null; this.members = new Array(); } ASTList.prototype.addToControlFlow = function (context) { var len = this.members.length; for(var i = 0; i < len; i++) { if(context.noContinuation) { context.addUnreachable(this.members[i]); break; } else { this.members[i] = context.walk(this.members[i], this); } } context.walker.options.goChildren = false; }; ASTList.prototype.append = function (ast) { this.members[this.members.length] = ast; return this; }; ASTList.prototype.appendAll = function (ast) { if(ast.nodeType == TypeScript.NodeType.List) { var list = ast; for(var i = 0, len = list.members.length; i < len; i++) { this.append(list.members[i]); } } else { this.append(ast); } return this; }; ASTList.prototype.emit = function (emitter, tokenId, startLine) { emitter.recordSourceMappingStart(this); emitter.emitJavascriptList(this, null, TypeScript.TokenID.Semicolon, startLine, false, false); emitter.recordSourceMappingEnd(this); }; ASTList.prototype.typeCheck = function (typeFlow) { var len = this.members.length; typeFlow.nestingLevel++; for(var i = 0; i < len; i++) { if(this.members[i]) { this.members[i] = this.members[i].typeCheck(typeFlow); } } typeFlow.nestingLevel--; return this; }; return ASTList; })(AST); TypeScript.ASTList = ASTList; var Identifier = (function (_super) { __extends(Identifier, _super); function Identifier(actualText, hasEscapeSequence) { _super.call(this, TypeScript.NodeType.Name); this.actualText = actualText; this.hasEscapeSequence = hasEscapeSequence; this.sym = null; this.cloId = -1; this.setText(actualText, hasEscapeSequence); } Identifier.prototype.setText = function (actualText, hasEscapeSequence) { this.actualText = actualText; if(hasEscapeSequence) { this.text = AST.getResolvedIdentifierName(actualText); } else { this.text = actualText; } }; Identifier.prototype.isMissing = function () { return false; }; Identifier.prototype.isLeaf = function () { return true; }; Identifier.prototype.treeViewLabel = function () { return "id: " + this.actualText; }; Identifier.prototype.printLabel = function () { if(this.actualText) { return "id: " + this.actualText; } else { return "name node"; } }; Identifier.prototype.typeCheck = function (typeFlow) { return typeFlow.typeCheckName(this); }; Identifier.prototype.emit = function (emitter, tokenId, startLine) { emitter.emitJavascriptName(this, true); }; Identifier.fromToken = function fromToken(token) { return new Identifier(token.getText(), (token).hasEscapeSequence); } return Identifier; })(AST); TypeScript.Identifier = Identifier; var MissingIdentifier = (function (_super) { __extends(MissingIdentifier, _super); function MissingIdentifier() { _super.call(this, "__missing"); } MissingIdentifier.prototype.isMissing = function () { return true; }; MissingIdentifier.prototype.emit = function (emitter, tokenId, startLine) { }; return MissingIdentifier; })(Identifier); TypeScript.MissingIdentifier = MissingIdentifier; var Label = (function (_super) { __extends(Label, _super); function Label(id) { _super.call(this, TypeScript.NodeType.Label); this.id = id; } Label.prototype.printLabel = function () { return this.id.actualText + ":"; }; Label.prototype.typeCheck = function (typeFlow) { this.type = typeFlow.voidType; return this; }; Label.prototype.emit = function (emitter, tokenId, startLine) { emitter.emitParensAndCommentsInPlace(this, true); emitter.recordSourceMappingStart(this); emitter.recordSourceMappingStart(this.id); emitter.writeToOutput(this.id.actualText); emitter.recordSourceMappingEnd(this.id); emitter.writeLineToOutput(":"); emitter.recordSourceMappingEnd(this); emitter.emitParensAndCommentsInPlace(this, false); }; return Label; })(AST); TypeScript.Label = Label; var Expression = (function (_super) { __extends(Expression, _super); function Expression(nodeType) { _super.call(this, nodeType); } Expression.prototype.isExpression = function () { return true; }; Expression.prototype.isStatementOrExpression = function () { return true; }; return Expression; })(AST); TypeScript.Expression = Expression; var UnaryExpression = (function (_super) { __extends(UnaryExpression, _super); function UnaryExpression(nodeType, operand) { _super.call(this, nodeType); this.operand = operand; this.targetType = null; this.castTerm = null; } UnaryExpression.prototype.addToControlFlow = function (context) { _super.prototype.addToControlFlow.call(this, context); if(this.nodeType == TypeScript.NodeType.Throw) { context.returnStmt(); } }; UnaryExpression.prototype.typeCheck = function (typeFlow) { switch(this.nodeType) { case TypeScript.NodeType.Not: { return typeFlow.typeCheckBitNot(this); } case TypeScript.NodeType.LogNot: { return typeFlow.typeCheckLogNot(this); } case TypeScript.NodeType.Pos: case TypeScript.NodeType.Neg: { return typeFlow.typeCheckUnaryNumberOperator(this); } case TypeScript.NodeType.IncPost: case TypeScript.NodeType.IncPre: case TypeScript.NodeType.DecPost: case TypeScript.NodeType.DecPre: { return typeFlow.typeCheckIncOrDec(this); } case TypeScript.NodeType.ArrayLit: { typeFlow.typeCheckArrayLit(this); return this; } case TypeScript.NodeType.ObjectLit: { typeFlow.typeCheckObjectLit(this); return this; } case TypeScript.NodeType.Throw: { this.operand = typeFlow.typeCheck(this.operand); this.type = typeFlow.voidType; return this; } case TypeScript.NodeType.Typeof: { this.operand = typeFlow.typeCheck(this.operand); this.type = typeFlow.stringType; return this; } case TypeScript.NodeType.Delete: { this.operand = typeFlow.typeCheck(this.operand); this.type = typeFlow.booleanType; break; } case TypeScript.NodeType.TypeAssertion: { this.castTerm = typeFlow.typeCheck(this.castTerm); var applyTargetType = !this.operand.isParenthesized; var targetType = applyTargetType ? this.castTerm.type : null; typeFlow.checker.typeCheckWithContextualType(targetType, typeFlow.checker.inProvisionalTypecheckMode(), true, this.operand); typeFlow.castWithCoercion(this.operand, this.castTerm.type, false, true); this.type = this.castTerm.type; return this; } case TypeScript.NodeType.Void: { this.operand = typeFlow.typeCheck(this.operand); this.type = typeFlow.checker.undefinedType; break; } default: { throw new Error("please implement in derived class"); } } return this; }; UnaryExpression.prototype.emit = function (emitter, tokenId, startLine) { emitter.emitParensAndCommentsInPlace(this, true); emitter.recordSourceMappingStart(this); switch(this.nodeType) { case TypeScript.NodeType.IncPost: { emitter.emitJavascript(this.operand, TypeScript.TokenID.PlusPlus, false); emitter.writeToOutput("++"); break; } case TypeScript.NodeType.LogNot: { emitter.writeToOutput("!"); emitter.emitJavascript(this.operand, TypeScript.TokenID.Exclamation, false); break; } case TypeScript.NodeType.DecPost: { emitter.emitJavascript(this.operand, TypeScript.TokenID.MinusMinus, false); emitter.writeToOutput("--"); break; } case TypeScript.NodeType.ObjectLit: { emitter.emitObjectLiteral(this.operand); break; } case TypeScript.NodeType.ArrayLit: { emitter.emitArrayLiteral(this.operand); break; } case TypeScript.NodeType.Not: { emitter.writeToOutput("~"); emitter.emitJavascript(this.operand, TypeScript.TokenID.Tilde, false); break; } case TypeScript.NodeType.Neg: { emitter.writeToOutput("-"); if(this.operand.nodeType == TypeScript.NodeType.Neg) { this.operand.isParenthesized = true; } emitter.emitJavascript(this.operand, TypeScript.TokenID.Minus, false); break; } case TypeScript.NodeType.Pos: { emitter.writeToOutput("+"); if(this.operand.nodeType == TypeScript.NodeType.Pos) { this.operand.isParenthesized = true; } emitter.emitJavascript(this.operand, TypeScript.TokenID.Plus, false); break; } case TypeScript.NodeType.IncPre: { emitter.writeToOutput("++"); emitter.emitJavascript(this.operand, TypeScript.TokenID.PlusPlus, false); break; } case TypeScript.NodeType.DecPre: { emitter.writeToOutput("--"); emitter.emitJavascript(this.operand, TypeScript.TokenID.MinusMinus, false); break; } case TypeScript.NodeType.Throw: { emitter.writeToOutput("throw "); emitter.emitJavascript(this.operand, TypeScript.TokenID.Tilde, false); emitter.writeToOutput(";"); break; } case TypeScript.NodeType.Typeof: { emitter.writeToOutput("typeof "); emitter.emitJavascript(this.operand, TypeScript.TokenID.Tilde, false); break; } case TypeScript.NodeType.Delete: { emitter.writeToOutput("delete "); emitter.emitJavas