use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SsaVariable {
pub base: String,
pub version: usize,
}
impl SsaVariable {
#[must_use]
pub const fn new(base: String, version: usize) -> Self {
Self { base, version }
}
#[must_use]
pub fn initial(base: String) -> Self {
Self::new(base, 0)
}
#[must_use]
pub fn next(&self) -> Self {
Self::new(self.base.clone(), self.version + 1)
}
#[must_use]
pub const fn is_initial(&self) -> bool {
self.version == 0
}
}
impl fmt::Display for SsaVariable {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.base)
}
}