LibJS: Convert Object::construct() to NonnullGCPtr

This commit is contained in:
Linus Groh 2022-12-14 19:18:10 +00:00 committed by Tim Flynn
parent 03acbf0beb
commit 6ae79a84df
Notes: sideshowbarker 2024-07-17 07:20:49 +09:00
117 changed files with 216 additions and 216 deletions

View file

@ -2004,7 +2004,7 @@ public:
virtual ~@constructor_class@() override;
virtual JS::ThrowCompletionOr<JS::Value> call() override;
virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override;
virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override;
private:
virtual bool has_constructor() const override { return true; }
@ -2135,7 +2135,7 @@ JS::ThrowCompletionOr<JS::Value> @constructor_class@::call()
return vm().throw_completion<JS::TypeError>(JS::ErrorType::ConstructorWithoutNew, "@name@");
}
JS::ThrowCompletionOr<JS::Object*> @constructor_class@::construct(FunctionObject&)
JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::construct(FunctionObject&)
{
)~~~");
@ -2172,7 +2172,7 @@ JS::ThrowCompletionOr<JS::Object*> @constructor_class@::construct(FunctionObject
)~~~");
}
generator.append(R"~~~(
return &(*impl);
return *impl;
)~~~");
} else {
// Multiple constructor overloads - can't do that yet.

View file

@ -38,7 +38,7 @@ ThrowCompletionOr<Value> AggregateErrorConstructor::call()
}
// 20.5.7.1.1 AggregateError ( errors, message [ , options ] ), https://tc39.es/ecma262/#sec-aggregate-error
ThrowCompletionOr<Object*> AggregateErrorConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> AggregateErrorConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
auto& realm = *vm.current_realm();
@ -69,7 +69,7 @@ ThrowCompletionOr<Object*> AggregateErrorConstructor::construct(FunctionObject&
MUST(aggregate_error->define_property_or_throw(vm.names.errors, { .value = Array::create_from(realm, errors_list), .writable = true, .enumerable = false, .configurable = true }));
// 7. Return O.
return aggregate_error.ptr();
return aggregate_error;
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~AggregateErrorConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit AggregateErrorConstructor(Realm&);

View file

@ -44,7 +44,7 @@ ThrowCompletionOr<Value> ArrayBufferConstructor::call()
}
// 25.1.3.1 ArrayBuffer ( length ), https://tc39.es/ecma262/#sec-arraybuffer-length
ThrowCompletionOr<Object*> ArrayBufferConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> ArrayBufferConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
auto byte_length_or_error = vm.argument(0).to_index(vm);
@ -57,7 +57,7 @@ ThrowCompletionOr<Object*> ArrayBufferConstructor::construct(FunctionObject& new
}
return error;
}
return TRY(allocate_array_buffer(vm, new_target, byte_length_or_error.release_value()));
return *TRY(allocate_array_buffer(vm, new_target, byte_length_or_error.release_value()));
}
// 25.1.4.1 ArrayBuffer.isView ( arg ), https://tc39.es/ecma262/#sec-arraybuffer.isview

View file

@ -18,7 +18,7 @@ public:
virtual ~ArrayBufferConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit ArrayBufferConstructor(Realm&);

View file

@ -47,7 +47,7 @@ ThrowCompletionOr<Value> ArrayConstructor::call()
}
// 23.1.1.1 Array ( ...values ), https://tc39.es/ecma262/#sec-array
ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> ArrayConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
auto& realm = *vm.current_realm();
@ -55,7 +55,7 @@ ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_targe
auto* proto = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::array_prototype));
if (vm.argument_count() == 0)
return MUST(Array::create(realm, 0, proto)).ptr();
return MUST(Array::create(realm, 0, proto));
if (vm.argument_count() == 1) {
auto length = vm.argument(0);
@ -70,7 +70,7 @@ ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_targe
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "array");
}
TRY(array->set(vm.names.length, Value(int_length), Object::ShouldThrowExceptions::Yes));
return array.ptr();
return array;
}
auto array = TRY(Array::create(realm, vm.argument_count(), proto));
@ -78,7 +78,7 @@ ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_targe
for (size_t k = 0; k < vm.argument_count(); ++k)
MUST(array->create_data_property_or_throw(k, vm.argument(k)));
return array.ptr();
return array;
}
// 23.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ), https://tc39.es/ecma262/#sec-array.from

View file

@ -18,7 +18,7 @@ public:
virtual ~ArrayConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit ArrayConstructor(Realm&);

View file

@ -35,7 +35,7 @@ ThrowCompletionOr<Value> AsyncFunctionConstructor::call()
}
// 27.7.1.1 AsyncFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-async-function-constructor-arguments
ThrowCompletionOr<Object*> AsyncFunctionConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> AsyncFunctionConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -46,7 +46,7 @@ ThrowCompletionOr<Object*> AsyncFunctionConstructor::construct(FunctionObject& n
auto& args = vm.running_execution_context().arguments;
// 3. Return CreateDynamicFunction(C, NewTarget, async, args).
return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Async, args));
return *TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Async, args));
}
}

View file

@ -18,7 +18,7 @@ public:
virtual ~AsyncFunctionConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit AsyncFunctionConstructor(Realm&);

View file

@ -36,7 +36,7 @@ ThrowCompletionOr<Value> AsyncGeneratorFunctionConstructor::call()
}
// 27.4.1.1 AsyncGeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-asyncgeneratorfunction
ThrowCompletionOr<Object*> AsyncGeneratorFunctionConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> AsyncGeneratorFunctionConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -47,7 +47,7 @@ ThrowCompletionOr<Object*> AsyncGeneratorFunctionConstructor::construct(Function
auto& args = vm.running_execution_context().arguments;
// 3. Return ? CreateDynamicFunction(C, NewTarget, asyncGenerator, args).
return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::AsyncGenerator, args));
return *TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::AsyncGenerator, args));
}
}

