OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 part of world_builder; | 5 part of world_builder; |
6 | 6 |
7 abstract class ResolutionWorldBuilder implements WorldBuilder, OpenWorld { | 7 abstract class ResolutionWorldBuilder implements WorldBuilder, OpenWorld { |
8 /// Set of all local functions in the program. Used by the mirror tracking | 8 /// Set of all local functions in the program. Used by the mirror tracking |
9 /// system to find all live closure instances. | 9 /// system to find all live closure instances. |
10 Iterable<Local> get localFunctions; | 10 Iterable<Local> get localFunctions; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 this._backendUsageBuilder, | 386 this._backendUsageBuilder, |
387 this._rtiNeedBuilder, | 387 this._rtiNeedBuilder, |
388 this._nativeResolutionEnqueuer, | 388 this._nativeResolutionEnqueuer, |
389 this.selectorConstraintsStrategy); | 389 this.selectorConstraintsStrategy); |
390 | 390 |
391 Iterable<ClassEntity> get processedClasses => _processedClasses.keys | 391 Iterable<ClassEntity> get processedClasses => _processedClasses.keys |
392 .where((cls) => _processedClasses[cls].isInstantiated); | 392 .where((cls) => _processedClasses[cls].isInstantiated); |
393 | 393 |
394 ClosedWorld get closedWorldForTesting { | 394 ClosedWorld get closedWorldForTesting { |
395 if (!_closed) { | 395 if (!_closed) { |
396 throw new SpannableAssertionFailure( | 396 failedAt( |
397 NO_LOCATION_SPANNABLE, "The world builder has not yet been closed."); | 397 NO_LOCATION_SPANNABLE, "The world builder has not yet been closed."); |
398 } | 398 } |
399 return _closedWorldCache; | 399 return _closedWorldCache; |
400 } | 400 } |
401 | 401 |
402 /// All directly instantiated classes, that is, classes with a generative | 402 /// All directly instantiated classes, that is, classes with a generative |
403 /// constructor that has been called directly and not only through a | 403 /// constructor that has been called directly and not only through a |
404 /// super-call. | 404 /// super-call. |
405 // TODO(johnniwinther): Improve semantic precision. | 405 // TODO(johnniwinther): Improve semantic precision. |
406 Iterable<ClassEntity> get directlyInstantiatedClasses { | 406 Iterable<ClassEntity> get directlyInstantiatedClasses { |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 case StaticUseKind.DIRECT_USE: | 641 case StaticUseKind.DIRECT_USE: |
642 case StaticUseKind.CONSTRUCTOR_INVOKE: | 642 case StaticUseKind.CONSTRUCTOR_INVOKE: |
643 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: | 643 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: |
644 case StaticUseKind.REDIRECTION: | 644 case StaticUseKind.REDIRECTION: |
645 useSet.addAll(usage.normalUse()); | 645 useSet.addAll(usage.normalUse()); |
646 break; | 646 break; |
647 case StaticUseKind.DIRECT_INVOKE: | 647 case StaticUseKind.DIRECT_INVOKE: |
648 failedAt(element, 'Direct static use is not supported for resolution.'); | 648 failedAt(element, 'Direct static use is not supported for resolution.'); |
649 break; | 649 break; |
650 case StaticUseKind.INLINING: | 650 case StaticUseKind.INLINING: |
651 throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE, | 651 failedAt(CURRENT_ELEMENT_SPANNABLE, |
652 "Static use ${staticUse.kind} is not supported during resolution."); | 652 "Static use ${staticUse.kind} is not supported during resolution."); |
653 } | 653 } |
654 if (useSet.isNotEmpty) { | 654 if (useSet.isNotEmpty) { |
655 memberUsed(usage.entity, useSet); | 655 memberUsed(usage.entity, useSet); |
656 } | 656 } |
657 } | 657 } |
658 | 658 |
659 /// Called to create a [_ClassUsage] for [cls]. | 659 /// Called to create a [_ClassUsage] for [cls]. |
660 /// | 660 /// |
661 /// Subclasses override this to ensure needed invariants on [cls]. | 661 /// Subclasses override this to ensure needed invariants on [cls]. |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 | 895 |
896 /// Updates the `isDirectlyInstantiated` and `isIndirectlyInstantiated` | 896 /// Updates the `isDirectlyInstantiated` and `isIndirectlyInstantiated` |
897 /// properties of the [ClassHierarchyNode] for [cls]. | 897 /// properties of the [ClassHierarchyNode] for [cls]. |
898 | 898 |
899 void addSubtypes(ClassEntity cls, InstantiationInfo info) { | 899 void addSubtypes(ClassEntity cls, InstantiationInfo info) { |
900 if (!info.hasInstantiation) { | 900 if (!info.hasInstantiation) { |
901 return; | 901 return; |
902 } | 902 } |
903 assert(checkClass(cls)); | 903 assert(checkClass(cls)); |
904 if (!validateClass(cls)) { | 904 if (!validateClass(cls)) { |
905 throw new SpannableAssertionFailure( | 905 failedAt(cls, 'Class "${cls.name}" is not resolved.'); |
906 cls, 'Class "${cls.name}" is not resolved.'); | |
907 } | 906 } |
908 | 907 |
909 _updateClassHierarchyNodeForClass(cls, | 908 _updateClassHierarchyNodeForClass(cls, |
910 directlyInstantiated: info.isDirectlyInstantiated, | 909 directlyInstantiated: info.isDirectlyInstantiated, |
911 abstractlyInstantiated: info.isAbstractlyInstantiated); | 910 abstractlyInstantiated: info.isAbstractlyInstantiated); |
912 | 911 |
913 // Walk through the superclasses, and record the types | 912 // Walk through the superclasses, and record the types |
914 // implemented by that type on the superclasses. | 913 // implemented by that type on the superclasses. |
915 ClassEntity superclass = getSuperClass(cls); | 914 ClassEntity superclass = getSuperClass(cls); |
916 while (superclass != null) { | 915 while (superclass != null) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 typesImplementedBySubclasses: typesImplementedBySubclasses, | 1007 typesImplementedBySubclasses: typesImplementedBySubclasses, |
1009 classHierarchyNodes: _classHierarchyNodes, | 1008 classHierarchyNodes: _classHierarchyNodes, |
1010 classSets: _classSets); | 1009 classSets: _classSets); |
1011 } | 1010 } |
1012 | 1011 |
1013 @override | 1012 @override |
1014 void registerClass(ClassEntity cls) { | 1013 void registerClass(ClassEntity cls) { |
1015 throw new UnimplementedError('KernelResolutionWorldBuilder.registerClass'); | 1014 throw new UnimplementedError('KernelResolutionWorldBuilder.registerClass'); |
1016 } | 1015 } |
1017 } | 1016 } |
OLD | NEW |