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:
parent
058e77bab2
commit
7d55b776de
9 changed files with 21 additions and 8 deletions
|
@ -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(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
tvix/eval/src/tests/tvix_tests/eval-okay-eq-float.exp
Normal file
1
tvix/eval/src/tests/tvix_tests/eval-okay-eq-float.exp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
true
|
1
tvix/eval/src/tests/tvix_tests/eval-okay-eq-float.nix
Normal file
1
tvix/eval/src/tests/tvix_tests/eval-okay-eq-float.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
4.2 == 4.2
|
1
tvix/eval/src/tests/tvix_tests/eval-okay-eq-int.exp
Normal file
1
tvix/eval/src/tests/tvix_tests/eval-okay-eq-int.exp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
true
|
1
tvix/eval/src/tests/tvix_tests/eval-okay-eq-int.nix
Normal file
1
tvix/eval/src/tests/tvix_tests/eval-okay-eq-int.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
42 == 42
|
1
tvix/eval/src/tests/tvix_tests/eval-okay-ne-int.exp
Normal file
1
tvix/eval/src/tests/tvix_tests/eval-okay-ne-int.exp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
true
|
1
tvix/eval/src/tests/tvix_tests/eval-okay-ne-int.nix
Normal file
1
tvix/eval/src/tests/tvix_tests/eval-okay-ne-int.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
42 != 69
|
1
tvix/eval/src/tests/tvix_tests/eval-okay-ne-string.exp
Normal file
1
tvix/eval/src/tests/tvix_tests/eval-okay-ne-string.exp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
true
|
1
tvix/eval/src/tests/tvix_tests/eval-okay-ne-string.nix
Normal file
1
tvix/eval/src/tests/tvix_tests/eval-okay-ne-string.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
"this" != "that"
|
Loading…
Add table
Reference in a new issue