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;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum FallthroughCounting {
Ignore,
Count,
}
pub struct BoundedBranchAnalysis {
max_steps: usize,
fallthrough_counting: FallthroughCounting,
}
impl BoundedBranchAnalysis {
pub fn new(max_steps: usize) -> Self {
Self {
max_steps,
fallthrough_counting: FallthroughCounting::Ignore,
}
}
pub fn with_fallthrough_counting(max_steps: usize, mode: FallthroughCounting) -> Self {
Self {
max_steps,
fallthrough_counting: mode,
}
}
pub fn new_counting_all(max_steps: usize) -> Self {
Self::with_fallthrough_counting(max_steps, FallthroughCounting::Count)
}
pub fn fallthrough_counting(&self) -> FallthroughCounting {
self.fallthrough_counting
}
pub fn max_steps(&self) -> usize {
self.max_steps
}
}
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::new(c.max_steps, c.fallthrough_counting)
}
}