mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
LibJS: Implement SuperCall for the Bytecode-VM
This commit is contained in:
parent
25be67299e
commit
21ae882cfd
5 changed files with 130 additions and 2 deletions
|
@ -613,6 +613,33 @@ private:
|
|||
Register m_arguments[];
|
||||
};
|
||||
|
||||
// NOTE: This instruction is variable-width depending on the number of arguments!
|
||||
class SuperCall : public Instruction {
|
||||
public:
|
||||
explicit SuperCall(bool is_synthetic, Vector<Register> const& arguments)
|
||||
: Instruction(Type::SuperCall)
|
||||
, m_is_synthetic(is_synthetic)
|
||||
, m_argument_count(arguments.size())
|
||||
{
|
||||
for (size_t i = 0; i < m_argument_count; ++i)
|
||||
m_arguments[i] = arguments[i];
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
|
||||
|
||||
size_t length_impl() const
|
||||
{
|
||||
return sizeof(*this) + sizeof(Register) * m_argument_count;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_is_synthetic;
|
||||
size_t m_argument_count { 0 };
|
||||
Register m_arguments[];
|
||||
};
|
||||
|
||||
class NewClass final : public Instruction {
|
||||
public:
|
||||
explicit NewClass(ClassExpression const& class_expression)
|
||||
|
@ -966,9 +993,11 @@ ALWAYS_INLINE size_t Instruction::length() const
|
|||
{
|
||||
if (type() == Type::Call)
|
||||
return static_cast<Op::Call const&>(*this).length_impl();
|
||||
else if (type() == Type::NewArray)
|
||||
if (type() == Type::SuperCall)
|
||||
return static_cast<Op::SuperCall const&>(*this).length_impl();
|
||||
if (type() == Type::NewArray)
|
||||
return static_cast<Op::NewArray const&>(*this).length_impl();
|
||||
else if (type() == Type::CopyObjectExcludingProperties)
|
||||
if (type() == Type::CopyObjectExcludingProperties)
|
||||
return static_cast<Op::CopyObjectExcludingProperties const&>(*this).length_impl();
|
||||
|
||||
#define __BYTECODE_OP(op) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue