pub struct MbaExpr { /* private fields */ }Expand description
A DAG in the MBA fragment over declared variables. The last node is the root. Nodes refer only to earlier nodes, so evaluation and every traversal are single forward passes.
Implementations§
Source§impl MbaExpr
impl MbaExpr
Sourcepub fn new(vars: Vec<Width>) -> MbaExpr
pub fn new(vars: Vec<Width>) -> MbaExpr
An expression over variables of the given widths, with no nodes yet.
Sourcepub fn push(&mut self, op: MOp, args: &[u32]) -> Result<u32, MbaError>
pub fn push(&mut self, op: MOp, args: &[u32]) -> Result<u32, MbaError>
Adds a node whose width follows from its operands (every operator but the casts).
Sourcepub fn push_cast(
&mut self,
op: MOp,
a: u32,
width: Width,
) -> Result<u32, MbaError>
pub fn push_cast( &mut self, op: MOp, a: u32, width: Width, ) -> Result<u32, MbaError>
Adds a cast (Zext, Sext, Trunc) to width.
Sourcepub fn eval(&self, vals: &[BitVec]) -> Option<BitVec>
pub fn eval(&self, vals: &[BitVec]) -> Option<BitVec>
The root’s value for the given variable values (None on a width mismatch).
Sourcepub fn key(&self) -> [u64; 2]
pub fn key(&self) -> [u64; 2]
A 128-bit content hash (variables, nodes), stable across processes.
Sourcepub fn is_linear(&self) -> bool
pub fn is_linear(&self) -> bool
Whether this is a linear MBA: arithmetic over bitwise functions of the variables, with no multiplication of two non-constants, no shift or cast, and only 0 and all-ones constants inside bitwise parts. Such an expression is determined by its values at the corners where every variable is 0 or all-ones.