1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

LibJS: Let Shape store a Realm instead of a GlobalObject

This is a cautious first step towards being able to create JS objects
before a global object has been instantiated.
This commit is contained in:
Andreas Kling 2022-08-01 20:27:20 +02:00
parent 7a6935a2ff
commit 50d951aea2
22 changed files with 104 additions and 55 deletions

View file

@ -34,15 +34,21 @@ Object* Object::create(GlobalObject& global_object, Object* prototype)
return global_object.heap().allocate<Object>(global_object, *prototype);
}
Object::Object(GlobalObjectTag)
GlobalObject& Object::global_object() const
{
return *shape().global_object();
}
Object::Object(GlobalObjectTag, Realm& realm)
{
// This is the global object
m_shape = heap().allocate_without_global_object<Shape>(*this);
m_shape = heap().allocate_without_global_object<Shape>(realm);
}
Object::Object(ConstructWithoutPrototypeTag, GlobalObject& global_object)
{
m_shape = heap().allocate_without_global_object<Shape>(global_object);
VERIFY(global_object.associated_realm());
m_shape = heap().allocate_without_global_object<Shape>(*global_object.associated_realm());
}
Object::Object(GlobalObject& global_object, Object* prototype)