mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Merge instance and static member usage maps.
Change-Id: I2c4802b946af162be2257a10502b2c8f823786d1 Reviewed-on: https://dart-review.googlesource.com/30448 Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
parent
aa9765604e
commit
a671328de3
|
@ -296,17 +296,28 @@ abstract class ResolutionWorldBuilderBase
|
||||||
Map<ClassEntity, _ClassUsage> get classUsageForTesting => _processedClasses;
|
Map<ClassEntity, _ClassUsage> get classUsageForTesting => _processedClasses;
|
||||||
|
|
||||||
/// Map of registered usage of static members of live classes.
|
/// Map of registered usage of static members of live classes.
|
||||||
final Map<Entity, _MemberUsage> _staticMemberUsage = <Entity, _MemberUsage>{};
|
final Map<MemberEntity, _MemberUsage> _memberUsage =
|
||||||
|
|
||||||
Map<Entity, _MemberUsage> get staticMemberUsageForTesting =>
|
|
||||||
_staticMemberUsage;
|
|
||||||
|
|
||||||
/// Map of registered usage of instance members of live classes.
|
|
||||||
final Map<MemberEntity, _MemberUsage> _instanceMemberUsage =
|
|
||||||
<MemberEntity, _MemberUsage>{};
|
<MemberEntity, _MemberUsage>{};
|
||||||
|
|
||||||
Map<MemberEntity, _MemberUsage> get instanceMemberUsageForTesting =>
|
Map<MemberEntity, _MemberUsage> get staticMemberUsageForTesting {
|
||||||
_instanceMemberUsage;
|
Map<MemberEntity, _MemberUsage> map = <MemberEntity, _MemberUsage>{};
|
||||||
|
_memberUsage.forEach((MemberEntity member, _MemberUsage usage) {
|
||||||
|
if (!member.isInstanceMember) {
|
||||||
|
map[member] = usage;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<MemberEntity, _MemberUsage> get instanceMemberUsageForTesting {
|
||||||
|
Map<MemberEntity, _MemberUsage> map = <MemberEntity, _MemberUsage>{};
|
||||||
|
_memberUsage.forEach((MemberEntity member, _MemberUsage usage) {
|
||||||
|
if (member.isInstanceMember) {
|
||||||
|
map[member] = usage;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
/// Map containing instance members of live classes that are not yet live
|
/// Map containing instance members of live classes that are not yet live
|
||||||
/// themselves.
|
/// themselves.
|
||||||
|
@ -616,7 +627,7 @@ abstract class ResolutionWorldBuilderBase
|
||||||
|
|
||||||
MemberEntity element = staticUse.element;
|
MemberEntity element = staticUse.element;
|
||||||
EnumSet<MemberUse> useSet = new EnumSet<MemberUse>();
|
EnumSet<MemberUse> useSet = new EnumSet<MemberUse>();
|
||||||
_MemberUsage usage = _staticMemberUsage.putIfAbsent(element, () {
|
_MemberUsage usage = _memberUsage.putIfAbsent(element, () {
|
||||||
_MemberUsage usage = new _MemberUsage(element);
|
_MemberUsage usage = new _MemberUsage(element);
|
||||||
useSet.addAll(usage.appliedUse);
|
useSet.addAll(usage.appliedUse);
|
||||||
return usage;
|
return usage;
|
||||||
|
@ -749,7 +760,7 @@ abstract class ResolutionWorldBuilderBase
|
||||||
// its metadata parsed and analyzed.
|
// its metadata parsed and analyzed.
|
||||||
// Note: this assumes that there are no non-native fields on native
|
// Note: this assumes that there are no non-native fields on native
|
||||||
// classes, which may not be the case when a native class is subclassed.
|
// classes, which may not be the case when a native class is subclassed.
|
||||||
_instanceMemberUsage.putIfAbsent(member, () {
|
_memberUsage.putIfAbsent(member, () {
|
||||||
bool isNative = _nativeBasicData.isNativeClass(cls);
|
bool isNative = _nativeBasicData.isNativeClass(cls);
|
||||||
_MemberUsage usage = new _MemberUsage(member, isNative: isNative);
|
_MemberUsage usage = new _MemberUsage(member, isNative: isNative);
|
||||||
EnumSet<MemberUse> useSet = new EnumSet<MemberUse>();
|
EnumSet<MemberUse> useSet = new EnumSet<MemberUse>();
|
||||||
|
@ -816,12 +827,7 @@ abstract class ResolutionWorldBuilderBase
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isMemberUsed(MemberEntity member) {
|
bool isMemberUsed(MemberEntity member) {
|
||||||
if (member.isInstanceMember) {
|
return _memberUsage[member]?.hasUse ?? false;
|
||||||
_MemberUsage usage = _instanceMemberUsage[member];
|
|
||||||
if (usage != null && usage.hasUse) return true;
|
|
||||||
}
|
|
||||||
_MemberUsage usage = _staticMemberUsage[member];
|
|
||||||
return usage != null && usage.hasUse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<ClassEntity, Set<ClassEntity>> populateHierarchyNodes() {
|
Map<ClassEntity, Set<ClassEntity>> populateHierarchyNodes() {
|
||||||
|
|
Loading…
Reference in a new issue