1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:18:11 +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:
Andreas Kling 2020-04-17 18:24:01 +02:00
parent ee5816b9c8
commit 2d7b495244
7 changed files with 23 additions and 12 deletions

View file

@ -46,11 +46,11 @@ ArrayConstructor::~ArrayConstructor()
Value ArrayConstructor::call(Interpreter& interpreter)
{
if (interpreter.argument_count() == 0)
return interpreter.heap().allocate<Array>();
if (interpreter.argument_count() <= 0)
return Array::create(interpreter.global_object());
if (interpreter.argument_count() == 1) {
auto* array = interpreter.heap().allocate<Array>();
auto* array = Array::create(interpreter.global_object());
array->elements().resize(interpreter.argument(0).to_i32());
return array;
}