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

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

Issue 12753003: Recognize const/fixed/growable arrays in simple types inferrer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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/simple_types_inferrer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart (revision 19761)
+++ sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart (working copy)
@@ -166,6 +166,9 @@
TypeMask boolType;
TypeMask functionType;
TypeMask listType;
+ TypeMask constListType;
+ TypeMask fixedListType;
+ TypeMask growableListType;
TypeMask mapType;
TypeMask constMapType;
TypeMask stringType;
@@ -346,8 +349,15 @@
rawTypeOf(backend.stringImplementation));
boolType = new TypeMask.nonNullExact(
rawTypeOf(backend.boolImplementation));
+
listType = new TypeMask.nonNullExact(
rawTypeOf(backend.listImplementation));
+ constListType = new TypeMask.nonNullExact(
+ rawTypeOf(backend.constListImplementation));
+ fixedListType = new TypeMask.nonNullExact(
+ rawTypeOf(backend.fixedListImplementation));
+ growableListType = new TypeMask.nonNullExact(
+ rawTypeOf(backend.growableListImplementation));
mapType = new TypeMask.nonNullSubtype(
rawTypeOf(backend.mapImplementation));
@@ -969,7 +979,11 @@
}
TypeMask visitLiteralList(LiteralList node) {
- return inferrer.listType;
+ if (node.isConst()) {
kasperl 2013/03/11 08:40:57 Use ? :
ngeoffray 2013/03/11 08:59:57 Done.
+ return inferrer.constListType;
+ } else {
+ return inferrer.growableListType;
+ }
}
TypeMask visitLiteralMap(LiteralMap node) {
@@ -1139,7 +1153,13 @@
}
ArgumentsTypes arguments = analyzeArguments(node.arguments);
inferrer.registerCalledElement(outermostElement, element, arguments);
- return inferrer.returnTypeOfElement(element);
+ if (Elements.isGrowableListConstructorCall(element, node, compiler)) {
+ return inferrer.growableListType;
+ } else if (Elements.isFixedListConstructorCall(element, node, compiler)) {
+ return inferrer.fixedListType;
+ } else {
+ return inferrer.returnTypeOfElement(element);
+ }
}
TypeMask handleForeignSend(Send node) {

Powered by Google App Engine
This is Rietveld 408576698