pub mod builder;
mod convert;
mod dominance;
mod form;
mod variable;
pub use builder::{build_ssa_from_cfg, SsaBuilder};
pub use convert::{expr_to_ssa, stmt_to_ssa};
pub use dominance::{compute, DominanceInfo};
pub use form::{SsaBlock, SsaExpr, SsaForm, SsaStats, SsaStmt, UseSite};
pub use variable::{PhiNode, SsaVariable};
use crate::decompiler::cfg::Cfg;
pub trait SsaConversion {
fn to_ssa(&self) -> SsaForm;
fn compute_dominance(&self) -> DominanceInfo;
}
impl SsaConversion for Cfg {
fn to_ssa(&self) -> SsaForm {
build_ssa_from_cfg(self)
}
fn compute_dominance(&self) -> DominanceInfo {
compute(self)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_ssa_conversion_trait() {
let cfg = Cfg::new();
let ssa = cfg.to_ssa();
assert_eq!(ssa.block_count(), 0);
}
#[test]
fn test_compute_dominance_via_trait() {
let cfg = Cfg::new();
let dominance = cfg.compute_dominance();
assert!(dominance.idom.is_empty());
}
}