1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:47:44 +00:00

LibJS/Bytecode: Support private class fields

This is accomplished with two new instructions:
- GetPrivateById
- PutPrivateById

Looks like 1616 new passes on test262. :^)
This commit is contained in:
Andreas Kling 2023-06-23 08:16:17 +02:00
parent 467ea86179
commit e5c7d8407b
5 changed files with 93 additions and 0 deletions

View file

@ -517,6 +517,23 @@ private:
IdentifierTableIndex m_property;
};
class GetPrivateById final : public Instruction {
public:
explicit GetPrivateById(IdentifierTableIndex property)
: Instruction(Type::GetPrivateById)
, m_property(property)
{
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
private:
IdentifierTableIndex m_property;
};
enum class PropertyKind {
Getter,
Setter,
@ -550,6 +567,31 @@ private:
PropertyKind m_kind;
};
class PutPrivateById final : public Instruction {
public:
explicit PutPrivateById(Register base, IdentifierTableIndex property, PropertyKind kind = PropertyKind::KeyValue)
: Instruction(Type::PutPrivateById)
, m_base(base)
, m_property(property)
, m_kind(kind)
{
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register from, Register to)
{
if (m_base == from)
m_base = to;
}
private:
Register m_base;
IdentifierTableIndex m_property;
PropertyKind m_kind;
};
class DeleteById final : public Instruction {
public:
explicit DeleteById(IdentifierTableIndex property)