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

Unified Diff: sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.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/simple_types_inferrer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart (revision 30992)
+++ sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart (working copy)
@@ -99,13 +99,17 @@
=> new TypeMask.nonNullExact(type.declaration);
TypeMask nonNullEmpty() => new TypeMask.nonNullEmpty();
- TypeMask allocateContainer(TypeMask type,
- Node node,
- Element enclosing,
- [TypeMask elementType, int length]) {
+ TypeMask allocateList(TypeMask type,
+ Node node,
+ Element enclosing,
+ [TypeMask elementType, int length]) {
return new ContainerTypeMask(type, node, enclosing, elementType, length);
}
+ TypeMask allocateMap(TypeMask keys, TypeMask values, TypeMask type) {
+ return type;
+ }
+
Selector newTypedSelector(TypeMask receiver, Selector selector) {
return new TypedSelector(receiver, selector);
}
@@ -595,7 +599,7 @@
T containerType = node.isConst()
? types.constListType
: types.growableListType;
- return types.allocateContainer(
+ return types.allocateList(
containerType,
node,
outermostElement,
@@ -604,6 +608,30 @@
});
}
+ T visitLiteralMap(LiteralMap node) {
+ NodeList entries = node.entries;
+ T keyType;
+ T valueType;
+ if (entries.isEmpty) {
+ keyType = types.nonNullEmpty();
+ valueType = types.nonNullEmpty();
+ } else {
+ for (LiteralMapEntry entry in entries) {
+ T key = visit(entry.key);
+ keyType = keyType == null
+ ? types.allocatePhi(null, null, key)
+ : types.addPhiInput(null, keyType, key);
+
+ T value = visit(entry.value);
+ valueType = valueType == null
+ ? types.allocatePhi(null, null, value)
+ : types.addPhiInput(null, valueType, value);
+ }
+ }
+ T type = node.isConst() ? types.constMapType : types.mapType;
+ return types.allocateMap(keyType, valueType, type);
+ }
+
bool isThisOrSuper(Node node) => node.isThis() || node.isSuper();
bool isInClassOrSubclass(Element element) {
@@ -909,7 +937,7 @@
T returnType = handleStaticSend(node, selector, element, arguments);
if (Elements.isGrowableListConstructorCall(element, node, compiler)) {
return inferrer.concreteTypes.putIfAbsent(
- node, () => types.allocateContainer(
+ node, () => types.allocateList(
types.growableListType, node, outermostElement,
types.nonNullEmpty(), 0));
} else if (Elements.isFixedListConstructorCall(element, node, compiler)
@@ -922,7 +950,7 @@
: arguments.positional[1];
return inferrer.concreteTypes.putIfAbsent(
- node, () => types.allocateContainer(
+ node, () => types.allocateList(
types.fixedListType, node, outermostElement,
elementType, length));
} else if (Elements.isConstructorOfTypedArraySubclass(element, compiler)) {
@@ -930,7 +958,7 @@
T elementType = inferrer.returnTypeOfElement(
element.getEnclosingClass().lookupMember('[]'));
return inferrer.concreteTypes.putIfAbsent(
- node, () => types.allocateContainer(
+ node, () => types.allocateList(
types.nonNullExact(element.getEnclosingClass()), node,
outermostElement, elementType, length));
} else if (element.isFunction() || element.isConstructor()) {

Powered by Google App Engine
This is Rietveld 408576698