aboutsummaryrefslogtreecommitdiff
path: root/crates/sloth_vm/src/native.rs
blob: 8790cbdfe419fc1dd36d4e67a078a785a2705dae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::value::Primitive;
use crate::VM;

pub type NativeFunctionResult = Result<Primitive, Error>;
pub type NativeFunctionInput = fn(&mut VM, &[Primitive]) -> NativeFunctionResult;

pub enum Error {
    InvalidArgument,
    Unknown(String),
}

#[allow(clippy::type_complexity)]
pub struct NativeFunction {
    pub name: &'static str,
    pub function: NativeFunctionInput,
    pub arity: u8,
    pub returns_value: bool,
}