From fa0da150a5a481be3d1de448edb6f23c170da9a9 Mon Sep 17 00:00:00 2001 From: Cody Date: Fri, 14 Apr 2023 00:04:46 -0500 Subject: Improved VM. Started work on std --- crates/sloth_vm/src/sloth_std/mod.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 crates/sloth_vm/src/sloth_std/mod.rs (limited to 'crates/sloth_vm/src/sloth_std/mod.rs') diff --git a/crates/sloth_vm/src/sloth_std/mod.rs b/crates/sloth_vm/src/sloth_std/mod.rs new file mode 100644 index 0000000..86611d7 --- /dev/null +++ b/crates/sloth_vm/src/sloth_std/mod.rs @@ -0,0 +1,24 @@ +use std::collections::HashMap; + +use once_cell::sync::Lazy; + +use crate::native::NativeFunction; + +pub mod rand; +pub mod stdio; + +pub static NATIVE_LIBRARY: Lazy> = Lazy::new(|| { + let mut map = HashMap::new(); + + // rand + map.insert("rand$gen", rand::GEN_FUNCTION); + map.insert("rand$gen_range", rand::GEN_RANGE_FUNCTION); + + // stdio + map.insert("write", stdio::WRITE_FUNCTION); + map.insert("read", stdio::READ_FUNCTION); + + // filesystem + + map +}); -- cgit v1.2.3