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

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

Issue 87783003: Add UInt32 and UInt31 types to better infer bit operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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_inferrer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart (revision 30666)
+++ sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart (working copy)
@@ -78,6 +78,18 @@
return intTypeCache = getConcreteTypeFor(compiler.typesTask.intType);
}
+ TypeInformation uint32TypeCache;
+ TypeInformation get uint32Type {
+ if (uint32TypeCache != null) return uint32TypeCache;
+ return uint32TypeCache = getConcreteTypeFor(compiler.typesTask.uint32Type);
+ }
+
+ TypeInformation uint31TypeCache;
+ TypeInformation get uint31Type {
+ if (uint31TypeCache != null) return uint31TypeCache;
+ return uint31TypeCache = getConcreteTypeFor(compiler.typesTask.uint31Type);
+ }
+
TypeInformation doubleTypeCache;
TypeInformation get doubleType {
if (doubleTypeCache != null) return doubleTypeCache;
@@ -225,6 +237,7 @@
}
ConcreteTypeInformation getConcreteTypeFor(TypeMask mask) {
+ assert(mask != null);
return concreteTypes.putIfAbsent(mask, () {
return new ConcreteTypeInformation(mask);
});
@@ -491,6 +504,15 @@
// If [element] is final and has an initializer, we record
// the inferred type.
if (node.asSendSet() != null) {
+ if (type is! ContainerTypeInformation) {
+ // For non-container types, the constant handler does
+ // constant folding that could give more precise results.
+ var value =
kasperl 2013/11/26 14:58:40 What's the type of this?
ngeoffray 2013/11/26 15:19:12 Constant. I need to add a 'show' to type it. Done.
+ compiler.constantHandler.getConstantForVariable(element);
+ if (value != null) {
+ type = types.getConcreteTypeFor(value.computeMask(compiler));
+ }
+ }
recordType(element, type);
} else if (!element.isInstanceMember()) {
recordType(element, types.nullType);

Powered by Google App Engine
This is Rietveld 408576698