diff options
| author | Nic Gaffney <gaffney_nic@protonmail.com> | 2023-04-14 00:25:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-14 00:25:32 -0500 |
| commit | 97b7cd10d2bec408cc237e13c61562c810d8fd29 (patch) | |
| tree | 03d4151581277209f3df48c1a49a656c6c32a52b /crates/sloth_vm/src/native.rs | |
| parent | 6b25c191a4522610877898506856bd00cd1fc4d5 (diff) | |
| parent | fa0da150a5a481be3d1de448edb6f23c170da9a9 (diff) | |
| download | sloth-97b7cd10d2bec408cc237e13c61562c810d8fd29.tar.gz | |
Merge pull request #4 from slothlang/vm-basics
Basic VM
Diffstat (limited to 'crates/sloth_vm/src/native.rs')
| -rw-r--r-- | crates/sloth_vm/src/native.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/sloth_vm/src/native.rs b/crates/sloth_vm/src/native.rs new file mode 100644 index 0000000..8790cbd --- /dev/null +++ b/crates/sloth_vm/src/native.rs @@ -0,0 +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, +} |
