use crate::v310::ext_instructions::ExtInstructions;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum BlockIndex {
Index(usize),
InvalidIndex(usize),
NoIndex,
}
pub struct Block {
instructions: ExtInstructions,
branch_block: BlockIndex,
default_block: BlockIndex,
}
impl Block {
pub fn is_terminating(&self) -> bool {
matches!(self.default_block, BlockIndex::NoIndex)
}
pub fn is_conditional(&self) -> bool {
matches!(self.branch_block, BlockIndex::Index(_))
}
}
pub struct ControlFlowGraph {
blocks: Vec<Block>,
start_index: BlockIndex,
}
impl From<ExtInstructions> for ControlFlowGraph {
fn from(value: ExtInstructions) -> Self {
let blocks = vec![];
ControlFlowGraph {
blocks,
start_index: BlockIndex::NoIndex,
}
}
}