talc/talc-std/src/lib.rs

48 lines
945 B
Rust
Raw Normal View History

2024-02-23 19:54:34 +00:00
use talc_lang::{symbol::{symbol, Symbol}, Vm};
2024-02-27 05:18:43 +00:00
pub mod value;
2024-02-23 19:54:34 +00:00
pub mod io;
pub mod iter;
pub mod exception;
2024-02-27 05:18:43 +00:00
pub mod num;
pub mod collection;
#[cfg(feature="random")]
pub mod random;
2024-02-23 19:54:34 +00:00
pub fn load_all(vm: &mut Vm) {
2024-02-27 05:18:43 +00:00
value::load(vm);
exception::load(vm);
iter::load(vm);
collection::load(vm);
num::load(vm);
io::load(vm);
#[cfg(feature="random")]
random::load(vm);
2024-02-23 19:54:34 +00:00
}
lazy_static::lazy_static! {
2024-02-27 05:18:43 +00:00
pub static ref SYM_IO_ERROR: Symbol = symbol!(io_error);
}
macro_rules! unpack_args {
($e:expr) => {
($e).try_into().expect("bypassed arity check")
};
2024-02-23 19:54:34 +00:00
}
2024-02-27 05:18:43 +00:00
pub(crate) use unpack_args;
macro_rules! unpack_varargs {
($e:expr) => {{
let mut args = $e;
let Value::List(varargs) = args.pop().expect("bypassed arity check") else {
panic!("bypassed arity check")
};
let varargs = ::std::rc::Rc::unwrap_or_clone(varargs).into_inner();
(args.try_into().expect("bypassed arity check"), varargs)
}};
}
pub(crate) use unpack_varargs;