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

Unified Diff: frog/gen.dart

Issue 8585044: Fixes issues in string interpolation tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove debugging code Created 9 years, 1 month 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
Index: frog/gen.dart
diff --git a/frog/gen.dart b/frog/gen.dart
index 387e64e0b1f51fba973f7a8922c0373127d82299..74291fa7157be50fb590c26cd30d121d06009b0b 100644
--- a/frog/gen.dart
+++ b/frog/gen.dart
@@ -2113,6 +2113,15 @@ class MethodGenerator implements TreeVisitor {
return new EvaluatedValue(world.varType, null, 'null', null);
}
+ _isUnaryIncrement(Expression item) {
+ if (item is UnaryExpression) {
+ UnaryExpression u = item;
+ return u.op.kind == TokenKind.INCR || u.op.kind == TokenKind.DECR;
+ } else {
+ return false;
+ }
+ }
+
visitLiteralExpression(LiteralExpression node) {
// All Literal types are filled in at parse time, so no need to resolve.
var type = node.type.type;
@@ -2125,8 +2134,11 @@ class MethodGenerator implements TreeVisitor {
val.invoke(this, 'toString', item, Arguments.EMPTY);
// TODO(jimhug): Ensure this solves all precedence problems.
+ // TODO(jmesserly): We could be smarter about prefix/postfix, but we'd
+ // need to know if it will compile to a ++ or to some sort of += form.
var code = val.code;
- if (item is BinaryExpression || item is ConditionalExpression) {
+ if (item is BinaryExpression || item is ConditionalExpression
+ || item is PostfixExpression || _isUnaryIncrement(item)) {
code = '(${code})';
}
items.add(code);

Powered by Google App Engine
This is Rietveld 408576698