pub mod state;
use crate::analysis::cpa::residue::EmptyResidue;
use crate::analysis::cpa::{ConfigurableProgramAnalysis, IntoState};
use crate::analysis::location::bound::state::BoundedBranchState;
use crate::modeling::machine::cpu::concrete::ConcretePcodeAddress;
pub struct BoundedBranchAnalysis {
max_instructions: Option<usize>,
max_branches: Option<usize>,
max_ops: Option<usize>,
}
impl BoundedBranchAnalysis {
pub fn new(max_branches: usize) -> Self {
Self {
max_instructions: None,
max_branches: Some(max_branches),
max_ops: None,
}
}
pub fn new_instruction_bound(max_instructions: usize) -> Self {
Self {
max_instructions: Some(max_instructions),
max_branches: None,
max_ops: None,
}
}
pub fn with_bounds(
max_instructions: Option<usize>,
max_branches: Option<usize>,
max_ops: Option<usize>,
) -> Self {
Self {
max_instructions,
max_branches,
max_ops,
}
}
pub fn max_branches(&self) -> Option<usize> {
self.max_branches
}
pub fn max_instructions(&self) -> Option<usize> {
self.max_instructions
}
pub fn max_ops(&self) -> Option<usize> {
self.max_ops
}
}
impl ConfigurableProgramAnalysis for BoundedBranchAnalysis {
type State = BoundedBranchState;
type Reducer<'op> = EmptyResidue<Self::State>;
}
impl IntoState<BoundedBranchAnalysis> for ConcretePcodeAddress {
fn into_state(self, c: &BoundedBranchAnalysis) -> BoundedBranchState {
BoundedBranchState::with_all_bounds(c.max_instructions, c.max_branches, c.max_ops)
}
}