Refactor Purity enum and NativeFunction struct
Move `Purity` enum definition from `optimizer.rs` to `types.rs` and create a `NativeFunction` struct to hold the function and its purity. Update `Value::Function` to store `Rc<NativeFunction>` and `Value::make_function` helper to simplify creation. This change allows tracking the purity of native functions, which is useful for optimization and static analysis.
This commit is contained in:
+2
-2
@@ -194,14 +194,14 @@ macro_rules! dispatch_eval {
|
||||
if $node.ty.is_tail {
|
||||
match func_val {
|
||||
Value::Object(obj) => return Ok(Value::TailCallRequest(Box::new((obj, arg_vals)))),
|
||||
Value::Function(f) => return Ok(f(arg_vals)),
|
||||
Value::Function(f) => return Ok((f.func)(arg_vals)),
|
||||
_ => return Err(format!("Tail call target is not a function: {}", func_val)),
|
||||
}
|
||||
}
|
||||
|
||||
loop {
|
||||
match func_val {
|
||||
Value::Function(f) => break Ok(f(arg_vals)),
|
||||
Value::Function(f) => break Ok((f.func)(arg_vals)),
|
||||
Value::Object(obj) => {
|
||||
if let Some(closure) = obj.as_any().downcast_ref::<Closure>() {
|
||||
let old_stack_top = $self.stack.len();
|
||||
|
||||
Reference in New Issue
Block a user