diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-26 13:53:40 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-26 15:51:07 +0200 |
commit | f897c410927817050c9f98081d45a32e893e6d73 (patch) | |
tree | 1b45402c82e1785b649d29c3252f1df9bdceb677 /Libraries/LibJS/Runtime/Shape.h | |
parent | 1617be1e6f1bb356ce1ae08d5443795a9c5f2f33 (diff) | |
download | serenity-f897c410927817050c9f98081d45a32e893e6d73.zip |
LibJS: Implement basic support for the "delete" operator
It turns out "delete" is actually a unary op :)
This patch implements deletion of object properties, it doesn't yet
work for casually deleting properties from the global object.
When deleting a property from an object, we switch that object to
having a unique shape, no longer sharing shapes with others.
Once an object has a unique shape, it no longer needs to care about
shape transitions.
Diffstat (limited to 'Libraries/LibJS/Runtime/Shape.h')
-rw-r--r-- | Libraries/LibJS/Runtime/Shape.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Libraries/LibJS/Runtime/Shape.h b/Libraries/LibJS/Runtime/Shape.h index 70c75fef78..26c8eb574b 100644 --- a/Libraries/LibJS/Runtime/Shape.h +++ b/Libraries/LibJS/Runtime/Shape.h @@ -78,6 +78,9 @@ public: Shape* create_configure_transition(const FlyString& name, u8 attributes); Shape* create_prototype_transition(Object* new_prototype); + bool is_unique() const { return m_unique; } + Shape* create_unique_clone() const; + Object* prototype() { return m_prototype; } const Object* prototype() const { return m_prototype; } @@ -87,6 +90,10 @@ public: void set_prototype_without_transition(Object* new_prototype) { m_prototype = new_prototype; } + void remove_property_from_unique_shape(const FlyString&, size_t offset); + void add_property_to_unique_shape(const FlyString&, u8 attributes); + void reconfigure_property_in_unique_shape(const FlyString& property_name, u8 attributes); + private: virtual const char* class_name() const override { return "Shape"; } virtual void visit_children(Visitor&) override; @@ -99,6 +106,7 @@ private: Shape* m_previous { nullptr }; FlyString m_property_name; u8 m_attributes { 0 }; + bool m_unique { false }; Object* m_prototype { nullptr }; TransitionType m_transition_type { TransitionType::Invalid }; }; |