nanvm_lib/vm/internal/istatic_function.rs
1use crate::vm::{Any, Array, IVm};
2
3/// The code of a static function.
4///
5/// One signature for every function, whether or not its body reads `self_`:
6/// the VM's own value the function is the code of, through which the body
7/// reads its frame, [`IVm::frame`], and names itself for recursion,
8/// `Function::new(self_.clone())`, an `Rc`-cheap clone of the same value.
9/// The arguments come by value, as every operator on `Any` takes its
10/// operands.
11pub type StaticCode<A> =
12 fn(self_: &<A as IVm>::InternalFunction, args: Array<A>) -> Result<Any<A>, Any<A>>;
13
14/// A VM that makes a function out of a Rust static function: every VM,
15/// since [`IVm::static_function`] is the capability itself. The name is
16/// what compiled modules and the runtime's member functions bound on, each
17/// a maker of functions, kept as the one spelling of that requirement where
18/// a bound on [`IVm`] alone would say less about what the code does.
19pub trait IStaticFunction: IVm {}
20
21impl<A: IVm> IStaticFunction for A {}