//! Builtin function modules. pub mod core; pub mod io; pub mod os; pub mod string; use crate::runtime::Value; use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; /// Register all standard library functions into a HashMap. pub fn register_all(map: &mut HashMap) { // io let mut io_map = HashMap::new(); io_map.insert("print".into(), Value::NativeFunction(Rc::new(io::print))); io_map.insert("input".into(), Value::NativeFunction(Rc::new(io::input))); map.insert("io".into(), Value::Object(Rc::new(RefCell::new(io_map)))); map.insert("print".into(), Value::NativeFunction(Rc::new(io::print))); map.insert("input".into(), Value::NativeFunction(Rc::new(io::input))); // os let mut os_map = HashMap::new(); os_map.insert("clock".into(), Value::NativeFunction(Rc::new(os::clock))); map.insert("os".into(), Value::Object(Rc::new(RefCell::new(os_map)))); map.insert("clock".into(), Value::NativeFunction(Rc::new(os::clock))); // core map.insert("len".into(), Value::NativeFunction(Rc::new(core::len))); map.insert("typeof".into(), Value::NativeFunction(Rc::new(core::typeof_fn))); map.insert("push".into(), Value::NativeFunction(Rc::new(core::push))); map.insert("pop".into(), Value::NativeFunction(Rc::new(core::pop))); // string map.insert("split".into(), Value::NativeFunction(Rc::new(string::split))); map.insert("trim".into(), Value::NativeFunction(Rc::new(string::trim))); map.insert("substring".into(), Value::NativeFunction(Rc::new(string::substring))); map.insert("replace".into(), Value::NativeFunction(Rc::new(string::replace))); map.insert("contains".into(), Value::NativeFunction(Rc::new(string::contains))); map.insert("upper".into(), Value::NativeFunction(Rc::new(string::upper))); map.insert("lower".into(), Value::NativeFunction(Rc::new(string::lower))); map.insert("starts_with".into(), Value::NativeFunction(Rc::new(string::starts_with))); map.insert("ends_with".into(), Value::NativeFunction(Rc::new(string::ends_with))); }