feat(tvix/eval): Support builtins.{mul,div}
Multiplication and division :) Change-Id: I79e76f3b55b7e9b8d1eb09b3d9741140b4d75742 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6406 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
b3097de75d
commit
15e2bc54f1
5 changed files with 28 additions and 0 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue