1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:17:36 +00:00

LibJS: Generate bytecode for array expressions

This commit is contained in:
Gunnar Beutner 2021-06-08 23:06:52 +02:00 committed by Andreas Kling
parent b8a5ea1f8d
commit a1e5711a27
6 changed files with 71 additions and 0 deletions

View file

@ -168,6 +168,27 @@ private:
Crypto::SignedBigInteger m_bigint;
};
// NOTE: This instruction is variable-width depending on the number of elements!
class NewArray final : public Instruction {
public:
NewArray(Vector<Register> const& elements)
: Instruction(Type::NewArray)
, m_element_count(elements.size())
{
for (size_t i = 0; i < m_element_count; ++i)
m_elements[i] = elements[i];
}
void execute(Bytecode::Interpreter&) const;
String to_string() const;
size_t length() const { return sizeof(*this) + sizeof(Register) * m_element_count; }
private:
size_t m_element_count { 0 };
Register m_elements[];
};
class ConcatString final : public Instruction {
public:
ConcatString(Register lhs)