feat(tvix/eval): Support builtins.bitOr
Bitwise `or` on integers. Change-Id: I45b0897331d1a9b6840f9d0feedcf10acc67fcec Reviewed-on: https://cl.tvl.fyi/c/depot/+/6549 Autosubmit: wpcarro <wpcarro@gmail.com> Reviewed-by: wpcarro <wpcarro@gmail.com> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
f5f6bd319d
commit
031ca653a3
3 changed files with 18 additions and 0 deletions
|
@ -108,6 +108,13 @@ fn pure_builtins() -> Vec<Builtin> {
|
|||
})
|
||||
})
|
||||
}),
|
||||
Builtin::new("bitOr", 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()?;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[ 0 1 1 1 8 8 8 8 ]
|
10
tvix/eval/src/tests/tvix_tests/eval-okay-builtins-bitor.nix
Normal file
10
tvix/eval/src/tests/tvix_tests/eval-okay-builtins-bitor.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
[
|
||||
(builtins.bitOr 0 0)
|
||||
(builtins.bitOr 1 0)
|
||||
(builtins.bitOr 0 1)
|
||||
(builtins.bitOr 1 1)
|
||||
(builtins.bitOr 8 8)
|
||||
(builtins.bitOr 8 (builtins.add 4 4))
|
||||
(builtins.bitOr (builtins.add 4 4) 8)
|
||||
(builtins.bitOr (builtins.add 4 4) (builtins.add 4 4))
|
||||
]
|
Loading…
Reference in a new issue