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

Side by Side Diff: pkg/compiler/lib/src/universe/world_impact.dart

Issue 1408383006: Rename UniverseSelector to DynamicUse and move it to use.dart (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 1 month 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 | « pkg/compiler/lib/src/universe/use.dart ('k') | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.universe.world_impact; 5 library dart2js.universe.world_impact;
6 6
7 import '../dart_types.dart' show 7 import '../dart_types.dart' show
8 DartType, 8 DartType,
9 InterfaceType; 9 InterfaceType;
10 import '../elements/elements.dart' show 10 import '../elements/elements.dart' show
11 Element, 11 Element,
12 LocalFunctionElement, 12 LocalFunctionElement,
13 MethodElement; 13 MethodElement;
14 import '../util/util.dart' show 14 import '../util/util.dart' show
15 Setlet; 15 Setlet;
16 16
17 import 'universe.dart' show
18 UniverseSelector;
19 import 'use.dart' show 17 import 'use.dart' show
18 DynamicUse,
20 StaticUse; 19 StaticUse;
21 20
22 class WorldImpact { 21 class WorldImpact {
23 const WorldImpact(); 22 const WorldImpact();
24 23
25 Iterable<UniverseSelector> get dynamicUses => 24 Iterable<DynamicUse> get dynamicUses =>
26 const <UniverseSelector>[]; 25 const <DynamicUse>[];
27 26
28 Iterable<StaticUse> get staticUses => const <StaticUse>[]; 27 Iterable<StaticUse> get staticUses => const <StaticUse>[];
29 28
30 // TODO(johnniwinther): Replace this by called constructors with type 29 // TODO(johnniwinther): Replace this by called constructors with type
31 // arguments. 30 // arguments.
32 Iterable<InterfaceType> get instantiatedTypes => const <InterfaceType>[]; 31 Iterable<InterfaceType> get instantiatedTypes => const <InterfaceType>[];
33 32
34 // TODO(johnniwinther): Collect checked types for checked mode separately to 33 // TODO(johnniwinther): Collect checked types for checked mode separately to
35 // support serialization. 34 // support serialization.
36 Iterable<DartType> get isChecks => const <DartType>[]; 35 Iterable<DartType> get isChecks => const <DartType>[];
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 add('as-casts', worldImpact.asCasts); 68 add('as-casts', worldImpact.asCasts);
70 add('on-catch-types', worldImpact.onCatchTypes); 69 add('on-catch-types', worldImpact.onCatchTypes);
71 add('closures', worldImpact.closures); 70 add('closures', worldImpact.closures);
72 add('type literals', worldImpact.typeLiterals); 71 add('type literals', worldImpact.typeLiterals);
73 } 72 }
74 } 73 }
75 74
76 class WorldImpactBuilder { 75 class WorldImpactBuilder {
77 // TODO(johnniwinther): Do we benefit from lazy initialization of the 76 // TODO(johnniwinther): Do we benefit from lazy initialization of the
78 // [Setlet]s? 77 // [Setlet]s?
79 Setlet<UniverseSelector> _dynamicUses; 78 Setlet<DynamicUse> _dynamicUses;
80 Setlet<InterfaceType> _instantiatedTypes; 79 Setlet<InterfaceType> _instantiatedTypes;
81 Setlet<StaticUse> _staticUses; 80 Setlet<StaticUse> _staticUses;
82 Setlet<DartType> _isChecks; 81 Setlet<DartType> _isChecks;
83 Setlet<DartType> _asCasts; 82 Setlet<DartType> _asCasts;
84 Setlet<DartType> _checkedModeChecks; 83 Setlet<DartType> _checkedModeChecks;
85 Setlet<DartType> _onCatchTypes; 84 Setlet<DartType> _onCatchTypes;
86 Setlet<LocalFunctionElement> _closures; 85 Setlet<LocalFunctionElement> _closures;
87 Setlet<DartType> _typeLiterals; 86 Setlet<DartType> _typeLiterals;
88 87
89 void registerDynamicUse(UniverseSelector dynamicUse) { 88 void registerDynamicUse(DynamicUse dynamicUse) {
90 assert(dynamicUse != null); 89 assert(dynamicUse != null);
91 if (_dynamicUses == null) { 90 if (_dynamicUses == null) {
92 _dynamicUses = new Setlet<UniverseSelector>(); 91 _dynamicUses = new Setlet<DynamicUse>();
93 } 92 }
94 _dynamicUses.add(dynamicUse); 93 _dynamicUses.add(dynamicUse);
95 } 94 }
96 95
97 Iterable<UniverseSelector> get dynamicUses { 96 Iterable<DynamicUse> get dynamicUses {
98 return _dynamicUses != null 97 return _dynamicUses != null
99 ? _dynamicUses : const <UniverseSelector>[]; 98 ? _dynamicUses : const <DynamicUse>[];
100 } 99 }
101 100
102 void registerInstantiatedType(InterfaceType type) { 101 void registerInstantiatedType(InterfaceType type) {
103 assert(type != null); 102 assert(type != null);
104 if (_instantiatedTypes == null) { 103 if (_instantiatedTypes == null) {
105 _instantiatedTypes = new Setlet<InterfaceType>(); 104 _instantiatedTypes = new Setlet<InterfaceType>();
106 } 105 }
107 _instantiatedTypes.add(type); 106 _instantiatedTypes.add(type);
108 } 107 }
109 108
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 199 }
201 } 200 }
202 201
203 /// Mutable implementation of [WorldImpact] used to transform 202 /// Mutable implementation of [WorldImpact] used to transform
204 /// [ResolutionImpact] or [CodegenImpact] to [WorldImpact]. 203 /// [ResolutionImpact] or [CodegenImpact] to [WorldImpact].
205 class TransformedWorldImpact implements WorldImpact { 204 class TransformedWorldImpact implements WorldImpact {
206 final WorldImpact worldImpact; 205 final WorldImpact worldImpact;
207 206
208 Setlet<StaticUse> _staticUses; 207 Setlet<StaticUse> _staticUses;
209 Setlet<InterfaceType> _instantiatedTypes; 208 Setlet<InterfaceType> _instantiatedTypes;
210 Setlet<UniverseSelector> _dynamicUses; 209 Setlet<DynamicUse> _dynamicUses;
211 210
212 TransformedWorldImpact(this.worldImpact); 211 TransformedWorldImpact(this.worldImpact);
213 212
214 @override 213 @override
215 Iterable<DartType> get asCasts => worldImpact.asCasts; 214 Iterable<DartType> get asCasts => worldImpact.asCasts;
216 215
217 @override 216 @override
218 Iterable<DartType> get checkedModeChecks => worldImpact.checkedModeChecks; 217 Iterable<DartType> get checkedModeChecks => worldImpact.checkedModeChecks;
219 218
220 @override 219 @override
221 Iterable<UniverseSelector> get dynamicUses { 220 Iterable<DynamicUse> get dynamicUses {
222 return _dynamicUses != null 221 return _dynamicUses != null
223 ? _dynamicUses : worldImpact.dynamicUses; 222 ? _dynamicUses : worldImpact.dynamicUses;
224 } 223 }
225 224
226 @override 225 @override
227 Iterable<DartType> get isChecks => worldImpact.isChecks; 226 Iterable<DartType> get isChecks => worldImpact.isChecks;
228 227
229 @override 228 @override
230 Iterable<DartType> get onCatchTypes => worldImpact.onCatchTypes; 229 Iterable<DartType> get onCatchTypes => worldImpact.onCatchTypes;
231 230
232 _unsupported(String message) => throw new UnsupportedError(message); 231 _unsupported(String message) => throw new UnsupportedError(message);
233 232
234 void registerDynamicUse(UniverseSelector selector) { 233 void registerDynamicUse(DynamicUse dynamicUse) {
235 if (_dynamicUses == null) { 234 if (_dynamicUses == null) {
236 _dynamicUses = new Setlet<UniverseSelector>(); 235 _dynamicUses = new Setlet<DynamicUse>();
237 _dynamicUses.addAll(worldImpact.dynamicUses); 236 _dynamicUses.addAll(worldImpact.dynamicUses);
238 } 237 }
239 _dynamicUses.add(selector); 238 _dynamicUses.add(dynamicUse);
240 } 239 }
241 240
242 void registerInstantiatedType(InterfaceType type) { 241 void registerInstantiatedType(InterfaceType type) {
243 if (_instantiatedTypes == null) { 242 if (_instantiatedTypes == null) {
244 _instantiatedTypes = new Setlet<InterfaceType>(); 243 _instantiatedTypes = new Setlet<InterfaceType>();
245 _instantiatedTypes.addAll(worldImpact.instantiatedTypes); 244 _instantiatedTypes.addAll(worldImpact.instantiatedTypes);
246 } 245 }
247 _instantiatedTypes.add(type); 246 _instantiatedTypes.add(type);
248 } 247 }
249 248
(...skipping 24 matching lines...) Expand all
274 @override 273 @override
275 Iterable<LocalFunctionElement> get closures => worldImpact.closures; 274 Iterable<LocalFunctionElement> get closures => worldImpact.closures;
276 275
277 String toString() { 276 String toString() {
278 StringBuffer sb = new StringBuffer(); 277 StringBuffer sb = new StringBuffer();
279 sb.write('TransformedWorldImpact($worldImpact)'); 278 sb.write('TransformedWorldImpact($worldImpact)');
280 WorldImpact.printOn(sb, this); 279 WorldImpact.printOn(sb, this);
281 return sb.toString(); 280 return sb.toString();
282 } 281 }
283 } 282 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/universe/use.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698