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
29
30
31
32
33
34
use std::fmt::Display;

use crate::ir::function::FunctionDefinitionIndex;

use super::IsAction;

#[derive(Debug, Clone)]
pub struct RemoveStatement {
    pub index: FunctionDefinitionIndex,
}

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

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

impl IsAction for RemoveStatement {
    fn perform_on_function(self, ir: &mut crate::ir::FunctionDefinition) {
        ir.content[self.index.0].content.remove(self.index.1);
    }
}