LibJS: Make Array constructor take its prototype

Let's start moving towards native JS objects taking their prototype as
a constructor argument.

This will eventually allow us to move prototypes off of Interpreter and
into GlobalObject.
This commit is contained in:
Andreas Kling 2020-04-17 18:24:01 +02:00
commit 2d7b495244
Notes: sideshowbarker 2024-07-19 07:31:46 +09:00
7 changed files with 23 additions and 12 deletions

View file

@ -27,13 +27,21 @@
#include <AK/Function.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/Array.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/ArrayPrototype.h>
#include <LibJS/Runtime/Error.h>
namespace JS {
Array::Array()
Array* Array::create(GlobalObject& global_object)
{
set_prototype(interpreter().array_prototype());
auto& interpreter = global_object.interpreter();
return interpreter.heap().allocate<Array>(*interpreter.array_prototype());
}
Array::Array(Object& prototype)
{
set_prototype(&prototype);
put_native_property("length", length_getter, length_setter);
}