pub struct LetInliner { /* private fields */ }Expand description
The let-inlining pass.
Iterates to a fixed point (or until config.max_passes is reached),
replacing eligible Let bindings with direct substitution of the bound
value into the body.
Implementations§
Source§impl LetInliner
impl LetInliner
Sourcepub fn new(config: InlineConfig) -> Self
pub fn new(config: InlineConfig) -> Self
Construct a new inliner with the given configuration.
Sourcepub fn with_default() -> Self
pub fn with_default() -> Self
Construct a new inliner with the default configuration.
Sourcepub fn run(&self, expr: TLExpr) -> (TLExpr, InlineStats)
pub fn run(&self, expr: TLExpr) -> (TLExpr, InlineStats)
Run inlining to a fixed point (or until config.max_passes is reached).
Returns the rewritten expression and collected InlineStats.
Sourcepub fn count_free_occurrences(var: &str, expr: &TLExpr) -> usize
pub fn count_free_occurrences(var: &str, expr: &TLExpr) -> usize
Count how many times var appears free in expr.
Sourcepub fn substitute(var: &str, replacement: &TLExpr, body: TLExpr) -> TLExpr
pub fn substitute(var: &str, replacement: &TLExpr, body: TLExpr) -> TLExpr
Substitute all free occurrences of var with replacement in body.
Sourcepub fn is_constant_binding(expr: &TLExpr) -> bool
pub fn is_constant_binding(expr: &TLExpr) -> bool
Returns true if expr is a constant literal (Constant(_)).
Sourcepub fn is_var_binding(expr: &TLExpr) -> bool
pub fn is_var_binding(expr: &TLExpr) -> bool
Returns true if expr is a zero-argument predicate (variable alias).
Sourcepub fn is_simple_binding(expr: &TLExpr) -> bool
pub fn is_simple_binding(expr: &TLExpr) -> bool
Returns true if expr is a “simple” binding worth inlining regardless
of use count: either a constant or a variable alias.
Sourcepub fn expr_depth(expr: &TLExpr) -> usize
pub fn expr_depth(expr: &TLExpr) -> usize
Compute the depth (height) of an expression tree.