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
+3 -4
View File
@@ -666,14 +666,13 @@ impl Environment {
} = &node.kind
&& upvalues.is_empty()
{
let stack_size = node.ty.stack_size;
let closure = Rc::new(crate::ast::vm::Closure::new(
params.ty.original.clone(),
params.clone(),
body.ty.original.clone(),
body.clone(),
vec![],
Vec::new(),
*positional_count,
stack_size,
node.ty.stack_size,
));
let closure_obj: Rc<dyn crate::ast::types::Object> = closure;