1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

LibJS: Replace GlobalObject with VM in Intl AOs [Part 1/19]

Instead of passing a GlobalObject everywhere, we will simply pass a VM,
from which we can get everything we need: common names, the current
realm, symbols, arguments, the heap, and a few other things.

In some places we already don't actually need a global object and just
do it for consistency - no more `auto& vm = global_object.vm();`!

This will eventually automatically fix the "wrong realm" issue we have
in some places where we (incorrectly) use the global object from the
allocating object, e.g. in call() / construct() implementations. When
only ever a VM is passed around, this issue can't happen :^)

I've decided to split this change into a series of patches that should
keep each commit down do a somewhat manageable size.
This commit is contained in:
Linus Groh 2022-08-20 08:25:24 +01:00
parent 999da617c5
commit f9705eb2f4
54 changed files with 317 additions and 317 deletions

View file

@ -753,7 +753,7 @@ static void print_intl_number_format(JS::Intl::NumberFormat const& number_format
print_value(JS::Value(number_format.max_significant_digits()), seen_objects);
}
js_out("\n useGrouping: ");
print_value(number_format.use_grouping_to_value(number_format.global_object()), seen_objects);
print_value(number_format.use_grouping_to_value(number_format.vm()), seen_objects);
js_out("\n roundingType: ");
print_value(js_string(number_format.vm(), number_format.rounding_type_string()), seen_objects);
js_out("\n roundingMode: ");
@ -798,7 +798,7 @@ static void print_intl_date_time_format(JS::Intl::DateTimeFormat& date_time_form
print_value(js_string(date_time_format.vm(), date_time_format.time_style_string()), seen_objects);
}
JS::Intl::for_each_calendar_field(date_time_format.global_object(), date_time_format, [&](auto& option, auto const& property, auto const&) -> JS::ThrowCompletionOr<void> {
JS::Intl::for_each_calendar_field(date_time_format.vm(), date_time_format, [&](auto& option, auto const& property, auto const&) -> JS::ThrowCompletionOr<void> {
using ValueType = typename RemoveReference<decltype(option)>::ValueType;
if (!option.has_value())