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

LibJS: Add support for SpreadExpressions in array literals for bytecode

For this it adds another opcode `Append $lhs` which appends the
accumulator to the Array in $lhs, optionally spreading it.
This commit is contained in:
Hendiadyoin1 2022-09-09 15:23:02 +02:00 committed by Linus Groh
parent 4235b2020f
commit ae52ae8f9f
4 changed files with 109 additions and 27 deletions

View file

@ -254,6 +254,24 @@ private:
Register m_elements[];
};
class Append final : public Instruction {
public:
Append(Register lhs, bool is_spread)
: Instruction(Type::Append)
, m_lhs(lhs)
, m_is_spread(is_spread)
{
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
private:
Register m_lhs;
bool m_is_spread = false;
};
class IteratorToArray final : public Instruction {
public:
IteratorToArray()