mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 21:17:44 +00:00
LibJS: Pass Realm to GlobalObject::initialize_global_object()
Global object initialization is tightly coupled to realm creation, so simply pass it to the function instead of relying on the non-standard 'associated realm' concept, which I'd like to remove later. This works essentially the same way as regular Object::initialize() now. Additionally this allows us to forward the realm to GlobalObject's add_constructor() / initialize_constructor() helpers, so they set the correct realm on the allocated constructor function object.
This commit is contained in:
parent
b465f46e00
commit
7c468b5a77
18 changed files with 76 additions and 79 deletions
|
@ -23,7 +23,7 @@ $262Object::$262Object(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void $262Object::initialize(JS::Realm& realm)
|
||||
void $262Object::initialize(Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
|
@ -63,7 +63,7 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::create_realm)
|
|||
VERIFY(realm_global_object);
|
||||
realm->set_global_object(realm_global_object, nullptr);
|
||||
realm_global_object->set_associated_realm(*realm);
|
||||
realm_global_object->initialize_global_object();
|
||||
realm_global_object->initialize_global_object(*realm);
|
||||
return Value(realm_global_object->$262());
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,10 @@
|
|||
|
||||
namespace JS::Test262 {
|
||||
|
||||
void GlobalObject::initialize_global_object()
|
||||
void GlobalObject::initialize_global_object(Realm& realm)
|
||||
{
|
||||
Base::initialize_global_object();
|
||||
Base::initialize_global_object(realm);
|
||||
|
||||
auto& realm = *associated_realm();
|
||||
m_$262 = vm().heap().allocate<$262Object>(realm, realm);
|
||||
|
||||
// https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@ public:
|
|||
: JS::GlobalObject(realm)
|
||||
{
|
||||
}
|
||||
virtual void initialize_global_object() override;
|
||||
virtual void initialize_global_object(Realm&) override;
|
||||
virtual ~GlobalObject() override = default;
|
||||
|
||||
$262Object* $262() const { return m_$262; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue