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

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

Issue 1421463005: Move codegen registration to transformImpact method. (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/resolution/registry.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
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 _closures = new Setlet<LocalFunctionElement>(); 239 _closures = new Setlet<LocalFunctionElement>();
240 } 240 }
241 _closures.add(element); 241 _closures.add(element);
242 } 242 }
243 243
244 Iterable<LocalFunctionElement> get closures { 244 Iterable<LocalFunctionElement> get closures {
245 return _closures != null 245 return _closures != null
246 ? _closures : const <LocalFunctionElement>[]; 246 ? _closures : const <LocalFunctionElement>[];
247 } 247 }
248 } 248 }
249
250 /// Mutable implementation of [WorldImpact] used to transform
251 /// [ResolutionImpact] or [CodegenImpact] to [WorldImpact].
252 class TransformedWorldImpact implements WorldImpact {
253 final WorldImpact worldImpact;
254
255 Setlet<Element> _staticUses;
256 Setlet<InterfaceType> _instantiatedTypes;
257 Setlet<UniverseSelector> _dynamicGetters;
258 Setlet<UniverseSelector> _dynamicInvocations;
259 Setlet<UniverseSelector> _dynamicSetters;
260
261 TransformedWorldImpact(this.worldImpact);
262
263 @override
264 Iterable<DartType> get asCasts => worldImpact.asCasts;
265
266 @override
267 Iterable<DartType> get checkedModeChecks => worldImpact.checkedModeChecks;
268
269 @override
270 Iterable<MethodElement> get closurizedFunctions {
271 return worldImpact.closurizedFunctions;
272 }
273
274 @override
275 Iterable<UniverseSelector> get dynamicGetters {
276 return _dynamicGetters != null
277 ? _dynamicGetters : worldImpact.dynamicGetters;
278 }
279
280 @override
281 Iterable<UniverseSelector> get dynamicInvocations {
282 return _dynamicInvocations != null
283 ? _dynamicInvocations : worldImpact.dynamicInvocations;
284 }
285
286 @override
287 Iterable<UniverseSelector> get dynamicSetters {
288 return _dynamicSetters != null
289 ? _dynamicSetters : worldImpact.dynamicSetters;
290 }
291
292 @override
293 Iterable<DartType> get isChecks => worldImpact.isChecks;
294
295 @override
296 Iterable<DartType> get onCatchTypes => worldImpact.onCatchTypes;
297
298 _unsupported(String message) => throw new UnsupportedError(message);
299
300 void registerDynamicGetter(UniverseSelector selector) {
301 if (_dynamicGetters == null) {
302 _dynamicGetters = new Setlet<UniverseSelector>();
303 _dynamicGetters.addAll(worldImpact.dynamicGetters);
304 }
305 _dynamicGetters.add(selector);
306 }
307
308 void registerDynamicInvocation(UniverseSelector selector) {
309 if (_dynamicInvocations == null) {
310 _dynamicInvocations = new Setlet<UniverseSelector>();
311 _dynamicInvocations.addAll(worldImpact.dynamicInvocations);
312 }
313 _dynamicInvocations.add(selector);
314 }
315
316 void registerDynamicSetter(UniverseSelector selector) {
317 if (_dynamicSetters == null) {
318 _dynamicSetters = new Setlet<UniverseSelector>();
319 _dynamicSetters.addAll(worldImpact.dynamicSetters);
320 }
321 _dynamicSetters.add(selector);
322 }
323
324 void registerInstantiatedType(InterfaceType type) {
325 if (_instantiatedTypes == null) {
326 _instantiatedTypes = new Setlet<InterfaceType>();
327 _instantiatedTypes.addAll(worldImpact.instantiatedTypes);
328 }
329 _instantiatedTypes.add(type);
330 }
331
332 @override
333 Iterable<InterfaceType> get instantiatedTypes {
334 return _instantiatedTypes != null
335 ? _instantiatedTypes : worldImpact.instantiatedTypes;
336 }
337
338 @override
339 Iterable<DartType> get typeLiterals {
340 return worldImpact.typeLiterals;
341 }
342
343 void registerStaticUse(Element element) {
344 if (_staticUses == null) {
345 _staticUses = new Setlet<Element>();
346 _staticUses.addAll(worldImpact.staticUses);
347 }
348 _staticUses.add(element);
349 }
350
351 @override
352 Iterable<Element> get staticUses {
353 return _staticUses != null ? _staticUses : worldImpact.staticUses;
354 }
355
356 @override
357 Iterable<LocalFunctionElement> get closures => worldImpact.closures;
358
359 String toString() {
360 StringBuffer sb = new StringBuffer();
361 sb.write('TransformedWorldImpact($worldImpact)');
362 WorldImpact.printOn(sb, this);
363 return sb.toString();
364 }
365 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/registry.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698