| Index: pkg/compiler/lib/src/ordered_typeset.dart
|
| diff --git a/pkg/compiler/lib/src/ordered_typeset.dart b/pkg/compiler/lib/src/ordered_typeset.dart
|
| index 3c249adcd66d477a85ea9ef48dc87b010f524e41..4798c43d3faff61f308f9f438c4de4031385ce26 100644
|
| --- a/pkg/compiler/lib/src/ordered_typeset.dart
|
| +++ b/pkg/compiler/lib/src/ordered_typeset.dart
|
| @@ -29,30 +29,35 @@ import 'util/util_implementation.dart' show LinkEntry;
|
| * C: [C, B, A, Object]
|
| */
|
| class OrderedTypeSet {
|
| - final List<Link<DartType>> _levels;
|
| - final Link<DartType> types;
|
| - final Link<DartType> _supertypes;
|
| + final List<Link<ResolutionDartType>> _levels;
|
| + final Link<ResolutionDartType> types;
|
| + final Link<ResolutionDartType> _supertypes;
|
|
|
| - OrderedTypeSet.internal(List<Link<DartType>> this._levels,
|
| - Link<DartType> this.types, Link<DartType> this._supertypes);
|
| + OrderedTypeSet.internal(
|
| + List<Link<ResolutionDartType>> this._levels,
|
| + Link<ResolutionDartType> this.types,
|
| + Link<ResolutionDartType> this._supertypes);
|
|
|
| - factory OrderedTypeSet.singleton(DartType type) {
|
| - Link<DartType> types =
|
| - new LinkEntry<DartType>(type, const Link<DartType>());
|
| - List<Link<DartType>> list = new List<Link<DartType>>(1);
|
| + factory OrderedTypeSet.singleton(ResolutionDartType type) {
|
| + Link<ResolutionDartType> types = new LinkEntry<ResolutionDartType>(
|
| + type, const Link<ResolutionDartType>());
|
| + List<Link<ResolutionDartType>> list = new List<Link<ResolutionDartType>>(1);
|
| list[0] = types;
|
| - return new OrderedTypeSet.internal(list, types, const Link<DartType>());
|
| + return new OrderedTypeSet.internal(
|
| + list, types, const Link<ResolutionDartType>());
|
| }
|
|
|
| /// Creates a new [OrderedTypeSet] for [type] when it directly extends the
|
| /// class which this set represents. This is for instance used to create the
|
| /// type set for [ClosureClassElement] which extends [Closure].
|
| - OrderedTypeSet extendClass(InterfaceType type) {
|
| + OrderedTypeSet extendClass(ResolutionInterfaceType type) {
|
| assert(invariant(type.element, types.head.treatAsRaw,
|
| message: 'Cannot extend generic class ${types.head} using '
|
| 'OrderedTypeSet.extendClass'));
|
| - Link<DartType> extendedTypes = new LinkEntry<DartType>(type, types);
|
| - List<Link<DartType>> list = new List<Link<DartType>>(levels + 1);
|
| + Link<ResolutionDartType> extendedTypes =
|
| + new LinkEntry<ResolutionDartType>(type, types);
|
| + List<Link<ResolutionDartType>> list =
|
| + new List<Link<ResolutionDartType>>(levels + 1);
|
| for (int i = 0; i < levels; i++) {
|
| list[i] = _levels[i];
|
| }
|
| @@ -61,24 +66,24 @@ class OrderedTypeSet {
|
| list, extendedTypes, _supertypes.prepend(types.head));
|
| }
|
|
|
| - Link<DartType> get supertypes => _supertypes;
|
| + Link<ResolutionDartType> get supertypes => _supertypes;
|
|
|
| int get levels => _levels.length;
|
|
|
| int get maxDepth => levels - 1;
|
|
|
| - Link<DartType> operator [](int index) {
|
| + Link<ResolutionDartType> operator [](int index) {
|
| if (index < levels) {
|
| return _levels[index];
|
| }
|
| - return const Link<DartType>();
|
| + return const Link<ResolutionDartType>();
|
| }
|
|
|
| /// Returns the offsets into [types] at which each level begins.
|
| List<int> get levelOffsets {
|
| List<int> offsets = new List.filled(levels, -1);
|
| int offset = 0;
|
| - Link<DartType> pointer = types;
|
| + Link<ResolutionDartType> pointer = types;
|
| for (int depth = maxDepth; depth >= 0; depth--) {
|
| while (!identical(pointer, _levels[depth])) {
|
| pointer = pointer.tail;
|
| @@ -89,11 +94,11 @@ class OrderedTypeSet {
|
| return offsets;
|
| }
|
|
|
| - void forEach(int level, void f(DartType type)) {
|
| + void forEach(int level, void f(ResolutionDartType type)) {
|
| if (level < levels) {
|
| - Link<DartType> pointer = _levels[level];
|
| - Link<DartType> end =
|
| - level > 0 ? _levels[level - 1] : const Link<DartType>();
|
| + Link<ResolutionDartType> pointer = _levels[level];
|
| + Link<ResolutionDartType> end =
|
| + level > 0 ? _levels[level - 1] : const Link<ResolutionDartType>();
|
| // TODO(het): checking `isNotEmpty` should be unnecessary, remove when
|
| // constants are properly canonicalized
|
| while (pointer.isNotEmpty && !identical(pointer, end)) {
|
| @@ -103,12 +108,12 @@ class OrderedTypeSet {
|
| }
|
| }
|
|
|
| - InterfaceType asInstanceOf(ClassElement cls) {
|
| + ResolutionInterfaceType asInstanceOf(ClassElement cls) {
|
| int level = cls.hierarchyDepth;
|
| if (level < levels) {
|
| - Link<DartType> pointer = _levels[level];
|
| - Link<DartType> end =
|
| - level > 0 ? _levels[level - 1] : const Link<DartType>();
|
| + Link<ResolutionDartType> pointer = _levels[level];
|
| + Link<ResolutionDartType> end =
|
| + level > 0 ? _levels[level - 1] : const Link<ResolutionDartType>();
|
| // TODO(het): checking `isNotEmpty` should be unnecessary, remove when
|
| // constants are properly canonicalized
|
| while (pointer.isNotEmpty && !identical(pointer, end)) {
|
| @@ -142,23 +147,26 @@ class OrderedTypeSet {
|
| * C: [C, B, A, Object]
|
| */
|
| class OrderedTypeSetBuilder {
|
| - Map<int, LinkEntry<DartType>> map = new Map<int, LinkEntry<DartType>>();
|
| + Map<int, LinkEntry<ResolutionDartType>> map =
|
| + new Map<int, LinkEntry<ResolutionDartType>>();
|
| // TODO(15296): Avoid computing this order on the side when member
|
| // lookup handles multiply inherited members correctly.
|
| - LinkBuilder<DartType> allSupertypes = new LinkBuilder<DartType>();
|
| + LinkBuilder<ResolutionDartType> allSupertypes =
|
| + new LinkBuilder<ResolutionDartType>();
|
| int maxDepth = -1;
|
|
|
| final DiagnosticReporter reporter;
|
| final ClassElement cls;
|
| - InterfaceType _objectType;
|
| + ResolutionInterfaceType _objectType;
|
|
|
| // TODO(johnniwinther): Provide access to `Object` in deserialization and
|
| // make [objectType] mandatory.
|
| - OrderedTypeSetBuilder(this.cls, {this.reporter, InterfaceType objectType})
|
| + OrderedTypeSetBuilder(this.cls,
|
| + {this.reporter, ResolutionInterfaceType objectType})
|
| : this._objectType = objectType;
|
|
|
| OrderedTypeSet createOrderedTypeSet(
|
| - InterfaceType supertype, Link<DartType> interfaces) {
|
| + ResolutionInterfaceType supertype, Link<ResolutionDartType> interfaces) {
|
| if (_objectType == null) {
|
| // Find `Object` through in hierarchy. This is used for serialization
|
| // where it is assumed that the hierarchy is valid.
|
| @@ -171,12 +179,16 @@ class OrderedTypeSetBuilder {
|
| // TODO(15296): Collapse these iterations to one when the order is not
|
| // needed.
|
| add(supertype);
|
| - for (Link<DartType> link = interfaces; !link.isEmpty; link = link.tail) {
|
| + for (Link<ResolutionDartType> link = interfaces;
|
| + !link.isEmpty;
|
| + link = link.tail) {
|
| add(link.head);
|
| }
|
|
|
| addAllSupertypes(supertype);
|
| - for (Link<DartType> link = interfaces; !link.isEmpty; link = link.tail) {
|
| + for (Link<ResolutionDartType> link = interfaces;
|
| + !link.isEmpty;
|
| + link = link.tail) {
|
| addAllSupertypes(link.head);
|
| }
|
| add(cls.thisType);
|
| @@ -187,20 +199,20 @@ class OrderedTypeSetBuilder {
|
| * Adds [type] and all supertypes of [type] to [allSupertypes] while
|
| * substituting type variables.
|
| */
|
| - void addAllSupertypes(InterfaceType type) {
|
| + void addAllSupertypes(ResolutionInterfaceType type) {
|
| ClassElement classElement = type.element;
|
| - Link<DartType> supertypes = classElement.allSupertypes;
|
| + Link<ResolutionDartType> supertypes = classElement.allSupertypes;
|
| assert(invariant(cls, supertypes != null,
|
| message: "Supertypes not computed on $classElement "
|
| "during resolution of $cls"));
|
| while (!supertypes.isEmpty) {
|
| - DartType supertype = supertypes.head;
|
| + ResolutionDartType supertype = supertypes.head;
|
| add(supertype.substByContext(type));
|
| supertypes = supertypes.tail;
|
| }
|
| }
|
|
|
| - void add(InterfaceType type) {
|
| + void add(ResolutionInterfaceType type) {
|
| if (type.element == cls) {
|
| if (type != _objectType) {
|
| allSupertypes.addLast(_objectType);
|
| @@ -214,11 +226,11 @@ class OrderedTypeSetBuilder {
|
| }
|
| }
|
|
|
| - void _addAtDepth(InterfaceType type, int depth) {
|
| - LinkEntry<DartType> prev = null;
|
| - LinkEntry<DartType> link = map[depth];
|
| + void _addAtDepth(ResolutionInterfaceType type, int depth) {
|
| + LinkEntry<ResolutionDartType> prev = null;
|
| + LinkEntry<ResolutionDartType> link = map[depth];
|
| while (link != null) {
|
| - DartType existingType = link.head;
|
| + ResolutionDartType existingType = link.head;
|
| if (existingType == type) return;
|
| if (existingType.element == type.element) {
|
| if (reporter != null) {
|
| @@ -236,7 +248,8 @@ class OrderedTypeSetBuilder {
|
| prev = link;
|
| link = link.tail;
|
| }
|
| - LinkEntry<DartType> next = new LinkEntry<DartType>(type);
|
| + LinkEntry<ResolutionDartType> next =
|
| + new LinkEntry<ResolutionDartType>(type);
|
| next.tail = null;
|
| if (prev == null) {
|
| map[depth] = next;
|
| @@ -249,19 +262,20 @@ class OrderedTypeSetBuilder {
|
| }
|
|
|
| OrderedTypeSet toTypeSet() {
|
| - List<Link<DartType>> levels = new List<Link<DartType>>(maxDepth + 1);
|
| + List<Link<ResolutionDartType>> levels =
|
| + new List<Link<ResolutionDartType>>(maxDepth + 1);
|
| if (maxDepth < 0) {
|
| - return new OrderedTypeSet.internal(
|
| - levels, const Link<DartType>(), const Link<DartType>());
|
| + return new OrderedTypeSet.internal(levels,
|
| + const Link<ResolutionDartType>(), const Link<ResolutionDartType>());
|
| }
|
| - Link<DartType> next = const Link<DartType>();
|
| + Link<ResolutionDartType> next = const Link<ResolutionDartType>();
|
| for (int depth = 0; depth <= maxDepth; depth++) {
|
| - LinkEntry<DartType> first = map[depth];
|
| + LinkEntry<ResolutionDartType> first = map[depth];
|
| if (first == null) {
|
| levels[depth] = next;
|
| } else {
|
| levels[depth] = first;
|
| - LinkEntry<DartType> last = first;
|
| + LinkEntry<ResolutionDartType> last = first;
|
| while (last.tail != null) {
|
| last = last.tail;
|
| }
|
| @@ -277,7 +291,7 @@ class OrderedTypeSetBuilder {
|
| StringBuffer sb = new StringBuffer();
|
| for (int depth = 0; depth <= maxDepth; depth++) {
|
| sb.write('$depth: ');
|
| - LinkEntry<DartType> first = map[depth];
|
| + LinkEntry<ResolutionDartType> first = map[depth];
|
| if (first != null) {
|
| sb.write('${first.head}');
|
| while (first.tail != null) {
|
|
|