View file

@ -18,7 +18,7 @@ public:
virtual ~AsyncGeneratorFunctionConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit AsyncGeneratorFunctionConstructor(Realm&);

View file

@ -56,7 +56,7 @@ ThrowCompletionOr<Value> BigIntConstructor::call()
}
// 21.2.1.1 BigInt ( value ), https://tc39.es/ecma262/#sec-bigint-constructor-number-value
ThrowCompletionOr<Object*> BigIntConstructor::construct(FunctionObject&)
ThrowCompletionOr<NonnullGCPtr<Object>> BigIntConstructor::construct(FunctionObject&)
{
return vm().throw_completion<TypeError>(ErrorType::NotAConstructor, "BigInt");
}

View file

@ -18,7 +18,7 @@ public:
virtual ~BigIntConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit BigIntConstructor(Realm&);

View file

@ -37,12 +37,12 @@ ThrowCompletionOr<Value> BooleanConstructor::call()
}
// 20.3.1.1 Boolean ( value ), https://tc39.es/ecma262/#sec-boolean-constructor-boolean-value
ThrowCompletionOr<Object*> BooleanConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> BooleanConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
auto b = vm.argument(0).to_boolean();
return TRY(ordinary_create_from_constructor<BooleanObject>(vm, new_target, &Intrinsics::boolean_prototype, b)).ptr();
return TRY(ordinary_create_from_constructor<BooleanObject>(vm, new_target, &Intrinsics::boolean_prototype, b));
}
}

View file

@ -18,7 +18,7 @@ public:
virtual ~BooleanConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit BooleanConstructor(Realm&);

View file

@ -38,7 +38,7 @@ ThrowCompletionOr<Value> DataViewConstructor::call()
}
// 25.3.2.1 DataView ( buffer [ , byteOffset [ , byteLength ] ] ), https://tc39.es/ecma262/#sec-dataview-buffer-byteoffset-bytelength
ThrowCompletionOr<Object*> DataViewConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> DataViewConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -72,7 +72,7 @@ ThrowCompletionOr<Object*> DataViewConstructor::construct(FunctionObject& new_ta
if (array_buffer.is_detached())
return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer);
return data_view.ptr();
return data_view;
}
}

View file

@ -18,7 +18,7 @@ public:
virtual ~DataViewConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
private:
explicit DataViewConstructor(Realm&);

View file

@ -208,7 +208,7 @@ ThrowCompletionOr<Value> DateConstructor::call()
}
// 21.4.2.1 Date ( ...values ), https://tc39.es/ecma262/#sec-date
ThrowCompletionOr<Object*> DateConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> DateConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -299,7 +299,7 @@ ThrowCompletionOr<Object*> DateConstructor::construct(FunctionObject& new_target
// 6. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Date.prototype%", « [[DateValue]] »).
// 7. Set O.[[DateValue]] to dv.
// 8. Return O.
return TRY(ordinary_create_from_constructor<Date>(vm, new_target, &Intrinsics::date_prototype, date_value)).ptr();
return TRY(ordinary_create_from_constructor<Date>(vm, new_target, &Intrinsics::date_prototype, date_value));
}
// 21.4.3.1 Date.now ( ), https://tc39.es/ecma262/#sec-date.now

View file

@ -18,7 +18,7 @@ public:
virtual ~DateConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit DateConstructor(Realm&);

View file

@ -35,7 +35,7 @@ ThrowCompletionOr<Value> ErrorConstructor::call()
}
// 20.5.1.1 Error ( message [ , options ] ), https://tc39.es/ecma262/#sec-error-message
ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> ErrorConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -58,7 +58,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe
TRY(error->install_error_cause(options));
// 5. Return O.
return error.ptr();
return error;
}
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
@ -88,7 +88,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe
} \
\
/* 20.5.6.1.1 NativeError ( message [ , options ] ), https://tc39.es/ecma262/#sec-nativeerror */ \
ThrowCompletionOr<Object*> ConstructorName::construct(FunctionObject& new_target) \
ThrowCompletionOr<NonnullGCPtr<Object>> ConstructorName::construct(FunctionObject& new_target) \
{ \
auto& vm = this->vm(); \
\
@ -111,7 +111,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe
TRY(error->install_error_cause(options)); \
\
/* 5. Return O. */ \
return error.ptr(); \
return error; \
}
JS_ENUMERATE_NATIVE_ERRORS

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -19,7 +19,7 @@ public:
virtual ~ErrorConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit ErrorConstructor(Realm&);
@ -27,23 +27,23 @@ private:
virtual bool has_constructor() const override { return true; }
};
#define DECLARE_NATIVE_ERROR_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName) \
class ConstructorName final : public NativeFunction { \
JS_OBJECT(ConstructorName, NativeFunction); \
\
public: \
virtual void initialize(Realm&) override; \
virtual ~ConstructorName() override; \
virtual ThrowCompletionOr<Value> call() override; \
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; \
\
private: \
explicit ConstructorName(Realm&); \
\
virtual bool has_constructor() const override \
{ \
return true; \
} \
#define DECLARE_NATIVE_ERROR_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName) \
class ConstructorName final : public NativeFunction { \
JS_OBJECT(ConstructorName, NativeFunction); \
\
public: \
virtual void initialize(Realm&) override; \
virtual ~ConstructorName() override; \
virtual ThrowCompletionOr<Value> call() override; \
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; \
\
private: \
explicit ConstructorName(Realm&); \
\
virtual bool has_constructor() const override \
{ \
return true; \
} \
};
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \

View file

@ -37,7 +37,7 @@ ThrowCompletionOr<Value> FinalizationRegistryConstructor::call()
}
// 26.2.1.1 FinalizationRegistry ( cleanupCallback ), https://tc39.es/ecma262/#sec-finalization-registry-cleanup-callback
ThrowCompletionOr<Object*> FinalizationRegistryConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> FinalizationRegistryConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -56,7 +56,7 @@ ThrowCompletionOr<Object*> FinalizationRegistryConstructor::construct(FunctionOb
// 7. Set finalizationRegistry.[[Cells]] to a new empty List.
// NOTE: This is done inside FinalizationRegistry instead of here.
// 8. Return finalizationRegistry.
return TRY(ordinary_create_from_constructor<FinalizationRegistry>(vm, new_target, &Intrinsics::finalization_registry_prototype, *realm(), vm.host_make_job_callback(cleanup_callback.as_function()))).ptr();
return TRY(ordinary_create_from_constructor<FinalizationRegistry>(vm, new_target, &Intrinsics::finalization_registry_prototype, *realm(), vm.host_make_job_callback(cleanup_callback.as_function())));
}
}

