1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:27:43 +00:00

LibJS: Allow Shape without a global object

It would be nice to be able to cache some shapes globally in the VM,
but then they can't be tied to a specific global object. So let's just
get rid of the requirement that shapes are tied to a global object.
This commit is contained in:
Andreas Kling 2020-11-28 13:58:20 +01:00
parent d66087ac2f
commit 97a05ac9ac
3 changed files with 14 additions and 6 deletions

View file

@ -62,6 +62,9 @@ public:
Prototype,
};
enum class ShapeWithoutGlobalObjectTag { Tag };
explicit Shape(ShapeWithoutGlobalObjectTag);
explicit Shape(GlobalObject&);
Shape(Shape& previous_shape, const StringOrSymbol& property_name, PropertyAttributes attributes, TransitionType);
Shape(Shape& previous_shape, Object* new_prototype);
@ -75,7 +78,7 @@ public:
bool is_unique() const { return m_unique; }
Shape* create_unique_clone() const;
GlobalObject& global_object() const { return m_global_object; }
GlobalObject* global_object() const { return m_global_object; }
Object* prototype() { return m_prototype; }
const Object* prototype() const { return m_prototype; }
@ -107,7 +110,7 @@ private:
TransitionType m_transition_type : 6 { TransitionType::Invalid };
bool m_unique : 1 { false };
GlobalObject& m_global_object;
GlobalObject* m_global_object { nullptr };
mutable OwnPtr<HashMap<StringOrSymbol, PropertyMetadata>> m_property_table;