Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Pretty-prints Node tree in XML-like format. | 6 * Pretty-prints Node tree in XML-like format. |
| 7 * | 7 * |
| 8 * TODO(smok): Add main() to run from command-line to print out tree for given | 8 * TODO(smok): Add main() to run from command-line to print out tree for given |
| 9 * .dart file. | 9 * .dart file. |
| 10 */ | 10 */ |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 | 234 |
| 235 visitOperator(Operator node) { | 235 visitOperator(Operator node) { |
| 236 openAndCloseNode("Operator", {"value" : node.token.slowToString()}); | 236 openAndCloseNode("Operator", {"value" : node.token.slowToString()}); |
| 237 } | 237 } |
| 238 | 238 |
| 239 visitParenthesizedExpression(ParenthesizedExpression node) { | 239 visitParenthesizedExpression(ParenthesizedExpression node) { |
| 240 visitNodeWithChildren(node, "ParenthesizedExpression"); | 240 visitNodeWithChildren(node, "ParenthesizedExpression"); |
| 241 } | 241 } |
| 242 | 242 |
| 243 visitReturn(Return node) { | 243 visitReturn(Return node) { |
| 244 visitNodeWithChildren(node, "Return"); | 244 var beginToken = |
| 245 node.beginToken != null ? node.beginToken.stringValue : "null"; | |
|
Anton Muhin
2012/06/15 02:55:56
nit (here and below): !== null
Roman
2012/06/17 00:27:03
Done.
| |
| 246 var endToken = node.endToken != null ? node.endToken.stringValue : "null"; | |
| 247 openNode("Return", {"beginToken" : beginToken, "endToken" : endToken}); | |
| 248 if (node.hasExpression) { | |
|
Anton Muhin
2012/06/15 02:55:56
nit: single line if?
Roman
2012/06/17 00:27:03
Done.
| |
| 249 visitWithPrefix(node.expression, "expression:"); | |
| 250 } | |
| 251 closeNode("Return"); | |
| 245 } | 252 } |
| 246 | 253 |
| 247 visitScriptTag(ScriptTag node) { | 254 visitScriptTag(ScriptTag node) { |
| 248 visitNodeWithChildren(node, "ScriptTag"); | 255 visitNodeWithChildren(node, "ScriptTag"); |
| 249 } | 256 } |
| 250 | 257 |
| 251 /** Custom helper to visit given node and print its type with prefix. */ | 258 /** Custom helper to visit given node and print its type with prefix. */ |
| 252 visitWithPrefix(Node node, String prefix) { | 259 visitWithPrefix(Node node, String prefix) { |
| 253 nextTypePrefix = prefix; | 260 nextTypePrefix = prefix; |
| 254 node.accept(this); | 261 node.accept(this); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 } | 326 } |
| 320 | 327 |
| 321 visitVariableDefinitions(VariableDefinitions node) { | 328 visitVariableDefinitions(VariableDefinitions node) { |
| 322 visitNodeWithChildren(node, "VariableDefinitions"); | 329 visitNodeWithChildren(node, "VariableDefinitions"); |
| 323 } | 330 } |
| 324 | 331 |
| 325 visitWhile(While node) { | 332 visitWhile(While node) { |
| 326 visitNodeWithChildren(node, "While"); | 333 visitNodeWithChildren(node, "While"); |
| 327 } | 334 } |
| 328 } | 335 } |
| OLD | NEW |