summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp
index ec61b3ca13..e3255d6e0d 100644
--- a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp
@@ -13,6 +13,14 @@
namespace JS {
+DeclarativeEnvironment* DeclarativeEnvironment::create_for_per_iteration_bindings(Badge<ForStatement>, DeclarativeEnvironment& other, size_t bindings_size)
+{
+ auto bindings = other.m_bindings.span().slice(0, bindings_size);
+ auto* parent_scope = other.outer_environment();
+
+ return parent_scope->heap().allocate_without_global_object<DeclarativeEnvironment>(parent_scope, bindings);
+}
+
DeclarativeEnvironment::DeclarativeEnvironment()
: Environment(nullptr)
{
@@ -23,6 +31,12 @@ DeclarativeEnvironment::DeclarativeEnvironment(Environment* parent_scope)
{
}
+DeclarativeEnvironment::DeclarativeEnvironment(Environment* parent_scope, Span<Binding const> bindings)
+ : Environment(parent_scope)
+ , m_bindings(bindings)
+{
+}
+
DeclarativeEnvironment::~DeclarativeEnvironment()
{
}