1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:27:45 +00:00

LibJS: Remove usages of String's null state in Temporal AOs

This commit is contained in:
Idan Horowitz 2021-07-21 19:58:17 +03:00 committed by Linus Groh
parent 68aad5d8fa
commit 44c8e158c1
4 changed files with 7 additions and 6 deletions

View file

@ -117,7 +117,7 @@ Value get_option(GlobalObject& global_object, Object& options, String const& pro
}
// 13.8 ToTemporalRoundingMode ( normalizedOptions, fallback ), https://tc39.es/proposal-temporal/#sec-temporal-totemporalroundingmode
String to_temporal_rounding_mode(GlobalObject& global_object, Object& normalized_options, String const& fallback)
Optional<String> to_temporal_rounding_mode(GlobalObject& global_object, Object& normalized_options, String const& fallback)
{
auto& vm = global_object.vm();
@ -424,7 +424,7 @@ Optional<TemporalInstant> parse_temporal_instant_string(GlobalObject& global_obj
}
// 13.37 ParseTemporalCalendarString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalcalendarstring
String parse_temporal_calendar_string([[maybe_unused]] GlobalObject& global_object, [[maybe_unused]] String const& iso_string)
Optional<String> parse_temporal_calendar_string([[maybe_unused]] GlobalObject& global_object, [[maybe_unused]] String const& iso_string)
{
// 1. Assert: Type(isoString) is String.

View file

@ -54,13 +54,13 @@ struct TemporalTimeZone {
Object* get_options_object(GlobalObject&, Value options);
Value get_option(GlobalObject&, Object& options, String const& property, Vector<OptionType> const& types, Vector<StringView> const& values, Value fallback);
String to_temporal_rounding_mode(GlobalObject&, Object& normalized_options, String const& fallback);
Optional<String> to_temporal_rounding_mode(GlobalObject&, Object& normalized_options, String const& fallback);
u64 to_temporal_rounding_increment(GlobalObject&, Object& normalized_options, Optional<double> dividend, bool inclusive);
Optional<String> to_smallest_temporal_unit(GlobalObject&, Object& normalized_options, Vector<StringView> const& disallowed_units, Optional<String> fallback);
BigInt* round_number_to_increment(GlobalObject&, BigInt const&, u64 increment, String const& rounding_mode);
Optional<ISODateTime> parse_iso_date_time(GlobalObject&, String const& iso_string);
Optional<TemporalInstant> parse_temporal_instant_string(GlobalObject&, String const& iso_string);
String parse_temporal_calendar_string(GlobalObject&, String const& iso_string);
Optional<String> parse_temporal_calendar_string(GlobalObject&, String const& iso_string);
Optional<TemporalDuration> parse_temporal_duration_string(GlobalObject&, String const& iso_string);
Optional<TemporalTimeZone> parse_temporal_time_zone_string(GlobalObject&, String const& iso_string);

View file

@ -126,9 +126,10 @@ Object* to_temporal_calendar(GlobalObject& global_object, Value temporal_calenda
// 3. If ! IsBuiltinCalendar(identifier) is false, then
if (!is_builtin_calendar(identifier)) {
// a. Let identifier be ? ParseTemporalCalendarString(identifier).
identifier = parse_temporal_calendar_string(global_object, identifier);
auto parsed_identifier = parse_temporal_calendar_string(global_object, identifier);
if (vm.exception())
return {};
identifier = move(*parsed_identifier);
}
// 4. Return ? CreateTemporalCalendar(identifier).

View file

@ -196,7 +196,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::round)
return {};
// 14. Let roundedNs be ? RoundTemporalInstant(instant.[[Nanoseconds]], roundingIncrement, smallestUnit, roundingMode).
auto* rounded_ns = round_temporal_instant(global_object, instant->nanoseconds(), rounding_increment, smallest_unit, rounding_mode);
auto* rounded_ns = round_temporal_instant(global_object, instant->nanoseconds(), rounding_increment, smallest_unit, *rounding_mode);
if (vm.exception())
return {};