summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-06-27 20:57:39 +0100
committerLinus Groh <mail@linusgroh.de>2021-06-27 21:01:01 +0100
commitd7750999b3b1c5edefe6a70d00ae934045cdf562 (patch)
tree4f839fa0d1c9a3442431849ea2b99807e5b64951 /Userland/Libraries/LibJS
parent93bae37dd91d84df26a6ef78964888f87a996933 (diff)
downloadserenity-d7750999b3b1c5edefe6a70d00ae934045cdf562.zip
LibJS: Implement the TypedArray [[ContentType]] internal slot
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArray.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArray.h7
2 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
index 8a2f0ee895..f42bc1fa3b 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
@@ -204,6 +204,10 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
ClassName::ClassName(u32 length, Object& prototype) \
: TypedArray(length, prototype) \
{ \
+ if constexpr (StringView { #ClassName }.is_one_of("BigInt64Array", "BigUint64Array")) \
+ m_content_type = ContentType::BigInt; \
+ else \
+ m_content_type = ContentType::Number; \
} \
\
ClassName::~ClassName() { } \
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h
index c84a5cbe69..0ea87b77d5 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArray.h
+++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h
@@ -17,9 +17,15 @@ class TypedArrayBase : public Object {
JS_OBJECT(TypedArrayBase, Object);
public:
+ enum class ContentType {
+ BigInt,
+ Number,
+ };
+
u32 array_length() const { return m_array_length; }
u32 byte_length() const { return m_byte_length; }
u32 byte_offset() const { return m_byte_offset; }
+ ContentType content_type() const { return m_content_type; }
ArrayBuffer* viewed_array_buffer() const { return m_viewed_array_buffer; }
void set_array_length(u32 length) { m_array_length = length; }
@@ -39,6 +45,7 @@ protected:
u32 m_array_length { 0 };
u32 m_byte_length { 0 };
u32 m_byte_offset { 0 };
+ ContentType m_content_type { ContentType::Number };
ArrayBuffer* m_viewed_array_buffer { nullptr };
private: