diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-27 21:48:34 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-27 22:36:04 +0200 |
commit | ba9d5c4d54d2e58c14eafe1e8960c3832fac46c7 (patch) | |
tree | 975cef60a364e12fb5600555548bdb1f8565874e | |
parent | e389ae3c9754b0c6c40a383a666f103c42789630 (diff) | |
download | serenity-ba9d5c4d54d2e58c14eafe1e8960c3832fac46c7.zip |
LibJS: Rename Function => FunctionObject
114 files changed, 263 insertions, 262 deletions
diff --git a/Tests/LibWeb/test-web.cpp b/Tests/LibWeb/test-web.cpp index 17f39bb3b3..958c66dceb 100644 --- a/Tests/LibWeb/test-web.cpp +++ b/Tests/LibWeb/test-web.cpp @@ -66,7 +66,7 @@ TESTJS_GLOBAL_FUNCTION(after_initial_page_load, afterInitialPageLoad) } after_initial_load_hooks.append([fn = JS::make_handle(&function.as_function()), &vm](auto& page_object) { - [[maybe_unused]] auto unused = vm.call(const_cast<JS::Function&>(*fn.cell()), JS::js_undefined(), &page_object); + [[maybe_unused]] auto unused = vm.call(const_cast<JS::FunctionObject&>(*fn.cell()), JS::js_undefined(), &page_object); }); return JS::js_undefined(); } @@ -81,7 +81,7 @@ TESTJS_GLOBAL_FUNCTION(before_initial_page_load, beforeInitialPageLoad) } before_initial_load_hooks.append([fn = JS::make_handle(&function.as_function()), &vm](auto& page_object) { - [[maybe_unused]] auto unused = vm.call(const_cast<JS::Function&>(*fn.cell()), JS::js_undefined(), &page_object); + [[maybe_unused]] auto unused = vm.call(const_cast<JS::FunctionObject&>(*fn.cell()), JS::js_undefined(), &page_object); }); return JS::js_undefined(); } diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index df1dc07a12..9168bda722 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -18,7 +18,7 @@ #include <AK/URL.h> #include <LibCore/File.h> #include <LibJS/Parser.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <ctype.h> #include <unistd.h> diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index de997c6324..1d9660042b 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -237,7 +237,7 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj vm.throw_exception<TypeError>(global_object, ErrorType::NotAConstructor, "Super constructor"); return {}; } - result = vm.construct(static_cast<Function&>(*super_constructor), function, move(arguments)); + result = vm.construct(static_cast<FunctionObject&>(*super_constructor), function, move(arguments)); if (vm.exception()) return {}; @@ -773,7 +773,7 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::ClassExtendsValueNotAConstructorOrNull, super_constructor.to_string_without_side_effects()); return {}; } - class_constructor->set_constructor_kind(Function::ConstructorKind::Derived); + class_constructor->set_constructor_kind(FunctionObject::ConstructorKind::Derived); Object* super_constructor_prototype = nullptr; if (!super_constructor.is_null()) { diff --git a/Userland/Libraries/LibJS/CMakeLists.txt b/Userland/Libraries/LibJS/CMakeLists.txt index f5361080ab..ce2f02c4dd 100644 --- a/Userland/Libraries/LibJS/CMakeLists.txt +++ b/Userland/Libraries/LibJS/CMakeLists.txt @@ -60,8 +60,8 @@ set(SOURCES Runtime/FinalizationRegistryConstructor.cpp Runtime/FinalizationRegistryPrototype.cpp Runtime/FunctionConstructor.cpp - Runtime/Function.cpp Runtime/FunctionEnvironmentRecord.cpp + Runtime/FunctionObject.cpp Runtime/FunctionPrototype.cpp Runtime/GeneratorFunctionConstructor.cpp Runtime/GeneratorFunctionPrototype.cpp diff --git a/Userland/Libraries/LibJS/Forward.h b/Userland/Libraries/LibJS/Forward.h index 5e1ba35db2..1e56bd0155 100644 --- a/Userland/Libraries/LibJS/Forward.h +++ b/Userland/Libraries/LibJS/Forward.h @@ -35,7 +35,7 @@ __JS_ENUMERATE(Date, date, DatePrototype, DateConstructor, void) \ __JS_ENUMERATE(Error, error, ErrorPrototype, ErrorConstructor, void) \ __JS_ENUMERATE(FinalizationRegistry, finalization_registry, FinalizationRegistryPrototype, FinalizationRegistryConstructor, void) \ - __JS_ENUMERATE(Function, function, FunctionPrototype, FunctionConstructor, void) \ + __JS_ENUMERATE(FunctionObject, function, FunctionPrototype, FunctionConstructor, void) \ __JS_ENUMERATE(GeneratorFunction, generator_function, GeneratorFunctionPrototype, GeneratorFunctionConstructor, void) \ __JS_ENUMERATE(Map, map, MapPrototype, MapConstructor, void) \ __JS_ENUMERATE(NumberObject, number, NumberPrototype, NumberConstructor, void) \ diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index 2ae3f3e2c3..85b7c4566b 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -14,8 +14,8 @@ #include <LibJS/Runtime/BoundFunction.h> #include <LibJS/Runtime/DeclarativeEnvironmentRecord.h> #include <LibJS/Runtime/ErrorTypes.h> -#include <LibJS/Runtime/Function.h> #include <LibJS/Runtime/FunctionEnvironmentRecord.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalEnvironmentRecord.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/Object.h> @@ -81,7 +81,7 @@ MarkedValueList create_list_from_array_like(GlobalObject& global_object, Value v } // 7.3.22 SpeciesConstructor ( O, defaultConstructor ), https://tc39.es/ecma262/#sec-speciesconstructor -Function* species_constructor(GlobalObject& global_object, Object const& object, Function& default_constructor) +FunctionObject* species_constructor(GlobalObject& global_object, Object const& object, FunctionObject& default_constructor) { auto& vm = global_object.vm(); auto constructor = object.get(vm.names.constructor).value_or(js_undefined()); @@ -103,7 +103,7 @@ Function* species_constructor(GlobalObject& global_object, Object const& object, } // 7.3.24 GetFunctionRealm ( obj ), https://tc39.es/ecma262/#sec-getfunctionrealm -GlobalObject* get_function_realm(GlobalObject& global_object, Function const& function) +GlobalObject* get_function_realm(GlobalObject& global_object, FunctionObject const& function) { auto& vm = global_object.vm(); @@ -123,14 +123,14 @@ GlobalObject* get_function_realm(GlobalObject& global_object, Function const& fu } auto& proxy_target = proxy.target(); VERIFY(proxy_target.is_function()); - return get_function_realm(global_object, static_cast<Function const&>(proxy_target)); + return get_function_realm(global_object, static_cast<FunctionObject const&>(proxy_target)); } // 5. Return the current Realm Record. return &global_object; } // 10.1.14 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) -Object* get_prototype_from_constructor(GlobalObject& global_object, Function const& constructor, Object* (GlobalObject::*intrinsic_default_prototype)()) +Object* get_prototype_from_constructor(GlobalObject& global_object, FunctionObject const& constructor, Object* (GlobalObject::*intrinsic_default_prototype)()) { auto& vm = global_object.vm(); auto prototype = constructor.get(vm.names.prototype); diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h index 0042bb47c7..acb63780fe 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h @@ -20,9 +20,9 @@ Object* get_super_constructor(VM&); Value require_object_coercible(GlobalObject&, Value); size_t length_of_array_like(GlobalObject&, Object const&); MarkedValueList create_list_from_array_like(GlobalObject&, Value, AK::Function<Result<void, ErrorType>(Value)> = {}); -Function* species_constructor(GlobalObject&, Object const&, Function& default_constructor); -GlobalObject* get_function_realm(GlobalObject&, Function const&); -Object* get_prototype_from_constructor(GlobalObject&, Function const& constructor, Object* (GlobalObject::*intrinsic_default_prototype)()); +FunctionObject* species_constructor(GlobalObject&, Object const&, FunctionObject& default_constructor); +GlobalObject* get_function_realm(GlobalObject&, FunctionObject const&); +Object* get_prototype_from_constructor(GlobalObject&, FunctionObject const& constructor, Object* (GlobalObject::*intrinsic_default_prototype)()); enum class CallerMode { Strict, @@ -36,7 +36,7 @@ Value perform_eval(Value, GlobalObject&, CallerMode, EvalMode); // 10.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ), https://tc39.es/ecma262/#sec-ordinarycreatefromconstructor template<typename T, typename... Args> -T* ordinary_create_from_constructor(GlobalObject& global_object, Function const& constructor, Object* (GlobalObject::*intrinsic_default_prototype)(), Args&&... args) +T* ordinary_create_from_constructor(GlobalObject& global_object, FunctionObject const& constructor, Object* (GlobalObject::*intrinsic_default_prototype)(), Args&&... args) { auto& vm = global_object.vm(); auto* prototype = get_prototype_from_constructor(global_object, constructor, intrinsic_default_prototype); diff --git a/Userland/Libraries/LibJS/Runtime/Accessor.h b/Userland/Libraries/LibJS/Runtime/Accessor.h index 793b494b01..5dfed111a7 100644 --- a/Userland/Libraries/LibJS/Runtime/Accessor.h +++ b/Userland/Libraries/LibJS/Runtime/Accessor.h @@ -7,29 +7,29 @@ #pragma once -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/VM.h> namespace JS { class Accessor final : public Cell { public: - static Accessor* create(VM& vm, Function* getter, Function* setter) + static Accessor* create(VM& vm, FunctionObject* getter, FunctionObject* setter) { return vm.heap().allocate_without_global_object<Accessor>(getter, setter); } - Accessor(Function* getter, Function* setter) + Accessor(FunctionObject* getter, FunctionObject* setter) : m_getter(getter) , m_setter(setter) { } - Function* getter() const { return m_getter; } - void set_getter(Function* getter) { m_getter = getter; } + FunctionObject* getter() const { return m_getter; } + void set_getter(FunctionObject* getter) { m_getter = getter; } - Function* setter() const { return m_setter; } - void set_setter(Function* setter) { m_setter = setter; } + FunctionObject* setter() const { return m_setter; } + void set_setter(FunctionObject* setter) { m_setter = setter; } Value call_getter(Value this_value) { @@ -55,8 +55,8 @@ public: private: const char* class_name() const override { return "Accessor"; }; - Function* m_getter { nullptr }; - Function* m_setter { nullptr }; + FunctionObject* m_getter { nullptr }; + FunctionObject* m_setter { nullptr }; }; } diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp index 204bd37853..8c4b732df5 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp @@ -37,7 +37,7 @@ Value AggregateErrorConstructor::call() } // 20.5.7.1.1 AggregateError ( errors, message ), https://tc39.es/ecma262/#sec-aggregate-error -Value AggregateErrorConstructor::construct(Function& new_target) +Value AggregateErrorConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h index 8353ea3d84..87d9bea3b3 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h @@ -19,7 +19,7 @@ public: virtual ~AggregateErrorConstructor() override = default; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp index 1b35ef78e2..19fb4b5b92 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp @@ -47,7 +47,7 @@ Value ArrayBufferConstructor::call() } // 25.1.3.1 ArrayBuffer ( length ), https://tc39.es/ecma262/#sec-arraybuffer-length -Value ArrayBufferConstructor::construct(Function&) +Value ArrayBufferConstructor::construct(FunctionObject&) { auto& vm = this->vm(); auto byte_length = vm.argument(0).to_index(global_object()); diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h index 542f9cc057..3c1e65f219 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h @@ -19,7 +19,7 @@ public: virtual ~ArrayBufferConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp index 10e1f91594..0f6730c829 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp @@ -68,7 +68,7 @@ Value ArrayConstructor::call() } // 23.1.1.1 Array ( ...values ), https://tc39.es/ecma262/#sec-array -Value ArrayConstructor::construct(Function&) +Value ArrayConstructor::construct(FunctionObject&) { return call(); } @@ -83,7 +83,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from) auto* array = Array::create(global_object); - Function* map_fn = nullptr; + FunctionObject* map_fn = nullptr; if (!vm.argument(1).is_undefined()) { auto callback = vm.argument(1); if (!callback.is_function()) { diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h index d2785216f9..191c5b59df 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h @@ -19,7 +19,7 @@ public: virtual ~ArrayConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 287e90eeca..e9c31b979c 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -16,7 +16,7 @@ #include <LibJS/Runtime/ArrayIterator.h> #include <LibJS/Runtime/ArrayPrototype.h> #include <LibJS/Runtime/Error.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/ObjectPrototype.h> #include <LibJS/Runtime/Value.h> @@ -95,7 +95,7 @@ ArrayPrototype::~ArrayPrototype() { } -static Function* callback_from_args(GlobalObject& global_object, const String& name) +static FunctionObject* callback_from_args(GlobalObject& global_object, const String& name) { auto& vm = global_object.vm(); if (vm.argument_count() < 1) { @@ -872,7 +872,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reverse) return this_object; } -static void array_merge_sort(VM& vm, GlobalObject& global_object, Function* compare_func, MarkedValueList& arr_to_sort) +static void array_merge_sort(VM& vm, GlobalObject& global_object, FunctionObject* compare_func, MarkedValueList& arr_to_sort) { // FIXME: it would probably be better to switch to insertion sort for small arrays for // better performance @@ -1360,7 +1360,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::keys) } // 23.1.3.10.1 FlattenIntoArray ( target, source, sourceLen, start, depth [ , mapperFunction [ , thisArg ] ] ), https://tc39.es/ecma262/#sec-flattenintoarray -static size_t flatten_into_array(GlobalObject& global_object, Object& new_array, Object& array, size_t array_length, size_t target_index, double depth, Function* mapper_func = {}, Value this_arg = {}) +static size_t flatten_into_array(GlobalObject& global_object, Object& new_array, Object& array, size_t array_length, size_t target_index, double depth, FunctionObject* mapper_func = {}, Value this_arg = {}) { VERIFY(!mapper_func || (!this_arg.is_empty() && depth == 1)); auto& vm = global_object.vm(); diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp index b60bf08ad2..b61a725f97 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp @@ -59,7 +59,7 @@ Value BigIntConstructor::call() } // 21.2.1.1 BigInt ( value ), https://tc39.es/ecma262/#sec-bigint-constructor-number-value -Value BigIntConstructor::construct(Function&) +Value BigIntConstructor::construct(FunctionObject&) { vm().throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, "BigInt"); return {}; diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h index 68bef70fa1..ad8b510636 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h @@ -19,7 +19,7 @@ public: virtual ~BigIntConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp index 3fb98b235f..0842380566 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp @@ -41,7 +41,7 @@ Value BooleanConstructor::call() } // 20.3.1.1 Boolean ( value ), https://tc39.es/ecma262/#sec-boolean-constructor-boolean-value -Value BooleanConstructor::construct(Function& new_target) +Value BooleanConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h index 416340cffb..a2df4f2c6d 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h @@ -19,7 +19,7 @@ public: virtual ~BooleanConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp index 2f7bf2d114..ef1d77ceef 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp @@ -9,8 +9,8 @@ namespace JS { -BoundFunction::BoundFunction(GlobalObject& global_object, Function& target_function, Value bound_this, Vector<Value> arguments, i32 length, Object* constructor_prototype) - : Function::Function(bound_this, move(arguments), *global_object.function_prototype()) +BoundFunction::BoundFunction(GlobalObject& global_object, FunctionObject& target_function, Value bound_this, Vector<Value> arguments, i32 length, Object* constructor_prototype) + : FunctionObject(bound_this, move(arguments), *global_object.function_prototype()) , m_target_function(&target_function) , m_constructor_prototype(constructor_prototype) , m_name(String::formatted("bound {}", target_function.name())) @@ -21,7 +21,7 @@ BoundFunction::BoundFunction(GlobalObject& global_object, Function& target_funct void BoundFunction::initialize(GlobalObject& global_object) { auto& vm = this->vm(); - Function::initialize(global_object); + Base::initialize(global_object); define_property(vm.names.length, Value(m_length), Attribute::Configurable); } @@ -34,7 +34,7 @@ Value BoundFunction::call() return m_target_function->call(); } -Value BoundFunction::construct(Function& new_target) +Value BoundFunction::construct(FunctionObject& new_target) { if (auto this_value = vm().this_value(global_object()); m_constructor_prototype && this_value.is_object()) { this_value.as_object().set_prototype(m_constructor_prototype); @@ -44,14 +44,14 @@ Value BoundFunction::construct(Function& new_target) return m_target_function->construct(new_target); } -FunctionEnvironmentRecord* BoundFunction::create_environment_record(Function& function_being_invoked) +FunctionEnvironmentRecord* BoundFunction::create_environment_record(FunctionObject& function_being_invoked) { return m_target_function->create_environment_record(function_being_invoked); } void BoundFunction::visit_edges(Visitor& visitor) { - Function::visit_edges(visitor); + Base::visit_edges(visitor); visitor.visit(m_target_function); visitor.visit(m_constructor_prototype); } diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.h b/Userland/Libraries/LibJS/Runtime/BoundFunction.h index 15f597b54e..7af8c915ab 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.h +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.h @@ -6,23 +6,23 @@ #pragma once -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> namespace JS { -class BoundFunction final : public Function { - JS_OBJECT(BoundFunction, Function); +class BoundFunction final : public FunctionObject { + JS_OBJECT(BoundFunction, FunctionObject); public: - BoundFunction(GlobalObject&, Function& target_function, Value bound_this, Vector<Value> arguments, i32 length, Object* constructor_prototype); + BoundFunction(GlobalObject&, FunctionObject& target_function, Value bound_this, Vector<Value> arguments, i32 length, Object* constructor_prototype); virtual void initialize(GlobalObject&) override; virtual ~BoundFunction(); virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; - virtual FunctionEnvironmentRecord* create_environment_record(Function&) override; + virtual FunctionEnvironmentRecord* create_environment_record(FunctionObject&) override; virtual void visit_edges(Visitor&) override; @@ -31,7 +31,7 @@ public: return m_name; } - Function& target_function() const + FunctionObject& target_function() const { return *m_target_function; } @@ -39,8 +39,8 @@ public: virtual bool is_strict_mode() const override { return m_target_function->is_strict_mode(); } private: - Function* m_target_function = nullptr; - Object* m_constructor_prototype = nullptr; + FunctionObject* m_target_function { nullptr }; + Object* m_constructor_prototype { nullptr }; FlyString m_name; i32 m_length { 0 }; }; diff --git a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h index 693a8b1257..f40c44533d 100644 --- a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h +++ b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h @@ -22,6 +22,7 @@ namespace JS { P(Boolean) \ P(E) \ P(EPSILON) \ + P(Function) \ P(Infinity) \ P(JSON) \ P(LN10) \ diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp index ff21e9675c..1e46111993 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp @@ -41,7 +41,7 @@ Value DataViewConstructor::call() } // 25.3.2.1 DataView ( buffer [ , byteOffset [ , byteLength ] ] ), https://tc39.es/ecma262/#sec-dataview-buffer-byteoffset-bytelength -Value DataViewConstructor::construct(Function& new_target) +Value DataViewConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h index c1a5852490..b68c350f84 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h @@ -19,7 +19,7 @@ public: virtual ~DataViewConstructor() override; virtual Value call() override; - virtual Value construct(Function&) override; + virtual Value construct(FunctionObject&) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp index b811978225..7ce27cd32c 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -168,7 +168,7 @@ Value DateConstructor::call() } // 21.4.2.1 Date ( ...values ), https://tc39.es/ecma262/#sec-date -Value DateConstructor::construct(Function& new_target) +Value DateConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.h b/Userland/Libraries/LibJS/Runtime/DateConstructor.h index b45aa530a8..6718aebd31 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.h @@ -19,7 +19,7 @@ public: virtual ~DateConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.cpp b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.cpp index a70aa7df8b..6e075e5be1 100644 --- a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.cpp +++ b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.cpp @@ -7,7 +7,7 @@ #include <LibJS/Interpreter.h> #include <LibJS/Runtime/DeclarativeEnvironmentRecord.h> #include <LibJS/Runtime/Error.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/Value.h> diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp index 27014c74d5..17b54eaebd 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp @@ -34,7 +34,7 @@ Value ErrorConstructor::call() } // 20.5.1.1 Error ( message ), https://tc39.es/ecma262/#sec-error-message -Value ErrorConstructor::construct(Function& new_target) +Value ErrorConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); @@ -86,7 +86,7 @@ Value ErrorConstructor::construct(Function& new_target) } \ \ /* 20.5.6.1.1 NativeError ( message ), https://tc39.es/ecma262/#sec-nativeerror */ \ - Value ConstructorName::construct(Function& new_target) \ + Value ConstructorName::construct(FunctionObject& new_target) \ { \ auto& vm = this->vm(); \ auto& global_object = this->global_object(); \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h index 71fd400b6f..8c37dbb1e2 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h @@ -20,7 +20,7 @@ public: virtual ~ErrorConstructor() override = default; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } @@ -35,7 +35,7 @@ private: virtual void initialize(GlobalObject&) override; \ virtual ~ConstructorName() override; \ virtual Value call() override; \ - virtual Value construct(Function& new_target) override; \ + virtual Value construct(FunctionObject& new_target) override; \ \ private: \ virtual bool has_constructor() const override { return true; } \ diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp index 12b8e9f61e..d4dad7c5b2 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp @@ -8,12 +8,12 @@ namespace JS { -FinalizationRegistry* FinalizationRegistry::create(GlobalObject& global_object, Function& cleanup_callback) +FinalizationRegistry* FinalizationRegistry::create(GlobalObject& global_object, FunctionObject& cleanup_callback) { return global_object.heap().allocate<FinalizationRegistry>(global_object, cleanup_callback, *global_object.finalization_registry_prototype()); } -FinalizationRegistry::FinalizationRegistry(Function& cleanup_callback, Object& prototype) +FinalizationRegistry::FinalizationRegistry(FunctionObject& cleanup_callback, Object& prototype) : Object(prototype) , WeakContainer(heap()) , m_cleanup_callback(&cleanup_callback) @@ -59,7 +59,7 @@ void FinalizationRegistry::remove_sweeped_cells(Badge<Heap>, Vector<Cell*>& cell } // 9.13 CleanupFinalizationRegistry ( finalizationRegistry ), https://tc39.es/ecma262/#sec-cleanup-finalization-registry -void FinalizationRegistry::cleanup(Function* callback) +void FinalizationRegistry::cleanup(FunctionObject* callback) { auto& vm = this->vm(); auto cleanup_callback = callback ?: m_cleanup_callback; diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h index 91b4866c1a..7b403dc583 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h @@ -7,7 +7,7 @@ #pragma once #include <AK/SinglyLinkedList.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/Object.h> #include <LibJS/Runtime/Value.h> @@ -21,21 +21,21 @@ class FinalizationRegistry final JS_OBJECT(FinalizationRegistry, Object); public: - static FinalizationRegistry* create(GlobalObject&, Function&); + static FinalizationRegistry* create(GlobalObject&, FunctionObject&); - explicit FinalizationRegistry(Function&, Object& prototype); + explicit FinalizationRegistry(FunctionObject&, Object& prototype); virtual ~FinalizationRegistry() override; void add_finalization_record(Cell& target, Value held_value, Object* unregister_token); bool remove_by_token(Object& unregister_token); - void cleanup(Function* callback = nullptr); + void cleanup(FunctionObject* callback = nullptr); virtual void remove_sweeped_cells(Badge<Heap>, Vector<Cell*>&) override; private: virtual void visit_edges(Visitor& visitor) override; - Function* m_cleanup_callback { nullptr }; + FunctionObject* m_cleanup_callback { nullptr }; struct FinalizationRecord { Cell* target { nullptr }; diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp index 72b15afbce..d15402f36f 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp @@ -41,7 +41,7 @@ Value FinalizationRegistryConstructor::call() } // 26.2.1.1 FinalizationRegistry ( cleanupCallback ), https://tc39.es/ecma262/#sec-finalization-registry-cleanup-callback -Value FinalizationRegistryConstructor::construct(Function& new_target) +Value FinalizationRegistryConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h index d72f5bf5ba..461113d506 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h @@ -19,7 +19,7 @@ public: virtual ~FinalizationRegistryConstructor() override; virtual Value call() override; - virtual Value construct(Function&) override; + virtual Value construct(FunctionObject&) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp index 988f829bc9..5c945bca18 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp @@ -9,8 +9,8 @@ #include <LibJS/Lexer.h> #include <LibJS/Parser.h> #include <LibJS/Runtime/Error.h> -#include <LibJS/Runtime/Function.h> #include <LibJS/Runtime/FunctionConstructor.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> namespace JS { @@ -36,7 +36,7 @@ FunctionConstructor::~FunctionConstructor() } // 20.2.1.1.1 CreateDynamicFunction ( constructor, newTarget, kind, args ), https://tc39.es/ecma262/#sec-createdynamicfunction -RefPtr<FunctionExpression> FunctionConstructor::create_dynamic_function_node(GlobalObject& global_object, Function&, FunctionKind kind) +RefPtr<FunctionExpression> FunctionConstructor::create_dynamic_function_node(GlobalObject& global_object, FunctionObject&, FunctionKind kind) { auto& vm = global_object.vm(); String parameters_source = ""; @@ -80,7 +80,7 @@ Value FunctionConstructor::call() } // 20.2.1.1 Function ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-function-p1-p2-pn-body -Value FunctionConstructor::construct(Function& new_target) +Value FunctionConstructor::construct(FunctionObject& new_target) { auto function = create_dynamic_function_node(global_object(), new_target, FunctionKind::Regular); if (!function) diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h index 5f237ba909..d9c0d8c3d0 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h @@ -14,14 +14,14 @@ class FunctionConstructor final : public NativeFunction { JS_OBJECT(FunctionConstructor, NativeFunction); public: - static RefPtr<FunctionExpression> create_dynamic_function_node(GlobalObject& global_object, Function& new_target, FunctionKind kind); + static RefPtr<FunctionExpression> create_dynamic_function_node(GlobalObject& global_object, FunctionObject& new_target, FunctionKind kind); explicit FunctionConstructor(GlobalObject&); virtual void initialize(GlobalObject&) override; virtual ~FunctionConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/FunctionEnvironmentRecord.cpp b/Userland/Libraries/LibJS/Runtime/FunctionEnvironmentRecord.cpp index fe70b951ff..3819fbb7cb 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionEnvironmentRecord.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionEnvironmentRecord.cpp @@ -5,8 +5,8 @@ */ #include <LibJS/Interpreter.h> -#include <LibJS/Runtime/Function.h> #include <LibJS/Runtime/FunctionEnvironmentRecord.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> namespace JS { diff --git a/Userland/Libraries/LibJS/Runtime/FunctionEnvironmentRecord.h b/Userland/Libraries/LibJS/Runtime/FunctionEnvironmentRecord.h index 0caf784b8c..aca3a8a223 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionEnvironmentRecord.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionEnvironmentRecord.h @@ -35,9 +35,9 @@ public: void set_this_binding_status(ThisBindingStatus status) { m_this_binding_status = status; } // [[FunctionObject]] - Function& function_object() { return *m_function_object; } - Function const& function_object() const { return *m_function_object; } - void set_function_object(Function& function) { m_function_object = &function; } + FunctionObject& function_object() { return *m_function_object; } + FunctionObject const& function_object() const { return *m_function_object; } + void set_function_object(FunctionObject& function) { m_function_object = &function; } // [[NewTarget]] Value new_target() const { return m_new_target; } @@ -56,7 +56,7 @@ private: Value m_this_value; ThisBindingStatus m_this_binding_status { ThisBindingStatus::Uninitialized }; - Function* m_function_object { nullptr }; + FunctionObject* m_function_object { nullptr }; Value m_new_target; }; diff --git a/Userland/Libraries/LibJS/Runtime/Function.cpp b/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp index 83a37ebfdb..bf4e02b0f6 100644 --- a/Userland/Libraries/LibJS/Runtime/Function.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp @@ -6,31 +6,31 @@ #include <LibJS/Interpreter.h> #include <LibJS/Runtime/BoundFunction.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> namespace JS { -Function::Function(Object& prototype) - : Function({}, {}, prototype) +FunctionObject::FunctionObject(Object& prototype) + : FunctionObject({}, {}, prototype) { } -Function::Function(Value bound_this, Vector<Value> bound_arguments, Object& prototype) +FunctionObject::FunctionObject(Value bound_this, Vector<Value> bound_arguments, Object& prototype) : Object(prototype) , m_bound_this(bound_this) , m_bound_arguments(move(bound_arguments)) { } -Function::~Function() +FunctionObject::~FunctionObject() { } -BoundFunction* Function::bind(Value bound_this_value, Vector<Value> arguments) +BoundFunction* FunctionObject::bind(Value bound_this_value, Vector<Value> arguments) { auto& vm = this->vm(); - Function& target_function = is<BoundFunction>(*this) ? static_cast<BoundFunction&>(*this).target_function() : *this; + FunctionObject& target_function = is<BoundFunction>(*this) ? static_cast<BoundFunction&>(*this).target_function() : *this; auto bound_this_object = [&vm, bound_this_value, this]() -> Value { if (!m_bound_this.is_empty()) @@ -66,7 +66,7 @@ BoundFunction* Function::bind(Value bound_this_value, Vector<Value> arguments) return heap().allocate<BoundFunction>(global_object(), global_object(), target_function, bound_this_object, move(all_bound_arguments), computed_length, constructor_prototype); } -void Function::visit_edges(Visitor& visitor) +void FunctionObject::visit_edges(Visitor& visitor) { Object::visit_edges(visitor); diff --git a/Userland/Libraries/LibJS/Runtime/Function.h b/Userland/Libraries/LibJS/Runtime/FunctionObject.h index 997e5e2bde..66637bcec6 100644 --- a/Userland/Libraries/LibJS/Runtime/Function.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionObject.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -11,7 +11,7 @@ namespace JS { -class Function : public Object { +class FunctionObject : public Object { JS_OBJECT(Function, Object); public: @@ -20,13 +20,13 @@ public: Derived, }; - virtual ~Function(); + virtual ~FunctionObject(); virtual void initialize(GlobalObject&) override { } virtual Value call() = 0; - virtual Value construct(Function& new_target) = 0; + virtual Value construct(FunctionObject& new_target) = 0; virtual const FlyString& name() const = 0; - virtual FunctionEnvironmentRecord* create_environment_record(Function&) = 0; + virtual FunctionEnvironmentRecord* create_environment_record(FunctionObject&) = 0; BoundFunction* bind(Value bound_this_value, Vector<Value> arguments); @@ -60,8 +60,8 @@ public: protected: virtual void visit_edges(Visitor&) override; - explicit Function(Object& prototype); - Function(Value bound_this, Vector<Value> bound_arguments, Object& prototype); + explicit FunctionObject(Object& prototype); + FunctionObject(Value bound_this, Vector<Value> bound_arguments, Object& prototype); private: virtual bool is_function() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index c2b5ced0aa..7129653fc4 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -11,7 +11,7 @@ #include <LibJS/Runtime/AbstractOperations.h> #include <LibJS/Runtime/BoundFunction.h> #include <LibJS/Runtime/Error.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/FunctionPrototype.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/MarkedValueList.h> @@ -53,7 +53,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::apply) vm.throw_exception<TypeError>(global_object, ErrorType::NotA, "Function"); return {}; } - auto& function = static_cast<Function&>(*this_object); + auto& function = static_cast<FunctionObject&>(*this_object); auto this_arg = vm.argument(0); auto arg_array = vm.argument(1); if (arg_array.is_nullish()) @@ -74,7 +74,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::bind) vm.throw_exception<TypeError>(global_object, ErrorType::NotA, "Function"); return {}; } - auto& this_function = static_cast<Function&>(*this_object); + auto& this_function = static_cast<FunctionObject&>(*this_object); auto bound_this_arg = vm.argument(0); Vector<Value> arguments; @@ -96,7 +96,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::call) vm.throw_exception<TypeError>(global_object, ErrorType::NotA, "Function"); return {}; } - auto& function = static_cast<Function&>(*this_object); + auto& function = static_cast<FunctionObject&>(*this_object); auto this_arg = vm.argument(0); MarkedValueList arguments(vm.heap()); if (vm.argument_count() > 1) { diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp index a1e0b02314..ee40a273f4 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp @@ -43,7 +43,7 @@ Value GeneratorFunctionConstructor::call() } // 27.3.1.1 GeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-generatorfunction -Value GeneratorFunctionConstructor::construct(Function& new_target) +Value GeneratorFunctionConstructor::construct(FunctionObject& new_target) { auto function = FunctionConstructor::create_dynamic_function_node(global_object(), new_target, FunctionKind::Generator); if (!function) diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h index 0ad60b3f17..03533a44b5 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h @@ -20,7 +20,7 @@ public: virtual ~GeneratorFunctionConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; }; } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h index 8bfe2fef09..6e54d66730 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h @@ -6,7 +6,7 @@ #pragma once -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> namespace JS { diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.h b/Userland/Libraries/LibJS/Runtime/GlobalObject.h index 669a99ef9b..c30f054ac7 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.h +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.h @@ -36,7 +36,7 @@ public: // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor GeneratorObjectPrototype* generator_object_prototype() { return m_generator_object_prototype; } - Function* eval_function() const { return m_eval_function; } + FunctionObject* eval_function() const { return m_eval_function; } #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ ConstructorName* snake_name##_constructor() { return m_##snake_name##_constructor; } \ @@ -98,7 +98,7 @@ private: JS_ENUMERATE_ITERATOR_PROTOTYPES #undef __JS_ENUMERATE - Function* m_eval_function; + FunctionObject* m_eval_function; }; template<typename ConstructorType> diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp index 0147aa345c..fc3245ab4b 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp @@ -446,7 +446,7 @@ Array* JSONObject::parse_json_array(GlobalObject& global_object, const JsonArray } // 25.5.1.1 InternalizeJSONProperty ( holder, name, reviver ), https://tc39.es/ecma262/#sec-internalizejsonproperty -Value JSONObject::internalize_json_property(GlobalObject& global_object, Object* holder, const PropertyName& name, Function& reviver) +Value JSONObject::internalize_json_property(GlobalObject& global_object, Object* holder, PropertyName const& name, FunctionObject& reviver) { auto& vm = global_object.vm(); auto value = holder->get(name); diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.h b/Userland/Libraries/LibJS/Runtime/JSONObject.h index 379e2148bd..6c83cce556 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.h +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.h @@ -24,7 +24,7 @@ public: private: struct StringifyState { - Function* replacer_function { nullptr }; + FunctionObject* replacer_function { nullptr }; HashTable<Object*> seen_objects; String indent { String::empty() }; String gap; @@ -41,7 +41,7 @@ private: static Object* parse_json_object(GlobalObject&, const JsonObject&); static Array* parse_json_array(GlobalObject&, const JsonArray&); static Value parse_json_value(GlobalObject&, const JsonValue&); - static Value internalize_json_property(GlobalObject&, Object* holder, const PropertyName& name, Function& reviver); + static Value internalize_json_property(GlobalObject&, Object* holder, PropertyName const& name, FunctionObject& reviver); JS_DECLARE_NATIVE_FUNCTION(stringify); JS_DECLARE_NATIVE_FUNCTION(parse); diff --git a/Userland/Libraries/LibJS/Runtime/JobCallback.h b/Userland/Libraries/LibJS/Runtime/JobCallback.h index 5cd67b5ee2..8be1854abd 100644 --- a/Userland/Libraries/LibJS/Runtime/JobCallback.h +++ b/Userland/Libraries/LibJS/Runtime/JobCallback.h @@ -6,18 +6,18 @@ #pragma once -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/VM.h> namespace JS { // 9.5.1 JobCallback Records, https://tc39.es/ecma262/#sec-jobcallback-records struct JobCallback { - Function* callback; + FunctionObject* callback { nullptr }; }; // 9.5.2 HostMakeJobCallback ( callback ), https://tc39.es/ecma262/#sec-hostmakejobcallback -inline JobCallback make_job_callback(Function& callback) +inline JobCallback make_job_callback(FunctionObject& callback) { return { &callback }; } diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp index cea85d6d42..eceff0913f 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp @@ -44,7 +44,7 @@ Value MapConstructor::call() } // 24.1.1.1 Map ( [ iterable ] ), https://tc39.es/ecma262/#sec-map-iterable -Value MapConstructor::construct(Function& new_target) +Value MapConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.h b/Userland/Libraries/LibJS/Runtime/MapConstructor.h index 2bec62abdb..e24bf64f9b 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.h @@ -19,7 +19,7 @@ public: virtual ~MapConstructor() override; virtual Value call() override; - virtual Value construct(Function&) override; + virtual Value construct(FunctionObject&) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index a507b4bdbe..0933d3a420 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -16,19 +16,19 @@ NativeFunction* NativeFunction::create(GlobalObject& global_object, const FlyStr } NativeFunction::NativeFunction(Object& prototype) - : Function(prototype) + : FunctionObject(prototype) { } NativeFunction::NativeFunction(PropertyName const& name, AK::Function<Value(VM&, GlobalObject&)> native_function, Object& prototype) - : Function(prototype) + : FunctionObject(prototype) , m_name(name.as_string()) , m_native_function(move(native_function)) { } NativeFunction::NativeFunction(PropertyName const& name, Object& prototype) - : Function(prototype) + : FunctionObject(prototype) , m_name(name.as_string()) { } @@ -42,12 +42,12 @@ Value NativeFunction::call() return m_native_function(vm(), global_object()); } -Value NativeFunction::construct(Function&) +Value NativeFunction::construct(FunctionObject&) { return {}; } -FunctionEnvironmentRecord* NativeFunction::create_environment_record(Function&) +FunctionEnvironmentRecord* NativeFunction::create_environment_record(FunctionObject&) { return nullptr; } diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.h b/Userland/Libraries/LibJS/Runtime/NativeFunction.h index 5b288f0338..fcff8a55e9 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.h +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.h @@ -7,12 +7,12 @@ #pragma once #include <AK/Function.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> namespace JS { -class NativeFunction : public Function { - JS_OBJECT(NativeFunction, Function); +class NativeFunction : public FunctionObject { + JS_OBJECT(NativeFunction, FunctionObject); public: static NativeFunction* create(GlobalObject&, const FlyString& name, AK::Function<Value(VM&, GlobalObject&)>); @@ -22,7 +22,7 @@ public: virtual ~NativeFunction() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; virtual const FlyString& name() const override { return m_name; }; virtual bool has_constructor() const { return false; } @@ -34,7 +34,7 @@ protected: explicit NativeFunction(Object& prototype); private: - virtual FunctionEnvironmentRecord* create_environment_record(Function&) override final; + virtual FunctionEnvironmentRecord* create_environment_record(FunctionObject&) override final; virtual bool is_native_function() const final { return true; } FlyString m_name; diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp index 97f79a1242..9e6b92ec04 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp @@ -95,7 +95,7 @@ Value NumberConstructor::call() } // 21.1.1.1 Number ( value ), https://tc39.es/ecma262/#sec-number-constructor-number-value -Value NumberConstructor::construct(Function& new_target) +Value NumberConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.h b/Userland/Libraries/LibJS/Runtime/NumberConstructor.h index 48d55cd5fa..8ae7830050 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.h @@ -19,7 +19,7 @@ public: virtual ~NumberConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 3571e23541..e67fc69379 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -490,8 +490,8 @@ bool Object::define_property(const StringOrSymbol& property_name, const Object& if (vm.exception()) return {}; - Function* getter_function { nullptr }; - Function* setter_function { nullptr }; + FunctionObject* getter_function { nullptr }; + FunctionObject* setter_function { nullptr }; // We should only take previous getters for our own object not from any prototype auto existing_property = get_own_property(property_name, {}, AllowSideEffects::No).value_or(js_undefined()); @@ -564,7 +564,7 @@ bool Object::define_native_accessor(PropertyName const& property_name, AK::Funct } else { formatted_property_name = String::formatted("[{}]", property_name.as_symbol()->description()); } - Function* getter_function = nullptr; + FunctionObject* getter_function = nullptr; if (getter) { auto name = String::formatted("get {}", formatted_property_name); getter_function = NativeFunction::create(global_object(), name, move(getter)); @@ -575,7 +575,7 @@ bool Object::define_native_accessor(PropertyName const& property_name, AK::Funct if (vm.exception()) return {}; } - Function* setter_function = nullptr; + FunctionObject* setter_function = nullptr; if (setter) { auto name = String::formatted("set {}", formatted_property_name); setter_function = NativeFunction::create(global_object(), name, move(setter)); @@ -589,7 +589,7 @@ bool Object::define_native_accessor(PropertyName const& property_name, AK::Funct return define_accessor(property_name, getter_function, setter_function, attribute); } -bool Object::define_accessor(const PropertyName& property_name, Function* getter, Function* setter, PropertyAttributes attributes, bool throw_exceptions) +bool Object::define_accessor(const PropertyName& property_name, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes, bool throw_exceptions) { VERIFY(property_name.is_valid()); diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index bd8fb0575e..5c27c82f08 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -28,8 +28,8 @@ public: \ struct PropertyDescriptor { PropertyAttributes attributes; Value value; - Function* getter { nullptr }; - Function* setter { nullptr }; + FunctionObject* getter { nullptr }; + FunctionObject* setter { nullptr }; static PropertyDescriptor from_dictionary(VM&, const Object&); @@ -91,7 +91,7 @@ public: virtual bool define_property(const StringOrSymbol& property_name, const Object& descriptor, bool throw_exceptions = true); bool define_property(const PropertyName&, Value value, PropertyAttributes attributes = default_attributes, bool throw_exceptions = true); bool define_property_without_transition(const PropertyName&, Value value, PropertyAttributes attributes = default_attributes, bool throw_exceptions = true); - bool define_accessor(const PropertyName&, Function* getter, Function* setter, PropertyAttributes attributes = default_attributes, bool throw_exceptions = true); + bool define_accessor(const PropertyName&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes = default_attributes, bool throw_exceptions = true); bool define_native_function(PropertyName const&, AK::Function<Value(VM&, GlobalObject&)>, i32 length = 0, PropertyAttributes attributes = default_attributes); bool define_native_property(PropertyName const&, AK::Function<Value(VM&, GlobalObject&)> getter, AK::Function<void(VM&, GlobalObject&, Value)> setter, PropertyAttributes attributes = default_attributes); diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp index 5807de05f5..09a80f4132 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -67,7 +67,7 @@ Value ObjectConstructor::call() } // 20.1.1.1 Object ( [ value ] ), https://tc39.es/ecma262/#sec-object-value -Value ObjectConstructor::construct(Function& new_target) +Value ObjectConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h index 50ea468e6b..42fd41fb5e 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h @@ -20,7 +20,7 @@ public: virtual ~ObjectConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/Promise.h b/Userland/Libraries/LibJS/Runtime/Promise.h index c3adf9e249..0f1c927c78 100644 --- a/Userland/Libraries/LibJS/Runtime/Promise.h +++ b/Userland/Libraries/LibJS/Runtime/Promise.h @@ -36,8 +36,8 @@ public: Value result() const { return m_result; } struct ResolvingFunctions { - Function& resolve; - Function& reject; + FunctionObject& resolve; + FunctionObject& reject; }; ResolvingFunctions create_resolving_functions(); diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp index beda396b18..cfed178d24 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -7,7 +7,7 @@ #include <LibJS/Interpreter.h> #include <LibJS/Runtime/AbstractOperations.h> #include <LibJS/Runtime/Error.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/Promise.h> #include <LibJS/Runtime/PromiseConstructor.h> @@ -51,7 +51,7 @@ Value PromiseConstructor::call() } // 27.2.3.1 Promise ( executor ), https://tc39.es/ecma262/#sec-promise-executor -Value PromiseConstructor::construct(Function& new_target) +Value PromiseConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h index 00334dc282..689df76a3a 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h @@ -19,7 +19,7 @@ public: virtual ~PromiseConstructor() override = default; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp index 7ff00b4f4b..dc28e1f793 100644 --- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp @@ -92,8 +92,8 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally) } else { // 27.2.5.3.1 Then Finally Functions, https://tc39.es/ecma262/#sec-thenfinallyfunctions auto* then_finally_function = NativeFunction::create(global_object, "", [constructor_handle = make_handle(constructor), on_finally_handle = make_handle(&on_finally.as_function())](auto& vm, auto& global_object) -> Value { - auto& constructor = const_cast<Function&>(*constructor_handle.cell()); - auto& on_finally = const_cast<Function&>(*on_finally_handle.cell()); + auto& constructor = const_cast<FunctionObject&>(*constructor_handle.cell()); + auto& on_finally = const_cast<FunctionObject&>(*on_finally_handle.cell()); auto value = vm.argument(0); auto result = vm.call(on_finally, js_undefined()); if (vm.exception()) @@ -110,8 +110,8 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally) // 27.2.5.3.2 Catch Finally Functions, https://tc39.es/ecma262/#sec-catchfinallyfunctions auto* catch_finally_function = NativeFunction::create(global_object, "", [constructor_handle = make_handle(constructor), on_finally_handle = make_handle(&on_finally.as_function())](auto& vm, auto& global_object) -> Value { - auto& constructor = const_cast<Function&>(*constructor_handle.cell()); - auto& on_finally = const_cast<Function&>(*on_finally_handle.cell()); + auto& constructor = const_cast<FunctionObject&>(*constructor_handle.cell()); + auto& on_finally = const_cast<FunctionObject&>(*on_finally_handle.cell()); auto reason = vm.argument(0); auto result = vm.call(on_finally, js_undefined()); if (vm.exception()) diff --git a/Userland/Libraries/LibJS/Runtime/PromiseReaction.h b/Userland/Libraries/LibJS/Runtime/PromiseReaction.h index c960ba2d63..ea538b927a 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseReaction.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseReaction.h @@ -14,9 +14,9 @@ namespace JS { // 27.2.1.1 PromiseCapability Records, https://tc39.es/ecma262/#sec-promisecapability-records struct PromiseCapability { - Object* promise; - Function* resolve; - Function* reject; + Object* promise { nullptr }; + FunctionObject* resolve { nullptr }; + FunctionObject* reject { nullptr }; }; // 27.2.1.5 NewPromiseCapability ( C ), https://tc39.es/ecma262/#sec-newpromisecapability diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp index 4f580bb834..65bda60eb2 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp @@ -55,7 +55,7 @@ Value ProxyConstructor::call() } // 28.2.1.1 Proxy ( target, handler ), https://tc39.es/ecma262/#sec-proxy-target-handler -Value ProxyConstructor::construct(Function&) +Value ProxyConstructor::construct(FunctionObject&) { auto& vm = this->vm(); return proxy_create(global_object(), vm.argument(0), vm.argument(1)); diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h index 2a3b888f68..f66ed96685 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h @@ -20,7 +20,7 @@ public: virtual ~ProxyConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index 696c2c8010..bc2f4abb27 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -45,7 +45,7 @@ ProxyObject* ProxyObject::create(GlobalObject& global_object, Object& target, Ob } ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype) - : Function(prototype) + : FunctionObject(prototype) , m_target(target) , m_handler(handler) { @@ -406,7 +406,7 @@ bool ProxyObject::delete_property(PropertyName const& name, bool force_throw_exc void ProxyObject::visit_edges(Cell::Visitor& visitor) { - Function::visit_edges(visitor); + Base::visit_edges(visitor); visitor.visit(&m_target); visitor.visit(&m_handler); } @@ -426,7 +426,7 @@ Value ProxyObject::call() if (vm.exception()) return {}; if (!trap) - return static_cast<Function&>(m_target).call(); + return static_cast<FunctionObject&>(m_target).call(); MarkedValueList arguments(heap()); arguments.append(Value(&m_target)); arguments.append(Value(&m_handler)); @@ -440,7 +440,7 @@ Value ProxyObject::call() return vm.call(*trap, Value(&m_handler), move(arguments)); } -Value ProxyObject::construct(Function& new_target) +Value ProxyObject::construct(FunctionObject& new_target) { auto& vm = this->vm(); if (!is_function()) { @@ -455,7 +455,7 @@ Value ProxyObject::construct(Function& new_target) if (vm.exception()) return {}; if (!trap) - return static_cast<Function&>(m_target).construct(new_target); + return static_cast<FunctionObject&>(m_target).construct(new_target); MarkedValueList arguments(vm.heap()); arguments.append(Value(&m_target)); auto arguments_array = Array::create(global_object()); @@ -475,13 +475,13 @@ Value ProxyObject::construct(Function& new_target) const FlyString& ProxyObject::name() const { VERIFY(is_function()); - return static_cast<Function&>(m_target).name(); + return static_cast<FunctionObject&>(m_target).name(); } -FunctionEnvironmentRecord* ProxyObject::create_environment_record(Function& function_being_invoked) +FunctionEnvironmentRecord* ProxyObject::create_environment_record(FunctionObject& function_being_invoked) { VERIFY(is_function()); - return static_cast<Function&>(m_target).create_environment_record(function_being_invoked); + return static_cast<FunctionObject&>(m_target).create_environment_record(function_being_invoked); } } diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.h b/Userland/Libraries/LibJS/Runtime/ProxyObject.h index 9cda19504b..566310aea9 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.h @@ -6,12 +6,12 @@ #pragma once -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> namespace JS { -class ProxyObject final : public Function { - JS_OBJECT(ProxyObject, Function); +class ProxyObject final : public FunctionObject { + JS_OBJECT(ProxyObject, FunctionObject); public: static ProxyObject* create(GlobalObject&, Object& target, Object& handler); @@ -20,9 +20,9 @@ public: virtual ~ProxyObject() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; virtual const FlyString& name() const override; - virtual FunctionEnvironmentRecord* create_environment_record(Function&) override; + virtual FunctionEnvironmentRecord* create_environment_record(FunctionObject&) override; const Object& target() const { return m_target; } const Object& handler() const { return m_handler; } diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp index aa2b9b5cf5..51c04175ab 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -8,7 +8,7 @@ #include <LibJS/Runtime/AbstractOperations.h> #include <LibJS/Runtime/Array.h> #include <LibJS/Runtime/Error.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/NativeFunction.h> #include <LibJS/Runtime/ReflectObject.h> @@ -26,7 +26,7 @@ static Object* get_target_object_from(GlobalObject& global_object, const String& return static_cast<Object*>(&target.as_object()); } -static Function* get_target_function_from(GlobalObject& global_object, const String& name) +static FunctionObject* get_target_function_from(GlobalObject& global_object, const String& name) { auto& vm = global_object.vm(); auto target = vm.argument(0); diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp index b556a121c9..d1252659bd 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp @@ -40,7 +40,7 @@ Value RegExpConstructor::call() } // 22.2.3.1 RegExp ( pattern, flags ), https://tc39.es/ecma262/#sec-regexp-pattern-flags -Value RegExpConstructor::construct(Function&) +Value RegExpConstructor::construct(FunctionObject&) { auto& vm = this->vm(); String pattern = ""; diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h index d110021ccf..d32ba1438a 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h @@ -19,7 +19,7 @@ public: virtual ~RegExpConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Userland/Libraries/LibJS/Runtime/ScriptFunction.cpp index 3d00c4bd4a..d2e9a9b687 100644 --- a/Userland/Libraries/LibJS/Runtime/ScriptFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/ScriptFunction.cpp @@ -51,7 +51,7 @@ ScriptFunction* ScriptFunction::create(GlobalObject& global_object, const FlyStr } ScriptFunction::ScriptFunction(GlobalObject& global_object, const FlyString& name, const Statement& body, Vector<FunctionNode::Parameter> parameters, i32 function_length, EnvironmentRecord* parent_scope, Object& prototype, FunctionKind kind, bool is_strict, bool is_arrow_function) - : Function(is_arrow_function ? vm().this_value(global_object) : Value(), {}, prototype) + : FunctionObject(is_arrow_function ? vm().this_value(global_object) : Value(), {}, prototype) , m_name(name) , m_body(body) , m_parameters(move(parameters)) @@ -73,7 +73,7 @@ ScriptFunction::ScriptFunction(GlobalObject& global_object, const FlyString& nam void ScriptFunction::initialize(GlobalObject& global_object) { auto& vm = this->vm(); - Function::initialize(global_object); + Base::initialize(global_object); if (!m_is_arrow_function) { auto* prototype = vm.heap().allocate<Object>(global_object, *global_object.new_script_function_prototype_object_shape()); switch (m_kind) { @@ -97,11 +97,11 @@ ScriptFunction::~ScriptFunction() void ScriptFunction::visit_edges(Visitor& visitor) { - Function::visit_edges(visitor); + Base::visit_edges(visitor); visitor.visit(m_environment); } -FunctionEnvironmentRecord* ScriptFunction::create_environment_record(Function& function_being_invoked) +FunctionEnvironmentRecord* ScriptFunction::create_environment_record(FunctionObject& function_being_invoked) { HashMap<FlyString, Variable> variables; for (auto& parameter : m_parameters) { @@ -225,7 +225,7 @@ Value ScriptFunction::call() return execute_function_body(); } -Value ScriptFunction::construct(Function&) +Value ScriptFunction::construct(FunctionObject&) { if (m_is_arrow_function || m_kind == FunctionKind::Generator) { vm().throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, m_name); diff --git a/Userland/Libraries/LibJS/Runtime/ScriptFunction.h b/Userland/Libraries/LibJS/Runtime/ScriptFunction.h index 6a1f3dd68d..4e44d8bfa3 100644 --- a/Userland/Libraries/LibJS/Runtime/ScriptFunction.h +++ b/Userland/Libraries/LibJS/Runtime/ScriptFunction.h @@ -8,12 +8,12 @@ #include <LibJS/AST.h> #include <LibJS/Bytecode/Generator.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> namespace JS { -class ScriptFunction final : public Function { - JS_OBJECT(ScriptFunction, Function); +class ScriptFunction final : public FunctionObject { + JS_OBJECT(ScriptFunction, FunctionObject); public: static ScriptFunction* create(GlobalObject&, const FlyString& name, const Statement& body, Vector<FunctionNode::Parameter> parameters, i32 m_function_length, EnvironmentRecord* parent_scope, FunctionKind, bool is_strict, bool is_arrow_function = false); @@ -26,7 +26,7 @@ public: const Vector<FunctionNode::Parameter>& parameters() const { return m_parameters; }; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; virtual const FlyString& name() const override { return m_name; }; void set_name(const FlyString& name) { m_name = name; }; @@ -41,7 +41,7 @@ protected: virtual bool is_strict_mode() const final { return m_is_strict; } private: - virtual FunctionEnvironmentRecord* create_environment_record(Function&) override; + virtual FunctionEnvironmentRecord* create_environment_record(FunctionObject&) override; virtual void visit_edges(Visitor&) override; Value execute_function_body(); diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp index cddf37dca1..d29eb4446f 100644 --- a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp @@ -44,7 +44,7 @@ Value SetConstructor::call() } // 24.2.1.1 Set ( [ iterable ] ), https://tc39.es/ecma262/#sec-set-iterable -Value SetConstructor::construct(Function& new_target) +Value SetConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.h b/Userland/Libraries/LibJS/Runtime/SetConstructor.h index 68449500e9..bd1e4f12ff 100644 --- a/Userland/Libraries/LibJS/Runtime/SetConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.h @@ -19,7 +19,7 @@ public: virtual ~SetConstructor() override; virtual Value call() override; - virtual Value construct(Function&) override; + virtual Value construct(FunctionObject&) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index 8d9ab3ed84..4876a07a85 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -53,7 +53,7 @@ Value StringConstructor::call() } // 22.1.1.1 String ( value ), https://tc39.es/ecma262/#sec-string-constructor-string-value -Value StringConstructor::construct(Function&) +Value StringConstructor::construct(FunctionObject&) { PrimitiveString* primitive_string = nullptr; if (!vm().argument_count()) diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.h b/Userland/Libraries/LibJS/Runtime/StringConstructor.h index 7b660540ba..148c9615c5 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.h @@ -19,7 +19,7 @@ public: virtual ~StringConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp index ca5a20d5eb..96fa5046b4 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp @@ -48,7 +48,7 @@ Value SymbolConstructor::call() } // 20.4.1.1 Symbol ( [ description ] ), https://tc39.es/ecma262/#sec-symbol-description -Value SymbolConstructor::construct(Function&) +Value SymbolConstructor::construct(FunctionObject&) { vm().throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, "Symbol"); return {}; diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h index c714272475..ae55b6ce78 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h @@ -19,7 +19,7 @@ public: virtual ~SymbolConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp index 867a34a90a..a757bfd8eb 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp @@ -260,7 +260,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor) } \ \ /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \ - Value ConstructorName::construct(Function&) \ + Value ConstructorName::construct(FunctionObject&) \ { \ auto& vm = this->vm(); \ if (vm.argument_count() == 0) \ diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h index 603d0ef63e..e8e51e104f 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h @@ -196,7 +196,7 @@ private: virtual ~ConstructorName() override; \ \ virtual Value call() override; \ - virtual Value construct(Function& new_target) override; \ + virtual Value construct(FunctionObject& new_target) override; \ \ private: \ virtual bool has_constructor() const override { return true; } \ diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp index b1ff8ae7e7..a1c108d726 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp @@ -47,14 +47,14 @@ Value TypedArrayConstructor::call() } // 23.2.1.1 %TypedArray% ( ), https://tc39.es/ecma262/#sec-%typedarray% -Value TypedArrayConstructor::construct(Function&) +Value TypedArrayConstructor::construct(FunctionObject&) { vm().throw_exception<TypeError>(global_object(), ErrorType::ClassIsAbstract, "TypedArray"); return {}; } // 23.2.4.2 TypedArrayCreate ( constructor, argumentList ), https://tc39.es/ecma262/#typedarray-create -static TypedArrayBase* typed_array_create(GlobalObject& global_object, Function& constructor, MarkedValueList arguments) +static TypedArrayBase* typed_array_create(GlobalObject& global_object, FunctionObject& constructor, MarkedValueList arguments) { auto& vm = global_object.vm(); diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h index 0057f546c6..5b2c3ff9ae 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h @@ -20,7 +20,7 @@ public: virtual ~TypedArrayConstructor() override; virtual Value call() override; - virtual Value construct(Function& new_target) override; + virtual Value construct(FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp index 496565494c..0a9e77bc2e 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp @@ -65,7 +65,7 @@ static TypedArrayBase* typed_array_from(VM& vm, GlobalObject& global_object) return typed_array; } -static Function* callback_from_args(GlobalObject& global_object, const String& name) +static FunctionObject* callback_from_args(GlobalObject& global_object, const String& name) { auto& vm = global_object.vm(); if (vm.argument_count() < 1) { diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index 119599d8d8..de32e8cd89 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -405,12 +405,12 @@ Reference VM::resolve_binding(GlobalObject& global_object, FlyString const& name return Reference { global_object.environment_record(), name }; } -Value VM::construct(Function& function, Function& new_target, Optional<MarkedValueList> arguments) +Value VM::construct(FunctionObject& function, FunctionObject& new_target, Optional<MarkedValueList> arguments) { auto& global_object = function.global_object(); Value this_argument; - if (function.constructor_kind() == Function::ConstructorKind::Base) { + if (function.constructor_kind() == FunctionObject::ConstructorKind::Base) { this_argument = ordinary_create_from_constructor<Object>(global_object, new_target, &GlobalObject::object_prototype); if (exception()) return {}; @@ -457,7 +457,7 @@ Value VM::construct(Function& function, Function& new_target, Optional<MarkedVal // If we are constructing an instance of a derived class, // set the prototype on objects created by constructors that return an object (i.e. NativeFunction subclasses). - if (function.constructor_kind() == Function::ConstructorKind::Base && new_target.constructor_kind() == Function::ConstructorKind::Derived && result.is_object()) { + if (function.constructor_kind() == FunctionObject::ConstructorKind::Base && new_target.constructor_kind() == FunctionObject::ConstructorKind::Derived && result.is_object()) { if (environment) { verify_cast<FunctionEnvironmentRecord>(lexical_environment())->replace_this_binding(result); } @@ -511,7 +511,7 @@ Value VM::get_new_target() return verify_cast<FunctionEnvironmentRecord>(env).new_target(); } -Value VM::call_internal(Function& function, Value this_value, Optional<MarkedValueList> arguments) +Value VM::call_internal(FunctionObject& function, Value this_value, Optional<MarkedValueList> arguments) { VERIFY(!exception()); VERIFY(!this_value.is_empty()); diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index 6e06771118..22f3692814 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -45,7 +45,7 @@ struct ScopeFrame { struct ExecutionContext { const ASTNode* current_node { nullptr }; FlyString function_name; - Function* function { nullptr }; + FunctionObject* function { nullptr }; Value this_value; Vector<Value> arguments; Array* arguments_object { nullptr }; @@ -224,14 +224,14 @@ public: return throw_exception(global_object, T::create(global_object, String::formatted(type.message(), forward<Args>(args)...))); } - Value construct(Function&, Function& new_target, Optional<MarkedValueList> arguments); + Value construct(FunctionObject&, FunctionObject& new_target, Optional<MarkedValueList> arguments); String join_arguments(size_t start_index = 0) const; Value get_new_target(); template<typename... Args> - [[nodiscard]] ALWAYS_INLINE Value call(Function& function, Value this_value, Args... args) + [[nodiscard]] ALWAYS_INLINE Value call(FunctionObject& function, Value this_value, Args... args) { if constexpr (sizeof...(Args) > 0) { MarkedValueList arglist { heap() }; @@ -259,7 +259,7 @@ public: private: VM(); - [[nodiscard]] Value call_internal(Function&, Value this_value, Optional<MarkedValueList> arguments); + [[nodiscard]] Value call_internal(FunctionObject&, Value this_value, Optional<MarkedValueList> arguments); Exception* m_exception { nullptr }; @@ -294,13 +294,13 @@ private: }; template<> -[[nodiscard]] ALWAYS_INLINE Value VM::call(Function& function, Value this_value, MarkedValueList arguments) { return call_internal(function, this_value, move(arguments)); } +[[nodiscard]] ALWAYS_INLINE Value VM::call(FunctionObject& function, Value this_value, MarkedValueList arguments) { return call_internal(function, this_value, move(arguments)); } template<> -[[nodiscard]] ALWAYS_INLINE Value VM::call(Function& function, Value this_value, Optional<MarkedValueList> arguments) { return call_internal(function, this_value, move(arguments)); } +[[nodiscard]] ALWAYS_INLINE Value VM::call(FunctionObject& function, Value this_value, Optional<MarkedValueList> arguments) { return call_internal(function, this_value, move(arguments)); } template<> -[[nodiscard]] ALWAYS_INLINE Value VM::call(Function& function, Value this_value) { return call(function, this_value, Optional<MarkedValueList> {}); } +[[nodiscard]] ALWAYS_INLINE Value VM::call(FunctionObject& function, Value this_value) { return call(function, this_value, Optional<MarkedValueList> {}); } ALWAYS_INLINE Heap& Cell::heap() const { diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index f1fa366a31..7ded9e7982 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -21,7 +21,7 @@ #include <LibJS/Runtime/BooleanObject.h> #include <LibJS/Runtime/BoundFunction.h> #include <LibJS/Runtime/Error.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/NativeFunction.h> #include <LibJS/Runtime/NumberObject.h> @@ -229,10 +229,10 @@ bool Value::is_function() const return is_object() && as_object().is_function(); } -Function& Value::as_function() +FunctionObject& Value::as_function() { VERIFY(is_function()); - return static_cast<Function&>(as_object()); + return static_cast<FunctionObject&>(as_object()); } // 7.2.4 IsConstructor ( argument ), https://tc39.es/ecma262/#sec-isconstructor @@ -808,7 +808,7 @@ Value Value::get(GlobalObject& global_object, PropertyName const& property_name) } // 7.3.10 GetMethod ( V, P ), https://tc39.es/ecma262/#sec-getmethod -Function* Value::get_method(GlobalObject& global_object, PropertyName const& property_name) const +FunctionObject* Value::get_method(GlobalObject& global_object, PropertyName const& property_name) const { auto& vm = global_object.vm(); diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index 16d08f2a29..18929724ef 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -252,7 +252,7 @@ public: } Array& as_array(); - Function& as_function(); + FunctionObject& as_function(); i32 as_i32() const; u32 as_u32() const; @@ -288,7 +288,7 @@ public: bool to_boolean() const; Value get(GlobalObject&, PropertyName const&) const; - Function* get_method(GlobalObject&, PropertyName const&) const; + FunctionObject* get_method(GlobalObject&, PropertyName const&) const; String to_string_without_side_effects() const; diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp index b51761d0ec..35fef084fd 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp @@ -42,7 +42,7 @@ Value WeakMapConstructor::call() } // 24.3.1.1 WeakMap ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakmap-iterable -Value WeakMapConstructor::construct(Function& new_target) +Value WeakMapConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h index 42d47eadad..df71a2b69f 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h @@ -19,7 +19,7 @@ public: virtual ~WeakMapConstructor() override; virtual Value call() override; - virtual Value construct(Function&) override; + virtual Value construct(FunctionObject&) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp index 37e4b95988..ee9cbed6da 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp @@ -41,7 +41,7 @@ Value WeakRefConstructor::call() } // 26.1.1.1 WeakRef ( target ), https://tc39.es/ecma262/#sec-weak-ref-target -Value WeakRefConstructor::construct(Function& new_target) +Value WeakRefConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h index 543bc5049f..346537d5d9 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h @@ -19,7 +19,7 @@ public: virtual ~WeakRefConstructor() override; virtual Value call() override; - virtual Value construct(Function&) override; + virtual Value construct(FunctionObject&) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp index 9509e63082..de5b8712bd 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp @@ -42,7 +42,7 @@ Value WeakSetConstructor::call() } // 24.4.1.1 WeakSet ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakset-iterable -Value WeakSetConstructor::construct(Function& new_target) +Value WeakSetConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h index 0e3c5838ab..93e54888e8 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h @@ -19,7 +19,7 @@ public: virtual ~WeakSetConstructor() override; virtual Value call() override; - virtual Value construct(Function&) override; + virtual Value construct(FunctionObject&) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp b/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp index 2af9ac26bb..0726f3358a 100644 --- a/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp +++ b/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibWeb/Bindings/EventListenerWrapper.h> #include <LibWeb/DOM/EventListener.h> diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp index ce9ee85778..e18fcb0b60 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp @@ -40,7 +40,7 @@ JS::Value ImageConstructor::call() } // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-image -JS::Value ImageConstructor::construct(Function&) +JS::Value ImageConstructor::construct(FunctionObject&) { auto& window = static_cast<WindowObject&>(global_object()); auto& document = window.impl().document(); diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h index 7f5ae51f41..54959d0cab 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h @@ -17,7 +17,7 @@ public: virtual ~ImageConstructor() override; virtual JS::Value call() override; - virtual JS::Value construct(JS::Function& new_target) override; + virtual JS::Value construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp index fd3d441432..b5c54ef232 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -8,7 +8,7 @@ #include <AK/String.h> #include <AK/Utf8View.h> #include <LibJS/Runtime/Error.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/Shape.h> #include <LibTextCodec/Decoder.h> #include <LibWeb/Bindings/DocumentWrapper.h> @@ -192,7 +192,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::set_interval) interval = 0; } - auto timer_id = impl->set_interval(*static_cast<JS::Function*>(callback_object), interval); + auto timer_id = impl->set_interval(*static_cast<JS::FunctionObject*>(callback_object), interval); return JS::Value(timer_id); } @@ -221,7 +221,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::set_timeout) interval = 0; } - auto timer_id = impl->set_timeout(*static_cast<JS::Function*>(callback_object), interval); + auto timer_id = impl->set_timeout(*static_cast<JS::FunctionObject*>(callback_object), interval); return JS::Value(timer_id); } @@ -273,7 +273,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::request_animation_frame) vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotAFunctionNoParam); return {}; } - return JS::Value(impl->request_animation_frame(*static_cast<JS::Function*>(callback_object))); + return JS::Value(impl->request_animation_frame(*static_cast<JS::FunctionObject*>(callback_object))); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::cancel_animation_frame) diff --git a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index 7180d2e299..31626bdb6f 100644 --- a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -854,7 +854,7 @@ void generate_implementation(const IDL::Interface& interface) #include <AK/FlyString.h> #include <LibJS/Runtime/Array.h> #include <LibJS/Runtime/Error.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/TypedArray.h> #include <LibJS/Runtime/Value.h> @@ -968,7 +968,7 @@ public: virtual ~@constructor_class@() override; virtual JS::Value call() override; - virtual JS::Value construct(JS::Function& new_target) override; + virtual JS::Value construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } @@ -1040,7 +1040,7 @@ JS::Value @constructor_class@::call() return {}; } -JS::Value @constructor_class@::construct(Function&) +JS::Value @constructor_class@::construct(FunctionObject&) { )~~~"); @@ -1198,7 +1198,7 @@ void generate_prototype_implementation(const IDL::Interface& interface) #include <AK/Function.h> #include <LibJS/Runtime/Array.h> #include <LibJS/Runtime/Error.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/TypedArray.h> #include <LibWeb/Bindings/@prototype_class@.h> diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 660828084f..a97d29207f 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -12,7 +12,7 @@ #include <LibCore/Timer.h> #include <LibJS/Interpreter.h> #include <LibJS/Parser.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibWeb/Bindings/MainThreadVM.h> #include <LibWeb/Bindings/WindowObject.h> #include <LibWeb/CSS/StyleResolver.h> diff --git a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp index c4d4133dc4..d6cb1ca939 100644 --- a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp @@ -6,7 +6,7 @@ #include <AK/Assertions.h> #include <AK/TypeCasts.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibWeb/Bindings/EventTargetWrapper.h> #include <LibWeb/Bindings/EventTargetWrapperFactory.h> #include <LibWeb/Bindings/EventWrapper.h> diff --git a/Userland/Libraries/LibWeb/DOM/EventListener.cpp b/Userland/Libraries/LibWeb/DOM/EventListener.cpp index bc03456a6d..29669cf12e 100644 --- a/Userland/Libraries/LibWeb/DOM/EventListener.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventListener.cpp @@ -4,12 +4,12 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibWeb/DOM/EventListener.h> namespace Web::DOM { -JS::Function& EventListener::function() +JS::FunctionObject& EventListener::function() { VERIFY(m_function.cell()); return *m_function.cell(); diff --git a/Userland/Libraries/LibWeb/DOM/EventListener.h b/Userland/Libraries/LibWeb/DOM/EventListener.h index cb77acfc59..8291d722b1 100644 --- a/Userland/Libraries/LibWeb/DOM/EventListener.h +++ b/Userland/Libraries/LibWeb/DOM/EventListener.h @@ -18,13 +18,13 @@ class EventListener public: using WrapperType = Bindings::EventListenerWrapper; - explicit EventListener(JS::Handle<JS::Function> function, bool is_attribute = false) + explicit EventListener(JS::Handle<JS::FunctionObject> function, bool is_attribute = false) : m_function(move(function)) , m_attribute(is_attribute) { } - JS::Function& function(); + JS::FunctionObject& function(); const FlyString& type() const { return m_type; } void set_type(const FlyString& type) { m_type = type; } @@ -45,7 +45,7 @@ public: private: FlyString m_type; - JS::Handle<JS::Function> m_function; + JS::Handle<JS::FunctionObject> m_function; bool m_capture { false }; bool m_passive { false }; bool m_once { false }; diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index aacf3cc5b5..ea0dea14dd 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -8,7 +8,7 @@ #include <AK/StringBuilder.h> #include <LibJS/AST.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibWeb/Bindings/EventWrapper.h> #include <LibWeb/Bindings/NodeWrapper.h> #include <LibWeb/Bindings/NodeWrapperFactory.h> diff --git a/Userland/Libraries/LibWeb/DOM/Timer.cpp b/Userland/Libraries/LibWeb/DOM/Timer.cpp index 4ef944a9eb..3f1f943dc2 100644 --- a/Userland/Libraries/LibWeb/DOM/Timer.cpp +++ b/Userland/Libraries/LibWeb/DOM/Timer.cpp @@ -5,23 +5,23 @@ */ #include <LibCore/Timer.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibWeb/DOM/Timer.h> #include <LibWeb/DOM/Window.h> namespace Web::DOM { -NonnullRefPtr<Timer> Timer::create_interval(Window& window, int milliseconds, JS::Function& callback) +NonnullRefPtr<Timer> Timer::create_interval(Window& window, int milliseconds, JS::FunctionObject& callback) { return adopt_ref(*new Timer(window, Type::Interval, milliseconds, callback)); } -NonnullRefPtr<Timer> Timer::create_timeout(Window& window, int milliseconds, JS::Function& callback) +NonnullRefPtr<Timer> Timer::create_timeout(Window& window, int milliseconds, JS::FunctionObject& callback) { return adopt_ref(*new Timer(window, Type::Timeout, milliseconds, callback)); } -Timer::Timer(Window& window, Type type, int milliseconds, JS::Function& callback) +Timer::Timer(Window& window, Type type, int milliseconds, JS::FunctionObject& callback) : m_window(window) , m_type(type) , m_callback(JS::make_handle(&callback)) diff --git a/Userland/Libraries/LibWeb/DOM/Timer.h b/Userland/Libraries/LibWeb/DOM/Timer.h index 47c6f4768c..e948d6bfc4 100644 --- a/Userland/Libraries/LibWeb/DOM/Timer.h +++ b/Userland/Libraries/LibWeb/DOM/Timer.h @@ -9,7 +9,7 @@ #include <AK/Forward.h> #include <LibCore/Forward.h> #include <LibJS/Heap/Handle.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibWeb/Forward.h> namespace Web::DOM { @@ -21,24 +21,24 @@ public: Timeout, }; - static NonnullRefPtr<Timer> create_interval(Window&, int milliseconds, JS::Function&); - static NonnullRefPtr<Timer> create_timeout(Window&, int milliseconds, JS::Function&); + static NonnullRefPtr<Timer> create_interval(Window&, int milliseconds, JS::FunctionObject&); + static NonnullRefPtr<Timer> create_timeout(Window&, int milliseconds, JS::FunctionObject&); ~Timer(); i32 id() const { return m_id; } Type type() const { return m_type; } - JS::Function& callback() { return *m_callback.cell(); } + JS::FunctionObject& callback() { return *m_callback.cell(); } private: - Timer(Window&, Type, int ms, JS::Function&); + Timer(Window&, Type, int ms, JS::FunctionObject&); Window& m_window; RefPtr<Core::Timer> m_timer; Type m_type; int m_id { 0 }; - JS::Handle<JS::Function> m_callback; + JS::Handle<JS::FunctionObject> m_callback; }; } diff --git a/Userland/Libraries/LibWeb/DOM/Window.cpp b/Userland/Libraries/LibWeb/DOM/Window.cpp index 24ff88fc88..321241b20b 100644 --- a/Userland/Libraries/LibWeb/DOM/Window.cpp +++ b/Userland/Libraries/LibWeb/DOM/Window.cpp @@ -5,7 +5,7 @@ */ #include <LibGUI/DisplayLink.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Event.h> #include <LibWeb/DOM/EventDispatcher.h> @@ -60,14 +60,14 @@ String Window::prompt(const String& message, const String& default_) return {}; } -i32 Window::set_interval(JS::Function& callback, i32 interval) +i32 Window::set_interval(JS::FunctionObject& callback, i32 interval) { auto timer = Timer::create_interval(*this, interval, callback); m_timers.set(timer->id(), timer); return timer->id(); } -i32 Window::set_timeout(JS::Function& callback, i32 interval) +i32 Window::set_timeout(JS::FunctionObject& callback, i32 interval) { auto timer = Timer::create_timeout(*this, interval, callback); m_timers.set(timer->id(), timer); @@ -112,13 +112,13 @@ void Window::clear_interval(i32 timer_id) m_timers.remove(timer_id); } -i32 Window::request_animation_frame(JS::Function& callback) +i32 Window::request_animation_frame(JS::FunctionObject& callback) { // FIXME: This is extremely fake! static double fake_timestamp = 0; i32 link_id = GUI::DisplayLink::register_callback([handle = make_handle(&callback)](i32 link_id) { - auto& function = const_cast<JS::Function&>(static_cast<const JS::Function&>(*handle.cell())); + auto& function = const_cast<JS::FunctionObject&>(static_cast<const JS::FunctionObject&>(*handle.cell())); auto& vm = function.vm(); fake_timestamp += 10; [[maybe_unused]] auto rc = vm.call(function, JS::js_undefined(), JS::Value(fake_timestamp)); diff --git a/Userland/Libraries/LibWeb/DOM/Window.h b/Userland/Libraries/LibWeb/DOM/Window.h index 55d288278a..ca3095b416 100644 --- a/Userland/Libraries/LibWeb/DOM/Window.h +++ b/Userland/Libraries/LibWeb/DOM/Window.h @@ -39,11 +39,11 @@ public: void alert(const String&); bool confirm(const String&); String prompt(const String&, const String&); - i32 request_animation_frame(JS::Function&); + i32 request_animation_frame(JS::FunctionObject&); void cancel_animation_frame(i32); - i32 set_timeout(JS::Function&, i32); - i32 set_interval(JS::Function&, i32); + i32 set_timeout(JS::FunctionObject&, i32); + i32 set_interval(JS::FunctionObject&, i32); void clear_timeout(i32); void clear_interval(i32); diff --git a/Userland/Libraries/LibWeb/HTML/EventHandler.h b/Userland/Libraries/LibWeb/HTML/EventHandler.h index 29bf3b9c58..f1a51f95f9 100644 --- a/Userland/Libraries/LibWeb/HTML/EventHandler.h +++ b/Userland/Libraries/LibWeb/HTML/EventHandler.h @@ -8,7 +8,7 @@ #include <AK/String.h> #include <LibJS/Heap/Handle.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> namespace Web::HTML { @@ -22,13 +22,13 @@ struct EventHandler { { } - EventHandler(JS::Handle<JS::Function> c) + EventHandler(JS::Handle<JS::FunctionObject> c) : callback(move(c)) { } String string; - JS::Handle<JS::Function> callback; + JS::Handle<JS::FunctionObject> callback; }; } diff --git a/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp b/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp index 8a6006c028..6ab8133a33 100644 --- a/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp +++ b/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.cpp @@ -51,7 +51,7 @@ void GlobalEventHandlers::set_event_handler_attribute(const FlyString& name, HTM } auto* function = JS::ScriptFunction::create(self.script_execution_context()->interpreter().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<JS::Function*>(function)))); + listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast<JS::FunctionObject*>(function)))); } if (listener) { for (auto& registered_listener : self.listeners()) { diff --git a/Userland/Libraries/LibWeb/HTML/WebSocket.cpp b/Userland/Libraries/LibWeb/HTML/WebSocket.cpp index ae3eff091a..82273a7bc5 100644 --- a/Userland/Libraries/LibWeb/HTML/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/HTML/WebSocket.cpp @@ -6,7 +6,7 @@ #include <LibJS/Interpreter.h> #include <LibJS/Parser.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/ScriptFunction.h> #include <LibProtocol/WebSocket.h> #include <LibProtocol/WebSocketClient.h> @@ -248,7 +248,7 @@ void WebSocket::set_event_handler_attribute(const FlyString& name, HTML::EventHa } auto* function = JS::ScriptFunction::create(script_execution_context()->interpreter().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<JS::Function*>(function)))); + listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast<JS::FunctionObject*>(function)))); } if (listener) { for (auto& registered_listener : listeners()) { diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp index 4a8ce4a786..f6c0e8dc4c 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp @@ -28,7 +28,7 @@ JS::Value WebAssemblyMemoryConstructor::call() return {}; } -JS::Value WebAssemblyMemoryConstructor::construct(Function&) +JS::Value WebAssemblyMemoryConstructor::construct(FunctionObject&) { auto& vm = this->vm(); auto& global_object = this->global_object(); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h index ecf8896449..c14f127871 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h @@ -19,7 +19,7 @@ public: virtual ~WebAssemblyMemoryConstructor() override; virtual JS::Value call() override; - virtual JS::Value construct(JS::Function& new_target) override; + virtual JS::Value construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h index 99f762c859..1229545e53 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h @@ -39,7 +39,7 @@ public: // so ideally this would be a refcounted object, shared between // WebAssemblyModuleObject's and WebAssemblyInstantiatedModuleObject's. struct ModuleCache { - HashMap<Wasm::FunctionAddress, JS::Function*> function_instances; + HashMap<Wasm::FunctionAddress, JS::FunctionObject*> function_instances; HashMap<Wasm::MemoryAddress, WebAssemblyMemoryObject*> memory_instances; }; struct GlobalModuleCache { diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 250f22fc39..3568efe714 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -5,7 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibWeb/Bindings/EventWrapper.h> #include <LibWeb/Bindings/XMLHttpRequestWrapper.h> #include <LibWeb/DOM/DOMException.h> diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index a4beb6ff20..50fdb22134 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -27,7 +27,7 @@ #include <LibJS/Runtime/DataView.h> #include <LibJS/Runtime/Date.h> #include <LibJS/Runtime/Error.h> -#include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/Map.h> #include <LibJS/Runtime/NativeFunction.h> |