View file

@ -18,7 +18,7 @@ public:
virtual ~FinalizationRegistryConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
private:
explicit FinalizationRegistryConstructor(Realm&);

View file

@ -265,7 +265,7 @@ ThrowCompletionOr<Value> FunctionConstructor::call()
}
// 20.2.1.1 Function ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-function-p1-p2-pn-body
ThrowCompletionOr<Object*> FunctionConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> FunctionConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -276,7 +276,7 @@ ThrowCompletionOr<Object*> FunctionConstructor::construct(FunctionObject& new_ta
auto& args = vm.running_execution_context().arguments;
// 3. Return ? CreateDynamicFunction(C, NewTarget, normal, args).
return TRY(create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Normal, args));
return *TRY(create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Normal, args));
}
}

View file

@ -21,7 +21,7 @@ public:
virtual ~FunctionConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit FunctionConstructor(Realm&);

View file

@ -34,7 +34,7 @@ ThrowCompletionOr<Value> GeneratorFunctionConstructor::call()
}
// 27.3.1.1 GeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-generatorfunction
ThrowCompletionOr<Object*> GeneratorFunctionConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> GeneratorFunctionConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -45,7 +45,7 @@ ThrowCompletionOr<Object*> GeneratorFunctionConstructor::construct(FunctionObjec
auto& args = vm.running_execution_context().arguments;
// 3. Return ? CreateDynamicFunction(C, NewTarget, generator, args).
return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Generator, args));
return *TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Generator, args));
}
}

View file

@ -19,7 +19,7 @@ public:
virtual ~GeneratorFunctionConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit GeneratorFunctionConstructor(Realm&);

View file

@ -157,7 +157,7 @@ ThrowCompletionOr<Value> CollatorConstructor::call()
}
// 10.1.1 Intl.Collator ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.collator
ThrowCompletionOr<Object*> CollatorConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> CollatorConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -174,7 +174,7 @@ ThrowCompletionOr<Object*> CollatorConstructor::construct(FunctionObject& new_ta
auto collator = TRY(ordinary_create_from_constructor<Collator>(vm, new_target, &Intrinsics::intl_collator_prototype));
// 6. Return ? InitializeCollator(collator, locales, options).
return TRY(initialize_collator(vm, collator, locales, options));
return *TRY(initialize_collator(vm, collator, locales, options));
}
// 10.2.2 Intl.Collator.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.collator.supportedlocalesof

View file

@ -18,7 +18,7 @@ public:
virtual ~CollatorConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit CollatorConstructor(Realm&);

View file

@ -46,7 +46,7 @@ ThrowCompletionOr<Value> DateTimeFormatConstructor::call()
}
// 11.1.1 Intl.DateTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.datetimeformat
ThrowCompletionOr<Object*> DateTimeFormatConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> DateTimeFormatConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -64,7 +64,7 @@ ThrowCompletionOr<Object*> DateTimeFormatConstructor::construct(FunctionObject&
// b. Return ? ChainDateTimeFormat(dateTimeFormat, NewTarget, this).
// 5. Return dateTimeFormat.
return date_time_format.ptr();
return date_time_format;
}
// 11.2.2 Intl.DateTimeFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.datetimeformat.supportedlocalesof

View file

@ -18,7 +18,7 @@ public:
virtual ~DateTimeFormatConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit DateTimeFormatConstructor(Realm&);

View file

@ -44,7 +44,7 @@ ThrowCompletionOr<Value> DisplayNamesConstructor::call()
}
// 12.1.1 Intl.DisplayNames ( locales, options ), https://tc39.es/ecma402/#sec-Intl.DisplayNames
ThrowCompletionOr<Object*> DisplayNamesConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> DisplayNamesConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -130,7 +130,7 @@ ThrowCompletionOr<Object*> DisplayNamesConstructor::construct(FunctionObject& ne
// 29. Set displayNames.[[Fields]] to styleFields.
// 30. Return displayNames.
return display_names.ptr();
return display_names;
}
// 12.2.2 Intl.DisplayNames.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.supportedLocalesOf

View file

@ -18,7 +18,7 @@ public:
virtual ~DisplayNamesConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit DisplayNamesConstructor(Realm&);

View file

@ -42,7 +42,7 @@ ThrowCompletionOr<Value> DurationFormatConstructor::call()
}
// 1.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat
ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> DurationFormatConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -138,7 +138,7 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject&
duration_format->set_fractional_digits(Optional<u8>(TRY(get_number_option(vm, *options, vm.names.fractionalDigits, 0, 9, 0))));
// 19. Return durationFormat.
return duration_format.ptr();
return duration_format;
}
// 1.3.2 Intl.DurationFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.supportedLocalesOf

View file

@ -18,7 +18,7 @@ public:
virtual ~DurationFormatConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit DurationFormatConstructor(Realm&);

View file

