1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 10:44:57 +00:00

LibJS: Add Function.prototype and make "new" Objects delegate to it

This commit is contained in:
Andreas Kling 2020-03-28 16:40:36 +01:00
parent 0593ce406b
commit 37fe16a99c
2 changed files with 6 additions and 0 deletions

View file

@ -83,6 +83,9 @@ Value CallExpression::execute(Interpreter& interpreter) const
Object* new_object = nullptr;
if (is_new_expression()) {
new_object = interpreter.heap().allocate<Object>();
auto prototype = function->get("prototype");
if (prototype.has_value() && prototype.value().is_object())
new_object->set_prototype(prototype.value().as_object());
call_frame.this_value = new_object;
} else {
if (m_callee->is_member_expression()) {