//! Defines the runtime representation of a partially applied function. use std::rc::Rc; use derive_more::Constructor; use nixjit_error::Result; use nixjit_ir::ExprId; use super::Value; use crate::EvalContext; pub type StackFrame = smallvec::SmallVec<[Value; 5]>; #[derive(Debug, Clone, Constructor)] pub struct Closure { pub body: ExprId, pub frame: StackFrame, } impl Closure { pub fn call(self: Rc, arg: Option, ctx: &mut Ctx) -> Result { let Self { body: func, frame } = Rc::unwrap_or_clone(self); ctx.call(func, arg, frame) } }