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