summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/AST.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-28 16:40:36 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-28 16:40:36 +0100
commit37fe16a99cd9ce31d6dba0b916be67929ae010a3 (patch)
treeb72242747c15658165c7fed2495e4ed56a0b3b25 /Libraries/LibJS/AST.cpp
parent0593ce406b588e5bf76440bdf56eeb04bbe12ec9 (diff)
downloadserenity-37fe16a99cd9ce31d6dba0b916be67929ae010a3.zip
LibJS: Add Function.prototype and make "new" Objects delegate to it
Diffstat (limited to 'Libraries/LibJS/AST.cpp')
-rw-r--r--Libraries/LibJS/AST.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp
index d5f8da6323..196901851d 100644
--- a/Libraries/LibJS/AST.cpp
+++ b/Libraries/LibJS/AST.cpp
@@ -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()) {