summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2023-04-13 00:47:15 +0200
committerLinus Groh <mail@linusgroh.de>2023-04-13 14:29:42 +0200
commitb84f8fb55b2f926970af1d657314bb82a905ae1d (patch)
treebef32f893a3077f71b29e955fbf036602e6e83e5 /Userland/Libraries/LibJS
parented9e2366da6a28ad39bf6f71d70201d59fa79220 (diff)
downloadserenity-b84f8fb55b2f926970af1d657314bb82a905ae1d.zip
LibJS: Make intrinsics getters return NonnullGCPtr
Some of these are allocated upon initialization of the intrinsics, and some lazily, but in neither case the getters actually return a nullptr. This saves us a whole bunch of pointer dereferences (as NonnullGCPtr has an `operator T&()`), and also has the interesting side effect of forcing us to explicitly use the FunctionObject& overload of call(), as passing a NonnullGCPtr is ambigous - it could implicitly be turned into a Value _or_ a FunctionObject& (so we have to dereference manually).
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/AST.cpp8
-rw-r--r--Userland/Libraries/LibJS/Console.cpp6
-rw-r--r--Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp10
-rw-r--r--Userland/Libraries/LibJS/Runtime/AbstractOperations.h6
-rw-r--r--Userland/Libraries/LibJS/Runtime/AggregateError.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp10
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/BigIntObject.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/BooleanObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Completion.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/DataView.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Date.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/DateConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/DatePrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Error.cpp50
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp110
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intrinsics.cpp16
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intrinsics.h78
-rw-r--r--Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/JSONObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Map.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/MapConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/MapIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/MapPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/MathObject.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/NativeFunction.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/NumberObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Promise.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp8
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp8
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ProxyObject.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Reference.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ReflectObject.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp42
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpObject.cpp9
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp14
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Set.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SetConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SetIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SetPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringIterator.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringPrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/SuppressedError.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SymbolObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArray.cpp280
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArray.h4
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakMap.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakRef.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakSet.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/SyntheticModule.cpp2
169 files changed, 537 insertions, 540 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp
index c17c92d077..c21b6617f6 100644
--- a/Userland/Libraries/LibJS/AST.cpp
+++ b/Userland/Libraries/LibJS/AST.cpp
@@ -1955,8 +1955,8 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
class_private_environment->add_private_name({}, opt_private_name.release_value());
}
- auto* proto_parent = realm.intrinsics().object_prototype();
- auto* constructor_parent = realm.intrinsics().function_prototype();
+ auto proto_parent = GCPtr { realm.intrinsics().object_prototype() };
+ auto constructor_parent = realm.intrinsics().function_prototype();
if (!m_super_class.is_null()) {
vm.running_execution_context().lexical_environment = class_environment;
@@ -1985,9 +1985,9 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
if (super_class_prototype.is_null())
proto_parent = nullptr;
else
- proto_parent = &super_class_prototype.as_object();
+ proto_parent = super_class_prototype.as_object();
- constructor_parent = &super_class.as_object();
+ constructor_parent = super_class.as_object();
}
}
diff --git a/Userland/Libraries/LibJS/Console.cpp b/Userland/Libraries/LibJS/Console.cpp
index c977452cc2..6dea85170e 100644
--- a/Userland/Libraries/LibJS/Console.cpp
+++ b/Userland/Libraries/LibJS/Console.cpp
@@ -615,7 +615,7 @@ ThrowCompletionOr<MarkedVector<Value>> ConsoleClient::formatter(MarkedVector<Val
// 1. If specifier is %s, let converted be the result of Call(%String%, undefined, ยซ current ยป).
if (specifier == "%s"sv) {
- converted = TRY(call(vm, realm.intrinsics().string_constructor(), js_undefined(), current));
+ converted = TRY(call(vm, *realm.intrinsics().string_constructor(), js_undefined(), current));
}
// 2. If specifier is %d or %i:
else if (specifier.is_one_of("%d"sv, "%i"sv)) {
@@ -625,7 +625,7 @@ ThrowCompletionOr<MarkedVector<Value>> ConsoleClient::formatter(MarkedVector<Val
}
// 2. Otherwise, let converted be the result of Call(%parseInt%, undefined, ยซ current, 10 ยป).
else {
- converted = TRY(call(vm, realm.intrinsics().parse_int_function(), js_undefined(), current, Value { 10 }));
+ converted = TRY(call(vm, *realm.intrinsics().parse_int_function(), js_undefined(), current, Value { 10 }));
}
}
// 3. If specifier is %f:
@@ -636,7 +636,7 @@ ThrowCompletionOr<MarkedVector<Value>> ConsoleClient::formatter(MarkedVector<Val
}
// 2. Otherwise, let converted be the result of Call(% parseFloat %, undefined, ยซ current ยป).
else {
- converted = TRY(call(vm, realm.intrinsics().parse_float_function(), js_undefined(), current));
+ converted = TRY(call(vm, *realm.intrinsics().parse_float_function(), js_undefined(), current));
}
}
// 4. If specifier is %o, optionally let converted be current with optimally useful formatting applied.
diff --git a/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp b/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp
index 8162ddac34..04b832e6f8 100644
--- a/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp
+++ b/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -11,7 +11,7 @@ namespace JS::Test262 {
IsHTMLDDA::IsHTMLDDA(Realm& realm)
// NativeFunction without prototype is currently not possible (only due to the lack of a ctor that supports it)
- : NativeFunction("IsHTMLDDA", *realm.intrinsics().function_prototype())
+ : NativeFunction("IsHTMLDDA", realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
index d52a6edb0d..f745e74341 100644
--- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
@@ -364,7 +364,7 @@ bool validate_and_apply_property_descriptor(Object* object, PropertyKey const& p
}
// 10.1.14 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ), https://tc39.es/ecma262/#sec-getprototypefromconstructor
-ThrowCompletionOr<Object*> get_prototype_from_constructor(VM& vm, FunctionObject const& constructor, Object* (Intrinsics::*intrinsic_default_prototype)())
+ThrowCompletionOr<Object*> get_prototype_from_constructor(VM& vm, FunctionObject const& constructor, NonnullGCPtr<Object> (Intrinsics::*intrinsic_default_prototype)())
{
// 1. Assert: intrinsicDefaultProto is this specification's name of an intrinsic object. The corresponding object must be an intrinsic that is intended to be used as the [[Prototype]] value of an object.
@@ -1075,11 +1075,11 @@ Object* create_unmapped_arguments_object(VM& vm, Span<Value> arguments)
}
// 7. Perform ! DefinePropertyOrThrow(obj, @@iterator, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
- auto* array_prototype_values = realm.intrinsics().array_prototype_values_function();
+ auto array_prototype_values = realm.intrinsics().array_prototype_values_function();
MUST(object->define_property_or_throw(*vm.well_known_symbol_iterator(), { .value = array_prototype_values, .writable = true, .enumerable = false, .configurable = true }));
// 8. Perform ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Get]]: %ThrowTypeError%, [[Set]]: %ThrowTypeError%, [[Enumerable]]: false, [[Configurable]]: false }).
- auto* throw_type_error = realm.intrinsics().throw_type_error_function();
+ auto throw_type_error = realm.intrinsics().throw_type_error_function();
MUST(object->define_property_or_throw(vm.names.callee, { .get = throw_type_error, .set = throw_type_error, .enumerable = false, .configurable = false }));
// 9. Return obj.
@@ -1158,7 +1158,7 @@ Object* create_mapped_arguments_object(VM& vm, FunctionObject& function, Vector<
}
// 20. Perform ! DefinePropertyOrThrow(obj, @@iterator, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
- auto* array_prototype_values = realm.intrinsics().array_prototype_values_function();
+ auto array_prototype_values = realm.intrinsics().array_prototype_values_function();
MUST(object->define_property_or_throw(*vm.well_known_symbol_iterator(), { .value = array_prototype_values, .writable = true, .enumerable = false, .configurable = true }));
// 21. Perform ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Value]]: func, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h
index 90087fc8ec..7301a7768a 100644
--- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h
+++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -38,7 +38,7 @@ ThrowCompletionOr<Realm*> get_function_realm(VM&, FunctionObject const&);
ThrowCompletionOr<void> initialize_bound_name(VM&, DeprecatedFlyString const&, Value, Environment*);
bool is_compatible_property_descriptor(bool extensible, PropertyDescriptor const&, Optional<PropertyDescriptor> const& current);
bool validate_and_apply_property_descriptor(Object*, PropertyKey const&, bool extensible, PropertyDescriptor const&, Optional<PropertyDescriptor> const& current);
-ThrowCompletionOr<Object*> get_prototype_from_constructor(VM&, FunctionObject const& constructor, Object* (Intrinsics::*intrinsic_default_prototype)());
+ThrowCompletionOr<Object*> get_prototype_from_constructor(VM&, FunctionObject const& constructor, NonnullGCPtr<Object> (Intrinsics::*intrinsic_default_prototype)());
Object* create_unmapped_arguments_object(VM&, Span<Value> arguments);
Object* create_mapped_arguments_object(VM&, FunctionObject&, Vector<FunctionParameter> const&, Span<Value> arguments, Environment&);
@@ -142,7 +142,7 @@ ALWAYS_INLINE ThrowCompletionOr<NonnullGCPtr<Object>> construct(VM& vm, Function
// 10.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ), https://tc39.es/ecma262/#sec-ordinarycreatefromconstructor
template<typename T, typename... Args>
-ThrowCompletionOr<NonnullGCPtr<T>> ordinary_create_from_constructor(VM& vm, FunctionObject const& constructor, Object* (Intrinsics::*intrinsic_default_prototype)(), Args&&... args)
+ThrowCompletionOr<NonnullGCPtr<T>> ordinary_create_from_constructor(VM& vm, FunctionObject const& constructor, NonnullGCPtr<Object> (Intrinsics::*intrinsic_default_prototype)(), Args&&... args)
{
auto& realm = *vm.current_realm();
auto* prototype = TRY(get_prototype_from_constructor(vm, constructor, intrinsic_default_prototype));
diff --git a/Userland/Libraries/LibJS/Runtime/AggregateError.cpp b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp
index 1f3a225b80..ce73fdac7e 100644
--- a/Userland/Libraries/LibJS/Runtime/AggregateError.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -12,7 +12,7 @@ namespace JS {
NonnullGCPtr<AggregateError> AggregateError::create(Realm& realm)
{
- return realm.heap().allocate<AggregateError>(realm, *realm.intrinsics().aggregate_error_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<AggregateError>(realm, realm.intrinsics().aggregate_error_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
AggregateError::AggregateError(Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp
index 59620b74a4..4f5930b1ef 100644
--- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp
index c9fad374e9..3f03b0eb23 100644
--- a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -11,7 +11,7 @@
namespace JS {
AggregateErrorPrototype::AggregateErrorPrototype(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().error_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().error_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp
index 91f8943959..3d66852ae9 100644
--- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp
@@ -11,7 +11,7 @@
namespace JS {
ArgumentsObject::ArgumentsObject(Realm& realm, Environment& environment)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
, m_environment(environment)
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp
index e86be838a3..843eefb428 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -17,17 +17,17 @@ ThrowCompletionOr<NonnullGCPtr<ArrayBuffer>> ArrayBuffer::create(Realm& realm, s
if (buffer.is_error())
return realm.vm().throw_completion<RangeError>(ErrorType::NotEnoughMemoryToAllocate, byte_length);
- return MUST_OR_THROW_OOM(realm.heap().allocate<ArrayBuffer>(realm, buffer.release_value(), *realm.intrinsics().array_buffer_prototype()));
+ return MUST_OR_THROW_OOM(realm.heap().allocate<ArrayBuffer>(realm, buffer.release_value(), realm.intrinsics().array_buffer_prototype()));
}
NonnullGCPtr<ArrayBuffer> ArrayBuffer::create(Realm& realm, ByteBuffer buffer)
{
- return realm.heap().allocate<ArrayBuffer>(realm, move(buffer), *realm.intrinsics().array_buffer_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<ArrayBuffer>(realm, move(buffer), realm.intrinsics().array_buffer_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
NonnullGCPtr<ArrayBuffer> ArrayBuffer::create(Realm& realm, ByteBuffer* buffer)
{
- return realm.heap().allocate<ArrayBuffer>(realm, buffer, *realm.intrinsics().array_buffer_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<ArrayBuffer>(realm, buffer, realm.intrinsics().array_buffer_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
ArrayBuffer::ArrayBuffer(ByteBuffer buffer, Object& prototype)
@@ -101,7 +101,7 @@ ThrowCompletionOr<ArrayBuffer*> clone_array_buffer(VM& vm, ArrayBuffer& source_b
VERIFY(!source_buffer.is_detached());
// 2. Let targetBuffer be ? AllocateArrayBuffer(%ArrayBuffer%, srcLength).
- auto* target_buffer = TRY(allocate_array_buffer(vm, *realm.intrinsics().array_buffer_constructor(), source_length));
+ auto* target_buffer = TRY(allocate_array_buffer(vm, realm.intrinsics().array_buffer_constructor(), source_length));
// 3. Let srcBlock be srcBuffer.[[ArrayBufferData]].
auto& source_block = source_buffer.buffer();
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
index 698902bdc5..50f541ef80 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
@@ -15,7 +15,7 @@
namespace JS {
ArrayBufferConstructor::ArrayBufferConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.ArrayBuffer.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.ArrayBuffer.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp
index 46aa683958..5bae2308b8 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
*
@@ -15,7 +15,7 @@
namespace JS {
ArrayBufferPrototype::ArrayBufferPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
@@ -84,7 +84,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice)
auto new_length = max(final - first, 0.0);
// 15. Let ctor be ? SpeciesConstructor(O, %ArrayBuffer%).
- auto* constructor = TRY(species_constructor(vm, *array_buffer_object, *realm.intrinsics().array_buffer_constructor()));
+ auto* constructor = TRY(species_constructor(vm, *array_buffer_object, realm.intrinsics().array_buffer_constructor()));
// 16. Let new be ? Construct(ctor, ยซ ๐”ฝ(newLen) ยป).
auto new_array_buffer = TRY(construct(vm, *constructor, Value(new_length)));
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
index 50338db90a..9d14df59b2 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
@@ -17,7 +17,7 @@
namespace JS {
ArrayConstructor::ArrayConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Array.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Array.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp
index 483f25f3d7..662a679667 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp
@@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<ArrayIterator> ArrayIterator::create(Realm& realm, Value array, Object::PropertyKind iteration_kind)
{
- return realm.heap().allocate<ArrayIterator>(realm, array, iteration_kind, *realm.intrinsics().array_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<ArrayIterator>(realm, array, iteration_kind, realm.intrinsics().array_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp
index 5f733c68ef..c7390316ce 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp
@@ -15,7 +15,7 @@
namespace JS {
ArrayIteratorPrototype::ArrayIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().iterator_prototype())
+ : PrototypeObject(realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp
index c3b1022c2b..bd3db43e70 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2020, Marcin Gasperowicz <xnooga@gmail.com>
* Copyright (c) 2021, David Tuin <davidot@serenityos.org>
*
@@ -29,7 +29,7 @@ namespace JS {
static HashTable<Object*> s_array_join_seen_objects;
ArrayPrototype::ArrayPrototype(Realm& realm)
- : Array(*realm.intrinsics().object_prototype())
+ : Array(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp
index ad1c97f981..c5568f5e5a 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2021, David Tuin <davidot@serenityos.org>
- * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -17,7 +17,7 @@ NonnullGCPtr<AsyncFromSyncIterator> AsyncFromSyncIterator::create(Realm& realm,
}
AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterator_record)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().async_from_sync_iterator_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().async_from_sync_iterator_prototype())
, m_sync_iterator_record(sync_iterator_record)
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp
index 70092e01f5..b366ea9f4e 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2021, David Tuin <davidot@serenityos.org>
- * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -15,7 +15,7 @@
namespace JS {
AsyncFromSyncIteratorPrototype::AsyncFromSyncIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().async_iterator_prototype())
+ : PrototypeObject(realm.intrinsics().async_iterator_prototype())
{
}
@@ -48,7 +48,7 @@ static Object* async_from_sync_iterator_continuation(VM& vm, Object& result, Pro
// 6. Let valueWrapper be PromiseResolve(%Promise%, value).
// 7. IfAbruptRejectPromise(valueWrapper, promiseCapability).
- auto value_wrapper = TRY_OR_MUST_REJECT(vm, &promise_capability, promise_resolve(vm, *realm.intrinsics().promise_constructor(), value));
+ auto value_wrapper = TRY_OR_MUST_REJECT(vm, &promise_capability, promise_resolve(vm, realm.intrinsics().promise_constructor(), value));
// 8. Let unwrap be a new Abstract Closure with parameters (value) that captures done and performs the following steps when called:
auto unwrap = [done](VM& vm) -> ThrowCompletionOr<Value> {
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp
index f7d5061b16..c9e21d8353 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp
@@ -13,7 +13,7 @@
namespace JS {
AsyncFunctionConstructor::AsyncFunctionConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.AsyncFunction.as_string(), *realm.intrinsics().function_constructor())
+ : NativeFunction(realm.vm().names.AsyncFunction.as_string(), realm.intrinsics().function_constructor())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp
index dd845b6374..e3f2ad5476 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp
@@ -27,7 +27,7 @@ ThrowCompletionOr<Value> AsyncFunctionDriverWrapper::create(Realm& realm, Genera
}
AsyncFunctionDriverWrapper::AsyncFunctionDriverWrapper(Realm& realm, NonnullGCPtr<GeneratorObject> generator_object, NonnullGCPtr<Promise> top_level_promise)
- : Promise(*realm.intrinsics().promise_prototype())
+ : Promise(realm.intrinsics().promise_prototype())
, m_generator_object(generator_object)
, m_on_fulfillment(*NativeFunction::create(realm, "async.on_fulfillment"sv, [this](VM& vm) -> ThrowCompletionOr<Value> {
auto arg = vm.argument(0);
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp
index decc505483..ae84175595 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp
@@ -10,7 +10,7 @@
namespace JS {
AsyncFunctionPrototype::AsyncFunctionPrototype(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().function_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp
index 172ed57e9e..67610de6fc 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp
@@ -13,7 +13,7 @@
namespace JS {
AsyncGeneratorFunctionConstructor::AsyncGeneratorFunctionConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.AsyncGeneratorFunction.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.AsyncGeneratorFunction.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp
index a37bbbf954..fbd6e496e6 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp
@@ -12,7 +12,7 @@
namespace JS {
AsyncGeneratorFunctionPrototype::AsyncGeneratorFunctionPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().function_prototype())
+ : PrototypeObject(realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp
index 002c2de529..b99b9a085c 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -10,7 +10,7 @@ namespace JS {
// 27.6.1 Properties of the AsyncGenerator Prototype Object, https://tc39.es/ecma262/#sec-properties-of-asyncgenerator-prototype
AsyncGeneratorPrototype::AsyncGeneratorPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().async_iterator_prototype())
+ : PrototypeObject(realm.intrinsics().async_iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp
index 6a7e3e3f9a..652bc17e99 100644
--- a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp
@@ -9,7 +9,7 @@
namespace JS {
AsyncIteratorPrototype::AsyncIteratorPrototype(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp
index d69c38fc2d..5c9d4ae97c 100644
--- a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp
@@ -125,7 +125,7 @@ static ThrowCompletionOr<Value> perform_atomic_operation(VM& vm, TypedArrayBase&
}
AtomicsObject::AtomicsObject(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp
index e8d6d6f4d6..ace1b00b63 100644
--- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -17,7 +17,7 @@ namespace JS {
static const Crypto::SignedBigInteger BIGINT_ONE { 1 };
BigIntConstructor::BigIntConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.BigInt.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.BigInt.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp b/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp
index 3c38567ca1..bdb946df7a 100644
--- a/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<BigIntObject> BigIntObject::create(Realm& realm, BigInt& bigint)
{
- return realm.heap().allocate<BigIntObject>(realm, bigint, *realm.intrinsics().bigint_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<BigIntObject>(realm, bigint, realm.intrinsics().bigint_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
BigIntObject::BigIntObject(BigInt& bigint, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp
index 30213e9ab3..6f00945064 100644
--- a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp
@@ -18,7 +18,7 @@
namespace JS {
BigIntPrototype::BigIntPrototype(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
@@ -90,7 +90,7 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_locale_string)
auto* bigint = TRY(this_bigint_value(vm, vm.this_value()));
// 2. Let numberFormat be ? Construct(%NumberFormat%, ยซ locales, options ยป).
- auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), locales, options)).ptr());
+ auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, realm.intrinsics().intl_number_format_constructor(), locales, options)).ptr());
// 3. Return ? FormatNumeric(numberFormat, x).
auto formatted = TRY(Intl::format_numeric(vm, *number_format, Value(bigint)));
diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp
index 4bb1fa1723..8850882207 100644
--- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp
@@ -13,7 +13,7 @@
namespace JS {
BooleanConstructor::BooleanConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Boolean.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Boolean.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp b/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp
index 964cc3926f..edf2262a3a 100644
--- a/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp
@@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<BooleanObject> BooleanObject::create(Realm& realm, bool value)
{
- return realm.heap().allocate<BooleanObject>(realm, value, *realm.intrinsics().boolean_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<BooleanObject>(realm, value, realm.intrinsics().boolean_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
BooleanObject::BooleanObject(bool value, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp
index 9a45712bf2..a0a8b3a793 100644
--- a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp
@@ -14,7 +14,7 @@
namespace JS {
BooleanPrototype::BooleanPrototype(Realm& realm)
- : BooleanObject(false, *realm.intrinsics().object_prototype())
+ : BooleanObject(false, realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Completion.cpp b/Userland/Libraries/LibJS/Runtime/Completion.cpp
index 647e1291d8..426fd4f8bd 100644
--- a/Userland/Libraries/LibJS/Runtime/Completion.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Completion.cpp
@@ -37,7 +37,7 @@ ThrowCompletionOr<Value> await(VM& vm, Value value)
// NOTE: This is not needed, as we don't suspend anything.
// 2. Let promise be ? PromiseResolve(%Promise%, value).
- auto* promise_object = TRY(promise_resolve(vm, *realm.intrinsics().promise_constructor(), value));
+ auto* promise_object = TRY(promise_resolve(vm, realm.intrinsics().promise_constructor(), value));
Optional<bool> success;
Value result;
diff --git a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
index aa7f0bed7d..ac7a0f2b94 100644
--- a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2020, Emanuele Torre <torreemanuele6@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
@@ -13,7 +13,7 @@
namespace JS {
ConsoleObject::ConsoleObject(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
, m_console(make<Console>(realm))
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/DataView.cpp b/Userland/Libraries/LibJS/Runtime/DataView.cpp
index eb3131b03f..6249eb9dcd 100644
--- a/Userland/Libraries/LibJS/Runtime/DataView.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DataView.cpp
@@ -10,7 +10,7 @@ namespace JS {
NonnullGCPtr<DataView> DataView::create(Realm& realm, ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset)
{
- return realm.heap().allocate<DataView>(realm, viewed_buffer, byte_length, byte_offset, *realm.intrinsics().data_view_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<DataView>(realm, viewed_buffer, byte_length, byte_offset, realm.intrinsics().data_view_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
DataView::DataView(ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp
index 44afbe9dd0..6233a0e47e 100644
--- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp
@@ -15,7 +15,7 @@
namespace JS {
DataViewConstructor::DataViewConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.DataView.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.DataView.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp
index 25af7f61c4..1252fe5116 100644
--- a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp
@@ -11,7 +11,7 @@
namespace JS {
DataViewPrototype::DataViewPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Date.cpp b/Userland/Libraries/LibJS/Runtime/Date.cpp
index cb0251ed98..9fad2afd66 100644
--- a/Userland/Libraries/LibJS/Runtime/Date.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Date.cpp
@@ -25,7 +25,7 @@ Crypto::SignedBigInteger const ns_per_day_bigint { static_cast<i64>(ns_per_day)
NonnullGCPtr<Date> Date::create(Realm& realm, double date_value)
{
- return realm.heap().allocate<Date>(realm, date_value, *realm.intrinsics().date_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<Date>(realm, date_value, realm.intrinsics().date_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
Date::Date(double date_value, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
index c5d7feb29f..96380dea5e 100644
--- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2020, Nico Weber <thakis@chromium.org>
* Copyright (c) 2021, Petrรณczi Zoltรกn <petroczizoltan@tutanota.com>
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
@@ -179,7 +179,7 @@ static double parse_date_string(DeprecatedString const& date_string)
}
DateConstructor::DateConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Date.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Date.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp
index 171ca047d5..5e0a4f9cda 100644
--- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021, Petrรณczi Zoltรกn <petroczizoltan@tutanota.com>
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
@@ -30,7 +30,7 @@
namespace JS {
DatePrototype::DatePrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
@@ -987,7 +987,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_json)
static ThrowCompletionOr<Intl::DateTimeFormat*> construct_date_time_format(VM& vm, Value locales, Value options)
{
auto& realm = *vm.current_realm();
- auto date_time_format = TRY(construct(vm, *realm.intrinsics().intl_date_time_format_constructor(), locales, options));
+ auto date_time_format = TRY(construct(vm, realm.intrinsics().intl_date_time_format_constructor(), locales, options));
return static_cast<Intl::DateTimeFormat*>(date_time_format.ptr());
}
diff --git a/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.cpp
index 64055d99eb..ae7a5d43d2 100644
--- a/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.cpp
@@ -11,7 +11,7 @@
namespace JS {
DisposableStackConstructor::DisposableStackConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.DisposableStack.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.DisposableStack.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.cpp b/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.cpp
index 2ad775b24e..3bcca253eb 100644
--- a/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.cpp
@@ -13,7 +13,7 @@
namespace JS {
DisposableStackPrototype::DisposableStackPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
index ff8107f9ce..0a3a4d9609 100644
--- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
@@ -115,7 +115,7 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::initialize(Realm& realm)
Object* prototype = nullptr;
switch (m_kind) {
case FunctionKind::Normal:
- prototype = MUST_OR_THROW_OOM(vm.heap().allocate<Object>(realm, *realm.intrinsics().new_ordinary_function_prototype_object_shape()));
+ prototype = MUST_OR_THROW_OOM(vm.heap().allocate<Object>(realm, realm.intrinsics().new_ordinary_function_prototype_object_shape()));
MUST(prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true }));
break;
case FunctionKind::Generator:
diff --git a/Userland/Libraries/LibJS/Runtime/Error.cpp b/Userland/Libraries/LibJS/Runtime/Error.cpp
index 33a4ab4a7f..8e33d839f9 100644
--- a/Userland/Libraries/LibJS/Runtime/Error.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Error.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -17,7 +17,7 @@ namespace JS {
NonnullGCPtr<Error> Error::create(Realm& realm)
{
- return realm.heap().allocate<Error>(realm, *realm.intrinsics().error_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<Error>(realm, realm.intrinsics().error_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
NonnullGCPtr<Error> Error::create(Realm& realm, String message)
@@ -105,29 +105,29 @@ ThrowCompletionOr<String> Error::stack_string(VM& vm) const
return stack_string_builder.to_string();
}
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- NonnullGCPtr<ClassName> ClassName::create(Realm& realm) \
- { \
- return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); \
- } \
- \
- NonnullGCPtr<ClassName> ClassName::create(Realm& realm, String message) \
- { \
- auto& vm = realm.vm(); \
- auto error = ClassName::create(realm); \
- u8 attr = Attribute::Writable | Attribute::Configurable; \
- error->define_direct_property(vm.names.message, PrimitiveString::create(vm, move(message)), attr); \
- return error; \
- } \
- \
- ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, StringView message) \
- { \
- return create(realm, TRY_OR_THROW_OOM(realm.vm(), String::from_utf8(message))); \
- } \
- \
- ClassName::ClassName(Object& prototype) \
- : Error(prototype) \
- { \
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
+ NonnullGCPtr<ClassName> ClassName::create(Realm& realm) \
+ { \
+ return realm.heap().allocate<ClassName>(realm, realm.intrinsics().snake_name##_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); \
+ } \
+ \
+ NonnullGCPtr<ClassName> ClassName::create(Realm& realm, String message) \
+ { \
+ auto& vm = realm.vm(); \
+ auto error = ClassName::create(realm); \
+ u8 attr = Attribute::Writable | Attribute::Configurable; \
+ error->define_direct_property(vm.names.message, PrimitiveString::create(vm, move(message)), attr); \
+ return error; \
+ } \
+ \
+ ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, StringView message) \
+ { \
+ return create(realm, TRY_OR_THROW_OOM(realm.vm(), String::from_utf8(message))); \
+ } \
+ \
+ ClassName::ClassName(Object& prototype) \
+ : Error(prototype) \
+ { \
}
JS_ENUMERATE_NATIVE_ERRORS
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
index 0bad44b86f..8f8692f5e4 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -12,7 +12,7 @@
namespace JS {
ErrorConstructor::ErrorConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Error.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Error.as_string(), realm.intrinsics().function_prototype())
{
}
@@ -63,59 +63,59 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ErrorConstructor::construct(FunctionObje
return error;
}
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- ConstructorName::ConstructorName(Realm& realm) \
- : NativeFunction(realm.vm().names.ClassName.as_string(), *static_cast<Object*>(realm.intrinsics().error_constructor())) \
- { \
- } \
- \
- ThrowCompletionOr<void> ConstructorName::initialize(Realm& realm) \
- { \
- auto& vm = this->vm(); \
- 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; \
- \
- /* 20.5.6.1.1 NativeError ( message [ , options ] ), https://tc39.es/ecma262/#sec-nativeerror */ \
- ThrowCompletionOr<Value> ConstructorName::call() \
- { \
- /* 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. */ \
- return TRY(construct(*this)); \
- } \
- \
- /* 20.5.6.1.1 NativeError ( message [ , options ] ), https://tc39.es/ecma262/#sec-nativeerror */ \
- ThrowCompletionOr<NonnullGCPtr<Object>> ConstructorName::construct(FunctionObject& new_target) \
- { \
- auto& vm = this->vm(); \
- \
- auto message = vm.argument(0); \
- auto options = vm.argument(1); \
- \
- /* 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeError.prototype%", ยซ [[ErrorData]] ยป). */ \
- auto error = TRY(ordinary_create_from_constructor<ClassName>(vm, new_target, &Intrinsics::snake_name##_prototype)); \
- \
- /* 3. If message is not undefined, then */ \
- if (!message.is_undefined()) { \
- /* a. Let msg be ? ToString(message). */ \
- auto msg = TRY(message.to_string(vm)); \
- \
- /* b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg). */ \
- error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, move(msg))); \
- } \
- \
- /* 4. Perform ? InstallErrorCause(O, options). */ \
- TRY(error->install_error_cause(options)); \
- \
- /* 5. Return O. */ \
- return error; \
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
+ ConstructorName::ConstructorName(Realm& realm) \
+ : NativeFunction(realm.vm().names.ClassName.as_string(), realm.intrinsics().error_constructor()) \
+ { \
+ } \
+ \
+ ThrowCompletionOr<void> ConstructorName::initialize(Realm& realm) \
+ { \
+ auto& vm = this->vm(); \
+ 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; \
+ \
+ /* 20.5.6.1.1 NativeError ( message [ , options ] ), https://tc39.es/ecma262/#sec-nativeerror */ \
+ ThrowCompletionOr<Value> ConstructorName::call() \
+ { \
+ /* 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. */ \
+ return TRY(construct(*this)); \
+ } \
+ \
+ /* 20.5.6.1.1 NativeError ( message [ , options ] ), https://tc39.es/ecma262/#sec-nativeerror */ \
+ ThrowCompletionOr<NonnullGCPtr<Object>> ConstructorName::construct(FunctionObject& new_target) \
+ { \
+ auto& vm = this->vm(); \
+ \
+ auto message = vm.argument(0); \
+ auto options = vm.argument(1); \
+ \
+ /* 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeError.prototype%", ยซ [[ErrorData]] ยป). */ \
+ auto error = TRY(ordinary_create_from_constructor<ClassName>(vm, new_target, &Intrinsics::snake_name##_prototype)); \
+ \
+ /* 3. If message is not undefined, then */ \
+ if (!message.is_undefined()) { \
+ /* a. Let msg be ? ToString(message). */ \
+ auto msg = TRY(message.to_string(vm)); \
+ \
+ /* b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg). */ \
+ error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, move(msg))); \
+ } \
+ \
+ /* 4. Perform ? InstallErrorCause(O, options). */ \
+ TRY(error->install_error_cause(options)); \
+ \
+ /* 5. Return O. */ \
+ return error; \
}
JS_ENUMERATE_NATIVE_ERRORS
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
index db56cbc8f6..ead30242f3 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -15,7 +15,7 @@
namespace JS {
ErrorPrototype::ErrorPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
@@ -126,7 +126,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_setter)
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
PrototypeName::PrototypeName(Realm& realm) \
- : PrototypeObject(*realm.intrinsics().error_prototype()) \
+ : PrototypeObject(realm.intrinsics().error_prototype()) \
{ \
} \
\
diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp
index 8574cd067c..4736650129 100644
--- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
FinalizationRegistryConstructor::FinalizationRegistryConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.FinalizationRegistry.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.FinalizationRegistry.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp
index 13cfd26615..4d97055ab2 100644
--- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp
@@ -11,7 +11,7 @@
namespace JS {
FinalizationRegistryPrototype::FinalizationRegistryPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp
index 12997aea77..0ae418615a 100644
--- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -19,7 +19,7 @@
namespace JS {
FunctionConstructor::FunctionConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Function.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Function.as_string(), realm.intrinsics().function_prototype())
{
}
@@ -50,7 +50,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
new_target = &constructor;
StringView prefix;
- Object* (Intrinsics::*fallback_prototype)() = nullptr;
+ NonnullGCPtr<Object> (Intrinsics::*fallback_prototype)() = nullptr;
switch (kind) {
// 4. If kind is normal, then
diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp
index 80c39d7e1f..fc2b1460d5 100644
--- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp
@@ -21,7 +21,7 @@
namespace JS {
FunctionPrototype::FunctionPrototype(Realm& realm)
- : FunctionObject(*realm.intrinsics().object_prototype())
+ : FunctionObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp
index 5b71e0dcfb..f81cc67a06 100644
--- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp
@@ -12,7 +12,7 @@
namespace JS {
GeneratorFunctionConstructor::GeneratorFunctionConstructor(Realm& realm)
- : NativeFunction(static_cast<Object&>(*realm.intrinsics().function_constructor()))
+ : NativeFunction(static_cast<Object&>(realm.intrinsics().function_constructor()))
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp
index a951b1d6a3..9f138b32c2 100644
--- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp
@@ -11,7 +11,7 @@
namespace JS {
GeneratorFunctionPrototype::GeneratorFunctionPrototype(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().function_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp
index 7093b9815f..aa64d6fde3 100644
--- a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp
@@ -10,7 +10,7 @@
namespace JS {
GeneratorPrototype::GeneratorPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().iterator_prototype())
+ : PrototypeObject(realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp
index a14b0f9fd2..e530a2cfa2 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp
@@ -17,7 +17,7 @@ NonnullGCPtr<CollatorCompareFunction> CollatorCompareFunction::create(Realm& rea
}
CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator)
- : NativeFunction(*realm.intrinsics().function_prototype())
+ : NativeFunction(realm.intrinsics().function_prototype())
, m_collator(collator)
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp
index d4ff6bcada..3d890e7c79 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp
@@ -131,7 +131,7 @@ static ThrowCompletionOr<Collator*> initialize_collator(VM& vm, Collator& collat
// 10.1 The Intl.Collator Constructor, https://tc39.es/ecma402/#sec-the-intl-collator-constructor
CollatorConstructor::CollatorConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Collator.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Collator.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp
index 4895281f7a..9a42cc411d 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp
@@ -13,7 +13,7 @@ namespace JS::Intl {
// 10.3 Properties of the Intl.Collator Prototype Object, https://tc39.es/ecma402/#sec-properties-of-the-intl-collator-prototype-object
CollatorPrototype::CollatorPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp
index 61b1caf85f..aa1e81aaf0 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp
@@ -551,7 +551,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
auto const& data_locale = date_time_format.data_locale();
auto construct_number_format = [&](auto& options) -> ThrowCompletionOr<NumberFormat*> {
- auto number_format = TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, locale), options));
+ auto number_format = TRY(construct(vm, realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, locale), options));
return static_cast<NumberFormat*>(number_format.ptr());
};
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp
index 7ce26d6543..a5feb85b29 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp
@@ -19,7 +19,7 @@ namespace JS::Intl {
// 11.1 The Intl.DateTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-datetimeformat-constructor
DateTimeFormatConstructor::DateTimeFormatConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.DateTimeFormat.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.DateTimeFormat.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp
index 5552bf5ef3..ea080face2 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp
@@ -16,7 +16,7 @@ namespace JS::Intl {
// 11.5.5 DateTime Format Functions, https://tc39.es/ecma402/#sec-datetime-format-functions
NonnullGCPtr<DateTimeFormatFunction> DateTimeFormatFunction::create(Realm& realm, DateTimeFormat& date_time_format)
{
- return realm.heap().allocate<DateTimeFormatFunction>(realm, date_time_format, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<DateTimeFormatFunction>(realm, date_time_format, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, Object& prototype)
@@ -51,7 +51,7 @@ ThrowCompletionOr<Value> DateTimeFormatFunction::call()
// 3. If date is not provided or is undefined, then
if (date.is_undefined()) {
// a. Let x be ! Call(%Date.now%, undefined).
- date_value = MUST(JS::call(vm, realm.intrinsics().date_constructor_now_function(), js_undefined())).as_double();
+ date_value = MUST(JS::call(vm, *realm.intrinsics().date_constructor_now_function(), js_undefined())).as_double();
}
// 4. Else,
else {
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp
index 39bb4ddc4a..dce8035fdb 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp
@@ -15,7 +15,7 @@ namespace JS::Intl {
// 11.3 Properties of the Intl.DateTimeFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-datetimeformat-prototype-object
DateTimeFormatPrototype::DateTimeFormatPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
@@ -80,7 +80,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_to_parts)
// 3. If date is undefined, then
if (date.is_undefined()) {
// a. Let x be ! Call(%Date.now%, undefined).
- date_value = MUST(call(vm, realm.intrinsics().date_constructor_now_function(), js_undefined())).as_double();
+ date_value = MUST(call(vm, *realm.intrinsics().date_constructor_now_function(), js_undefined())).as_double();
}
// 4. Else,
else {
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
index d09882ffd3..056ee602b4 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp
@@ -17,7 +17,7 @@ namespace JS::Intl {
// 12.1 The Intl.DisplayNames Constructor, https://tc39.es/ecma402/#sec-intl-displaynames-constructor
DisplayNamesConstructor::DisplayNamesConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.DisplayNames.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.DisplayNames.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
index 4e8c00fa70..c5a79e3d09 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp
@@ -15,7 +15,7 @@ namespace JS::Intl {
// 12.3 Properties of the Intl.DisplayNames Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-displaynames-prototype-object
DisplayNamesPrototype::DisplayNamesPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
index 4ba7e8adb6..9dd4e132c1 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
@@ -438,7 +438,7 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_duration_format_pattern(VM
// i. If style is "2-digit" or "numeric", then
if (style == DurationFormat::ValueStyle::TwoDigit || style == DurationFormat::ValueStyle::Numeric) {
// 1. Let nf be ! Construct(%NumberFormat%, ยซ durationFormat.[[Locale]], nfOpts ยป).
- auto* number_format = static_cast<NumberFormat*>(MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), number_format_options)).ptr());
+ auto* number_format = static_cast<NumberFormat*>(MUST(construct(vm, realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), number_format_options)).ptr());
// 2. Let dataLocale be durationFormat.[[DataLocale]].
auto const& data_locale = duration_format.data_locale();
@@ -502,7 +502,7 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_duration_format_pattern(VM
MUST(number_format_options->create_data_property_or_throw(vm.names.unitDisplay, MUST_OR_THROW_OOM(PrimitiveString::create(vm, unicode_style))));
// 4. Let nf be ! Construct(%NumberFormat%, ยซ durationFormat.[[Locale]], nfOpts ยป).
- auto* number_format = static_cast<NumberFormat*>(MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), number_format_options)).ptr());
+ auto* number_format = static_cast<NumberFormat*>(MUST(construct(vm, realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), number_format_options)).ptr());
// 5. Let parts be ! PartitionNumberPattern(nf, ๐”ฝ(value)).
auto parts = MUST_OR_THROW_OOM(partition_number_pattern(vm, *number_format, MathematicalValue(value)));
@@ -543,7 +543,7 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_duration_format_pattern(VM
MUST(list_format_options->create_data_property_or_throw(vm.names.style, MUST_OR_THROW_OOM(PrimitiveString::create(vm, unicode_list_style))));
// 9. Let lf be ! Construct(%ListFormat%, ยซ durationFormat.[[Locale]], lfOpts ยป).
- auto* list_format = static_cast<ListFormat*>(MUST(construct(vm, *realm.intrinsics().intl_list_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), list_format_options)).ptr());
+ auto* list_format = static_cast<ListFormat*>(MUST(construct(vm, realm.intrinsics().intl_list_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), list_format_options)).ptr());
// FIXME: CreatePartsFromList expects a list of strings and creates a list of Pattern Partition records, but we already created a list of Pattern Partition records
// so we try to hack something together from it that looks mostly right
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
index 1e2dab45bc..8840bf0410 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp
@@ -16,7 +16,7 @@ namespace JS::Intl {
// 1.2 The Intl.DurationFormat Constructor, https://tc39.es/proposal-intl-duration-format/#sec-intl-durationformat-constructor
DurationFormatConstructor::DurationFormatConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.DurationFormat.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.DurationFormat.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp
index 7dbeec8c9d..884d5e7d53 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp
@@ -14,7 +14,7 @@ namespace JS::Intl {
// 1.4 Properties of the Intl.DurationFormat Prototype Object, https://tc39.es/proposal-intl-duration-format/#sec-properties-of-intl-durationformat-prototype-object
DurationFormatPrototype::DurationFormatPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp
index 9f9cf96abd..0dc9eeffe7 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -28,7 +28,7 @@ namespace JS::Intl {
// 8 The Intl Object, https://tc39.es/ecma402/#intl-object
Intl::Intl(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp
index 11d8afc2f1..2a5e3ea048 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp
@@ -16,7 +16,7 @@ namespace JS::Intl {
// 13.1 The Intl.ListFormat Constructor, https://tc39.es/ecma402/#sec-intl-listformat-constructor
ListFormatConstructor::ListFormatConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.ListFormat.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.ListFormat.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp
index bc880466b9..62380ff9bf 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp
@@ -14,7 +14,7 @@ namespace JS::Intl {
// 13.3 Properties of the Intl.ListFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-listformat-prototype-object
ListFormatPrototype::ListFormatPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp
index b177efc065..422a66b408 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp
@@ -16,7 +16,7 @@ namespace JS::Intl {
ThrowCompletionOr<NonnullGCPtr<Locale>> Locale::create(Realm& realm, ::Locale::LocaleID locale_id)
{
- auto locale = MUST_OR_THROW_OOM(realm.heap().allocate<Locale>(realm, *realm.intrinsics().intl_locale_prototype()));
+ auto locale = MUST_OR_THROW_OOM(realm.heap().allocate<Locale>(realm, realm.intrinsics().intl_locale_prototype()));
locale->set_locale(TRY_OR_THROW_OOM(realm.vm(), locale_id.to_string()));
for (auto& extension : locale_id.extensions) {
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp
index d980aad5df..ac9a2b343e 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp
@@ -218,7 +218,7 @@ static ThrowCompletionOr<LocaleAndKeys> apply_unicode_extension_to_tag(VM& vm, S
// 14.1 The Intl.Locale Constructor, https://tc39.es/ecma402/#sec-intl-locale-constructor
LocaleConstructor::LocaleConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Locale.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Locale.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
index ae4140e1cb..f22fe16213 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp
@@ -15,7 +15,7 @@ namespace JS::Intl {
// 14.3 Properties of the Intl.Locale Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-locale-prototype-object
LocalePrototype::LocalePrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp
index c3e64c270a..ce69d0dd6b 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp
@@ -15,7 +15,7 @@ namespace JS::Intl {
// 15.1 The Intl.NumberFormat Constructor, https://tc39.es/ecma402/#sec-intl-numberformat-constructor
NumberFormatConstructor::NumberFormatConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.NumberFormat.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.NumberFormat.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp
index e47cd5edc1..9affae90fe 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp
@@ -13,7 +13,7 @@ namespace JS::Intl {
// 15.5.2 Number Format Functions, https://tc39.es/ecma402/#sec-number-format-functions
NonnullGCPtr<NumberFormatFunction> NumberFormatFunction::create(Realm& realm, NumberFormat& number_format)
{
- return realm.heap().allocate<NumberFormatFunction>(realm, number_format, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<NumberFormatFunction>(realm, number_format, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp
index 9b5ba4ddae..8308f7a4d0 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp
@@ -15,7 +15,7 @@ namespace JS::Intl {
// 15.3 Properties of the Intl.NumberFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-numberformat-prototype-object
NumberFormatPrototype::NumberFormatPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp
index fd99f4bdfe..83452ba49b 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp
@@ -17,7 +17,7 @@ namespace JS::Intl {
// 16.1 The Intl.PluralRules Constructor, https://tc39.es/ecma402/#sec-intl-pluralrules-constructor
PluralRulesConstructor::PluralRulesConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.PluralRules.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.PluralRules.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp
index 08a3b48801..c972374374 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp
@@ -14,7 +14,7 @@ namespace JS::Intl {
// 16.3 Properties of the Intl.PluralRules Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-pluralrules-prototype-object
PluralRulesPrototype::PluralRulesPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp
index 1cd0353d40..6803679d13 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp
@@ -20,7 +20,7 @@ namespace JS::Intl {
// 17.1 The Intl.RelativeTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-relativetimeformat-constructor
RelativeTimeFormatConstructor::RelativeTimeFormatConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.RelativeTimeFormat.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.RelativeTimeFormat.as_string(), realm.intrinsics().function_prototype())
{
}
@@ -140,11 +140,11 @@ ThrowCompletionOr<RelativeTimeFormat*> initialize_relative_time_format(VM& vm, R
relative_time_format.set_numeric(TRY(numeric.as_string().utf8_string_view()));
// 19. Let relativeTimeFormat.[[NumberFormat]] be ! Construct(%NumberFormat%, ยซ locale ยป).
- auto number_format = MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, locale)));
+ auto number_format = MUST(construct(vm, realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, locale)));
relative_time_format.set_number_format(static_cast<NumberFormat*>(number_format.ptr()));
// 20. Let relativeTimeFormat.[[PluralRules]] be ! Construct(%PluralRules%, ยซ locale ยป).
- auto plural_rules = MUST(construct(vm, *realm.intrinsics().intl_plural_rules_constructor(), PrimitiveString::create(vm, locale)));
+ auto plural_rules = MUST(construct(vm, realm.intrinsics().intl_plural_rules_constructor(), PrimitiveString::create(vm, locale)));
relative_time_format.set_plural_rules(static_cast<PluralRules*>(plural_rules.ptr()));
// 21. Return relativeTimeFormat.
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp
index f3727f17d7..bdd562ac10 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp
@@ -12,7 +12,7 @@ namespace JS::Intl {
// 17.3 Properties of the Intl.RelativeTimeFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-relativetimeformat-prototype-object
RelativeTimeFormatPrototype::RelativeTimeFormatPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp
index d8a44e153e..756293f580 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp
@@ -24,7 +24,7 @@ NonnullGCPtr<SegmentIterator> SegmentIterator::create(Realm& realm, Segmenter& s
// 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects
SegmentIterator::SegmentIterator(Realm& realm, Segmenter& segmenter, Utf16View const& string, Segments const& segments)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().intl_segment_iterator_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().intl_segment_iterator_prototype())
, m_iterating_segmenter(segmenter)
, m_iterated_string(string)
, m_segments(segments)
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp
index dd4e957296..c9cc4e81eb 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp
@@ -14,7 +14,7 @@ namespace JS::Intl {
// 18.6.2 The %SegmentIteratorPrototype% Object, https://tc39.es/ecma402/#sec-%segmentiteratorprototype%-object
SegmentIteratorPrototype::SegmentIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().iterator_prototype())
+ : PrototypeObject(realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp
index bc8f15d5b3..8bc8b6c005 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp
@@ -17,7 +17,7 @@ namespace JS::Intl {
// 18.1 The Intl.Segmenter Constructor, https://tc39.es/ecma402/#sec-intl-segmenter-constructor
SegmenterConstructor::SegmenterConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Segmenter.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Segmenter.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp
index c886c0477c..9ec0dcfabe 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp
@@ -13,7 +13,7 @@ namespace JS::Intl {
// 18.3 Properties of the Intl.Segmenter Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-segmenter-prototype-object
SegmenterPrototype::SegmenterPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp
index c34d985d22..e6d1cf9819 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp
@@ -23,7 +23,7 @@ NonnullGCPtr<Segments> Segments::create(Realm& realm, Segmenter& segmenter, Utf1
// 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects
Segments::Segments(Realm& realm, Segmenter& segmenter, Utf16String string)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().intl_segments_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().intl_segments_prototype())
, m_segments_segmenter(segmenter)
, m_segments_string(move(string))
{
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp
index f3a4fe5a61..2115f75d9c 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp
@@ -13,7 +13,7 @@ namespace JS::Intl {
// 18.5.2 The %SegmentsPrototype% Object, https://tc39.es/ecma402/#sec-%segmentsprototype%-object
SegmentsPrototype::SegmentsPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp
index cedda40bb1..93abad707a 100644
--- a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp
@@ -302,18 +302,18 @@ JS_ENUMERATE_TYPED_ARRAYS
initialize_constructor(vm, vm.names.ClassName, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
} \
\
- Namespace::ConstructorName* Intrinsics::snake_namespace##snake_name##_constructor() \
+ NonnullGCPtr<Namespace::ConstructorName> Intrinsics::snake_namespace##snake_name##_constructor() \
{ \
if (!m_##snake_namespace##snake_name##_constructor) \
initialize_##snake_namespace##snake_name(); \
- return m_##snake_namespace##snake_name##_constructor; \
+ return *m_##snake_namespace##snake_name##_constructor; \
} \
\
- Object* Intrinsics::snake_namespace##snake_name##_prototype() \
+ NonnullGCPtr<Object> Intrinsics::snake_namespace##snake_name##_prototype() \
{ \
if (!m_##snake_namespace##snake_name##_prototype) \
initialize_##snake_namespace##snake_name(); \
- return m_##snake_namespace##snake_name##_prototype; \
+ return *m_##snake_namespace##snake_name##_prototype; \
}
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
@@ -334,11 +334,11 @@ JS_ENUMERATE_TEMPORAL_OBJECTS
#undef __JS_ENUMERATE_INNER
#define __JS_ENUMERATE(ClassName, snake_name) \
- ClassName* Intrinsics::snake_name##_object() \
+ NonnullGCPtr<ClassName> Intrinsics::snake_name##_object() \
{ \
if (!m_##snake_name##_object) \
m_##snake_name##_object = heap().allocate<ClassName>(m_realm, m_realm).release_allocated_value_but_fixme_should_propagate_errors(); \
- return m_##snake_name##_object; \
+ return *m_##snake_name##_object; \
}
JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS
#undef __JS_ENUMERATE
@@ -397,10 +397,10 @@ void add_restricted_function_properties(FunctionObject& function, Realm& realm)
auto& vm = realm.vm();
// 1. Assert: realm.[[Intrinsics]].[[%ThrowTypeError%]] exists and has been initialized.
- VERIFY(realm.intrinsics().throw_type_error_function());
+ // NOTE: This is ensured by dereferencing the GCPtr in the getter.
// 2. Let thrower be realm.[[Intrinsics]].[[%ThrowTypeError%]].
- auto* thrower = realm.intrinsics().throw_type_error_function();
+ auto thrower = realm.intrinsics().throw_type_error_function();
// 3. Perform ! DefinePropertyOrThrow(F, "caller", PropertyDescriptor { [[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: true }).
function.define_direct_accessor(vm.names.caller, thrower, thrower, Attribute::Configurable);
diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.h b/Userland/Libraries/LibJS/Runtime/Intrinsics.h
index 56bd2ae558..27402d0fab 100644
--- a/Userland/Libraries/LibJS/Runtime/Intrinsics.h
+++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.h
@@ -17,75 +17,75 @@ class Intrinsics final : public Cell {
public:
static ThrowCompletionOr<NonnullGCPtr<Intrinsics>> create(Realm&);
- Shape* empty_object_shape() { return m_empty_object_shape; }
+ NonnullGCPtr<Shape> empty_object_shape() { return *m_empty_object_shape; }
- Shape* new_object_shape() { return m_new_object_shape; }
- Shape* new_ordinary_function_prototype_object_shape() { return m_new_ordinary_function_prototype_object_shape; }
+ NonnullGCPtr<Shape> new_object_shape() { return *m_new_object_shape; }
+ NonnullGCPtr<Shape> new_ordinary_function_prototype_object_shape() { return *m_new_ordinary_function_prototype_object_shape; }
// Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype
- ProxyConstructor* proxy_constructor() { return m_proxy_constructor; }
+ NonnullGCPtr<ProxyConstructor> proxy_constructor() { return *m_proxy_constructor; }
// Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor
- Object* async_from_sync_iterator_prototype() { return m_async_from_sync_iterator_prototype; }
- Object* async_generator_prototype() { return m_async_generator_prototype; }
- Object* generator_prototype() { return m_generator_prototype; }
+ NonnullGCPtr<Object> async_from_sync_iterator_prototype() { return *m_async_from_sync_iterator_prototype; }
+ NonnullGCPtr<Object> async_generator_prototype() { return *m_async_generator_prototype; }
+ NonnullGCPtr<Object> generator_prototype() { return *m_generator_prototype; }
// Alias for the AsyncGenerator Prototype Object used by the spec (%AsyncGeneratorFunction.prototype.prototype%)
- Object* async_generator_function_prototype_prototype() { return m_async_generator_prototype; }
+ NonnullGCPtr<Object> async_generator_function_prototype_prototype() { return *m_async_generator_prototype; }
// Alias for the Generator Prototype Object used by the spec (%GeneratorFunction.prototype.prototype%)
- Object* generator_function_prototype_prototype() { return m_generator_prototype; }
+ NonnullGCPtr<Object> generator_function_prototype_prototype() { return *m_generator_prototype; }
// Not included in JS_ENUMERATE_INTL_OBJECTS due to missing distinct constructor
- Object* intl_segments_prototype() { return m_intl_segments_prototype; }
+ NonnullGCPtr<Object> intl_segments_prototype() { return *m_intl_segments_prototype; }
// Global object functions
- FunctionObject* eval_function() const { return m_eval_function; }
- FunctionObject* is_finite_function() const { return m_is_finite_function; }
- FunctionObject* is_nan_function() const { return m_is_nan_function; }
- FunctionObject* parse_float_function() const { return m_parse_float_function; }
- FunctionObject* parse_int_function() const { return m_parse_int_function; }
- FunctionObject* decode_uri_function() const { return m_decode_uri_function; }
- FunctionObject* decode_uri_component_function() const { return m_decode_uri_component_function; }
- FunctionObject* encode_uri_function() const { return m_encode_uri_function; }
- FunctionObject* encode_uri_component_function() const { return m_encode_uri_component_function; }
- FunctionObject* escape_function() const { return m_escape_function; }
- FunctionObject* unescape_function() const { return m_unescape_function; }
+ NonnullGCPtr<FunctionObject> eval_function() const { return *m_eval_function; }
+ NonnullGCPtr<FunctionObject> is_finite_function() const { return *m_is_finite_function; }
+ NonnullGCPtr<FunctionObject> is_nan_function() const { return *m_is_nan_function; }
+ NonnullGCPtr<FunctionObject> parse_float_function() const { return *m_parse_float_function; }
+ NonnullGCPtr<FunctionObject> parse_int_function() const { return *m_parse_int_function; }
+ NonnullGCPtr<FunctionObject> decode_uri_function() const { return *m_decode_uri_function; }
+ NonnullGCPtr<FunctionObject> decode_uri_component_function() const { return *m_decode_uri_component_function; }
+ NonnullGCPtr<FunctionObject> encode_uri_function() const { return *m_encode_uri_function; }
+ NonnullGCPtr<FunctionObject> encode_uri_component_function() const { return *m_encode_uri_component_function; }
+ NonnullGCPtr<FunctionObject> escape_function() const { return *m_escape_function; }
+ NonnullGCPtr<FunctionObject> unescape_function() const { return *m_unescape_function; }
// Namespace/constructor object functions
- FunctionObject* array_prototype_values_function() const { return m_array_prototype_values_function; }
- FunctionObject* date_constructor_now_function() const { return m_date_constructor_now_function; }
- FunctionObject* json_parse_function() const { return m_json_parse_function; }
- FunctionObject* json_stringify_function() const { return m_json_stringify_function; }
- FunctionObject* object_prototype_to_string_function() const { return m_object_prototype_to_string_function; }
- FunctionObject* throw_type_error_function() const { return m_throw_type_error_function; }
+ NonnullGCPtr<FunctionObject> array_prototype_values_function() const { return *m_array_prototype_values_function; }
+ NonnullGCPtr<FunctionObject> date_constructor_now_function() const { return *m_date_constructor_now_function; }
+ NonnullGCPtr<FunctionObject> json_parse_function() const { return *m_json_parse_function; }
+ NonnullGCPtr<FunctionObject> json_stringify_function() const { return *m_json_stringify_function; }
+ NonnullGCPtr<FunctionObject> object_prototype_to_string_function() const { return *m_object_prototype_to_string_function; }
+ NonnullGCPtr<FunctionObject> throw_type_error_function() const { return *m_throw_type_error_function; }
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
- ConstructorName* snake_name##_constructor(); \
- Object* snake_name##_prototype();
+ NonnullGCPtr<ConstructorName> snake_name##_constructor(); \
+ NonnullGCPtr<Object> snake_name##_prototype();
JS_ENUMERATE_BUILTIN_TYPES
#undef __JS_ENUMERATE
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- Intl::ConstructorName* intl_##snake_name##_constructor(); \
- Object* intl_##snake_name##_prototype();
+ NonnullGCPtr<Intl::ConstructorName> intl_##snake_name##_constructor(); \
+ NonnullGCPtr<Object> intl_##snake_name##_prototype();
JS_ENUMERATE_INTL_OBJECTS
#undef __JS_ENUMERATE
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- Temporal::ConstructorName* temporal_##snake_name##_constructor(); \
- Object* temporal_##snake_name##_prototype();
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ NonnullGCPtr<Temporal::ConstructorName> temporal_##snake_name##_constructor(); \
+ NonnullGCPtr<Object> temporal_##snake_name##_prototype();
JS_ENUMERATE_TEMPORAL_OBJECTS
#undef __JS_ENUMERATE
#define __JS_ENUMERATE(ClassName, snake_name) \
- ClassName* snake_name##_object();
+ NonnullGCPtr<ClassName> snake_name##_object();
JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS
#undef __JS_ENUMERATE
-#define __JS_ENUMERATE(ClassName, snake_name) \
- Object* snake_name##_prototype() \
- { \
- return m_##snake_name##_prototype; \
+#define __JS_ENUMERATE(ClassName, snake_name) \
+ NonnullGCPtr<Object> snake_name##_prototype() \
+ { \
+ return *m_##snake_name##_prototype; \
}
JS_ENUMERATE_ITERATOR_PROTOTYPES
#undef __JS_ENUMERATE
diff --git a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp
index 16e8ad99e4..53c938f8eb 100644
--- a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp
@@ -12,7 +12,7 @@ namespace JS {
// 27.1.2 The %IteratorPrototype% Object, https://tc39.es/ecma262/#sec-%iteratorprototype%-object
IteratorPrototype::IteratorPrototype(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp
index db57b0deb6..c7bb90a949 100644
--- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp
@@ -27,7 +27,7 @@
namespace JS {
JSONObject::JSONObject(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Map.cpp b/Userland/Libraries/LibJS/Runtime/Map.cpp
index e685db97fa..6bc86460ab 100644
--- a/Userland/Libraries/LibJS/Runtime/Map.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Map.cpp
@@ -10,7 +10,7 @@ namespace JS {
NonnullGCPtr<Map> Map::create(Realm& realm)
{
- return realm.heap().allocate<Map>(realm, *realm.intrinsics().map_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<Map>(realm, realm.intrinsics().map_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
Map::Map(Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp
index fdd8a24e18..126bd34b7f 100644
--- a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
MapConstructor::MapConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Map.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Map.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/MapIterator.cpp b/Userland/Libraries/LibJS/Runtime/MapIterator.cpp
index 425abfd6db..79442203c7 100644
--- a/Userland/Libraries/LibJS/Runtime/MapIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/MapIterator.cpp
@@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<MapIterator> MapIterator::create(Realm& realm, Map& map, Object::PropertyKind iteration_kind)
{
- return realm.heap().allocate<MapIterator>(realm, map, iteration_kind, *realm.intrinsics().map_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<MapIterator>(realm, map, iteration_kind, realm.intrinsics().map_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp
index fa4221d648..47c2aaa73f 100644
--- a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp
@@ -14,7 +14,7 @@
namespace JS {
MapIteratorPrototype::MapIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().iterator_prototype())
+ : PrototypeObject(realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp
index 73cf91d311..e822d3874c 100644
--- a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp
@@ -13,7 +13,7 @@
namespace JS {
MapPrototype::MapPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/MathObject.cpp b/Userland/Libraries/LibJS/Runtime/MathObject.cpp
index e59b85ac36..f02c07e489 100644
--- a/Userland/Libraries/LibJS/Runtime/MathObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/MathObject.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
@@ -16,7 +16,7 @@
namespace JS {
MathObject::MathObject(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp
index 3fd904227a..d9e2392a3a 100644
--- a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp
@@ -11,7 +11,7 @@
namespace JS {
ModuleNamespaceObject::ModuleNamespaceObject(Realm& realm, Module* module, Vector<DeprecatedFlyString> exports)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
, m_module(module)
, m_exports(move(exports))
{
diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp
index c55c12476e..081fb929cc 100644
--- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -53,7 +53,7 @@ NonnullGCPtr<NativeFunction> NativeFunction::create(Realm& allocating_realm, Saf
NonnullGCPtr<NativeFunction> NativeFunction::create(Realm& realm, DeprecatedFlyString const& name, SafeFunction<ThrowCompletionOr<Value>(VM&)> function)
{
- return realm.heap().allocate<NativeFunction>(realm, name, move(function), *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<NativeFunction>(realm, name, move(function), realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
NativeFunction::NativeFunction(SafeFunction<ThrowCompletionOr<Value>(VM&)> native_function, Object* prototype, Realm& realm)
diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp
index c7cb0a906e..d061171e7a 100644
--- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -25,7 +25,7 @@ constexpr double const MIN_SAFE_INTEGER_VALUE { -(__builtin_exp2(53) - 1) };
namespace JS {
NumberConstructor::NumberConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Number.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Number.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/NumberObject.cpp b/Userland/Libraries/LibJS/Runtime/NumberObject.cpp
index 9a17e3c386..343f93f735 100644
--- a/Userland/Libraries/LibJS/Runtime/NumberObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/NumberObject.cpp
@@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<NumberObject> NumberObject::create(Realm& realm, double value)
{
- return realm.heap().allocate<NumberObject>(realm, value, *realm.intrinsics().number_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<NumberObject>(realm, value, realm.intrinsics().number_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
NumberObject::NumberObject(double value, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp
index a2e11abafc..3c18498c24 100644
--- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
@@ -38,7 +38,7 @@ static constexpr AK::Array<char, 36> digits = {
};
NumberPrototype::NumberPrototype(Realm& realm)
- : NumberObject(0, *realm.intrinsics().object_prototype())
+ : NumberObject(0, realm.intrinsics().object_prototype())
{
}
@@ -286,7 +286,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_locale_string)
auto number_value = TRY(this_number_value(vm, vm.this_value()));
// 2. Let numberFormat be ? Construct(%NumberFormat%, ยซ locales, options ยป).
- auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), locales, options)).ptr());
+ auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, realm.intrinsics().intl_number_format_constructor(), locales, options)).ptr());
// 3. Return ? FormatNumeric(numberFormat, x).
auto formatted = TRY(Intl::format_numeric(vm, *number_format, number_value));
diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp
index 7df8a5f435..5414a94fb5 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Object.cpp
@@ -30,9 +30,9 @@ static HashMap<GCPtr<Object const>, HashMap<DeprecatedFlyString, Object::Intrins
NonnullGCPtr<Object> Object::create(Realm& realm, Object* prototype)
{
if (!prototype)
- return realm.heap().allocate<Object>(realm, *realm.intrinsics().empty_object_shape()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<Object>(realm, realm.intrinsics().empty_object_shape()).release_allocated_value_but_fixme_should_propagate_errors();
if (prototype == realm.intrinsics().object_prototype())
- return realm.heap().allocate<Object>(realm, *realm.intrinsics().new_object_shape()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<Object>(realm, realm.intrinsics().new_object_shape()).release_allocated_value_but_fixme_should_propagate_errors();
return realm.heap().allocate<Object>(realm, ConstructWithPrototypeTag::Tag, *prototype).release_allocated_value_but_fixme_should_propagate_errors();
}
diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
index e88f7427a9..cf81559b06 100644
--- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -18,7 +18,7 @@
namespace JS {
ObjectConstructor::ObjectConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Object.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Object.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Promise.cpp b/Userland/Libraries/LibJS/Runtime/Promise.cpp
index cd76df1c7c..1cdf32ccfd 100644
--- a/Userland/Libraries/LibJS/Runtime/Promise.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Promise.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -44,7 +44,7 @@ ThrowCompletionOr<Object*> promise_resolve(VM& vm, Object& constructor, Value va
NonnullGCPtr<Promise> Promise::create(Realm& realm)
{
- return realm.heap().allocate<Promise>(realm, *realm.intrinsics().promise_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<Promise>(realm, realm.intrinsics().promise_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
// 27.2 Promise Objects, https://tc39.es/ecma262/#sec-promise-objects
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp
index 36fc7c23be..d339cfc700 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -240,7 +240,7 @@ static ThrowCompletionOr<Value> perform_promise_race(VM& vm, Iterator& iterator_
}
PromiseConstructor::PromiseConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Promise.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Promise.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp
index 5bcad40fb4..e73e5d182e 100644
--- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -17,7 +17,7 @@
namespace JS {
PromisePrototype::PromisePrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
@@ -50,7 +50,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::then)
auto promise = TRY(typed_this_object(vm));
// 3. Let C be ? SpeciesConstructor(promise, %Promise%).
- auto* constructor = TRY(species_constructor(vm, *promise, *realm.intrinsics().promise_constructor()));
+ auto* constructor = TRY(species_constructor(vm, *promise, realm.intrinsics().promise_constructor()));
// 4. Let resultCapability be ? NewPromiseCapability(C).
auto result_capability = TRY(new_promise_capability(vm, constructor));
@@ -86,7 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, promise.to_string_without_side_effects()));
// 3. Let C be ? SpeciesConstructor(promise, %Promise%).
- auto* constructor = TRY(species_constructor(vm, promise.as_object(), *realm.intrinsics().promise_constructor()));
+ auto* constructor = TRY(species_constructor(vm, promise.as_object(), realm.intrinsics().promise_constructor()));
// 4. Assert: IsConstructor(C) is true.
VERIFY(constructor);
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp
index d1eab26f23..54a7268daa 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp
@@ -57,7 +57,7 @@ void PromiseResolvingElementFunction::visit_edges(Cell::Visitor& visitor)
NonnullGCPtr<PromiseAllResolveElementFunction> PromiseAllResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements)
{
- return realm.heap().allocate<PromiseAllResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<PromiseAllResolveElementFunction>(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements, Object& prototype)
@@ -89,7 +89,7 @@ ThrowCompletionOr<Value> PromiseAllResolveElementFunction::resolve_element()
NonnullGCPtr<PromiseAllSettledResolveElementFunction> PromiseAllSettledResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements)
{
- return realm.heap().allocate<PromiseAllSettledResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<PromiseAllSettledResolveElementFunction>(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements, Object& prototype)
@@ -130,7 +130,7 @@ ThrowCompletionOr<Value> PromiseAllSettledResolveElementFunction::resolve_elemen
NonnullGCPtr<PromiseAllSettledRejectElementFunction> PromiseAllSettledRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements)
{
- return realm.heap().allocate<PromiseAllSettledRejectElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<PromiseAllSettledRejectElementFunction>(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements, Object& prototype)
@@ -171,7 +171,7 @@ ThrowCompletionOr<Value> PromiseAllSettledRejectElementFunction::resolve_element
NonnullGCPtr<PromiseAnyRejectElementFunction> PromiseAnyRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& errors, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements)
{
- return realm.heap().allocate<PromiseAnyRejectElementFunction>(realm, index, errors, capability, remaining_elements, *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<PromiseAnyRejectElementFunction>(realm, index, errors, capability, remaining_elements, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
PromiseAnyRejectElementFunction::PromiseAnyRejectElementFunction(size_t index, PromiseValueList& errors, NonnullGCPtr<PromiseCapability const> capability, RemainingElements& remaining_elements, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp
index e1475514fd..5194613230 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -13,7 +13,7 @@ namespace JS {
NonnullGCPtr<PromiseResolvingFunction> PromiseResolvingFunction::create(Realm& realm, Promise& promise, AlreadyResolved& already_resolved, FunctionType function)
{
- return realm.heap().allocate<PromiseResolvingFunction>(realm, promise, already_resolved, move(function), *realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<PromiseResolvingFunction>(realm, promise, already_resolved, move(function), realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyResolved& already_resolved, FunctionType native_function, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp
index 0bc52ed790..adee9ac550 100644
--- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -25,7 +25,7 @@ static ThrowCompletionOr<ProxyObject*> proxy_create(VM& vm, Value target, Value
}
ProxyConstructor::ProxyConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Proxy.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Proxy.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
index 721d6a7859..215f06bd3c 100644
--- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -17,7 +17,7 @@ namespace JS {
NonnullGCPtr<ProxyObject> ProxyObject::create(Realm& realm, Object& target, Object& handler)
{
- return realm.heap().allocate<ProxyObject>(realm, target, handler, *realm.intrinsics().object_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<ProxyObject>(realm, target, handler, realm.intrinsics().object_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/Reference.cpp b/Userland/Libraries/LibJS/Runtime/Reference.cpp
index 87ac05f672..358f9e6226 100644
--- a/Userland/Libraries/LibJS/Runtime/Reference.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Reference.cpp
@@ -112,7 +112,7 @@ ThrowCompletionOr<Value> Reference::get_value(VM& vm) const
}
// OPTIMIZATION: For various primitives we can avoid actually creating a new object for them.
- Object* base_obj = nullptr;
+ GCPtr<Object> base_obj;
if (m_base_value.is_string()) {
auto string_value = TRY(m_base_value.as_string().get(vm, m_name));
if (string_value.has_value())
diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
index 12abd35fc0..f3ba6ed5ab 100644
--- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -16,7 +16,7 @@
namespace JS {
ReflectObject::ReflectObject(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp
index 877df6fc58..9930f6d6fa 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp
@@ -13,7 +13,7 @@
namespace JS {
RegExpConstructor::RegExpConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.RegExp.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.RegExp.as_string(), realm.intrinsics().function_prototype())
{
}
@@ -152,11 +152,11 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::symbol_species_getter)
// get RegExp.input, https://github.com/tc39/proposal-regexp-legacy-features#get-regexpinput
JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::input_getter)
{
- auto* regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
+ auto regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
// 1. Return ? GetLegacyRegExpStaticProperty(%RegExp%, this value, [[RegExpInput]]).
auto property_getter = &RegExpLegacyStaticProperties::input;
- return TRY(get_legacy_regexp_static_property(vm, *regexp_constructor, vm.this_value(), property_getter));
+ return TRY(get_legacy_regexp_static_property(vm, regexp_constructor, vm.this_value(), property_getter));
}
// get RegExp.$_, https://github.com/tc39/proposal-regexp-legacy-features#get-regexp_
@@ -169,11 +169,11 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::input_alias_getter)
// set RegExp.input, https://github.com/tc39/proposal-regexp-legacy-features#set-regexpinput--val
JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::input_setter)
{
- auto* regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
+ auto regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
// 1. Perform ? SetLegacyRegExpStaticProperty(%RegExp%, this value, [[RegExpInput]], val).
auto property_setter = &RegExpLegacyStaticProperties::set_input;
- TRY(set_legacy_regexp_static_property(vm, *regexp_constructor, vm.this_value(), property_setter, vm.argument(0)));
+ TRY(set_legacy_regexp_static_property(vm, regexp_constructor, vm.this_value(), property_setter, vm.argument(0)));
return js_undefined();
}
@@ -187,11 +187,11 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::input_alias_setter)
// get RegExp.lastMatch, https://github.com/tc39/proposal-regexp-legacy-features#get-regexplastmatch
JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::last_match_getter)
{
- auto* regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
+ auto regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
// 1. Return ? GetLegacyRegExpStaticProperty(%RegExp%, this value, [[RegExpLastMatch]]).
auto property_getter = &RegExpLegacyStaticProperties::last_match;
- return TRY(get_legacy_regexp_static_property(vm, *regexp_constructor, vm.this_value(), property_getter));
+ return TRY(get_legacy_regexp_static_property(vm, regexp_constructor, vm.this_value(), property_getter));
}
// get RegExp.$&, https://github.com/tc39/proposal-regexp-legacy-features#get-regexp
@@ -204,11 +204,11 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::last_match_alias_getter)
// get RegExp.lastParen, https://github.com/tc39/proposal-regexp-legacy-features#get-regexplastparen
JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::last_paren_getter)
{
- auto* regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
+ auto regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
// 1. Return ? GetLegacyRegExpStaticProperty(%RegExp%, this value, [[RegExpLastParen]]).
auto property_getter = &RegExpLegacyStaticProperties::last_paren;
- return TRY(get_legacy_regexp_static_property(vm, *regexp_constructor, vm.this_value(), property_getter));
+ return TRY(get_legacy_regexp_static_property(vm, regexp_constructor, vm.this_value(), property_getter));
}
// get RegExp.$+, https://github.com/tc39/proposal-regexp-legacy-features#get-regexp-1
@@ -221,11 +221,11 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::last_paren_alias_getter)
// get RegExp.leftContext, https://github.com/tc39/proposal-regexp-legacy-features#get-regexpleftcontext
JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::left_context_getter)
{
- auto* regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
+ auto regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
// 1. Return ? GetLegacyRegExpStaticProperty(%RegExp%, this value, [[RegExpLeftContext]]).
auto property_getter = &RegExpLegacyStaticProperties::left_context;
- return TRY(get_legacy_regexp_static_property(vm, *regexp_constructor, vm.this_value(), property_getter));
+ return TRY(get_legacy_regexp_static_property(vm, regexp_constructor, vm.this_value(), property_getter));
}
// get RegExp.$`, https://github.com/tc39/proposal-regexp-legacy-features#get-regexp-2
@@ -238,11 +238,11 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::left_context_alias_getter)
// get RegExp.rightContext, https://github.com/tc39/proposal-regexp-legacy-features#get-regexprightcontext
JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::right_context_getter)
{
- auto* regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
+ auto regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor();
// 1. Return ? GetLegacyRegExpStaticProperty(%RegExp%, this value, [[RegExpRightContext]]).
auto property_getter = &RegExpLegacyStaticProperties::right_context;
- return TRY(get_legacy_regexp_static_property(vm, *regexp_constructor, vm.this_value(), property_getter));
+ return TRY(get_legacy_regexp_static_property(vm, regexp_constructor, vm.this_value(), property_getter));
}
// get RegExp.$', https://github.com/tc39/proposal-regexp-legacy-features#get-regexp-3
@@ -252,14 +252,14 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::right_context_alias_getter)
return right_context_getter(vm);
}
-#define DEFINE_REGEXP_GROUP_GETTER(n) \
- JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::group_##n##_getter) \
- { \
- auto* regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor(); \
- \
- /* 1. Return ? GetLegacyRegExpStaticProperty(%RegExp%, this value, [[RegExpParen##n##]]).*/ \
- auto property_getter = &RegExpLegacyStaticProperties::$##n; \
- return TRY(get_legacy_regexp_static_property(vm, *regexp_constructor, vm.this_value(), property_getter)); \
+#define DEFINE_REGEXP_GROUP_GETTER(n) \
+ JS_DEFINE_NATIVE_FUNCTION(RegExpConstructor::group_##n##_getter) \
+ { \
+ auto regexp_constructor = vm.current_realm()->intrinsics().regexp_constructor(); \
+ \
+ /* 1. Return ? GetLegacyRegExpStaticProperty(%RegExp%, this value, [[RegExpParen##n##]]).*/ \
+ auto property_getter = &RegExpLegacyStaticProperties::$##n; \
+ return TRY(get_legacy_regexp_static_property(vm, regexp_constructor, vm.this_value(), property_getter)); \
}
// get RegExp.$1, https://github.com/tc39/proposal-regexp-legacy-features#get-regexp1
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp
index 955e18e879..4a37d5c99a 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp
@@ -130,12 +130,12 @@ ThrowCompletionOr<DeprecatedString> parse_regex_pattern(VM& vm, StringView patte
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm)
{
- return realm.heap().allocate<RegExpObject>(realm, *realm.intrinsics().regexp_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<RegExpObject>(realm, realm.intrinsics().regexp_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags)
{
- return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), realm.intrinsics().regexp_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
RegExpObject::RegExpObject(Object& prototype)
@@ -297,7 +297,7 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> regexp_create(VM& vm, Value patter
auto& realm = *vm.current_realm();
// 1. Let obj be ! RegExpAlloc(%RegExp%).
- auto regexp_object = MUST(regexp_alloc(vm, *realm.intrinsics().regexp_constructor()));
+ auto regexp_object = MUST(regexp_alloc(vm, realm.intrinsics().regexp_constructor()));
// 2. Return ? RegExpInitialize(obj, P, F).
return TRY(regexp_object->regexp_initialize(vm, pattern, flags));
@@ -317,8 +317,7 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> regexp_alloc(VM& vm, FunctionObjec
regexp_object->set_realm(this_realm);
// 4. If SameValue(newTarget, thisRealm.[[Intrinsics]].[[%RegExp%]]) is true, then
- auto* regexp_constructor = this_realm.intrinsics().regexp_constructor();
- if (same_value(&new_target, regexp_constructor)) {
+ if (same_value(&new_target, this_realm.intrinsics().regexp_constructor())) {
// i. Set the value of objโ€™s [[LegacyFeaturesEnabled]] internal slot to true.
regexp_object->set_legacy_features_enabled(true);
}
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
index 3730f3fb2b..f07b68cc44 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
@@ -23,7 +23,7 @@
namespace JS {
RegExpPrototype::RegExpPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
@@ -352,14 +352,12 @@ static ThrowCompletionOr<Value> regexp_builtin_exec(VM& vm, RegExpObject& regexp
// i. If the value of Rโ€™s [[LegacyFeaturesEnabled]] internal slot is true, then
if (regexp_object.legacy_features_enabled()) {
// a. Perform UpdateLegacyRegExpStaticProperties(%RegExp%, S, lastIndex, e, capturedValues).
- auto* regexp_constructor = realm.intrinsics().regexp_constructor();
- TRY(update_legacy_regexp_static_properties(vm, *regexp_constructor, string, match_indices.start_index, match_indices.end_index, captured_values));
+ TRY(update_legacy_regexp_static_properties(vm, realm.intrinsics().regexp_constructor(), string, match_indices.start_index, match_indices.end_index, captured_values));
}
// ii. Else,
else {
// a. Perform InvalidateLegacyRegExpStaticProperties(%RegExp%).
- auto* regexp_constructor = realm.intrinsics().regexp_constructor();
- invalidate_legacy_regexp_static_properties(*regexp_constructor);
+ invalidate_legacy_regexp_static_properties(realm.intrinsics().regexp_constructor());
}
}
@@ -605,7 +603,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match_all)
auto string = TRY(vm.argument(0).to_utf16_string(vm));
// 4. Let C be ? SpeciesConstructor(R, %RegExp%).
- auto* constructor = TRY(species_constructor(vm, *regexp_object, *realm.intrinsics().regexp_constructor()));
+ auto* constructor = TRY(species_constructor(vm, *regexp_object, realm.intrinsics().regexp_constructor()));
// 5. Let flags be ? ToString(? Get(R, "flags")).
auto flags_value = TRY(regexp_object->get(vm.names.flags));
@@ -910,7 +908,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split)
auto string = TRY(vm.argument(0).to_utf16_string(vm));
// 4. Let C be ? SpeciesConstructor(rx, %RegExp%).
- auto* constructor = TRY(species_constructor(vm, *regexp_object, *realm.intrinsics().regexp_constructor()));
+ auto* constructor = TRY(species_constructor(vm, *regexp_object, realm.intrinsics().regexp_constructor()));
// 5. Let flags be ? ToString(? Get(rx, "flags")).
auto flags_value = TRY(regexp_object->get(vm.names.flags));
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp
index 045ed51545..0929b4ec14 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp
@@ -12,7 +12,7 @@ namespace JS {
// 22.2.7.1 CreateRegExpStringIterator ( R, S, global, fullUnicode ), https://tc39.es/ecma262/#sec-createregexpstringiterator
NonnullGCPtr<RegExpStringIterator> RegExpStringIterator::create(Realm& realm, Object& regexp_object, Utf16String string, bool global, bool unicode)
{
- return realm.heap().allocate<RegExpStringIterator>(realm, *realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<RegExpStringIterator>(realm, realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode).release_allocated_value_but_fixme_should_propagate_errors();
}
RegExpStringIterator::RegExpStringIterator(Object& prototype, Object& regexp_object, Utf16String string, bool global, bool unicode)
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp
index b1e7a259d0..c415716eb0 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp
@@ -13,7 +13,7 @@
namespace JS {
RegExpStringIteratorPrototype::RegExpStringIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().iterator_prototype())
+ : PrototypeObject(realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Set.cpp b/Userland/Libraries/LibJS/Runtime/Set.cpp
index 40c951415e..3defd113eb 100644
--- a/Userland/Libraries/LibJS/Runtime/Set.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Set.cpp
@@ -10,7 +10,7 @@ namespace JS {
NonnullGCPtr<Set> Set::create(Realm& realm)
{
- return realm.heap().allocate<Set>(realm, *realm.intrinsics().set_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<Set>(realm, realm.intrinsics().set_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
Set::Set(Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp
index dc5be635a2..60a2775540 100644
--- a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
SetConstructor::SetConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Set.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Set.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/SetIterator.cpp b/Userland/Libraries/LibJS/Runtime/SetIterator.cpp
index 71f6d1d2ef..120c98a332 100644
--- a/Userland/Libraries/LibJS/Runtime/SetIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SetIterator.cpp
@@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<SetIterator> SetIterator::create(Realm& realm, Set& set, Object::PropertyKind iteration_kind)
{
- return realm.heap().allocate<SetIterator>(realm, set, iteration_kind, *realm.intrinsics().set_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<SetIterator>(realm, set, iteration_kind, realm.intrinsics().set_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
SetIterator::SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp
index 4fa0281dbd..c93538009a 100644
--- a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp
@@ -14,7 +14,7 @@
namespace JS {
SetIteratorPrototype::SetIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().iterator_prototype())
+ : PrototypeObject(realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp
index 5e4db71c63..fcc8370b5f 100644
--- a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp
@@ -15,7 +15,7 @@
namespace JS {
SetPrototype::SetPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp
index bfd28289c2..49d9c6e591 100644
--- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -12,7 +12,7 @@ namespace JS {
// 3.2 The ShadowRealm Constructor, https://tc39.es/proposal-shadowrealm/#sec-shadowrealm-constructor
ShadowRealmConstructor::ShadowRealmConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.ShadowRealm.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.ShadowRealm.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp
index 534e41f57f..fcfc7aee95 100644
--- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -12,7 +12,7 @@ namespace JS {
// 3.4 Properties of the ShadowRealm Prototype Object, https://tc39.es/proposal-shadowrealm/#sec-properties-of-the-shadowrealm-prototype-object
ShadowRealmPrototype::ShadowRealmPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
index 5b97fe46c5..4c1ccdc1ae 100644
--- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
@@ -18,7 +18,7 @@
namespace JS {
StringConstructor::StringConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.String.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.String.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp
index 532c57bb85..e559728648 100644
--- a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp
@@ -12,7 +12,7 @@ namespace JS {
NonnullGCPtr<StringIterator> StringIterator::create(Realm& realm, String string)
{
- return realm.heap().allocate<StringIterator>(realm, move(string), *realm.intrinsics().string_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<StringIterator>(realm, move(string), realm.intrinsics().string_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
StringIterator::StringIterator(String string, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp
index 9e83dc6255..66d6a9cc67 100644
--- a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp
@@ -14,7 +14,7 @@
namespace JS {
StringIteratorPrototype::StringIteratorPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().iterator_prototype())
+ : PrototypeObject(realm.intrinsics().iterator_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp
index 2d1ac1fb8a..301cd0a0d7 100644
--- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -149,7 +149,7 @@ CodePoint code_point_at(Utf16View const& string, size_t position)
}
StringPrototype::StringPrototype(Realm& realm)
- : StringObject(*PrimitiveString::create(realm.vm(), String {}), *realm.intrinsics().object_prototype())
+ : StringObject(*PrimitiveString::create(realm.vm(), String {}), realm.intrinsics().object_prototype())
{
}
@@ -452,7 +452,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::locale_compare)
auto that_value = TRY(vm.argument(0).to_string(vm));
// 4. Let collator be ? Construct(%Collator%, ยซ locales, options ยป).
- auto collator = TRY(construct(vm, *realm.intrinsics().intl_collator_constructor(), vm.argument(1), vm.argument(2)));
+ auto collator = TRY(construct(vm, realm.intrinsics().intl_collator_constructor(), vm.argument(1), vm.argument(2)));
// 5. Return CompareStrings(collator, S, thatValue).
return Intl::compare_strings(static_cast<Intl::Collator&>(*collator), string.code_points(), that_value.code_points());
diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp b/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp
index a7edd888a9..b98ce1a46f 100644
--- a/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp
@@ -12,7 +12,7 @@ namespace JS {
NonnullGCPtr<SuppressedError> SuppressedError::create(Realm& realm)
{
- return *realm.heap().allocate<SuppressedError>(realm, *realm.intrinsics().suppressed_error_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<SuppressedError>(realm, realm.intrinsics().suppressed_error_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
SuppressedError::SuppressedError(Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.cpp
index 8269b9cfb5..ac199d7fc6 100644
--- a/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.cpp
@@ -15,7 +15,7 @@
namespace JS {
SuppressedErrorConstructor::SuppressedErrorConstructor(Realm& realm)
- : NativeFunction(static_cast<Object&>(*realm.intrinsics().error_constructor()))
+ : NativeFunction(static_cast<Object&>(realm.intrinsics().error_constructor()))
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp
index 2a1f1b87df..2dce2448b5 100644
--- a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp
@@ -11,7 +11,7 @@
namespace JS {
SuppressedErrorPrototype::SuppressedErrorPrototype(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().error_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().error_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp
index dec3bf65fe..f9fc5c241b 100644
--- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp
@@ -12,7 +12,7 @@
namespace JS {
SymbolConstructor::SymbolConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Symbol.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Symbol.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp b/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp
index 795920f884..37b4f506b2 100644
--- a/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp
@@ -12,7 +12,7 @@ namespace JS {
NonnullGCPtr<SymbolObject> SymbolObject::create(Realm& realm, Symbol& primitive_symbol)
{
- return realm.heap().allocate<SymbolObject>(realm, primitive_symbol, *realm.intrinsics().symbol_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<SymbolObject>(realm, primitive_symbol, realm.intrinsics().symbol_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
SymbolObject::SymbolObject(Symbol& symbol, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp
index 1bcdbbab2a..6ec92b05a7 100644
--- a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp
@@ -19,7 +19,7 @@
namespace JS {
SymbolPrototype::SymbolPrototype(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp
index 18f0f7cb7f..87b7d0db03 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp
@@ -12,7 +12,7 @@ namespace JS::Temporal {
// 12.2 The Temporal.Calendar Constructor, https://tc39.es/proposal-temporal/#sec-temporal-calendar-constructor
CalendarConstructor::CalendarConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Calendar.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Calendar.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp
index 14d40369ea..6cf6a0448b 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp
@@ -25,7 +25,7 @@ namespace JS::Temporal {
// 12.4 Properties of the Temporal.Calendar Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-calendar-prototype-object
CalendarPrototype::CalendarPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp
index 8896f7ed69..488d6bb199 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp
@@ -15,7 +15,7 @@ namespace JS::Temporal {
// 7.1 The Temporal.Duration Constructor, https://tc39.es/proposal-temporal/#sec-temporal-duration-constructor
DurationConstructor::DurationConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Duration.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Duration.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp
index ef46f95f2e..2c3b5a71d9 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp
@@ -16,7 +16,7 @@ namespace JS::Temporal {
// 7.3 Properties of the Temporal.Duration Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-duration-prototype-object
DurationPrototype::DurationPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp
index a886a9d812..eda4be9c07 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -14,7 +14,7 @@ namespace JS::Temporal {
// 8.1 The Temporal.Instant Constructor, https://tc39.es/proposal-temporal/#sec-temporal-instant-constructor
InstantConstructor::InstantConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.Instant.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.Instant.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp
index 8b832b5722..ca33a0bb00 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp
@@ -20,7 +20,7 @@ namespace JS::Temporal {
// 8.3 Properties of the Temporal.Instant Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-instant-prototype-object
InstantPrototype::InstantPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp
index 17c9716ceb..009900f92c 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp
@@ -22,7 +22,7 @@ namespace JS::Temporal {
// 2 The Temporal.Now Object, https://tc39.es/proposal-temporal/#sec-temporal-now-object
Now::Now(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp
index 85e3f9f4be..72c194428f 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp
@@ -16,7 +16,7 @@ namespace JS::Temporal {
// 3.1 The Temporal.PlainDate Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plaindate-constructor
PlainDateConstructor::PlainDateConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.PlainDate.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.PlainDate.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp
index b8893fb0f8..7a8950f77c 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -21,7 +21,7 @@ namespace JS::Temporal {
// 3.3 Properties of the Temporal.PlainDate Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plaindate-prototype-object
PlainDatePrototype::PlainDatePrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp
index 0bb6b9340a..d69469f79d 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -16,7 +16,7 @@ namespace JS::Temporal {
// 5.1 The Temporal.PlainDateTime Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plaindatetime-constructor
PlainDateTimeConstructor::PlainDateTimeConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.PlainDateTime.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.PlainDateTime.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp
index a8c98de8e1..50d4b5b335 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp
@@ -22,7 +22,7 @@ namespace JS::Temporal {
// 5.3 Properties of the Temporal.PlainDateTime Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plaindatetime-prototype-object
PlainDateTimePrototype::PlainDateTimePrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp
index 169ca0ee36..c90829a4d1 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -15,7 +15,7 @@ namespace JS::Temporal {
// 10.1 The Temporal.PlainMonthDay Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plainmonthday-constructor
PlainMonthDayConstructor::PlainMonthDayConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.PlainMonthDay.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.PlainMonthDay.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp
index 1ee78ff6cb..19f0232b06 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -16,7 +16,7 @@ namespace JS::Temporal {
// 10.3 Properties of the Temporal.PlainMonthDay Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plainmonthday-prototype-object
PlainMonthDayPrototype::PlainMonthDayPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp
index 162d0e7f08..1921237045 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -14,7 +14,7 @@ namespace JS::Temporal {
// 4.1 The Temporal.PlainTime Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plaintime-constructor
PlainTimeConstructor::PlainTimeConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.PlainTime.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.PlainTime.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp
index accac0d30b..7244cee2b2 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp
@@ -21,7 +21,7 @@ namespace JS::Temporal {
// 4.3 Properties of the Temporal.PlainTime Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plaintime-prototype-object
PlainTimePrototype::PlainTimePrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp
index 33bf3dadc1..f92f77f20b 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
@@ -16,7 +16,7 @@ namespace JS::Temporal {
// 9.1 The Temporal.PlainYearMonth Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plainyearmonth-constructor
PlainYearMonthConstructor::PlainYearMonthConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.PlainYearMonth.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.PlainYearMonth.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp
index 493fd77b3e..5c74bcb522 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -18,7 +18,7 @@ namespace JS::Temporal {
// 9.3 Properties of the Temporal.PlainYearMonth Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plainyearmonth-prototype-object
PlainYearMonthPrototype::PlainYearMonthPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp
index 8e817bf4e5..d37ee63b0a 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -22,7 +22,7 @@ namespace JS::Temporal {
// 1 The Temporal Object, https://tc39.es/proposal-temporal/#sec-temporal-objects
Temporal::Temporal(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp
index 10c4656d02..4e77f9706a 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp
@@ -13,7 +13,7 @@ namespace JS::Temporal {
// 11.2 The Temporal.TimeZone Constructor, https://tc39.es/proposal-temporal/#sec-temporal-timezone-constructor
TimeZoneConstructor::TimeZoneConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.TimeZone.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.TimeZone.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp
index b06663fa58..99695bef0c 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp
@@ -19,7 +19,7 @@ namespace JS::Temporal {
// 11.4 Properties of the Temporal.TimeZone Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-timezone-prototype-object
TimeZonePrototype::TimeZonePrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp
index 6ec6dbaeac..f03dfd453e 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp
@@ -17,7 +17,7 @@ namespace JS::Temporal {
// 6.1 The Temporal.ZonedDateTime Constructor, https://tc39.es/proposal-temporal/#sec-temporal-zoneddatetime-constructor
ZonedDateTimeConstructor::ZonedDateTimeConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.ZonedDateTime.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.ZonedDateTime.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp
index e7c47fbff6..fe6eebd261 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp
@@ -22,7 +22,7 @@ namespace JS::Temporal {
// 6.3 Properties of the Temporal.ZonedDateTime Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-zoneddatetime-prototype-object
ZonedDateTimePrototype::ZonedDateTimePrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
index 26bee682f1..1f40d37961 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -169,7 +169,7 @@ static ThrowCompletionOr<void> initialize_typed_array_from_typed_array(VM& vm, T
// 11. Else,
else {
// a. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength).
- data = TRY(allocate_array_buffer(vm, *realm.intrinsics().array_buffer_constructor(), byte_length.value()));
+ data = TRY(allocate_array_buffer(vm, realm.intrinsics().array_buffer_constructor(), byte_length.value()));
// b. If IsDetachedBuffer(srcData) is true, throw a TypeError exception.
if (src_data->is_detached())
@@ -241,7 +241,7 @@ static ThrowCompletionOr<void> allocate_typed_array_buffer(VM& vm, TypedArray<T>
auto byte_length = element_size * length;
// 4. Let data be ? AllocateArrayBuffer(%ArrayBuffer%, byteLength).
- auto* data = TRY(allocate_array_buffer(vm, *realm.intrinsics().array_buffer_constructor(), byte_length));
+ auto* data = TRY(allocate_array_buffer(vm, realm.intrinsics().array_buffer_constructor(), byte_length));
// 5. Set O.[[ViewedArrayBuffer]] to data.
typed_array.set_viewed_array_buffer(data);
@@ -346,10 +346,10 @@ ThrowCompletionOr<TypedArrayBase*> typed_array_create_same_type(VM& vm, TypedArr
auto& realm = *vm.current_realm();
// 1. Let constructor be the intrinsic object associated with the constructor name exemplar.[[TypedArrayName]] in Table 68.
- auto* constructor = (realm.intrinsics().*exemplar.intrinsic_constructor())();
+ auto constructor = (realm.intrinsics().*exemplar.intrinsic_constructor())();
// 2. Let result be ? TypedArrayCreate(constructor, argumentList).
- auto* result = TRY(typed_array_create(vm, *constructor, move(arguments)));
+ auto* result = TRY(typed_array_create(vm, constructor, move(arguments)));
// 3. Assert: result has [[TypedArrayName]] and [[ContentType]] internal slots.
// 4. Assert: result.[[ContentType]] is exemplar.[[ContentType]].
@@ -419,141 +419,141 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
visitor.visit(m_viewed_array_buffer);
}
-#define JS_DEFINE_TYPED_ARRAY(ClassName, snake_name, PrototypeName, ConstructorName, Type) \
- ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length, FunctionObject& new_target) \
- { \
- auto* prototype = TRY(get_prototype_from_constructor(realm.vm(), new_target, &Intrinsics::snake_name##_prototype)); \
- auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
- return MUST_OR_THROW_OOM(realm.heap().allocate<ClassName>(realm, *prototype, length, *array_buffer)); \
- } \
- \
- ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length) \
- { \
- auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
- return create(realm, length, *array_buffer); \
- } \
- \
- NonnullGCPtr<ClassName> ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \
- { \
- return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype(), length, array_buffer).release_allocated_value_but_fixme_should_propagate_errors(); \
- } \
- \
- ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \
- : TypedArray(prototype, \
- reinterpret_cast<TypedArrayBase::IntrinsicConstructor>(&Intrinsics::snake_name##_constructor), length, array_buffer) \
- { \
- if constexpr (#ClassName##sv.is_one_of("BigInt64Array", "BigUint64Array")) \
- m_content_type = ContentType::BigInt; \
- else \
- m_content_type = ContentType::Number; \
- } \
- \
- ClassName::~ClassName() \
- { \
- } \
- \
- DeprecatedFlyString const& ClassName::element_name() const \
- { \
- return vm().names.ClassName.as_string(); \
- } \
- \
- PrototypeName::PrototypeName(Object& prototype) \
- : Object(ConstructWithPrototypeTag::Tag, prototype) \
- { \
- } \
- \
- PrototypeName::~PrototypeName() \
- { \
- } \
- \
- ThrowCompletionOr<void> PrototypeName::initialize(Realm& realm) \
- { \
- auto& vm = this->vm(); \
- MUST_OR_THROW_OOM(Base::initialize(realm)); \
- define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
- \
- return {}; \
- } \
- \
- ConstructorName::ConstructorName(Realm& realm, Object& prototype) \
- : TypedArrayConstructor(realm.vm().names.ClassName.as_string(), prototype) \
- { \
- } \
- \
- ConstructorName::~ConstructorName() \
- { \
- } \
- \
- ThrowCompletionOr<void> ConstructorName::initialize(Realm& realm) \
- { \
- auto& vm = this->vm(); \
- MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); \
- \
- /* 23.2.6.2 TypedArray.prototype, https://tc39.es/ecma262/#sec-typedarray.prototype */ \
- define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \
- \
- /* 23.2.6.1 TypedArray.BYTES_PER_ELEMENT, https://tc39.es/ecma262/#sec-typedarray.bytes_per_element */ \
- define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
- \
- define_direct_property(vm.names.length, Value(3), Attribute::Configurable); \
- \
- return {}; \
- } \
- \
- /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
- ThrowCompletionOr<Value> ConstructorName::call() \
- { \
- auto& vm = this->vm(); \
- return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \
- } \
- \
- /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
- 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)); \
- \
- auto first_argument = vm.argument(0); \
- if (first_argument.is_object()) { \
- auto typed_array = TRY(ClassName::create(realm, 0, new_target)); \
- if (first_argument.as_object().is_typed_array()) { \
- auto& arg_typed_array = static_cast<TypedArrayBase&>(first_argument.as_object()); \
- TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \
- } else if (is<ArrayBuffer>(first_argument.as_object())) { \
- auto& array_buffer = static_cast<ArrayBuffer&>(first_argument.as_object()); \
- TRY(initialize_typed_array_from_array_buffer(vm, *typed_array, array_buffer, \
- vm.argument(1), vm.argument(2))); \
- } else { \
- auto iterator = TRY(first_argument.get_method(vm, *vm.well_known_symbol_iterator())); \
- if (iterator) { \
- auto values = TRY(iterable_to_list(vm, first_argument, iterator)); \
- TRY(initialize_typed_array_from_list(vm, *typed_array, values)); \
- } else { \
- TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \
- } \
- } \
- return typed_array; \
- } \
- \
- auto array_length_or_error = first_argument.to_index(vm); \
- if (array_length_or_error.is_error()) { \
- auto error = array_length_or_error.release_error(); \
- if (error.value()->is_object() && is<RangeError>(error.value()->as_object())) { \
- /* Re-throw more specific RangeError */ \
- return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
- } \
- return error; \
- } \
- auto array_length = array_length_or_error.release_value(); \
- if (array_length > NumericLimits<i32>::max() / sizeof(Type)) \
- return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
- /* 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)); \
+#define JS_DEFINE_TYPED_ARRAY(ClassName, snake_name, PrototypeName, ConstructorName, Type) \
+ ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length, FunctionObject& new_target) \
+ { \
+ auto* prototype = TRY(get_prototype_from_constructor(realm.vm(), new_target, &Intrinsics::snake_name##_prototype)); \
+ auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
+ return MUST_OR_THROW_OOM(realm.heap().allocate<ClassName>(realm, *prototype, length, *array_buffer)); \
+ } \
+ \
+ ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length) \
+ { \
+ auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
+ return create(realm, length, *array_buffer); \
+ } \
+ \
+ NonnullGCPtr<ClassName> ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \
+ { \
+ return realm.heap().allocate<ClassName>(realm, realm.intrinsics().snake_name##_prototype(), length, array_buffer).release_allocated_value_but_fixme_should_propagate_errors(); \
+ } \
+ \
+ ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \
+ : TypedArray(prototype, \
+ bit_cast<TypedArrayBase::IntrinsicConstructor>(&Intrinsics::snake_name##_constructor), length, array_buffer) \
+ { \
+ if constexpr (#ClassName##sv.is_one_of("BigInt64Array", "BigUint64Array")) \
+ m_content_type = ContentType::BigInt; \
+ else \
+ m_content_type = ContentType::Number; \
+ } \
+ \
+ ClassName::~ClassName() \
+ { \
+ } \
+ \
+ DeprecatedFlyString const& ClassName::element_name() const \
+ { \
+ return vm().names.ClassName.as_string(); \
+ } \
+ \
+ PrototypeName::PrototypeName(Object& prototype) \
+ : Object(ConstructWithPrototypeTag::Tag, prototype) \
+ { \
+ } \
+ \
+ PrototypeName::~PrototypeName() \
+ { \
+ } \
+ \
+ ThrowCompletionOr<void> PrototypeName::initialize(Realm& realm) \
+ { \
+ auto& vm = this->vm(); \
+ MUST_OR_THROW_OOM(Base::initialize(realm)); \
+ define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
+ \
+ return {}; \
+ } \
+ \
+ ConstructorName::ConstructorName(Realm& realm, Object& prototype) \
+ : TypedArrayConstructor(realm.vm().names.ClassName.as_string(), prototype) \
+ { \
+ } \
+ \
+ ConstructorName::~ConstructorName() \
+ { \
+ } \
+ \
+ ThrowCompletionOr<void> ConstructorName::initialize(Realm& realm) \
+ { \
+ auto& vm = this->vm(); \
+ MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); \
+ \
+ /* 23.2.6.2 TypedArray.prototype, https://tc39.es/ecma262/#sec-typedarray.prototype */ \
+ define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \
+ \
+ /* 23.2.6.1 TypedArray.BYTES_PER_ELEMENT, https://tc39.es/ecma262/#sec-typedarray.bytes_per_element */ \
+ define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
+ \
+ define_direct_property(vm.names.length, Value(3), Attribute::Configurable); \
+ \
+ return {}; \
+ } \
+ \
+ /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
+ ThrowCompletionOr<Value> ConstructorName::call() \
+ { \
+ auto& vm = this->vm(); \
+ return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \
+ } \
+ \
+ /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
+ 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)); \
+ \
+ auto first_argument = vm.argument(0); \
+ if (first_argument.is_object()) { \
+ auto typed_array = TRY(ClassName::create(realm, 0, new_target)); \
+ if (first_argument.as_object().is_typed_array()) { \
+ auto& arg_typed_array = static_cast<TypedArrayBase&>(first_argument.as_object()); \
+ TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \
+ } else if (is<ArrayBuffer>(first_argument.as_object())) { \
+ auto& array_buffer = static_cast<ArrayBuffer&>(first_argument.as_object()); \
+ TRY(initialize_typed_array_from_array_buffer(vm, *typed_array, array_buffer, \
+ vm.argument(1), vm.argument(2))); \
+ } else { \
+ auto iterator = TRY(first_argument.get_method(vm, *vm.well_known_symbol_iterator())); \
+ if (iterator) { \
+ auto values = TRY(iterable_to_list(vm, first_argument, iterator)); \
+ TRY(initialize_typed_array_from_list(vm, *typed_array, values)); \
+ } else { \
+ TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \
+ } \
+ } \
+ return typed_array; \
+ } \
+ \
+ auto array_length_or_error = first_argument.to_index(vm); \
+ if (array_length_or_error.is_error()) { \
+ auto error = array_length_or_error.release_error(); \
+ if (error.value()->is_object() && is<RangeError>(error.value()->as_object())) { \
+ /* Re-throw more specific RangeError */ \
+ return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
+ } \
+ return error; \
+ } \
+ auto array_length = array_length_or_error.release_value(); \
+ if (array_length > NumericLimits<i32>::max() / sizeof(Type)) \
+ return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
+ /* 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)); \
}
#undef __JS_ENUMERATE
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h
index a98c69d455..bae9568ea9 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArray.h
+++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -32,7 +32,7 @@ public:
Number,
};
- using IntrinsicConstructor = TypedArrayConstructor* (Intrinsics::*)();
+ using IntrinsicConstructor = NonnullGCPtr<TypedArrayConstructor> (Intrinsics::*)();
u32 array_length() const { return m_array_length; }
u32 byte_length() const { return m_byte_length; }
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp
index 2225d964ab..17b623e63f 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp
@@ -17,7 +17,7 @@ TypedArrayConstructor::TypedArrayConstructor(DeprecatedFlyString const& name, Ob
}
TypedArrayConstructor::TypedArrayConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.TypedArray.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.TypedArray.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp
index d5425043ac..f0b95d6c7e 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp
@@ -17,7 +17,7 @@
namespace JS {
TypedArrayPrototype::TypedArrayPrototype(Realm& realm)
- : Object(ConstructWithPrototypeTag::Tag, *realm.intrinsics().object_prototype())
+ : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
{
}
@@ -149,7 +149,7 @@ static ThrowCompletionOr<TypedArrayBase*> typed_array_species_create(VM& vm, Typ
auto& realm = *vm.current_realm();
// 1. Let defaultConstructor be the intrinsic object listed in column one of Table 72 for exemplar.[[TypedArrayName]].
- auto* default_constructor = (realm.intrinsics().*exemplar.intrinsic_constructor())();
+ auto default_constructor = (realm.intrinsics().*exemplar.intrinsic_constructor())();
// 2. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
auto* constructor = TRY(species_constructor(vm, exemplar, *default_constructor));
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp
index 90ed71024d..5b01429326 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Value.cpp
@@ -579,7 +579,7 @@ ThrowCompletionOr<Object*> Value::to_object(VM& vm) const
// String
case STRING_TAG:
// Return a new String object whose [[StringData]] internal slot is set to argument. See 22.1 for a description of String objects.
- return MUST_OR_THROW_OOM(StringObject::create(realm, const_cast<JS::PrimitiveString&>(as_string()), *realm.intrinsics().string_prototype())).ptr();
+ return MUST_OR_THROW_OOM(StringObject::create(realm, const_cast<JS::PrimitiveString&>(as_string()), realm.intrinsics().string_prototype())).ptr();
// Symbol
case SYMBOL_TAG:
// Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 20.4 for a description of Symbol objects.
diff --git a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp
index b2d7173b19..e17d342858 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp
@@ -10,7 +10,7 @@ namespace JS {
NonnullGCPtr<WeakMap> WeakMap::create(Realm& realm)
{
- return realm.heap().allocate<WeakMap>(realm, *realm.intrinsics().weak_map_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<WeakMap>(realm, realm.intrinsics().weak_map_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
WeakMap::WeakMap(Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp
index 7020175f74..85516bb3cb 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
WeakMapConstructor::WeakMapConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.WeakMap.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.WeakMap.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp
index 348fc40a13..54048ab8b3 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp
@@ -12,7 +12,7 @@
namespace JS {
WeakMapPrototype::WeakMapPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp
index eae13f6e63..10c8762321 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp
@@ -10,12 +10,12 @@ namespace JS {
NonnullGCPtr<WeakRef> WeakRef::create(Realm& realm, Object& value)
{
- return realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<WeakRef>(realm, value, realm.intrinsics().weak_ref_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
NonnullGCPtr<WeakRef> WeakRef::create(Realm& realm, Symbol& value)
{
- return realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<WeakRef>(realm, value, realm.intrinsics().weak_ref_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
WeakRef::WeakRef(Object& value, Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp
index 3408b80dee..d6396ef5b6 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp
@@ -13,7 +13,7 @@
namespace JS {
WeakRefConstructor::WeakRefConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.WeakRef.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.WeakRef.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp
index 9dc1dee494..7fe74c7c5f 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp
@@ -10,7 +10,7 @@
namespace JS {
WeakRefPrototype::WeakRefPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp
index a288695a3f..5efa3bf020 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp
@@ -10,7 +10,7 @@ namespace JS {
NonnullGCPtr<WeakSet> WeakSet::create(Realm& realm)
{
- return realm.heap().allocate<WeakSet>(realm, *realm.intrinsics().weak_set_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
+ return realm.heap().allocate<WeakSet>(realm, realm.intrinsics().weak_set_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
}
WeakSet::WeakSet(Object& prototype)
diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp
index d4901a6f0d..07ecf796f5 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp
@@ -14,7 +14,7 @@
namespace JS {
WeakSetConstructor::WeakSetConstructor(Realm& realm)
- : NativeFunction(realm.vm().names.WeakSet.as_string(), *realm.intrinsics().function_prototype())
+ : NativeFunction(realm.vm().names.WeakSet.as_string(), realm.intrinsics().function_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp
index 73e0b877fb..b13cc9b790 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp
@@ -12,7 +12,7 @@
namespace JS {
WeakSetPrototype::WeakSetPrototype(Realm& realm)
- : PrototypeObject(*realm.intrinsics().object_prototype())
+ : PrototypeObject(realm.intrinsics().object_prototype())
{
}
diff --git a/Userland/Libraries/LibJS/SyntheticModule.cpp b/Userland/Libraries/LibJS/SyntheticModule.cpp
index 492f23325b..038c9229dc 100644
--- a/Userland/Libraries/LibJS/SyntheticModule.cpp
+++ b/Userland/Libraries/LibJS/SyntheticModule.cpp
@@ -148,7 +148,7 @@ ThrowCompletionOr<NonnullGCPtr<Module>> parse_json_module(StringView source_text
auto& vm = realm.vm();
// 1. Let jsonParse be realm's intrinsic object named "%JSON.parse%".
- auto* json_parse = realm.intrinsics().json_parse_function();
+ auto json_parse = realm.intrinsics().json_parse_function();
// 2. Let json be ? Call(jsonParse, undefined, ยซ sourceText ยป).
auto json = TRY(call(vm, *json_parse, js_undefined(), MUST_OR_THROW_OOM(PrimitiveString::create(realm.vm(), source_text))));