mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors
Note that as of this commit, there aren't any such throwers, and the call site in Heap::allocate will drop exceptions on the floor. This commit only serves to change the declaration of the overrides, make sure they return an empty value, and to propagate OOM errors frm their base initialize invocations.
This commit is contained in:
parent
1c1b902a6a
commit
2692db8699
Notes:
sideshowbarker
2024-07-17 01:01:29 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/2692db8699 Pull-request: https://github.com/SerenityOS/serenity/pull/17220 Reviewed-by: https://github.com/linusg ✅
694 changed files with 1774 additions and 1065 deletions
|
@ -18,12 +18,14 @@ ConsoleGlobalObject::ConsoleGlobalObject(JS::Realm& realm, Web::HTML::Window& pa
|
|||
{
|
||||
}
|
||||
|
||||
void ConsoleGlobalObject::initialize(JS::Realm& realm)
|
||||
JS::ThrowCompletionOr<void> ConsoleGlobalObject::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
// $0 magic variable
|
||||
define_native_accessor(realm, "$0", inspected_node_getter, nullptr, 0);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void ConsoleGlobalObject::visit_edges(Visitor& visitor)
|
||||
|
|
|
@ -24,7 +24,7 @@ class ConsoleGlobalObject final : public JS::GlobalObject {
|
|||
|
||||
public:
|
||||
ConsoleGlobalObject(JS::Realm&, Web::HTML::Window&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
virtual ~ConsoleGlobalObject() override = default;
|
||||
|
||||
virtual JS::ThrowCompletionOr<Object*> internal_get_prototype_of() const override;
|
||||
|
|
|
@ -121,7 +121,7 @@ class TestRunnerGlobalObject final : public JS::GlobalObject {
|
|||
|
||||
public:
|
||||
TestRunnerGlobalObject(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
virtual ~TestRunnerGlobalObject() override;
|
||||
|
||||
private:
|
||||
|
@ -168,11 +168,13 @@ JS_DEFINE_NATIVE_FUNCTION(TestRunnerGlobalObject::fuzzilli)
|
|||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
void TestRunnerGlobalObject::initialize(JS::Realm& realm)
|
||||
JS::ThrowCompletionOr<void> TestRunnerGlobalObject::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
define_direct_property("global", this, JS::Attribute::Enumerable);
|
||||
define_native_function(realm, "fuzzilli", fuzzilli, 2, JS::default_attributes);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
|
|
|
@ -2001,7 +2001,7 @@ class @constructor_class@ : public JS::NativeFunction {
|
|||
JS_OBJECT(@constructor_class@, JS::NativeFunction);
|
||||
public:
|
||||
explicit @constructor_class@(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
virtual ~@constructor_class@() override;
|
||||
|
||||
virtual JS::ThrowCompletionOr<JS::Value> call() override;
|
||||
|
@ -2183,12 +2183,12 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::constru
|
|||
generator.append(R"~~~(
|
||||
}
|
||||
|
||||
void @constructor_class@::initialize(JS::Realm& realm)
|
||||
JS::ThrowCompletionOr<void> @constructor_class@::initialize(JS::Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
[[maybe_unused]] u8 default_attributes = JS::Attribute::Enumerable;
|
||||
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
define_direct_property(vm.names.prototype, &ensure_web_prototype<@prototype_class@>(realm, "@name@"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(@constructor.length@), JS::Attribute::Configurable);
|
||||
|
||||
|
@ -2218,6 +2218,7 @@ void @constructor_class@::initialize(JS::Realm& realm)
|
|||
}
|
||||
|
||||
generator.append(R"~~~(
|
||||
return {};
|
||||
}
|
||||
)~~~");
|
||||
|
||||
|
@ -2255,7 +2256,7 @@ class @prototype_class@ : public JS::Object {
|
|||
JS_OBJECT(@prototype_class@, JS::Object);
|
||||
public:
|
||||
explicit @prototype_class@(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
virtual ~@prototype_class@() override;
|
||||
private:
|
||||
)~~~");
|
||||
|
@ -2458,7 +2459,7 @@ namespace Web::Bindings {
|
|||
{
|
||||
}
|
||||
|
||||
void @prototype_class@::initialize(JS::Realm& realm)
|
||||
JS::ThrowCompletionOr<void> @prototype_class@::initialize(JS::Realm& realm)
|
||||
{
|
||||
[[maybe_unused]] auto& vm = this->vm();
|
||||
[[maybe_unused]] u8 default_attributes = JS::Attribute::Enumerable | JS::Attribute::Configurable | JS::Attribute::Writable;
|
||||
|
@ -2576,7 +2577,8 @@ void @prototype_class@::initialize(JS::Realm& realm)
|
|||
generator.append(R"~~~(
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm, "@name@"), JS::Attribute::Configurable);
|
||||
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Object::initialize(realm));
|
||||
return {};
|
||||
}
|
||||
)~~~");
|
||||
|
||||
|
@ -2811,7 +2813,7 @@ class @prototype_class@ : public JS::Object {
|
|||
JS_OBJECT(@prototype_class@, JS::Object);
|
||||
public:
|
||||
explicit @prototype_class@(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
virtual ~@prototype_class@() override;
|
||||
|
||||
private:
|
||||
|
@ -2881,13 +2883,15 @@ namespace Web::Bindings {
|
|||
{
|
||||
}
|
||||
|
||||
void @prototype_class@::initialize(JS::Realm& realm)
|
||||
JS::ThrowCompletionOr<void> @prototype_class@::initialize(JS::Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Object::initialize(realm));
|
||||
|
||||
define_native_function(realm, vm.names.next, next, 0, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm, "Iterator"), JS::Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
static JS::ThrowCompletionOr<@fully_qualified_name@*> impl_from(JS::VM& vm)
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
: GlobalObject(realm)
|
||||
{
|
||||
}
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
virtual ~ReplObject() override = default;
|
||||
|
||||
private:
|
||||
|
@ -235,9 +235,9 @@ static bool parse_and_run(JS::Interpreter& interpreter, StringView source, Strin
|
|||
return true;
|
||||
}
|
||||
|
||||
void ReplObject::initialize(JS::Realm& realm)
|
||||
JS::ThrowCompletionOr<void> ReplObject::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
define_direct_property("global", this, JS::Attribute::Enumerable);
|
||||
u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
|
||||
|
@ -262,6 +262,8 @@ void ReplObject::initialize(JS::Realm& realm)
|
|||
return value;
|
||||
},
|
||||
attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(ReplObject::print)
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
instance->m_module_instance = result.release_value();
|
||||
return instance.ptr();
|
||||
}
|
||||
void initialize(JS::Realm&) override;
|
||||
JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
|
||||
~WebAssemblyModule() override = default;
|
||||
|
||||
|
@ -143,11 +143,13 @@ TESTJS_GLOBAL_FUNCTION(compare_typed_arrays, compareTypedArrays)
|
|||
return JS::Value(lhs_array.viewed_array_buffer()->buffer() == rhs_array.viewed_array_buffer()->buffer());
|
||||
}
|
||||
|
||||
void WebAssemblyModule::initialize(JS::Realm& realm)
|
||||
JS::ThrowCompletionOr<void> WebAssemblyModule::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
define_native_function(realm, "getExport", get_export, 1, JS::default_attributes);
|
||||
define_native_function(realm, "invoke", wasm_invoke, 1, JS::default_attributes);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export)
|
||||
|
|
|
@ -144,9 +144,9 @@ JS::ThrowCompletionOr<bool> SheetGlobalObject::internal_set(const JS::PropertyKe
|
|||
return Base::internal_set(property_name, value, receiver);
|
||||
}
|
||||
|
||||
void SheetGlobalObject::initialize(JS::Realm& realm)
|
||||
JS::ThrowCompletionOr<void> SheetGlobalObject::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
|
||||
define_native_function(realm, "get_real_cell_contents", get_real_cell_contents, 1, attr);
|
||||
|
@ -157,6 +157,8 @@ void SheetGlobalObject::initialize(JS::Realm& realm)
|
|||
define_native_function(realm, "column_index", column_index, 1, attr);
|
||||
define_native_function(realm, "get_column_bound", get_column_bound, 1, attr);
|
||||
define_native_accessor(realm, "name", get_name, nullptr, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void SheetGlobalObject::visit_edges(Visitor& visitor)
|
||||
|
@ -376,10 +378,12 @@ WorkbookObject::WorkbookObject(JS::Realm& realm, Workbook& workbook)
|
|||
{
|
||||
}
|
||||
|
||||
void WorkbookObject::initialize(JS::Realm& realm)
|
||||
JS::ThrowCompletionOr<void> WorkbookObject::initialize(JS::Realm& realm)
|
||||
{
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Object::initialize(realm));
|
||||
define_native_function(realm, "sheet", sheet, 1, JS::default_attributes);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void WorkbookObject::visit_edges(Visitor& visitor)
|
||||
|
|
|
@ -24,7 +24,7 @@ class SheetGlobalObject final : public JS::GlobalObject {
|
|||
|
||||
public:
|
||||
SheetGlobalObject(JS::Realm&, Sheet&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
virtual ~SheetGlobalObject() override = default;
|
||||
|
||||
virtual JS::ThrowCompletionOr<bool> internal_has_property(JS::PropertyKey const& name) const override;
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
|
||||
virtual ~WorkbookObject() override = default;
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(sheet);
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ $262Object::$262Object(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void $262Object::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> $262Object::initialize(Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
m_agent = vm().heap().allocate<AgentObject>(realm, realm);
|
||||
m_is_htmldda = vm().heap().allocate<IsHTMLDDA>(realm, realm);
|
||||
|
@ -41,6 +41,8 @@ void $262Object::initialize(Realm& realm)
|
|||
define_direct_property("gc", realm.global_object().get_without_side_effects("gc"), attr);
|
||||
define_direct_property("global", &realm.global_object(), attr);
|
||||
define_direct_property("IsHTMLDDA", m_is_htmldda, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void $262Object::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -17,7 +17,7 @@ class $262Object final : public Object {
|
|||
JS_OBJECT($262Object, Object);
|
||||
|
||||
public:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~$262Object() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -17,9 +17,9 @@ AgentObject::AgentObject(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void AgentObject::initialize(JS::Realm& realm)
|
||||
JS::ThrowCompletionOr<void> AgentObject::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, "monotonicNow", monotonic_now, 0, attr);
|
||||
|
@ -27,6 +27,8 @@ void AgentObject::initialize(JS::Realm& realm)
|
|||
// TODO: broadcast
|
||||
// TODO: getReport
|
||||
// TODO: start
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(AgentObject::monotonic_now)
|
||||
|
|
|
@ -15,7 +15,7 @@ class AgentObject final : public Object {
|
|||
JS_OBJECT(AgentObject, Object);
|
||||
|
||||
public:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual JS::ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AgentObject() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
namespace JS::Test262 {
|
||||
|
||||
void GlobalObject::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> GlobalObject::initialize(Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
m_$262 = vm().heap().allocate<$262Object>(realm, realm);
|
||||
|
||||
|
@ -24,6 +24,8 @@ void GlobalObject::initialize(Realm& realm)
|
|||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, "print", print, 1, attr);
|
||||
define_direct_property("$262", m_$262, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void GlobalObject::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -15,7 +15,7 @@ class GlobalObject final : public JS::GlobalObject {
|
|||
JS_OBJECT(GlobalObject, JS::GlobalObject);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~GlobalObject() override = default;
|
||||
|
||||
$262Object* $262() const { return m_$262; }
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -31,7 +32,7 @@ class Cell {
|
|||
AK_MAKE_NONMOVABLE(Cell);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) { }
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) { return {}; }
|
||||
virtual ~Cell() = default;
|
||||
|
||||
bool is_marked() const { return m_mark; }
|
||||
|
|
|
@ -46,7 +46,10 @@ public:
|
|||
auto* memory = allocate_cell(sizeof(T));
|
||||
new (memory) T(forward<Args>(args)...);
|
||||
auto* cell = static_cast<T*>(memory);
|
||||
memory->initialize(realm);
|
||||
|
||||
// FIXME: Propagate this error.
|
||||
(void)memory->initialize(realm);
|
||||
|
||||
return *cell;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,17 @@ AggregateErrorConstructor::AggregateErrorConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void AggregateErrorConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> AggregateErrorConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 20.5.7.2.1 AggregateError.prototype, https://tc39.es/ecma262/#sec-aggregate-error.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().aggregate_error_prototype(), 0);
|
||||
|
||||
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 20.5.7.1.1 AggregateError ( errors, message [ , options ] ), https://tc39.es/ecma262/#sec-aggregate-error
|
||||
|
|
|
@ -14,7 +14,7 @@ class AggregateErrorConstructor final : public NativeFunction {
|
|||
JS_OBJECT(AggregateErrorConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AggregateErrorConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -15,13 +15,15 @@ AggregateErrorPrototype::AggregateErrorPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void AggregateErrorPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> AggregateErrorPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_direct_property(vm.names.name, PrimitiveString::create(vm, "AggregateError"), attr);
|
||||
define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class AggregateErrorPrototype final : public Object {
|
|||
JS_OBJECT(AggregateErrorPrototype, Object);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AggregateErrorPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -16,11 +16,13 @@ ArgumentsObject::ArgumentsObject(Realm& realm, Environment& environment)
|
|||
{
|
||||
}
|
||||
|
||||
void ArgumentsObject::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> ArgumentsObject::initialize(Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
set_has_parameter_map();
|
||||
m_parameter_map = Object::create(realm, nullptr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void ArgumentsObject::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -16,7 +16,7 @@ class ArgumentsObject final : public Object {
|
|||
JS_OBJECT(ArgumentsObject, Object);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~ArgumentsObject() override = default;
|
||||
|
||||
Environment& environment() { return m_environment; }
|
||||
|
|
|
@ -19,10 +19,10 @@ ArrayBufferConstructor::ArrayBufferConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void ArrayBufferConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> ArrayBufferConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 25.1.4.2 ArrayBuffer.prototype, https://tc39.es/ecma262/#sec-arraybuffer.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().array_buffer_prototype(), 0);
|
||||
|
@ -34,6 +34,8 @@ void ArrayBufferConstructor::initialize(Realm& realm)
|
|||
define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
|
||||
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 25.1.3.1 ArrayBuffer ( length ), https://tc39.es/ecma262/#sec-arraybuffer-length
|
||||
|
|
|
@ -14,7 +14,7 @@ class ArrayBufferConstructor final : public NativeFunction {
|
|||
JS_OBJECT(ArrayBufferConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~ArrayBufferConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -19,16 +19,18 @@ ArrayBufferPrototype::ArrayBufferPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void ArrayBufferPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> ArrayBufferPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.slice, slice, 2, attr);
|
||||
define_native_accessor(realm, vm.names.byteLength, byte_length_getter, {}, Attribute::Configurable);
|
||||
|
||||
// 25.1.5.4 ArrayBuffer.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-arraybuffer.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.ArrayBuffer.as_string()), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 25.1.5.3 ArrayBuffer.prototype.slice ( start, end ), https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice
|
||||
|
|
|
@ -15,7 +15,7 @@ class ArrayBufferPrototype final : public PrototypeObject<ArrayBufferPrototype,
|
|||
JS_PROTOTYPE_OBJECT(ArrayBufferPrototype, ArrayBuffer, ArrayBuffer);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~ArrayBufferPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -21,10 +21,10 @@ ArrayConstructor::ArrayConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void ArrayConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> ArrayConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 23.1.2.4 Array.prototype, https://tc39.es/ecma262/#sec-array.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().array_prototype(), 0);
|
||||
|
@ -38,6 +38,8 @@ void ArrayConstructor::initialize(Realm& realm)
|
|||
define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
|
||||
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 23.1.1.1 Array ( ...values ), https://tc39.es/ecma262/#sec-array
|
||||
|
|
|
@ -14,7 +14,7 @@ class ArrayConstructor final : public NativeFunction {
|
|||
JS_OBJECT(ArrayConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~ArrayConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -19,15 +19,17 @@ ArrayIteratorPrototype::ArrayIteratorPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void ArrayIteratorPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> ArrayIteratorPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable);
|
||||
|
||||
// 23.1.5.2.2 %ArrayIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Array Iterator"), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 23.1.5.2.1 %ArrayIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
|
||||
|
|
|
@ -15,7 +15,7 @@ class ArrayIteratorPrototype final : public PrototypeObject<ArrayIteratorPrototy
|
|||
JS_PROTOTYPE_OBJECT(ArrayIteratorPrototype, ArrayIterator, ArrayIterator);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~ArrayIteratorPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -33,10 +33,10 @@ ArrayPrototype::ArrayPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void ArrayPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> ArrayPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Array::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Array::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
|
||||
define_native_function(realm, vm.names.at, at, 1, attr);
|
||||
|
@ -110,6 +110,8 @@ void ArrayPrototype::initialize(Realm& realm)
|
|||
MUST(unscopable_list->create_data_property_or_throw(vm.names.values, Value(true)));
|
||||
|
||||
define_direct_property(*vm.well_known_symbol_unscopables(), unscopable_list, Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 10.4.2.3 ArraySpeciesCreate ( originalArray, length ), https://tc39.es/ecma262/#sec-arrayspeciescreate
|
||||
|
|
|
@ -15,7 +15,7 @@ class ArrayPrototype final : public Array {
|
|||
JS_OBJECT(ArrayPrototype, Array);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~ArrayPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -22,9 +22,10 @@ AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterato
|
|||
{
|
||||
}
|
||||
|
||||
void AsyncFromSyncIterator::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> AsyncFromSyncIterator::initialize(Realm& realm)
|
||||
{
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
return {};
|
||||
}
|
||||
|
||||
void AsyncFromSyncIterator::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -19,7 +19,7 @@ class AsyncFromSyncIterator final : public Object {
|
|||
public:
|
||||
static NonnullGCPtr<AsyncFromSyncIterator> create(Realm&, Iterator sync_iterator_record);
|
||||
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AsyncFromSyncIterator() override = default;
|
||||
|
||||
void visit_edges(Visitor& visitor) override;
|
||||
|
|
|
@ -19,15 +19,17 @@ AsyncFromSyncIteratorPrototype::AsyncFromSyncIteratorPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void AsyncFromSyncIteratorPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> AsyncFromSyncIteratorPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.next, next, 1, attr);
|
||||
define_native_function(realm, vm.names.return_, return_, 1, attr);
|
||||
define_native_function(realm, vm.names.throw_, throw_, 1, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 27.1.4.4 AsyncFromSyncIteratorContinuation ( result, promiseCapability ), https://tc39.es/ecma262/#sec-asyncfromsynciteratorcontinuation
|
||||
|
|
|
@ -19,7 +19,7 @@ class AsyncFromSyncIteratorPrototype final : public PrototypeObject<AsyncFromSyn
|
|||
JS_PROTOTYPE_OBJECT(AsyncFromSyncIteratorPrototype, AsyncFromSyncIterator, AsyncFromSyncIterator);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AsyncFromSyncIteratorPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -17,15 +17,17 @@ AsyncFunctionConstructor::AsyncFunctionConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void AsyncFunctionConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> AsyncFunctionConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 27.7.2.2 AsyncFunction.prototype, https://tc39.es/ecma262/#sec-async-function-constructor-prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().async_function_prototype(), 0);
|
||||
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 27.7.1.1 AsyncFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-async-function-constructor-arguments
|
||||
|
|
|
@ -14,7 +14,7 @@ class AsyncFunctionConstructor final : public NativeFunction {
|
|||
JS_OBJECT(AsyncFunctionConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AsyncFunctionConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -14,13 +14,15 @@ AsyncFunctionPrototype::AsyncFunctionPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void AsyncFunctionPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> AsyncFunctionPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
// 27.7.3.2 AsyncFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-async-function-prototype-properties-toStringTag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.AsyncFunction.as_string()), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class AsyncFunctionPrototype final : public Object {
|
|||
JS_OBJECT(AsyncFunctionPrototype, Object);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AsyncFunctionPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -17,16 +17,18 @@ AsyncGeneratorFunctionConstructor::AsyncGeneratorFunctionConstructor(Realm& real
|
|||
{
|
||||
}
|
||||
|
||||
void AsyncGeneratorFunctionConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> AsyncGeneratorFunctionConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 27.4.2.1 AsyncGeneratorFunction.length, https://tc39.es/ecma262/#sec-asyncgeneratorfunction-length
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
// 27.4.2.2 AsyncGeneratorFunction.prototype, https://tc39.es/ecma262/#sec-asyncgeneratorfunction-prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().async_generator_function_prototype(), 0);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 27.4.1.1 AsyncGeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-asyncgeneratorfunction
|
||||
|
|
|
@ -14,7 +14,7 @@ class AsyncGeneratorFunctionConstructor final : public NativeFunction {
|
|||
JS_OBJECT(AsyncGeneratorFunctionConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AsyncGeneratorFunctionConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -16,10 +16,10 @@ AsyncGeneratorFunctionPrototype::AsyncGeneratorFunctionPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void AsyncGeneratorFunctionPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> AsyncGeneratorFunctionPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
// The constructor cannot be set at this point since it has not been initialized.
|
||||
|
||||
|
@ -28,6 +28,8 @@ void AsyncGeneratorFunctionPrototype::initialize(Realm& realm)
|
|||
|
||||
// 27.4.3.3 AsyncGeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-asyncgeneratorfunction-prototype-tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.AsyncGeneratorFunction.as_string()), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class AsyncGeneratorFunctionPrototype final : public PrototypeObject<AsyncGenera
|
|||
JS_PROTOTYPE_OBJECT(AsyncGeneratorFunctionPrototype, AsyncGeneratorFunction, AsyncGeneratorFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AsyncGeneratorFunctionPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -14,13 +14,15 @@ AsyncGeneratorPrototype::AsyncGeneratorPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void AsyncGeneratorPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> AsyncGeneratorPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
// 27.6.1.5 AsyncGenerator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-asyncgenerator-prototype-tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "AsyncGenerator"), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class AsyncGeneratorPrototype final : public PrototypeObject<AsyncGeneratorProto
|
|||
JS_PROTOTYPE_OBJECT(AsyncGeneratorPrototype, AsyncGenerator, AsyncGenerator)
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AsyncGeneratorPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -13,12 +13,14 @@ AsyncIteratorPrototype::AsyncIteratorPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void AsyncIteratorPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> AsyncIteratorPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, *vm.well_known_symbol_async_iterator(), symbol_async_iterator, 0, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 27.1.3.1 %AsyncIteratorPrototype% [ @@asyncIterator ] ( ), https://tc39.es/ecma262/#sec-asynciteratorprototype-asynciterator
|
||||
|
|
|
@ -14,7 +14,7 @@ class AsyncIteratorPrototype final : public Object {
|
|||
JS_OBJECT(AsyncIteratorPrototype, Object)
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AsyncIteratorPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -129,9 +129,9 @@ AtomicsObject::AtomicsObject(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void AtomicsObject::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> AtomicsObject::initialize(Realm& realm)
|
||||
{
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
auto& vm = this->vm();
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
|
@ -148,6 +148,8 @@ void AtomicsObject::initialize(Realm& realm)
|
|||
|
||||
// 25.4.15 Atomics [ @@toStringTag ], https://tc39.es/ecma262/#sec-atomics-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Atomics"), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 25.4.3 Atomics.add ( typedArray, index, value ), https://tc39.es/ecma262/#sec-atomics.add
|
||||
|
|
|
@ -14,7 +14,7 @@ class AtomicsObject : public Object {
|
|||
JS_OBJECT(AtomicsObject, Object);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~AtomicsObject() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -22,10 +22,10 @@ BigIntConstructor::BigIntConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void BigIntConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> BigIntConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 21.2.2.3 BigInt.prototype, https://tc39.es/ecma262/#sec-bigint.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().bigint_prototype(), 0);
|
||||
|
@ -35,6 +35,8 @@ void BigIntConstructor::initialize(Realm& realm)
|
|||
define_native_function(realm, vm.names.asUintN, as_uint_n, 2, attr);
|
||||
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 21.2.1.1 BigInt ( value ), https://tc39.es/ecma262/#sec-bigint-constructor-number-value
|
||||
|
|
|
@ -14,7 +14,7 @@ class BigIntConstructor final : public NativeFunction {
|
|||
JS_OBJECT(BigIntConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~BigIntConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -22,10 +22,10 @@ BigIntPrototype::BigIntPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void BigIntPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> BigIntPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.toString, to_string, 0, attr);
|
||||
define_native_function(realm, vm.names.toLocaleString, to_locale_string, 0, attr);
|
||||
|
@ -33,6 +33,8 @@ void BigIntPrototype::initialize(Realm& realm)
|
|||
|
||||
// 21.2.3.5 BigInt.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-bigint.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.BigInt.as_string()), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// thisBigIntValue ( value ), https://tc39.es/ecma262/#thisbigintvalue
|
||||
|
|
|
@ -14,7 +14,7 @@ class BigIntPrototype final : public Object {
|
|||
JS_OBJECT(BigIntPrototype, Object);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~BigIntPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -17,15 +17,17 @@ BooleanConstructor::BooleanConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void BooleanConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> BooleanConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 20.3.2.1 Boolean.prototype, https://tc39.es/ecma262/#sec-boolean.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().boolean_prototype(), 0);
|
||||
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 20.3.1.1 Boolean ( value ), https://tc39.es/ecma262/#sec-boolean-constructor-boolean-value
|
||||
|
|
|
@ -14,7 +14,7 @@ class BooleanConstructor final : public NativeFunction {
|
|||
JS_OBJECT(BooleanConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~BooleanConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -18,13 +18,15 @@ BooleanPrototype::BooleanPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void BooleanPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> BooleanPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
BooleanObject::initialize(realm);
|
||||
MUST_OR_THROW_OOM(BooleanObject::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.toString, to_string, 0, attr);
|
||||
define_native_function(realm, vm.names.valueOf, value_of, 0, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// thisBooleanValue ( value ), https://tc39.es/ecma262/#thisbooleanvalue
|
||||
|
|
|
@ -14,7 +14,7 @@ class BooleanPrototype final : public BooleanObject {
|
|||
JS_OBJECT(BooleanPrototype, BooleanObject);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~BooleanPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -18,10 +18,10 @@ ConsoleObject::ConsoleObject(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void ConsoleObject::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> ConsoleObject::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Enumerable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.log, log, 0, attr);
|
||||
define_native_function(realm, vm.names.debug, debug, 0, attr);
|
||||
|
@ -39,6 +39,8 @@ void ConsoleObject::initialize(Realm& realm)
|
|||
define_native_function(realm, vm.names.time, time, 0, attr);
|
||||
define_native_function(realm, vm.names.timeLog, time_log, 0, attr);
|
||||
define_native_function(realm, vm.names.timeEnd, time_end, 0, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 1.1.6. log(...data), https://console.spec.whatwg.org/#log
|
||||
|
|
|
@ -14,7 +14,7 @@ class ConsoleObject final : public Object {
|
|||
JS_OBJECT(ConsoleObject, Object);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~ConsoleObject() override = default;
|
||||
|
||||
Console& console() { return *m_console; }
|
||||
|
|
|
@ -19,15 +19,17 @@ DataViewConstructor::DataViewConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DataViewConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DataViewConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 25.3.3.1 DataView.prototype, https://tc39.es/ecma262/#sec-dataview.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().data_view_prototype(), 0);
|
||||
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 25.3.2.1 DataView ( buffer [ , byteOffset [ , byteLength ] ] ), https://tc39.es/ecma262/#sec-dataview-buffer-byteoffset-bytelength
|
||||
|
|
|
@ -14,7 +14,7 @@ class DataViewConstructor final : public NativeFunction {
|
|||
JS_OBJECT(DataViewConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~DataViewConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -15,10 +15,10 @@ DataViewPrototype::DataViewPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DataViewPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DataViewPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
|
||||
define_native_function(realm, vm.names.getBigInt64, get_big_int_64, 1, attr);
|
||||
|
@ -48,6 +48,8 @@ void DataViewPrototype::initialize(Realm& realm)
|
|||
|
||||
// 25.3.4.25 DataView.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-dataview.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.DataView.as_string()), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 25.3.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type ), https://tc39.es/ecma262/#sec-getviewvalue
|
||||
|
|
|
@ -15,7 +15,7 @@ class DataViewPrototype final : public PrototypeObject<DataViewPrototype, DataVi
|
|||
JS_PROTOTYPE_OBJECT(DataViewPrototype, DataView, DataView);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~DataViewPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -180,10 +180,10 @@ DateConstructor::DateConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DateConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DateConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 21.4.3.3 Date.prototype, https://tc39.es/ecma262/#sec-date.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().date_prototype(), 0);
|
||||
|
@ -194,6 +194,8 @@ void DateConstructor::initialize(Realm& realm)
|
|||
define_native_function(realm, vm.names.UTC, utc, 7, attr);
|
||||
|
||||
define_direct_property(vm.names.length, Value(7), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 21.4.2.1 Date ( ...values ), https://tc39.es/ecma262/#sec-date
|
||||
|
|
|
@ -14,7 +14,7 @@ class DateConstructor final : public NativeFunction {
|
|||
JS_OBJECT(DateConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~DateConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -34,10 +34,10 @@ DatePrototype::DatePrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DatePrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DatePrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.getDate, get_date, 0, attr);
|
||||
define_native_function(realm, vm.names.getDay, get_day, 0, attr);
|
||||
|
@ -95,6 +95,8 @@ void DatePrototype::initialize(Realm& realm)
|
|||
// B.2.4.3 Date.prototype.toGMTString ( ), https://tc39.es/ecma262/#sec-date.prototype.togmtstring
|
||||
// The initial value of the "toGMTString" property is %Date.prototype.toUTCString%, defined in 21.4.4.43.
|
||||
define_direct_property(vm.names.toGMTString, get_without_side_effects(vm.names.toUTCString), attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// thisTimeValue ( value ), https://tc39.es/ecma262/#thistimevalue
|
||||
|
|
|
@ -15,7 +15,7 @@ class DatePrototype final : public PrototypeObject<DatePrototype, Date> {
|
|||
JS_PROTOTYPE_OBJECT(DatePrototype, Date, Date);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~DatePrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -15,15 +15,17 @@ DisposableStackConstructor::DisposableStackConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DisposableStackConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DisposableStackConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 26.2.2.1 DisposableStack.prototype, https://tc39.es/ecma262/#sec-finalization-registry.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().disposable_stack_prototype(), 0);
|
||||
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 11.3.1.1 DisposableStack ( ), https://tc39.es/proposal-explicit-resource-management/#sec-disposablestack
|
||||
|
|
|
@ -14,7 +14,7 @@ class DisposableStackConstructor final : public NativeFunction {
|
|||
JS_OBJECT(DisposableStackConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~DisposableStackConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -17,10 +17,10 @@ DisposableStackPrototype::DisposableStackPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DisposableStackPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DisposableStackPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
|
||||
define_native_accessor(realm, vm.names.disposed, disposed_getter, {}, attr);
|
||||
|
@ -35,6 +35,8 @@ void DisposableStackPrototype::initialize(Realm& realm)
|
|||
|
||||
// 11.3.3.8 DisposableStack.prototype [ @@toStringTag ], https://tc39.es/proposal-explicit-resource-management/#sec-disposablestack.prototype-@@toStringTag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.DisposableStack.as_string()), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 11.3.3.1 get DisposableStack.prototype.disposed, https://tc39.es/proposal-explicit-resource-management/#sec-get-disposablestack.prototype.disposed
|
||||
|
|
|
@ -15,7 +15,7 @@ class DisposableStackPrototype final : public PrototypeObject<DisposableStackPro
|
|||
JS_PROTOTYPE_OBJECT(DisposableStackPrototype, DisposableStack, DisposableStack);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~DisposableStackPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -97,10 +97,10 @@ ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, Dep
|
|||
});
|
||||
}
|
||||
|
||||
void ECMAScriptFunctionObject::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> ECMAScriptFunctionObject::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
// Note: The ordering of these properties must be: length, name, prototype which is the order
|
||||
// they are defined in the spec: https://tc39.es/ecma262/#sec-function-instances .
|
||||
// This is observable through something like: https://tc39.es/ecma262/#sec-ordinaryownpropertykeys
|
||||
|
@ -132,6 +132,8 @@ void ECMAScriptFunctionObject::initialize(Realm& realm)
|
|||
if (m_kind != FunctionKind::Async)
|
||||
define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 10.2.1 [[Call]] ( thisArgument, argumentsList ), https://tc39.es/ecma262/#sec-ecmascript-function-objects-call-thisargument-argumentslist
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {});
|
||||
static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {});
|
||||
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~ECMAScriptFunctionObject() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> internal_call(Value this_argument, MarkedVector<Value> arguments_list) override;
|
||||
|
|
|
@ -16,15 +16,17 @@ ErrorConstructor::ErrorConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void ErrorConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> ErrorConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 20.5.2.1 Error.prototype, https://tc39.es/ecma262/#sec-error.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().error_prototype(), 0);
|
||||
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 20.5.1.1 Error ( message [ , options ] ), https://tc39.es/ecma262/#sec-error-message
|
||||
|
@ -67,15 +69,17 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ErrorConstructor::construct(FunctionObje
|
|||
{ \
|
||||
} \
|
||||
\
|
||||
void ConstructorName::initialize(Realm& realm) \
|
||||
ThrowCompletionOr<void> ConstructorName::initialize(Realm& realm) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
NativeFunction::initialize(realm); \
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); \
|
||||
\
|
||||
/* 20.5.6.2.1 NativeError.prototype, https://tc39.es/ecma262/#sec-nativeerror.prototype */ \
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \
|
||||
\
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable); \
|
||||
\
|
||||
return {}; \
|
||||
} \
|
||||
\
|
||||
ConstructorName::~ConstructorName() = default; \
|
||||
|
|
|
@ -15,7 +15,7 @@ class ErrorConstructor final : public NativeFunction {
|
|||
JS_OBJECT(ErrorConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~ErrorConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
@ -32,7 +32,7 @@ private:
|
|||
JS_OBJECT(ConstructorName, NativeFunction); \
|
||||
\
|
||||
public: \
|
||||
virtual void initialize(Realm&) override; \
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override; \
|
||||
virtual ~ConstructorName() override; \
|
||||
virtual ThrowCompletionOr<Value> call() override; \
|
||||
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; \
|
||||
|
|
|
@ -19,10 +19,10 @@ ErrorPrototype::ErrorPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void ErrorPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> ErrorPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_direct_property(vm.names.name, PrimitiveString::create(vm, "Error"), attr);
|
||||
define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr);
|
||||
|
@ -31,6 +31,8 @@ void ErrorPrototype::initialize(Realm& realm)
|
|||
// Every other engine seems to have this in some way or another, and the spec
|
||||
// proposal for this is only Stage 1
|
||||
define_native_accessor(realm, vm.names.stack, stack_getter, stack_setter, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 20.5.3.4 Error.prototype.toString ( ), https://tc39.es/ecma262/#sec-error.prototype.tostring
|
||||
|
@ -128,13 +130,15 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_setter)
|
|||
{ \
|
||||
} \
|
||||
\
|
||||
void PrototypeName::initialize(Realm& realm) \
|
||||
ThrowCompletionOr<void> PrototypeName::initialize(Realm& realm) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
Object::initialize(realm); \
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm)); \
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable; \
|
||||
define_direct_property(vm.names.name, PrimitiveString::create(vm, #ClassName), attr); \
|
||||
define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr); \
|
||||
\
|
||||
return {}; \
|
||||
}
|
||||
|
||||
JS_ENUMERATE_NATIVE_ERRORS
|
||||
|
|
|
@ -16,7 +16,7 @@ class ErrorPrototype final : public PrototypeObject<ErrorPrototype, Error> {
|
|||
JS_PROTOTYPE_OBJECT(ErrorPrototype, Error, Error);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~ErrorPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
@ -32,7 +32,7 @@ private:
|
|||
JS_PROTOTYPE_OBJECT(PrototypeName, ClassName, ClassName); \
|
||||
\
|
||||
public: \
|
||||
virtual void initialize(Realm&) override; \
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override; \
|
||||
virtual ~PrototypeName() override = default; \
|
||||
\
|
||||
private: \
|
||||
|
|
|
@ -18,15 +18,17 @@ FinalizationRegistryConstructor::FinalizationRegistryConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void FinalizationRegistryConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> FinalizationRegistryConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 26.2.2.1 FinalizationRegistry.prototype, https://tc39.es/ecma262/#sec-finalization-registry.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().finalization_registry_prototype(), 0);
|
||||
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 26.2.1.1 FinalizationRegistry ( cleanupCallback ), https://tc39.es/ecma262/#sec-finalization-registry-cleanup-callback
|
||||
|
|
|
@ -14,7 +14,7 @@ class FinalizationRegistryConstructor final : public NativeFunction {
|
|||
JS_OBJECT(FinalizationRegistryConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~FinalizationRegistryConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -15,10 +15,10 @@ FinalizationRegistryPrototype::FinalizationRegistryPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void FinalizationRegistryPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> FinalizationRegistryPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
|
||||
define_native_function(realm, vm.names.cleanupSome, cleanup_some, 0, attr);
|
||||
|
@ -27,6 +27,8 @@ void FinalizationRegistryPrototype::initialize(Realm& realm)
|
|||
|
||||
// 26.2.3.4 FinalizationRegistry.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-finalization-registry.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.FinalizationRegistry.as_string()), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// @STAGE 2@ FinalizationRegistry.prototype.cleanupSome ( [ callback ] ), https://github.com/tc39/proposal-cleanup-some/blob/master/spec/finalization-registry.html
|
||||
|
|
|
@ -15,7 +15,7 @@ class FinalizationRegistryPrototype final : public PrototypeObject<FinalizationR
|
|||
JS_PROTOTYPE_OBJECT(FinalizationRegistryPrototype, FinalizationRegistry, FinalizationRegistry);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~FinalizationRegistryPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -23,15 +23,17 @@ FunctionConstructor::FunctionConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void FunctionConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> FunctionConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 20.2.2.2 Function.prototype, https://tc39.es/ecma262/#sec-function.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().function_prototype(), 0);
|
||||
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 20.2.1.1.1 CreateDynamicFunction ( constructor, newTarget, kind, args ), https://tc39.es/ecma262/#sec-createdynamicfunction
|
||||
|
|
|
@ -17,7 +17,7 @@ class FunctionConstructor final : public NativeFunction {
|
|||
public:
|
||||
static ThrowCompletionOr<ECMAScriptFunctionObject*> create_dynamic_function(VM&, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector<Value> const& args);
|
||||
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~FunctionConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -20,7 +20,7 @@ class FunctionObject : public Object {
|
|||
|
||||
public:
|
||||
virtual ~FunctionObject() = default;
|
||||
virtual void initialize(Realm&) override { }
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override { return {}; }
|
||||
|
||||
// Table 7: Additional Essential Internal Methods of Function Objects, https://tc39.es/ecma262/#table-additional-essential-internal-methods-of-function-objects
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ FunctionPrototype::FunctionPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void FunctionPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> FunctionPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.apply, apply, 2, attr);
|
||||
define_native_function(realm, vm.names.bind, bind, 1, attr);
|
||||
|
@ -37,6 +37,8 @@ void FunctionPrototype::initialize(Realm& realm)
|
|||
define_native_function(realm, *vm.well_known_symbol_has_instance(), symbol_has_instance, 1, 0);
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, PrimitiveString::create(vm, ""), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
ThrowCompletionOr<Value> FunctionPrototype::internal_call(Value, MarkedVector<Value>)
|
||||
|
|
|
@ -14,7 +14,7 @@ class FunctionPrototype final : public FunctionObject {
|
|||
JS_OBJECT(FunctionPrototype, FunctionObject);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~FunctionPrototype() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> internal_call(Value this_argument, MarkedVector<Value> arguments_list) override;
|
||||
|
|
|
@ -16,15 +16,17 @@ GeneratorFunctionConstructor::GeneratorFunctionConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void GeneratorFunctionConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> GeneratorFunctionConstructor::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
// 27.3.2.1 GeneratorFunction.length, https://tc39.es/ecma262/#sec-generatorfunction.length
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
// 27.3.2.2 GeneratorFunction.prototype, https://tc39.es/ecma262/#sec-generatorfunction.length
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().generator_function_prototype(), 0);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 27.3.1.1 GeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-generatorfunction
|
||||
|
|
|
@ -15,7 +15,7 @@ class GeneratorFunctionConstructor final : public NativeFunction {
|
|||
JS_OBJECT(GeneratorFunctionConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~GeneratorFunctionConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -15,15 +15,17 @@ GeneratorFunctionPrototype::GeneratorFunctionPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void GeneratorFunctionPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> GeneratorFunctionPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
// 27.3.3.2 GeneratorFunction.prototype.prototype, https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().generator_prototype(), Attribute::Configurable);
|
||||
// 27.3.3.3 GeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generatorfunction.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "GeneratorFunction"), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class GeneratorFunctionPrototype final : public Object {
|
|||
JS_OBJECT(GeneratorFunctionPrototype, Object);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~GeneratorFunctionPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -41,8 +41,9 @@ GeneratorObject::GeneratorObject(Realm&, Object& prototype, ExecutionContext con
|
|||
{
|
||||
}
|
||||
|
||||
void GeneratorObject::initialize(Realm&)
|
||||
ThrowCompletionOr<void> GeneratorObject::initialize(Realm&)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void GeneratorObject::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -17,7 +17,7 @@ class GeneratorObject final : public Object {
|
|||
|
||||
public:
|
||||
static ThrowCompletionOr<NonnullGCPtr<GeneratorObject>> create(Realm&, Value, ECMAScriptFunctionObject*, ExecutionContext, Bytecode::RegisterWindow);
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~GeneratorObject() override = default;
|
||||
void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@ GeneratorPrototype::GeneratorPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void GeneratorPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> GeneratorPrototype::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.next, next, 1, attr);
|
||||
define_native_function(realm, vm.names.return_, return_, 1, attr);
|
||||
|
@ -25,6 +25,8 @@ void GeneratorPrototype::initialize(Realm& realm)
|
|||
|
||||
// 27.5.1.5 Generator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generator.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Generator"), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 27.5.1.2 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.next
|
||||
|
|
|
@ -16,7 +16,7 @@ class GeneratorPrototype final : public PrototypeObject<GeneratorPrototype, Gene
|
|||
JS_PROTOTYPE_OBJECT(GeneratorPrototype, GeneratorObject, Generator);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~GeneratorPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -190,15 +190,17 @@ Object& set_default_global_bindings(Realm& realm)
|
|||
return global;
|
||||
}
|
||||
|
||||
void GlobalObject::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> GlobalObject::initialize(Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
auto& vm = this->vm();
|
||||
|
||||
// Non-standard
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.gc, gc, 0, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
GlobalObject::~GlobalObject() = default;
|
||||
|
|
|
@ -19,7 +19,7 @@ class GlobalObject : public Object {
|
|||
friend class Intrinsics;
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~GlobalObject() override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -22,11 +22,13 @@ CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collato
|
|||
{
|
||||
}
|
||||
|
||||
void CollatorCompareFunction::initialize(Realm&)
|
||||
ThrowCompletionOr<void> CollatorCompareFunction::initialize(Realm&)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 10.3.3.2 CompareStrings ( collator, x, y ), https://tc39.es/ecma402/#sec-collator-comparestrings
|
||||
|
|
|
@ -16,7 +16,7 @@ class CollatorCompareFunction : public NativeFunction {
|
|||
public:
|
||||
static NonnullGCPtr<CollatorCompareFunction> create(Realm&, Collator&);
|
||||
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~CollatorCompareFunction() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -135,9 +135,9 @@ CollatorConstructor::CollatorConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void CollatorConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> CollatorConstructor::initialize(Realm& realm)
|
||||
{
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
auto& vm = this->vm();
|
||||
|
||||
|
@ -147,6 +147,8 @@ void CollatorConstructor::initialize(Realm& realm)
|
|||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 10.1.1 Intl.Collator ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.collator
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue