use super::*;
#[derive(Hash, PartialEq, Eq, Clone)]
pub struct CFGNode {
from_pred : Name,
to_succ : Name
}
impl CFGNode {
pub fn new(from_pred : Name, to_succ : Name) -> Self { Self {
from_pred,
to_succ
} }
pub fn from_pred(&self) -> &Name { &self.from_pred }
pub fn to_succ(&self) -> &Name { &self.to_succ }
}
impl Into<CFGNode> for &Name {
fn into(self) -> CFGNode { CFGNode {
from_pred : self.clone(),
to_succ : self.clone()
} }
}
impl Into<CFGNode> for &CFGNode {
fn into(self) -> CFGNode { self.clone() }
}
impl fmt::Display for CFGNode {
fn fmt(&self, f : &mut fmt::Formatter<'_>) -> fmt::Result {
let from_pred = self.from_pred();
let to_succ = self.to_succ();
if (from_pred == to_succ) {
write!(f, "{}", from_pred)
} else {
write!(f, "({}...{})", from_pred, to_succ)
}
}
}