diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index 4cd9deb70c..332f76d6e6 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -150,7 +150,7 @@ ThrowCompletionOr get_function_realm(GlobalObject& global_object, Functi auto& bound_function = static_cast(function); // a. Let target be obj.[[BoundTargetFunction]]. - auto& target = bound_function.target_function(); + auto& target = bound_function.bound_target_function(); // b. Return ? GetFunctionRealm(target). return get_function_realm(global_object, target); diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp index 7b2ba688c4..cbac8c5fa7 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp @@ -9,11 +9,11 @@ namespace JS { -BoundFunction::BoundFunction(GlobalObject& global_object, FunctionObject& target_function, Value bound_this, Vector arguments, i32 length, Object* constructor_prototype) +BoundFunction::BoundFunction(GlobalObject& global_object, FunctionObject& bound_target_function, Value bound_this, Vector arguments, i32 length, Object* constructor_prototype) : FunctionObject(bound_this, move(arguments), *global_object.function_prototype()) - , m_target_function(&target_function) + , m_bound_target_function(&bound_target_function) , m_constructor_prototype(constructor_prototype) - , m_name(String::formatted("bound {}", target_function.name())) + , m_name(String::formatted("bound {}", bound_target_function.name())) , m_length(length) { } @@ -31,7 +31,7 @@ BoundFunction::~BoundFunction() Value BoundFunction::call() { - return m_target_function->call(); + return m_bound_target_function->call(); } Value BoundFunction::construct(FunctionObject& new_target) @@ -41,18 +41,18 @@ Value BoundFunction::construct(FunctionObject& new_target) if (vm().exception()) return {}; } - return m_target_function->construct(new_target); + return m_bound_target_function->construct(new_target); } FunctionEnvironment* BoundFunction::create_environment(FunctionObject& function_being_invoked) { - return m_target_function->create_environment(function_being_invoked); + return m_bound_target_function->create_environment(function_being_invoked); } void BoundFunction::visit_edges(Visitor& visitor) { Base::visit_edges(visitor); - visitor.visit(m_target_function); + visitor.visit(m_bound_target_function); visitor.visit(m_constructor_prototype); } diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.h b/Userland/Libraries/LibJS/Runtime/BoundFunction.h index 7403b392a3..f183dd7b8b 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.h +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.h @@ -19,27 +19,18 @@ public: virtual ~BoundFunction(); virtual Value call() override; - virtual Value construct(FunctionObject& new_target) override; - virtual FunctionEnvironment* create_environment(FunctionObject&) override; + virtual const FlyString& name() const override { return m_name; } + virtual bool is_strict_mode() const override { return m_bound_target_function->is_strict_mode(); } - virtual void visit_edges(Visitor&) override; - - virtual const FlyString& name() const override - { - return m_name; - } - - FunctionObject& target_function() const - { - return *m_target_function; - } - - virtual bool is_strict_mode() const override { return m_target_function->is_strict_mode(); } + FunctionObject& bound_target_function() const { return *m_bound_target_function; } private: - FunctionObject* m_target_function { nullptr }; + virtual void visit_edges(Visitor&) override; + + FunctionObject* m_bound_target_function { nullptr }; // [[BoundTargetFunction]] + Object* m_constructor_prototype { nullptr }; FlyString m_name; i32 m_length { 0 }; diff --git a/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp index 3004a004e2..0d6f844857 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp @@ -30,7 +30,7 @@ FunctionObject::~FunctionObject() BoundFunction* FunctionObject::bind(Value bound_this_value, Vector arguments) { auto& vm = this->vm(); - FunctionObject& target_function = is(*this) ? static_cast(*this).target_function() : *this; + FunctionObject& target_function = is(*this) ? static_cast(*this).bound_target_function() : *this; auto bound_this_object = [&vm, bound_this_value, this]() -> Value { if (!m_bound_this.is_empty()) diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index 08ae93bbb3..390cd79357 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -677,7 +677,7 @@ ThrowCompletionOr VM::call_internal(FunctionObject& function, Value this_ MarkedValueList with_bound_arguments { heap() }; append_bound_and_passed_arguments(with_bound_arguments, bound_function.bound_arguments(), move(arguments)); - return call_internal(bound_function.target_function(), bound_function.bound_this(), move(with_bound_arguments)); + return call_internal(bound_function.bound_target_function(), bound_function.bound_this(), move(with_bound_arguments)); } // FIXME: prepare_for_ordinary_call() is not supposed to receive a BoundFunction, ProxyObject, etc. - ever. diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 29d5de6736..a32565fa55 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -236,7 +236,7 @@ bool Value::is_constructor() const if (is(as_object())) return static_cast(as_object()).has_constructor(); if (is(as_object())) - return Value(&static_cast(as_object()).target_function()).is_constructor(); + return Value(&static_cast(as_object()).bound_target_function()).is_constructor(); // ECMAScriptFunctionObject return true; } @@ -1310,7 +1310,7 @@ Value ordinary_has_instance(GlobalObject& global_object, Value lhs, Value rhs) if (is(rhs_function)) { auto& bound_target = static_cast(rhs_function); - return instance_of(global_object, lhs, Value(&bound_target.target_function())); + return instance_of(global_object, lhs, Value(&bound_target.bound_target_function())); } if (!lhs.is_object())