Update benchmarks and adjust tests

This commit updates benchmark values in several example files to reflect
minor performance variations. It also includes adjustments to
integration
and unit tests to align with recent changes in the type checking and VM
logic, specifically concerning closures and TCO handling.
This commit is contained in:
Michael Schimmel
2026-02-19 23:54:53 +01:00
parent 3c0f2ec8ce
commit 1331aabbe1
13 changed files with 108 additions and 71 deletions
+29 -3
View File
@@ -288,10 +288,36 @@ impl VM {
closure: None,
});
let result = self.eval(root);
let mut result = self.eval(root);
self.frames.pop();
result
loop {
match result {
Ok(Value::TailCallRequest(payload)) => {
let (next_obj, next_args) = *payload;
if let Some(closure) = next_obj.as_any().downcast_ref::<Closure>() {
let old_stack_top = 0; // Root is always base 0
let closure_rc = Rc::new(closure.clone());
// Reset stack for the next call (TCO)
self.stack.clear();
self.stack.extend(next_args);
self.frames.push(CallFrame {
stack_base: old_stack_top,
closure: Some(closure_rc),
});
result = self.eval(&closure.function_node);
self.frames.pop();
} else {
return Err(format!("Tail call target is not a closure: {}", next_obj.type_name()));
}
}
_ => return result,
}
}
}
pub fn run_with_observer<O: VMObserver>(&mut self, observer: &mut O, root: &TypedNode) -> Result<Value, String> {