Skip to content

Commit

Permalink
js: Implement strict equality operators
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Jul 6, 2024
1 parent aa65f76 commit 7e09bd5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/js/src/bytecode/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 7e09bd5

Please sign in to comment.