Skip to content

Commit

Permalink
js: implement bytecode LogicalAnd instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Jul 6, 2024
1 parent eb1529f commit aa65f76
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/js/src/bytecode/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,17 @@ impl Vm {

self.set_register(*dst, result.into());
},
Instruction::LogicalAnd { lhs, rhs, dst } => {
// https://262.ecma-international.org/14.0/#sec-binary-logical-operators-runtime-semantics-evaluation
let lval = self.register(*lhs).get_value()?;
let result = if !lval.to_boolean() {
lval
} else {
self.register(*rhs).get_value()?
};

self.set_register(*dst, 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 aa65f76

Please sign in to comment.