summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Runtime/Object.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-04-26 13:53:40 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-26 15:51:07 +0200
commitf897c410927817050c9f98081d45a32e893e6d73 (patch)
tree1b45402c82e1785b649d29c3252f1df9bdceb677 /Libraries/LibJS/Runtime/Object.h
parent1617be1e6f1bb356ce1ae08d5443795a9c5f2f33 (diff)
downloadserenity-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/Object.h')
-rw-r--r--Libraries/LibJS/Runtime/Object.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/Libraries/LibJS/Runtime/Object.h b/Libraries/LibJS/Runtime/Object.h
index 0b0ccc4fcc..5c945ea888 100644
--- a/Libraries/LibJS/Runtime/Object.h
+++ b/Libraries/LibJS/Runtime/Object.h
@@ -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;