mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
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:
parent
ee5816b9c8
commit
2d7b495244
7 changed files with 23 additions and 12 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue