8c865681ff11fc90eb04ec058ad8773d8411f24b
This commit introduces a new mechanism for calculating the required stack size for closures at bind time, rather than storing it in the AST. This is achieved by adding a `calculate_stack_size` method to `BoundNode`. Key changes include: - `BoundNode::calculate_stack_size`: Recursively traverses the bound AST to find the maximum `LocalSlot` index used. - Recursion blocker for lambdas: Ensures that nested lambdas are not visited during stack size calculation for the outer closure, preventing incorrect stack size estimations. - VM update: The `VM::run` method now accepts and uses the pre-calculated stack size for setting up call frames. - `Closure` struct update: Stores the `stack_size` directly within the `Closure` struct. - Binder and TypeChecker updates: Minor adjustments to accommodate the new strategy and error reporting. - Optimizer enhancements: Constant and pure-lambda propagation for `Define` statements within blocks to ensure inlinability. This refactoring addresses issues related to accurate stack size management and improves the overall robustness of the binder and VM.
Description
No description provided
Languages
Rust
100%