Skip to content

Commit

Permalink
Some emit cleanup for ES6 classes, comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Mar 23, 2015
1 parent bf383b5 commit 5b988cd
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 142 deletions.
24 changes: 0 additions & 24 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11256,29 +11256,6 @@ module ts {
!hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name);
}

function getClassDeclarationVariableId(n: Identifier): number {
Debug.assert(!nodeIsSynthesized(n));

let isClassDeclaration = n.parent.kind === SyntaxKind.ClassDeclaration;

let symbol =
(isClassDeclaration ? getSymbolOfNode(n.parent) : undefined) ||
getNodeLinks(n).resolvedSymbol ||
resolveName(n, n.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);

symbol = getExportSymbolOfValueSymbolIfExported(symbol);

let isClass = symbol && (symbol.flags & SymbolFlags.Class) !== 0;

if (isClass) {
// side-effect of calling this method:
// assign id to symbol if it was not yet set
getSymbolLinks(symbol);
return symbol.id;
}
return undefined;
}

function getBlockScopedVariableId(n: Identifier): number {
Debug.assert(!nodeIsSynthesized(n));

Expand Down Expand Up @@ -11335,7 +11312,6 @@ module ts {
getConstantValue,
isUnknownIdentifier,
getBlockScopedVariableId,
getClassDeclarationVariableId,
};
}

Expand Down
33 changes: 33 additions & 0 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,39 @@ module ts {
return ~low;
}

export function foldLeft<T>(array: T[], f: (a: T, x: T) => T): T;

This comment has been minimized.

Copy link
@JsonFreeman

JsonFreeman Mar 24, 2015

Contributor

Let's call it reduceLeft and reduceRight to match javascript

export function foldLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
export function foldLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
if (array) {
var count = array.length;
if (count > 0) {
var pos = 0;
var result = arguments.length <= 2 ? array[pos++] : initial;
while (pos < count) {
result = f(<U>result, array[pos++]);
}
return <U>result;
}
}
return initial;
}

export function foldRight<T>(array: T[], f: (a: T, x: T) => T): T;
export function foldRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
export function foldRight<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
if (array) {
var pos = array.length - 1;
if (pos >= 0) {
var result = arguments.length <= 2 ? array[pos--] : initial;
while (pos >= 0) {
result = f(<U>result, array[pos--]);
}
return <U>result;
}
}
return initial;
}

let hasOwnProperty = Object.prototype.hasOwnProperty;

export function hasProperty<T>(map: Map<T>, key: string): boolean {
Expand Down
Loading

0 comments on commit 5b988cd

Please sign in to comment.