diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp index 7e11a1d6bd6..1f0a40b8273 100644 --- a/Libraries/LibJS/AST.cpp +++ b/Libraries/LibJS/AST.cpp @@ -69,7 +69,7 @@ static void update_function_name(Value value, FlyString const& name) if (!value.is_function()) return; auto& function = value.as_function(); - if (is(function) && function.name().is_empty()) + if (is(function) && static_cast(function).name().is_empty()) static_cast(function).set_name(name); } diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index dea70a0957c..9e22a199a7b 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -1212,14 +1212,14 @@ inline ThrowCompletionOr put_by_property_key(VM& vm, Value base, Value thi switch (kind) { case Op::PropertyKind::Getter: { auto& function = value.as_function(); - if (function.name().is_empty() && is(function)) + if (is(function) && static_cast(function).name().is_empty()) static_cast(&function)->set_name(MUST(String::formatted("get {}", name))); object->define_direct_accessor(name, &function, nullptr, Attribute::Configurable | Attribute::Enumerable); break; } case Op::PropertyKind::Setter: { auto& function = value.as_function(); - if (function.name().is_empty() && is(function)) + if (is(function) && static_cast(function).name().is_empty()) static_cast(&function)->set_name(MUST(String::formatted("set {}", name))); object->define_direct_accessor(name, nullptr, &function, Attribute::Configurable | Attribute::Enumerable); break; diff --git a/Libraries/LibJS/Runtime/BoundFunction.cpp b/Libraries/LibJS/Runtime/BoundFunction.cpp index 0f799289b34..a8d4be7df0b 100644 --- a/Libraries/LibJS/Runtime/BoundFunction.cpp +++ b/Libraries/LibJS/Runtime/BoundFunction.cpp @@ -39,8 +39,6 @@ BoundFunction::BoundFunction(Realm& realm, FunctionObject& bound_target_function , m_bound_target_function(&bound_target_function) , m_bound_this(bound_this) , m_bound_arguments(move(bound_arguments)) - // FIXME: Non-standard and redundant, remove. - , m_name(MUST(String::formatted("bound {}", bound_target_function.name()))) { } diff --git a/Libraries/LibJS/Runtime/BoundFunction.h b/Libraries/LibJS/Runtime/BoundFunction.h index 7c48ebf4eed..9f90e3e7779 100644 --- a/Libraries/LibJS/Runtime/BoundFunction.h +++ b/Libraries/LibJS/Runtime/BoundFunction.h @@ -23,7 +23,6 @@ public: virtual ThrowCompletionOr internal_call(Value this_argument, ReadonlySpan arguments_list) override; virtual ThrowCompletionOr> internal_construct(ReadonlySpan arguments_list, FunctionObject& new_target) override; - virtual FlyString const& name() const override { return m_name; } virtual bool is_strict_mode() const override { return m_bound_target_function->is_strict_mode(); } virtual bool has_constructor() const override { return m_bound_target_function->has_constructor(); } @@ -39,8 +38,6 @@ private: GC::Ptr m_bound_target_function; // [[BoundTargetFunction]] Value m_bound_this; // [[BoundThis]] Vector m_bound_arguments; // [[BoundArguments]] - - FlyString m_name; }; } diff --git a/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h b/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h index 95b053996b1..47c6397d14b 100644 --- a/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h +++ b/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h @@ -127,7 +127,7 @@ public: Statement const& ecmascript_code() const { return *shared_data().m_ecmascript_code; } [[nodiscard]] virtual FunctionParameters const& formal_parameters() const override { return *shared_data().m_formal_parameters; } - virtual FlyString const& name() const override { return shared_data().m_name; } + FlyString const& name() const { return shared_data().m_name; } void set_name(FlyString const& name); void set_is_class_constructor() { const_cast(shared_data()).m_is_class_constructor = true; } diff --git a/Libraries/LibJS/Runtime/FunctionObject.h b/Libraries/LibJS/Runtime/FunctionObject.h index 6af855a0f30..5d94b9449fd 100644 --- a/Libraries/LibJS/Runtime/FunctionObject.h +++ b/Libraries/LibJS/Runtime/FunctionObject.h @@ -26,8 +26,6 @@ public: virtual ThrowCompletionOr internal_call(Value this_argument, ReadonlySpan arguments_list) = 0; virtual ThrowCompletionOr> internal_construct([[maybe_unused]] ReadonlySpan arguments_list, [[maybe_unused]] FunctionObject& new_target) { VERIFY_NOT_REACHED(); } - virtual FlyString const& name() const = 0; - void set_function_name(Variant const& name_arg, Optional const& prefix = {}); void set_function_length(double length); diff --git a/Libraries/LibJS/Runtime/FunctionPrototype.h b/Libraries/LibJS/Runtime/FunctionPrototype.h index e61e89fc7bd..493fcd53ca4 100644 --- a/Libraries/LibJS/Runtime/FunctionPrototype.h +++ b/Libraries/LibJS/Runtime/FunctionPrototype.h @@ -19,7 +19,6 @@ public: virtual ~FunctionPrototype() override = default; virtual ThrowCompletionOr internal_call(Value this_argument, ReadonlySpan arguments_list) override; - virtual FlyString const& name() const override { return m_name; } private: explicit FunctionPrototype(Realm&); @@ -29,9 +28,6 @@ private: JS_DECLARE_NATIVE_FUNCTION(call); JS_DECLARE_NATIVE_FUNCTION(to_string); JS_DECLARE_NATIVE_FUNCTION(symbol_has_instance); - - // 20.2.3: The Function prototype object has a "name" property whose value is the empty String. - FlyString m_name; }; } diff --git a/Libraries/LibJS/Runtime/NativeFunction.h b/Libraries/LibJS/Runtime/NativeFunction.h index 6fab066c68b..19875d56ad3 100644 --- a/Libraries/LibJS/Runtime/NativeFunction.h +++ b/Libraries/LibJS/Runtime/NativeFunction.h @@ -34,7 +34,7 @@ public: virtual ThrowCompletionOr call(); virtual ThrowCompletionOr> construct(FunctionObject& new_target); - virtual FlyString const& name() const override { return m_name; } + FlyString const& name() const { return m_name; } virtual bool is_strict_mode() const override; virtual bool has_constructor() const override { return false; } virtual Realm* realm() const override { return m_realm; } diff --git a/Libraries/LibJS/Runtime/ProxyObject.cpp b/Libraries/LibJS/Runtime/ProxyObject.cpp index 60762d8e254..318742043ed 100644 --- a/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -897,10 +897,4 @@ void ProxyObject::visit_edges(Cell::Visitor& visitor) visitor.visit(m_handler); } -FlyString const& ProxyObject::name() const -{ - VERIFY(is_function()); - return static_cast(*m_target).name(); -} - } diff --git a/Libraries/LibJS/Runtime/ProxyObject.h b/Libraries/LibJS/Runtime/ProxyObject.h index e1cf4e73d0b..e52cda49db1 100644 --- a/Libraries/LibJS/Runtime/ProxyObject.h +++ b/Libraries/LibJS/Runtime/ProxyObject.h @@ -21,7 +21,6 @@ public: virtual ~ProxyObject() override = default; - virtual FlyString const& name() const override; virtual bool has_constructor() const override; Object const& target() const { return m_target; } diff --git a/Libraries/LibJS/Runtime/WrappedFunction.h b/Libraries/LibJS/Runtime/WrappedFunction.h index 93291000794..d29e67db66a 100644 --- a/Libraries/LibJS/Runtime/WrappedFunction.h +++ b/Libraries/LibJS/Runtime/WrappedFunction.h @@ -22,9 +22,6 @@ public: virtual ThrowCompletionOr internal_call(Value this_argument, ReadonlySpan arguments_list) override; - // FIXME: Remove this (and stop inventing random internal slots that shouldn't exist, jeez) - virtual FlyString const& name() const override { return m_wrapped_target_function->name(); } - virtual Realm* realm() const override { return m_realm; } FunctionObject const& wrapped_target_function() const { return m_wrapped_target_function; }