Files
RustAst/src/ast/compiler/optimizer/utils.rs
T
Michael Schimmel cad0c03973 Refactor: Move inlining logic to Inliner struct
Introduces the `Inliner` struct to encapsulate logic related to value
and function inlining. This improves code organization and readability
within the optimizer engine.

Key changes include:
- Moving `is_inlinable_value` to the `Inliner` struct.
- Extracting beta-reduction preparation logic into
  `Inliner::prepare_beta_reduction`.
- Moving parameter slot collection to
  `Inliner::collect_parameter_slots`.
- Introducing `flatten_tuple` to a new `utils` module, used by both
  `Folder` and `Inliner`.
2026-02-25 20:07:37 +01:00

19 lines
529 B
Rust

use crate::ast::compiler::bound_nodes::{AnalyzedNode, BoundKind};
pub fn flatten_tuple(node: AnalyzedNode, into: &mut Vec<AnalyzedNode>) {
match node.kind {
BoundKind::Tuple { elements } => {
for el in elements {
flatten_tuple(el, into);
}
}
BoundKind::Record { fields } => {
for (_, v) in fields {
flatten_tuple(v, into);
}
}
BoundKind::Nop => {}
_ => into.push(node),
}
}