liblisa::instr

Struct InstructionFilter

pub struct InstructionFilter {
    pub data: ArrayVec<ByteFilter, 16>,
}
Expand description

A filter that can match groups of instructions.

Fields§

§data: ArrayVec<ByteFilter, 16>

The filters for each byte in the instruction.

Implementations§

§

impl InstructionFilter

pub fn new<I: IntoIterator<Item = ByteFilter>>(data: I) -> InstructionFilter

Creates a new InstructionFilter from the provided iterator. The iterator should not yield more than 15 elements.

pub fn parse(s: &str) -> InstructionFilter

Parses an instruction filter from a string.

pub fn intersect(&self, other: &InstructionFilter) -> InstructionFilter

Computes the intersection of the InstructionFilters.

pub fn matches(&self, instr: &Instruction) -> bool

Returns true if the filter matches instr.

pub fn matches_smaller_instr_partially(&self, instr: &Instruction) -> bool

Returns true if the filter matches all bytes in instr, even if not all instructions that start with instr are matched by this filter.

For example: the filter 03AB partially matches the instruction 03. However, it does not match all instructions starting with 03. For example, 0300.

pub fn len(&self) -> usize

Returns the byte length of the instructions matched by the InstructionFilter.

pub fn is_empty(&self) -> bool

Returns true if the InstructionFilter is empty.

pub fn bit_len(&self) -> usize

Returns the bitlength of the instructions matched by the InstructionFilter.

pub fn byte_len(&self) -> usize

Returns the byte length of the instructions matched by the InstructionFilter.

pub fn nth_bit_from_left(&self, index: usize) -> FilterBit

Returns the bit at position index, counting from the left.

pub fn nth_bit_from_right(&self, index: usize) -> FilterBit

Returns the bit at position index, counting from the right.

pub fn value_as_u128(&self) -> u128

Returns the values of the ByteFilters concatenated into an u128.

pub fn mask_as_u128(&self) -> u128

Returns the masks of the ByteFilters concatenated into an u128.

pub fn covers(&self, other: &InstructionFilter) -> bool

Returns true if the filter matches all instructions matched by other.

pub fn overlaps(&self, other: &InstructionFilter) -> bool

Returns true if there is at least one instruction which both filters match.

pub fn try_merge(&self, other: &InstructionFilter) -> Option<InstructionFilter>

Tries to merge the filters into a filter that matches all instructions matched by either self or other.

pub fn try_exclude( &self, other: &InstructionFilter, ) -> Option<InstructionFilter>

Tries to compute self - other.

pub fn smallest_matching_instruction(&self) -> Instruction

Returns the smallest matching instruction. In other words, the instruction with all wildcard bits set to 0.

pub fn largest_matching_instruction(&self) -> Instruction

Returns the largest matching instruction. In other words, the instruction with all wildcard bits set to 1.

pub fn next_matching_instruction( &self, instr: &Instruction, ) -> Option<Instruction>

When instr does not match the filter, returns the first instruction after instr that matches the filter. When instr does match the filter, returns instr.

pub fn num_wildcard_bits(&self) -> usize

Returns the number of wildcard bits in the InstructionFilter.

pub fn set_nth_bit_from_right(&mut self, index: usize, bit: FilterBit)

Sets the bit at position index, counting from the right, to bit.

pub fn set_nth_bit_from_left(&mut self, index: usize, bit: FilterBit)

Sets the bit at position index, counting from the left, to bit.

pub fn find_uncovered_instr( &self, covering_filters: Vec<InstructionFilter>, ) -> Option<Instruction>

Returns an crate::instr::Instruction that matches this filter, but none of the filters in covering_filters.

Trait Implementations§

§

impl Clone for InstructionFilter

§

fn clone(&self) -> Self

Returns a copy of the value. Read more
§

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

Performs copy-assignment from source. Read more
§

impl Debug for InstructionFilter

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for InstructionFilter

§

fn deserialize<D>(deserializer: D) -> Result<InstructionFilter, D::Error>
where D: Deserializer<'de>,

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

impl From<&Instruction> for InstructionFilter

§

fn from(instr: &Instruction) -> Self

Converts to this type from the input type.
§

impl From<&str> for InstructionFilter

§

fn from(s: &str) -> Self

Converts to this type from the input type.
§

impl From<Instruction> for InstructionFilter

§

fn from(instr: Instruction) -> Self

Converts to this type from the input type.
§

impl FromStr for InstructionFilter

§

type Err = FromHexError

The associated error which can be returned from parsing.
§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
§

impl Hash for InstructionFilter

§

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
§

impl Ord for InstructionFilter

§

fn cmp(&self, other: &InstructionFilter) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl PartialEq for InstructionFilter

§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

impl PartialOrd for InstructionFilter

§

fn partial_cmp(&self, other: &InstructionFilter) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl Serialize for InstructionFilter

§

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

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

impl Eq for InstructionFilter

§

impl StructuralPartialEq for InstructionFilter

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
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

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

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

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