From d431f43f5fbb0c8eaa23fd082ddb8839cdc0f642 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 8 Aug 2022 02:55:13 +0300 Subject: feat(tvix/eval): implement boolean inversion operator Change-Id: Icb1d449fdee4d67b5f1eefdbc01baa1584ea0a67 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6079 Tested-by: BuildkiteCI Autosubmit: tazjin Reviewed-by: grfn --- tvix/eval/src/vm.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tvix/eval/src/vm.rs') diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index 25a9074c7592..7b02c68dc193 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -81,6 +81,11 @@ impl VM { NumberPair::Integer(i1, i2) => self.push(Value::Integer(i1 / i2)), }, + OpCode::OpInvert => { + let v = self.pop().as_bool()?; + self.push(Value::Bool(!v)); + } + OpCode::OpNegate => match self.pop() { Value::Integer(i) => self.push(Value::Integer(-i)), Value::Float(f) => self.push(Value::Float(-f)), @@ -106,7 +111,6 @@ impl VM { self.push(Value::Bool(eq)) } - OpCode::OpInvert => todo!("invert"), OpCode::OpNull => todo!("null"), OpCode::OpTrue => todo!("true"), OpCode::OpFalse => todo!("false"), -- cgit 1.4.1