diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-10T18·09+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-08-25T11·34+0000 |
commit | 7d55b776de29cfaa70a2ab9ae61b6cabe70ed637 (patch) | |
tree | 88efe21bdf71867c3a5cbdc18aa893af6a2edf02 /tvix/eval/src/compiler.rs | |
parent | 058e77bab20db90347ce1d91c41076ef56b61b26 (diff) |
feat(tvix): implement not-equals (!=) operator r/4476
Change-Id: Ic259d6d0cf30553e944682a0d1d2c610df7fe5c2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6141 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/compiler.rs')
-rw-r--r-- | tvix/eval/src/compiler.rs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tvix/eval/src/compiler.rs b/tvix/eval/src/compiler.rs index 4aadfaba80e7..d48490dde7a6 100644 --- a/tvix/eval/src/compiler.rs +++ b/tvix/eval/src/compiler.rs @@ -130,17 +130,22 @@ impl Compiler { use rnix::types::BinOpKind; - let opcode = match op.operator().unwrap() { - BinOpKind::Add => OpCode::OpAdd, - BinOpKind::Sub => OpCode::OpSub, - BinOpKind::Mul => OpCode::OpMul, - BinOpKind::Div => OpCode::OpDiv, - BinOpKind::Equal => OpCode::OpEqual, - BinOpKind::Update => OpCode::OpAttrsUpdate, + match op.operator().unwrap() { + BinOpKind::Add => self.chunk.add_op(OpCode::OpAdd), + BinOpKind::Sub => self.chunk.add_op(OpCode::OpSub), + BinOpKind::Mul => self.chunk.add_op(OpCode::OpMul), + BinOpKind::Div => self.chunk.add_op(OpCode::OpDiv), + BinOpKind::Update => self.chunk.add_op(OpCode::OpAttrsUpdate), + BinOpKind::Equal => self.chunk.add_op(OpCode::OpEqual), + + BinOpKind::NotEqual => { + self.chunk.add_op(OpCode::OpEqual); + self.chunk.add_op(OpCode::OpInvert) + } + _ => todo!(), }; - self.chunk.add_op(opcode); Ok(()) } |