OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library analyzer2dart.closedWorld; | |
6 | |
7 import 'dart:collection'; | |
8 | |
9 import 'package:analyzer/analyzer.dart'; | |
10 import 'package:analyzer/src/generated/element.dart'; | |
11 import 'package:analyzer/src/generated/resolver.dart'; | |
12 | |
13 /** | |
14 * Container for the elements and AST nodes which have been determined by | |
15 * tree shaking to be reachable by the program being compiled. | |
16 */ | |
17 class ClosedWorld { | |
18 /// The core types of this world. | |
19 final TypeProvider typeProvider; | |
20 | |
21 /// Returns the main function of this closed world compilation. | |
22 final FunctionElement mainFunction; | |
23 | |
24 // TODO(paulberry): is it a problem to hold on to all the AST's for the | |
25 // duration of tree shaking & CPS generation? | |
26 | |
27 /** | |
28 * Methods, toplevel functions, etc. that are reachable. | |
29 */ | |
30 Map<ExecutableElement, Declaration> executableElements = | |
31 new HashMap<ExecutableElement, Declaration>(); | |
32 | |
33 /** | |
34 * Fields that are reachable. | |
35 */ | |
36 Map<FieldElement, VariableDeclaration> fields = | |
37 new HashMap<FieldElement, VariableDeclaration>(); | |
38 | |
39 /** | |
40 * Top-level variables that are reachable. | |
41 */ | |
42 // TODO(johnniwinther): Is there value in splitting fields and top-level | |
43 // variables? | |
44 Map<TopLevelVariableElement, VariableDeclaration> variables = | |
45 new HashMap<TopLevelVariableElement, VariableDeclaration>(); | |
46 | |
47 /** | |
48 * Classes that are instantiated from reachable code. | |
49 * | |
50 * TODO(paulberry): Also keep track of classes that are reachable but not | |
51 * instantiated (because they are extended or mixed in) | |
52 */ | |
53 Map<ClassElement, ClassDeclaration> instantiatedClasses = | |
54 new HashMap<ClassElement, ClassDeclaration>(); | |
55 | |
56 ClosedWorld(this.typeProvider, this.mainFunction); | |
57 } | |
OLD | NEW |