diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index a6b97aa4a5..fec35d2b63 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -25,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -68,8 +68,8 @@ 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()) - static_cast(function).set_name(name); + if (is(function) && function.name().is_empty()) + static_cast(function).set_name(name); } static String get_function_name(GlobalObject& global_object, Value value) @@ -111,7 +111,7 @@ Value FunctionExpression::execute(Interpreter& interpreter, GlobalObject& global func_env->create_immutable_binding(global_object, name(), false); } - auto closure = OrdinaryFunctionObject::create(global_object, name(), body(), parameters(), function_length(), func_env, kind(), is_strict_mode(), is_arrow_function()); + auto closure = ECMAScriptFunctionObject::create(global_object, name(), body(), parameters(), function_length(), func_env, kind(), is_strict_mode(), is_arrow_function()); if (has_identifier) func_env->initialize_binding(global_object, name(), closure); @@ -874,8 +874,8 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob update_function_name(class_constructor_value, m_name); - VERIFY(class_constructor_value.is_function() && is(class_constructor_value.as_function())); - auto* class_constructor = static_cast(&class_constructor_value.as_function()); + VERIFY(class_constructor_value.is_function() && is(class_constructor_value.as_function())); + auto* class_constructor = static_cast(&class_constructor_value.as_function()); class_constructor->set_is_class_constructor(); Value super_constructor = js_undefined(); if (!m_super_class.is_null()) { @@ -970,7 +970,7 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob auto copy_initializer = field.initializer(); auto body = create_ast_node(field.initializer()->source_range(), copy_initializer.release_nonnull()); // FIXME: A potential optimization is not creating the functions here since these are never directly accessible. - initializer = OrdinaryFunctionObject::create(interpreter.global_object(), property_key.to_display_string(), *body, {}, 0, interpreter.lexical_environment(), FunctionKind::Regular, false); + initializer = ECMAScriptFunctionObject::create(interpreter.global_object(), property_key.to_display_string(), *body, {}, 0, interpreter.lexical_environment(), FunctionKind::Regular, false); initializer->set_home_object(field.is_static() ? class_constructor : &class_prototype.as_object()); } diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index dc92b4ba71..3da278f1b1 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -12,10 +12,10 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -318,7 +318,7 @@ void Call::execute_impl(Bytecode::Interpreter& interpreter) const void NewFunction::execute_impl(Bytecode::Interpreter& interpreter) const { auto& vm = interpreter.vm(); - interpreter.accumulator() = OrdinaryFunctionObject::create(interpreter.global_object(), m_function_node.name(), m_function_node.body(), m_function_node.parameters(), m_function_node.function_length(), vm.lexical_environment(), m_function_node.kind(), m_function_node.is_strict_mode(), m_function_node.is_arrow_function()); + interpreter.accumulator() = ECMAScriptFunctionObject::create(interpreter.global_object(), m_function_node.name(), m_function_node.body(), m_function_node.parameters(), m_function_node.function_length(), vm.lexical_environment(), m_function_node.kind(), m_function_node.is_strict_mode(), m_function_node.is_arrow_function()); } void Return::execute_impl(Bytecode::Interpreter& interpreter) const diff --git a/Userland/Libraries/LibJS/CMakeLists.txt b/Userland/Libraries/LibJS/CMakeLists.txt index 35330bfdba..90eaadd0c9 100644 --- a/Userland/Libraries/LibJS/CMakeLists.txt +++ b/Userland/Libraries/LibJS/CMakeLists.txt @@ -53,6 +53,7 @@ set(SOURCES Runtime/DateConstructor.cpp Runtime/DatePrototype.cpp Runtime/DeclarativeEnvironment.cpp + Runtime/ECMAScriptFunctionObject.cpp Runtime/Environment.cpp Runtime/Error.cpp Runtime/ErrorConstructor.cpp @@ -105,7 +106,6 @@ set(SOURCES Runtime/ObjectConstructor.cpp Runtime/ObjectEnvironment.cpp Runtime/ObjectPrototype.cpp - Runtime/OrdinaryFunctionObject.cpp Runtime/PrimitiveString.cpp Runtime/Promise.cpp Runtime/PromiseConstructor.cpp diff --git a/Userland/Libraries/LibJS/Interpreter.cpp b/Userland/Libraries/LibJS/Interpreter.cpp index bbf5282323..0d7ff1a346 100644 --- a/Userland/Libraries/LibJS/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Interpreter.cpp @@ -8,10 +8,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -100,7 +100,7 @@ void Interpreter::enter_scope(const ScopeNode& scope_node, ScopeType scope_type, lexical_environment()->put_into_environment(declaration.name(), { js_undefined(), DeclarationKind::Var }); } for (auto& declaration : scope_node.functions()) { - auto* function = OrdinaryFunctionObject::create(global_object, declaration.name(), declaration.body(), declaration.parameters(), declaration.function_length(), lexical_environment(), declaration.kind(), declaration.is_strict_mode()); + auto* function = ECMAScriptFunctionObject::create(global_object, declaration.name(), declaration.body(), declaration.parameters(), declaration.function_length(), lexical_environment(), declaration.kind(), declaration.is_strict_mode()); vm().set_variable(declaration.name(), function, global_object); } }); diff --git a/Userland/Libraries/LibJS/Runtime/OrdinaryFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp similarity index 87% rename from Userland/Libraries/LibJS/Runtime/OrdinaryFunctionObject.cpp rename to Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index 6d4fd0e5d0..9de4b5050e 100644 --- a/Userland/Libraries/LibJS/Runtime/OrdinaryFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -12,18 +12,18 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include namespace JS { -OrdinaryFunctionObject* OrdinaryFunctionObject::create(GlobalObject& global_object, const FlyString& name, const Statement& body, Vector parameters, i32 m_function_length, Environment* parent_scope, FunctionKind kind, bool is_strict, bool is_arrow_function) +ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(GlobalObject& global_object, const FlyString& name, const Statement& body, Vector parameters, i32 m_function_length, Environment* parent_scope, FunctionKind kind, bool is_strict, bool is_arrow_function) { Object* prototype = nullptr; switch (kind) { @@ -34,10 +34,10 @@ OrdinaryFunctionObject* OrdinaryFunctionObject::create(GlobalObject& global_obje prototype = global_object.generator_function_prototype(); break; } - return global_object.heap().allocate(global_object, global_object, name, body, move(parameters), m_function_length, parent_scope, *prototype, kind, is_strict, is_arrow_function); + return global_object.heap().allocate(global_object, global_object, name, body, move(parameters), m_function_length, parent_scope, *prototype, kind, is_strict, is_arrow_function); } -OrdinaryFunctionObject::OrdinaryFunctionObject(GlobalObject& global_object, const FlyString& name, const Statement& body, Vector parameters, i32 function_length, Environment* parent_scope, Object& prototype, FunctionKind kind, bool is_strict, bool is_arrow_function) +ECMAScriptFunctionObject::ECMAScriptFunctionObject(GlobalObject& global_object, const FlyString& name, const Statement& body, Vector parameters, i32 function_length, Environment* parent_scope, Object& prototype, FunctionKind kind, bool is_strict, bool is_arrow_function) : FunctionObject(is_arrow_function ? vm().this_value(global_object) : Value(), {}, prototype) , m_name(name) , m_body(body) @@ -69,7 +69,7 @@ OrdinaryFunctionObject::OrdinaryFunctionObject(GlobalObject& global_object, cons })); } -void OrdinaryFunctionObject::initialize(GlobalObject& global_object) +void ECMAScriptFunctionObject::initialize(GlobalObject& global_object) { auto& vm = this->vm(); Base::initialize(global_object); @@ -90,18 +90,18 @@ void OrdinaryFunctionObject::initialize(GlobalObject& global_object) define_property_or_throw(vm.names.name, { .value = js_string(vm, m_name.is_null() ? "" : m_name), .writable = false, .enumerable = false, .configurable = true }); } -OrdinaryFunctionObject::~OrdinaryFunctionObject() +ECMAScriptFunctionObject::~ECMAScriptFunctionObject() { } -void OrdinaryFunctionObject::visit_edges(Visitor& visitor) +void ECMAScriptFunctionObject::visit_edges(Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_environment); visitor.visit(m_realm); } -FunctionEnvironment* OrdinaryFunctionObject::create_environment(FunctionObject& function_being_invoked) +FunctionEnvironment* ECMAScriptFunctionObject::create_environment(FunctionObject& function_being_invoked) { HashMap variables; for (auto& parameter : m_parameters) { @@ -140,7 +140,7 @@ FunctionEnvironment* OrdinaryFunctionObject::create_environment(FunctionObject& return environment; } -Value OrdinaryFunctionObject::execute_function_body() +Value ECMAScriptFunctionObject::execute_function_body() { auto& vm = this->vm(); @@ -217,7 +217,7 @@ Value OrdinaryFunctionObject::execute_function_body() } } -Value OrdinaryFunctionObject::call() +Value ECMAScriptFunctionObject::call() { if (m_is_class_constructor) { vm().throw_exception(global_object(), ErrorType::ClassConstructorWithoutNew, m_name); @@ -226,7 +226,7 @@ Value OrdinaryFunctionObject::call() return execute_function_body(); } -Value OrdinaryFunctionObject::construct(FunctionObject&) +Value ECMAScriptFunctionObject::construct(FunctionObject&) { if (m_is_arrow_function || m_kind == FunctionKind::Generator) { vm().throw_exception(global_object(), ErrorType::NotAConstructor, m_name); @@ -235,7 +235,7 @@ Value OrdinaryFunctionObject::construct(FunctionObject&) return execute_function_body(); } -void OrdinaryFunctionObject::set_name(const FlyString& name) +void ECMAScriptFunctionObject::set_name(const FlyString& name) { VERIFY(!name.is_null()); auto& vm = this->vm(); diff --git a/Userland/Libraries/LibJS/Runtime/OrdinaryFunctionObject.h b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h similarity index 65% rename from Userland/Libraries/LibJS/Runtime/OrdinaryFunctionObject.h rename to Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h index 4b0a782844..9c3d73781c 100644 --- a/Userland/Libraries/LibJS/Runtime/OrdinaryFunctionObject.h +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h @@ -12,15 +12,16 @@ namespace JS { -class OrdinaryFunctionObject final : public FunctionObject { - JS_OBJECT(OrdinaryFunctionObject, FunctionObject); +// 10.2 ECMAScript Function Objects, https://tc39.es/ecma262/#sec-ecmascript-function-objects +class ECMAScriptFunctionObject final : public FunctionObject { + JS_OBJECT(ECMAScriptFunctionObject, FunctionObject); public: - static OrdinaryFunctionObject* create(GlobalObject&, const FlyString& name, const Statement& body, Vector parameters, i32 m_function_length, Environment* parent_scope, FunctionKind, bool is_strict, bool is_arrow_function = false); + static ECMAScriptFunctionObject* create(GlobalObject&, const FlyString& name, const Statement& body, Vector parameters, i32 m_function_length, Environment* parent_scope, FunctionKind, bool is_strict, bool is_arrow_function = false); - OrdinaryFunctionObject(GlobalObject&, const FlyString& name, const Statement& body, Vector parameters, i32 m_function_length, Environment* parent_scope, Object& prototype, FunctionKind, bool is_strict, bool is_arrow_function = false); + ECMAScriptFunctionObject(GlobalObject&, const FlyString& name, const Statement& body, Vector parameters, i32 m_function_length, Environment* parent_scope, Object& prototype, FunctionKind, bool is_strict, bool is_arrow_function = false); virtual void initialize(GlobalObject&) override; - virtual ~OrdinaryFunctionObject(); + virtual ~ECMAScriptFunctionObject(); const Statement& body() const { return m_body; } const Vector& parameters() const { return m_parameters; }; @@ -42,7 +43,7 @@ protected: virtual bool is_strict_mode() const final { return m_is_strict; } private: - virtual bool is_ordinary_function_object() const override { return true; } + virtual bool is_ecmascript_function_object() const override { return true; } virtual FunctionEnvironment* create_environment(FunctionObject&) override; virtual void visit_edges(Visitor&) override; diff --git a/Userland/Libraries/LibJS/Runtime/FunctionObject.h b/Userland/Libraries/LibJS/Runtime/FunctionObject.h index dce1c3ea99..3d4f53073a 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionObject.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionObject.h @@ -11,7 +11,6 @@ namespace JS { -// 10.2 ECMAScript Function Objects, https://tc39.es/ecma262/#sec-ecmascript-function-objects class FunctionObject : public Object { JS_OBJECT(Function, Object); diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index 295dd1b3c2..72f0f06422 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -9,13 +9,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include namespace JS { @@ -117,11 +117,11 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::to_string) String function_parameters; String function_body; - if (is(this_object)) { - auto& ordinary_function = static_cast(*this_object); + if (is(this_object)) { + auto& function = static_cast(*this_object); StringBuilder parameters_builder; auto first = true; - for (auto& parameter : ordinary_function.parameters()) { + for (auto& parameter : function.parameters()) { // FIXME: Also stringify binding patterns. if (auto* name_ptr = parameter.binding.get_pointer()) { if (!first) @@ -134,10 +134,10 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::to_string) } } } - function_name = ordinary_function.name(); + function_name = function.name(); function_parameters = parameters_builder.build(); // FIXME: ASTNodes should be able to dump themselves to source strings - something like this: - // auto& body = static_cast(this_object)->body(); + // auto& body = static_cast(this_object)->body(); // function_body = body.to_source(); function_body = " ???"; } else { diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp index 849ed24317..721762bd86 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp @@ -9,10 +9,10 @@ #include #include #include +#include #include #include #include -#include namespace JS { @@ -62,7 +62,7 @@ Value GeneratorFunctionConstructor::construct(FunctionObject& new_target) block.dump(executable); } - return OrdinaryFunctionObject::create(global_object(), function->name(), function->body(), function->parameters(), function->function_length(), vm().lexical_environment(), FunctionKind::Generator, function->is_strict_mode(), false); + return ECMAScriptFunctionObject::create(global_object(), function->name(), function->body(), function->parameters(), function->function_length(), vm().lexical_environment(), FunctionKind::Generator, function->is_strict_mode(), false); } } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp index 23853be5c6..0a0c0e3358 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp @@ -13,7 +13,7 @@ namespace JS { -GeneratorObject* GeneratorObject::create(GlobalObject& global_object, Value initial_value, OrdinaryFunctionObject* generating_function, Environment* generating_scope, Bytecode::RegisterWindow frame) +GeneratorObject* GeneratorObject::create(GlobalObject& global_object, Value initial_value, ECMAScriptFunctionObject* generating_function, Environment* generating_scope, Bytecode::RegisterWindow frame) { // This is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png) auto generating_function_proto_property = generating_function->get(global_object.vm().names.prototype).to_object(global_object); diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h index e0159ab9ab..341f4e9782 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h @@ -7,8 +7,8 @@ #pragma once #include +#include #include -#include namespace JS { @@ -16,7 +16,7 @@ class GeneratorObject final : public Object { JS_OBJECT(GeneratorObject, Object); public: - static GeneratorObject* create(GlobalObject&, Value, OrdinaryFunctionObject*, Environment*, Bytecode::RegisterWindow); + static GeneratorObject* create(GlobalObject&, Value, ECMAScriptFunctionObject*, Environment*, Bytecode::RegisterWindow); GeneratorObject(GlobalObject&, Object& prototype); virtual void initialize(GlobalObject&) override; virtual ~GeneratorObject() override; @@ -27,7 +27,7 @@ public: private: Environment* m_environment { nullptr }; - OrdinaryFunctionObject* m_generating_function { nullptr }; + ECMAScriptFunctionObject* m_generating_function { nullptr }; Value m_previous_value; Bytecode::RegisterWindow m_frame; bool m_done { false }; diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index 70d3dff18a..350876dfc6 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -136,7 +136,7 @@ public: virtual bool is_global_object() const { return false; } virtual bool is_proxy_object() const { return false; } virtual bool is_native_function() const { return false; } - virtual bool is_ordinary_function_object() const { return false; } + virtual bool is_ecmascript_function_object() const { return false; } // B.3.7 The [[IsHTMLDDA]] Internal Slot, https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot virtual bool is_htmldda() const { return false; } diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index 55d7b7e53a..5b33725171 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -377,7 +377,7 @@ Value VM::get_variable(const FlyString& name, GlobalObject& global_object) if (context.function->is_strict_mode() || !context.function->has_simple_parameter_list()) { context.arguments_object = create_unmapped_arguments_object(global_object, context.arguments.span()); } else { - context.arguments_object = create_mapped_arguments_object(global_object, *context.function, verify_cast(context.function)->parameters(), context.arguments.span(), *lexical_environment()); + context.arguments_object = create_mapped_arguments_object(global_object, *context.function, verify_cast(context.function)->parameters(), context.arguments.span(), *lexical_environment()); } } return context.arguments_object; @@ -479,7 +479,7 @@ Value VM::construct(FunctionObject& function, FunctionObject& new_target, Option this_argument = TRY_OR_DISCARD(ordinary_create_from_constructor(global_object, new_target, &GlobalObject::object_prototype)); // FIXME: prepare_for_ordinary_call() is not supposed to receive a BoundFunction, ProxyObject, etc. - ever. - // This needs to be moved to NativeFunction/OrdinaryFunctionObject's construct() (10.2.2 [[Construct]]) + // This needs to be moved to NativeFunction/ECMAScriptFunctionObject's construct() (10.2.2 [[Construct]]) ExecutionContext callee_context(heap()); prepare_for_ordinary_call(function, callee_context, &new_target); if (exception()) @@ -677,7 +677,7 @@ ThrowCompletionOr VM::call_internal(FunctionObject& function, Value this_ } // FIXME: prepare_for_ordinary_call() is not supposed to receive a BoundFunction, ProxyObject, etc. - ever. - // This needs to be moved to NativeFunction/OrdinaryFunctionObject's construct() (10.2.2 [[Construct]]) + // This needs to be moved to NativeFunction/ECMAScriptFunctionObject's construct() (10.2.2 [[Construct]]) ExecutionContext callee_context(heap()); prepare_for_ordinary_call(function, callee_context, nullptr); if (auto* exception = this->exception()) diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index bbb403361a..29d5de6736 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -237,7 +237,7 @@ bool Value::is_constructor() const return static_cast(as_object()).has_constructor(); if (is(as_object())) return Value(&static_cast(as_object()).target_function()).is_constructor(); - // OrdinaryFunctionObject + // ECMAScriptFunctionObject return true; } diff --git a/Userland/Libraries/LibJS/Tests/builtins/Symbol/Symbol.keyFor.js b/Userland/Libraries/LibJS/Tests/builtins/Symbol/Symbol.keyFor.js index 44404fde9d..7d2b867b5b 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Symbol/Symbol.keyFor.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Symbol/Symbol.keyFor.js @@ -15,7 +15,7 @@ test("bad argument values", () => { [{}, "[object Object]"], [true, "true"], ["foobar", "foobar"], - [function () {}, "[object OrdinaryFunctionObject]"], // FIXME: Better function stringification + [function () {}, "[object ECMAScriptFunctionObject]"], // FIXME: Better function stringification ].forEach(testCase => { expect(() => { Symbol.keyFor(testCase[0]); diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index 142a48d96b..18221d0363 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -133,7 +133,7 @@ void EventTarget::set_event_handler_attribute(FlyString const& name, HTML::Event dbgln("Failed to parse script in event handler attribute '{}'", name); return; } - auto* function = JS::OrdinaryFunctionObject::create(target->script_execution_context()->realm().global_object(), name, program->body(), program->parameters(), program->function_length(), nullptr, JS::FunctionKind::Regular, false, false); + auto* function = JS::ECMAScriptFunctionObject::create(target->script_execution_context()->realm().global_object(), name, program->body(), program->parameters(), program->function_length(), nullptr, JS::FunctionKind::Regular, false, false); VERIFY(function); listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast(function)))); } diff --git a/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp b/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp index b6a2bf1a6c..82a3cd5def 100644 --- a/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp +++ b/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibWeb/HTML/WebSocket.cpp b/Userland/Libraries/LibWeb/HTML/WebSocket.cpp index f3aabe91cf..2a067cb142 100644 --- a/Userland/Libraries/LibWeb/HTML/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/HTML/WebSocket.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 4d8ad054e7..6c0346021b 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -38,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -255,8 +255,8 @@ static void print_object(JS::Object& object, HashTable& seen_object static void print_function(JS::Object const& object, HashTable&) { print_type(object.class_name()); - if (is(object)) - out(" {}", static_cast(object).name()); + if (is(object)) + out(" {}", static_cast(object).name()); else if (is(object)) out(" {}", static_cast(object).name()); }