summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Runtime/Array.h
diff options
context:
space:
mode:
authorMatthew Olsson <matthewcolsson@gmail.com>2020-05-27 11:35:09 -0700
committerAndreas Kling <kling@serenityos.org>2020-05-28 17:17:13 +0200
commit5ae9419a069f8180197df14447b1a23f1cf9411d (patch)
treeeee7680898e6520632343d36a32ac05c82f4614b /Libraries/LibJS/Runtime/Array.h
parentcc54974431abe402d4c6ac3c50df3b6d4353d507 (diff)
downloadserenity-5ae9419a069f8180197df14447b1a23f1cf9411d.zip
LibJS: Object index properties have descriptors; Handle sparse indices
This patch adds an IndexedProperties object for storing indexed properties within an Object. This accomplishes two goals: indexed properties now have an associated descriptor, and objects now gracefully handle sparse properties. The IndexedProperties class is a wrapper around two other classes, one for simple indexed properties storage, and one for general indexed property storage. Simple indexed property storage is the common-case, and is simply a vector of properties which all have attributes of default_attributes (writable, enumerable, and configurable). General indexed property storage is for a collection of indexed properties where EITHER one or more properties have attributes other than default_attributes OR there is a property with a large index (in particular, large is '200' or higher). Indexed properties are now treated relatively the same as storage within the various Object methods. Additionally, there is a custom iterator class for IndexedProperties which makes iteration easy. The iterator skips empty values by default, but can be configured otherwise. Likewise, it evaluates getters by default, but can be set not to.
Diffstat (limited to 'Libraries/LibJS/Runtime/Array.h')
-rw-r--r--Libraries/LibJS/Runtime/Array.h2
1 files changed, 0 insertions, 2 deletions
diff --git a/Libraries/LibJS/Runtime/Array.h b/Libraries/LibJS/Runtime/Array.h
index 6b580b2889..a45ac0e9eb 100644
--- a/Libraries/LibJS/Runtime/Array.h
+++ b/Libraries/LibJS/Runtime/Array.h
@@ -39,8 +39,6 @@ public:
explicit Array(Object& prototype);
virtual ~Array() override;
- i32 length() const { return static_cast<i32>(elements().size()); }
-
private:
virtual const char* class_name() const override { return "Array"; }
virtual bool is_array() const override { return true; }