LibJS: Rename Function => FunctionObject
This commit is contained in:
parent
e389ae3c97
commit
ba9d5c4d54
Notes:
sideshowbarker
2024-07-18 11:26:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ba9d5c4d54d
114 changed files with 263 additions and 262 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) \
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 {};
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace JS {
|
|||
P(Boolean) \
|
||||
P(E) \
|
||||
P(EPSILON) \
|
||||
P(Function) \
|
||||
P(Infinity) \
|
||||
P(JSON) \
|
||||
P(LN10) \
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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(); \
|
||||
|
|
|
@ -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; } \
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
@ -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; }
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
||||
namespace JS {
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 = "";
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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 {};
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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) \
|
||||
|
|
|
@ -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; } \
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue