LibJS/Bytecode: Support in binary operator for private fields

11 new passes on test262. :^)
This commit is contained in:
Andreas Kling 2023-07-05 12:42:50 +02:00
commit e87d84f883
Notes: sideshowbarker 2024-07-17 04:41:05 +09:00
4 changed files with 44 additions and 0 deletions

View file

@ -66,6 +66,13 @@ Bytecode::CodeGenerationErrorOr<void> ExpressionStatement::generate_bytecode(Byt
Bytecode::CodeGenerationErrorOr<void> BinaryExpression::generate_bytecode(Bytecode::Generator& generator) const
{
if (m_op == BinaryOp::In && is<PrivateIdentifier>(*m_lhs)) {
auto const& private_identifier = static_cast<PrivateIdentifier const&>(*m_lhs).string();
TRY(m_rhs->generate_bytecode(generator));
generator.emit<Bytecode::Op::HasPrivateId>(generator.intern_identifier(private_identifier));
return {};
}
TRY(m_lhs->generate_bytecode(generator));
auto lhs_reg = generator.allocate_register();
generator.emit<Bytecode::Op::Store>(lhs_reg);