blob: 982017d259a694dd0d014fba7ff3ed0e441e3a50 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
use std::collections::HashMap;
use once_cell::sync::Lazy;
use crate::native::NativeFunction;
pub mod file;
pub mod misc;
pub mod rand;
pub mod stdio;
pub mod term;
pub mod time;
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("writeln", stdio::WRITELN_FUNCTION);
map.insert("read", stdio::READ_FUNCTION);
// term
map.insert("term$clear", term::TERM_CLEAR);
map.insert("term$setpos", term::TERM_SETPOS);
// filesystem
// TODO: Make the files commands work by making a global file variable with
// certain permissions created by 'file.open' instead of just reading the file.
map.insert("file$read", file::FILE_READ);
map.insert("file$write", file::FILE_WRITE);
// time
map.insert("wait", time::WAIT);
map
});
|