1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00
ladybird/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h
Linus Groh 7c468b5a77 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.
2022-08-23 13:58:30 +01:00

35 lines
730 B
C++

/*
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Contrib/Test262/$262Object.h>
#include <LibJS/Runtime/GlobalObject.h>
namespace JS::Test262 {
class GlobalObject final : public JS::GlobalObject {
JS_OBJECT(GlobalObject, JS::GlobalObject);
public:
GlobalObject(JS::Realm& realm)
: JS::GlobalObject(realm)
{
}
virtual void initialize_global_object(Realm&) override;
virtual ~GlobalObject() override = default;
$262Object* $262() const { return m_$262; }
private:
virtual void visit_edges(Visitor&) override;
$262Object* m_$262 { nullptr };
JS_DECLARE_NATIVE_FUNCTION(print);
};
}