Skip to content

Commit

Permalink
Merge pull request #11908 from Microsoft/revert_map4
Browse files Browse the repository at this point in the history
Revert "Merge pull request #11354 from Microsoft/map4"
  • Loading branch information
Andy authored Oct 27, 2016
2 parents adfdae0 + 12f6dce commit d32c526
Show file tree
Hide file tree
Showing 68 changed files with 1,430 additions and 1,781 deletions.
2 changes: 0 additions & 2 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function measure(marker) {
}

var compilerSources = [
"collections.ts",
"core.ts",
"performance.ts",
"sys.ts",
Expand Down Expand Up @@ -94,7 +93,6 @@ var compilerSources = [
});

var servicesSources = [
"collections.ts",
"core.ts",
"performance.ts",
"sys.ts",
Expand Down
18 changes: 9 additions & 9 deletions scripts/processDiagnosticMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function main(): void {

var inputFilePath = sys.args[0].replace(/\\/g, "/");
var inputStr = sys.readFile(inputFilePath);

var diagnosticMessages: InputDiagnosticMessageTable = JSON.parse(inputStr);

var names = Utilities.getObjectKeys(diagnosticMessages);
Expand All @@ -44,7 +44,7 @@ function main(): void {
function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosticMessageTable) {
const originalMessageForCode: string[] = [];
let numConflicts = 0;

for (const currentMessage of messages) {
const code = diagnosticTable[currentMessage].code;

Expand All @@ -68,19 +68,19 @@ function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosti
}
}

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

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

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

return nameMap;
}

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

result +=
' ' + propName +
Expand All @@ -107,14 +107,14 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
return result;
}

function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map<string, string>): string {
function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map<string>): string {
var result =
'{';
var names = Utilities.getObjectKeys(messageTable);
for (var i = 0; i < names.length; i++) {
var name = names[i];
var diagnosticDetails = messageTable[name];
var propName = convertPropertyName(nameMap.get(name));
var propName = convertPropertyName(nameMap[name]);

result += '\r\n "' + createKey(propName, diagnosticDetails.code) + '"' + ' : "' + name.replace(/[\"]/g, '\\"') + '"';
if (i !== names.length - 1) {
Expand Down
44 changes: 22 additions & 22 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace ts {

let symbolCount = 0;
let Symbol: { new (flags: SymbolFlags, name: string): Symbol };
let classifiableNames: Set<string>;
let classifiableNames: Map<string>;

const unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
const reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
Expand All @@ -147,7 +147,7 @@ namespace ts {
options = opts;
languageVersion = getEmitScriptTarget(options);
inStrictMode = bindInStrictMode(file, opts);
classifiableNames = createSet();
classifiableNames = createMap<string>();
symbolCount = 0;
skipTransformFlagAggregation = isDeclarationFile(file);

Expand Down Expand Up @@ -207,11 +207,11 @@ namespace ts {
symbol.declarations.push(node);

if (symbolFlags & SymbolFlags.HasExports && !symbol.exports) {
symbol.exports = createMap<string, Symbol>();
symbol.exports = createMap<Symbol>();
}

if (symbolFlags & SymbolFlags.HasMembers && !symbol.members) {
symbol.members = createMap<string, Symbol>();
symbol.members = createMap<Symbol>();
}

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

if (name && (includes & SymbolFlags.Classifiable)) {
classifiableNames.add(name);
classifiableNames[name] = name;
}

if (symbol.flags & excludes) {
if (symbol.isReplaceableByMethod) {
// Javascript constructor-declared symbols can be discarded in favor of
// prototype symbols like methods.
symbol = setAndReturn(symbolTable, name, createSymbol(SymbolFlags.None, name));
symbol = symbolTable[name] = createSymbol(SymbolFlags.None, name);
}
else {
if (node.name) {
Expand Down Expand Up @@ -484,7 +484,7 @@ namespace ts {
if (containerFlags & ContainerFlags.IsContainer) {
container = blockScopeContainer = node;
if (containerFlags & ContainerFlags.HasLocals) {
container.locals = createMap<string, Symbol>();
container.locals = createMap<Symbol>();
}
addToContainerChain(container);
}
Expand Down Expand Up @@ -1525,7 +1525,8 @@ namespace ts {

const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type");
addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral);
typeLiteralSymbol.members = createMap([[symbol.name, symbol]]);
typeLiteralSymbol.members = createMap<Symbol>();
typeLiteralSymbol.members[symbol.name] = symbol;
}

function bindObjectLiteralExpression(node: ObjectLiteralExpression) {
Expand All @@ -1535,7 +1536,7 @@ namespace ts {
}

if (inStrictMode) {
const seen = createMap<string, ElementKind>();
const seen = createMap<ElementKind>();

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

const existingKind = seen.get(identifier.text);
const existingKind = seen[identifier.text];
if (!existingKind) {
seen.set(identifier.text, currentKind);
seen[identifier.text] = currentKind;
continue;
}

Expand Down Expand Up @@ -1591,7 +1592,7 @@ namespace ts {
// fall through.
default:
if (!blockScopeContainer.locals) {
blockScopeContainer.locals = createMap<string, Symbol>();
blockScopeContainer.locals = createMap<Symbol>();
addToContainerChain(blockScopeContainer);
}
declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes);
Expand Down Expand Up @@ -2071,7 +2072,7 @@ namespace ts {
}
}

file.symbol.globalExports = file.symbol.globalExports || createMap<string, Symbol>();
file.symbol.globalExports = file.symbol.globalExports || createMap<Symbol>();
declareSymbol(file.symbol.globalExports, file.symbol, node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
}

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

const funcSymbol = container.locals.get(constructorFunction.text);
const funcSymbol = container.locals[constructorFunction.text];
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
return;
}

// Set up the members collection if it doesn't exist already
if (!funcSymbol.members) {
funcSymbol.members = createMap<string, Symbol>();
funcSymbol.members = createMap<Symbol>();
}

// Declare the method/property
Expand Down Expand Up @@ -2190,7 +2191,7 @@ namespace ts {
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName);
// Add name of class expression into the map for semantic classifier
if (node.name) {
classifiableNames.add(node.name.text);
classifiableNames[node.name.text] = node.name.text;
}
}

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

Expand Down
Loading

0 comments on commit d32c526

Please sign in to comment.