Ver código fonte

LibJS: Replace to_deprecated_string() with to_string() in Temporal

Turns out all of these can already be replaced with no further changes!
Linus Groh 2 anos atrás
pai
commit
b41e7b7e86

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp

@@ -390,7 +390,7 @@ ThrowCompletionOr<SecondsStringPrecision> to_seconds_string_precision(VM& vm, Ob
         // a. If fractionalDigitsVal is not undefined, then
         if (!fractional_digits_value.is_undefined()) {
             // i. If ? ToString(fractionalDigitsVal) is not "auto", throw a RangeError exception.
-            if (TRY(fractional_digits_value.to_deprecated_string(vm)) != "auto"sv)
+            if (TRY(fractional_digits_value.to_string(vm)) != "auto"sv)
                 return vm.template throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, fractional_digits_value, "fractionalSecondDigits"sv);
         }
 
@@ -690,7 +690,7 @@ ThrowCompletionOr<Value> to_relative_temporal_object(VM& vm, Object const& optio
     if (offset_behavior == OffsetBehavior::Option) {
         // a. Set offsetString to ? ToString(offsetString).
         // NOTE: offsetString is not used after this path, so we don't need to put this into the original offset_string which is of type JS::Value.
-        auto actual_offset_string = TRY(offset_string.to_deprecated_string(vm));
+        auto actual_offset_string = TRY(offset_string.to_string(vm));
 
         // b. If IsTimeZoneOffsetString(offsetString) is false, throw a RangeError exception.
         if (!is_time_zone_offset_string(actual_offset_string))

+ 5 - 5
Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp

@@ -389,7 +389,7 @@ ThrowCompletionOr<Value> calendar_era(VM& vm, Object& calendar, Object& date_lik
 
     // 3. If result is not undefined, set result to ? ToString(result).
     if (!result.is_undefined())
-        result = PrimitiveString::create(vm, TRY(result.to_deprecated_string(vm)));
+        result = PrimitiveString::create(vm, TRY(result.to_string(vm)));
 
     // 4. Return result.
     return result;
@@ -609,10 +609,10 @@ ThrowCompletionOr<bool> calendar_equals(VM& vm, Object& one, Object& two)
         return true;
 
     // 2. Let calendarOne be ? ToString(one).
-    auto calendar_one = TRY(Value(&one).to_deprecated_string(vm));
+    auto calendar_one = TRY(Value(&one).to_string(vm));
 
     // 3. Let calendarTwo be ? ToString(two).
-    auto calendar_two = TRY(Value(&two).to_deprecated_string(vm));
+    auto calendar_two = TRY(Value(&two).to_string(vm));
 
     // 4. If calendarOne is calendarTwo, return true.
     if (calendar_one == calendar_two)
@@ -630,10 +630,10 @@ ThrowCompletionOr<Object*> consolidate_calendars(VM& vm, Object& one, Object& tw
         return &two;
 
     // 2. Let calendarOne be ? ToString(one).
-    auto calendar_one = TRY(Value(&one).to_deprecated_string(vm));
+    auto calendar_one = TRY(Value(&one).to_string(vm));
 
     // 3. Let calendarTwo be ? ToString(two).
-    auto calendar_two = TRY(Value(&two).to_deprecated_string(vm));
+    auto calendar_two = TRY(Value(&two).to_string(vm));
 
     // 4. If calendarOne is calendarTwo, return two.
     if (calendar_one == calendar_two)

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp

@@ -627,7 +627,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::to_json)
     auto* calendar = TRY(typed_this_object(vm));
 
     // 3. Return ? ToString(calendar).
-    return PrimitiveString::create(vm, TRY(Value(calendar).to_deprecated_string(vm)));
+    return PrimitiveString::create(vm, TRY(Value(calendar).to_string(vm)));
 }
 
 // 15.6.2.6 Temporal.Calendar.prototype.era ( temporalDateLike ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.era

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp

@@ -122,7 +122,7 @@ ThrowCompletionOr<PlainTime*> to_temporal_time(VM& vm, Value item, Optional<Stri
         auto* calendar = TRY(get_temporal_calendar_with_iso_default(vm, item_object));
 
         // e. If ? ToString(calendar) is not "iso8601", then
-        auto calendar_identifier = TRY(Value(calendar).to_deprecated_string(vm));
+        auto calendar_identifier = TRY(Value(calendar).to_string(vm));
         if (calendar_identifier != "iso8601"sv) {
             // i. Throw a RangeError exception.
             return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarIdentifier, calendar_identifier);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp

@@ -563,10 +563,10 @@ ThrowCompletionOr<bool> time_zone_equals(VM& vm, Object& one, Object& two)
         return true;
 
     // 2. Let timeZoneOne be ? ToString(one).
-    auto time_zone_one = TRY(Value(&one).to_deprecated_string(vm));
+    auto time_zone_one = TRY(Value(&one).to_string(vm));
 
     // 3. Let timeZoneTwo be ? ToString(two).
-    auto time_zone_two = TRY(Value(&two).to_deprecated_string(vm));
+    auto time_zone_two = TRY(Value(&two).to_string(vm));
 
     // 4. If timeZoneOne is timeZoneTwo, return true.
     if (time_zone_one == time_zone_two)

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.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
  */
@@ -244,7 +244,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_json)
     auto* time_zone = TRY(typed_this_object(vm));
 
     // 3. Return ? ToString(timeZone).
-    return PrimitiveString::create(vm, TRY(Value(time_zone).to_deprecated_string(vm)));
+    return PrimitiveString::create(vm, TRY(Value(time_zone).to_string(vm)));
 }
 
 }

+ 1 - 1
Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp

@@ -340,7 +340,7 @@ ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM& vm, ZonedDateTi
     // 13. Else,
     else {
         // a. Let timeZoneID be ? ToString(timeZone).
-        auto time_zone_id = TRY(Value(&time_zone).to_deprecated_string(vm));
+        auto time_zone_id = TRY(Value(&time_zone).to_string(vm));
 
         // b. If showTimeZone is "critical", let flag be "!"; else let flag be the empty String.
         auto flag = show_time_zone == "critical"sv ? "!"sv : ""sv;