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

Unified Diff: sdk/lib/_internal/compiler/implementation/types/container_type_mask.dart

Issue 17017003: Introduce an ElementTypeMask to recognize simple constraints like "the type of parameter foo is the… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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: sdk/lib/_internal/compiler/implementation/types/container_type_mask.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/types/container_type_mask.dart (revision 24183)
+++ sdk/lib/_internal/compiler/implementation/types/container_type_mask.dart (working copy)
@@ -15,11 +15,10 @@
/// A [ContainerTypeMask] is a [TypeMask] for a specific allocation
/// site of a container (currently only List) that will get specialized
/// once the [ListTracer] phase finds an element type for it.
-class ContainerTypeMask implements TypeMask {
-
+class ContainerTypeMask extends ForwardingTypeMask {
// The flat version of a [ContainerTypeMask] is the container type
// (for example List).
- final FlatTypeMask asFlat;
+ final FlatTypeMask forwardTo;
// The [Node] where this type mask was created.
final Node allocationNode;
@@ -36,7 +35,7 @@
holder.elementType = mask;
}
- ContainerTypeMask(this.asFlat,
+ ContainerTypeMask(this.forwardTo,
this.allocationNode,
this.allocationElement,
[holder])
@@ -45,7 +44,7 @@
TypeMask nullable() {
return isNullable
? this
- : new ContainerTypeMask(asFlat.nullable(),
+ : new ContainerTypeMask(forwardTo.nullable(),
allocationNode,
allocationElement,
holder);
@@ -53,79 +52,29 @@
TypeMask nonNullable() {
return isNullable
- ? new ContainerTypeMask(asFlat.nonNullable(),
+ ? new ContainerTypeMask(forwardTo.nonNullable(),
allocationNode,
allocationElement,
holder)
: this;
}
- TypeMask simplify(Compiler compiler) => this;
-
- bool get isEmpty => false;
- bool get isNullable => asFlat.isNullable;
- bool get isExact => true;
- bool get isUnion => false;
bool get isContainer => true;
+ bool get isExact => true;
- bool containsOnlyInt(Compiler compiler) => false;
- bool containsOnlyDouble(Compiler compiler) => false;
- bool containsOnlyNum(Compiler compiler) => false;
- bool containsOnlyNull(Compiler compiler) => false;
- bool containsOnlyBool(Compiler compiler) => false;
- bool containsOnlyString(Compiler compiler) => false;
- bool containsOnly(ClassElement element) {
- return asFlat.containsOnly(element);
+ bool equalsDisregardNull(other) {
+ if (other is! ContainerTypeMask) return false;
+ return allocationNode == other.allocationNode;
}
- bool satisfies(ClassElement cls, Compiler compiler) {
- return asFlat.satisfies(cls, compiler);
- }
-
- bool contains(DartType type, Compiler compiler) {
- return asFlat.contains(type, compiler);
- }
-
- bool containsAll(Compiler compiler) => false;
-
- ClassElement singleClass(Compiler compiler) {
- return asFlat.singleClass(compiler);
- }
-
- Iterable<ClassElement> containedClasses(Compiler compiler) {
- return asFlat.containedClasses(compiler);
- }
-
- TypeMask union(other, Compiler compiler) {
- if (other.isContainer
- && other.allocationNode == this.allocationNode) {
- return other.isNullable ? other : this;
- } else if (other.isEmpty) {
- return other.isNullable ? this.nullable() : this;
- }
- return asFlat.union(other, compiler);
- }
-
TypeMask intersection(TypeMask other, Compiler compiler) {
- TypeMask flatIntersection = asFlat.intersection(other, compiler);
- if (flatIntersection.isEmpty) return flatIntersection;
- return flatIntersection.isNullable
+ TypeMask forwardIntersection = forwardTo.intersection(other, compiler);
+ if (forwardIntersection.isEmpty) return forwardIntersection;
+ return forwardIntersection.isNullable
? nullable()
: nonNullable();
}
- bool willHit(Selector selector, Compiler compiler) {
- return asFlat.willHit(selector, compiler);
- }
-
- bool canHit(Element element, Selector selector, Compiler compiler) {
- return asFlat.canHit(element, selector, compiler);
- }
-
- Element locateSingleElement(Selector selector, Compiler compiler) {
- return asFlat.locateSingleElement(selector, compiler);
- }
-
bool operator==(other) {
if (other is! ContainerTypeMask) return false;
return allocationNode == other.allocationNode

Powered by Google App Engine
This is Rietveld 408576698