1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00

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
parent e4b6c402cb
commit e87d84f883
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);