1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 23:04:58 +00:00
serenity/Userland/Libraries/LibJS/Runtime/EnvironmentRecord.cpp
Andreas Kling f1e1d9dd74 LibJS: Add EnvironmentRecord::global_object()
Our environment records are currently weird in that they inherit from
Object, but don't have a connection to the global object.

I'd like to remove this inheritance, and the first step is giving them
their own pointer to the global object.
2021-06-23 12:50:26 +02:00

30 lines
657 B
C++

/*
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/EnvironmentRecord.h>
#include <LibJS/Runtime/VM.h>
namespace JS {
EnvironmentRecord::EnvironmentRecord(EnvironmentRecord* outer_environment)
: Object(vm().environment_record_shape())
, m_outer_environment(outer_environment)
{
}
void EnvironmentRecord::initialize(GlobalObject& global_object)
{
m_global_object = &global_object;
Base::initialize(global_object);
}
void EnvironmentRecord::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_outer_environment);
}
}