diff options
| author | Cody <cody@codyq.dev> | 2023-04-14 00:04:46 -0500 |
|---|---|---|
| committer | Cody <cody@codyq.dev> | 2023-04-14 00:04:46 -0500 |
| commit | fa0da150a5a481be3d1de448edb6f23c170da9a9 (patch) | |
| tree | 42771a909fca18fb0fe7d5645a7f40b4d69107ef /crates/sloth_vm/src/native.rs | |
| parent | a8b2a413a455fb06e0b10cf13d132c812f92bd4b (diff) | |
| download | sloth-fa0da150a5a481be3d1de448edb6f23c170da9a9.tar.gz | |
Improved VM. Started work on std
Diffstat (limited to 'crates/sloth_vm/src/native.rs')
| -rw-r--r-- | crates/sloth_vm/src/native.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/sloth_vm/src/native.rs b/crates/sloth_vm/src/native.rs index 8b13789..8790cbd 100644 --- a/crates/sloth_vm/src/native.rs +++ b/crates/sloth_vm/src/native.rs @@ -1 +1,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, +} |
