Skip to main content

oxilean_codegen/opt_passes/
unreachablecodeeliminationpass_traits.rs

1//! # UnreachableCodeEliminationPass - Trait Implementations
2//!
3//! This module contains trait implementations for `UnreachableCodeEliminationPass`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Default`
8//! - `Debug`
9//! - `OptPass`
10//!
11//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
12
13use crate::lcnf::{LcnfArg, LcnfExpr, LcnfFunDecl, LcnfLetValue, LcnfLit, LcnfVarId};
14
15use super::functions::OptPass;
16use super::types::UnreachableCodeEliminationPass;
17use std::fmt;
18
19impl Default for UnreachableCodeEliminationPass {
20    fn default() -> Self {
21        Self::new()
22    }
23}
24
25impl fmt::Debug for UnreachableCodeEliminationPass {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        write!(
28            f,
29            "UnreachableCodeEliminationPass(elim={})",
30            self.eliminated
31        )
32    }
33}
34
35impl OptPass for UnreachableCodeEliminationPass {
36    fn name(&self) -> &str {
37        "unreachable_code_elimination"
38    }
39    fn run_pass(&mut self, decls: &mut [LcnfFunDecl]) -> usize {
40        let before = self.eliminated;
41        self.run(decls);
42        (self.eliminated - before) as usize
43    }
44}