feat: Add tail call optimization
Introduce a TCO pass to the compiler and modify the VM to handle tail calls. This allows for deep recursion without stack overflow.
This commit is contained in:
@@ -9,7 +9,7 @@ pub enum Address {
|
||||
Global(u32), // Index in the global environment vector
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum BoundKind {
|
||||
Nop,
|
||||
Constant(Value),
|
||||
@@ -47,6 +47,11 @@ pub enum BoundKind {
|
||||
args: Vec<Node<BoundKind, StaticType>>,
|
||||
},
|
||||
|
||||
TailCall {
|
||||
callee: Box<Node<BoundKind, StaticType>>,
|
||||
args: Vec<Node<BoundKind, StaticType>>,
|
||||
},
|
||||
|
||||
Block {
|
||||
exprs: Vec<Node<BoundKind, StaticType>>,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user