1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:17:34 +00:00

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.
This commit is contained in:
Andreas Kling 2020-04-26 13:53:40 +02:00
parent 1617be1e6f
commit f897c41092
9 changed files with 190 additions and 8 deletions

View file

@ -46,6 +46,8 @@ public:
Shape& shape() { return *m_shape; }
const Shape& shape() const { return *m_shape; }
Value delete_property(PropertyName);
virtual Value get_by_index(i32 property_index) const;
Value get(const FlyString& property_name) const;
Value get(PropertyName) const;
@ -102,6 +104,7 @@ public:
private:
void set_shape(Shape&);
void ensure_shape_is_unique();
Shape* m_shape { nullptr };
Vector<Value> m_storage;