1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:18:12 +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

@ -20,6 +20,7 @@ Optional<Bytecode::Register> ASTNode::generate_bytecode(Bytecode::Generator&) co
Optional<Bytecode::Register> ScopeNode::generate_bytecode(Bytecode::Generator& generator) const
{
generator.emit<Bytecode::Op::EnterScope>(*this);
for (auto& child : children()) {
[[maybe_unused]] auto reg = child.generate_bytecode(generator);
}