summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-08-16 00:20:49 +0100
committerLinus Groh <mail@linusgroh.de>2022-08-23 13:58:30 +0100
commitb99cc7d05039b9386538a581244be5af782c8d05 (patch)
tree76e012c25d6ecda6dc56b37354dc833bd1a1b9ee /Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
parent5dd5896588b0e5a7bc7bdadeaa7dd4865f663b79 (diff)
downloadserenity-b99cc7d05039b9386538a581244be5af782c8d05.zip
LibJS+LibWeb: Replace GlobalObject with Realm in create() functions
This is a continuation of the previous two commits. As allocating a JS cell already primarily involves a realm instead of a global object, and we'll need to pass one to the allocate() function itself eventually (it's bridged via the global object right now), the create() functions need to receive a realm as well. The plan is for this to be the highest-level function that actually receives a realm and passes it around, AOs on an even higher level will use the "current realm" concept via VM::current_realm() as that's what the spec assumes; passing around realms (or global objects, for that matter) on higher AO levels is pointless and unlike for allocating individual objects, which may happen outside of regular JS execution, we don't need control over the specific realm that is being used there.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
index 9735e34269..f5adef89f0 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
@@ -82,11 +82,12 @@ ThrowCompletionOr<MarkedVector<Value>> iterable_to_list_of_type(GlobalObject& gl
ThrowCompletionOr<Object*> get_options_object(GlobalObject& global_object, Value options)
{
auto& vm = global_object.vm();
+ auto& realm = *global_object.associated_realm();
// 1. If options is undefined, then
if (options.is_undefined()) {
// a. Return OrdinaryObjectCreate(null).
- return Object::create(global_object, nullptr);
+ return Object::create(realm, nullptr);
}
// 2. If Type(options) is Object, then
@@ -552,6 +553,7 @@ ThrowCompletionOr<Optional<String>> get_temporal_unit(GlobalObject& global_objec
ThrowCompletionOr<Value> to_relative_temporal_object(GlobalObject& global_object, Object const& options)
{
auto& vm = global_object.vm();
+ auto& realm = *global_object.associated_realm();
// 1. Assert: Type(options) is Object.
@@ -603,7 +605,7 @@ ThrowCompletionOr<Value> to_relative_temporal_object(GlobalObject& global_object
auto* fields = TRY(prepare_temporal_fields(global_object, value_object, field_names, Vector<StringView> {}));
// f. Let dateOptions be OrdinaryObjectCreate(null).
- auto* date_options = Object::create(global_object, nullptr);
+ auto* date_options = Object::create(realm, nullptr);
// g. Perform ! CreateDataPropertyOrThrow(dateOptions, "overflow", "constrain").
MUST(date_options->create_data_property_or_throw(vm.names.overflow, js_string(vm, "constrain"sv)));
@@ -743,9 +745,10 @@ StringView larger_of_two_temporal_units(StringView unit1, StringView unit2)
ThrowCompletionOr<Object*> merge_largest_unit_option(GlobalObject& global_object, Object const& options, String largest_unit)
{
auto& vm = global_object.vm();
+ auto& realm = *global_object.associated_realm();
// 1. Let merged be OrdinaryObjectCreate(null).
- auto* merged = Object::create(global_object, nullptr);
+ auto* merged = Object::create(realm, nullptr);
// 2. Let keys be ? EnumerableOwnPropertyNames(options, key).
auto keys = TRY(options.enumerable_own_property_names(Object::PropertyKind::Key));
@@ -1769,9 +1772,10 @@ ThrowCompletionOr<double> to_positive_integer(GlobalObject& global_object, Value
ThrowCompletionOr<Object*> prepare_temporal_fields(GlobalObject& global_object, Object const& fields, Vector<String> const& field_names, Variant<PrepareTemporalFieldsPartial, Vector<StringView>> const& required_fields)
{
auto& vm = global_object.vm();
+ auto& realm = *global_object.associated_realm();
// 1. Let result be OrdinaryObjectCreate(null).
- auto* result = Object::create(global_object, nullptr);
+ auto* result = Object::create(realm, nullptr);
VERIFY(result);
// 2. Let any be false.