aboutsummaryrefslogtreecommitdiff
path: root/crates/sloth_vm/src/sloth_std/mod.rs
diff options
context:
space:
mode:
authorCody <cody@codyq.dev>2023-04-14 00:04:46 -0500
committerCody <cody@codyq.dev>2023-04-14 00:04:46 -0500
commitfa0da150a5a481be3d1de448edb6f23c170da9a9 (patch)
tree42771a909fca18fb0fe7d5645a7f40b4d69107ef /crates/sloth_vm/src/sloth_std/mod.rs
parenta8b2a413a455fb06e0b10cf13d132c812f92bd4b (diff)
downloadsloth-fa0da150a5a481be3d1de448edb6f23c170da9a9.tar.gz
Improved VM. Started work on std
Diffstat (limited to 'crates/sloth_vm/src/sloth_std/mod.rs')
-rw-r--r--crates/sloth_vm/src/sloth_std/mod.rs24
1 files changed, 24 insertions, 0 deletions
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<HashMap<&'static str, NativeFunction>> = 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
+});