diff options
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r-- | tvix/eval/src/builtins/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index 49f047543994..a0ada0233c59 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -13,8 +13,15 @@ use crate::{ value::{Builtin, NixAttrs, NixList, NixString, Value}, }; +use crate::arithmetic_op; + fn pure_builtins() -> Vec<Builtin> { vec![ + Builtin::new("add", 2, |mut args| { + let b = args.pop().unwrap(); + let a = args.pop().unwrap(); + Ok(arithmetic_op!(a, b, +)) + }), Builtin::new("abort", 1, |mut args| { return Err( ErrorKind::Abort(args.pop().unwrap().to_string()?.as_str().to_owned()).into(), @@ -63,6 +70,11 @@ fn pure_builtins() -> Vec<Builtin> { Builtin::new("isString", 1, |args| { Ok(Value::Bool(matches!(args[0], Value::String(_)))) }), + Builtin::new("sub", 2, |mut args| { + let b = args.pop().unwrap(); + let a = args.pop().unwrap(); + Ok(arithmetic_op!(a, b, -)) + }), Builtin::new("throw", 1, |mut args| { return Err( ErrorKind::Throw(args.pop().unwrap().to_string()?.as_str().to_owned()).into(), |