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

Unified Diff: sdk/lib/_internal/compiler/implementation/inferrer/type_graph_nodes.dart

Issue 111423003: Add a new node in the inferrer to materialize literal maps. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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/inferrer/type_graph_nodes.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/inferrer/type_graph_nodes.dart (revision 30992)
+++ sdk/lib/_internal/compiler/implementation/inferrer/type_graph_nodes.dart (working copy)
@@ -816,10 +816,10 @@
}
/**
- * A [ContainerTypeInformation] is a [TypeInformation] created
+ * A [ListTypeInformation] is a [TypeInformation] created
* for each `List` instantiations.
*/
-class ContainerTypeInformation extends TypeInformation {
+class ListTypeInformation extends TypeInformation {
final ElementInContainerTypeInformation elementType;
/** The container type before it is inferred. */
@@ -832,7 +832,7 @@
int inferredLength;
/**
- * Whether this container goes through a growable check.
+ * Whether this list goes through a growable check.
* We conservatively assume it does.
*/
bool checksGrowable = true;
@@ -844,18 +844,18 @@
bool bailedOut = true;
bool analyzed = false;
- ContainerTypeInformation(this.originalContainerType,
- this.elementType,
- this.originalLength) {
+ ListTypeInformation(this.originalContainerType,
+ this.elementType,
+ this.originalLength) {
type = originalContainerType;
inferredLength = originalContainerType.length;
elementType.addUser(this);
}
- String toString() => 'Container type $type';
+ String toString() => 'List type $type';
accept(TypeInformationVisitor visitor) {
- return visitor.visitContainerTypeInformation(this);
+ return visitor.visitListTypeInformation(this);
}
bool hasStableType(TypeGraphInferrerEngine inferrer) {
@@ -879,7 +879,7 @@
/**
* An [ElementInContainerTypeInformation] holds the common type of the
- * elements in a [ContainerTypeInformation].
+ * elements in a [ListTypeInformation].
*/
class ElementInContainerTypeInformation extends TypeInformation {
/** Whether the element type in that container has been inferred. */
@@ -908,6 +908,32 @@
}
/**
+ * A [MapTypeInformation] is a [TypeInformation] created
+ * for maps.
+ */
+class MapTypeInformation extends TypeInformation {
+ final TypeInformation keyType;
+ final TypeInformation valueType;
+ final TypeMask initialType;
+
+ MapTypeInformation(this.keyType, this.valueType, this.initialType) {
+ keyType.addUser(this);
+ valueType.addUser(this);
+ type = initialType;
+ }
+
+ accept(TypeInformationVisitor visitor) {
+ return visitor.visitMapTypeInformation(this);
+ }
+
+ TypeMask refine(TypeGraphInferrerEngine inferrer) {
+ return initialType;
+ }
+
+ String toString() => 'Map $type';
+}
+
+/**
* A [PhiElementTypeInformation] is an union of
* [ElementTypeInformation], that is local to a method.
*/
@@ -934,7 +960,8 @@
T visitPhiElementTypeInformation(PhiElementTypeInformation info);
T visitElementInContainerTypeInformation(
ElementInContainerTypeInformation info);
- T visitContainerTypeInformation(ContainerTypeInformation info);
+ T visitListTypeInformation(ListTypeInformation info);
+ T visitMapTypeInformation(MapTypeInformation info);
T visitConcreteTypeInformation(ConcreteTypeInformation info);
T visitClosureCallSiteTypeInformation(ClosureCallSiteTypeInformation info);
T visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info);

Powered by Google App Engine
This is Rietveld 408576698