Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Unified Diff: frog/minfrog

Issue 8947008: When += (and similar operations) are converted to = + , (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « frog/gen.dart ('k') | tests/language/src/AssignOpTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/minfrog
===================================================================
--- frog/minfrog (revision 2468)
+++ frog/minfrog (working copy)
@@ -3521,6 +3521,9 @@
var index = this.visitValue(node.index);
return target.invoke$4(this, ':index', node, new Arguments(null, [index]));
}
+MethodGenerator.prototype._expressionNeedsParens = function(e) {
+ return ((e instanceof BinaryExpression) || (e instanceof ConditionalExpression) || (e instanceof PostfixExpression) || this._isUnaryIncrement(e));
+}
MethodGenerator.prototype.visitBinaryExpression = function(node, isVoid) {
var kind = node.op.kind;
if (kind == 35/*TokenKind.AND*/ || kind == 34/*TokenKind.OR*/) {
@@ -3574,6 +3577,9 @@
}
return x.invoke$4(this, name, node, new Arguments(null, [y]));
}
+ else if ((assignKind != 0) && this._expressionNeedsParens(node.y)) {
+ return this._visitAssign(assignKind, node.x, new ParenExpression(node.y, node.y.span), node, to$call$1(null), isVoid);
+ }
else {
return this._visitAssign(assignKind, node.x, node.y, node, to$call$1(null), isVoid);
}
@@ -3983,7 +3989,7 @@
var val = this.visitValue(item);
val.invoke$4(this, 'toString', item, Arguments.get$EMPTY());
var code = val.get$code();
- if ((item instanceof BinaryExpression) || (item instanceof ConditionalExpression) || (item instanceof PostfixExpression) || this._isUnaryIncrement(item)) {
+ if (this._expressionNeedsParens(item)) {
code = ('(' + code + ')');
}
if ($eq(items.get$length(), 0) || ($ne(code, "''") && $ne(code, '""'))) {
« no previous file with comments | « frog/gen.dart ('k') | tests/language/src/AssignOpTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698