mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'es2015-cleanup' into asyncGenerators
This commit is contained in:
+17
-13
@@ -1862,19 +1862,6 @@ namespace ts {
|
||||
|
||||
// Utilities
|
||||
|
||||
export function restoreEnclosingLabels(node: Statement, enclosingLabeledStatements: LabeledStatement[]) {
|
||||
if (enclosingLabeledStatements) {
|
||||
for (const labeledStatement of enclosingLabeledStatements) {
|
||||
node = updateLabel(
|
||||
labeledStatement,
|
||||
labeledStatement.label,
|
||||
node
|
||||
);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createForOfBindingStatement(node: ForInitializer, boundValue: Expression): Statement {
|
||||
if (isVariableDeclarationList(node)) {
|
||||
const firstDeclaration = firstOrUndefined(node.declarations);
|
||||
@@ -1906,6 +1893,23 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function restoreEnclosingLabel(node: Statement, outermostLabeledStatement: LabeledStatement, afterRestoreLabelCallback?: (node: LabeledStatement) => void): Statement {
|
||||
if (!outermostLabeledStatement) {
|
||||
return node;
|
||||
}
|
||||
const updated = updateLabel(
|
||||
outermostLabeledStatement,
|
||||
outermostLabeledStatement.label,
|
||||
outermostLabeledStatement.statement.kind === SyntaxKind.LabeledStatement
|
||||
? restoreEnclosingLabel(node, <LabeledStatement>outermostLabeledStatement.statement)
|
||||
: node
|
||||
);
|
||||
if (afterRestoreLabelCallback) {
|
||||
afterRestoreLabelCallback(outermostLabeledStatement);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
export interface CallBinding {
|
||||
target: LeftHandSideExpression;
|
||||
thisArg: Expression;
|
||||
|
||||
+557
-428
File diff suppressed because it is too large
Load Diff
@@ -156,16 +156,16 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitLabeledStatement(node: LabeledStatement): VisitResult<Statement> {
|
||||
const enclosedStatement = getEnclosedStatement(node);
|
||||
if (enclosedStatement.statement.kind === SyntaxKind.ForOfStatement &&
|
||||
(<ForOfStatement>enclosedStatement.statement).awaitModifier) {
|
||||
return visitForOfStatement(<ForOfStatement>node.statement, enclosedStatement.enclosingLabeledStatements);
|
||||
const statement = unwrapInnermostStatmentOfLabel(node);
|
||||
if (statement.kind === SyntaxKind.ForOfStatement &&
|
||||
(<ForOfStatement>statement).awaitModifier) {
|
||||
return visitForOfStatement(<ForOfStatement>statement, node);
|
||||
}
|
||||
|
||||
return restoreEnclosingLabels(visitEachChild(node, visitor, context), enclosedStatement.enclosingLabeledStatements);
|
||||
return restoreEnclosingLabel(visitEachChild(node, visitor, context), node);
|
||||
}
|
||||
|
||||
function visitForOfStatement(node: ForOfStatement, enclosingLabeledStatements: LabeledStatement[]): VisitResult<Statement> {
|
||||
function visitForOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement): VisitResult<Statement> {
|
||||
if (!node.awaitModifier) return visitEachChild(node, visitor, context);
|
||||
|
||||
let bodyLocation: TextRange;
|
||||
@@ -247,7 +247,7 @@ namespace ts {
|
||||
EmitFlags.NoTokenTrailingSourceMaps
|
||||
);
|
||||
|
||||
outerStatement = restoreEnclosingLabels(outerStatement, enclosingLabeledStatements);
|
||||
outerStatement = restoreEnclosingLabel(outerStatement, outermostLabeledStatement);
|
||||
return closeAsyncIterator(outerStatement, iteratorRecord);
|
||||
}
|
||||
|
||||
|
||||
@@ -900,20 +900,18 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getEnclosedStatement(node: LabeledStatement): { statement: Statement; enclosingLabeledStatements: LabeledStatement[]; } {
|
||||
switch (node.statement.kind) {
|
||||
case SyntaxKind.LabeledStatement:
|
||||
const result = getEnclosedStatement(<LabeledStatement>node.statement);
|
||||
if (result) {
|
||||
result.enclosingLabeledStatements.push(node);
|
||||
}
|
||||
return result;
|
||||
default:
|
||||
return { statement: <IterationStatement>node.statement, enclosingLabeledStatements: [node] };
|
||||
export function unwrapInnermostStatmentOfLabel(node: LabeledStatement, beforeUnwrapLabelCallback?: (node: LabeledStatement) => void) {
|
||||
while (true) {
|
||||
if (beforeUnwrapLabelCallback) {
|
||||
beforeUnwrapLabelCallback(node);
|
||||
}
|
||||
if (node.statement.kind !== SyntaxKind.LabeledStatement) {
|
||||
return node.statement;
|
||||
}
|
||||
node = <LabeledStatement>node.statement;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function isFunctionBlock(node: Node) {
|
||||
return node && node.kind === SyntaxKind.Block && isFunctionLike(node.parent);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ var A = (function () {
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
var _this = _super.call(this, function () { return _super.blah.call(_this); }) || this;
|
||||
var _this = _super.call(this, function () { return _super.prototype.blah.call(_this); }) || this;
|
||||
return _this;
|
||||
}
|
||||
return B;
|
||||
|
||||
@@ -41,9 +41,9 @@ var Q = (function (_super) {
|
||||
__extends(Q, _super);
|
||||
// Super is not allowed in constructor args
|
||||
function Q(z, zz, zzz) {
|
||||
if (z === void 0) { z = _super.; }
|
||||
if (zz === void 0) { zz = _super.; }
|
||||
if (zzz === void 0) { zzz = function () { return _super.; }; }
|
||||
if (z === void 0) { z = _super.prototype.; }
|
||||
if (zz === void 0) { zz = _super.prototype.; }
|
||||
if (zzz === void 0) { zzz = function () { return _super.prototype.; }; }
|
||||
var _this = _super.call(this) || this;
|
||||
_this.z = z;
|
||||
_this.xx = _super.prototype.;
|
||||
|
||||
@@ -27,7 +27,7 @@ var B = (function () {
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C(a) {
|
||||
if (a === void 0) { a = _super.foo.call(_this); }
|
||||
if (a === void 0) { a = _super.prototype.foo.call(_this); }
|
||||
var _this;
|
||||
return _this;
|
||||
}
|
||||
|
||||
@@ -72,14 +72,14 @@ var obj = {
|
||||
}
|
||||
},
|
||||
method: function () {
|
||||
_super.prototype.method.call(this);
|
||||
_super.method.call(this);
|
||||
},
|
||||
get prop() {
|
||||
_super.prototype.method.call(this);
|
||||
_super.method.call(this);
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
_super.prototype.method.call(this);
|
||||
_super.method.call(this);
|
||||
},
|
||||
p1: function () {
|
||||
_super.method.call(this);
|
||||
@@ -110,14 +110,14 @@ var B = (function (_super) {
|
||||
}
|
||||
},
|
||||
method: function () {
|
||||
_super.prototype.method.call(this);
|
||||
_super.method.call(this);
|
||||
},
|
||||
get prop() {
|
||||
_super.prototype.method.call(this);
|
||||
_super.method.call(this);
|
||||
return 10;
|
||||
},
|
||||
set prop(value) {
|
||||
_super.prototype.method.call(this);
|
||||
_super.method.call(this);
|
||||
},
|
||||
p1: function () {
|
||||
_super.method.call(this);
|
||||
|
||||
@@ -26,7 +26,7 @@ var A = (function () {
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
var _this = _super.call(this, _super.blah.call(_this)) || this;
|
||||
var _this = _super.call(this, _super.prototype.blah.call(_this)) || this;
|
||||
return _this;
|
||||
}
|
||||
return B;
|
||||
|
||||
@@ -40,7 +40,7 @@ var C1 = (function (_super) {
|
||||
var C2 = (function (_super) {
|
||||
__extends(C2, _super);
|
||||
function C2() {
|
||||
var _this = _super.call(this, _super.x.call(_this)) || this;
|
||||
var _this = _super.call(this, _super.prototype.x.call(_this)) || this;
|
||||
return _this;
|
||||
}
|
||||
return C2;
|
||||
|
||||
@@ -38,10 +38,10 @@ var ObjectLiteral;
|
||||
var ThisInObjectLiteral = {
|
||||
_foo: '1',
|
||||
get foo() {
|
||||
return _super.prototype._foo;
|
||||
return _super._foo;
|
||||
},
|
||||
set foo(value) {
|
||||
_super.prototype._foo = value;
|
||||
_super._foo = value;
|
||||
},
|
||||
test: function () {
|
||||
return _super._foo;
|
||||
@@ -62,7 +62,7 @@ var SuperObjectTest = (function (_super) {
|
||||
SuperObjectTest.prototype.testing = function () {
|
||||
var test = {
|
||||
get F() {
|
||||
return _super.prototype.test.call(this);
|
||||
return _super.test.call(this);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user