summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Runtime/Array.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibJS/Runtime/Array.cpp')
-rw-r--r--Libraries/LibJS/Runtime/Array.cpp41
1 files changed, 5 insertions, 36 deletions
diff --git a/Libraries/LibJS/Runtime/Array.cpp b/Libraries/LibJS/Runtime/Array.cpp
index 019697fe74..e779630c2c 100644
--- a/Libraries/LibJS/Runtime/Array.cpp
+++ b/Libraries/LibJS/Runtime/Array.cpp
@@ -43,52 +43,21 @@ Array::~Array()
Value Array::shift()
{
- if (m_elements.size() == 0)
+ if (elements().size() == 0)
return js_undefined();
- return Value(m_elements.take_first());
+ return Value(elements().take_first());
}
Value Array::pop()
{
- if (m_elements.size() == 0)
+ if (elements().size() == 0)
return js_undefined();
- return Value(m_elements.take_last());
+ return Value(elements().take_last());
}
void Array::push(Value value)
{
- m_elements.append(value);
-}
-
-void Array::visit_children(Cell::Visitor& visitor)
-{
- Object::visit_children(visitor);
- for (auto& element : m_elements)
- visitor.visit(element);
-}
-
-Optional<Value> Array::get_own_property(const Object& this_object, const FlyString& property_name) const
-{
- bool ok;
- i32 index = property_name.to_int(ok);
- if (ok) {
- if (index >= 0 && index < length())
- return m_elements[index];
- }
- return Object::get_own_property(this_object, property_name);
-}
-
-bool Array::put_own_property(Object& this_object, const FlyString& property_name, Value value)
-{
- bool ok;
- i32 index = property_name.to_int(ok);
- if (ok && index >= 0) {
- if (index >= length())
- m_elements.resize(index + 1);
- m_elements[index] = value;
- return true;
- }
- return Object::put_own_property(this_object, property_name, value);
+ elements().append(value);
}
Value Array::length_getter(Interpreter& interpreter)