blob: af4ecab060da3bda7f0b6e19de317f0bc2c3900d (
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
41
42
43
44
45
46
47
48
49
50
|
mod core;
mod sys;
mod math;
mod io;
mod iter;
use matrix_lang::prelude::*;
pub(crate) type VmArgs<'a, 'b> = (&'a mut Vm, &'b mut StackFrame);
macro_rules! error {
($($arg:tt)*) => {
Err(::matrix_lang::prelude::exception!(::matrix_lang::prelude::RUNTIME_EXCEPTION, $($arg)*))
};
}
macro_rules! next {
($vm:expr, $frame:expr, $iter:expr) => {
$vm.run_fn($frame, $iter.clone(), vec![])
};
}
macro_rules! unpack_args {
($e:expr) => {
$e.try_into().expect("bypassed arity check")
};
}
macro_rules! unpack_varargs {
($e:expr) => {{
let mut args = $e;
let matrix_lang::prelude::Value::List(varargs) = args.pop().expect("bypassed arity check") else {
panic!("bypassed arity check")
};
let varargs = varargs.into_inner();
(args.try_into().expect("bypassed arity check"), varargs)
}};
}
pub(crate) use error;
pub(crate) use next;
pub(crate) use unpack_args;
pub(crate) use unpack_varargs;
pub fn load(vm: &mut Vm) {
core::load(vm);
sys::load(vm);
io::load(vm);
iter::load(vm);
math::load(vm);
}
|