feat(tvix): implement not-equals (!=) operator

Change-Id: Ic259d6d0cf30553e944682a0d1d2c610df7fe5c2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6141
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-08-10 21:09:59 +03:00 committed by tazjin
parent 058e77bab2
commit 7d55b776de
9 changed files with 21 additions and 8 deletions

View file

@ -130,17 +130,22 @@ impl Compiler {
use rnix::types::BinOpKind; use rnix::types::BinOpKind;
let opcode = match op.operator().unwrap() { match op.operator().unwrap() {
BinOpKind::Add => OpCode::OpAdd, BinOpKind::Add => self.chunk.add_op(OpCode::OpAdd),
BinOpKind::Sub => OpCode::OpSub, BinOpKind::Sub => self.chunk.add_op(OpCode::OpSub),
BinOpKind::Mul => OpCode::OpMul, BinOpKind::Mul => self.chunk.add_op(OpCode::OpMul),
BinOpKind::Div => OpCode::OpDiv, BinOpKind::Div => self.chunk.add_op(OpCode::OpDiv),
BinOpKind::Equal => OpCode::OpEqual, BinOpKind::Update => self.chunk.add_op(OpCode::OpAttrsUpdate),
BinOpKind::Update => 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!(), _ => todo!(),
}; };
self.chunk.add_op(opcode);
Ok(()) Ok(())
} }

View file

@ -0,0 +1 @@
true

View file

@ -0,0 +1 @@
4.2 == 4.2

View file

@ -0,0 +1 @@
true

View file

@ -0,0 +1 @@
42 == 42

View file

@ -0,0 +1 @@
true

View file

@ -0,0 +1 @@
42 != 69

View file

@ -0,0 +1 @@
true

View file

@ -0,0 +1 @@
"this" != "that"