OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// Helper for debug Kernel nodes. | 5 /// Helper for debug Kernel nodes. |
6 | 6 |
7 library kernel.debug; | 7 library kernel.debug; |
8 | 8 |
9 import 'package:kernel/kernel.dart'; | 9 import 'package:kernel/kernel.dart'; |
10 import 'package:kernel/visitor.dart'; | 10 import 'package:kernel/visitor.dart'; |
(...skipping 18 matching lines...) Expand all Loading... |
29 void visitName(Name node) { | 29 void visitName(Name node) { |
30 openAndCloseNode(node, '${node.runtimeType}', | 30 openAndCloseNode(node, '${node.runtimeType}', |
31 {'name': node.name, 'library': node.library?.name}); | 31 {'name': node.name, 'library': node.library?.name}); |
32 } | 32 } |
33 | 33 |
34 @override | 34 @override |
35 void visitIntLiteral(IntLiteral node) { | 35 void visitIntLiteral(IntLiteral node) { |
36 openAndCloseNode(node, '${node.runtimeType}', {'value': '${node.value}'}); | 36 openAndCloseNode(node, '${node.runtimeType}', {'value': '${node.value}'}); |
37 } | 37 } |
38 | 38 |
| 39 @override |
| 40 void visitVariableGet(VariableGet node) { |
| 41 openAndCloseNode( |
| 42 node, '${node.runtimeType}', {'variable': '${node.variable}'}); |
| 43 } |
| 44 |
| 45 @override |
| 46 void visitVariableDeclaration(VariableDeclaration node) { |
| 47 openNode(node, '${node.runtimeType}', { |
| 48 'name': '${node.name}', |
| 49 'isFinal': '${node.isFinal}', |
| 50 'isConst': '${node.isConst}' |
| 51 }); |
| 52 node.visitChildren(this); |
| 53 closeNode(); |
| 54 } |
| 55 |
39 /// Pretty-prints given node tree into string. | 56 /// Pretty-prints given node tree into string. |
40 static String prettyPrint(Node node) { | 57 static String prettyPrint(Node node) { |
41 var p = new DebugPrinter(); | 58 var p = new DebugPrinter(); |
42 node.accept(p); | 59 node.accept(p); |
43 return p.sb.toString(); | 60 return p.sb.toString(); |
44 } | 61 } |
45 } | 62 } |
OLD | NEW |