Skip to content

Commit 12f6dce

Browse files
author
Andy Hanson
committed
Revert "Merge pull request #11354 from Microsoft/map4"
This reverts commit adfdae0, reversing changes made to aad663c.
1 parent adfdae0 commit 12f6dce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1430
-1781
lines changed

Jakefile.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ function measure(marker) {
5757
}
5858

5959
var compilerSources = [
60-
"collections.ts",
6160
"core.ts",
6261
"performance.ts",
6362
"sys.ts",
@@ -94,7 +93,6 @@ var compilerSources = [
9493
});
9594

9695
var servicesSources = [
97-
"collections.ts",
9896
"core.ts",
9997
"performance.ts",
10098
"sys.ts",

scripts/processDiagnosticMessages.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function main(): void {
2727

2828
var inputFilePath = sys.args[0].replace(/\\/g, "/");
2929
var inputStr = sys.readFile(inputFilePath);
30-
30+
3131
var diagnosticMessages: InputDiagnosticMessageTable = JSON.parse(inputStr);
3232

3333
var names = Utilities.getObjectKeys(diagnosticMessages);
@@ -44,7 +44,7 @@ function main(): void {
4444
function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosticMessageTable) {
4545
const originalMessageForCode: string[] = [];
4646
let numConflicts = 0;
47-
47+
4848
for (const currentMessage of messages) {
4949
const code = diagnosticTable[currentMessage].code;
5050

@@ -68,19 +68,19 @@ function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosti
6868
}
6969
}
7070

71-
function buildUniqueNameMap(names: string[]): ts.Map<string, string> {
72-
var nameMap = ts.createMap<string, string>();
71+
function buildUniqueNameMap(names: string[]): ts.Map<string> {
72+
var nameMap = ts.createMap<string>();
7373

7474
var uniqueNames = NameGenerator.ensureUniqueness(names, /* isCaseSensitive */ false, /* isFixed */ undefined);
7575

7676
for (var i = 0; i < names.length; i++) {
77-
nameMap.set(names[i], uniqueNames[i]);
77+
nameMap[names[i]] = uniqueNames[i];
7878
}
7979

8080
return nameMap;
8181
}
8282

83-
function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map<string, string>): string {
83+
function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map<string>): string {
8484
var result =
8585
'// <auto-generated />\r\n' +
8686
'/// <reference path="types.ts" />\r\n' +
@@ -91,7 +91,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
9191
for (var i = 0; i < names.length; i++) {
9292
var name = names[i];
9393
var diagnosticDetails = messageTable[name];
94-
var propName = convertPropertyName(nameMap.get(name));
94+
var propName = convertPropertyName(nameMap[name]);
9595

9696
result +=
9797
' ' + propName +
@@ -107,14 +107,14 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
107107
return result;
108108
}
109109

110-
function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map<string, string>): string {
110+
function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map<string>): string {
111111
var result =
112112
'{';
113113
var names = Utilities.getObjectKeys(messageTable);
114114
for (var i = 0; i < names.length; i++) {
115115
var name = names[i];
116116
var diagnosticDetails = messageTable[name];
117-
var propName = convertPropertyName(nameMap.get(name));
117+
var propName = convertPropertyName(nameMap[name]);
118118

119119
result += '\r\n "' + createKey(propName, diagnosticDetails.code) + '"' + ' : "' + name.replace(/[\"]/g, '\\"') + '"';
120120
if (i !== names.length - 1) {

src/compiler/binder.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ namespace ts {
133133

134134
let symbolCount = 0;
135135
let Symbol: { new (flags: SymbolFlags, name: string): Symbol };
136-
let classifiableNames: Set<string>;
136+
let classifiableNames: Map<string>;
137137

138138
const unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
139139
const reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
@@ -147,7 +147,7 @@ namespace ts {
147147
options = opts;
148148
languageVersion = getEmitScriptTarget(options);
149149
inStrictMode = bindInStrictMode(file, opts);
150-
classifiableNames = createSet();
150+
classifiableNames = createMap<string>();
151151
symbolCount = 0;
152152
skipTransformFlagAggregation = isDeclarationFile(file);
153153

@@ -207,11 +207,11 @@ namespace ts {
207207
symbol.declarations.push(node);
208208

209209
if (symbolFlags & SymbolFlags.HasExports && !symbol.exports) {
210-
symbol.exports = createMap<string, Symbol>();
210+
symbol.exports = createMap<Symbol>();
211211
}
212212

213213
if (symbolFlags & SymbolFlags.HasMembers && !symbol.members) {
214-
symbol.members = createMap<string, Symbol>();
214+
symbol.members = createMap<Symbol>();
215215
}
216216

217217
if (symbolFlags & SymbolFlags.Value) {
@@ -349,17 +349,17 @@ namespace ts {
349349
// Otherwise, we'll be merging into a compatible existing symbol (for example when
350350
// you have multiple 'vars' with the same name in the same container). In this case
351351
// just add this node into the declarations list of the symbol.
352-
symbol = getOrUpdate(symbolTable, name, name => createSymbol(SymbolFlags.None, name));
352+
symbol = symbolTable[name] || (symbolTable[name] = createSymbol(SymbolFlags.None, name));
353353

354354
if (name && (includes & SymbolFlags.Classifiable)) {
355-
classifiableNames.add(name);
355+
classifiableNames[name] = name;
356356
}
357357

358358
if (symbol.flags & excludes) {
359359
if (symbol.isReplaceableByMethod) {
360360
// Javascript constructor-declared symbols can be discarded in favor of
361361
// prototype symbols like methods.
362-
symbol = setAndReturn(symbolTable, name, createSymbol(SymbolFlags.None, name));
362+
symbol = symbolTable[name] = createSymbol(SymbolFlags.None, name);
363363
}
364364
else {
365365
if (node.name) {
@@ -484,7 +484,7 @@ namespace ts {
484484
if (containerFlags & ContainerFlags.IsContainer) {
485485
container = blockScopeContainer = node;
486486
if (containerFlags & ContainerFlags.HasLocals) {
487-
container.locals = createMap<string, Symbol>();
487+
container.locals = createMap<Symbol>();
488488
}
489489
addToContainerChain(container);
490490
}
@@ -1525,7 +1525,8 @@ namespace ts {
15251525

15261526
const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type");
15271527
addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral);
1528-
typeLiteralSymbol.members = createMap([[symbol.name, symbol]]);
1528+
typeLiteralSymbol.members = createMap<Symbol>();
1529+
typeLiteralSymbol.members[symbol.name] = symbol;
15291530
}
15301531

15311532
function bindObjectLiteralExpression(node: ObjectLiteralExpression) {
@@ -1535,7 +1536,7 @@ namespace ts {
15351536
}
15361537

15371538
if (inStrictMode) {
1538-
const seen = createMap<string, ElementKind>();
1539+
const seen = createMap<ElementKind>();
15391540

15401541
for (const prop of node.properties) {
15411542
if (prop.name.kind !== SyntaxKind.Identifier) {
@@ -1556,9 +1557,9 @@ namespace ts {
15561557
? ElementKind.Property
15571558
: ElementKind.Accessor;
15581559

1559-
const existingKind = seen.get(identifier.text);
1560+
const existingKind = seen[identifier.text];
15601561
if (!existingKind) {
1561-
seen.set(identifier.text, currentKind);
1562+
seen[identifier.text] = currentKind;
15621563
continue;
15631564
}
15641565

@@ -1591,7 +1592,7 @@ namespace ts {
15911592
// fall through.
15921593
default:
15931594
if (!blockScopeContainer.locals) {
1594-
blockScopeContainer.locals = createMap<string, Symbol>();
1595+
blockScopeContainer.locals = createMap<Symbol>();
15951596
addToContainerChain(blockScopeContainer);
15961597
}
15971598
declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes);
@@ -2071,7 +2072,7 @@ namespace ts {
20712072
}
20722073
}
20732074

2074-
file.symbol.globalExports = file.symbol.globalExports || createMap<string, Symbol>();
2075+
file.symbol.globalExports = file.symbol.globalExports || createMap<Symbol>();
20752076
declareSymbol(file.symbol.globalExports, file.symbol, node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
20762077
}
20772078

@@ -2118,7 +2119,7 @@ namespace ts {
21182119
Debug.assert(isInJavaScriptFile(node));
21192120
// Declare a 'member' if the container is an ES5 class or ES6 constructor
21202121
if (container.kind === SyntaxKind.FunctionDeclaration || container.kind === SyntaxKind.FunctionExpression) {
2121-
container.symbol.members = container.symbol.members || createMap<string, Symbol>();
2122+
container.symbol.members = container.symbol.members || createMap<Symbol>();
21222123
// It's acceptable for multiple 'this' assignments of the same identifier to occur
21232124
declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property);
21242125
}
@@ -2150,14 +2151,14 @@ namespace ts {
21502151
constructorFunction.parent = classPrototype;
21512152
classPrototype.parent = leftSideOfAssignment;
21522153

2153-
const funcSymbol = container.locals.get(constructorFunction.text);
2154+
const funcSymbol = container.locals[constructorFunction.text];
21542155
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
21552156
return;
21562157
}
21572158

21582159
// Set up the members collection if it doesn't exist already
21592160
if (!funcSymbol.members) {
2160-
funcSymbol.members = createMap<string, Symbol>();
2161+
funcSymbol.members = createMap<Symbol>();
21612162
}
21622163

21632164
// Declare the method/property
@@ -2190,7 +2191,7 @@ namespace ts {
21902191
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName);
21912192
// Add name of class expression into the map for semantic classifier
21922193
if (node.name) {
2193-
classifiableNames.add(node.name.text);
2194+
classifiableNames[node.name.text] = node.name.text;
21942195
}
21952196
}
21962197

@@ -2206,15 +2207,14 @@ namespace ts {
22062207
// module might have an exported variable called 'prototype'. We can't allow that as
22072208
// that would clash with the built-in 'prototype' for the class.
22082209
const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype");
2209-
const symbolExport = symbol.exports.get(prototypeSymbol.name);
2210-
if (symbolExport) {
2210+
if (symbol.exports[prototypeSymbol.name]) {
22112211
if (node.name) {
22122212
node.name.parent = node;
22132213
}
2214-
file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0],
2214+
file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0],
22152215
Diagnostics.Duplicate_identifier_0, prototypeSymbol.name));
22162216
}
2217-
symbol.exports.set(prototypeSymbol.name, prototypeSymbol);
2217+
symbol.exports[prototypeSymbol.name] = prototypeSymbol;
22182218
prototypeSymbol.parent = symbol;
22192219
}
22202220

0 commit comments

Comments
 (0)