Add print
This commit is contained in:
parent
fb851093f0
commit
fc50632a6f
@ -1 +1 @@
|
||||
global c = max(5, 7)
|
||||
global c = print(5, 7)
|
||||
12
src/main.rs
12
src/main.rs
@ -31,6 +31,14 @@ impl RustFunction for Max {
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct Print;
|
||||
impl RustFunction for Print {
|
||||
fn execute(&self, parameters: Vec<vm::Value>) -> Vec<vm::Value> {
|
||||
println!("{:?}", parameters);
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let file_path = PathBuf::from("../examples/test.lua");
|
||||
@ -68,6 +76,10 @@ fn main() {
|
||||
vm::Constant::String("max".to_owned()),
|
||||
vm::Value::RustFunction(Rc::new(RefCell::new(Max))),
|
||||
);
|
||||
vm.environment.borrow_mut().globals.insert(
|
||||
vm::Constant::String("print".to_owned()),
|
||||
vm::Value::RustFunction(Rc::new(RefCell::new(Print))),
|
||||
);
|
||||
|
||||
let closure = vm.create_closure(0);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user