added comments

This commit is contained in:
Vladimir Matveev 2015-02-26 17:19:47 -08:00
parent 904d116f9a
commit 4bf0bb6405
2 changed files with 12 additions and 2 deletions

View File

@ -280,7 +280,7 @@ module ts {
Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here.");
if (symbol.flags & meaning) {
return symbol;
}
}
if (symbol.flags & SymbolFlags.Import) {
var target = resolveImport(symbol);
@ -10716,7 +10716,7 @@ module ts {
}
function isUnknownIdentifier(location: Node, name: string): boolean {
return !resolveName(location, name, SymbolFlags.Value | SymbolFlags.Import, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined) &&
return !resolveName(location, name, SymbolFlags.Value, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined) &&
!hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name);
}

View File

@ -33,11 +33,17 @@ module ts {
trailingCommentRanges?: CommentRange[];
}
// represents one LexicalEnvironment frame to store unique generated names
interface ScopeFrame {
names: Map<string>;
previous: ScopeFrame;
}
// isExisingName function has signature string -> boolean, however check if name is unique should be performed
// in the context of some location. Instead of creating function expression and closing over location
// every time isExisingName is called we use one single instance of NameLookup that is effectively a
// handrolled closure where value of location can be swapped. This allows to avoid allocations of closures on
// every call and use one shared instance instead
interface NameLookup {
setLocation(location: Node): void;
isExistingName(name: string): boolean;
@ -1663,6 +1669,8 @@ module ts {
writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM);
return;
// enters the new lexical environment
// return value should be passed to matching call to exitNameScope.
function enterNameScope(): boolean {
var names = currentScopeNames;
currentScopeNames = undefined;
@ -1683,6 +1691,8 @@ module ts {
}
}
// creates instance of NameLookup to be used in 'isExisingName' checks.
// see comment for NameLookup for more information
function createNameLookup(): NameLookup {
var location: Node;
return {