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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/// try for generators (where '?' operator won't work)
#[macro_export]
macro_rules! gentry {
    ($e:expr) => {
        match $e {
            Ok(t) => t,
            Err(error) => return $crate::ResumeResult::Err($crate::Error::from(error)),
        }
    };
}
/// Outside of mtots_core, you can't just impl From<..> for mtots_core::Error
/// This macro is for conveniently converting an error of any type that
/// already implements std::error::Error, into mtots_core::Error
#[macro_export]
macro_rules! mtry {
    ($e:expr) => {
        match $e {
            Ok(t) => t,
            Err(error) => return Err($crate::Error::from_std(error)),
        }
    };
}

/// Utility for constructing runtime errors
#[macro_export]
macro_rules! rterr {
    ( $($args:expr),+ $(,)?) => {
        $crate::Error::rt(
            format!( $($args),+ ).into(),
            vec![])
    };
}

mod base;
mod cli;
mod nlibs;
mod util;

// I feel really yucky depending on an external crate in core
// Eventually I might just replace this with a makeshift implementation
// and eat the performance costs
pub extern crate indexmap;

pub use base::*;
pub use cli::climain;
pub use cli::ordie;
pub use indexmap::IndexMap;
pub use indexmap::IndexSet;
pub use nlibs::*;
pub use util::*;

pub use xref::XRef;
pub use xref::XRefMut;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn hello() {
        let mut globals = Globals::new();
        globals
            .exec_str(
                "[test]",
                None,
                r###"
                print("Hello world")
                "###,
            )
            .unwrap();
    }
}