@ -43,7 +43,7 @@ ThrowCompletionOr<Value> ListFormatConstructor::call()
}
// 13.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat
ThrowCompletionOr<Object*> ListFormatConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> ListFormatConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -91,7 +91,7 @@ ThrowCompletionOr<Object*> ListFormatConstructor::construct(FunctionObject& new_
// Note: The remaining steps are skipped in favor of deferring to LibUnicode.
// 19. Return listFormat.
return list_format.ptr();
return list_format;
}
// 13.2.2 Intl.ListFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat.supportedLocalesOf

View file

@ -18,7 +18,7 @@ public:
virtual ~ListFormatConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit ListFormatConstructor(Realm&);

View file

@ -241,7 +241,7 @@ ThrowCompletionOr<Value> LocaleConstructor::call()
}
// 14.1.1 Intl.Locale ( tag [ , options ] ), https://tc39.es/ecma402/#sec-Intl.Locale
ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> LocaleConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -362,7 +362,7 @@ ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_targ
locale->set_numbering_system(result.nu.release_value());
// 37. Return locale.
return locale.ptr();
return locale;
}
}

View file

@ -18,7 +18,7 @@ public:
virtual ~LocaleConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit LocaleConstructor(Realm&);

View file

@ -42,7 +42,7 @@ ThrowCompletionOr<Value> NumberFormatConstructor::call()
}
// 15.1.1 Intl.NumberFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.numberformat
ThrowCompletionOr<Object*> NumberFormatConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> NumberFormatConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -60,7 +60,7 @@ ThrowCompletionOr<Object*> NumberFormatConstructor::construct(FunctionObject& ne
// b. Return ? ChainNumberFormat(numberFormat, NewTarget, this).
// 5. Return numberFormat.
return number_format.ptr();
return number_format;
}
// 15.2.2 Intl.NumberFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.numberformat.supportedlocalesof

View file

@ -19,7 +19,7 @@ public:
virtual ~NumberFormatConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit NumberFormatConstructor(Realm&);

View file

@ -43,7 +43,7 @@ ThrowCompletionOr<Value> PluralRulesConstructor::call()
}
// 16.1.1 Intl.PluralRules ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.pluralrules
ThrowCompletionOr<Object*> PluralRulesConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> PluralRulesConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -54,7 +54,7 @@ ThrowCompletionOr<Object*> PluralRulesConstructor::construct(FunctionObject& new
auto plural_rules = TRY(ordinary_create_from_constructor<PluralRules>(vm, new_target, &Intrinsics::intl_plural_rules_prototype));
// 3. Return ? InitializePluralRules(pluralRules, locales, options).
return TRY(initialize_plural_rules(vm, plural_rules, locales, options));
return *TRY(initialize_plural_rules(vm, plural_rules, locales, options));
}
// 16.2.2 Intl.PluralRules.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.pluralrules.supportedlocalesof

View file

@ -18,7 +18,7 @@ public:
virtual ~PluralRulesConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit PluralRulesConstructor(Realm&);

View file

@ -46,7 +46,7 @@ ThrowCompletionOr<Value> RelativeTimeFormatConstructor::call()
}
// 17.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat
ThrowCompletionOr<Object*> RelativeTimeFormatConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> RelativeTimeFormatConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -57,7 +57,7 @@ ThrowCompletionOr<Object*> RelativeTimeFormatConstructor::construct(FunctionObje
auto relative_time_format = TRY(ordinary_create_from_constructor<RelativeTimeFormat>(vm, new_target, &Intrinsics::intl_relative_time_format_prototype));
// 3. Return ? InitializeRelativeTimeFormat(relativeTimeFormat, locales, options).
return TRY(initialize_relative_time_format(vm, relative_time_format, locales, options));
return *TRY(initialize_relative_time_format(vm, relative_time_format, locales, options));
}
// 17.2.2 Intl.RelativeTimeFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.supportedLocalesOf

View file

@ -18,7 +18,7 @@ public:
virtual ~RelativeTimeFormatConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit RelativeTimeFormatConstructor(Realm&);

View file

@ -42,7 +42,7 @@ ThrowCompletionOr<Value> SegmenterConstructor::call()
}
// 18.1.1 Intl.Segmenter ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.segmenter
ThrowCompletionOr<Object*> SegmenterConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> SegmenterConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -83,7 +83,7 @@ ThrowCompletionOr<Object*> SegmenterConstructor::construct(FunctionObject& new_t
segmenter->set_segmenter_granularity(granularity.as_string().deprecated_string());
// 14. Return segmenter.
return segmenter.ptr();
return segmenter;
}
// 18.2.2 Intl.Segmenter.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.segmenter.supportedlocalesof

View file

@ -18,7 +18,7 @@ public:
virtual ~SegmenterConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit SegmenterConstructor(Realm&);

View file

@ -39,14 +39,14 @@ ThrowCompletionOr<Value> MapConstructor::call()
}
// 24.1.1.1 Map ( [ iterable ] ), https://tc39.es/ecma262/#sec-map-iterable
ThrowCompletionOr<Object*> MapConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> MapConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
auto map = TRY(ordinary_create_from_constructor<Map>(vm, new_target, &Intrinsics::map_prototype));
if (vm.argument(0).is_nullish())
return map.ptr();
return map;
auto adder = TRY(map->get(vm.names.set));
if (!adder.is_function())
@ -63,7 +63,7 @@ ThrowCompletionOr<Object*> MapConstructor::construct(FunctionObject& new_target)
return {};
}));
return map.ptr();
return map;
}
// 24.1.2.2 get Map [ @@species ], https://tc39.es/ecma262/#sec-get-map-@@species

View file

@ -18,7 +18,7 @@ public:
virtual ~MapConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
private:
explicit MapConstructor(Realm&);

View file

