1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +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

@ -544,6 +544,20 @@ ThrowCompletionOr<void> GetPrivateById::execute_impl(Bytecode::Interpreter& inte
return {};
}
ThrowCompletionOr<void> HasPrivateId::execute_impl(Bytecode::Interpreter& interpreter) const
{
auto& vm = interpreter.vm();
if (!interpreter.accumulator().is_object())
return vm.throw_completion<TypeError>(ErrorType::InOperatorWithObject);
auto private_environment = vm.running_execution_context().private_environment;
VERIFY(private_environment);
auto private_name = private_environment->resolve_private_identifier(interpreter.current_executable().get_identifier(m_property));
interpreter.accumulator() = Value(interpreter.accumulator().as_object().private_element_find(private_name) != nullptr);
return {};
}
ThrowCompletionOr<void> PutById::execute_impl(Bytecode::Interpreter& interpreter) const
{
auto& vm = interpreter.vm();
@ -1383,6 +1397,11 @@ DeprecatedString GetPrivateById::to_deprecated_string_impl(Bytecode::Executable
return DeprecatedString::formatted("GetPrivateById {} ({})", m_property, executable.identifier_table->get(m_property));
}
DeprecatedString HasPrivateId::to_deprecated_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("HasPrivateId {} ({})", m_property, executable.identifier_table->get(m_property));
}
DeprecatedString DeleteById::to_deprecated_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("DeleteById {} ({})", m_property, executable.identifier_table->get(m_property));