Refactor closure instantiation and inlining

This commit makes several changes related to how closures are handled:

- **Dumper:** Removes redundant introspection of closure ASTs, as this
  is no longer relevant.
- **Optimizer:** Updates `try_inline` to accept `ExecNode` for
  parameters and adds a check to ensure the `function_node` is a
  `Lambda` before attempting inlining.
- **Environment:** Simplifies closure creation by passing an `ExecNode`
  for parameters and ensuring the correct `stack_size` is used.
- **VM:** Adjusts `Closure` to store an `ExecNode` for parameters and
  updates `VM::unpack` to accept an `ExecNode`.
This commit is contained in:
Michael Schimmel
2026-03-13 18:00:58 +01:00
parent ef5c2367a7
commit b87a6d7ada
4 changed files with 26 additions and 47 deletions
+17 -12
View File
@@ -334,19 +334,24 @@ impl Optimizer {
}
path.inlining_depth += 1;
let collapsed = self.try_inline(
&closure.parameter_node,
&arg_nodes,
&closure.function_node,
sub,
path,
Some(closure_sub),
);
path.inlining_depth -= 1;
path.exit_lambda(&closure.function_node.identity);
if let BoundKind::Lambda { params, .. } = &closure.function_node.kind {
let collapsed = self.try_inline(
params,
&arg_nodes,
&closure.function_node,
sub,
path,
Some(closure_sub),
);
path.inlining_depth -= 1;
path.exit_lambda(&closure.function_node.identity);
if let Some(res) = collapsed {
return res;
if let Some(res) = collapsed {
return res;
}
} else {
path.inlining_depth -= 1;
path.exit_lambda(&closure.function_node.identity);
}
}