From 7e09bd519f1098e898fbbee7e48c2d601a1869fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20W=C3=BClker?= Date: Sun, 7 Jul 2024 00:56:00 +0200 Subject: [PATCH] js: Implement strict equality operators --- crates/js/src/bytecode/vm.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/js/src/bytecode/vm.rs b/crates/js/src/bytecode/vm.rs index bc094e56..39bfa96b 100644 --- a/crates/js/src/bytecode/vm.rs +++ b/crates/js/src/bytecode/vm.rs @@ -233,6 +233,22 @@ impl Vm { self.set_register(*dst, result.into()); }, + Instruction::StrictEqual { lhs, rhs, dst } => { + // https://262.ecma-international.org/14.0/#sec-equality-operators-runtime-semantics-evaluation + let result = Value::is_strictly_equal( + &self.register(*lhs).get_value()?, + &self.register(*rhs).get_value()?, + )?; + self.set_register(*dst, Value::from(result).into()); + }, + Instruction::StrictNotEqual { lhs, rhs, dst } => { + // https://262.ecma-international.org/14.0/#sec-equality-operators-runtime-semantics-evaluation + let result = Value::is_strictly_equal( + &self.register(*lhs).get_value()?, + &self.register(*rhs).get_value()?, + )?; + self.set_register(*dst, Value::from(!result).into()); + }, Instruction::LooselyEqual { lhs, rhs, dst } => { // https://262.ecma-international.org/14.0/#sec-equality-operators-runtime-semantics-evaluation let result = Value::is_loosely_equal(