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

Unified Diff: lib/compiler/implementation/ssa/types.dart

Issue 11024003: Add a fixed array type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « lib/compiler/implementation/ssa/optimize.dart ('k') | tests/compiler/dart2js/type_combination_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/types.dart
===================================================================
--- lib/compiler/implementation/ssa/types.dart (revision 13038)
+++ lib/compiler/implementation/ssa/types.dart (working copy)
@@ -52,6 +52,7 @@
static const HType STRING = const HStringType();
static const HType READABLE_ARRAY = const HReadableArrayType();
static const HType MUTABLE_ARRAY = const HMutableArrayType();
+ static const HType FIXED_ARRAY = const HFixedArrayType();
static const HType EXTENDABLE_ARRAY = const HExtendableArrayType();
static const HType NULL = const HNullType();
@@ -75,6 +76,7 @@
bool isDoubleOrNull() => false;
bool isStringOrNull() => false;
bool isIndexablePrimitive() => false;
+ bool isFixedArray() => false;
bool isReadableArray() => false;
bool isMutableArray() => false;
bool isExtendableArray() => false;
@@ -609,6 +611,34 @@
}
}
+class HFixedArrayType extends HMutableArrayType {
+ const HFixedArrayType();
Søren Gjesse 2012/10/01 06:47:31 Would it make sense to add the length (if known) t
ngeoffray 2012/10/01 21:54:39 Yes, I was planning on doing that as the next step
+ bool isFixedArray() => true;
+ String toString() => "fixed array";
+
+ HType union(HType other) {
+ if (other.isConflicting()) return HType.FIXED_ARRAY;
+ if (other.isUnknown()) return HType.UNKNOWN;
+ if (other.isFixedArray()) return HType.FIXED_ARRAY;
+ if (other.isMutableArray()) return HType.MUTABLE_ARRAY;
+ if (other.isReadableArray()) return HType.READABLE_ARRAY;
+ if (other.isIndexablePrimitive()) return HType.INDEXABLE_PRIMITIVE;
+ if (other is HBoundedPotentialPrimitiveArray) return other;
+ return HType.UNKNOWN;
+ }
+
+ HType intersection(HType other) {
+ if (other.isConflicting()) return HType.CONFLICTING;
+ if (other.isUnknown()) return HType.FIXED_ARRAY;
+ if (other.isFixedArray()) return HType.FIXED_ARRAY;
+ if (other.isExtendableArray()) return HType.CONFLICTING;
+ if (other.isString()) return HType.CONFLICTING;
+ if (other.isIndexablePrimitive()) return HType.FIXED_ARRAY;
+ if (other is HBoundedPotentialPrimitiveArray) return HType.FIXED_ARRAY;
+ return HType.CONFLICTING;
+ }
+}
+
class HExtendableArrayType extends HMutableArrayType {
const HExtendableArrayType();
bool isExtendableArray() => true;
@@ -630,6 +660,7 @@
if (other.isUnknown()) return HType.EXTENDABLE_ARRAY;
if (other.isExtendableArray()) return HType.EXTENDABLE_ARRAY;
if (other.isString()) return HType.CONFLICTING;
+ if (other.isFixedArray()) return HType.CONFLICTING;
if (other.isIndexablePrimitive()) return HType.EXTENDABLE_ARRAY;
if (other is HBoundedPotentialPrimitiveArray) return HType.EXTENDABLE_ARRAY;
return HType.CONFLICTING;
« no previous file with comments | « lib/compiler/implementation/ssa/optimize.dart ('k') | tests/compiler/dart2js/type_combination_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698