@ -227,7 +227,7 @@ ThrowCompletionOr<Value> NativeFunction::call()
return m_native_function(vm());
}
ThrowCompletionOr<Object*> NativeFunction::construct(FunctionObject&)
ThrowCompletionOr<NonnullGCPtr<Object>> NativeFunction::construct(FunctionObject&)
{
// Needs to be overridden if [[Construct]] is needed.
VERIFY_NOT_REACHED();

View file

@ -32,7 +32,7 @@ public:
// Used for [[Call]] / [[Construct]]'s "...result of evaluating F in a manner that conforms to the specification of F".
// Needs to be overridden by all NativeFunctions without an m_native_function.
virtual ThrowCompletionOr<Value> call();
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target);
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target);
virtual FlyString const& name() const override { return m_name; };
virtual bool is_strict_mode() const override;

View file

@ -90,7 +90,7 @@ ThrowCompletionOr<Value> NumberConstructor::call()
}
// 21.1.1.1 Number ( value ), https://tc39.es/ecma262/#sec-number-constructor-number-value
ThrowCompletionOr<Object*> NumberConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> NumberConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
// NOTE: get_value_from_constructor_argument performs steps 1 and 2 and returns n.
@ -99,7 +99,7 @@ ThrowCompletionOr<Object*> NumberConstructor::construct(FunctionObject& new_targ
// 4. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Number.prototype%", « [[NumberData]] »).
// 5. Set O.[[NumberData]] to n.
// 6. Return O.
return TRY(ordinary_create_from_constructor<NumberObject>(vm, new_target, &Intrinsics::number_prototype, number.as_double())).ptr();
return TRY(ordinary_create_from_constructor<NumberObject>(vm, new_target, &Intrinsics::number_prototype, number.as_double()));
}
// 21.1.2.2 Number.isFinite ( number ), https://tc39.es/ecma262/#sec-number.isfinite

View file

@ -18,7 +18,7 @@ public:
virtual ~NumberConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit NumberConstructor(Realm&);

View file

@ -64,17 +64,17 @@ ThrowCompletionOr<Value> ObjectConstructor::call()
}
// 20.1.1.1 Object ( [ value ] ), https://tc39.es/ecma262/#sec-object-value
ThrowCompletionOr<Object*> ObjectConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> ObjectConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
auto& realm = *vm.current_realm();
if (&new_target != this)
return TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype, ConstructWithPrototypeTag::Tag)).ptr();
return TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype, ConstructWithPrototypeTag::Tag));
auto value = vm.argument(0);
if (value.is_nullish())
return Object::create(realm, realm.intrinsics().object_prototype()).ptr();
return value.to_object(vm);
return Object::create(realm, realm.intrinsics().object_prototype());
return *TRY(value.to_object(vm));
}
enum class GetOwnPropertyKeysType {

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -19,7 +19,7 @@ public:
virtual ~ObjectConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit ObjectConstructor(Realm&);

View file

@ -275,7 +275,7 @@ ThrowCompletionOr<Value> PromiseConstructor::call()
}
// 27.2.3.1 Promise ( executor ), https://tc39.es/ecma262/#sec-promise-executor
ThrowCompletionOr<Object*> PromiseConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> PromiseConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -305,7 +305,7 @@ ThrowCompletionOr<Object*> PromiseConstructor::construct(FunctionObject& new_tar
}
// 11. Return promise.
return promise.ptr();
return promise;
}
// 27.2.4.1 Promise.all ( iterable ), https://tc39.es/ecma262/#sec-promise.all

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~PromiseConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit PromiseConstructor(Realm&);

View file

@ -47,10 +47,10 @@ ThrowCompletionOr<Value> ProxyConstructor::call()
}
// 28.2.1.1 Proxy ( target, handler ), https://tc39.es/ecma262/#sec-proxy-target-handler
ThrowCompletionOr<Object*> ProxyConstructor::construct(FunctionObject&)
ThrowCompletionOr<NonnullGCPtr<Object>> ProxyConstructor::construct(FunctionObject&)
{
auto& vm = this->vm();
return TRY(proxy_create(vm, vm.argument(0), vm.argument(1)));
return *TRY(proxy_create(vm, vm.argument(0), vm.argument(1)));
}
// 28.2.2.1 Proxy.revocable ( target, handler ), https://tc39.es/ecma262/#sec-proxy.revocable

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -19,7 +19,7 @@ public:
virtual ~ProxyConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit ProxyConstructor(Realm&);

View file

@ -80,7 +80,7 @@ ThrowCompletionOr<Value> RegExpConstructor::call()
}
// 22.2.3.1 RegExp ( pattern, flags ), https://tc39.es/ecma262/#sec-regexp-pattern-flags
ThrowCompletionOr<Object*> RegExpConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> RegExpConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -137,7 +137,7 @@ ThrowCompletionOr<Object*> RegExpConstructor::construct(FunctionObject& new_targ
auto regexp_object = TRY(regexp_alloc(vm, new_target));
// 8. Return ? RegExpInitialize(O, P, F).
return TRY(regexp_object->regexp_initialize(vm, pattern_value, flags_value)).ptr();
return TRY(regexp_object->regexp_initialize(vm, pattern_value, flags_value));
}
// 22.2.4.2 get RegExp [ @@species ], https://tc39.es/ecma262/#sec-get-regexp-@@species

View file

@ -19,7 +19,7 @@ public:
virtual ~RegExpConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
RegExpLegacyStaticProperties& legacy_static_properties() { return m_legacy_static_properties; }

View file

