add basic arithmatic operations
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
f8ab31e9aa
commit
a429b546d0
5 changed files with 364 additions and 6 deletions
45
src/stl.rs
45
src/stl.rs
|
|
@ -23,6 +23,7 @@ pub mod append;
|
|||
pub mod boolean;
|
||||
pub mod control;
|
||||
pub mod decl;
|
||||
pub mod math;
|
||||
//pub mod str;
|
||||
|
||||
/// static_stdlib
|
||||
|
|
@ -183,6 +184,50 @@ pub fn static_stdlib(syms: &mut SymTable) -> Result<(), String> {
|
|||
},
|
||||
);
|
||||
|
||||
syms.insert(
|
||||
"add".to_string(),
|
||||
Symbol {
|
||||
name: String::from("add"),
|
||||
args: Args::Infinite,
|
||||
conditional_branches: false,
|
||||
docs: math::ADD_DOCSTRING.to_string(),
|
||||
value: ValueType::Internal(Rc::new(math::add_callback)),
|
||||
},
|
||||
);
|
||||
|
||||
syms.insert(
|
||||
"sub".to_string(),
|
||||
Symbol {
|
||||
name: String::from("sub"),
|
||||
args: Args::Infinite,
|
||||
conditional_branches: false,
|
||||
docs: math::SUB_DOCSTRING.to_string(),
|
||||
value: ValueType::Internal(Rc::new(math::sub_callback)),
|
||||
},
|
||||
);
|
||||
|
||||
syms.insert(
|
||||
"div".to_string(),
|
||||
Symbol {
|
||||
name: String::from("div"),
|
||||
args: Args::Lazy(2),
|
||||
conditional_branches: false,
|
||||
docs: math::DIV_DOCSTRING.to_string(),
|
||||
value: ValueType::Internal(Rc::new(math::div_callback)),
|
||||
},
|
||||
);
|
||||
|
||||
syms.insert(
|
||||
"mul".to_string(),
|
||||
Symbol {
|
||||
name: String::from("mul"),
|
||||
args: Args::Infinite,
|
||||
conditional_branches: false,
|
||||
docs: math::MUL_DOCSTRING.to_string(),
|
||||
value: ValueType::Internal(Rc::new(math::mul_callback)),
|
||||
},
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue