mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 12:13:01 +00:00
[js_ast] Don't rewrite compound assignments
Bug: 37337 Change-Id: Ibda0d9233d480cc64732e9e17182b55cde77baf2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107181 Reviewed-by: Mayank Patke <fishythefish@google.com> Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
parent
bc8b6fb94d
commit
c7524cc296
|
@ -763,7 +763,10 @@ class Printer implements NodeVisitor {
|
|||
// Output 'a += 1' as '++a' and 'a -= 1' as '--a'.
|
||||
_outputIncDec(op, assignment.leftHandSide);
|
||||
return;
|
||||
} else if (leftHandSide is VariableUse && rightHandSide is Binary) {
|
||||
}
|
||||
if (!assignment.isCompound &&
|
||||
leftHandSide is VariableUse &&
|
||||
rightHandSide is Binary) {
|
||||
Node rLeft = undefer(rightHandSide.left);
|
||||
Node rRight = undefer(rightHandSide.right);
|
||||
String op = rightHandSide.op;
|
||||
|
|
|
@ -29,6 +29,25 @@ main() {
|
|||
test(map, '# = # - 1', [deferred, variableUseAlias], '--variable');
|
||||
test(map, '# = # + 2', [variableUse, variableUseAlias], 'variable += 2');
|
||||
test(map, '# = # + 2', [deferred, variableUseAlias], 'variable += 2');
|
||||
test(map, '# = # * 2', [variableUse, variableUseAlias], 'variable *= 2');
|
||||
test(map, '# = # * 2', [deferred, variableUseAlias], 'variable *= 2');
|
||||
|
||||
test(map, '# += # + 1', [variableUse, variableUseAlias],
|
||||
'variable += variable + 1');
|
||||
test(map, '# += # + 1', [deferred, variableUseAlias],
|
||||
'variable += variable + 1');
|
||||
test(map, '# += # - 1', [variableUse, variableUseAlias],
|
||||
'variable += variable - 1');
|
||||
test(map, '# += # - 1', [deferred, variableUseAlias],
|
||||
'variable += variable - 1');
|
||||
test(map, '# += # + 2', [variableUse, variableUseAlias],
|
||||
'variable += variable + 2');
|
||||
test(map, '# += # + 2', [deferred, variableUseAlias],
|
||||
'variable += variable + 2');
|
||||
test(map, '# += # * 2', [variableUse, variableUseAlias],
|
||||
'variable += variable * 2');
|
||||
test(map, '# += # * 2', [deferred, variableUseAlias],
|
||||
'variable += variable * 2');
|
||||
}
|
||||
|
||||
void test(Map<Expression, DeferredExpression> map, String template,
|
||||
|
|
Loading…
Reference in a new issue