diff options
author | Jack Karamanian <karamanian.jack@gmail.com> | 2020-04-19 14:51:17 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-21 12:23:07 +0200 |
commit | b3800829daad3d3bae0fce63739686baae37251f (patch) | |
tree | 0a3021db40290d065eaa7077778b7a94436e2cd8 /Libraries/LibJS/AST.cpp | |
parent | 5750edd859a375a7a8e8f1e5d1131b3d92502fcc (diff) | |
download | serenity-b3800829daad3d3bae0fce63739686baae37251f.zip |
LibJS: Prepend callee's bound arguments to the CallFrame and set the
this_value to the callee's bound |this| in CallExpression::execute()
Diffstat (limited to 'Libraries/LibJS/AST.cpp')
-rw-r--r-- | Libraries/LibJS/AST.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp index 87989e47bf..4801583890 100644 --- a/Libraries/LibJS/AST.cpp +++ b/Libraries/LibJS/AST.cpp @@ -114,6 +114,9 @@ Value CallExpression::execute(Interpreter& interpreter) const auto& function = static_cast<Function&>(callee.as_object()); MarkedValueList arguments(interpreter.heap()); + for (auto bound_argument : function.bound_arguments()) { + arguments.append(bound_argument); + } for (size_t i = 0; i < m_arguments.size(); ++i) { auto value = m_arguments[i].execute(interpreter); if (interpreter.exception()) @@ -138,7 +141,7 @@ Value CallExpression::execute(Interpreter& interpreter) const call_frame.this_value = new_object; result = function.construct(interpreter); } else { - call_frame.this_value = this_value; + call_frame.this_value = function.bound_this().value_or(this_value); result = function.call(interpreter); } |