mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 20:25:23 -06:00
fix emit for unary operators on exported variables in system modules
This commit is contained in:
parent
5880029a13
commit
8ebe08105d
@ -1092,13 +1092,16 @@ namespace ts {
|
||||
if (substitute) {
|
||||
const exportDeclaration = resolver.getReferencedExportContainer(<Identifier>operand);
|
||||
if (exportDeclaration) {
|
||||
const expr = createPostfix(operand, node.operator, node);
|
||||
const expr = createPrefix(node.operator, operand, node);
|
||||
setNodeEmitFlags(expr, NodeEmitFlags.NoSubstitution);
|
||||
const call = createExportExpression(<Identifier>operand, expr);
|
||||
if (node.kind === SyntaxKind.PrefixUnaryExpression) {
|
||||
return call;
|
||||
}
|
||||
else {
|
||||
// export function returns the value that was passes as the second argument
|
||||
// however for postfix unary expressions result value should be the value before modification.
|
||||
// emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)'
|
||||
return operator === SyntaxKind.PlusPlusToken
|
||||
? createSubtract(call, createLiteral(1))
|
||||
: createAdd(call, createLiteral(1));
|
||||
|
||||
@ -31,13 +31,13 @@ if (++y) {
|
||||
}
|
||||
|
||||
//// [prefixUnaryOperatorsOnExportedVariables.js]
|
||||
System.register([], function(exports_1, context_1) {
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var x, y;
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
exports_1("x", x = false);
|
||||
exports_1("y", y = 1);
|
||||
if (!x) {
|
||||
@ -55,5 +55,5 @@ System.register([], function(exports_1, context_1) {
|
||||
if (exports_1("y", ++y)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@ -10,7 +10,7 @@ export {n2}
|
||||
export {n2 as n3}
|
||||
|
||||
//// [systemModule10.js]
|
||||
System.register(['file1', 'file2'], function (exports_1, context_1) {
|
||||
System.register(["file1", "file2"], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var file1_1, n2;
|
||||
|
||||
@ -10,7 +10,7 @@ export {n2}
|
||||
export {n2 as n3}
|
||||
|
||||
//// [systemModule10_ES5.js]
|
||||
System.register(['file1', 'file2'], function (exports_1, context_1) {
|
||||
System.register(["file1", "file2"], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var file1_1, n2;
|
||||
|
||||
@ -65,8 +65,8 @@ System.register(["f1"], function (exports_1, context_1) {
|
||||
var x, N, IX, f1_1;
|
||||
return {
|
||||
setters: [
|
||||
function (_1) {
|
||||
f1_1 = _1;
|
||||
function (f1_1_1) {
|
||||
f1_1 = f1_1_1;
|
||||
}
|
||||
],
|
||||
execute: function () {
|
||||
|
||||
@ -42,10 +42,10 @@ System.register([], function (exports_1, context_1) {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
exports_1("x", x = 1);
|
||||
exports_1("x", x++) - 1;
|
||||
exports_1("x", x--) + 1;
|
||||
exports_1("x", x++);
|
||||
exports_1("x", x--);
|
||||
exports_1("x", ++x) - 1;
|
||||
exports_1("x", --x) + 1;
|
||||
exports_1("x", ++x);
|
||||
exports_1("x", --x);
|
||||
exports_1("x", x += 1);
|
||||
exports_1("x", x -= 1);
|
||||
exports_1("x", x *= 1);
|
||||
@ -56,10 +56,10 @@ System.register([], function (exports_1, context_1) {
|
||||
x - 1;
|
||||
x & 1;
|
||||
x | 1;
|
||||
for (exports_1("x", x = 5);; exports_1("x", x++) - 1) { }
|
||||
for (exports_1("x", x = 8);; exports_1("x", x--) + 1) { }
|
||||
for (exports_1("x", x = 15);; exports_1("x", x++)) { }
|
||||
for (exports_1("x", x = 18);; exports_1("x", x--)) { }
|
||||
for (exports_1("x", x = 5);; exports_1("x", ++x) - 1) { }
|
||||
for (exports_1("x", x = 8);; exports_1("x", --x) + 1) { }
|
||||
for (exports_1("x", x = 15);; exports_1("x", ++x)) { }
|
||||
for (exports_1("x", x = 18);; exports_1("x", --x)) { }
|
||||
for (x = 50;;) { }
|
||||
exports_1("y", y = [1][0]);
|
||||
_a = { a: true, b: { c: "123" } }, exports_1("z0", z0 = _a.a), exports_1("z1", z1 = _a.b.c);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user