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

Unified Diff: sdk/lib/_internal/compiler/implementation/inferrer/inferrer_visitor.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/inferrer_visitor.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/inferrer/inferrer_visitor.dart (revision 30666)
+++ sdk/lib/_internal/compiler/implementation/inferrer/inferrer_visitor.dart (working copy)
@@ -10,6 +10,7 @@
import '../tree/tree.dart';
import '../universe/universe.dart';
import '../util/util.dart';
+import '../types/types.dart' show TypeMask;
/**
* The interface [InferrerVisitor] will use when working on types.
@@ -18,6 +19,8 @@
T get dynamicType;
T get nullType;
T get intType;
+ T get uint31Type;
+ T get uint32Type;
T get doubleType;
T get numType;
T get boolType;
@@ -85,6 +88,11 @@
* [receiverType].
*/
T refineReceiver(Selector selector, T receiverType);
+
+ /**
+ * Returns the internal inferrer representation for [mask].
+ */
+ T getConcreteTypeFor(TypeMask mask);
}
/**
@@ -248,8 +256,8 @@
bool hasNoArguments() => positional.isEmpty && named.isEmpty;
- bool hasOnePositionalArgumentWithType(T type) {
- return named.isEmpty && positional.length == 1 && positional[0] == type;
+ bool hasOnePositionalArgumentThatMatches(bool f(T type)) {
+ return named.isEmpty && positional.length == 1 && f(positional[0]);
}
void forEach(void f(T type)) {
@@ -652,22 +660,18 @@
T visitLiteralDouble(LiteralDouble node) {
ConstantSystem constantSystem = compiler.backend.constantSystem;
- Constant constant = constantSystem.createDouble(node.value);
// The JavaScript backend may turn this literal into an integer at
// runtime.
- return constantSystem.isDouble(constant)
- ? types.doubleType
- : types.intType;
+ return types.getConcreteTypeFor(
+ constantSystem.createDouble(node.value).computeMask(compiler));
}
T visitLiteralInt(LiteralInt node) {
ConstantSystem constantSystem = compiler.backend.constantSystem;
- Constant constant = constantSystem.createInt(node.value);
// The JavaScript backend may turn this literal into a double at
// runtime.
- return constantSystem.isDouble(constant)
- ? types.doubleType
- : types.intType;
+ return types.getConcreteTypeFor(
+ constantSystem.createInt(node.value).computeMask(compiler));
}
T visitLiteralList(LiteralList node) {

Powered by Google App Engine
This is Rietveld 408576698