@ -39,14 +39,14 @@ ThrowCompletionOr<Value> SetConstructor::call()
}
// 24.2.1.1 Set ( [ iterable ] ), https://tc39.es/ecma262/#sec-set-iterable
ThrowCompletionOr<Object*> SetConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> SetConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
auto set = TRY(ordinary_create_from_constructor<Set>(vm, new_target, &Intrinsics::set_prototype));
if (vm.argument(0).is_nullish())
return set.ptr();
return set;
auto adder = TRY(set->get(vm.names.add));
if (!adder.is_function())
@ -57,7 +57,7 @@ ThrowCompletionOr<Object*> SetConstructor::construct(FunctionObject& new_target)
return {};
}));
return set.ptr();
return set;
}
// 24.2.2.2 get Set [ @@species ], https://tc39.es/ecma262/#sec-get-set-@@species

View file

@ -18,7 +18,7 @@ public:
virtual ~SetConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
private:
explicit SetConstructor(Realm&);

View file

@ -37,7 +37,7 @@ ThrowCompletionOr<Value> ShadowRealmConstructor::call()
}
// 3.2.1 ShadowRealm ( ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealm
ThrowCompletionOr<Object*> ShadowRealmConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> ShadowRealmConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -71,7 +71,7 @@ ThrowCompletionOr<Object*> ShadowRealmConstructor::construct(FunctionObject& new
global_object.initialize(object->shadow_realm());
// 13. Return O.
return object.ptr();
return object;
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~ShadowRealmConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit ShadowRealmConstructor(Realm&);

View file

@ -50,7 +50,7 @@ ThrowCompletionOr<Value> StringConstructor::call()
}
// 22.1.1.1 String ( value ), https://tc39.es/ecma262/#sec-string-constructor-string-value
ThrowCompletionOr<Object*> StringConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> StringConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
auto& realm = *vm.current_realm();
@ -61,7 +61,7 @@ ThrowCompletionOr<Object*> StringConstructor::construct(FunctionObject& new_targ
else
primitive_string = TRY(vm.argument(0).to_primitive_string(vm));
auto* prototype = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::string_prototype));
return StringObject::create(realm, *primitive_string, *prototype).ptr();
return StringObject::create(realm, *primitive_string, *prototype);
}
// 22.1.2.4 String.raw ( template, ...substitutions ), https://tc39.es/ecma262/#sec-string.raw

View file

@ -18,7 +18,7 @@ public:
virtual ~StringConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit StringConstructor(Realm&);

View file

@ -46,7 +46,7 @@ ThrowCompletionOr<Value> SymbolConstructor::call()
}
// 20.4.1.1 Symbol ( [ description ] ), https://tc39.es/ecma262/#sec-symbol-description
ThrowCompletionOr<Object*> SymbolConstructor::construct(FunctionObject&)
ThrowCompletionOr<NonnullGCPtr<Object>> SymbolConstructor::construct(FunctionObject&)
{
return vm().throw_completion<TypeError>(ErrorType::NotAConstructor, "Symbol");
}

View file

@ -18,7 +18,7 @@ public:
virtual ~SymbolConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit SymbolConstructor(Realm&);

View file

@ -42,7 +42,7 @@ ThrowCompletionOr<Value> CalendarConstructor::call()
}
// 12.2.1 Temporal.Calendar ( id ), https://tc39.es/proposal-temporal/#sec-temporal.calendar
ThrowCompletionOr<Object*> CalendarConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> CalendarConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -56,7 +56,7 @@ ThrowCompletionOr<Object*> CalendarConstructor::construct(FunctionObject& new_ta
}
// 4. Return ? CreateTemporalCalendar(id, NewTarget).
return TRY(create_temporal_calendar(vm, identifier, &new_target));
return *TRY(create_temporal_calendar(vm, identifier, &new_target));
}
// 12.3.2 Temporal.Calendar.from ( calendarLike ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.from

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~CalendarConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit CalendarConstructor(Realm&);

View file

@ -46,7 +46,7 @@ ThrowCompletionOr<Value> DurationConstructor::call()
}
// 7.1.1 Temporal.Duration ( [ years [ , months [ , weeks [ , days [ , hours [ , minutes [ , seconds [ , milliseconds [ , microseconds [ , nanoseconds ] ] ] ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.duration
ThrowCompletionOr<Object*> DurationConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> DurationConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -81,7 +81,7 @@ ThrowCompletionOr<Object*> DurationConstructor::construct(FunctionObject& new_ta
auto ns = TRY(to_integer_if_integral(vm, vm.argument(9), ErrorType::TemporalInvalidDuration));
// 12. Return ? CreateTemporalDuration(y, mo, w, d, h, m, s, ms, mis, ns, NewTarget).
return TRY(create_temporal_duration(vm, y, mo, w, d, h, m, s, ms, mis, ns, &new_target));
return *TRY(create_temporal_duration(vm, y, mo, w, d, h, m, s, ms, mis, ns, &new_target));
}
// 7.2.2 Temporal.Duration.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.duration.from

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~DurationConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit DurationConstructor(Realm&);

View file

@ -49,7 +49,7 @@ ThrowCompletionOr<Value> InstantConstructor::call()
}
// 8.1.1 Temporal.Instant ( epochNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant
ThrowCompletionOr<Object*> InstantConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> InstantConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -61,7 +61,7 @@ ThrowCompletionOr<Object*> InstantConstructor::construct(FunctionObject& new_tar
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds);
// 4. Return ? CreateTemporalInstant(epochNanoseconds, NewTarget).
return TRY(create_temporal_instant(vm, *epoch_nanoseconds, &new_target));
return *TRY(create_temporal_instant(vm, *epoch_nanoseconds, &new_target));
}
// 8.2.2 Temporal.Instant.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.instant.from

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~InstantConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit InstantConstructor(Realm&);

View file

