use super::bitset::BitsetDomain;
use super::traits::{Domain, LatticeDomain};
#[derive(Debug, Clone, PartialEq)]
pub struct BitsetLatticeDomain {
value: BitsetDomain,
}
impl BitsetLatticeDomain {
pub fn new(value: BitsetDomain) -> Self {
Self { value }
}
pub fn inner(&self) -> &BitsetDomain {
&self.value
}
}
impl Domain for BitsetLatticeDomain {
type Value = BitsetDomain;
fn size(&self) -> usize {
1
}
fn is_singleton(&self) -> bool {
true
}
fn singleton_value(&self) -> Option<BitsetDomain> {
Some(self.value.clone())
}
fn contains(&self, val: &BitsetDomain) -> bool {
self.value == *val
}
fn remove(&mut self, _val: &BitsetDomain) -> bool {
false
}
fn add(&mut self, _val: &BitsetDomain) {
}
fn values(&self) -> Vec<BitsetDomain> {
vec![self.value.clone()]
}
fn iter(&self) -> impl Iterator<Item = BitsetDomain> {
std::iter::once(self.value.clone())
}
}
impl LatticeDomain for BitsetLatticeDomain {
fn bottom() -> Self {
Self {
value: BitsetDomain::empty(),
}
}
fn join(&mut self, other: &Self) -> bool {
let old = self.value.bits();
self.value.union_with(&other.value);
self.value.bits() != old
}
}