mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-27 03:37:53 +00:00
LibJS: Add ArrayPrototype and implement Array.prototype.push()
This function is ultimately supposed to be generic and allow any |this| that has a length property, but for now it only works on our own Array object type.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include <AK/Badge.h>
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/ArrayPrototype.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/NativeFunction.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
@@ -42,6 +43,7 @@ Interpreter::Interpreter()
|
||||
m_global_object = heap().allocate<GlobalObject>();
|
||||
m_object_prototype = heap().allocate<ObjectPrototype>();
|
||||
m_string_prototype = heap().allocate<StringPrototype>();
|
||||
m_array_prototype = heap().allocate<ArrayPrototype>();
|
||||
}
|
||||
|
||||
Interpreter::~Interpreter()
|
||||
@@ -143,6 +145,7 @@ void Interpreter::gather_roots(Badge<Heap>, HashTable<Cell*>& roots)
|
||||
roots.set(m_global_object);
|
||||
roots.set(m_string_prototype);
|
||||
roots.set(m_object_prototype);
|
||||
roots.set(m_array_prototype);
|
||||
|
||||
for (auto& scope : m_scope_stack) {
|
||||
for (auto& it : scope.variables) {
|
||||
|
||||
Reference in New Issue
Block a user