Skip to main content

oxilean_codegen/opt_passes/
betareductionpass_traits.rs

1//! # BetaReductionPass - Trait Implementations
2//!
3//! This module contains trait implementations for `BetaReductionPass`.
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::BetaReductionPass;
17use std::fmt;
18
19impl Default for BetaReductionPass {
20    fn default() -> Self {
21        Self::new()
22    }
23}
24
25impl fmt::Debug for BetaReductionPass {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        write!(f, "BetaReductionPass(reductions={})", self.reductions)
28    }
29}
30
31impl OptPass for BetaReductionPass {
32    fn name(&self) -> &str {
33        "beta_reduction"
34    }
35    fn run_pass(&mut self, decls: &mut [LcnfFunDecl]) -> usize {
36        let before = self.reductions;
37        self.run(decls);
38        (self.reductions - before) as usize
39    }
40}