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

Unified Diff: pkg/kernel/lib/class_hierarchy.dart

Issue 2924713002: Replace ClassHierarchy.classes with getOrderedClasses(). (Closed)
Patch Set: Update getOrderedClasses() to return only given classes. 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
« no previous file with comments | « no previous file | pkg/kernel/lib/src/incremental_class_hierarchy.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/class_hierarchy.dart
diff --git a/pkg/kernel/lib/class_hierarchy.dart b/pkg/kernel/lib/class_hierarchy.dart
index 34bf1277580f7850ec2fec6bacaf9d30a210d904..c17bd8c11d07424108ab78050ccfb0801f790249 100644
--- a/pkg/kernel/lib/class_hierarchy.dart
+++ b/pkg/kernel/lib/class_hierarchy.dart
@@ -16,12 +16,12 @@ abstract class ClassHierarchy {
factory ClassHierarchy(Program program) =>
new ClosedWorldClassHierarchy(program);
- /// All classes in the program.
- ///
- /// The iterable is ordered so that classes occur after their super classes.
- Iterable<Class> get classes;
+ /// Given the [unordered] classes, return them in such order that classes
+ /// occur after their superclasses. If some superclasses are not in
+ /// [unordered], they are not included.
+ Iterable<Class> getOrderedClasses(Iterable<Class> unordered);
- /// Returns the index of [class_] in the [classes] list.
+ /// Returns the unique index of the [class_].
int getClassIndex(Class class_);
/// True if the program contains another class that is a subtype of given one.
@@ -137,6 +137,12 @@ class ClosedWorldClassHierarchy implements ClassHierarchy {
@override
int getClassIndex(Class class_) => _infoFor[class_].topologicalIndex;
+ @override
+ Iterable<Class> getOrderedClasses(Iterable<Class> unordered) {
+ var unorderedSet = unordered.toSet();
+ return classes.where(unorderedSet.contains);
+ }
+
/// True if [subclass] inherits from [superclass] though zero or more
/// `extends` relationships.
bool isSubclassOf(Class subclass, Class superclass) {
« no previous file with comments | « no previous file | pkg/kernel/lib/src/incremental_class_hierarchy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698