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.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index 077acfcc1b..da79867ef3 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -81,6 +81,18 @@ impl VM {
                     NumberPair::Integer(i1, i2) => self.push(Value::Integer(i1 / i2)),
                 },
 
+                OpCode::OpNegate => match self.pop() {
+                    Value::Integer(i) => self.push(Value::Integer(-i)),
+                    Value::Float(f) => self.push(Value::Float(-f)),
+                    v => {
+                        return Err(Error::TypeError {
+                            expected: "number (either int or float)",
+                            actual: v.type_of(),
+                        })
+                    }
+                },
+
+                OpCode::OpInvert => todo!(),
                 OpCode::OpNull => todo!(),
                 OpCode::OpTrue => todo!(),
                 OpCode::OpFalse => todo!(),