mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
added debug to lox_std
This commit is contained in:
parent
f8b59e6034
commit
812cf0d2d0
1 changed files with 13 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ use crate::error::RuntimeError;
|
||||||
|
|
||||||
pub fn init_std(env: &mut Runtime) {
|
pub fn init_std(env: &mut Runtime) {
|
||||||
clock().register(env);
|
clock().register(env);
|
||||||
|
debug().register(env);
|
||||||
exit().register(env);
|
exit().register(env);
|
||||||
input().register(env);
|
input().register(env);
|
||||||
print_env().register(env);
|
print_env().register(env);
|
||||||
|
|
@ -26,6 +27,18 @@ fn clock() -> LoxExternFunction {
|
||||||
LoxExternFunction::new("clock", 0, closure)
|
LoxExternFunction::new("clock", 0, closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn debug() -> LoxExternFunction {
|
||||||
|
let closure: ExternFunClosure = |args, _env| {
|
||||||
|
for arg in args {
|
||||||
|
println!("{arg:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Value::Nil)
|
||||||
|
};
|
||||||
|
|
||||||
|
LoxExternFunction::new("debug", 1, closure)
|
||||||
|
}
|
||||||
|
|
||||||
fn exit() -> LoxExternFunction {
|
fn exit() -> LoxExternFunction {
|
||||||
let closure: ExternFunClosure = |args, _env| {
|
let closure: ExternFunClosure = |args, _env| {
|
||||||
assert_eq!(args.len(), 1);
|
assert_eq!(args.len(), 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue