summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/AST.cpp
diff options
context:
space:
mode:
authorHendi <hendi48@users.noreply.github.com>2021-07-04 03:15:52 +0200
committerLinus Groh <mail@linusgroh.de>2021-07-06 00:15:37 +0100
commit38fd980b0ce98130f5f62ab8c87531a2b367da5c (patch)
treea6297d970ed05b5653beeb90c5ee739150009fee /Userland/Libraries/LibJS/AST.cpp
parent72f8d90dc5afb023eb2449511439fc2116783961 (diff)
downloadserenity-38fd980b0ce98130f5f62ab8c87531a2b367da5c.zip
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.
Diffstat (limited to 'Userland/Libraries/LibJS/AST.cpp')
-rw-r--r--Userland/Libraries/LibJS/AST.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp
index 7dce1fca03..23b16fb21b 100644
--- a/Userland/Libraries/LibJS/AST.cpp
+++ b/Userland/Libraries/LibJS/AST.cpp
@@ -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));
+}
+
}