feat: 添加内置函数支持(len, typeof, push, pop),更新相关错误处理和测试用例
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
//! 内置函数模块:按功能分组注册,便于扩展和维护。
|
||||
|
||||
mod core;
|
||||
mod io;
|
||||
mod os;
|
||||
|
||||
@@ -27,4 +28,10 @@ pub fn register_all(env: &Rc<RefCell<Env>>) {
|
||||
e.define("os".into(), Value::Object(Rc::new(RefCell::new(os))), true);
|
||||
// clock can also be used as a global function for convenience
|
||||
e.define("clock".into(), Value::NativeFunction(os::clock), true);
|
||||
|
||||
// core — len, typeof, push, pop
|
||||
e.define("len".into(), Value::NativeFunction(core::len), true);
|
||||
e.define("typeof".into(), Value::NativeFunction(core::typeof_fn), true);
|
||||
e.define("push".into(), Value::NativeFunction(core::push), true);
|
||||
e.define("pop".into(), Value::NativeFunction(core::pop), true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user