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

LibJS: Support basic function calls in the bytecode world :^)

This patch adds the Call bytecode instruction which is emitted for the
CallExpression AST node.

It's pretty barebones and doesn't handle 'this' values properly, etc.
But it can perform basic function calls! :^)

Note that the called function will *not* execute as bytecode, but will
simply fall back into the old codepath and use the AST interpreter.
This commit is contained in:
Andreas Kling 2021-06-05 15:15:30 +02:00
parent 1eafaf67fe
commit dc63958478
4 changed files with 85 additions and 0 deletions

View file

@ -265,6 +265,27 @@ private:
Optional<Label> m_target;
};
class Call final : public Instruction {
public:
Call(Register dst, Register callee, Register this_value, Vector<Register> arguments)
: m_dst(dst)
, m_callee(callee)
, m_this_value(this_value)
, m_arguments(move(arguments))
{
}
virtual ~Call() override { }
virtual void execute(Bytecode::Interpreter&) const override;
virtual String to_string() const override;
private:
Register m_dst;
Register m_callee;
Register m_this_value;
Vector<Register> m_arguments;
};
class EnterScope final : public Instruction {
public:
explicit EnterScope(ScopeNode const& scope_node)