1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::fmt::Display;

use super::IsAction;

#[derive(Debug, Clone)]
pub struct RemoveBasicBlock {
    pub index: usize,
}

impl RemoveBasicBlock {
    pub fn new(index: impl Into<usize>) -> Self {
        Self {
            index: index.into(),
        }
    }
}

impl Display for RemoveBasicBlock {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "remove basic block at {}", self.index)
    }
}

impl IsAction for RemoveBasicBlock {
    fn perform_on_function(self, ir: &mut crate::ir::FunctionDefinition) {
        ir.content.remove(self.index);
    }
}