mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:47:45 +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
694 changed files with 1774 additions and 1065 deletions
|
@ -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
|
||||
|
|
|
@ -14,7 +14,7 @@ class CollatorConstructor final : public NativeFunction {
|
|||
JS_OBJECT(CollatorConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~CollatorConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -17,9 +17,9 @@ CollatorPrototype::CollatorPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void CollatorPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> CollatorPrototype::initialize(Realm& realm)
|
||||
{
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Object::initialize(realm));
|
||||
|
||||
auto& vm = this->vm();
|
||||
|
||||
|
@ -29,6 +29,8 @@ void CollatorPrototype::initialize(Realm& realm)
|
|||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_accessor(realm, vm.names.compare, compare_getter, {}, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 10.3.3 get Intl.Collator.prototype.compare, https://tc39.es/ecma402/#sec-intl.collator.prototype.compare
|
||||
|
|
|
@ -15,7 +15,7 @@ class CollatorPrototype final : public PrototypeObject<CollatorPrototype, Collat
|
|||
JS_PROTOTYPE_OBJECT(CollatorPrototype, Collator, Collator);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~CollatorPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -23,9 +23,9 @@ DateTimeFormatConstructor::DateTimeFormatConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DateTimeFormatConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DateTimeFormatConstructor::initialize(Realm& realm)
|
||||
{
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
auto& vm = this->vm();
|
||||
|
||||
|
@ -36,6 +36,8 @@ void DateTimeFormatConstructor::initialize(Realm& realm)
|
|||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 11.1.1 Intl.DateTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.datetimeformat
|
||||
|
|
|
@ -14,7 +14,7 @@ class DateTimeFormatConstructor final : public NativeFunction {
|
|||
JS_OBJECT(DateTimeFormatConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~DateTimeFormatConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -25,13 +25,15 @@ DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format,
|
|||
{
|
||||
}
|
||||
|
||||
void DateTimeFormatFunction::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DateTimeFormatFunction::initialize(Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
|
||||
Base::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
ThrowCompletionOr<Value> DateTimeFormatFunction::call()
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
static NonnullGCPtr<DateTimeFormatFunction> create(Realm&, DateTimeFormat&);
|
||||
|
||||
virtual ~DateTimeFormatFunction() override = default;
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ DateTimeFormatPrototype::DateTimeFormatPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DateTimeFormatPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DateTimeFormatPrototype::initialize(Realm& realm)
|
||||
{
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
auto& vm = this->vm();
|
||||
|
||||
|
@ -35,6 +35,8 @@ void DateTimeFormatPrototype::initialize(Realm& realm)
|
|||
define_native_function(realm, vm.names.formatRange, format_range, 2, attr);
|
||||
define_native_function(realm, vm.names.formatRangeToParts, format_range_to_parts, 2, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 11.3.3 get Intl.DateTimeFormat.prototype.format, https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype.format
|
||||
|
|
|
@ -15,7 +15,7 @@ class DateTimeFormatPrototype final : public PrototypeObject<DateTimeFormatProto
|
|||
JS_PROTOTYPE_OBJECT(DateTimeFormatPrototype, DateTimeFormat, Intl.DateTimeFormat);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~DateTimeFormatPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -21,9 +21,9 @@ DisplayNamesConstructor::DisplayNamesConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DisplayNamesConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DisplayNamesConstructor::initialize(Realm& realm)
|
||||
{
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
auto& vm = this->vm();
|
||||
|
||||
|
@ -34,6 +34,8 @@ void DisplayNamesConstructor::initialize(Realm& realm)
|
|||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
|
||||
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 12.1.1 Intl.DisplayNames ( locales, options ), https://tc39.es/ecma402/#sec-Intl.DisplayNames
|
||||
|
|
|
@ -14,7 +14,7 @@ class DisplayNamesConstructor final : public NativeFunction {
|
|||
JS_OBJECT(DisplayNamesConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~DisplayNamesConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -19,9 +19,9 @@ DisplayNamesPrototype::DisplayNamesPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DisplayNamesPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DisplayNamesPrototype::initialize(Realm& realm)
|
||||
{
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
auto& vm = this->vm();
|
||||
|
||||
|
@ -31,6 +31,8 @@ void DisplayNamesPrototype::initialize(Realm& realm)
|
|||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.of, of, 1, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 12.3.3 Intl.DisplayNames.prototype.of ( code ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype.of
|
||||
|
|
|
@ -15,7 +15,7 @@ class DisplayNamesPrototype final : public PrototypeObject<DisplayNamesPrototype
|
|||
JS_PROTOTYPE_OBJECT(DisplayNamesPrototype, DisplayNames, Intl.DisplayNames);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~DisplayNamesPrototype() override = default;
|
||||
|
||||
private:
|
||||
|
|
|
@ -20,9 +20,9 @@ DurationFormatConstructor::DurationFormatConstructor(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DurationFormatConstructor::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DurationFormatConstructor::initialize(Realm& realm)
|
||||
{
|
||||
NativeFunction::initialize(realm);
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm));
|
||||
|
||||
auto& vm = this->vm();
|
||||
|
||||
|
@ -32,6 +32,8 @@ void DurationFormatConstructor::initialize(Realm& realm)
|
|||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 1.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat
|
||||
|
|
|
@ -14,7 +14,7 @@ class DurationFormatConstructor final : public NativeFunction {
|
|||
JS_OBJECT(DurationFormatConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~DurationFormatConstructor() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> call() override;
|
||||
|
|
|
@ -18,9 +18,9 @@ DurationFormatPrototype::DurationFormatPrototype(Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
void DurationFormatPrototype::initialize(Realm& realm)
|
||||
ThrowCompletionOr<void> DurationFormatPrototype::initialize(Realm& realm)
|
||||
{
|
||||
Object::initialize(realm);
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
auto& vm = this->vm();
|
||||
|
||||
|
@ -31,6 +31,8 @@ void DurationFormatPrototype::initialize(Realm& realm)
|
|||
define_native_function(realm, vm.names.format, format, 1, attr);
|
||||
define_native_function(realm, vm.names.formatToParts, format_to_parts, 1, attr);
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// 1.4.3 Intl.DurationFormat.prototype.format ( duration ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.format
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue