mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
Add experimental option to cache the .length access in downlevel for-of emit.
This commit is contained in:
39
bin/tsc.js
39
bin/tsc.js
@@ -11815,7 +11815,7 @@ var ts;
|
||||
}
|
||||
ts.bindSourceFile = bindSourceFile;
|
||||
function bindSourceFileWorker(file) {
|
||||
var parent;
|
||||
var _parent;
|
||||
var container;
|
||||
var blockScopeContainer;
|
||||
var lastContainer;
|
||||
@@ -11956,10 +11956,10 @@ var ts;
|
||||
if (symbolKind & 255504) {
|
||||
node.locals = {};
|
||||
}
|
||||
var saveParent = parent;
|
||||
var saveParent = _parent;
|
||||
var saveContainer = container;
|
||||
var savedBlockScopeContainer = blockScopeContainer;
|
||||
parent = node;
|
||||
_parent = node;
|
||||
if (symbolKind & 262128) {
|
||||
container = node;
|
||||
if (lastContainer) {
|
||||
@@ -11972,7 +11972,7 @@ var ts;
|
||||
}
|
||||
ts.forEachChild(node, bind);
|
||||
container = saveContainer;
|
||||
parent = saveParent;
|
||||
_parent = saveParent;
|
||||
blockScopeContainer = savedBlockScopeContainer;
|
||||
}
|
||||
function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) {
|
||||
@@ -12075,7 +12075,7 @@ var ts;
|
||||
return "__" + ts.indexOf(node.parent.parameters, node);
|
||||
}
|
||||
function bind(node) {
|
||||
node.parent = parent;
|
||||
node.parent = _parent;
|
||||
switch (node.kind) {
|
||||
case 127:
|
||||
bindDeclaration(node, 262144, 530912, false);
|
||||
@@ -12209,10 +12209,10 @@ var ts;
|
||||
bindChildren(node, 0, true);
|
||||
break;
|
||||
default:
|
||||
var saveParent = parent;
|
||||
parent = node;
|
||||
var saveParent = _parent;
|
||||
_parent = node;
|
||||
ts.forEachChild(node, bind);
|
||||
parent = saveParent;
|
||||
_parent = saveParent;
|
||||
}
|
||||
}
|
||||
function bindParameter(node) {
|
||||
@@ -24542,6 +24542,7 @@ var ts;
|
||||
var rhsIsIdentifier = node.expression.kind === 64;
|
||||
var counter = createTempVariable(node, true);
|
||||
var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(node, false);
|
||||
var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, false) : undefined;
|
||||
emitStart(node.expression);
|
||||
write("var ");
|
||||
emitNodeWithoutSourceMap(counter);
|
||||
@@ -24555,12 +24556,24 @@ var ts;
|
||||
emitNodeWithoutSourceMap(node.expression);
|
||||
emitEnd(node.expression);
|
||||
}
|
||||
if (cachedLength) {
|
||||
write(", ");
|
||||
emitNodeWithoutSourceMap(cachedLength);
|
||||
write(" = ");
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
}
|
||||
write("; ");
|
||||
emitStart(node.initializer);
|
||||
emitNodeWithoutSourceMap(counter);
|
||||
write(" < ");
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
if (cachedLength) {
|
||||
emitNodeWithoutSourceMap(cachedLength);
|
||||
}
|
||||
else {
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
}
|
||||
emitEnd(node.initializer);
|
||||
write("; ");
|
||||
emitStart(node.initializer);
|
||||
@@ -26921,6 +26934,12 @@ var ts;
|
||||
description: ts.Diagnostics.Preserve_new_lines_when_emitting_code,
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "cacheDownlevelForOfLength",
|
||||
type: "boolean",
|
||||
description: "Cache length access when downlevel emitting for-of statements",
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "target",
|
||||
shortName: "t",
|
||||
|
||||
@@ -7473,6 +7473,12 @@ var ts;
|
||||
description: ts.Diagnostics.Preserve_new_lines_when_emitting_code,
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "cacheDownlevelForOfLength",
|
||||
type: "boolean",
|
||||
description: "Cache length access when downlevel emitting for-of statements",
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "target",
|
||||
shortName: "t",
|
||||
@@ -12165,7 +12171,7 @@ var ts;
|
||||
}
|
||||
ts.bindSourceFile = bindSourceFile;
|
||||
function bindSourceFileWorker(file) {
|
||||
var parent;
|
||||
var _parent;
|
||||
var container;
|
||||
var blockScopeContainer;
|
||||
var lastContainer;
|
||||
@@ -12306,10 +12312,10 @@ var ts;
|
||||
if (symbolKind & 255504) {
|
||||
node.locals = {};
|
||||
}
|
||||
var saveParent = parent;
|
||||
var saveParent = _parent;
|
||||
var saveContainer = container;
|
||||
var savedBlockScopeContainer = blockScopeContainer;
|
||||
parent = node;
|
||||
_parent = node;
|
||||
if (symbolKind & 262128) {
|
||||
container = node;
|
||||
if (lastContainer) {
|
||||
@@ -12322,7 +12328,7 @@ var ts;
|
||||
}
|
||||
ts.forEachChild(node, bind);
|
||||
container = saveContainer;
|
||||
parent = saveParent;
|
||||
_parent = saveParent;
|
||||
blockScopeContainer = savedBlockScopeContainer;
|
||||
}
|
||||
function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) {
|
||||
@@ -12425,7 +12431,7 @@ var ts;
|
||||
return "__" + ts.indexOf(node.parent.parameters, node);
|
||||
}
|
||||
function bind(node) {
|
||||
node.parent = parent;
|
||||
node.parent = _parent;
|
||||
switch (node.kind) {
|
||||
case 127:
|
||||
bindDeclaration(node, 262144, 530912, false);
|
||||
@@ -12559,10 +12565,10 @@ var ts;
|
||||
bindChildren(node, 0, true);
|
||||
break;
|
||||
default:
|
||||
var saveParent = parent;
|
||||
parent = node;
|
||||
var saveParent = _parent;
|
||||
_parent = node;
|
||||
ts.forEachChild(node, bind);
|
||||
parent = saveParent;
|
||||
_parent = saveParent;
|
||||
}
|
||||
}
|
||||
function bindParameter(node) {
|
||||
@@ -24892,6 +24898,7 @@ var ts;
|
||||
var rhsIsIdentifier = node.expression.kind === 64;
|
||||
var counter = createTempVariable(node, true);
|
||||
var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(node, false);
|
||||
var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, false) : undefined;
|
||||
emitStart(node.expression);
|
||||
write("var ");
|
||||
emitNodeWithoutSourceMap(counter);
|
||||
@@ -24905,12 +24912,24 @@ var ts;
|
||||
emitNodeWithoutSourceMap(node.expression);
|
||||
emitEnd(node.expression);
|
||||
}
|
||||
if (cachedLength) {
|
||||
write(", ");
|
||||
emitNodeWithoutSourceMap(cachedLength);
|
||||
write(" = ");
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
}
|
||||
write("; ");
|
||||
emitStart(node.initializer);
|
||||
emitNodeWithoutSourceMap(counter);
|
||||
write(" < ");
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
if (cachedLength) {
|
||||
emitNodeWithoutSourceMap(cachedLength);
|
||||
}
|
||||
else {
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
}
|
||||
emitEnd(node.initializer);
|
||||
write("; ");
|
||||
emitStart(node.initializer);
|
||||
|
||||
1
bin/typescript.d.ts
vendored
1
bin/typescript.d.ts
vendored
@@ -1202,6 +1202,7 @@ declare module "typescript" {
|
||||
watch?: boolean;
|
||||
stripInternal?: boolean;
|
||||
preserveNewLines?: boolean;
|
||||
cacheDownlevelForOfLength?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
|
||||
@@ -12444,7 +12444,7 @@ var ts;
|
||||
}
|
||||
ts.bindSourceFile = bindSourceFile;
|
||||
function bindSourceFileWorker(file) {
|
||||
var parent;
|
||||
var _parent;
|
||||
var container;
|
||||
var blockScopeContainer;
|
||||
var lastContainer;
|
||||
@@ -12585,10 +12585,10 @@ var ts;
|
||||
if (symbolKind & 255504) {
|
||||
node.locals = {};
|
||||
}
|
||||
var saveParent = parent;
|
||||
var saveParent = _parent;
|
||||
var saveContainer = container;
|
||||
var savedBlockScopeContainer = blockScopeContainer;
|
||||
parent = node;
|
||||
_parent = node;
|
||||
if (symbolKind & 262128) {
|
||||
container = node;
|
||||
if (lastContainer) {
|
||||
@@ -12601,7 +12601,7 @@ var ts;
|
||||
}
|
||||
ts.forEachChild(node, bind);
|
||||
container = saveContainer;
|
||||
parent = saveParent;
|
||||
_parent = saveParent;
|
||||
blockScopeContainer = savedBlockScopeContainer;
|
||||
}
|
||||
function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) {
|
||||
@@ -12704,7 +12704,7 @@ var ts;
|
||||
return "__" + ts.indexOf(node.parent.parameters, node);
|
||||
}
|
||||
function bind(node) {
|
||||
node.parent = parent;
|
||||
node.parent = _parent;
|
||||
switch (node.kind) {
|
||||
case 127:
|
||||
bindDeclaration(node, 262144, 530912, false);
|
||||
@@ -12838,10 +12838,10 @@ var ts;
|
||||
bindChildren(node, 0, true);
|
||||
break;
|
||||
default:
|
||||
var saveParent = parent;
|
||||
parent = node;
|
||||
var saveParent = _parent;
|
||||
_parent = node;
|
||||
ts.forEachChild(node, bind);
|
||||
parent = saveParent;
|
||||
_parent = saveParent;
|
||||
}
|
||||
}
|
||||
function bindParameter(node) {
|
||||
@@ -25171,6 +25171,7 @@ var ts;
|
||||
var rhsIsIdentifier = node.expression.kind === 64;
|
||||
var counter = createTempVariable(node, true);
|
||||
var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(node, false);
|
||||
var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, false) : undefined;
|
||||
emitStart(node.expression);
|
||||
write("var ");
|
||||
emitNodeWithoutSourceMap(counter);
|
||||
@@ -25184,12 +25185,24 @@ var ts;
|
||||
emitNodeWithoutSourceMap(node.expression);
|
||||
emitEnd(node.expression);
|
||||
}
|
||||
if (cachedLength) {
|
||||
write(", ");
|
||||
emitNodeWithoutSourceMap(cachedLength);
|
||||
write(" = ");
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
}
|
||||
write("; ");
|
||||
emitStart(node.initializer);
|
||||
emitNodeWithoutSourceMap(counter);
|
||||
write(" < ");
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
if (cachedLength) {
|
||||
emitNodeWithoutSourceMap(cachedLength);
|
||||
}
|
||||
else {
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
}
|
||||
emitEnd(node.initializer);
|
||||
write("; ");
|
||||
emitStart(node.initializer);
|
||||
@@ -27550,6 +27563,12 @@ var ts;
|
||||
description: ts.Diagnostics.Preserve_new_lines_when_emitting_code,
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "cacheDownlevelForOfLength",
|
||||
type: "boolean",
|
||||
description: "Cache length access when downlevel emitting for-of statements",
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "target",
|
||||
shortName: "t",
|
||||
|
||||
1
bin/typescriptServices.d.ts
vendored
1
bin/typescriptServices.d.ts
vendored
@@ -1202,6 +1202,7 @@ declare module ts {
|
||||
watch?: boolean;
|
||||
stripInternal?: boolean;
|
||||
preserveNewLines?: boolean;
|
||||
cacheDownlevelForOfLength?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
|
||||
@@ -12444,7 +12444,7 @@ var ts;
|
||||
}
|
||||
ts.bindSourceFile = bindSourceFile;
|
||||
function bindSourceFileWorker(file) {
|
||||
var parent;
|
||||
var _parent;
|
||||
var container;
|
||||
var blockScopeContainer;
|
||||
var lastContainer;
|
||||
@@ -12585,10 +12585,10 @@ var ts;
|
||||
if (symbolKind & 255504) {
|
||||
node.locals = {};
|
||||
}
|
||||
var saveParent = parent;
|
||||
var saveParent = _parent;
|
||||
var saveContainer = container;
|
||||
var savedBlockScopeContainer = blockScopeContainer;
|
||||
parent = node;
|
||||
_parent = node;
|
||||
if (symbolKind & 262128) {
|
||||
container = node;
|
||||
if (lastContainer) {
|
||||
@@ -12601,7 +12601,7 @@ var ts;
|
||||
}
|
||||
ts.forEachChild(node, bind);
|
||||
container = saveContainer;
|
||||
parent = saveParent;
|
||||
_parent = saveParent;
|
||||
blockScopeContainer = savedBlockScopeContainer;
|
||||
}
|
||||
function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) {
|
||||
@@ -12704,7 +12704,7 @@ var ts;
|
||||
return "__" + ts.indexOf(node.parent.parameters, node);
|
||||
}
|
||||
function bind(node) {
|
||||
node.parent = parent;
|
||||
node.parent = _parent;
|
||||
switch (node.kind) {
|
||||
case 127:
|
||||
bindDeclaration(node, 262144, 530912, false);
|
||||
@@ -12838,10 +12838,10 @@ var ts;
|
||||
bindChildren(node, 0, true);
|
||||
break;
|
||||
default:
|
||||
var saveParent = parent;
|
||||
parent = node;
|
||||
var saveParent = _parent;
|
||||
_parent = node;
|
||||
ts.forEachChild(node, bind);
|
||||
parent = saveParent;
|
||||
_parent = saveParent;
|
||||
}
|
||||
}
|
||||
function bindParameter(node) {
|
||||
@@ -25171,6 +25171,7 @@ var ts;
|
||||
var rhsIsIdentifier = node.expression.kind === 64;
|
||||
var counter = createTempVariable(node, true);
|
||||
var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(node, false);
|
||||
var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, false) : undefined;
|
||||
emitStart(node.expression);
|
||||
write("var ");
|
||||
emitNodeWithoutSourceMap(counter);
|
||||
@@ -25184,12 +25185,24 @@ var ts;
|
||||
emitNodeWithoutSourceMap(node.expression);
|
||||
emitEnd(node.expression);
|
||||
}
|
||||
if (cachedLength) {
|
||||
write(", ");
|
||||
emitNodeWithoutSourceMap(cachedLength);
|
||||
write(" = ");
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
}
|
||||
write("; ");
|
||||
emitStart(node.initializer);
|
||||
emitNodeWithoutSourceMap(counter);
|
||||
write(" < ");
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
if (cachedLength) {
|
||||
emitNodeWithoutSourceMap(cachedLength);
|
||||
}
|
||||
else {
|
||||
emitNodeWithoutSourceMap(rhsReference);
|
||||
write(".length");
|
||||
}
|
||||
emitEnd(node.initializer);
|
||||
write("; ");
|
||||
emitStart(node.initializer);
|
||||
@@ -27550,6 +27563,12 @@ var ts;
|
||||
description: ts.Diagnostics.Preserve_new_lines_when_emitting_code,
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "cacheDownlevelForOfLength",
|
||||
type: "boolean",
|
||||
description: "Cache length access when downlevel emitting for-of statements",
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "target",
|
||||
shortName: "t",
|
||||
|
||||
Reference in New Issue
Block a user