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

Unified Diff: pkg/kernel/lib/src/incremental_class_hierarchy.dart

Issue 2924713002: Replace ClassHierarchy.classes with getOrderedClasses(). (Closed)
Patch Set: Tweak the comment. Created 3 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: pkg/kernel/lib/src/incremental_class_hierarchy.dart
diff --git a/pkg/kernel/lib/src/incremental_class_hierarchy.dart b/pkg/kernel/lib/src/incremental_class_hierarchy.dart
index af79293b68243ec755b4202a8e661058ace27f8b..8c6db567d818b11ef7be9e3caccb5271a6153e6e 100644
--- a/pkg/kernel/lib/src/incremental_class_hierarchy.dart
+++ b/pkg/kernel/lib/src/incremental_class_hierarchy.dart
@@ -74,14 +74,9 @@ class IncrementalClassHierarchy implements ClassHierarchy {
int _nextId = 0;
/// The mapping from [Class]es to the corresponding [_ClassInfo]s.
+ /// The map is ordered in such a way that classes are after superclasses.
/// It is filled lazily as the client requests information about classes.
- final Map<Class, _ClassInfo> _info = {};
-
- @override
- Iterable<Class> get classes {
- // TODO(scheglov): implement classes
- throw new UnimplementedError();
- }
+ final Map<Class, _ClassInfo> _info = new LinkedHashMap<Class, _ClassInfo>();
@override
void forEachOverridePair(Class node,
@@ -251,6 +246,12 @@ class IncrementalClassHierarchy implements ClassHierarchy {
}
@override
+ Iterable<Class> getOrderedClasses(Iterable<Class> unordered) {
+ unordered.forEach(_getInfo);
+ return _info.keys;
+ }
+
+ @override
List<Class> getRankedSuperclasses(Class node) {
var info = _getInfo(node);
return _getRankedSuperclassList(info).map((info) => info.node).toList();
@@ -360,7 +361,6 @@ class IncrementalClassHierarchy implements ClassHierarchy {
var info = _info[node];
if (info == null) {
info = new _ClassInfo(_nextId++, node);
- _info[node] = info;
void addSupertypeIdentifiers(_ClassInfo superInfo) {
info.supertypeIdSet.add(superInfo.id);
@@ -386,7 +386,9 @@ class IncrementalClassHierarchy implements ClassHierarchy {
addSupertypeIdentifiers(implementedInfo);
_recordSuperTypes(info, implementedType, implementedInfo);
}
+
info.depth = superDepth + 1;
+ _info[node] = info;
_buildDeclaredMembers(info);
_buildImplementedMembers(info);
@@ -628,7 +630,7 @@ class _ClassInfo {
int depth = -1;
/// The list of superclasses sorted by depth (descending order) and
- /// unique identifiers (ascending order), or `null` if the lit has not
+ /// unique identifiers (ascending order), or `null` if the list has not
/// been computed yet.
List<_ClassInfo> rankedSuperclassList;

Powered by Google App Engine
This is Rietveld 408576698