OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library kernel.class_hierarchy; | 4 library kernel.class_hierarchy; |
5 | 5 |
6 import 'ast.dart'; | 6 import 'ast.dart'; |
7 import 'dart:math'; | 7 import 'dart:math'; |
8 import 'dart:typed_data'; | 8 import 'dart:typed_data'; |
9 import 'src/heap.dart'; | 9 import 'src/heap.dart'; |
10 import 'type_algebra.dart'; | 10 import 'type_algebra.dart'; |
11 | 11 |
12 /// Interface for answering various subclassing queries. | 12 /// Interface for answering various subclassing queries. |
13 /// TODO(scheglov) Several methods are not used, or used only in tests. | 13 /// TODO(scheglov) Several methods are not used, or used only in tests. |
14 /// Check if these methods are not useful and should be removed . | 14 /// Check if these methods are not useful and should be removed . |
15 abstract class ClassHierarchy { | 15 abstract class ClassHierarchy { |
16 factory ClassHierarchy(Program program) => | |
17 new ClosedWorldClassHierarchy(program); | |
18 | |
19 /// Given the [unordered] classes, return them in such order that classes | 16 /// Given the [unordered] classes, return them in such order that classes |
20 /// occur after their superclasses. If some superclasses are not in | 17 /// occur after their superclasses. If some superclasses are not in |
21 /// [unordered], they are not included. | 18 /// [unordered], they are not included. |
22 Iterable<Class> getOrderedClasses(Iterable<Class> unordered); | 19 Iterable<Class> getOrderedClasses(Iterable<Class> unordered); |
23 | 20 |
24 /// Returns the unique index of the [class_]. | 21 /// Returns the unique index of the [class_]. |
25 int getClassIndex(Class class_); | 22 int getClassIndex(Class class_); |
26 | 23 |
27 /// True if the program contains another class that is a subtype of given one. | 24 /// True if the program contains another class that is a subtype of given one. |
28 bool hasProperSubtypes(Class class_); | 25 bool hasProperSubtypes(Class class_); |
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 class _LubHeap extends Heap<_ClassInfo> { | 1130 class _LubHeap extends Heap<_ClassInfo> { |
1134 @override | 1131 @override |
1135 bool sortsBefore(_ClassInfo a, _ClassInfo b) => sortsBeforeStatic(a, b); | 1132 bool sortsBefore(_ClassInfo a, _ClassInfo b) => sortsBeforeStatic(a, b); |
1136 | 1133 |
1137 static bool sortsBeforeStatic(_ClassInfo a, _ClassInfo b) { | 1134 static bool sortsBeforeStatic(_ClassInfo a, _ClassInfo b) { |
1138 if (a.depth > b.depth) return true; | 1135 if (a.depth > b.depth) return true; |
1139 if (a.depth < b.depth) return false; | 1136 if (a.depth < b.depth) return false; |
1140 return a.topologicalIndex < b.topologicalIndex; | 1137 return a.topologicalIndex < b.topologicalIndex; |
1141 } | 1138 } |
1142 } | 1139 } |
OLD | NEW |