From f5f6bd319db3b224aa603d5eaa74e1d61f071f50 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 5 Sep 2022 22:16:17 -0700 Subject: feat(tvix/eval): Support builtins.bitAnd Bitwise `and` on integers. Change-Id: I9f2a9182a057af26906683acd97a40dfabbdded8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6548 Reviewed-by: wpcarro Autosubmit: wpcarro Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/eval/src/builtins/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tvix/eval/src/builtins') diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index 605c7c2607ef..009758fe0f33 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -101,6 +101,13 @@ fn pure_builtins() -> Vec { Ok(Value::List(NixList::construct(output.len(), output))) }) }), + Builtin::new("bitAnd", 2, |args, vm| { + force!(vm, &args[0], x, { + force!(vm, &args[1], y, { + Ok(Value::Integer(x.as_int()? & y.as_int()?)) + }) + }) + }), Builtin::new("catAttrs", 2, |mut args, _| { let list = args.pop().unwrap().to_list()?; let key = args.pop().unwrap().to_str()?; -- cgit 1.4.1