Index: src/types.cc |
diff --git a/src/types.cc b/src/types.cc |
index db638ed141d604e95ffe7ab9f9099aac0ba34a2d..327eba0679bc9cb9efa5444a839ef02b8b8082e3 100644 |
--- a/src/types.cc |
+++ b/src/types.cc |
@@ -262,7 +262,7 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) { |
if (this->IsBitset() && SEMANTIC(this->AsBitset()) == BitsetType::kNone) { |
// Bitsets only have non-bitset supertypes along the representation axis. |
int that_bitset = that->BitsetGlb(); |
- return (this->AsBitset() | that_bitset) == that_bitset; |
+ return (BitsetType::Is(this->AsBitset(), that_bitset)); |
} |
if (that->IsClass()) { |
@@ -313,16 +313,12 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) { |
// T <= (T1 \/ ... \/ Tn) <=> (T <= T1) \/ ... \/ (T <= Tn) |
// (iff T is not a union) |
- ASSERT(!this->IsUnion()); |
- if (that->IsUnion()) { |
- UnionHandle unioned = handle(that->AsUnion()); |
- for (int i = 0; i < unioned->Length(); ++i) { |
- if (this->Is(unioned->Get(i))) return true; |
- if (this->IsBitset()) break; // Fast fail, only first field is a bitset. |
- } |
- return false; |
+ ASSERT(!this->IsUnion() && that->IsUnion()); |
+ UnionHandle unioned = handle(that->AsUnion()); |
+ for (int i = 0; i < unioned->Length(); ++i) { |
+ if (this->Is(unioned->Get(i))) return true; |
+ if (this->IsBitset()) break; // Fast fail, only first field is a bitset. |
} |
- |
return false; |
} |
@@ -382,11 +378,8 @@ bool TypeImpl<Config>::Maybe(TypeImpl* that) { |
} |
ASSERT(!this->IsUnion() && !that->IsUnion()); |
- if (this->IsBitset()) { |
- return BitsetType::IsInhabited(this->AsBitset() & that->BitsetLub()); |
- } |
- if (that->IsBitset()) { |
- return BitsetType::IsInhabited(this->BitsetLub() & that->AsBitset()); |
+ if (this->IsBitset() || that->IsBitset()) { |
+ return BitsetType::IsInhabited(this->BitsetLub() & that->BitsetLub()); |
} |
if (this->IsClass()) { |
return that->IsClass() |
@@ -441,7 +434,7 @@ bool TypeImpl<Config>::UnionType::Wellformed() { |
// Union and intersection |
template<class Config> |
-typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Narrow( |
+typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Rebound( |
int bitset, Region* region) { |
TypeHandle bound = BitsetType::New(bitset, region); |
if (this->IsClass()) { |
@@ -555,7 +548,7 @@ int TypeImpl<Config>::ExtendUnion( |
new_bound |= type_i_bound; |
if (new_bound == type_i_bound) return size; |
} |
- if (new_bound != old_bound) type = type->Narrow(new_bound, region); |
+ if (new_bound != old_bound) type = type->Rebound(new_bound, region); |
result->Set(i, type); |
} |
} |
@@ -570,7 +563,7 @@ int TypeImpl<Config>::NormalizeUnion(UnionHandle result, int size, int bitset) { |
if (bitset != BitsetType::kNone && SEMANTIC(bitset) == BitsetType::kNone) { |
for (int i = 1; i < size; ++i) { |
int glb = result->Get(i)->BitsetGlb(); |
- if ((bitset | glb) == glb) { |
+ if (BitsetType::Is(bitset, glb)) { |
for (int j = 1; j < size; ++j) { |
result->Set(j - 1, result->Get(j)); |
} |