Chromium Code Reviews| 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) { |