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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 final BackendUsageBuilder _backendUsageBuilder; | 347 final BackendUsageBuilder _backendUsageBuilder; |
348 | 348 |
349 final SelectorConstraintsStrategy selectorConstraintsStrategy; | 349 final SelectorConstraintsStrategy selectorConstraintsStrategy; |
350 | 350 |
351 bool hasRuntimeTypeSupport = false; | 351 bool hasRuntimeTypeSupport = false; |
352 bool hasIsolateSupport = false; | 352 bool hasIsolateSupport = false; |
353 bool hasFunctionApplySupport = false; | 353 bool hasFunctionApplySupport = false; |
354 | 354 |
355 bool _closed = false; | 355 bool _closed = false; |
356 ClosedWorld _closedWorldCache; | 356 ClosedWorld _closedWorldCache; |
357 FunctionSetBuilder _allFunctions; | 357 final Set<MemberEntity> _liveInstanceMembers = new Set<MemberEntity>(); |
358 | 358 |
359 final Set<TypedefElement> _allTypedefs = new Set<TypedefElement>(); | 359 final Set<TypedefElement> _allTypedefs = new Set<TypedefElement>(); |
360 | 360 |
361 final Map<ClassEntity, Set<ClassEntity>> _mixinUses = | 361 final Map<ClassEntity, Set<ClassEntity>> _mixinUses = |
362 new Map<ClassEntity, Set<ClassEntity>>(); | 362 new Map<ClassEntity, Set<ClassEntity>>(); |
363 | 363 |
364 // We keep track of subtype and subclass relationships in four | 364 // We keep track of subtype and subclass relationships in four |
365 // distinct sets to make class hierarchy analysis faster. | 365 // distinct sets to make class hierarchy analysis faster. |
366 final Map<ClassEntity, ClassHierarchyNode> _classHierarchyNodes = | 366 final Map<ClassEntity, ClassHierarchyNode> _classHierarchyNodes = |
367 <ClassEntity, ClassHierarchyNode>{}; | 367 <ClassEntity, ClassHierarchyNode>{}; |
368 final Map<ClassEntity, ClassSet> _classSets = <ClassEntity, ClassSet>{}; | 368 final Map<ClassEntity, ClassSet> _classSets = <ClassEntity, ClassSet>{}; |
369 | 369 |
370 final Set<ConstantValue> _constantValues = new Set<ConstantValue>(); | 370 final Set<ConstantValue> _constantValues = new Set<ConstantValue>(); |
371 | 371 |
372 bool get isClosed => _closed; | 372 bool get isClosed => _closed; |
373 | 373 |
374 ResolutionWorldBuilderBase( | 374 ResolutionWorldBuilderBase( |
375 this._elementEnvironment, | 375 this._elementEnvironment, |
376 this._dartTypes, | 376 this._dartTypes, |
377 this._commonElements, | 377 this._commonElements, |
378 this._constantSystem, | 378 this._constantSystem, |
379 this._nativeBasicData, | 379 this._nativeBasicData, |
380 this._nativeDataBuilder, | 380 this._nativeDataBuilder, |
381 this._interceptorDataBuilder, | 381 this._interceptorDataBuilder, |
382 this._backendUsageBuilder, | 382 this._backendUsageBuilder, |
383 this.selectorConstraintsStrategy) { | 383 this.selectorConstraintsStrategy); |
384 _allFunctions = new FunctionSetBuilder(); | |
385 } | |
386 | 384 |
387 Iterable<ClassEntity> get processedClasses => _processedClasses.keys | 385 Iterable<ClassEntity> get processedClasses => _processedClasses.keys |
388 .where((cls) => _processedClasses[cls].isInstantiated); | 386 .where((cls) => _processedClasses[cls].isInstantiated); |
389 | 387 |
390 ClosedWorld get closedWorldForTesting { | 388 ClosedWorld get closedWorldForTesting { |
391 if (!_closed) { | 389 if (!_closed) { |
392 throw new SpannableAssertionFailure( | 390 throw new SpannableAssertionFailure( |
393 NO_LOCATION_SPANNABLE, "The world builder has not yet been closed."); | 391 NO_LOCATION_SPANNABLE, "The world builder has not yet been closed."); |
394 } | 392 } |
395 return _closedWorldCache; | 393 return _closedWorldCache; |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 covariant ClassEntity mixinApplication, covariant ClassEntity mixin) { | 778 covariant ClassEntity mixinApplication, covariant ClassEntity mixin) { |
781 // TODO(johnniwinther): Add map restricted to live classes. | 779 // TODO(johnniwinther): Add map restricted to live classes. |
782 // We don't support patch classes as mixin. | 780 // We don't support patch classes as mixin. |
783 Set<ClassEntity> users = | 781 Set<ClassEntity> users = |
784 _mixinUses.putIfAbsent(mixin, () => new Set<ClassEntity>()); | 782 _mixinUses.putIfAbsent(mixin, () => new Set<ClassEntity>()); |
785 users.add(mixinApplication); | 783 users.add(mixinApplication); |
786 } | 784 } |
787 | 785 |
788 void registerUsedElement(MemberEntity element) { | 786 void registerUsedElement(MemberEntity element) { |
789 if (element.isInstanceMember && !element.isAbstract) { | 787 if (element.isInstanceMember && !element.isAbstract) { |
790 _allFunctions.add(element); | 788 _liveInstanceMembers.add(element); |
791 } | 789 } |
792 } | 790 } |
793 | 791 |
794 ClosedWorld get closedWorldCache { | 792 ClosedWorld get closedWorldCache { |
795 assert(isClosed); | 793 assert(isClosed); |
796 return _closedWorldCache; | 794 return _closedWorldCache; |
797 } | 795 } |
798 | 796 |
799 @override | 797 @override |
800 bool isMemberUsed(MemberEntity member) { | 798 bool isMemberUsed(MemberEntity member) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 return _closedWorldCache = new KernelClosedWorld(elementMap, | 968 return _closedWorldCache = new KernelClosedWorld(elementMap, |
971 elementEnvironment: _elementEnvironment, | 969 elementEnvironment: _elementEnvironment, |
972 dartTypes: _dartTypes, | 970 dartTypes: _dartTypes, |
973 commonElements: _commonElements, | 971 commonElements: _commonElements, |
974 nativeData: _nativeDataBuilder.close(), | 972 nativeData: _nativeDataBuilder.close(), |
975 interceptorData: _interceptorDataBuilder.close(), | 973 interceptorData: _interceptorDataBuilder.close(), |
976 backendUsage: _backendUsageBuilder.close(), | 974 backendUsage: _backendUsageBuilder.close(), |
977 constantSystem: _constantSystem, | 975 constantSystem: _constantSystem, |
978 resolutionWorldBuilder: this, | 976 resolutionWorldBuilder: this, |
979 implementedClasses: _implementedClasses, | 977 implementedClasses: _implementedClasses, |
980 functionSet: _allFunctions.close(), | 978 liveInstanceMembers: _liveInstanceMembers, |
981 allTypedefs: _allTypedefs, | 979 allTypedefs: _allTypedefs, |
982 mixinUses: _mixinUses, | 980 mixinUses: _mixinUses, |
983 typesImplementedBySubclasses: typesImplementedBySubclasses, | 981 typesImplementedBySubclasses: typesImplementedBySubclasses, |
984 classHierarchyNodes: _classHierarchyNodes, | 982 classHierarchyNodes: _classHierarchyNodes, |
985 classSets: _classSets); | 983 classSets: _classSets); |
986 } | 984 } |
987 | 985 |
988 @override | 986 @override |
989 void registerClass(ClassEntity cls) { | 987 void registerClass(ClassEntity cls) { |
990 throw new UnimplementedError('KernelResolutionWorldBuilder.registerClass'); | 988 throw new UnimplementedError('KernelResolutionWorldBuilder.registerClass'); |
991 } | 989 } |
992 } | 990 } |
OLD | NEW |