Index: src/types.h |
diff --git a/src/types.h b/src/types.h |
index 55c7e6c4692d8e19c89177a97128bd8ee222cd8b..669e02bd7ff3feac32ef3c2e99f49d837b1b3c13 100644 |
--- a/src/types.h |
+++ b/src/types.h |
@@ -349,6 +349,16 @@ class TypeImpl : public Config::Base { |
PROPER_BITSET_TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR) |
#undef DEFINE_TYPE_CONSTRUCTOR |
+#define DEFINE_TYPE_CONSTRUCTOR(type, value) \ |
+ static TypeImpl* Mask##type##ForTesting() { \ |
+ return BitsetType::New(BitsetType::k##type); \ |
+ } \ |
+ static TypeHandle Mask##type##ForTesting(Region* region) { \ |
+ return BitsetType::New(BitsetType::k##type, region); \ |
+ } |
+ MASK_BITSET_TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR) |
+#undef DEFINE_TYPE_CONSTRUCTOR |
+ |
static TypeImpl* SignedSmall() { |
return BitsetType::New(BitsetType::SignedSmall()); |
} |
@@ -563,12 +573,16 @@ class TypeImpl : public Config::Base { |
} |
UnionType* AsUnion() { return UnionType::cast(this); } |
+ bitset GetRepresentation(); |
rossberg
2015/02/11 12:34:11
Nit: drop the "Get"
Jarin
2015/02/11 16:10:47
Done.
|
+ |
// Auxiliary functions. |
+ bool SemanticMaybe(TypeImpl* that); |
bitset BitsetGlb() { return BitsetType::Glb(this); } |
bitset BitsetLub() { return BitsetType::Lub(this); } |
bool SlowIs(TypeImpl* that); |
+ bool SemanticIs(TypeImpl* that); |
static bool IsInteger(double x) { |
return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities. |
@@ -580,16 +594,9 @@ class TypeImpl : public Config::Base { |
struct Limits { |
double min; |
double max; |
- bitset representation; |
- Limits(double min, double max, bitset representation) |
- : min(min), max(max), representation(representation) {} |
- explicit Limits(RangeType* range) |
- : min(range->Min()), |
- max(range->Max()), |
- representation(REPRESENTATION(range->Bound())) {} |
- static Limits Empty(Region* region) { |
- return Limits(1, 0, BitsetType::kNone); |
- } |
+ Limits(double min, double max) : min(min), max(max) {} |
+ explicit Limits(RangeType* range) : min(range->Min()), max(range->Max()) {} |
+ static Limits Empty(Region* region) { return Limits(1, 0); } |
}; |
static bool IsEmpty(Limits lim); |
@@ -649,11 +656,13 @@ class TypeImpl<Config>::BitsetType : public TypeImpl<Config> { |
if (FLAG_enable_slow_asserts) CheckNumberBits(bits); |
return Config::from_bitset(bits, region); |
} |
- // TODO(neis): Eventually allow again for types with empty semantics |
- // part and modify intersection and possibly subtyping accordingly. |
static bool IsInhabited(bitset bits) { |
- return bits & kSemantic; |
+ return SEMANTIC(bits) != kNone && REPRESENTATION(bits) != kNone; |
+ } |
+ |
+ static bool SemanticIsInhabited(bitset bits) { |
+ return SEMANTIC(bits) != kNone; |
} |
static bool Is(bitset bits1, bitset bits2) { |
@@ -855,8 +864,8 @@ class TypeImpl<Config>::RangeType : public TypeImpl<Config> { |
return Config::template cast<RangeType>(Config::from_range(range)); |
} |
- static RangeHandle New(Limits lim, Region* region) { |
- return New(lim.min, lim.max, BitsetType::New(lim.representation, region), |
+ static RangeHandle New(Limits lim, bitset representation, Region* region) { |
+ return New(lim.min, lim.max, BitsetType::New(representation, region), |
region); |
} |
@@ -866,7 +875,6 @@ class TypeImpl<Config>::RangeType : public TypeImpl<Config> { |
} |
}; |
// TODO(neis): Also cache min and max values. |
-// TODO(neis): Allow restricting the representation. |
// ----------------------------------------------------------------------------- |