about summary refs log tree commit diff
path: root/tvix/eval/src/vm.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tvix/eval/src/vm.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index 332398d7b9..232e27aabb 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -173,6 +173,16 @@ impl VM {
                     }
                 }
 
+                OpCode::OpAttrOrNotFound => {
+                    let key = self.pop().as_string()?;
+                    let attrs = self.pop().as_attrs()?;
+
+                    match attrs.select(key.as_str()) {
+                        Some(value) => self.push(value.clone()),
+                        None => self.push(Value::NotFound),
+                    }
+                }
+
                 OpCode::OpAttrsIsSet => {
                     let key = self.pop().as_string()?;
                     let attrs = self.pop().as_attrs()?;
@@ -210,6 +220,13 @@ impl VM {
                     }
                 }
 
+                OpCode::OpJumpIfNotFound(offset) => {
+                    if matches!(self.peek(0), Value::NotFound) {
+                        self.pop();
+                        self.ip += offset;
+                    }
+                }
+
                 // These assertion operations error out if the stack
                 // top is not of the expected type. This is necessary
                 // to implement some specific behaviours of Nix