OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library dart_tree_printer; | 5 library dart_tree_printer; |
6 | 6 |
7 import '../constants/values.dart' as values; | 7 import '../constants/values.dart' as values; |
8 import '../dart_types.dart' as types; | 8 import '../dart_types.dart' as types; |
9 import '../dart2jslib.dart' as dart2js; | 9 import '../dart2jslib.dart' as dart2js; |
10 import '../elements/elements.dart' as elements; | 10 import '../elements/elements.dart' as elements; |
| 11 import '../resolution/resolution.dart' show |
| 12 TreeElementMapping; |
11 import '../tree/tree.dart' as tree; | 13 import '../tree/tree.dart' as tree; |
12 import '../scanner/scannerlib.dart'; | 14 import '../scanner/scannerlib.dart'; |
13 import '../util/util.dart'; | 15 import '../util/util.dart'; |
14 import 'backend_ast_nodes.dart'; | 16 import 'backend_ast_nodes.dart'; |
15 import 'backend_ast_emitter.dart' show TypeGenerator; | 17 import 'backend_ast_emitter.dart' show TypeGenerator; |
16 | 18 |
17 /// Translates the backend AST to Dart frontend AST. | 19 /// Translates the backend AST to Dart frontend AST. |
18 tree.Node emit(dart2js.TreeElementMapping treeElements, | 20 tree.Node emit(TreeElementMapping treeElements, |
19 RootNode root) { | 21 RootNode root) { |
20 return new TreePrinter(treeElements).makeDefinition(root); | 22 return new TreePrinter(treeElements).makeDefinition(root); |
21 } | 23 } |
22 | 24 |
23 /// If true, the unparser will insert a coment in front of every function | 25 /// If true, the unparser will insert a coment in front of every function |
24 /// it emits. This helps indicate which functions were translated by the new | 26 /// it emits. This helps indicate which functions were translated by the new |
25 /// backend. | 27 /// backend. |
26 bool INSERT_NEW_BACKEND_COMMENT = | 28 bool INSERT_NEW_BACKEND_COMMENT = |
27 const bool.fromEnvironment("INSERT_NEW_BACKEND_COMMENT"); | 29 const bool.fromEnvironment("INSERT_NEW_BACKEND_COMMENT"); |
28 | 30 |
29 /// Converts backend ASTs to frontend ASTs. | 31 /// Converts backend ASTs to frontend ASTs. |
30 class TreePrinter { | 32 class TreePrinter { |
31 dart2js.TreeElementMapping treeElements; | 33 TreeElementMapping treeElements; |
32 | 34 |
33 TreePrinter([this.treeElements]); | 35 TreePrinter([this.treeElements]); |
34 | 36 |
35 tree.Node makeDefinition(RootNode node) { | 37 tree.Node makeDefinition(RootNode node) { |
36 if (node is FieldDefinition) { | 38 if (node is FieldDefinition) { |
37 tree.Node definition; | 39 tree.Node definition; |
38 if (node.initializer == null) { | 40 if (node.initializer == null) { |
39 definition = makeIdentifier(node.element.name); | 41 definition = makeIdentifier(node.element.name); |
40 } else { | 42 } else { |
41 definition = new tree.SendSet( | 43 definition = new tree.SendSet( |
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 printStringChunk(chunk.previous), | 1333 printStringChunk(chunk.previous), |
1332 node); | 1334 node); |
1333 } else { | 1335 } else { |
1334 return node; | 1336 return node; |
1335 } | 1337 } |
1336 } | 1338 } |
1337 return printStringChunk(output.chunk); | 1339 return printStringChunk(output.chunk); |
1338 } | 1340 } |
1339 | 1341 |
1340 } | 1342 } |
OLD | NEW |