use std::fmt;
use super::expr::SsaExpr;
use crate::decompiler::cfg::ssa::variable::{PhiNode, SsaVariable};
use crate::decompiler::ir::Stmt;
#[derive(Debug, Clone, PartialEq)]
pub enum SsaStmt {
Assign {
target: SsaVariable,
value: SsaExpr,
},
Phi(PhiNode),
Other(Stmt),
}
impl SsaStmt {
#[must_use]
pub fn assign(target: SsaVariable, value: SsaExpr) -> Self {
Self::Assign { target, value }
}
#[must_use]
pub const fn phi(phi: PhiNode) -> Self {
Self::Phi(phi)
}
#[must_use]
pub const fn other(stmt: Stmt) -> Self {
Self::Other(stmt)
}
}
impl fmt::Display for SsaStmt {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Assign { target, value } => write!(f, "{} = {};", target, value),
Self::Phi(phi) => write!(f, "{}", phi),
Self::Other(stmt) => write!(f, "{:?}", stmt),
}
}
}