Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: pkg/compiler/lib/src/resolution/registry.dart

Issue 1413543004: Extract WorldImpactBuilder from _ResolutionWorldImpact. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/universe/world_impact.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 dart2js.resolution.registry; 5 library dart2js.resolution.registry;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/backend_api.dart' show 8 import '../common/backend_api.dart' show
9 Backend, 9 Backend,
10 ForeignResolver; 10 ForeignResolver;
(...skipping 13 matching lines...) Expand all
24 import '../elements/elements.dart'; 24 import '../elements/elements.dart';
25 import '../tree/tree.dart'; 25 import '../tree/tree.dart';
26 import '../util/util.dart' show 26 import '../util/util.dart' show
27 Setlet; 27 Setlet;
28 import '../universe/call_structure.dart' show 28 import '../universe/call_structure.dart' show
29 CallStructure; 29 CallStructure;
30 import '../universe/selector.dart' show 30 import '../universe/selector.dart' show
31 Selector; 31 Selector;
32 import '../universe/universe.dart' show 32 import '../universe/universe.dart' show
33 UniverseSelector; 33 UniverseSelector;
34 import '../universe/world_impact.dart' show
35 WorldImpactBuilder;
34 import '../world.dart' show World; 36 import '../world.dart' show World;
35 37
36 import 'send_structure.dart'; 38 import 'send_structure.dart';
37 39
38 import 'members.dart' show 40 import 'members.dart' show
39 ResolverVisitor; 41 ResolverVisitor;
40 import 'tree_elements.dart' show 42 import 'tree_elements.dart' show
41 TreeElementMapping; 43 TreeElementMapping;
42 44
43 // TODO(johnniwinther): Remove this. 45 // TODO(johnniwinther): Remove this.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 80 }
79 81
80 @override 82 @override
81 void registerStaticInvocation(Element element) { 83 void registerStaticInvocation(Element element) {
82 world.registerStaticUse(element); 84 world.registerStaticUse(element);
83 } 85 }
84 86
85 String toString() => 'EagerRegistry for ${mapping.analyzedElement}'; 87 String toString() => 'EagerRegistry for ${mapping.analyzedElement}';
86 } 88 }
87 89
88 class _ResolutionWorldImpact extends ResolutionImpact { 90 class _ResolutionWorldImpact extends ResolutionImpact with WorldImpactBuilder {
89 final String name; 91 final String name;
90 // TODO(johnniwinther): Do we benefit from lazy initialization of the
91 // [Setlet]s?
92 Setlet<UniverseSelector> _dynamicInvocations;
93 Setlet<UniverseSelector> _dynamicGetters;
94 Setlet<UniverseSelector> _dynamicSetters;
95 Setlet<InterfaceType> _instantiatedTypes;
96 Setlet<Element> _staticUses;
97 Setlet<DartType> _isChecks;
98 Setlet<DartType> _asCasts;
99 Setlet<DartType> _checkedModeChecks;
100 Setlet<MethodElement> _closurizedFunctions;
101 Setlet<LocalFunctionElement> _closures;
102 Setlet<Feature> _features; 92 Setlet<Feature> _features;
103 // TODO(johnniwinther): This seems to be a union of other sets. 93 // TODO(johnniwinther): This seems to be a union of other sets.
104 Setlet<DartType> _requiredTypes; 94 Setlet<DartType> _requiredTypes;
105 Setlet<MapLiteralUse> _mapLiterals; 95 Setlet<MapLiteralUse> _mapLiterals;
106 Setlet<ListLiteralUse> _listLiterals; 96 Setlet<ListLiteralUse> _listLiterals;
107 Setlet<DartType> _typeLiterals;
108 Setlet<String> _constSymbolNames; 97 Setlet<String> _constSymbolNames;
109 98
110 _ResolutionWorldImpact(this.name); 99 _ResolutionWorldImpact(this.name);
111 100
112 void registerDynamicGetter(UniverseSelector selector) {
113 assert(selector != null);
114 if (_dynamicGetters == null) {
115 _dynamicGetters = new Setlet<UniverseSelector>();
116 }
117 _dynamicGetters.add(selector);
118 }
119
120 @override
121 Iterable<UniverseSelector> get dynamicGetters {
122 return _dynamicGetters != null
123 ? _dynamicGetters : const <UniverseSelector>[];
124 }
125
126 void registerDynamicInvocation(UniverseSelector selector) {
127 assert(selector != null);
128 if (_dynamicInvocations == null) {
129 _dynamicInvocations = new Setlet<UniverseSelector>();
130 }
131 _dynamicInvocations.add(selector);
132 }
133
134 @override
135 Iterable<UniverseSelector> get dynamicInvocations {
136 return _dynamicInvocations != null
137 ? _dynamicInvocations : const <UniverseSelector>[];
138 }
139
140 void registerDynamicSetter(UniverseSelector selector) {
141 assert(selector != null);
142 if (_dynamicSetters == null) {
143 _dynamicSetters = new Setlet<UniverseSelector>();
144 }
145 _dynamicSetters.add(selector);
146 }
147
148 @override
149 Iterable<UniverseSelector> get dynamicSetters {
150 return _dynamicSetters != null
151 ? _dynamicSetters : const <UniverseSelector>[];
152 }
153
154 void registerInstantiatedType(InterfaceType type) {
155 assert(type != null);
156 if (_instantiatedTypes == null) {
157 _instantiatedTypes = new Setlet<InterfaceType>();
158 }
159 _instantiatedTypes.add(type);
160 }
161
162 @override
163 Iterable<InterfaceType> get instantiatedTypes {
164 return _instantiatedTypes != null
165 ? _instantiatedTypes : const <InterfaceType>[];
166 }
167
168 void registerTypeLiteral(DartType type) {
169 assert(type != null);
170 if (_typeLiterals == null) {
171 _typeLiterals = new Setlet<DartType>();
172 }
173 _typeLiterals.add(type);
174 }
175
176 @override
177 Iterable<DartType> get typeLiterals {
178 return _typeLiterals != null
179 ? _typeLiterals : const <DartType>[];
180 }
181
182 void registerRequiredType(DartType type) { 101 void registerRequiredType(DartType type) {
183 assert(type != null); 102 assert(type != null);
184 if (_requiredTypes == null) { 103 if (_requiredTypes == null) {
185 _requiredTypes = new Setlet<DartType>(); 104 _requiredTypes = new Setlet<DartType>();
186 } 105 }
187 _requiredTypes.add(type); 106 _requiredTypes.add(type);
188 } 107 }
189 108
190 @override 109 @override
191 Iterable<DartType> get requiredTypes { 110 Iterable<DartType> get requiredTypes {
(...skipping 22 matching lines...) Expand all
214 } 133 }
215 _listLiterals.add(listLiteralUse); 134 _listLiterals.add(listLiteralUse);
216 } 135 }
217 136
218 @override 137 @override
219 Iterable<ListLiteralUse> get listLiterals { 138 Iterable<ListLiteralUse> get listLiterals {
220 return _listLiterals != null 139 return _listLiterals != null
221 ? _listLiterals : const <ListLiteralUse>[]; 140 ? _listLiterals : const <ListLiteralUse>[];
222 } 141 }
223 142
224 void registerStaticUse(Element element) {
225 assert(element != null);
226 if (_staticUses == null) {
227 _staticUses = new Setlet<Element>();
228 }
229 _staticUses.add(element);
230 }
231
232 @override
233 Iterable<Element> get staticUses {
234 return _staticUses != null ? _staticUses : const <Element>[];
235 }
236
237 void registerIsCheck(DartType type) {
238 assert(type != null);
239 if (_isChecks == null) {
240 _isChecks = new Setlet<DartType>();
241 }
242 _isChecks.add(type);
243 }
244
245 @override
246 Iterable<DartType> get isChecks {
247 return _isChecks != null
248 ? _isChecks : const <DartType>[];
249 }
250
251 void registerAsCast(DartType type) {
252 if (_asCasts == null) {
253 _asCasts = new Setlet<DartType>();
254 }
255 _asCasts.add(type);
256 }
257
258 @override
259 Iterable<DartType> get asCasts {
260 return _asCasts != null
261 ? _asCasts : const <DartType>[];
262 }
263
264 void registerCheckedModeCheckedType(DartType type) {
265 if (_checkedModeChecks == null) {
266 _checkedModeChecks = new Setlet<DartType>();
267 }
268 _checkedModeChecks.add(type);
269 }
270
271 @override
272 Iterable<DartType> get checkedModeChecks {
273 return _checkedModeChecks != null
274 ? _checkedModeChecks : const <DartType>[];
275 }
276
277 void registerClosurizedFunction(MethodElement element) {
278 if (_closurizedFunctions == null) {
279 _closurizedFunctions = new Setlet<MethodElement>();
280 }
281 _closurizedFunctions.add(element);
282 }
283
284 @override
285 Iterable<MethodElement> get closurizedFunctions {
286 return _closurizedFunctions != null
287 ? _closurizedFunctions : const <MethodElement>[];
288 }
289
290 void registerClosure(LocalFunctionElement element) {
291 if (_closures == null) {
292 _closures = new Setlet<LocalFunctionElement>();
293 }
294 _closures.add(element);
295 }
296
297 @override
298 Iterable<LocalFunctionElement> get closures {
299 return _closures != null
300 ? _closures : const <LocalFunctionElement>[];
301 }
302
303 void registerConstSymbolName(String name) { 143 void registerConstSymbolName(String name) {
304 if (_constSymbolNames == null) { 144 if (_constSymbolNames == null) {
305 _constSymbolNames = new Setlet<String>(); 145 _constSymbolNames = new Setlet<String>();
306 } 146 }
307 _constSymbolNames.add(name); 147 _constSymbolNames.add(name);
308 } 148 }
309 149
310 @override 150 @override
311 Iterable<String> get constSymbolNames { 151 Iterable<String> get constSymbolNames {
312 return _constSymbolNames != null 152 return _constSymbolNames != null
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 @override 604 @override
765 void registerInstantiatedType(InterfaceType type) { 605 void registerInstantiatedType(InterfaceType type) {
766 registry.registerInstantiatedType(type); 606 registry.registerInstantiatedType(type);
767 } 607 }
768 608
769 @override 609 @override
770 DartType resolveTypeFromString(Node node, String typeName) { 610 DartType resolveTypeFromString(Node node, String typeName) {
771 return visitor.resolveTypeFromString(node, typeName); 611 return visitor.resolveTypeFromString(node, typeName);
772 } 612 }
773 } 613 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/universe/world_impact.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698