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 | 4 |
5 /// Notation: | 5 /// Notation: |
6 /// | 6 /// |
7 /// * `[[T]]` is the runtime representation of type `T` (that is, `T` reified). | 7 /// * `[[T]]` is the runtime representation of type `T` (that is, `T` reified). |
8 library kernel.transformations.reify.runtime.types; | 8 library kernel.transformations.reify.runtime.types; |
9 | 9 |
10 import 'declarations.dart' show Class; | 10 import 'declarations.dart' show Class; |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 String toString() => "{ $typeA, $typeB }"; | 422 String toString() => "{ $typeA, $typeB }"; |
423 } | 423 } |
424 | 424 |
425 /// Represents a type variable aka type parameter. | 425 /// Represents a type variable aka type parameter. |
426 /// | 426 /// |
427 /// For example, this class: | 427 /// For example, this class: |
428 /// | 428 /// |
429 /// class Box<T> {} | 429 /// class Box<T> {} |
430 /// | 430 /// |
431 /// Defines one type variable. In the type `Box<int>`, there are no type | 431 /// Defines one type variable. In the type `Box<int>`, there are no type |
432 /// variables. However, `int` is a type argument to the the type | 432 /// variables. However, `int` is a type argument to the type |
433 /// parameter/variable `T`. | 433 /// parameter/variable `T`. |
434 class TypeVariable extends ReifiedType { | 434 class TypeVariable extends ReifiedType { |
435 final int _id; | 435 final int _id; |
436 | 436 |
437 // TODO(ahe): Do we need to reify bounds? | 437 // TODO(ahe): Do we need to reify bounds? |
438 ReifiedType bound; | 438 ReifiedType bound; |
439 | 439 |
440 TypeVariable(this._id) : super(Kind.Variable); | 440 TypeVariable(this._id) : super(Kind.Variable); |
441 | 441 |
442 bool _isMoreSpecificThan(ReifiedType type) { | 442 bool _isMoreSpecificThan(ReifiedType type) { |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 a._isMoreSpecificThan(b); | 669 a._isMoreSpecificThan(b); |
670 } | 670 } |
671 | 671 |
672 /// If [type] is a type variable, return its bound. Otherwise `null`. | 672 /// If [type] is a type variable, return its bound. Otherwise `null`. |
673 ReifiedType getBoundOrNull(ReifiedType type) { | 673 ReifiedType getBoundOrNull(ReifiedType type) { |
674 if (type == null) return null; | 674 if (type == null) return null; |
675 if (!type._isVariable) return null; | 675 if (!type._isVariable) return null; |
676 TypeVariable tv = type; | 676 TypeVariable tv = type; |
677 return tv.bound; | 677 return tv.bound; |
678 } | 678 } |
OLD | NEW |