Formatting

This commit is contained in:
Michael Schimmel
2026-02-24 07:27:13 +01:00
parent 9b7ef5080c
commit eeb6621280
7 changed files with 713 additions and 334 deletions
+19 -8
View File
@@ -198,7 +198,7 @@ impl Environment {
pub fn link(&self, node: TypedNode) -> ExecNode {
// 1. Analyze
let analyzed = Analyzer::analyze(&node, &self.global_purity.borrow());
// 2. Collect Analyzed Lambdas
LambdaCollector::collect(&analyzed, &mut self.typed_function_registry.borrow_mut());
@@ -218,13 +218,18 @@ impl Environment {
pub fn instantiate(&self, node: ExecNode) -> Rc<crate::ast::types::NativeFunction> {
let global_values = self.global_values.clone();
if let BoundKind::Lambda { params, upvalues, body, positional_count } = &node.kind
if let BoundKind::Lambda {
params,
upvalues,
body,
positional_count,
} = &node.kind
&& upvalues.is_empty()
{
let closure = Rc::new(crate::ast::vm::Closure::new(
params.ty.original.clone(),
body.ty.original.clone(),
body.clone(),
params.ty.original.clone(),
body.ty.original.clone(),
body.clone(),
vec![],
*positional_count,
));
@@ -294,7 +299,8 @@ impl Environment {
registry: untyped_reg.clone(),
analyzed_registry: typed_reg.clone(),
});
let sub_rtl_lookup = Rc::new(|name: &str, args: &[StaticType]| intrinsics::lookup(name, args));
let sub_rtl_lookup =
Rc::new(|name: &str, args: &[StaticType]| intrinsics::lookup(name, args));
let sub_specializer = Specializer::new(
Some(sub_registry),
@@ -335,7 +341,9 @@ impl Environment {
pub fn run_script(&self, source: &str) -> Result<Value, String> {
if self.debug_mode {
let (res, logs) = self.run_debug(source)?;
for line in logs { println!("{}", line); }
for line in logs {
println!("{}", line);
}
res
} else {
let compiled = self.compile(source)?;
@@ -363,7 +371,10 @@ impl Environment {
if let Some(closure) = next_obj.as_any().downcast_ref::<crate::ast::vm::Closure>() {
result = vm.run_with_args_observed(&mut observer, closure, next_args);
} else {
result = Err(format!("Tail call target is not a closure: {}", next_obj.type_name()));
result = Err(format!(
"Tail call target is not a closure: {}",
next_obj.type_name()
));
break;
}
}