LibJS: Improve function hoisting across blocks

The parser now keeps track of a scope chain so that it can hoist
function declarations to the closest function scope.
This commit is contained in:
Hendi 2021-07-04 03:15:52 +02:00 committed by Linus Groh
commit 38fd980b0c
Notes: sideshowbarker 2024-07-18 10:20:15 +09:00
6 changed files with 79 additions and 22 deletions

View file

@ -2377,4 +2377,9 @@ void ScopeNode::add_functions(NonnullRefPtrVector<FunctionDeclaration> functions
m_functions.extend(move(functions));
}
void ScopeNode::add_hoisted_functions(NonnullRefPtrVector<FunctionDeclaration> hoisted_functions)
{
m_hoisted_functions.extend(move(hoisted_functions));
}
}