compose_library/
lib.rs

1// Workaround to refer to self as compose_library instead of crate. Needed for some macros
2extern crate self as compose_library;
3pub mod diag;
4mod world;
5mod foundations;
6mod sink;
7pub mod repr;
8mod engine;
9mod gc;
10mod vm;
11mod modules;
12
13pub use engine::*;
14pub use foundations::*;
15pub use gc::*;
16pub use sink::*;
17use std::fmt::Debug;
18pub use vm::*;
19pub use world::*;
20
21#[derive(Clone)]
22pub struct Library {
23    /// The module containing global functions, types and values.
24    pub global: Module,
25}
26
27impl Debug for Library {
28    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29        write!(f, "Library")
30    }
31}
32
33impl Trace for Library {
34    fn visit_refs(&self, f: &mut dyn FnMut(UntypedRef)) {
35        self.global.visit_refs(f);
36    }
37}
38
39pub struct Routines {
40}
41
42
43pub fn library() -> Library {
44    let mut global = Scope::new();
45
46    global.define_func::<assert>();
47    global.define_func::<panic>();
48    global.define_func::<print>();
49    global.define_func::<println>();
50    global.define_type::<i64>();
51    global.define_type::<Type>();
52    global.define_type::<IterValue>();
53    global.define_type::<Func>();
54    global.define_type::<Boxed>();
55    global.define_type::<ArrayValue>();
56    global.define_type::<RangeValue>();
57
58    global.define("std", Module::new("std", global.clone()));
59    
60    Library {
61        global: Module::new("global", global),
62    }
63}