1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:27:35 +00:00

LibJS: Basic bytecode support for computed member expressions

Expressions like foo[1 + 2] now work, and you can assign to them
as well! :^)
This commit is contained in:
Andreas Kling 2021-06-11 00:35:25 +02:00
parent b47246ec70
commit 9ee5029bc5
4 changed files with 75 additions and 3 deletions

View file

@ -266,6 +266,38 @@ private:
StringTableIndex m_property;
};
class GetByValue final : public Instruction {
public:
explicit GetByValue(Register base)
: Instruction(Type::GetByValue)
, m_base(base)
{
}
void execute(Bytecode::Interpreter&) const;
String to_string(Bytecode::Executable const&) const;
private:
Register m_base;
};
class PutByValue final : public Instruction {
public:
PutByValue(Register base, Register property)
: Instruction(Type::PutByValue)
, m_base(base)
, m_property(property)
{
}
void execute(Bytecode::Interpreter&) const;
String to_string(Bytecode::Executable const&) const;
private:
Register m_base;
Register m_property;
};
class Jump : public Instruction {
public:
constexpr static bool IsTerminator = true;