From aa65f7602531ce2d1305eb1f323b0228854ebccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20W=C3=BClker?= Date: Sat, 6 Jul 2024 16:48:39 +0200 Subject: [PATCH] js: implement bytecode LogicalAnd instruction --- crates/js/src/bytecode/vm.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/js/src/bytecode/vm.rs b/crates/js/src/bytecode/vm.rs index a81e8559..bc094e56 100644 --- a/crates/js/src/bytecode/vm.rs +++ b/crates/js/src/bytecode/vm.rs @@ -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(