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

LibJS: Perform function instantiation in bytecode

This replaces Bytecode::Op::EnterScope with a new NewFunction op that
instantiates a ScriptFunction from a given FunctionNode (AST).

This is then used to instantiate the local functions directly from
bytecode when entering a ScopeNode. :^)
This commit is contained in:
Andreas Kling 2021-06-10 00:49:23 +02:00
parent 941be2dcc2
commit b3e6a6c1cd
5 changed files with 16 additions and 21 deletions

View file

@ -346,11 +346,11 @@ private:
Register m_arguments[];
};
class EnterScope final : public Instruction {
class NewFunction final : public Instruction {
public:
explicit EnterScope(ScopeNode const& scope_node)
: Instruction(Type::EnterScope)
, m_scope_node(scope_node)
explicit NewFunction(FunctionNode const& function_node)
: Instruction(Type::NewFunction)
, m_function_node(function_node)
{
}
@ -358,7 +358,7 @@ public:
String to_string(Bytecode::Executable const&) const;
private:
ScopeNode const& m_scope_node;
FunctionNode const& m_function_node;
};
class Return final : public Instruction {