| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 universe; | 5 library universe; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import '../cache_strategy.dart'; | 9 import '../cache_strategy.dart'; |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 /// directly and abstractly instantiated classes but also classes whose type | 165 /// directly and abstractly instantiated classes but also classes whose type |
| 166 /// arguments are used in live factory constructors. | 166 /// arguments are used in live factory constructors. |
| 167 void forEachInstantiatedClass(f(ClassElement cls, InstantiationInfo info)); | 167 void forEachInstantiatedClass(f(ClassElement cls, InstantiationInfo info)); |
| 168 | 168 |
| 169 /// Returns `true` if [member] is invoked as a setter. | 169 /// Returns `true` if [member] is invoked as a setter. |
| 170 bool hasInvokedSetter(Element member); | 170 bool hasInvokedSetter(Element member); |
| 171 | 171 |
| 172 /// The [OpenWorld] being created by this world builder. | 172 /// The [OpenWorld] being created by this world builder. |
| 173 // TODO(johnniwinther): Merge this with [ResolutionWorldBuilder]. | 173 // TODO(johnniwinther): Merge this with [ResolutionWorldBuilder]. |
| 174 OpenWorld get openWorld; | 174 OpenWorld get openWorld; |
| 175 |
| 176 /// The closed world computed by this world builder. |
| 177 /// |
| 178 /// This is only available after the world builder has been closed. |
| 179 ClosedWorld get closedWorldForTesting; |
| 175 } | 180 } |
| 176 | 181 |
| 177 /// The type and kind of an instantiation registered through | 182 /// The type and kind of an instantiation registered through |
| 178 /// `ResolutionWorldBuilder.registerTypeInstantiation`. | 183 /// `ResolutionWorldBuilder.registerTypeInstantiation`. |
| 179 class Instance { | 184 class Instance { |
| 180 final InterfaceType type; | 185 final InterfaceType type; |
| 181 final Instantiation kind; | 186 final Instantiation kind; |
| 182 final bool isRedirection; | 187 final bool isRedirection; |
| 183 | 188 |
| 184 Instance(this.type, this.kind, {this.isRedirection: false}); | 189 Instance(this.type, this.kind, {this.isRedirection: false}); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 final SelectorConstraintsStrategy selectorConstraintsStrategy; | 423 final SelectorConstraintsStrategy selectorConstraintsStrategy; |
| 419 | 424 |
| 420 bool hasRuntimeTypeSupport = false; | 425 bool hasRuntimeTypeSupport = false; |
| 421 bool hasIsolateSupport = false; | 426 bool hasIsolateSupport = false; |
| 422 bool hasFunctionApplySupport = false; | 427 bool hasFunctionApplySupport = false; |
| 423 | 428 |
| 424 /// Used for testing the new more precise computation of instantiated types | 429 /// Used for testing the new more precise computation of instantiated types |
| 425 /// and classes. | 430 /// and classes. |
| 426 bool useInstantiationMap = false; | 431 bool useInstantiationMap = false; |
| 427 | 432 |
| 428 OpenWorld _openWorld; | 433 WorldImpl _openWorld; |
| 429 | 434 |
| 430 final Backend _backend; | 435 final Backend _backend; |
| 431 final Resolution _resolution; | 436 final Resolution _resolution; |
| 432 | 437 |
| 433 ResolutionWorldBuilderImpl(Backend backend, Resolution resolution, | 438 ResolutionWorldBuilderImpl(Backend backend, Resolution resolution, |
| 434 CacheStrategy cacheStrategy, this.selectorConstraintsStrategy) | 439 CacheStrategy cacheStrategy, this.selectorConstraintsStrategy) |
| 435 : this._backend = backend, | 440 : this._backend = backend, |
| 436 this._resolution = resolution { | 441 this._resolution = resolution { |
| 437 _openWorld = new WorldImpl(this, backend, resolution.coreClasses, | 442 _openWorld = new WorldImpl(this, backend, resolution.coreClasses, |
| 438 resolution.coreTypes, cacheStrategy); | 443 resolution.coreTypes, cacheStrategy); |
| 439 } | 444 } |
| 440 | 445 |
| 441 Iterable<ClassElement> get processedClasses => _processedClasses.keys | 446 Iterable<ClassElement> get processedClasses => _processedClasses.keys |
| 442 .where((cls) => _processedClasses[cls].isInstantiated); | 447 .where((cls) => _processedClasses[cls].isInstantiated); |
| 443 | 448 |
| 444 OpenWorld get openWorld => _openWorld; | 449 OpenWorld get openWorld => _openWorld; |
| 445 | 450 |
| 451 ClosedWorld get closedWorldForTesting { |
| 452 if (!_openWorld.isClosed) { |
| 453 throw new SpannableAssertionFailure( |
| 454 NO_LOCATION_SPANNABLE, "The world builder has not yet been closed."); |
| 455 } |
| 456 return _openWorld; |
| 457 } |
| 458 |
| 446 /// All directly instantiated classes, that is, classes with a generative | 459 /// All directly instantiated classes, that is, classes with a generative |
| 447 /// constructor that has been called directly and not only through a | 460 /// constructor that has been called directly and not only through a |
| 448 /// super-call. | 461 /// super-call. |
| 449 // TODO(johnniwinther): Improve semantic precision. | 462 // TODO(johnniwinther): Improve semantic precision. |
| 450 Iterable<ClassElement> get directlyInstantiatedClasses { | 463 Iterable<ClassElement> get directlyInstantiatedClasses { |
| 451 Set<ClassElement> classes = new Set<ClassElement>(); | 464 Set<ClassElement> classes = new Set<ClassElement>(); |
| 452 getInstantiationMap().forEach((ClassElement cls, InstantiationInfo info) { | 465 getInstantiationMap().forEach((ClassElement cls, InstantiationInfo info) { |
| 453 if (info.hasInstantiation) { | 466 if (info.hasInstantiation) { |
| 454 classes.add(cls); | 467 classes.add(cls); |
| 455 } | 468 } |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 if (hasClosurization) { | 1541 if (hasClosurization) { |
| 1529 return MemberUses.NONE; | 1542 return MemberUses.NONE; |
| 1530 } | 1543 } |
| 1531 hasNormalUse = hasClosurization = true; | 1544 hasNormalUse = hasClosurization = true; |
| 1532 return _pendingUse.removeAll(MemberUses.ALL_STATIC); | 1545 return _pendingUse.removeAll(MemberUses.ALL_STATIC); |
| 1533 } | 1546 } |
| 1534 | 1547 |
| 1535 @override | 1548 @override |
| 1536 EnumSet<MemberUse> get _originalUse => MemberUses.ALL_STATIC; | 1549 EnumSet<MemberUse> get _originalUse => MemberUses.ALL_STATIC; |
| 1537 } | 1550 } |
| OLD | NEW |