about summary refs log tree commit diff
path: root/tvix/eval/src/builtins/mod.rs
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2022-08-30T00·31-0700
committertazjin <tazjin@tvl.su>2022-09-07T20·56+0000
commit15e2bc54f1beab0f99a7d7199af92a3139052302 (patch)
tree7135003cb5cd5901723ff77e248a97838141d43c /tvix/eval/src/builtins/mod.rs
parentb3097de75d50a018665823e28e0ee4d7a3878160 (diff)
feat(tvix/eval): Support builtins.{mul,div} r/4739
Multiplication and division :)

Change-Id: I79e76f3b55b7e9b8d1eb09b3d9741140b4d75742
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6406
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r--tvix/eval/src/builtins/mod.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index a0ada0233c59..1a0443cb6012 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -40,6 +40,11 @@ fn pure_builtins() -> Vec<Builtin> {
 
             Ok(Value::List(NixList::construct(output.len(), output)))
         }),
+        Builtin::new("div", 2, |mut args| {
+            let b = args.pop().unwrap();
+            let a = args.pop().unwrap();
+            Ok(arithmetic_op!(a, b, /))
+        }),
         Builtin::new("isAttrs", 1, |args| {
             Ok(Value::Bool(matches!(args[0], Value::Attrs(_))))
         }),
@@ -70,6 +75,11 @@ fn pure_builtins() -> Vec<Builtin> {
         Builtin::new("isString", 1, |args| {
             Ok(Value::Bool(matches!(args[0], Value::String(_))))
         }),
+        Builtin::new("mul", 2, |mut args| {
+            let b = args.pop().unwrap();
+            let a = args.pop().unwrap();
+            Ok(arithmetic_op!(a, b, *))
+        }),
         Builtin::new("sub", 2, |mut args| {
             let b = args.pop().unwrap();
             let a = args.pop().unwrap();