Refactor the arguments of a Builtin to be a vec of a new BuiltinArgument struct, which contains the old strictness boolean and also a static `name` str - this is automatically determined via the ident for the corresponding function argument in the proc-macro case, and passed in in the cases where we're still manually calling Builtin::new. Currently this name is unused, but in the future this can be used as part of a documentation system for builtins. Change-Id: Ib9dadb15b69bf8c9ea1983a4f4f197294a2394a6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7204 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
48 lines
1.1 KiB
Rust
48 lines
1.1 KiB
Rust
mod builtins;
|
|
mod chunk;
|
|
mod compiler;
|
|
mod errors;
|
|
mod eval;
|
|
pub mod observer;
|
|
mod opcode;
|
|
mod pretty_ast;
|
|
mod source;
|
|
mod spans;
|
|
mod systems;
|
|
mod upvalues;
|
|
mod value;
|
|
mod vm;
|
|
mod warnings;
|
|
|
|
mod nix_search_path;
|
|
#[cfg(test)]
|
|
mod properties;
|
|
#[cfg(test)]
|
|
mod test_utils;
|
|
#[cfg(test)]
|
|
mod tests;
|
|
|
|
use std::rc::Rc;
|
|
|
|
// Re-export the public interface used by other crates.
|
|
pub use crate::builtins::global_builtins;
|
|
pub use crate::compiler::{compile, prepare_globals};
|
|
pub use crate::errors::{ErrorKind, EvalResult};
|
|
pub use crate::eval::{interpret, Options};
|
|
pub use crate::pretty_ast::pretty_print_expr;
|
|
pub use crate::source::SourceCode;
|
|
pub use crate::value::Value;
|
|
pub use crate::vm::run_lambda;
|
|
|
|
/// Internal-only parts of `tvix-eval`, exported for use in macros, but not part of the public
|
|
/// interface of the crate.
|
|
pub mod internal {
|
|
pub use crate::value::{Builtin, BuiltinArgument};
|
|
pub use crate::vm::VM;
|
|
}
|
|
|
|
// TODO: use Rc::unwrap_or_clone once it is stabilised.
|
|
// https://doc.rust-lang.org/std/rc/struct.Rc.html#method.unwrap_or_clone
|
|
pub fn unwrap_or_clone_rc<T: Clone>(rc: Rc<T>) -> T {
|
|
Rc::try_unwrap(rc).unwrap_or_else(|rc| (*rc).clone())
|
|
}
|