1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:37:36 +00:00

LibJS: Add a new EnterScope bytecode instruction

This is intended to perform the same duties as enter_scope() does in
the AST tree-walk interpreter:

- Hoisted function declaration processing
- Hoisted variable declaration processing
- ... maybe more

This first cut only implements the function declaration processing.
This commit is contained in:
Andreas Kling 2021-06-05 15:14:09 +02:00
parent 2316a084bf
commit 1eafaf67fe
3 changed files with 40 additions and 0 deletions

View file

@ -265,4 +265,19 @@ private:
Optional<Label> m_target;
};
class EnterScope final : public Instruction {
public:
explicit EnterScope(ScopeNode const& scope_node)
: m_scope_node(scope_node)
{
}
virtual ~EnterScope() override { }
virtual void execute(Bytecode::Interpreter&) const override;
virtual String to_string() const override;
private:
ScopeNode const& m_scope_node;
};
}