about summary refs log tree commit diff
path: root/tvix/eval/src/vm.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r--tvix/eval/src/vm.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index a64e0b337aea..4ea1b3b65cf5 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -83,6 +83,10 @@ impl VM {
         self.stack.push(value)
     }
 
+    fn peek(&self, offset: usize) -> &Value {
+        &self.stack[self.stack.len() - 1 - offset]
+    }
+
     fn run(&mut self) -> EvalResult<Value> {
         loop {
             match self.inc_ip() {
@@ -91,6 +95,10 @@ impl VM {
                     self.push(c);
                 }
 
+                OpCode::OpPop => {
+                    self.pop();
+                }
+
                 OpCode::OpAdd => {
                     let b = self.pop();
                     let a = self.pop();
@@ -163,6 +171,16 @@ impl VM {
                 }
 
                 OpCode::OpInterpolate(count) => self.run_interpolate(count)?,
+
+                OpCode::OpJump(offset) => {
+                    self.ip += offset;
+                }
+
+                OpCode::OpJumpIfFalse(offset) => {
+                    if !self.peek(0).as_bool()? {
+                        self.ip += offset;
+                    }
+                }
             }
 
             if self.ip == self.chunk.code.len() {