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

Unified Diff: lib/compiler/implementation/tree/unparser.dart

Issue 10448008: fix for index operation unparses (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/tree/unparser.dart
diff --git a/lib/compiler/implementation/tree/unparser.dart b/lib/compiler/implementation/tree/unparser.dart
index 05b24260254451bb67f314f740ba13b5e4956b95..2a891eb8d6cbafcebf8c68e23f22743490475e69 100644
--- a/lib/compiler/implementation/tree/unparser.dart
+++ b/lib/compiler/implementation/tree/unparser.dart
@@ -179,7 +179,6 @@ class Unparser implements Visitor {
if (node.endToken !== null) add(node.endToken.value);
}
-
unparseSendPart(Send node) {
if (node.isPrefix) {
visit(node.selector);
@@ -198,10 +197,29 @@ class Unparser implements Visitor {
visit(node.argumentsNode);
}
- visitSendSet(SendSet node) {
- unparseSendPart(node);
+ // Special case for assignments like "list[0] = 1".
+ visitListIndexSet(SendSet node) {
+ visit(node.receiver);
+ sb.add('[');
+ sb.add(node.arguments.head);
+ sb.add(']');
add(node.assignmentOperator.token.value);
- visit(node.argumentsNode);
+ NodeList tailArguments = new NodeList(
+ node.argumentsNode.beginToken, node.argumentsNode.nodes.tail, node.argumentsNode.endToken,
+ node.argumentsNode.delimiter);
+ visit(tailArguments);
+ }
+
+ visitSendSet(SendSet node) {
+ Operator op = node.selector.asOperator();
+ bool isListIndex = op !== null && op.source.stringValue == '[]';
Anton Muhin 2012/05/24 16:59:58 I believe we have exactly the same problem for exp
+ if (isListIndex) {
+ visitListIndexSet(node);
+ } else {
+ unparseSendPart(node);
+ add(node.assignmentOperator.token.value);
+ visit(node.argumentsNode);
+ }
}
visitThrow(Throw node) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698