Stop using rewrites for object literal downlevel emit.

This commit is contained in:
Daniel Rosenwasser
2015-02-23 17:44:48 -08:00
parent 34bd2987ea
commit a391d70baa
50 changed files with 624 additions and 326 deletions
+192 -3
View File
@@ -2555,6 +2555,195 @@ module ts {
}
}
function emitObjectLiteralBody(node: ObjectLiteralExpression, numElements: number): void {
if (numElements === 0) {
write("{}");
return;
}
write("{");
if (numElements > 0) {
var properties = node.properties;
// If we are not doing a downlevel transformation for object literals,
// then try to preserve the original shape of the object literal.
// Otherwise just try to preserve the formatting.
if (numElements === properties.length) {
emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= ScriptTarget.ES5, /* spacesBetweenBraces */ true);
}
else {
var multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
if (!multiLine) {
write(" ");
}
else {
increaseIndent();
}
emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false);
if (!multiLine) {
write(" ");
}
else {
decreaseIndent();
}
}
}
write("}");
}
function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number) {
var multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
var properties = node.properties;
write("(");
if (multiLine) {
increaseIndent();
}
// For computed properties, we need to create a unique handle to the object
// literal so we can modify it without risking internal assignments tainting the object.
var tempVar = createAndRecordTempVariable(node);
// Write out the first non-computed properties
// (or all properties if none of them are computed),
// then emit the rest through indexing on the temp variable.
emit(tempVar)
write(" = ");
emitObjectLiteralBody(node, firstComputedPropertyIndex);
for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) {
writeComma();
var property = properties[i];
emitStart(property)
if (property.kind === SyntaxKind.GetAccessor || property.kind === SyntaxKind.SetAccessor) {
// TODO (drosen): Reconcile with 'emitMemberFunctions'.
var accessors = getAllAccessorDeclarations(node.properties, <AccessorDeclaration>property);
if (property !== accessors.firstAccessor) {
continue;
}
write("Object.defineProperty(");
emit(tempVar);
write(", ");
emitStart(node.name);
emitExpressionForPropertyName(property.name);
emitEnd(property.name);
write(", {");
increaseIndent();
if (accessors.getAccessor) {
writeLine()
emitLeadingComments(accessors.getAccessor);
write("get: ");
emitStart(accessors.getAccessor);
write("function ");
emitSignatureAndBody(accessors.getAccessor);
emitEnd(accessors.getAccessor);
emitTrailingComments(accessors.getAccessor);
write(",");
}
if (accessors.setAccessor) {
writeLine();
emitLeadingComments(accessors.setAccessor);
write("set: ");
emitStart(accessors.setAccessor);
write("function ");
emitSignatureAndBody(accessors.setAccessor);
emitEnd(accessors.setAccessor);
emitTrailingComments(accessors.setAccessor);
write(",");
}
writeLine();
write("enumerable: true,");
writeLine();
write("configurable: true");
decreaseIndent();
writeLine();
write("})");
emitEnd(property);
}
else {
emitLeadingComments(property);
emitStart(property.name);
emit(tempVar);
emitMemberAccessForPropertyName(property.name);
emitEnd(property.name);
write(" = ");
if (property.kind === SyntaxKind.PropertyAssignment) {
emit((<PropertyAssignment>property).initializer);
}
else if (property.kind === SyntaxKind.ShorthandPropertyAssignment) {
emitExpressionIdentifier((<ShorthandPropertyAssignment>property).name);
}
else if (property.kind === SyntaxKind.MethodDeclaration) {
emitFunctionDeclaration(<MethodDeclaration>property);
}
else {
Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind);
}
}
emitEnd(property);
}
writeComma();
emit(tempVar);
if (multiLine) {
decreaseIndent();
writeLine();
}
write(")");
function writeComma() {
if (multiLine) {
write(",");
writeLine();
}
else {
write(", ");
}
}
}
function emitObjectLiteral(node: ObjectLiteralExpression): void {
var properties = node.properties;
if (languageVersion < ScriptTarget.ES6) {
var numProperties = properties.length;
// Find the first computed property.
// Everything until that point can be emitted as part of the initial object literal.
var numInitialNonComputedProperties = numProperties;
for (var i = 0, n = properties.length; i < n; i++) {
if (properties[i].name.kind === SyntaxKind.ComputedPropertyName) {
numInitialNonComputedProperties = i;
break;
}
}
var hasComputedProperty = numInitialNonComputedProperties !== properties.length;
if (hasComputedProperty) {
emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties);
return;
}
}
// Ordinary case: either the object has no computed properties
// or we're compiling with an ES6+ target.
emitObjectLiteralBody(node, properties.length);
}
function createSynthesizedNode(kind: SyntaxKind): Node {
var node = createNode(kind);
node.pos = -1;
@@ -2563,7 +2752,7 @@ module ts {
return node;
}
function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number): void {
function emitDownlevelObjectLiteralWithComputedPropertiesThroughRewrite(node: ObjectLiteralExpression, firstComputedPropertyIndex: number): void {
var parenthesizedObjectLiteral = createDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex);
return emit(parenthesizedObjectLiteral);
}
@@ -2763,7 +2952,7 @@ module ts {
return result;
}
function emitObjectLiteral(node: ObjectLiteralExpression): void {
function emitObjectLiteralThroughRewrite(node: ObjectLiteralExpression): void {
var properties = node.properties;
if (languageVersion < ScriptTarget.ES6) {
@@ -2781,7 +2970,7 @@ module ts {
var hasComputedProperty = numInitialNonComputedProperties !== properties.length;
if (hasComputedProperty) {
emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties);
emitDownlevelObjectLiteralWithComputedPropertiesThroughRewrite(node, numInitialNonComputedProperties);
return;
}
}
@@ -12,8 +12,9 @@ obj[Symbol.foo];
//// [ES5SymbolProperty1.js]
var Symbol;
var obj = (_a = {}, _a[Symbol.foo] =
0,
_a);
var obj = (_a = {},
_a[Symbol.foo] = 0,
_a
);
obj[Symbol.foo];
var _a;
@@ -2,7 +2,5 @@
var v = { [yield]: foo }
//// [FunctionDeclaration8_es6.js]
var v = (_a = {}, _a[yield] =
foo,
_a);
var v = (_a = {}, _a[yield] = foo, _a);
var _a;
@@ -5,8 +5,6 @@ function * foo() {
//// [FunctionDeclaration9_es6.js]
function foo() {
var v = (_a = {}, _a[] =
foo,
_a);
var v = (_a = {}, _a[] = foo, _a);
var _a;
}
@@ -2,6 +2,5 @@
var v = { *[foo()]() { } }
//// [FunctionPropertyAssignments5_es6.js]
var v = (_a = {}, _a[foo()] = function () { },
_a);
var v = (_a = {}, _a[foo()] = function () { }, _a);
var _a;
@@ -20,6 +20,18 @@ var v = {
var s;
var n;
var a;
var v = (_a = {}, _a[s] = function () { }, _a[n] = function () { }, _a[s + s] = function () { }, _a[s + n] = function () { }, _a[+s] = function () { }, _a[""] = function () { }, _a[0] = function () { }, _a[a] = function () { }, _a[true] = function () { }, _a["hello bye"] = function () { }, _a["hello " + a + " bye"] = function () { },
_a);
var v = (_a = {},
_a[s] = function () { },
_a[n] = function () { },
_a[s + s] = function () { },
_a[s + n] = function () { },
_a[+s] = function () { },
_a[""] = function () { },
_a[0] = function () { },
_a[a] = function () { },
_a[true] = function () { },
_a["hello bye"] = function () { },
_a["hello " + a + " bye"] = function () { },
_a
);
var _a;
@@ -20,6 +20,62 @@ var v = {
var s;
var n;
var a;
var v = (_a = {}, _a[s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[s + s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[s + n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[+s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[""] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[0] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[a] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[true] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a["hello bye"] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a["hello " + a + " bye"] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }),
_a);
var v = (_a = {},
Object.defineProperty(_a, s, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, n, {
set: function (v) { },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, s + s, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, s + n, {
set: function (v) { },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, +s, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, "", {
set: function (v) { },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 0, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, a, {
set: function (v) { },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, true, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, "hello bye", {
set: function (v) { },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, "hello " + a + " bye", {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
_a
);
var _a;
@@ -7,8 +7,9 @@ function foo() {
//// [computedPropertyNames18_ES5.js]
function foo() {
var obj = (_a = {}, _a[this.bar] =
0,
_a);
var obj = (_a = {},
_a[this.bar] = 0,
_a
);
var _a;
}
@@ -8,8 +8,9 @@ module M {
//// [computedPropertyNames19_ES5.js]
var M;
(function (M) {
var obj = (_a = {}, _a[this.bar] =
0,
_a);
var obj = (_a = {},
_a[this.bar] = 0,
_a
);
var _a;
})(M || (M = {}));
@@ -5,6 +5,18 @@ var v = {
}
//// [computedPropertyNames1_ES5.js]
var v = (_a = {}, _a[0 + 1] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a[0 + 1] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }),
_a);
var v = (_a = {},
Object.defineProperty(_a, 0 + 1, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 0 + 1, {
set: function (v) { } //No error
,
enumerable: true,
configurable: true
}),
_a
);
var _a;
@@ -4,7 +4,8 @@ var obj = {
}
//// [computedPropertyNames20_ES5.js]
var obj = (_a = {}, _a[this.bar] =
0,
_a);
var obj = (_a = {},
_a[this.bar] = 0,
_a
);
var _a;
@@ -13,8 +13,10 @@ var C = (function () {
function C() {
}
C.prototype.bar = function () {
var obj = (_a = {}, _a[this.bar()] = function () { },
_a);
var obj = (_a = {},
_a[this.bar()] = function () { },
_a
);
return 0;
var _a;
};
@@ -15,9 +15,7 @@ var C = (function () {
C.prototype.bar = function () {
return 0;
};
C.prototype[(_a = {}, _a[this.bar()] =
1,
_a)[0]] = function () { };
C.prototype[(_a = {}, _a[this.bar()] = 1, _a)[0]] = function () { };
return C;
})();
var _a;
@@ -34,8 +34,10 @@ var C = (function (_super) {
_super.apply(this, arguments);
}
C.prototype.foo = function () {
var obj = (_a = {}, _a[_super.prototype.bar.call(this)] = function () { },
_a);
var obj = (_a = {},
_a[_super.prototype.bar.call(this)] = function () { },
_a
);
return 0;
var _a;
};
@@ -34,9 +34,7 @@ var C = (function (_super) {
}
// Gets emitted as super, not _super, which is consistent with
// use of super in static properties initializers.
C.prototype[(_a = {}, _a[super.bar.call(this)] =
1,
_a)[0]] = function () { };
C.prototype[(_a = {}, _a[super.bar.call(this)] = 1, _a)[0]] = function () { };
return C;
})(Base);
var _a;
@@ -26,8 +26,10 @@ var C = (function (_super) {
__extends(C, _super);
function C() {
_super.call(this);
var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { },
_a);
var obj = (_a = {},
_a[(_super.call(this), "prop")] = function () { },
_a
);
var _a;
}
return C;
@@ -17,8 +17,10 @@ var C = (function () {
C.prototype.bar = function () {
var _this = this;
(function () {
var obj = (_a = {}, _a[_this.bar()] = function () { },
_a);
var obj = (_a = {},
_a[_this.bar()] = function () { },
_a
);
var _a;
});
return 0;
@@ -32,8 +32,13 @@ var C = (function (_super) {
function C() {
_super.call(this);
(function () {
var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { },
_a);
var obj = (_a = {},
// Ideally, we would capture this. But the reference is
// illegal, and not capturing this is consistent with
//treatment of other similar violations.
_a[(_super.call(this), "prop")] = function () { },
_a
);
var _a;
});
}
@@ -38,8 +38,10 @@ var C = (function (_super) {
C.prototype.foo = function () {
var _this = this;
(function () {
var obj = (_a = {}, _a[_super.prototype.bar.call(_this)] = function () { },
_a);
var obj = (_a = {},
_a[_super.prototype.bar.call(_this)] = function () { },
_a
);
var _a;
});
return 0;
@@ -15,8 +15,10 @@ var C = (function () {
function C() {
}
C.prototype.bar = function () {
var obj = (_a = {}, _a[foo()] = function () { },
_a);
var obj = (_a = {},
_a[foo()] = function () { },
_a
);
return 0;
var _a;
};
@@ -15,8 +15,10 @@ var C = (function () {
function C() {
}
C.bar = function () {
var obj = (_a = {}, _a[foo()] = function () { },
_a);
var obj = (_a = {},
_a[foo()] = function () { },
_a
);
return 0;
var _a;
};
@@ -4,7 +4,8 @@ var o = {
};
//// [computedPropertyNames46_ES5.js]
var o = (_a = {}, _a["" || 0] =
0,
_a);
var o = (_a = {},
_a["" || 0] = 0,
_a
);
var _a;
@@ -14,7 +14,8 @@ var E2;
(function (E2) {
E2[E2["x"] = 0] = "x";
})(E2 || (E2 = {}));
var o = (_a = {}, _a[0 /* x */ || 0 /* x */] =
0,
_a);
var o = (_a = {},
_a[0 /* x */ || 0 /* x */] = 0,
_a
);
var _a;
@@ -23,13 +23,16 @@ var E;
E[E["x"] = 0] = "x";
})(E || (E = {}));
var a;
extractIndexer((_a = {}, _a[a] =
"",
_a)); // Should return string
extractIndexer((_b = {}, _b[0 /* x */] =
"",
_b)); // Should return string
extractIndexer((_c = {}, _c["" || 0] =
"",
_c)); // Should return any (widened form of undefined)
extractIndexer((_a = {},
_a[a] = "",
_a
)); // Should return string
extractIndexer((_b = {},
_b[0 /* x */] = "",
_b
)); // Should return string
extractIndexer((_c = {},
_c["" || 0] = "",
_c
)); // Should return any (widened form of undefined)
var _a, _b, _c;
@@ -27,20 +27,41 @@ var x = {
//// [computedPropertyNames49_ES5.js]
var x = (_a = {
p1: 10
}, _a.p1 =
10, _a[1 + 1] = Object.defineProperty({ get: function () {
throw 10;
}, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ get: function () {
return 10;
}, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ set: function () {
// just throw
throw 10;
}, enumerable: true, configurable: true }), _a.foo = Object.defineProperty({ get: function () {
if (1 == 1) {
p1: 10
},
Object.defineProperty(_a, 1 + 1, {
get: function () {
throw 10;
},
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 1 + 1, {
get: function () {
return 10;
}
}, enumerable: true, configurable: true }), _a.p2 =
20,
_a);
},
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 1 + 1, {
set: function () {
// just throw
throw 10;
},
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, "foo", {
get: function () {
if (1 == 1) {
return 10;
}
},
enumerable: true,
configurable: true
}),
,
_a.p2 = 20,
_a
);
var _a;
@@ -20,17 +20,18 @@ var v = {
var s;
var n;
var a;
var v = (_a = {}, _a[s] =
0, _a[n] =
n, _a[s + s] =
1, _a[s + n] =
2, _a[+s] =
s, _a[""] =
0, _a[0] =
0, _a[a] =
1, _a[true] =
0, _a["hello bye"] =
0, _a["hello " + a + " bye"] =
0,
_a);
var v = (_a = {},
_a[s] = 0,
_a[n] = n,
_a[s + s] = 1,
_a[s + n] = 2,
_a[+s] = s,
_a[""] = 0,
_a[0] = 0,
_a[a] = 1,
_a[true] = 0,
_a["hello bye"] = 0,
_a["hello " + a + " bye"] = 0,
_a
);
var _a;
@@ -27,25 +27,37 @@ var x = {
//// [computedPropertyNames50_ES5.js]
var x = (_a = {
p1: 10,
get foo() {
if (1 == 1) {
return 10;
p1: 10,
get foo() {
if (1 == 1) {
return 10;
}
}
}
}, _a.p1 =
10, _a.foo = Object.defineProperty({ get: function () {
if (1 == 1) {
},
Object.defineProperty(_a, 1 + 1, {
get: function () {
throw 10;
},
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 1 + 1, {
set: function () {
// just throw
throw 10;
},
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 1 + 1, {
get: function () {
return 10;
}
}, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ get: function () {
throw 10;
}, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ set: function () {
// just throw
throw 10;
}, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ get: function () {
return 10;
}, enumerable: true, configurable: true }), _a.p2 =
20,
_a);
},
enumerable: true,
configurable: true
}),
,
_a.p2 = 20,
_a
);
var _a;
@@ -11,12 +11,13 @@ var v = {
//// [computedPropertyNames5_ES5.js]
var b;
var v = (_a = {}, _a[b] =
0, _a[true] =
1, _a[[]] =
0, _a[{}] =
0, _a[undefined] =
undefined, _a[null] =
null,
_a);
var v = (_a = {},
_a[b] = 0,
_a[true] = 1,
_a[[]] = 0,
_a[{}] = 0,
_a[undefined] = undefined,
_a[null] = null,
_a
);
var _a;
@@ -12,9 +12,10 @@ var v = {
var p1;
var p2;
var p3;
var v = (_a = {}, _a[p1] =
0, _a[p2] =
1, _a[p3] =
2,
_a);
var v = (_a = {},
_a[p1] = 0,
_a[p2] = 1,
_a[p3] = 2,
_a
);
var _a;
@@ -11,7 +11,8 @@ var E;
(function (E) {
E[E["member"] = 0] = "member";
})(E || (E = {}));
var v = (_a = {}, _a[0 /* member */] =
0,
_a);
var v = (_a = {},
_a[0 /* member */] = 0,
_a
);
var _a;
@@ -12,9 +12,10 @@ function f<T, U extends string>() {
function f() {
var t;
var u;
var v = (_a = {}, _a[t] =
0, _a[u] =
1,
_a);
var v = (_a = {},
_a[t] = 0,
_a[u] = 1,
_a
);
var _a;
}
@@ -12,9 +12,10 @@ var v = {
//// [computedPropertyNames9_ES5.js]
function f(x) { }
var v = (_a = {}, _a[f("")] =
0, _a[f(0)] =
0, _a[f(true)] =
0,
_a);
var v = (_a = {},
_a[f("")] = 0,
_a[f(0)] = 0,
_a[f(true)] = 0,
_a
);
var _a;
@@ -9,8 +9,9 @@ var o: I = {
}
//// [computedPropertyNamesContextualType10_ES5.js]
var o = (_a = {}, _a[+"foo"] =
"", _a[+"bar"] =
0,
_a);
var o = (_a = {},
_a[+"foo"] = "",
_a[+"bar"] = 0,
_a
);
var _a;
@@ -10,7 +10,9 @@ var o: I = {
}
//// [computedPropertyNamesContextualType1_ES5.js]
var o = (_a = {}, _a["" + 0] = function (y) { return y.length; }, _a["" + 1] =
function (y) { return y.length; },
_a);
var o = (_a = {},
_a["" + 0] = function (y) { return y.length; },
_a["" + 1] = function (y) { return y.length; },
_a
);
var _a;
@@ -10,7 +10,9 @@ var o: I = {
}
//// [computedPropertyNamesContextualType2_ES5.js]
var o = (_a = {}, _a[+"foo"] = function (y) { return y.length; }, _a[+"bar"] =
function (y) { return y.length; },
_a);
var o = (_a = {},
_a[+"foo"] = function (y) { return y.length; },
_a[+"bar"] = function (y) { return y.length; },
_a
);
var _a;
@@ -9,7 +9,9 @@ var o: I = {
}
//// [computedPropertyNamesContextualType3_ES5.js]
var o = (_a = {}, _a[+"foo"] = function (y) { return y.length; }, _a[+"bar"] =
function (y) { return y.length; },
_a);
var o = (_a = {},
_a[+"foo"] = function (y) { return y.length; },
_a[+"bar"] = function (y) { return y.length; },
_a
);
var _a;
@@ -10,8 +10,9 @@ var o: I = {
}
//// [computedPropertyNamesContextualType4_ES5.js]
var o = (_a = {}, _a["" + "foo"] =
"", _a["" + "bar"] =
0,
_a);
var o = (_a = {},
_a["" + "foo"] = "",
_a["" + "bar"] = 0,
_a
);
var _a;
@@ -10,8 +10,9 @@ var o: I = {
}
//// [computedPropertyNamesContextualType5_ES5.js]
var o = (_a = {}, _a[+"foo"] =
"", _a[+"bar"] =
0,
_a);
var o = (_a = {},
_a[+"foo"] = "",
_a[+"bar"] = 0,
_a
);
var _a;
@@ -15,13 +15,12 @@ foo({
//// [computedPropertyNamesContextualType6_ES5.js]
foo((_a = {
p: "",
0: function () { }
}, _a.p =
"", _a[0] =
function () { }, _a["hi" + "bye"] =
true, _a[0 + 1] =
0, _a[+"hi"] =
[0],
_a));
p: "",
0: function () { }
},
_a["hi" + "bye"] = true,
_a[0 + 1] = 0,
_a[+"hi"] = [0],
_a
));
var _a;
@@ -15,13 +15,12 @@ foo({
//// [computedPropertyNamesContextualType7_ES5.js]
foo((_a = {
p: "",
0: function () { }
}, _a.p =
"", _a[0] =
function () { }, _a["hi" + "bye"] =
true, _a[0 + 1] =
0, _a[+"hi"] =
[0],
_a));
p: "",
0: function () { }
},
_a["hi" + "bye"] = true,
_a[0 + 1] = 0,
_a[+"hi"] = [0],
_a
));
var _a;
@@ -10,8 +10,9 @@ var o: I = {
}
//// [computedPropertyNamesContextualType8_ES5.js]
var o = (_a = {}, _a["" + "foo"] =
"", _a["" + "bar"] =
0,
_a);
var o = (_a = {},
_a["" + "foo"] = "",
_a["" + "bar"] = 0,
_a
);
var _a;
@@ -10,8 +10,9 @@ var o: I = {
}
//// [computedPropertyNamesContextualType9_ES5.js]
var o = (_a = {}, _a[+"foo"] =
"", _a[+"bar"] =
0,
_a);
var o = (_a = {},
_a[+"foo"] = "",
_a[+"bar"] = 0,
_a
);
var _a;
@@ -7,9 +7,21 @@ var v = {
}
//// [computedPropertyNamesDeclarationEmit5_ES5.js]
var v = (_a = {}, _a["" + ""] =
0, _a["" + ""] = function () { }, _a["" + ""] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }), _a["" + ""] = Object.defineProperty({ set: function (x) { }, enumerable: true, configurable: true }),
_a);
var v = (_a = {},
_a["" + ""] = 0,
_a["" + ""] = function () { },
Object.defineProperty(_a, "" + "", {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, "" + "", {
set: function (x) { },
enumerable: true,
configurable: true
}),
_a
);
var _a;
@@ -6,9 +6,11 @@ var v = {
}
//// [computedPropertyNamesSourceMap2_ES5.js]
var v = (_a = {}, _a["hello"] = function () {
debugger;
},
_a);
var v = (_a = {},
_a["hello"] = function () {
debugger;
},
_a
);
var _a;
//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map
@@ -1,2 +1,2 @@
//// [computedPropertyNamesSourceMap2_ES5.js.map]
{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,AADA,CACA,EAAA,GADA,EAAA,EACA,EAAA,CACK,OAAO,CAFA,GAAA;IAGA,QAAQ,CAAC;AACb,CAAC,AAJA;AACA,EAAA,AADA,CAKA,CAAA;IAJD,EAAA"}
{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":["[\"hello\"]"],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAR,EAAA;IACI,AADJ,EAAA,CACK,OAAO,CAAC;QACLA,QAAQA,CAACA;IACbA,CAACA;IAHL,EAAA;CAIC,CAAA;IAJD,EAAA"}
@@ -8,153 +8,100 @@ sources: computedPropertyNamesSourceMap2_ES5.ts
emittedFile:tests/cases/conformance/es6/computedProperties/computedPropertyNamesSourceMap2_ES5.js
sourceFile:computedPropertyNamesSourceMap2_ES5.ts
-------------------------------------------------------------------
>>>var v = (_a = {}, _a["hello"] = function () {
>>>var v = (_a = {},
1 >
2 >^^^^
3 > ^
4 > ^^^
5 >
6 > ^
7 > ^^
8 > ^^^
9 > ^^
10> ^^
11> ^^
12> ^
13> ^^^^^^^
14> ^
15> ^^^
5 > ^
6 > ^^
7 > ^^^^^^^^^^^^^^^^^^^^^->
1 >
2 >var
3 > v
4 > =
5 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found
5 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 9) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 9) Source(0, NaN) + SourceIndex(0) nameIndex (-1)
5 >
6 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column
6 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 9) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 10) Source(1, 1) + SourceIndex(0) nameIndex (-1)
6 >
7 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
7 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 10) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 12) Source(1, 1) + SourceIndex(0) nameIndex (-1)
7 >
8 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
8 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 12) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 15) Source(0, NaN) + SourceIndex(0) nameIndex (-1)
8 >
9 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found
9 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 15) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 17) Source(0, NaN) + SourceIndex(0) nameIndex (-1)
9 >
10> !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column
10> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 15) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 19) Source(1, 1) + SourceIndex(0) nameIndex (-1)
10>
11> !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found
11> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 21) Source(1, 1) + SourceIndex(0) nameIndex (-1)
11>
12> !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column
12> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 17) Source(0, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 22) Source(2, 6) + SourceIndex(0) nameIndex (-1)
12> var v = {
> [
13> !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
13> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 19) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 29) Source(2, 13) + SourceIndex(0) nameIndex (-1)
13> "hello"
14> !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
14> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 21) Source(1, 9) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 30) Source(0, NaN) + SourceIndex(0) nameIndex (-1)
14>
15> !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
15> !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 22) Source(2, 14) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(1, 33) Source(0, NaN) + SourceIndex(0) nameIndex (-1)
15>
6 >
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0)
4 >Emitted(1, 9) Source(1, 9) + SourceIndex(0)
5 >Emitted(1, 9) Source(0, NaN) + SourceIndex(0)
6 >Emitted(1, 10) Source(1, 1) + SourceIndex(0)
7 >Emitted(1, 12) Source(1, 1) + SourceIndex(0)
8 >Emitted(1, 15) Source(0, NaN) + SourceIndex(0)
9 >Emitted(1, 17) Source(0, NaN) + SourceIndex(0)
10>Emitted(1, 19) Source(1, 1) + SourceIndex(0)
11>Emitted(1, 21) Source(1, 1) + SourceIndex(0)
12>Emitted(1, 22) Source(2, 6) + SourceIndex(0)
13>Emitted(1, 29) Source(2, 13) + SourceIndex(0)
14>Emitted(1, 30) Source(0, NaN) + SourceIndex(0)
15>Emitted(1, 33) Source(0, NaN) + SourceIndex(0)
5 >Emitted(1, 10) Source(1, 1) + SourceIndex(0)
6 >Emitted(1, 12) Source(1, 1) + SourceIndex(0)
---
>>> debugger;
>>> _a["hello"] = function () {
1->^^^^
2 >
3 > ^^
4 > ^
5 > ^^^^^^^
6 > ^
7 > ^^^->
1->var v = {
>
2 >
3 >
4 > var v = {
> [
5 > "hello"
6 > ]
1->Emitted(2, 5) Source(2, 5) + SourceIndex(0)
2 >Emitted(2, 5) Source(1, 1) + SourceIndex(0)
3 >Emitted(2, 7) Source(1, 1) + SourceIndex(0)
4 >Emitted(2, 8) Source(2, 6) + SourceIndex(0)
5 >Emitted(2, 15) Source(2, 13) + SourceIndex(0)
6 >Emitted(2, 16) Source(2, 14) + SourceIndex(0)
---
>>> debugger;
1->^^^^^^^^
2 > ^^^^^^^^
3 > ^
1->() {
>
2 > debugger
3 > ;
1->Emitted(3, 9) Source(3, 9) + SourceIndex(0) name (["hello"])
2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0) name (["hello"])
3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0) name (["hello"])
---
>>> },
1 >^^^^
2 > ^^^^^^^^
3 > ^
1 >!!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
1 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 29) Source(2, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 5) Source(3, 9) + SourceIndex(0) nameIndex (-1)
1 >
2 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found
2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 30) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 13) Source(3, 17) + SourceIndex(0) nameIndex (-1)
2 > debugger
3 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column
3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 30) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(2, 14) Source(3, 18) + SourceIndex(0) nameIndex (-1)
3 > ;
1 >Emitted(2, 5) Source(3, 9) + SourceIndex(0)
2 >Emitted(2, 13) Source(3, 17) + SourceIndex(0)
3 >Emitted(2, 14) Source(3, 18) + SourceIndex(0)
---
>>>},
1 >
2 >^
3 >
4 > ^^^^->
1 >!!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found
1 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 33) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 1) Source(4, 5) + SourceIndex(0) nameIndex (-1)
2 > ^
3 > ^^->
1 >
>
2 >!!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column
2 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 33) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 2) Source(4, 6) + SourceIndex(0) nameIndex (-1)
2 >}
3 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 5) Source(3, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 2) Source(0, NaN) + SourceIndex(0) nameIndex (-1)
3 >
1 >Emitted(3, 1) Source(4, 5) + SourceIndex(0)
2 >Emitted(3, 2) Source(4, 6) + SourceIndex(0)
3 >Emitted(3, 2) Source(0, NaN) + SourceIndex(0)
2 > }
1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) name (["hello"])
2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) name (["hello"])
---
>>>_a);
>>> _a
1->^^^^
2 > ^^
1->
2 >^^
3 >
4 > ^
5 > ^
6 > ^^^^->
1->!!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
1->!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 13) Source(3, 29) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 1) Source(1, 1) + SourceIndex(0) nameIndex (-1)
1->
2 >!!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
2 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 14) Source(3, 30) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 3) Source(1, 1) + SourceIndex(0) nameIndex (-1)
2 >
3 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 1) Source(4, 17) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 3) Source(0, NaN) + SourceIndex(0) nameIndex (-1)
3 >
4 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
4 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 2) Source(4, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 4) Source(5, 2) + SourceIndex(0) nameIndex (-1)
4 >
5 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found
5 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 2) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 5) Source(5, 2) + SourceIndex(0) nameIndex (-1)
5 >
1->Emitted(4, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(4, 3) Source(1, 1) + SourceIndex(0)
3 >Emitted(4, 3) Source(0, NaN) + SourceIndex(0)
4 >Emitted(4, 4) Source(5, 2) + SourceIndex(0)
5 >Emitted(4, 5) Source(5, 2) + SourceIndex(0)
2 >
1->Emitted(5, 5) Source(1, 1) + SourceIndex(0)
2 >Emitted(5, 7) Source(1, 1) + SourceIndex(0)
---
>>>);
1 >^
2 > ^
3 > ^^^^^^->
1 >var v = {
> ["hello"]() {
> debugger;
> }
>}
2 >
1 >Emitted(6, 2) Source(5, 2) + SourceIndex(0)
2 >Emitted(6, 3) Source(5, 2) + SourceIndex(0)
---
>>>var _a;
1->^^^^
2 > ^^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1->!!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column
1->!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 2) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 5) Source(1, 1) + SourceIndex(0) nameIndex (-1)
1->
2 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(4, 1) Source(1, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 7) Source(1, 1) + SourceIndex(0) nameIndex (-1)
2 >
1->Emitted(5, 5) Source(1, 1) + SourceIndex(0)
2 >Emitted(5, 7) Source(1, 1) + SourceIndex(0)
1->Emitted(7, 5) Source(1, 1) + SourceIndex(0)
2 >Emitted(7, 7) Source(1, 1) + SourceIndex(0)
---
!!!! **** There are more source map entries in the sourceMap's mapping than what was encoded
!!!! **** Remaining decoded string: ,EAAA,AADA,CAKA,CAAA;IAJD,EAAA
>>>//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map
@@ -2,7 +2,5 @@
var v = { [e]: 1 };
//// [parserES5ComputedPropertyName2.js]
var v = (_a = {}, _a[e] =
1,
_a);
var v = (_a = {}, _a[e] = 1, _a);
var _a;
@@ -2,6 +2,5 @@
var v = { [e]() { } };
//// [parserES5ComputedPropertyName3.js]
var v = (_a = {}, _a[e] = function () { },
_a);
var v = (_a = {}, _a[e] = function () { }, _a);
var _a;
@@ -2,6 +2,9 @@
var v = { get [e]() { } };
//// [parserES5ComputedPropertyName4.js]
var v = (_a = {}, _a[e] = Object.defineProperty({ get: function () { }, enumerable: true, configurable: true }),
_a);
var v = (_a = {}, Object.defineProperty(_a, e, {
get: function () { },
enumerable: true,
configurable: true
}), _a);
var _a;
+5 -4
View File
@@ -11,9 +11,10 @@ var y: {
//// [privateIndexer2.js]
// private indexers not allowed
var x = (_a = {}, _a[x] =
string, _a.string =
,
_a);
var x = (_a = {},
_a[x] = string,
_a.string = ,
_a
);
var y;
var _a;