diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-10T18·01+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-08-25T11·34+0000 |
commit | 058e77bab20db90347ce1d91c41076ef56b61b26 (patch) | |
tree | 95198e36be78d26ce14bf40cb0a5cfb4d536cce6 /tvix/eval/src/vm.rs | |
parent | fa2d250d1a65ba3bf8522fdbbe72dca21fa7ee66 (diff) |
feat(tvix/eval): implement attrset update (`//`) operator r/4475
The underlying implementation does a few tricks based on which pair of attrset representations is encountered. Particularly the effect of short-circuiting the empty cases might be relevant in nixpkgs/NixOS, due to the use of lib.optionalAttrs. Change-Id: I22b978b1c69af12926489a71087c6a6219c012f3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6140 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r-- | tvix/eval/src/vm.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index 9a65668caa23..7a1082344e34 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -117,8 +117,17 @@ impl VM { OpCode::OpNull => self.push(Value::Null), OpCode::OpTrue => self.push(Value::Bool(true)), OpCode::OpFalse => self.push(Value::Bool(false)), + OpCode::OpAttrs(count) => self.run_attrset(count)?, OpCode::OpAttrPath(count) => self.run_attr_path(count)?, + + OpCode::OpAttrsUpdate => { + let rhs = self.pop().as_attrs()?; + let lhs = self.pop().as_attrs()?; + + self.push(Value::Attrs(Rc::new(lhs.update(&rhs)))) + } + OpCode::OpList(count) => self.run_list(count)?, OpCode::OpInterpolate(count) => self.run_interpolate(count)?, } |