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..fba8553de302e388562ee3873eca20b7d8af6905 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 next openNode() invocation for that type. |
|
Anton Muhin
2012/06/14 20:32:37
nit: /** Prefix for the next [:openNode():] invoca
Roman
2012/06/14 20:47:32
Done. Reformulated. It's the type of the node to p
|
| + String nextPrefix; |
| PrettyPrinter() : sb = new StringBuffer(), depth = 0; |
| @@ -61,6 +63,10 @@ class PrettyPrinter implements Visitor { |
| } |
| void addTypeWithParams(String type, [Map params]) { |
| + if (nextPrefix != null) { |
|
Anton Muhin
2012/06/14 20:32:37
nit: !==
Roman
2012/06/14 20:47:32
Done.
|
| + sb.add("$nextPrefix"); |
|
Anton Muhin
2012/06/14 20:32:37
I think simple sb.add(nextPrefix) should work as w
Roman
2012/06/14 20:47:32
Done.
|
| + nextPrefix = null; |
|
Anton Muhin
2012/06/14 20:32:37
is it okay to reset it that early, do we want to h
Roman
2012/06/14 20:47:32
It may be nice, but not so necessary. And we would
|
| + } |
| sb.add("${type}"); |
| if (params != null) { |
| // TODO(smok): Escape doublequotes in values. |
| @@ -242,12 +248,36 @@ class PrettyPrinter implements Visitor { |
| visitNodeWithChildren(node, "ScriptTag"); |
| } |
| + openSendNodeWithFields(Send node, String type) { |
| + openNode(type, |
|
Anton Muhin
2012/06/14 20:32:37
nit: somewhat weird formatting, I'd rather do it l
Roman
2012/06/14 20:47:32
Done.
|
| + {"isPrefix" : "${node.isPrefix}", "isPostfix" : "${node.isPostfix}", |
| + "isIndex" : "${node.isIndex}"}); |
| + if (node.receiver !== null) { |
| + nextPrefix = "receiver:"; |
|
Anton Muhin
2012/06/14 20:32:37
you may want to introduce withPrefix helper, somet
Roman
2012/06/14 20:47:32
Done.
|
| + node.receiver.accept(this); |
| + } |
| + if (node.selector !== null) { |
| + nextPrefix = "selector:"; |
| + node.selector.accept(this); |
| + } |
| + if (node.argumentsNode !== null) { |
| + nextPrefix = "argumentsNode:"; |
| + node.argumentsNode.accept(this); |
| + } |
| + } |
| + |
| visitSend(Send node) { |
| - visitNodeWithChildren(node, "Send"); |
| + openSendNodeWithFields(node, "Send"); |
| + closeNode("Send"); |
| } |
| visitSendSet(SendSet node) { |
| - visitNodeWithChildren(node, "SendSet"); |
| + openSendNodeWithFields(node, "SendSet"); |
| + if (node.assignmentOperator !== null) { |
| + nextPrefix = "assignmentOperator:"; |
| + node.assignmentOperator.accept(this); |
| + } |
| + closeNode("SendSet"); |
| } |
| visitStringInterpolation(StringInterpolation node) { |