@ -46,7 +46,7 @@ ThrowCompletionOr<Value> PlainDateConstructor::call()
}
// 3.1.1 Temporal.PlainDate ( isoYear, isoMonth, isoDay [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate
ThrowCompletionOr<Object*> PlainDateConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> PlainDateConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -69,7 +69,7 @@ ThrowCompletionOr<Object*> PlainDateConstructor::construct(FunctionObject& new_t
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDate);
// 6. Return ? CreateTemporalDate(y, m, d, calendar, NewTarget).
return TRY(create_temporal_date(vm, y, m, d, *calendar, &new_target));
return *TRY(create_temporal_date(vm, y, m, d, *calendar, &new_target));
}
// 3.2.2 Temporal.PlainDate.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.from

View file

@ -18,7 +18,7 @@ public:
virtual ~PlainDateConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit PlainDateConstructor(Realm&);

View file

@ -46,7 +46,7 @@ ThrowCompletionOr<Value> PlainDateTimeConstructor::call()
}
// 5.1.1 Temporal.PlainDateTime ( isoYear, isoMonth, isoDay [ , hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond [ , calendarLike ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime
ThrowCompletionOr<Object*> PlainDateTimeConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> PlainDateTimeConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -88,7 +88,7 @@ ThrowCompletionOr<Object*> PlainDateTimeConstructor::construct(FunctionObject& n
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDateTime);
// 12. Return ? CreateTemporalDateTime(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar, NewTarget).
return TRY(create_temporal_date_time(vm, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond, *calendar, &new_target));
return *TRY(create_temporal_date_time(vm, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond, *calendar, &new_target));
}
// 5.2.2 Temporal.PlainDateTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.from

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~PlainDateTimeConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit PlainDateTimeConstructor(Realm&);

View file

@ -44,7 +44,7 @@ ThrowCompletionOr<Value> PlainMonthDayConstructor::call()
}
// 10.1.1 Temporal.PlainMonthDay ( isoMonth, isoDay [ , calendarLike [ , referenceISOYear ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday
ThrowCompletionOr<Object*> PlainMonthDayConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> PlainMonthDayConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -78,7 +78,7 @@ ThrowCompletionOr<Object*> PlainMonthDayConstructor::construct(FunctionObject& n
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainMonthDay);
// 7. Return ? CreateTemporalMonthDay(m, d, calendar, ref, NewTarget).
return TRY(create_temporal_month_day(vm, m, d, *calendar, ref, &new_target));
return *TRY(create_temporal_month_day(vm, m, d, *calendar, ref, &new_target));
}
// 10.2.2 Temporal.PlainMonthDay.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.from

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~PlainMonthDayConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit PlainMonthDayConstructor(Realm&);

View file

@ -44,7 +44,7 @@ ThrowCompletionOr<Value> PlainTimeConstructor::call()
}
// 4.1.1 Temporal.PlainTime ( [ hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime
ThrowCompletionOr<Object*> PlainTimeConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> PlainTimeConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -74,7 +74,7 @@ ThrowCompletionOr<Object*> PlainTimeConstructor::construct(FunctionObject& new_t
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainTime);
// 8. Return ? CreateTemporalTime(hour, minute, second, millisecond, microsecond, nanosecond, NewTarget).
return TRY(create_temporal_time(vm, hour, minute, second, millisecond, microsecond, nanosecond, &new_target));
return *TRY(create_temporal_time(vm, hour, minute, second, millisecond, microsecond, nanosecond, &new_target));
}
// 4.2.2 Temporal.PlainTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.from

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~PlainTimeConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit PlainTimeConstructor(Realm&);

View file

@ -46,7 +46,7 @@ ThrowCompletionOr<Value> PlainYearMonthConstructor::call()
}
// 9.1.1 Temporal.PlainYearMonth ( isoYear, isoMonth [ , calendarLike [ , referenceISODay ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth
ThrowCompletionOr<Object*> PlainYearMonthConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> PlainYearMonthConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -80,7 +80,7 @@ ThrowCompletionOr<Object*> PlainYearMonthConstructor::construct(FunctionObject&
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainYearMonth);
// 7. Return ? CreateTemporalYearMonth(y, m, calendar, ref, NewTarget).
return TRY(create_temporal_year_month(vm, y, m, *calendar, ref, &new_target));
return *TRY(create_temporal_year_month(vm, y, m, *calendar, ref, &new_target));
}
// 9.2.2 Temporal.PlainYearMonth.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.from

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~PlainYearMonthConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit PlainYearMonthConstructor(Realm&);

View file

@ -43,7 +43,7 @@ ThrowCompletionOr<Value> TimeZoneConstructor::call()
}
// 11.2.1 Temporal.TimeZone ( identifier ), https://tc39.es/proposal-temporal/#sec-temporal.timezone
ThrowCompletionOr<Object*> TimeZoneConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> TimeZoneConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -63,7 +63,7 @@ ThrowCompletionOr<Object*> TimeZoneConstructor::construct(FunctionObject& new_ta
}
// 4. Return ? CreateTemporalTimeZone(identifier, NewTarget).
return TRY(create_temporal_time_zone(vm, identifier, &new_target));
return *TRY(create_temporal_time_zone(vm, identifier, &new_target));
}
// 11.3.2 Temporal.TimeZone.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.from

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~TimeZoneConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit TimeZoneConstructor(Realm&);

View file

@ -48,7 +48,7 @@ ThrowCompletionOr<Value> ZonedDateTimeConstructor::call()
}
// 6.1.1 Temporal.ZonedDateTime ( epochNanoseconds, timeZoneLike [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime
ThrowCompletionOr<Object*> ZonedDateTimeConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> ZonedDateTimeConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -66,7 +66,7 @@ ThrowCompletionOr<Object*> ZonedDateTimeConstructor::construct(FunctionObject& n
auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, vm.argument(2)));
// 6. Return ? CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar, NewTarget).
return TRY(create_temporal_zoned_date_time(vm, *epoch_nanoseconds, *time_zone, *calendar, &new_target));
return *TRY(create_temporal_zoned_date_time(vm, *epoch_nanoseconds, *time_zone, *calendar, &new_target));
}
// 6.2.2 Temporal.ZonedDateTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.from

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +18,7 @@ public:
virtual ~ZonedDateTimeConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
private:
explicit ZonedDateTimeConstructor(Realm&);

