remove special ExpressionStatement handling in destructuring transformer
This commit is contained in:
parent
164b2116a3
commit
f979d55b71
@ -107,25 +107,10 @@ export function CatchClause(node, parent, scope, file) {
|
|||||||
node.body.body = nodes.concat(node.body.body);
|
node.body.body = nodes.concat(node.body.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ExpressionStatement(node, parent, scope, file) {
|
|
||||||
var expr = node.expression;
|
|
||||||
if (expr.type !== "AssignmentExpression") return;
|
|
||||||
if (!t.isPattern(expr.left)) return;
|
|
||||||
if (this.isCompletionRecord()) return;
|
|
||||||
|
|
||||||
var destructuring = new DestructuringTransformer({
|
|
||||||
operator: expr.operator,
|
|
||||||
scope: scope,
|
|
||||||
file: file,
|
|
||||||
});
|
|
||||||
|
|
||||||
return destructuring.init(expr.left, expr.right);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AssignmentExpression(node, parent, scope, file) {
|
export function AssignmentExpression(node, parent, scope, file) {
|
||||||
if (!t.isPattern(node.left)) return;
|
if (!t.isPattern(node.left)) return;
|
||||||
|
|
||||||
var ref = scope.generateUidIdentifier("temp");
|
var ref = scope.generateUidIdentifierBasedOnNode(node.right, "ref");
|
||||||
|
|
||||||
var nodes = [];
|
var nodes = [];
|
||||||
nodes.push(t.variableDeclaration("var", [
|
nodes.push(t.variableDeclaration("var", [
|
||||||
|
|||||||
@ -22,7 +22,7 @@ var b = _ref2[1];
|
|||||||
var _ref3 = [a, b];
|
var _ref3 = [a, b];
|
||||||
var a = _ref3[0];
|
var a = _ref3[0];
|
||||||
var b = _ref3[1];
|
var b = _ref3[1];
|
||||||
var _temp = [a[1], a[0]];
|
var _ref4 = [a[1], a[0]];
|
||||||
a[0] = _temp[0];
|
a[0] = _ref4[0];
|
||||||
a[1] = _temp[1];
|
a[1] = _ref4[1];
|
||||||
_temp;
|
_ref4;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var x, y;
|
var x, y;
|
||||||
var _temp = [1, 2];
|
var _ref = [1, 2];
|
||||||
x = _temp[0];
|
x = _ref[0];
|
||||||
y = _temp[1];
|
y = _ref[1];
|
||||||
_temp;
|
_ref;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _temp;
|
var _ref;
|
||||||
|
|
||||||
console.log((_temp = [123], x = _temp[0], _temp));
|
console.log((_ref = [123], x = _ref[0], _ref));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user