forked from katzen-cafe/iowo
25 lines
652 B
Rust
25 lines
652 B
Rust
use crate::namespace::{typedef::TypeDef, GlobalNamespace};
|
|
|
|
pub fn initialise_globals() -> GlobalNamespace {
|
|
let ns = GlobalNamespace::init();
|
|
|
|
let numeric = ns.register_trait("Numeric").unwrap();
|
|
|
|
ns.register_type("integer").unwrap().add_trait(&numeric);
|
|
ns.register_type("float").unwrap().add_trait(&numeric);
|
|
|
|
ns.register_type("string").unwrap();
|
|
|
|
// def math add [ Numeric Numeric ] -> Numeric
|
|
ns.register_command(
|
|
"add",
|
|
Some(TypeDef::List(vec![
|
|
TypeDef::Trait(numeric),
|
|
TypeDef::Trait(numeric),
|
|
])),
|
|
Some(TypeDef::Trait(numeric)),
|
|
)
|
|
.unwrap();
|
|
|
|
ns
|
|
}
|