View file

@ -505,13 +505,13 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
} \
\
/* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
ThrowCompletionOr<Object*> ConstructorName::construct(FunctionObject& new_target) \
ThrowCompletionOr<NonnullGCPtr<Object>> ConstructorName::construct(FunctionObject& new_target) \
{ \
auto& vm = this->vm(); \
auto& realm = *vm.current_realm(); \
\
if (vm.argument_count() == 0) \
return TRY(ClassName::create(realm, 0, new_target)).ptr(); \
return TRY(ClassName::create(realm, 0, new_target)); \
\
auto first_argument = vm.argument(0); \
if (first_argument.is_object()) { \
@ -532,7 +532,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \
} \
} \
return typed_array.ptr(); \
return typed_array; \
} \
\
auto array_length_or_error = first_argument.to_index(vm); \
@ -550,7 +550,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
/* FIXME: What is the best/correct behavior here? */ \
if (Checked<u32>::multiplication_would_overflow(array_length, sizeof(Type))) \
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
return TRY(ClassName::create(realm, array_length, new_target)).ptr(); \
return TRY(ClassName::create(realm, array_length, new_target)); \
}
#undef __JS_ENUMERATE

View file

@ -493,7 +493,7 @@ ThrowCompletionOr<double> compare_typed_array_elements(VM&, Value x, Value y, Fu
virtual ~ConstructorName() override; \
\
virtual ThrowCompletionOr<Value> call() override; \
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; \
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; \
\
private: \
explicit ConstructorName(Realm&, Object& prototype); \

View file

@ -45,7 +45,7 @@ ThrowCompletionOr<Value> TypedArrayConstructor::call()
}
// 23.2.1.1 %TypedArray% ( ), https://tc39.es/ecma262/#sec-%typedarray%
ThrowCompletionOr<Object*> TypedArrayConstructor::construct(FunctionObject&)
ThrowCompletionOr<NonnullGCPtr<Object>> TypedArrayConstructor::construct(FunctionObject&)
{
return vm().throw_completion<TypeError>(ErrorType::ClassIsAbstract, "TypedArray");
}

View file

@ -19,7 +19,7 @@ public:
virtual ~TypedArrayConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
protected:
TypedArrayConstructor(FlyString const& name, Object& prototype);

View file

@ -37,14 +37,14 @@ ThrowCompletionOr<Value> WeakMapConstructor::call()
}
// 24.3.1.1 WeakMap ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakmap-iterable
ThrowCompletionOr<Object*> WeakMapConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> WeakMapConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
auto weak_map = TRY(ordinary_create_from_constructor<WeakMap>(vm, new_target, &Intrinsics::weak_map_prototype));
if (vm.argument(0).is_nullish())
return weak_map.ptr();
return weak_map;
auto adder = TRY(weak_map->get(vm.names.set));
if (!adder.is_function())
@ -61,7 +61,7 @@ ThrowCompletionOr<Object*> WeakMapConstructor::construct(FunctionObject& new_tar
return {};
}));
return weak_map.ptr();
return weak_map;
}
}

View file

@ -18,7 +18,7 @@ public:
virtual ~WeakMapConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
private:
explicit WeakMapConstructor(Realm&);

View file

@ -36,7 +36,7 @@ ThrowCompletionOr<Value> WeakRefConstructor::call()
}
// 26.1.1.1 WeakRef ( target ), https://tc39.es/ecma262/#sec-weak-ref-target
ThrowCompletionOr<Object*> WeakRefConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> WeakRefConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
@ -45,9 +45,9 @@ ThrowCompletionOr<Object*> WeakRefConstructor::construct(FunctionObject& new_tar
return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, target.to_string_without_side_effects());
if (target.is_object())
return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_object())).ptr();
return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_object()));
VERIFY(target.is_symbol());
return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_symbol())).ptr();
return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_symbol()));
}
}

View file

@ -18,7 +18,7 @@ public:
virtual ~WeakRefConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
private:
explicit WeakRefConstructor(Realm&);

View file

@ -37,14 +37,14 @@ ThrowCompletionOr<Value> WeakSetConstructor::call()
}
// 24.4.1.1 WeakSet ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakset-iterable
ThrowCompletionOr<Object*> WeakSetConstructor::construct(FunctionObject& new_target)
ThrowCompletionOr<NonnullGCPtr<Object>> WeakSetConstructor::construct(FunctionObject& new_target)
{
auto& vm = this->vm();
auto weak_set = TRY(ordinary_create_from_constructor<WeakSet>(vm, new_target, &Intrinsics::weak_set_prototype));
if (vm.argument(0).is_nullish())
return weak_set.ptr();
return weak_set;
auto adder = TRY(weak_set->get(vm.names.add));
if (!adder.is_function())
@ -55,7 +55,7 @@ ThrowCompletionOr<Object*> WeakSetConstructor::construct(FunctionObject& new_tar
return {};
}));
return weak_set.ptr();
return weak_set;
}
}

View file

@ -18,7 +18,7 @@ public:
virtual ~WeakSetConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override;
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override;
private:
explicit WeakSetConstructor(Realm&);

View file

@ -33,7 +33,7 @@ JS::ThrowCompletionOr<JS::Value> AudioConstructor::call()
}
// https://html.spec.whatwg.org/multipage/media.html#dom-audio
JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&)
JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> AudioConstructor::construct(FunctionObject&)
{
auto& vm = this->vm();
@ -57,7 +57,7 @@ JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&)
}
// 5. Return audio.
return audio.ptr();
return audio;
}
}

Some files were not shown because too many files have changed in this diff Show more