pub struct Interval {
    pub start: Bitvector,
    pub end: Bitvector,
    pub stride: u64,
}
Expand description

A strided interval of values with a fixed byte size.

The interval bounds are interpreted as signed integers, i.e. self.start is not allowed to be greater than self.end as signed integers.

The values represented by the interval are start, start + stride, start + 2*stride, ... , end. The following invariants have to hold for a correct interval instance:

  • end - start % stride == 0
  • if start == end, then the stride should always be set to zero.

Fields§

§start: Bitvector

The start of the interval. The bound is included in the represented interval.

§end: Bitvector

The end of the interval. The bound is included in the represented interval.

§stride: u64

The stride.

Implementations§

source§

impl Interval

source

pub fn new(start: Bitvector, end: Bitvector, stride: u64) -> Interval

Construct a new interval.

Both start and end of the interval are inclusive, i.e. contained in the represented interval.

The function automatically rounds down end (if necessary) so that it is contained in the same residue class as the start value modulo the stride. If the stride is 0 then end will be set to start.

source

pub fn new_top(bytesize: ByteSize) -> Interval

Construct a new unconstrained interval.

source

pub fn is_top(&self) -> bool

Returns true if all values representable by bitvectors of the corresponding length are contained in the interval.

source

pub fn bytesize(&self) -> ByteSize

Get the size in bytes of values contained in the interval.

source

pub fn signed_merge(&self, other: &Interval) -> Interval

Merge two intervals interpreting both as intervals of signed integers.

source

pub fn signed_intersect(&self, other: &Interval) -> Result<Interval, Error>

Compute the intersection of two intervals as intervals of signed integers. Return an error if the intersection is empty.

source

pub fn adjust_end_to_value_in_stride(&mut self)

Round down self.end to the nearest value such that self.end - self.start is again divisible by the stride. If afterwards self.start == self.end holds then set the stride to 0.

source

pub fn adjust_start_to_value_in_stride(&mut self)

Round up self.start to the nearest value such that self.end - self.start is again divisible by the stride. If afterwards self.start == self.end holds then set the stride to 0.

source

pub fn adjust_to_stride_and_remainder( self, stride: u64, remainder: u64 ) -> Result<Self, Error>

Change the given interval such that it only contains values with the given remainder modulo the given stride. This may round up the start of the interval and may round down the end of the interval. If the resulting interval is empty then an error is returned. This function ignores and replaces the previous stride of the interval.

For intervals with bytesize greater than 8 this function just returns the unmodified interval.

source

pub fn zero_extend(self, width: ByteSize) -> Interval

Compute the interval represented if the byte size of the value is zero-extended.

source

pub fn subpiece_higher(self, low_byte: ByteSize) -> Self

Truncate the bitvectors in the interval by removing the least significant bytes lower than the low_byte from them.

source

pub fn subpiece_lower(self, size: ByteSize) -> Self

Truncate the bitvectors in the interval to size, i.e. the most significant bytes (higher than size) are removed from all values.

source

pub fn subpiece(self, low_byte: ByteSize, size: ByteSize) -> Self

Take a subpiece of the bitvectors.

source

pub fn piece(&self, other: &Interval) -> Self

Piece two intervals together, where self contains the most signifcant bytes and other contains the least significant bytes of the resulting values.

source

pub fn int_2_comp(self) -> Self

Take the 2’s complement of values in the interval.

source

pub fn bitwise_not(self) -> Self

Compute the bitwise negation of values in the interval. Only exact if there is exactly one value in the interval.

source

pub fn add(&self, rhs: &Interval) -> Interval

Compute the interval of possible results if one adds a value from self to a value from rhs.

source

pub fn sub(&self, rhs: &Interval) -> Interval

Compute the interval of possible results if one subtracts a value in rhs from a value in self.

source

pub fn signed_mul(&self, rhs: &Interval) -> Interval

Compute the interval of possible results if one multiplies a value in self with a value in rhs.

source

pub fn contains(&self, bitvec: &Bitvector) -> bool

Return true if bitvec is contained in the strided interval. Panics if the interval and bitvec have different bytesizes.

Trait Implementations§

source§

impl Clone for Interval

source§

fn clone(&self) -> Interval

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Interval

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Interval

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<ApInt> for Interval

source§

fn from(bitvec: Bitvector) -> Self

Create an interval that only contains the given bitvector.

source§

impl From<Interval> for IntervalDomain

source§

fn from(interval: Interval) -> IntervalDomain

Generate an interval domain without widening hints.

source§

impl Hash for Interval

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Interval

source§

fn eq(&self, other: &Interval) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Interval

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Interval

source§

impl StructuralEq for Interval

source§

impl StructuralPartialEq for Interval

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,