Skip to content

Commit 24dbe2d

Browse files
ahejlsbergunknown
authored andcommitted
Improving code and addressing code review feedback.
Binder now builds more generally useful linked list of all container declarations. Emitter uses original spelling when creating unique local container names.
1 parent 175dba4 commit 24dbe2d

File tree

3 files changed

+1
-45
lines changed

3 files changed

+1
-45
lines changed

src/compiler/binder.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ module ts {
3333
var container: Declaration;
3434
var lastContainer: Declaration;
3535
var symbolCount = 0;
36-
var lastLocals: Declaration;
3736
var Symbol = objectAllocator.getSymbolConstructor();
3837

3938
if (!file.locals) {

src/compiler/checker.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6049,49 +6049,6 @@ module ts {
60496049
Debug.fail("getLocalNameForSymbol failed");
60506050
}
60516051

6052-
function isNodeParentedBy(node: Node, parent: Node): boolean {
6053-
while (node) {
6054-
if (node === parent) return true;
6055-
node = node.parent;
6056-
}
6057-
return false;
6058-
}
6059-
6060-
function isUniqueLocalName(name: string, container: Node): boolean {
6061-
name = escapeIdentifier(name);
6062-
if (container.locals) {
6063-
for (var node = container; isNodeParentedBy(node, container); node = node.nextLocals) {
6064-
if (hasProperty(node.locals, name) && node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue)) {
6065-
return false;
6066-
}
6067-
}
6068-
}
6069-
return true;
6070-
}
6071-
6072-
function getLocalNameOfContainer(container: Declaration): string {
6073-
var links = getNodeLinks(container);
6074-
if (!links.localModuleName) {
6075-
var name = container.name.text ? unescapeIdentifier(container.name.text) : "M";
6076-
while (!isUniqueLocalName(name, container)) {
6077-
name = "_" + name;
6078-
}
6079-
links.localModuleName = name;
6080-
}
6081-
return links.localModuleName;
6082-
}
6083-
6084-
function getLocalNameForSymbol(symbol: Symbol, location: Node): string {
6085-
var node = location;
6086-
while (node) {
6087-
if ((node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(node) === symbol) {
6088-
return getLocalNameOfContainer(node);
6089-
}
6090-
node = node.parent;
6091-
}
6092-
Debug.fail("getLocalNameForSymbol failed");
6093-
}
6094-
60956052
function getExpressionNamePrefix(node: Identifier): string {
60966053
var symbol = getNodeLinks(node).resolvedSymbol;
60976054
if (symbol) {

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ module ts {
691691

692692
ExportHasLocal = Function | Class | Enum | ValueModule,
693693

694-
HasLocals = Function | Enum | Module | Method | Constructor | Accessor | Signature,
694+
HasLocals = Function | Module | Method | Constructor | Accessor | Signature,
695695
HasExports = Class | Enum | Module,
696696
HasMembers = Class | Interface | TypeLiteral | ObjectLiteral,
697697

0 commit comments

Comments
 (0)