Skip to content

Commit 25c7caa

Browse files
committed
Simplify es2015 visitor, replace function tracking with flags
1 parent 4e9bc69 commit 25c7caa

File tree

8 files changed

+596
-400
lines changed

8 files changed

+596
-400
lines changed

src/compiler/factory.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,19 @@ namespace ts {
17541754

17551755
// Utilities
17561756

1757+
export function restoreEnclosingLabels(node: Statement, enclosingLabeledStatements: LabeledStatement[]) {
1758+
if (enclosingLabeledStatements) {
1759+
for (const labeledStatement of enclosingLabeledStatements) {
1760+
node = updateLabel(
1761+
labeledStatement,
1762+
labeledStatement.label,
1763+
node
1764+
);
1765+
}
1766+
}
1767+
return node;
1768+
}
1769+
17571770
export interface CallBinding {
17581771
target: LeftHandSideExpression;
17591772
thisArg: Expression;

src/compiler/transformers/es2015.ts

Lines changed: 557 additions & 386 deletions
Large diffs are not rendered by default.

src/compiler/utilities.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,18 @@ namespace ts {
883883
return false;
884884
}
885885

886+
export function getAllLabeledStatements(node: LabeledStatement): { statement: Statement; labeledStatements: LabeledStatement[]; } {
887+
switch (node.statement.kind) {
888+
case SyntaxKind.LabeledStatement:
889+
const result = getAllLabeledStatements(<LabeledStatement>node.statement);
890+
if (result) {
891+
result.labeledStatements.push(node);
892+
}
893+
return result;
894+
default:
895+
return { statement: <IterationStatement>node.statement, labeledStatements: [node] };
896+
}
897+
}
886898

887899
export function isFunctionBlock(node: Node) {
888900
return node && node.kind === SyntaxKind.Block && isFunctionLike(node.parent);

tests/baselines/reference/superAccess2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ var Q = (function (_super) {
4141
__extends(Q, _super);
4242
// Super is not allowed in constructor args
4343
function Q(z, zz, zzz) {
44-
if (z === void 0) { z = _super.; }
45-
if (zz === void 0) { zz = _super.; }
46-
if (zzz === void 0) { zzz = function () { return _super.; }; }
44+
if (z === void 0) { z = _super.prototype.; }
45+
if (zz === void 0) { zz = _super.prototype.; }
46+
if (zzz === void 0) { zzz = function () { return _super.prototype.; }; }
4747
var _this = _super.call(this) || this;
4848
_this.z = z;
4949
_this.xx = _super.prototype.;

tests/baselines/reference/superInConstructorParam1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var B = (function () {
2727
var C = (function (_super) {
2828
__extends(C, _super);
2929
function C(a) {
30-
if (a === void 0) { a = _super.foo.call(_this); }
30+
if (a === void 0) { a = _super.prototype.foo.call(_this); }
3131
var _this;
3232
return _this;
3333
}

tests/baselines/reference/superInObjectLiterals_ES5.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ var obj = {
7272
}
7373
},
7474
method: function () {
75-
_super.prototype.method.call(this);
75+
_super.method.call(this);
7676
},
7777
get prop() {
78-
_super.prototype.method.call(this);
78+
_super.method.call(this);
7979
return 10;
8080
},
8181
set prop(value) {
82-
_super.prototype.method.call(this);
82+
_super.method.call(this);
8383
},
8484
p1: function () {
8585
_super.method.call(this);
@@ -110,14 +110,14 @@ var B = (function (_super) {
110110
}
111111
},
112112
method: function () {
113-
_super.prototype.method.call(this);
113+
_super.method.call(this);
114114
},
115115
get prop() {
116-
_super.prototype.method.call(this);
116+
_super.method.call(this);
117117
return 10;
118118
},
119119
set prop(value) {
120-
_super.prototype.method.call(this);
120+
_super.method.call(this);
121121
},
122122
p1: function () {
123123
_super.method.call(this);

tests/baselines/reference/superPropertyInConstructorBeforeSuperCall.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var C1 = (function (_super) {
4040
var C2 = (function (_super) {
4141
__extends(C2, _super);
4242
function C2() {
43-
return _super.call(this, _super.x.call(_this)) || this;
43+
return _super.call(this, _super.prototype.x.call(_this)) || this;
4444
}
4545
return C2;
4646
}(B));

tests/baselines/reference/super_inside-object-literal-getters-and-setters.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ var ObjectLiteral;
3838
var ThisInObjectLiteral = {
3939
_foo: '1',
4040
get foo() {
41-
return _super.prototype._foo;
41+
return _super._foo;
4242
},
4343
set foo(value) {
44-
_super.prototype._foo = value;
44+
_super._foo = value;
4545
},
4646
test: function () {
4747
return _super._foo;
@@ -62,7 +62,7 @@ var SuperObjectTest = (function (_super) {
6262
SuperObjectTest.prototype.testing = function () {
6363
var test = {
6464
get F() {
65-
return _super.prototype.test.call(this);
65+
return _super.test.call(this);
6666
}
6767
};
6868
};

0 commit comments

Comments
 (0)