1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

LibJS: Allocate a Realm next to GlobalObject in Interpreter::create()

Also pass a Realm reference to the Bytecode::Interpreter constructor,
just like we pass the GlobalObject.
This commit is contained in:
Linus Groh 2021-09-11 19:36:25 +01:00
parent d9c3bafcd9
commit 2b8d5696ab
8 changed files with 54 additions and 10 deletions

View file

@ -11,7 +11,6 @@
#include <LibJS/Runtime/FunctionEnvironment.h>
#include <LibJS/Runtime/GlobalEnvironment.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/OrdinaryFunctionObject.h>
#include <LibJS/Runtime/Reference.h>
#include <LibJS/Runtime/Shape.h>
@ -23,7 +22,7 @@ NonnullOwnPtr<Interpreter> Interpreter::create_with_existing_global_object(Globa
{
DeferGC defer_gc(global_object.heap());
auto interpreter = adopt_own(*new Interpreter(global_object.vm()));
interpreter->m_global_object = make_handle(static_cast<Object*>(&global_object));
interpreter->m_global_object = make_handle(&global_object);
return interpreter;
}
@ -80,6 +79,16 @@ const GlobalObject& Interpreter::global_object() const
return static_cast<const GlobalObject&>(*m_global_object.cell());
}
Realm& Interpreter::realm()
{
return static_cast<Realm&>(*m_realm.cell());
}
const Realm& Interpreter::realm() const
{
return static_cast<const Realm&>(*m_realm.cell());
}
void Interpreter::enter_scope(const ScopeNode& scope_node, ScopeType scope_type, GlobalObject& global_object)
{
ScopeGuard guard([&] {