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

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

Issue 10532150: PrettyPrinter: add an ability to prefix node fields, so instead of: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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/prettyprint.dart
diff --git a/lib/compiler/implementation/tree/prettyprint.dart b/lib/compiler/implementation/tree/prettyprint.dart
index 2c7bb33a26dbcb3cf7f4fb8838e3460c76e1ac32..032b3b046d9974f849420bb110c4efa637750cf1 100644
--- a/lib/compiler/implementation/tree/prettyprint.dart
+++ b/lib/compiler/implementation/tree/prettyprint.dart
@@ -15,6 +15,8 @@ class PrettyPrinter implements Visitor {
StringBuffer sb;
int depth;
+ /** Prefix for the type passed to next openNode() call. */
Anton Muhin 2012/06/14 20:52:07 nit: I think you'd better put openNode() into [: :
Roman 2012/06/14 21:14:31 Simple grep shows that in "lib" [::] is never used
+ String nextPrefix;
Anton Muhin 2012/06/14 20:52:07 maybe something like nextTypePrefix would be a bet
Roman 2012/06/14 21:14:31 Done.
PrettyPrinter() : sb = new StringBuffer(), depth = 0;
@@ -61,6 +63,10 @@ class PrettyPrinter implements Visitor {
}
void addTypeWithParams(String type, [Map params]) {
+ if (nextPrefix !== null) {
+ sb.add(nextPrefix);
+ nextPrefix = null;
+ }
sb.add("${type}");
if (params != null) {
// TODO(smok): Escape doublequotes in values.
@@ -242,12 +248,40 @@ class PrettyPrinter implements Visitor {
visitNodeWithChildren(node, "ScriptTag");
}
+ // Custom helper to visit given node and print its type with prefix.
+ visitWithPrefix(Node node, String prefix) {
+ nextPrefix = prefix;
+ node.accept(this);
+ }
+
+ openSendNodeWithFields(Send node, String type) {
+ openNode(type, {
+ "isPrefix" : "${node.isPrefix}",
+ "isPostfix" : "${node.isPostfix}",
+ "isIndex" : "${node.isIndex}"
+ });
+ if (node.receiver !== null) {
Anton Muhin 2012/06/14 20:52:07 nit: single line? here and below
Roman 2012/06/14 21:14:31 Done (where possible).
+ visitWithPrefix(node.receiver, "receiver:");
+ }
+ if (node.selector !== null) {
+ visitWithPrefix(node.selector, "selector:");
+ }
+ if (node.argumentsNode !== null) {
+ visitWithPrefix(node.argumentsNode, "argumentsNode:");
+ }
+ }
+
visitSend(Send node) {
- visitNodeWithChildren(node, "Send");
+ openSendNodeWithFields(node, "Send");
+ closeNode("Send");
}
visitSendSet(SendSet node) {
- visitNodeWithChildren(node, "SendSet");
+ openSendNodeWithFields(node, "SendSet");
+ if (node.assignmentOperator !== null) {
+ visitWithPrefix(node.assignmentOperator, "assignmentOperator:");
+ }
+ closeNode("SendSet");
}
visitStringInterpolation(StringInterpolation 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