Skip to content

Commit 5b988cd

Browse files
committed
Some emit cleanup for ES6 classes, comments.
1 parent bf383b5 commit 5b988cd

File tree

5 files changed

+189
-142
lines changed

5 files changed

+189
-142
lines changed

src/compiler/checker.ts

-24
Original file line numberDiff line numberDiff line change
@@ -11256,29 +11256,6 @@ module ts {
1125611256
!hasProperty(getGeneratedNamesForSourceFile(getSourceFile(location)), name);
1125711257
}
1125811258

11259-
function getClassDeclarationVariableId(n: Identifier): number {
11260-
Debug.assert(!nodeIsSynthesized(n));
11261-
11262-
let isClassDeclaration = n.parent.kind === SyntaxKind.ClassDeclaration;
11263-
11264-
let symbol =
11265-
(isClassDeclaration ? getSymbolOfNode(n.parent) : undefined) ||
11266-
getNodeLinks(n).resolvedSymbol ||
11267-
resolveName(n, n.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);
11268-
11269-
symbol = getExportSymbolOfValueSymbolIfExported(symbol);
11270-
11271-
let isClass = symbol && (symbol.flags & SymbolFlags.Class) !== 0;
11272-
11273-
if (isClass) {
11274-
// side-effect of calling this method:
11275-
// assign id to symbol if it was not yet set
11276-
getSymbolLinks(symbol);
11277-
return symbol.id;
11278-
}
11279-
return undefined;
11280-
}
11281-
1128211259
function getBlockScopedVariableId(n: Identifier): number {
1128311260
Debug.assert(!nodeIsSynthesized(n));
1128411261

@@ -11335,7 +11312,6 @@ module ts {
1133511312
getConstantValue,
1133611313
isUnknownIdentifier,
1133711314
getBlockScopedVariableId,
11338-
getClassDeclarationVariableId,
1133911315
};
1134011316
}
1134111317

src/compiler/core.ts

+33
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,39 @@ module ts {
160160
return ~low;
161161
}
162162

163+
export function foldLeft<T>(array: T[], f: (a: T, x: T) => T): T;
164+
export function foldLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
165+
export function foldLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
166+
if (array) {
167+
var count = array.length;
168+
if (count > 0) {
169+
var pos = 0;
170+
var result = arguments.length <= 2 ? array[pos++] : initial;
171+
while (pos < count) {
172+
result = f(<U>result, array[pos++]);
173+
}
174+
return <U>result;
175+
}
176+
}
177+
return initial;
178+
}
179+
180+
export function foldRight<T>(array: T[], f: (a: T, x: T) => T): T;
181+
export function foldRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
182+
export function foldRight<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
183+
if (array) {
184+
var pos = array.length - 1;
185+
if (pos >= 0) {
186+
var result = arguments.length <= 2 ? array[pos--] : initial;
187+
while (pos >= 0) {
188+
result = f(<U>result, array[pos--]);
189+
}
190+
return <U>result;
191+
}
192+
}
193+
return initial;
194+
}
195+
163196
let hasOwnProperty = Object.prototype.hasOwnProperty;
164197

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

0 commit comments

Comments
 (0)