| 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 25 matching lines...) Expand all Loading... |
| 36 openAndCloseNode(node, '${node.runtimeType}', {'value': '${node.value}'}); | 36 openAndCloseNode(node, '${node.runtimeType}', {'value': '${node.value}'}); |
| 37 } | 37 } |
| 38 | 38 |
| 39 @override | 39 @override |
| 40 void visitVariableGet(VariableGet node) { | 40 void visitVariableGet(VariableGet node) { |
| 41 openAndCloseNode( | 41 openAndCloseNode( |
| 42 node, '${node.runtimeType}', {'variable': '${node.variable}'}); | 42 node, '${node.runtimeType}', {'variable': '${node.variable}'}); |
| 43 } | 43 } |
| 44 | 44 |
| 45 @override | 45 @override |
| 46 void visitStaticGet(StaticGet node) { |
| 47 openAndCloseNode(node, '${node.runtimeType}', {'target': '${node.target}'}); |
| 48 } |
| 49 |
| 50 @override |
| 46 void visitVariableDeclaration(VariableDeclaration node) { | 51 void visitVariableDeclaration(VariableDeclaration node) { |
| 47 openNode(node, '${node.runtimeType}', { | 52 openNode(node, '${node.runtimeType}', { |
| 48 'name': '${node.name ?? '--unnamed--'}', | 53 'name': '${node.name ?? '--unnamed--'}', |
| 49 'isFinal': '${node.isFinal}', | 54 'isFinal': '${node.isFinal}', |
| 50 'isConst': '${node.isConst}' | 55 'isConst': '${node.isConst}' |
| 51 }); | 56 }); |
| 52 node.visitChildren(this); | 57 node.visitChildren(this); |
| 53 closeNode(); | 58 closeNode(); |
| 54 } | 59 } |
| 55 | 60 |
| 56 @override | 61 @override |
| 57 void visitInterfaceType(InterfaceType node) { | 62 void visitInterfaceType(InterfaceType node) { |
| 58 openNode(node, '${node.runtimeType}', { | 63 openNode(node, '${node.runtimeType}', { |
| 59 'name': '${node.classNode.name}', | 64 'name': '${node.classNode.name}', |
| 60 }); | 65 }); |
| 61 node.visitChildren(this); | 66 node.visitChildren(this); |
| 62 closeNode(); | 67 closeNode(); |
| 63 } | 68 } |
| 64 | 69 |
| 65 /// Pretty-prints given node tree into string. | 70 /// Pretty-prints given node tree into string. |
| 66 static String prettyPrint(Node node) { | 71 static String prettyPrint(Node node) { |
| 67 var p = new DebugPrinter(); | 72 var p = new DebugPrinter(); |
| 68 node.accept(p); | 73 node.accept(p); |
| 69 return p.sb.toString(); | 74 return p.sb.toString(); |
| 70 } | 75 } |
| 71 } | 76 } |
| OLD | NEW |