diff options
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
118 files changed, 705 insertions, 705 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index 77dfb031bb..d3824857b2 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -1209,7 +1209,7 @@ CanonicalIndex canonical_numeric_index_string(PropertyKey const& property_key, C } // 22.1.3.17.1 GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ), https://tc39.es/ecma262/#sec-getsubstitution -ThrowCompletionOr<String> get_substitution(VM& vm, Utf16View const& matched, Utf16View const& str, size_t position, Span<Value> captures, Value named_captures, Value replacement) +ThrowCompletionOr<DeprecatedString> get_substitution(VM& vm, Utf16View const& matched, Utf16View const& str, size_t position, Span<Value> captures, Value named_captures, Value replacement) { auto replace_string = TRY(replacement.to_utf16_string(vm)); auto replace_view = replace_string.view(); diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h index 562154f699..b9be4c4bdb 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h @@ -46,7 +46,7 @@ enum class CanonicalIndexMode { IgnoreNumericRoundtrip, }; CanonicalIndex canonical_numeric_index_string(PropertyKey const&, CanonicalIndexMode needs_numeric); -ThrowCompletionOr<String> get_substitution(VM&, Utf16View const& matched, Utf16View const& str, size_t position, Span<Value> captures, Value named_captures, Value replacement); +ThrowCompletionOr<DeprecatedString> get_substitution(VM&, Utf16View const& matched, Utf16View const& str, size_t position, Span<Value> captures, Value named_captures, Value replacement); enum class CallerMode { Strict, diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 47fb1de68a..d9eb4357d9 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -998,7 +998,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join) }; auto length = TRY(length_of_array_like(vm, *this_object)); - String separator = ","; + DeprecatedString separator = ","; if (!vm.argument(0).is_undefined()) separator = TRY(vm.argument(0).to_string(vm)); StringBuilder builder; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp index e8899b7c63..4ce08d1704 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp @@ -135,7 +135,7 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::return_) // 11. If Type(result) is not Object, then if (!result.is_object()) { - auto* error = TypeError::create(realm, String::formatted(ErrorType::NotAnObject.message(), "SyncIteratorReturnResult")); + auto* error = TypeError::create(realm, DeprecatedString::formatted(ErrorType::NotAnObject.message(), "SyncIteratorReturnResult")); // a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »). MUST(call(vm, *promise_capability->reject(), js_undefined(), error)); // b. Return promiseCapability.[[Promise]]. @@ -183,7 +183,7 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::throw_) // 11. If Type(result) is not Object, then if (!result.is_object()) { - auto* error = TypeError::create(realm, String::formatted(ErrorType::NotAnObject.message(), "SyncIteratorThrowResult")); + auto* error = TypeError::create(realm, DeprecatedString::formatted(ErrorType::NotAnObject.message(), "SyncIteratorThrowResult")); // a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »). MUST(call(vm, *promise_capability->reject(), js_undefined(), error)); diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h b/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h index ee8e74618c..f173615849 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGenerator.h @@ -39,7 +39,7 @@ private: Optional<State> m_async_generator_state; // [[AsyncGeneratorState]] ExecutionContextVariant m_async_generator_context; // [[AsyncGeneratorContext]] Vector<AsyncGeneratorRequest> m_async_generator_queue; // [[AsyncGeneratorQueue]] - Optional<String> m_generator_brand; // [[GeneratorBrand]] + Optional<DeprecatedString> m_generator_brand; // [[GeneratorBrand]] }; } diff --git a/Userland/Libraries/LibJS/Runtime/BigInt.h b/Userland/Libraries/LibJS/Runtime/BigInt.h index 00365aa58a..73bdf27871 100644 --- a/Userland/Libraries/LibJS/Runtime/BigInt.h +++ b/Userland/Libraries/LibJS/Runtime/BigInt.h @@ -19,7 +19,7 @@ public: virtual ~BigInt() override = default; Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; } - const String to_string() const { return String::formatted("{}n", m_big_integer.to_base(10)); } + const DeprecatedString to_string() const { return DeprecatedString::formatted("{}n", m_big_integer.to_base(10)); } private: explicit BigInt(Crypto::SignedBigInteger); diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp index 90c3aebf43..3142f41fd7 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <AK/String.h> +#include <AK/DeprecatedString.h> #include <LibJS/Runtime/AbstractOperations.h> #include <LibJS/Runtime/BigInt.h> #include <LibJS/Runtime/BigIntConstructor.h> diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp index f93244f397..8b317fba90 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp @@ -38,7 +38,7 @@ BoundFunction::BoundFunction(Realm& realm, FunctionObject& bound_target_function , m_bound_this(bound_this) , m_bound_arguments(move(bound_arguments)) // FIXME: Non-standard and redundant, remove. - , m_name(String::formatted("bound {}", bound_target_function.name())) + , m_name(DeprecatedString::formatted("bound {}", bound_target_function.name())) { } diff --git a/Userland/Libraries/LibJS/Runtime/Date.cpp b/Userland/Libraries/LibJS/Runtime/Date.cpp index 5ccb2d7048..4a0dffedc3 100644 --- a/Userland/Libraries/LibJS/Runtime/Date.cpp +++ b/Userland/Libraries/LibJS/Runtime/Date.cpp @@ -32,7 +32,7 @@ Date::Date(double date_value, Object& prototype) { } -String Date::iso_date_string() const +DeprecatedString Date::iso_date_string() const { int year = year_from_time(m_date_value); @@ -616,7 +616,7 @@ double parse_time_zone_offset_string(StringView offset_string) auto parsed_fraction = *parse_result->time_zone_utc_offset_fraction; // b. Let fraction be the string-concatenation of CodePointsToString(parsedFraction) and "000000000". - auto fraction = String::formatted("{}000000000", parsed_fraction); + auto fraction = DeprecatedString::formatted("{}000000000", parsed_fraction); // c. Let nanosecondsString be the substring of fraction from 1 to 10. auto nanoseconds_string = fraction.substring_view(1, 9); diff --git a/Userland/Libraries/LibJS/Runtime/Date.h b/Userland/Libraries/LibJS/Runtime/Date.h index 8cf6808fda..9233b33460 100644 --- a/Userland/Libraries/LibJS/Runtime/Date.h +++ b/Userland/Libraries/LibJS/Runtime/Date.h @@ -23,7 +23,7 @@ public: double date_value() const { return m_date_value; } void set_date_value(double value) { m_date_value = value; } - String iso_date_string() const; + DeprecatedString iso_date_string() const; private: Date(double date_value, Object& prototype); diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp index 0a0d82c76f..7a8ac037a1 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -23,7 +23,7 @@ namespace JS { // 21.4.3.2 Date.parse ( string ), https://tc39.es/ecma262/#sec-date.parse -static double parse_simplified_iso8601(String const& iso_8601) +static double parse_simplified_iso8601(DeprecatedString const& iso_8601) { // 21.4.1.15 Date Time String Format, https://tc39.es/ecma262/#sec-date-time-string-format GenericLexer lexer(iso_8601); @@ -152,7 +152,7 @@ static constexpr AK::Array<StringView, 2> extra_formats = { "%m/%e/%Y"sv }; -static double parse_date_string(String const& date_string) +static double parse_date_string(DeprecatedString const& date_string) { auto value = parse_simplified_iso8601(date_string); if (isfinite(value)) diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index 4d0b0ea89a..c4f9365c01 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -9,8 +9,8 @@ #include <AK/Array.h> #include <AK/DateConstants.h> +#include <AK/DeprecatedString.h> #include <AK/Function.h> -#include <AK/String.h> #include <AK/TypeCasts.h> #include <LibCore/DateTime.h> #include <LibCrypto/BigInt/UnsignedBigInteger.h> @@ -1076,7 +1076,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_string) } // 21.4.4.41.1 TimeString ( tv ), https://tc39.es/ecma262/#sec-timestring -String time_string(double time) +DeprecatedString time_string(double time) { // 1. Let hour be ToZeroPaddedDecimalString(ℝ(HourFromTime(tv)), 2). auto hour = hour_from_time(time); @@ -1088,11 +1088,11 @@ String time_string(double time) auto second = sec_from_time(time); // 4. Return the string-concatenation of hour, ":", minute, ":", second, the code unit 0x0020 (SPACE), and "GMT". - return String::formatted("{:02}:{:02}:{:02} GMT", hour, minute, second); + return DeprecatedString::formatted("{:02}:{:02}:{:02} GMT", hour, minute, second); } // 21.4.4.41.2 DateString ( tv ), https://tc39.es/ecma262/#sec-datestring -String date_string(double time) +DeprecatedString date_string(double time) { // 1. Let weekday be the Name of the entry in Table 62 with the Number WeekDay(tv). auto weekday = short_day_names[week_day(time)]; @@ -1111,11 +1111,11 @@ String date_string(double time) // 6. Let paddedYear be ToZeroPaddedDecimalString(abs(ℝ(yv)), 4). // 7. Return the string-concatenation of weekday, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE), day, the code unit 0x0020 (SPACE), yearSign, and paddedYear. - return String::formatted("{} {} {:02} {}{:04}", weekday, month, day, year_sign, abs(year)); + return DeprecatedString::formatted("{} {} {:02} {}{:04}", weekday, month, day, year_sign, abs(year)); } // 21.4.4.41.3 TimeZoneString ( tv ), https://tc39.es/ecma262/#sec-timezoneestring -String time_zone_string(double time) +DeprecatedString time_zone_string(double time) { // 1. Let localTimeZone be DefaultTimeZone(). auto local_time_zone = default_time_zone(); @@ -1169,11 +1169,11 @@ String time_zone_string(double time) } // 10. Return the string-concatenation of offsetSign, offsetHour, offsetMin, and tzName. - return String::formatted("{}{:02}{:02} ({})", offset_sign, offset_hour, offset_min, tz_name); + return DeprecatedString::formatted("{}{:02}{:02} ({})", offset_sign, offset_hour, offset_min, tz_name); } // 21.4.4.41.4 ToDateString ( tv ), https://tc39.es/ecma262/#sec-todatestring -String to_date_string(double time) +DeprecatedString to_date_string(double time) { // 1. If tv is NaN, return "Invalid Date". if (Value(time).is_nan()) @@ -1183,7 +1183,7 @@ String to_date_string(double time) time = local_time(time); // 3. Return the string-concatenation of DateString(t), the code unit 0x0020 (SPACE), TimeString(t), and TimeZoneString(tv). - return String::formatted("{} {}{}", date_string(time), time_string(time), time_zone_string(time)); + return DeprecatedString::formatted("{} {}{}", date_string(time), time_string(time), time_zone_string(time)); } // 14.1.1 Date.prototype.toTemporalInstant ( ), https://tc39.es/proposal-temporal/#sec-date.prototype.totemporalinstant @@ -1213,7 +1213,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_time_string) // 4. Let t be LocalTime(tv). // 5. Return the string-concatenation of TimeString(t) and TimeZoneString(tv). - auto string = String::formatted("{}{}", time_string(local_time(time)), time_zone_string(time)); + auto string = DeprecatedString::formatted("{}{}", time_string(local_time(time)), time_zone_string(time)); return js_string(vm, move(string)); } @@ -1245,7 +1245,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_utc_string) // 9. Let paddedYear be ToZeroPaddedDecimalString(abs(ℝ(yv)), 4). // 10. Return the string-concatenation of weekday, ",", the code unit 0x0020 (SPACE), day, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE), yearSign, paddedYear, the code unit 0x0020 (SPACE), and TimeString(tv). - auto string = String::formatted("{}, {:02} {} {}{:04} {}", weekday, day, month, year_sign, abs(year), time_string(time)); + auto string = DeprecatedString::formatted("{}, {:02} {} {}{:04} {}", weekday, day, month, year_sign, abs(year), time_string(time)); return js_string(vm, move(string)); } diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.h b/Userland/Libraries/LibJS/Runtime/DatePrototype.h index aaa63634bd..c54223ccff 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.h @@ -73,9 +73,9 @@ private: }; ThrowCompletionOr<double> this_time_value(VM&, Value value); -String time_string(double time); -String date_string(double time); -String time_zone_string(double time); -String to_date_string(double time); +DeprecatedString time_string(double time); +DeprecatedString date_string(double time); +DeprecatedString time_zone_string(double time); +DeprecatedString to_date_string(double time); } diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index 91e65fb49a..1bccffefc5 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -28,7 +28,7 @@ namespace JS { -ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(Realm& realm, FlyString name, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name) +ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(Realm& realm, FlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name) { Object* prototype = nullptr; switch (kind) { @@ -48,12 +48,12 @@ ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(Realm& realm, FlyStri return realm.heap().allocate<ECMAScriptFunctionObject>(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, *prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)); } -ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(Realm& realm, FlyString name, Object& prototype, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name) +ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(Realm& realm, FlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name) { return realm.heap().allocate<ECMAScriptFunctionObject>(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)); } -ECMAScriptFunctionObject::ECMAScriptFunctionObject(FlyString name, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> formal_parameters, i32 function_length, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind kind, bool strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name) +ECMAScriptFunctionObject::ECMAScriptFunctionObject(FlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> formal_parameters, i32 function_length, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind kind, bool strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name) : FunctionObject(prototype) , m_name(move(name)) , m_function_length(function_length) @@ -832,7 +832,7 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body() for (auto& parameter : m_formal_parameters) { if (!parameter.default_value) continue; - auto executable = TRY(compile(*parameter.default_value, FunctionKind::Normal, String::formatted("default parameter #{} for {}", default_parameter_index, m_name))); + auto executable = TRY(compile(*parameter.default_value, FunctionKind::Normal, DeprecatedString::formatted("default parameter #{} for {}", default_parameter_index, m_name))); m_default_parameter_bytecode_executables.append(move(executable)); } } diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h index 4113741a15..abda919e09 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h @@ -32,8 +32,8 @@ public: Global, }; - static ECMAScriptFunctionObject* create(Realm&, FlyString name, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {}); - static ECMAScriptFunctionObject* create(Realm&, FlyString name, Object& prototype, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {}); + static ECMAScriptFunctionObject* create(Realm&, FlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {}); + static ECMAScriptFunctionObject* create(Realm&, FlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {}); virtual void initialize(Realm&) override; virtual ~ECMAScriptFunctionObject() override = default; @@ -64,8 +64,8 @@ public: Object* home_object() const { return m_home_object; } void set_home_object(Object* home_object) { m_home_object = home_object; } - String const& source_text() const { return m_source_text; } - void set_source_text(String source_text) { m_source_text = move(source_text); } + DeprecatedString const& source_text() const { return m_source_text; } + void set_source_text(DeprecatedString source_text) { m_source_text = move(source_text); } Vector<ClassFieldDefinition> const& fields() const { return m_fields; } void add_field(ClassFieldDefinition field) { m_fields.append(move(field)); } @@ -93,7 +93,7 @@ protected: virtual Completion ordinary_call_evaluate_body(); private: - ECMAScriptFunctionObject(FlyString name, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name); + ECMAScriptFunctionObject(FlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name); virtual bool is_ecmascript_function_object() const override { return true; } virtual void visit_edges(Visitor&) override; @@ -118,7 +118,7 @@ private: Realm* m_realm { nullptr }; // [[Realm]] ScriptOrModule m_script_or_module; // [[ScriptOrModule]] Object* m_home_object { nullptr }; // [[HomeObject]] - String m_source_text; // [[SourceText]] + DeprecatedString m_source_text; // [[SourceText]] Vector<ClassFieldDefinition> m_fields; // [[Fields]] Vector<PrivateElement> m_private_methods; // [[PrivateMethods]] Variant<PropertyKey, PrivateName, Empty> m_class_field_initializer_name; // [[ClassFieldInitializerName]] diff --git a/Userland/Libraries/LibJS/Runtime/Error.cpp b/Userland/Libraries/LibJS/Runtime/Error.cpp index 5c2946cd27..c8babe021c 100644 --- a/Userland/Libraries/LibJS/Runtime/Error.cpp +++ b/Userland/Libraries/LibJS/Runtime/Error.cpp @@ -19,7 +19,7 @@ Error* Error::create(Realm& realm) return realm.heap().allocate<Error>(realm, *realm.intrinsics().error_prototype()); } -Error* Error::create(Realm& realm, String const& message) +Error* Error::create(Realm& realm, DeprecatedString const& message) { auto& vm = realm.vm(); auto* error = Error::create(realm); @@ -73,7 +73,7 @@ void Error::populate_stack() } } -String Error::stack_string() const +DeprecatedString Error::stack_string() const { StringBuilder stack_string_builder; // Note: We roughly follow V8's formatting @@ -104,7 +104,7 @@ String Error::stack_string() const return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype()); \ } \ \ - ClassName* ClassName::create(Realm& realm, String const& message) \ + ClassName* ClassName::create(Realm& realm, DeprecatedString const& message) \ { \ auto& vm = realm.vm(); \ auto* error = ClassName::create(realm); \ diff --git a/Userland/Libraries/LibJS/Runtime/Error.h b/Userland/Libraries/LibJS/Runtime/Error.h index 74a16db8f5..80981ff81e 100644 --- a/Userland/Libraries/LibJS/Runtime/Error.h +++ b/Userland/Libraries/LibJS/Runtime/Error.h @@ -24,11 +24,11 @@ class Error : public Object { public: static Error* create(Realm&); - static Error* create(Realm&, String const& message); + static Error* create(Realm&, DeprecatedString const& message); virtual ~Error() override = default; - [[nodiscard]] String stack_string() const; + [[nodiscard]] DeprecatedString stack_string() const; ThrowCompletionOr<void> install_error_cause(Value options); @@ -51,7 +51,7 @@ private: \ public: \ static ClassName* create(Realm&); \ - static ClassName* create(Realm&, String const& message); \ + static ClassName* create(Realm&, DeprecatedString const& message); \ \ explicit ClassName(Object& prototype); \ virtual ~ClassName() override = default; \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp index 4018a0e796..72976c058a 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp @@ -45,7 +45,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string) // 4. If name is undefined, set name to "Error"; otherwise set name to ? ToString(name). auto name = name_property.is_undefined() - ? String { "Error"sv } + ? DeprecatedString { "Error"sv } : TRY(name_property.to_string(vm)); // 5. Let msg be ? Get(O, "message"). @@ -53,7 +53,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string) // 6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg). auto message = message_property.is_undefined() - ? String::empty() + ? DeprecatedString::empty() : TRY(message_property.to_string(vm)); // 7. If name is the empty String, return msg. @@ -65,7 +65,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string) return js_string(vm, name); // 9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE), and msg. - return js_string(vm, String::formatted("{}: {}", name, message)); + return js_string(vm, DeprecatedString::formatted("{}: {}", name, message)); } // B.1.1 get Error.prototype.stack ( ), https://tc39.es/proposal-error-stacks/#sec-get-error.prototype-stack @@ -84,21 +84,21 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_getter) // 4. Return ? GetStackString(error). // NOTE: These steps are not implemented based on the proposal, but to roughly follow behavior of other browsers. - String name = "Error"; + DeprecatedString name = "Error"; auto name_property = TRY(error.get(vm.names.name)); if (!name_property.is_undefined()) name = TRY(name_property.to_string(vm)); - String message = ""; + DeprecatedString message = ""; auto message_property = TRY(error.get(vm.names.message)); if (!message_property.is_undefined()) message = TRY(message_property.to_string(vm)); - String header = name; + DeprecatedString header = name; if (!message.is_empty()) - header = String::formatted("{}: {}", name, message); + header = DeprecatedString::formatted("{}: {}", name, message); - return js_string(vm, String::formatted("{}\n{}", header, error.stack_string())); + return js_string(vm, DeprecatedString::formatted("{}\n{}", header, error.stack_string())); } // B.1.2 set Error.prototype.stack ( value ), https://tc39.es/proposal-error-stacks/#sec-set-error.prototype-stack diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp index 823316ecdb..5eaaf26763 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp @@ -113,7 +113,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic auto arg_count = args.size(); // 9. Let P be the empty String. - String parameters_string = ""; + DeprecatedString parameters_string = ""; Optional<Value> body_arg; @@ -138,7 +138,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic size_t k = 0; // e. Repeat, while k < argCount - 1, - Vector<String> parameters; + Vector<DeprecatedString> parameters; for (; k < arg_count - 1; ++k) { // i. Let nextArg be args[k]. auto next_arg = args[k]; @@ -149,18 +149,18 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic // iv. Set k to k + 1. } - parameters_string = String::join(',', parameters); + parameters_string = DeprecatedString::join(',', parameters); // f. Let bodyArg be args[k]. body_arg = args[k]; } // 13. Let bodyString be the string-concatenation of 0x000A (LINE FEED), ? ToString(bodyArg), and 0x000A (LINE FEED). - auto body_string = String::formatted("\n{}\n", body_arg.has_value() ? TRY(body_arg->to_string(vm)) : ""); + auto body_string = DeprecatedString::formatted("\n{}\n", body_arg.has_value() ? TRY(body_arg->to_string(vm)) : ""); // 14. Let sourceString be the string-concatenation of prefix, " anonymous(", P, 0x000A (LINE FEED), ") {", bodyString, and "}". // 15. Let sourceText be StringToCodePoints(sourceString). - auto source_text = String::formatted("{} anonymous({}\n) {{{}}}", prefix, parameters_string, body_string); + auto source_text = DeprecatedString::formatted("{} anonymous({}\n) {{{}}}", prefix, parameters_string, body_string); u8 parse_options = FunctionNodeParseOptions::CheckForFunctionAndName; if (kind == FunctionKind::Async || kind == FunctionKind::AsyncGenerator) diff --git a/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp index 9dbff6aac7..38eea536c2 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp @@ -32,7 +32,7 @@ void FunctionObject::set_function_name(Variant<PropertyKey, PrivateName> const& VERIFY(m_is_extensible); VERIFY(!storage_has(vm.names.name)); - String name; + DeprecatedString name; // 2. If Type(name) is Symbol, then if (auto const* property_key = name_arg.get_pointer<PropertyKey>(); property_key && property_key->is_symbol()) { @@ -41,10 +41,10 @@ void FunctionObject::set_function_name(Variant<PropertyKey, PrivateName> const& // b. If description is undefined, set name to the empty String. if (!description.has_value()) - name = String::empty(); + name = DeprecatedString::empty(); // c. Else, set name to the string-concatenation of "[", description, and "]". else - name = String::formatted("[{}]", *description); + name = DeprecatedString::formatted("[{}]", *description); } // 3. Else if name is a Private Name, then else if (auto const* private_name = name_arg.get_pointer<PrivateName>()) { @@ -65,7 +65,7 @@ void FunctionObject::set_function_name(Variant<PropertyKey, PrivateName> const& // 5. If prefix is present, then if (prefix.has_value()) { // a. Set name to the string-concatenation of prefix, the code unit 0x0020 (SPACE), and name. - name = String::formatted("{} {}", *prefix, name); + name = DeprecatedString::formatted("{} {}", *prefix, name); // b. If F has an [[InitialName]] internal slot, then if (is<NativeFunction>(this)) { diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index 745976fda4..693c264f50 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -164,7 +164,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::to_string) // NOTE: once we remove name(), the fallback here can simply be an empty string. auto const& native_function = static_cast<NativeFunction&>(function); auto const name = native_function.initial_name().value_or(native_function.name()); - return js_string(vm, String::formatted("function {}() {{ [native code] }}", name)); + return js_string(vm, DeprecatedString::formatted("function {}() {{ [native code] }}", name)); } // 4. If Type(func) is Object and IsCallable(func) is true, return an implementation-defined String source code representation of func. The representation must have the syntax of a NativeFunction. diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp index e17b333616..1136e9aa9b 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp @@ -53,7 +53,7 @@ void GeneratorObject::visit_edges(Cell::Visitor& visitor) } // 27.5.3.2 GeneratorValidate ( generator, generatorBrand ), https://tc39.es/ecma262/#sec-generatorvalidate -ThrowCompletionOr<GeneratorObject::GeneratorState> GeneratorObject::validate(VM& vm, Optional<String> const& generator_brand) +ThrowCompletionOr<GeneratorObject::GeneratorState> GeneratorObject::validate(VM& vm, Optional<DeprecatedString> const& generator_brand) { // 1. Perform ? RequireInternalSlot(generator, [[GeneratorState]]). // 2. Perform ? RequireInternalSlot(generator, [[GeneratorBrand]]). @@ -152,7 +152,7 @@ ThrowCompletionOr<Value> GeneratorObject::execute(VM& vm, Completion const& comp } // 27.5.3.3 GeneratorResume ( generator, value, generatorBrand ), https://tc39.es/ecma262/#sec-generatorresume -ThrowCompletionOr<Value> GeneratorObject::resume(VM& vm, Value value, Optional<String> generator_brand) +ThrowCompletionOr<Value> GeneratorObject::resume(VM& vm, Value value, Optional<DeprecatedString> generator_brand) { // 1. Let state be ? GeneratorValidate(generator, generatorBrand). auto state = TRY(validate(vm, generator_brand)); @@ -191,7 +191,7 @@ ThrowCompletionOr<Value> GeneratorObject::resume(VM& vm, Value value, Optional<S } // 27.5.3.4 GeneratorResumeAbrupt ( generator, abruptCompletion, generatorBrand ), https://tc39.es/ecma262/#sec-generatorresumeabrupt -ThrowCompletionOr<Value> GeneratorObject::resume_abrupt(JS::VM& vm, JS::Completion abrupt_completion, Optional<AK::String> generator_brand) +ThrowCompletionOr<Value> GeneratorObject::resume_abrupt(JS::VM& vm, JS::Completion abrupt_completion, Optional<AK::DeprecatedString> generator_brand) { // Not part of the spec, but the spec assumes abruptCompletion.[[Value]] is not empty. VERIFY(abrupt_completion.value().has_value()); diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h index 9dd09762ba..9769256776 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h @@ -21,8 +21,8 @@ public: virtual ~GeneratorObject() override = default; void visit_edges(Cell::Visitor&) override; - ThrowCompletionOr<Value> resume(VM&, Value value, Optional<String> generator_brand); - ThrowCompletionOr<Value> resume_abrupt(VM&, JS::Completion abrupt_completion, Optional<String> generator_brand); + ThrowCompletionOr<Value> resume(VM&, Value value, Optional<DeprecatedString> generator_brand); + ThrowCompletionOr<Value> resume_abrupt(VM&, JS::Completion abrupt_completion, Optional<DeprecatedString> generator_brand); private: GeneratorObject(Realm&, Object& prototype, ExecutionContext); @@ -34,7 +34,7 @@ private: Completed, }; - ThrowCompletionOr<GeneratorState> validate(VM&, Optional<String> const& generator_brand); + ThrowCompletionOr<GeneratorState> validate(VM&, Optional<DeprecatedString> const& generator_brand); ThrowCompletionOr<Value> execute(VM&, JS::Completion const& completion); ExecutionContext m_execution_context; @@ -42,7 +42,7 @@ private: Value m_previous_value; Optional<Bytecode::RegisterWindow> m_frame; GeneratorState m_generator_state { GeneratorState::SuspendedStart }; - Optional<String> m_generator_brand; + Optional<DeprecatedString> m_generator_brand; }; } diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp index 4ed7be0b4a..b482b34dbf 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -341,7 +341,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::eval) } // 19.2.6.1.1 Encode ( string, unescapedSet ), https://tc39.es/ecma262/#sec-encode -static ThrowCompletionOr<String> encode(VM& vm, String const& string, StringView unescaped_set) +static ThrowCompletionOr<DeprecatedString> encode(VM& vm, DeprecatedString const& string, StringView unescaped_set) { auto utf16_string = Utf16String(string); @@ -396,7 +396,7 @@ static ThrowCompletionOr<String> encode(VM& vm, String const& string, StringView } // 19.2.6.1.2 Decode ( string, reservedSet ), https://tc39.es/ecma262/#sec-decode -static ThrowCompletionOr<String> decode(VM& vm, String const& string, StringView reserved_set) +static ThrowCompletionOr<DeprecatedString> decode(VM& vm, DeprecatedString const& string, StringView reserved_set) { StringBuilder decoded_builder; auto code_point_start_offset = 0u; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp index 2d48c84fa5..c70fed0ef5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp @@ -80,7 +80,7 @@ Optional<::Locale::LocaleID> is_structurally_valid_language_tag(StringView local } // 6.2.3 CanonicalizeUnicodeLocaleId ( locale ), https://tc39.es/ecma402/#sec-canonicalizeunicodelocaleid -String canonicalize_unicode_locale_id(::Locale::LocaleID& locale) +DeprecatedString canonicalize_unicode_locale_id(::Locale::LocaleID& locale) { // Note: This implementation differs from the spec in how Step 3 is implemented. The spec assumes // the input to this method is a string, and is written such that operations are performed on parts @@ -183,18 +183,18 @@ bool is_well_formed_unit_identifier(StringView unit_identifier) } // 9.2.1 CanonicalizeLocaleList ( locales ), https://tc39.es/ecma402/#sec-canonicalizelocalelist -ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM& vm, Value locales) +ThrowCompletionOr<Vector<DeprecatedString>> canonicalize_locale_list(VM& vm, Value locales) { auto& realm = *vm.current_realm(); // 1. If locales is undefined, then if (locales.is_undefined()) { // a. Return a new empty List. - return Vector<String> {}; + return Vector<DeprecatedString> {}; } // 2. Let seen be a new empty List. - Vector<String> seen; + Vector<DeprecatedString> seen; Object* object = nullptr; // 3. If Type(locales) is String or Type(locales) is Object and locales has an [[InitializedLocale]] internal slot, then @@ -230,7 +230,7 @@ ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM& vm, Value locales if (!key_value.is_string() && !key_value.is_object()) return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOrString, key_value.to_string_without_side_effects()); - String tag; + DeprecatedString tag; // iii. If Type(kValue) is Object and kValue has an [[InitializedLocale]] internal slot, then if (key_value.is_object() && is<Locale>(key_value.as_object())) { @@ -263,7 +263,7 @@ ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM& vm, Value locales } // 9.2.2 BestAvailableLocale ( availableLocales, locale ), https://tc39.es/ecma402/#sec-bestavailablelocale -Optional<String> best_available_locale(StringView locale) +Optional<DeprecatedString> best_available_locale(StringView locale) { // 1. Let candidate be locale. StringView candidate = locale; @@ -289,12 +289,12 @@ Optional<String> best_available_locale(StringView locale) } struct MatcherResult { - String locale; + DeprecatedString locale; Vector<::Locale::Extension> extensions {}; }; // 9.2.3 LookupMatcher ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-lookupmatcher -static MatcherResult lookup_matcher(Vector<String> const& requested_locales) +static MatcherResult lookup_matcher(Vector<DeprecatedString> const& requested_locales) { // 1. Let result be a new Record. MatcherResult result {}; @@ -337,7 +337,7 @@ static MatcherResult lookup_matcher(Vector<String> const& requested_locales) } // 9.2.4 BestFitMatcher ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-bestfitmatcher -static MatcherResult best_fit_matcher(Vector<String> const& requested_locales) +static MatcherResult best_fit_matcher(Vector<DeprecatedString> const& requested_locales) { // The algorithm is implementation dependent, but should produce results that a typical user of the requested locales would // perceive as at least as good as those produced by the LookupMatcher abstract operation. @@ -345,7 +345,7 @@ static MatcherResult best_fit_matcher(Vector<String> const& requested_locales) } // 9.2.6 InsertUnicodeExtensionAndCanonicalize ( locale, extension ), https://tc39.es/ecma402/#sec-insert-unicode-extension-and-canonicalize -String insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale, ::Locale::LocaleExtension extension) +DeprecatedString insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale, ::Locale::LocaleExtension extension) { // Note: This implementation differs from the spec in how the extension is inserted. The spec assumes // the input to this method is a string, and is written such that operations are performed on parts @@ -376,7 +376,7 @@ static auto& find_key_in_value(T& value, StringView key) } // 9.2.7 ResolveLocale ( availableLocales, requestedLocales, options, relevantExtensionKeys, localeData ), https://tc39.es/ecma402/#sec-resolvelocale -LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys) +LocaleResult resolve_locale(Vector<DeprecatedString> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys) { // 1. Let matcher be options.[[localeMatcher]]. auto const& matcher = options.locale_matcher; @@ -431,7 +431,7 @@ LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptio // f. Assert: Type(value) is either String or Null. // NOTE: ECMA-402 assumes keyLocaleData is sorted by locale preference. Our list is sorted // alphabetically, so we get the locale's preferred value from LibUnicode. - Optional<String> value; + Optional<DeprecatedString> value; if (auto preference = ::Locale::get_preferred_keyword_value_for_locale(found_locale, key); preference.has_value()) value = *preference; @@ -526,10 +526,10 @@ LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptio } // 9.2.8 LookupSupportedLocales ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-lookupsupportedlocales -Vector<String> lookup_supported_locales(Vector<String> const& requested_locales) +Vector<DeprecatedString> lookup_supported_locales(Vector<DeprecatedString> const& requested_locales) { // 1. Let subset be a new empty List. - Vector<String> subset; + Vector<DeprecatedString> subset; // 2. For each element locale of requestedLocales, do for (auto const& locale : requested_locales) { @@ -553,7 +553,7 @@ Vector<String> lookup_supported_locales(Vector<String> const& requested_locales) } // 9.2.9 BestFitSupportedLocales ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-bestfitsupportedlocales -Vector<String> best_fit_supported_locales(Vector<String> const& requested_locales) +Vector<DeprecatedString> best_fit_supported_locales(Vector<DeprecatedString> const& requested_locales) { // The BestFitSupportedLocales abstract operation returns the subset of the provided BCP 47 // language priority list requestedLocales for which availableLocales has a matching locale @@ -565,7 +565,7 @@ Vector<String> best_fit_supported_locales(Vector<String> const& requested_locale } // 9.2.10 SupportedLocales ( availableLocales, requestedLocales, options ), https://tc39.es/ecma402/#sec-supportedlocales -ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<String> const& requested_locales, Value options) +ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<DeprecatedString> const& requested_locales, Value options) { auto& realm = *vm.current_realm(); @@ -575,7 +575,7 @@ ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<String> const& reques // 2. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). auto matcher = TRY(get_option(vm, *options_object, vm.names.localeMatcher, OptionType::String, { "lookup"sv, "best fit"sv }, "best fit"sv)); - Vector<String> supported_locales; + Vector<DeprecatedString> supported_locales; // 3. If matcher is "best fit", then if (matcher.as_string().string() == "best fit"sv) { @@ -589,7 +589,7 @@ ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<String> const& reques } // 5. Return CreateArrayFromList(supportedLocales). - return Array::create_from<String>(realm, supported_locales, [&vm](auto& locale) { return js_string(vm, locale); }); + return Array::create_from<DeprecatedString>(realm, supported_locales, [&vm](auto& locale) { return js_string(vm, locale); }); } // 9.2.12 CoerceOptionsToObject ( options ), https://tc39.es/ecma402/#sec-coerceoptionstoobject diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h index 326fab3274..03ee60e235 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h @@ -6,8 +6,8 @@ #pragma once +#include <AK/DeprecatedString.h> #include <AK/Span.h> -#include <AK/String.h> #include <AK/Variant.h> #include <AK/Vector.h> #include <LibJS/Forward.h> @@ -21,36 +21,36 @@ namespace JS::Intl { struct LocaleOptions { Value locale_matcher; - Optional<String> ca; // [[Calendar]] - Optional<String> co; // [[Collation]] - Optional<String> hc; // [[HourCycle]] - Optional<String> kf; // [[CaseFirst]] - Optional<String> kn; // [[Numeric]] - Optional<String> nu; // [[NumberingSystem]] + Optional<DeprecatedString> ca; // [[Calendar]] + Optional<DeprecatedString> co; // [[Collation]] + Optional<DeprecatedString> hc; // [[HourCycle]] + Optional<DeprecatedString> kf; // [[CaseFirst]] + Optional<DeprecatedString> kn; // [[Numeric]] + Optional<DeprecatedString> nu; // [[NumberingSystem]] }; struct LocaleResult { - String locale; - String data_locale; - Optional<String> ca; // [[Calendar]] - Optional<String> co; // [[Collation]] - Optional<String> hc; // [[HourCycle]] - Optional<String> kf; // [[CaseFirst]] - Optional<String> kn; // [[Numeric]] - Optional<String> nu; // [[NumberingSystem]] + DeprecatedString locale; + DeprecatedString data_locale; + Optional<DeprecatedString> ca; // [[Calendar]] + Optional<DeprecatedString> co; // [[Collation]] + Optional<DeprecatedString> hc; // [[HourCycle]] + Optional<DeprecatedString> kf; // [[CaseFirst]] + Optional<DeprecatedString> kn; // [[Numeric]] + Optional<DeprecatedString> nu; // [[NumberingSystem]] }; struct PatternPartition { PatternPartition() = default; - PatternPartition(StringView type_string, String value_string) + PatternPartition(StringView type_string, DeprecatedString value_string) : type(type_string) , value(move(value_string)) { } StringView type; - String value; + DeprecatedString value; }; struct PatternPartitionWithSource : public PatternPartition { @@ -80,16 +80,16 @@ struct PatternPartitionWithSource : public PatternPartition { using StringOrBoolean = Variant<StringView, bool>; Optional<::Locale::LocaleID> is_structurally_valid_language_tag(StringView locale); -String canonicalize_unicode_locale_id(::Locale::LocaleID& locale); +DeprecatedString canonicalize_unicode_locale_id(::Locale::LocaleID& locale); bool is_well_formed_currency_code(StringView currency); bool is_well_formed_unit_identifier(StringView unit_identifier); -ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM&, Value locales); -Optional<String> best_available_locale(StringView locale); -String insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale_id, ::Locale::LocaleExtension extension); -LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys); -Vector<String> lookup_supported_locales(Vector<String> const& requested_locales); -Vector<String> best_fit_supported_locales(Vector<String> const& requested_locales); -ThrowCompletionOr<Array*> supported_locales(VM&, Vector<String> const& requested_locales, Value options); +ThrowCompletionOr<Vector<DeprecatedString>> canonicalize_locale_list(VM&, Value locales); +Optional<DeprecatedString> best_available_locale(StringView locale); +DeprecatedString insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale_id, ::Locale::LocaleExtension extension); +LocaleResult resolve_locale(Vector<DeprecatedString> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys); +Vector<DeprecatedString> lookup_supported_locales(Vector<DeprecatedString> const& requested_locales); +Vector<DeprecatedString> best_fit_supported_locales(Vector<DeprecatedString> const& requested_locales); +ThrowCompletionOr<Array*> supported_locales(VM&, Vector<DeprecatedString> const& requested_locales, Value options); ThrowCompletionOr<Object*> coerce_options_to_object(VM&, Value options); ThrowCompletionOr<StringOrBoolean> get_string_or_boolean_option(VM&, Object const& options, PropertyKey const& property, Span<StringView const> values, StringOrBoolean true_value, StringOrBoolean falsy_value, StringOrBoolean fallback); ThrowCompletionOr<Optional<int>> default_number_option(VM&, Value value, int minimum, int maximum, Optional<int> fallback); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Collator.h b/Userland/Libraries/LibJS/Runtime/Intl/Collator.h index bd319bc801..72d0c84bda 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Collator.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/Collator.h @@ -7,7 +7,7 @@ #pragma once #include <AK/Array.h> -#include <AK/String.h> +#include <AK/DeprecatedString.h> #include <AK/StringView.h> #include <LibJS/Runtime/Intl/CollatorCompareFunction.h> #include <LibJS/Runtime/Object.h> @@ -45,8 +45,8 @@ public: virtual ~Collator() override = default; - String const& locale() const { return m_locale; } - void set_locale(String locale) { m_locale = move(locale); } + DeprecatedString const& locale() const { return m_locale; } + void set_locale(DeprecatedString locale) { m_locale = move(locale); } Usage usage() const { return m_usage; } void set_usage(StringView usage); @@ -60,8 +60,8 @@ public: void set_case_first(StringView case_first); StringView case_first_string() const; - String const& collation() const { return m_collation; } - void set_collation(String collation) { m_collation = move(collation); } + DeprecatedString const& collation() const { return m_collation; } + void set_collation(DeprecatedString collation) { m_collation = move(collation); } bool ignore_punctuation() const { return m_ignore_punctuation; } void set_ignore_punctuation(bool ignore_punctuation) { m_ignore_punctuation = ignore_punctuation; } @@ -77,11 +77,11 @@ private: virtual void visit_edges(Visitor&) override; - String m_locale; // [[Locale]] + DeprecatedString m_locale; // [[Locale]] Usage m_usage { Usage::Sort }; // [[Usage]] Sensitivity m_sensitivity { Sensitivity::Variant }; // [[Sensitivity]] CaseFirst m_case_first { CaseFirst::False }; // [[CaseFirst]] - String m_collation; // [[Collation]] + DeprecatedString m_collation; // [[Collation]] bool m_ignore_punctuation { false }; // [[IgnorePunctuation]] bool m_numeric { false }; // [[Numeric]] CollatorCompareFunction* m_bound_compare { nullptr }; // [[BoundCompare]] diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp index 4f1cb868a2..771f2104f6 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp @@ -26,7 +26,7 @@ void CollatorCompareFunction::initialize(Realm&) { auto& vm = this->vm(); define_direct_property(vm.names.length, Value(2), Attribute::Configurable); - define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); + define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); } // 10.3.3.2 CompareStrings ( collator, x, y ), https://tc39.es/ecma402/#sec-collator-comparestrings diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp index 290aa5f985..99c457e8cf 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp @@ -629,7 +629,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat // d. Else if p is equal to "dayPeriod", then else if (part == "dayPeriod"sv) { - String formatted_value; + DeprecatedString formatted_value; // i. Let f be the value of dateTimeFormat's internal slot whose name is the Internal Slot column of the matching row. auto style = date_time_format.day_period(); @@ -662,7 +662,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat // f. Else if p matches a Property column of the row in Table 6, then else if (auto style_and_value = find_calendar_field(part, date_time_format, range_format_options, local_time); style_and_value.has_value()) { - String formatted_value; + DeprecatedString formatted_value; // i. If rangeFormatOptions is not undefined, let f be the value of rangeFormatOptions's field whose name matches p. // ii. Else, let f be the value of dateTimeFormat's internal slot whose name is the Internal Slot column of the matching row. @@ -741,7 +741,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat else if (part == "weekday"sv) symbol = ::Locale::get_calendar_weekday_symbol(data_locale, date_time_format.calendar(), style, static_cast<::Locale::Weekday>(value)); - formatted_value = symbol.value_or(String::number(value)); + formatted_value = symbol.value_or(DeprecatedString::number(value)); break; } @@ -755,7 +755,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat // g. Else if p is equal to "ampm", then else if (part == "ampm"sv) { - String formatted_value; + DeprecatedString formatted_value; // i. Let v be tm.[[Hour]]. auto value = local_time.hour; @@ -830,7 +830,7 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_date_time_pattern(VM& vm, } // 11.5.8 FormatDateTime ( dateTimeFormat, x ), https://tc39.es/ecma402/#sec-formatdatetime -ThrowCompletionOr<String> format_date_time(VM& vm, DateTimeFormat& date_time_format, double time) +ThrowCompletionOr<DeprecatedString> format_date_time(VM& vm, DateTimeFormat& date_time_format, double time) { // 1. Let parts be ? PartitionDateTimePattern(dateTimeFormat, x). auto parts = TRY(partition_date_time_pattern(vm, date_time_format, time)); @@ -1146,7 +1146,7 @@ ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_date_time_range_ } // 11.5.11 FormatDateTimeRange ( dateTimeFormat, x, y ), https://tc39.es/ecma402/#sec-formatdatetimerange -ThrowCompletionOr<String> format_date_time_range(VM& vm, DateTimeFormat& date_time_format, double start, double end) +ThrowCompletionOr<DeprecatedString> format_date_time_range(VM& vm, DateTimeFormat& date_time_format, double start, double end) { // 1. Let parts be ? PartitionDateTimeRangePattern(dateTimeFormat, x, y). auto parts = TRY(partition_date_time_range_pattern(vm, date_time_format, start, end)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h index ad56e01634..7e9ac01710 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h @@ -7,7 +7,7 @@ #pragma once #include <AK/Array.h> -#include <AK/String.h> +#include <AK/DeprecatedString.h> #include <AK/StringView.h> #include <AK/Time.h> #include <AK/Types.h> @@ -43,17 +43,17 @@ public: virtual ~DateTimeFormat() override = default; - String const& locale() const { return m_locale; } - void set_locale(String locale) { m_locale = move(locale); } + DeprecatedString const& locale() const { return m_locale; } + void set_locale(DeprecatedString locale) { m_locale = move(locale); } - String const& data_locale() const { return m_data_locale; } - void set_data_locale(String data_locale) { m_data_locale = move(data_locale); } + DeprecatedString const& data_locale() const { return m_data_locale; } + void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); } - String const& calendar() const { return m_calendar; } - void set_calendar(String calendar) { m_calendar = move(calendar); } + DeprecatedString const& calendar() const { return m_calendar; } + void set_calendar(DeprecatedString calendar) { m_calendar = move(calendar); } - String const& numbering_system() const { return m_numbering_system; } - void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); } + DeprecatedString const& numbering_system() const { return m_numbering_system; } + void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); } bool has_hour_cycle() const { return m_hour_cycle.has_value(); } ::Locale::HourCycle hour_cycle() const { return *m_hour_cycle; } @@ -61,8 +61,8 @@ public: void set_hour_cycle(::Locale::HourCycle hour_cycle) { m_hour_cycle = hour_cycle; } void clear_hour_cycle() { m_hour_cycle.clear(); } - String const& time_zone() const { return m_time_zone; } - void set_time_zone(String time_zone) { m_time_zone = move(time_zone); } + DeprecatedString const& time_zone() const { return m_time_zone; } + void set_time_zone(DeprecatedString time_zone) { m_time_zone = move(time_zone); } bool has_date_style() const { return m_date_style.has_value(); } Style date_style() const { return *m_date_style; }; @@ -74,8 +74,8 @@ public: StringView time_style_string() const { return style_to_string(*m_time_style); }; void set_time_style(StringView style) { m_time_style = style_from_string(style); }; - String const& pattern() const { return Patterns::pattern; }; - void set_pattern(String pattern) { Patterns::pattern = move(pattern); } + DeprecatedString const& pattern() const { return Patterns::pattern; }; + void set_pattern(DeprecatedString pattern) { Patterns::pattern = move(pattern); } Span<::Locale::CalendarRangePattern const> range_patterns() const { return m_range_patterns.span(); }; void set_range_patterns(Vector<::Locale::CalendarRangePattern> range_patterns) { m_range_patterns = move(range_patterns); } @@ -134,17 +134,17 @@ private: virtual void visit_edges(Visitor&) override; - String m_locale; // [[Locale]] - String m_calendar; // [[Calendar]] - String m_numbering_system; // [[NumberingSystem]] + DeprecatedString m_locale; // [[Locale]] + DeprecatedString m_calendar; // [[Calendar]] + DeprecatedString m_numbering_system; // [[NumberingSystem]] Optional<::Locale::HourCycle> m_hour_cycle; // [[HourCycle]] - String m_time_zone; // [[TimeZone]] + DeprecatedString m_time_zone; // [[TimeZone]] Optional<Style> m_date_style; // [[DateStyle]] Optional<Style> m_time_style; // [[TimeStyle]] Vector<::Locale::CalendarRangePattern> m_range_patterns; // [[RangePatterns]] NativeFunction* m_bound_format { nullptr }; // [[BoundFormat]] - String m_data_locale; + DeprecatedString m_data_locale; }; enum class OptionRequired { @@ -186,10 +186,10 @@ Optional<::Locale::CalendarPattern> basic_format_matcher(::Locale::CalendarPatte Optional<::Locale::CalendarPattern> best_fit_format_matcher(::Locale::CalendarPattern const& options, Vector<::Locale::CalendarPattern> formats); ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM&, DateTimeFormat&, Vector<PatternPartition> pattern_parts, double time, ::Locale::CalendarPattern const* range_format_options); ThrowCompletionOr<Vector<PatternPartition>> partition_date_time_pattern(VM&, DateTimeFormat&, double time); -ThrowCompletionOr<String> format_date_time(VM&, DateTimeFormat&, double time); +ThrowCompletionOr<DeprecatedString> format_date_time(VM&, DateTimeFormat&, double time); ThrowCompletionOr<Array*> format_date_time_to_parts(VM&, DateTimeFormat&, double time); ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_date_time_range_pattern(VM&, DateTimeFormat&, double start, double end); -ThrowCompletionOr<String> format_date_time_range(VM&, DateTimeFormat&, double start, double end); +ThrowCompletionOr<DeprecatedString> format_date_time_range(VM&, DateTimeFormat&, double start, double end); ThrowCompletionOr<Array*> format_date_time_range_to_parts(VM&, DateTimeFormat&, double start, double end); ThrowCompletionOr<LocalTime> to_local_time(VM&, Crypto::SignedBigInteger const& epoch_ns, StringView calendar, StringView time_zone); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp index ac85f3520c..63e6ed52de 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp @@ -212,7 +212,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF // 29. Let timeZone be ? Get(options, "timeZone"). auto time_zone_value = TRY(options->get(vm.names.timeZone)); - String time_zone; + DeprecatedString time_zone; // 30. If timeZone is undefined, then if (time_zone_value.is_undefined()) { @@ -345,7 +345,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF } }); - String pattern; + DeprecatedString pattern; Vector<::Locale::CalendarRangePattern> range_patterns; // 45. If dateTimeFormat.[[Hour]] is undefined, then diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp index 86acca212c..09587a72c1 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp @@ -31,7 +31,7 @@ void DateTimeFormatFunction::initialize(Realm& realm) Base::initialize(realm); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); - define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); + define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); } ThrowCompletionOr<Value> DateTimeFormatFunction::call() diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.h b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.h index ebe0a55f9c..008ee5f574 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.h @@ -6,8 +6,8 @@ #pragma once +#include <AK/DeprecatedString.h> #include <AK/Optional.h> -#include <AK/String.h> #include <AK/StringView.h> #include <LibJS/Runtime/Object.h> #include <LibLocale/Locale.h> @@ -41,8 +41,8 @@ class DisplayNames final : public Object { public: virtual ~DisplayNames() override = default; - String const& locale() const { return m_locale; } - void set_locale(String locale) { m_locale = move(locale); } + DeprecatedString const& locale() const { return m_locale; } + void set_locale(DeprecatedString locale) { m_locale = move(locale); } ::Locale::Style style() const { return m_style; } void set_style(StringView style) { m_style = ::Locale::style_from_string(style); } @@ -64,7 +64,7 @@ public: private: DisplayNames(Object& prototype); - String m_locale; // [[Locale]] + DeprecatedString m_locale; // [[Locale]] ::Locale::Style m_style { ::Locale::Style::Long }; // [[Style]] Type m_type { Type::Invalid }; // [[Type]] Fallback m_fallback { Fallback::Invalid }; // [[Fallback]] diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp index 22e4484e7a..d88c6d3336 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp @@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of) // 5. Let fields be displayNames.[[Fields]]. // 6. If fields has a field [[<code>]], return fields.[[<code>]]. Optional<StringView> result; - Optional<String> formatted_result; + Optional<DeprecatedString> formatted_result; switch (display_names->type()) { case DisplayNames::Type::Language: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp index 394d9a00df..7c6f32337e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp @@ -232,7 +232,7 @@ bool is_valid_duration_record(Temporal::DurationRecord const& record) } // 1.1.6 GetDurationUnitOptions ( unit, options, baseStyle, stylesList, digitalBase, prevStyle ), https://tc39.es/proposal-intl-duration-format/#sec-getdurationunitoptions -ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String const& unit, Object const& options, StringView base_style, Span<StringView const> styles_list, StringView digital_base, StringView previous_style) +ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, DeprecatedString const& unit, Object const& options, StringView base_style, Span<StringView const> styles_list, StringView digital_base, StringView previous_style) { // 1. Let style be ? GetOption(options, unit, "string", stylesList, undefined). auto style_value = TRY(get_option(vm, options, unit, OptionType::String, styles_list, Empty {})); @@ -240,7 +240,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String // 2. Let displayDefault be "always". auto display_default = "always"sv; - String style; + DeprecatedString style; // 3. If style is undefined, then if (style_value.is_undefined()) { @@ -276,7 +276,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String } // 4. Let displayField be the string-concatenation of unit and "Display". - auto display_field = String::formatted("{}Display", unit); + auto display_field = DeprecatedString::formatted("{}Display", unit); // 5. Let display be ? GetOption(options, displayField, "string", « "auto", "always" », displayDefault). auto display = TRY(get_option(vm, options, display_field, OptionType::String, { "auto"sv, "always"sv }, display_default)); @@ -510,17 +510,17 @@ Vector<PatternPartition> partition_duration_format_pattern(VM& vm, DurationForma // 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 - Vector<String> string_result; + Vector<DeprecatedString> string_result; bool merge = false; for (size_t i = 0; i < result.size(); ++i) { auto const& part = result[i]; if (part.type == "literal") { - string_result.last() = String::formatted("{}{}", string_result.last(), part.value); + string_result.last() = DeprecatedString::formatted("{}{}", string_result.last(), part.value); merge = true; continue; } if (merge) { - string_result.last() = String::formatted("{}{}", string_result.last(), part.value); + string_result.last() = DeprecatedString::formatted("{}{}", string_result.last(), part.value); merge = false; continue; } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.h b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.h index ec94d24ebe..e3da094932 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.h @@ -8,7 +8,7 @@ #pragma once #include <AK/Array.h> -#include <AK/String.h> +#include <AK/DeprecatedString.h> #include <LibJS/Runtime/Intl/AbstractOperations.h> #include <LibJS/Runtime/Object.h> #include <LibJS/Runtime/Temporal/Duration.h> @@ -51,18 +51,18 @@ public: virtual ~DurationFormat() override = default; - void set_locale(String locale) { m_locale = move(locale); } - String const& locale() const { return m_locale; } + void set_locale(DeprecatedString locale) { m_locale = move(locale); } + DeprecatedString const& locale() const { return m_locale; } - void set_data_locale(String data_locale) { m_data_locale = move(data_locale); } - String const& data_locale() const { return m_data_locale; } + void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); } + DeprecatedString const& data_locale() const { return m_data_locale; } - void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); } - String const& numbering_system() const { return m_numbering_system; } + void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); } + DeprecatedString const& numbering_system() const { return m_numbering_system; } void set_style(StringView style) { m_style = style_from_string(style); } Style style() const { return m_style; } - String style_string() const { return style_to_string(m_style); } + DeprecatedString style_string() const { return style_to_string(m_style); } void set_years_style(StringView years_style) { m_years_style = date_style_from_string(years_style); } ValueStyle years_style() const { return m_years_style; } @@ -160,9 +160,9 @@ private: static Display display_from_string(StringView display); static StringView display_to_string(Display); - String m_locale; // [[Locale]] - String m_data_locale; // [[DataLocale]] - String m_numbering_system; // [[NumberingSystem]] + DeprecatedString m_locale; // [[Locale]] + DeprecatedString m_data_locale; // [[DataLocale]] + DeprecatedString m_numbering_system; // [[NumberingSystem]] Style m_style; // [[Style]] ValueStyle m_years_style { ValueStyle::Long }; // [[YearsStyle]] Display m_years_display { Display::Auto }; // [[YearsDisplay]] @@ -217,14 +217,14 @@ static constexpr AK::Array<DurationInstanceComponent, 10> duration_instances_com }; struct DurationUnitOptions { - String style; - String display; + DeprecatedString style; + DeprecatedString display; }; ThrowCompletionOr<Temporal::DurationRecord> to_duration_record(VM&, Value input); i8 duration_record_sign(Temporal::DurationRecord const&); bool is_valid_duration_record(Temporal::DurationRecord const&); -ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM&, String const& unit, Object const& options, StringView base_style, Span<StringView const> styles_list, StringView digital_base, StringView previous_style); +ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM&, DeprecatedString const& unit, Object const& options, StringView base_style, Span<StringView const> styles_list, StringView digital_base, StringView previous_style); Vector<PatternPartition> partition_duration_format_pattern(VM&, DurationFormat const&, Temporal::DurationRecord const& duration); } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp index d7cefbcc23..02459a4c6f 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp @@ -74,7 +74,7 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject& // 8. Let opt be the Record { [[localeMatcher]]: matcher, [[nu]]: numberingSystem }. LocaleOptions opt {}; opt.locale_matcher = matcher; - opt.nu = numbering_system.is_undefined() ? Optional<String>() : numbering_system.as_string().string(); + opt.nu = numbering_system.is_undefined() ? Optional<DeprecatedString>() : numbering_system.as_string().string(); // 9. Let r be ResolveLocale(%DurationFormat%.[[AvailableLocales]], requestedLocales, opt, %DurationFormat%.[[RelevantExtensionKeys]], %DurationFormat%.[[LocaleData]]). auto result = resolve_locale(requested_locales, opt, DurationFormat::relevant_extension_keys()); @@ -99,7 +99,7 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject& duration_format->set_data_locale(move(result.data_locale)); // 16. Let prevStyle be the empty String. - auto previous_style = String::empty(); + auto previous_style = DeprecatedString::empty(); // 17. For each row of Table 1, except the header row, in table order, do for (auto const& duration_instances_component : duration_instances_components) { diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp index 722c91b7d7..bad9f2e087 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp @@ -93,7 +93,7 @@ Vector<PatternPartition> deconstruct_pattern(StringView pattern, Placeables plac } // 13.5.2 CreatePartsFromList ( listFormat, list ), https://tc39.es/ecma402/#sec-createpartsfromlist -Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, Vector<String> const& list) +Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, Vector<DeprecatedString> const& list) { auto list_patterns = ::Locale::get_locale_list_patterns(list_format.locale(), list_format.type_string(), list_format.style()); if (!list_patterns.has_value()) @@ -182,7 +182,7 @@ Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, V } // 13.5.3 FormatList ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlist -String format_list(ListFormat const& list_format, Vector<String> const& list) +DeprecatedString format_list(ListFormat const& list_format, Vector<DeprecatedString> const& list) { // 1. Let parts be ! CreatePartsFromList(listFormat, list). auto parts = create_parts_from_list(list_format, list); @@ -201,7 +201,7 @@ String format_list(ListFormat const& list_format, Vector<String> const& list) } // 13.5.4 FormatListToParts ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlisttoparts -Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<String> const& list) +Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<DeprecatedString> const& list) { auto& realm = *vm.current_realm(); @@ -237,19 +237,19 @@ Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<String } // 13.5.5 StringListFromIterable ( iterable ), https://tc39.es/ecma402/#sec-createstringlistfromiterable -ThrowCompletionOr<Vector<String>> string_list_from_iterable(VM& vm, Value iterable) +ThrowCompletionOr<Vector<DeprecatedString>> string_list_from_iterable(VM& vm, Value iterable) { // 1. If iterable is undefined, then if (iterable.is_undefined()) { // a. Return a new empty List. - return Vector<String> {}; + return Vector<DeprecatedString> {}; } // 2. Let iteratorRecord be ? GetIterator(iterable). auto iterator_record = TRY(get_iterator(vm, iterable)); // 3. Let list be a new empty List. - Vector<String> list; + Vector<DeprecatedString> list; // 4. Let next be true. Object* next = nullptr; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.h b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.h index 29e44d63e3..ef505b4a52 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.h @@ -6,8 +6,8 @@ #pragma once +#include <AK/DeprecatedString.h> #include <AK/HashMap.h> -#include <AK/String.h> #include <AK/StringView.h> #include <AK/Variant.h> #include <AK/Vector.h> @@ -30,8 +30,8 @@ public: virtual ~ListFormat() override = default; - String const& locale() const { return m_locale; } - void set_locale(String locale) { m_locale = move(locale); } + DeprecatedString const& locale() const { return m_locale; } + void set_locale(DeprecatedString locale) { m_locale = move(locale); } Type type() const { return m_type; } void set_type(StringView type); @@ -44,7 +44,7 @@ public: private: explicit ListFormat(Object& prototype); - String m_locale; // [[Locale]] + DeprecatedString m_locale; // [[Locale]] Type m_type { Type::Invalid }; // [[Type]] ::Locale::Style m_style { ::Locale::Style::Long }; // [[Style]] }; @@ -52,9 +52,9 @@ private: using Placeables = HashMap<StringView, Variant<PatternPartition, Vector<PatternPartition>>>; Vector<PatternPartition> deconstruct_pattern(StringView pattern, Placeables); -Vector<PatternPartition> create_parts_from_list(ListFormat const&, Vector<String> const& list); -String format_list(ListFormat const&, Vector<String> const& list); -Array* format_list_to_parts(VM&, ListFormat const&, Vector<String> const& list); -ThrowCompletionOr<Vector<String>> string_list_from_iterable(VM&, Value iterable); +Vector<PatternPartition> create_parts_from_list(ListFormat const&, Vector<DeprecatedString> const& list); +DeprecatedString format_list(ListFormat const&, Vector<DeprecatedString> const& list); +Array* format_list_to_parts(VM&, ListFormat const&, Vector<DeprecatedString> const& list); +ThrowCompletionOr<Vector<DeprecatedString>> string_list_from_iterable(VM&, Value iterable); } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp index 5ca295dfc5..a685623fcb 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp @@ -55,7 +55,7 @@ Locale::Locale(::Locale::LocaleID const& locale_id, Object& prototype) } // 1.1.1 CreateArrayFromListOrRestricted ( list , restricted ) -static Array* create_array_from_list_or_restricted(VM& vm, Vector<StringView> list, Optional<String> restricted) +static Array* create_array_from_list_or_restricted(VM& vm, Vector<StringView> list, Optional<DeprecatedString> restricted) { auto& realm = *vm.current_realm(); @@ -75,7 +75,7 @@ static Array* create_array_from_list_or_restricted(VM& vm, Vector<StringView> li Array* calendars_of_locale(VM& vm, Locale const& locale_object) { // 1. Let restricted be loc.[[Calendar]]. - Optional<String> restricted = locale_object.has_calendar() ? locale_object.calendar() : Optional<String> {}; + Optional<DeprecatedString> restricted = locale_object.has_calendar() ? locale_object.calendar() : Optional<DeprecatedString> {}; // 2. Let locale be loc.[[Locale]]. auto const& locale = locale_object.locale(); @@ -94,7 +94,7 @@ Array* calendars_of_locale(VM& vm, Locale const& locale_object) Array* collations_of_locale(VM& vm, Locale const& locale_object) { // 1. Let restricted be loc.[[Collation]]. - Optional<String> restricted = locale_object.has_collation() ? locale_object.collation() : Optional<String> {}; + Optional<DeprecatedString> restricted = locale_object.has_collation() ? locale_object.collation() : Optional<DeprecatedString> {}; // 2. Let locale be loc.[[Locale]]. auto const& locale = locale_object.locale(); @@ -113,7 +113,7 @@ Array* collations_of_locale(VM& vm, Locale const& locale_object) Array* hour_cycles_of_locale(VM& vm, Locale const& locale_object) { // 1. Let restricted be loc.[[HourCycle]]. - Optional<String> restricted = locale_object.has_hour_cycle() ? locale_object.hour_cycle() : Optional<String> {}; + Optional<DeprecatedString> restricted = locale_object.has_hour_cycle() ? locale_object.hour_cycle() : Optional<DeprecatedString> {}; // 2. Let locale be loc.[[Locale]]. auto const& locale = locale_object.locale(); @@ -132,7 +132,7 @@ Array* hour_cycles_of_locale(VM& vm, Locale const& locale_object) Array* numbering_systems_of_locale(VM& vm, Locale const& locale_object) { // 1. Let restricted be loc.[[NumberingSystem]]. - Optional<String> restricted = locale_object.has_numbering_system() ? locale_object.numbering_system() : Optional<String> {}; + Optional<DeprecatedString> restricted = locale_object.has_numbering_system() ? locale_object.numbering_system() : Optional<DeprecatedString> {}; // 2. Let locale be loc.[[Locale]]. auto const& locale = locale_object.locale(); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Locale.h b/Userland/Libraries/LibJS/Runtime/Intl/Locale.h index 571e175403..222d74e5a9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Locale.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/Locale.h @@ -7,8 +7,8 @@ #pragma once #include <AK/Array.h> +#include <AK/DeprecatedString.h> #include <AK/Optional.h> -#include <AK/String.h> #include <AK/Vector.h> #include <LibJS/Runtime/Completion.h> #include <LibJS/Runtime/Object.h> @@ -36,28 +36,28 @@ public: virtual ~Locale() override = default; - String const& locale() const { return m_locale; } - void set_locale(String locale) { m_locale = move(locale); } + DeprecatedString const& locale() const { return m_locale; } + void set_locale(DeprecatedString locale) { m_locale = move(locale); } bool has_calendar() const { return m_calendar.has_value(); } - String const& calendar() const { return m_calendar.value(); } - void set_calendar(String calendar) { m_calendar = move(calendar); } + DeprecatedString const& calendar() const { return m_calendar.value(); } + void set_calendar(DeprecatedString calendar) { m_calendar = move(calendar); } bool has_case_first() const { return m_case_first.has_value(); } - String const& case_first() const { return m_case_first.value(); } - void set_case_first(String case_first) { m_case_first = move(case_first); } + DeprecatedString const& case_first() const { return m_case_first.value(); } + void set_case_first(DeprecatedString case_first) { m_case_first = move(case_first); } bool has_collation() const { return m_collation.has_value(); } - String const& collation() const { return m_collation.value(); } - void set_collation(String collation) { m_collation = move(collation); } + DeprecatedString const& collation() const { return m_collation.value(); } + void set_collation(DeprecatedString collation) { m_collation = move(collation); } bool has_hour_cycle() const { return m_hour_cycle.has_value(); } - String const& hour_cycle() const { return m_hour_cycle.value(); } - void set_hour_cycle(String hour_cycle) { m_hour_cycle = move(hour_cycle); } + DeprecatedString const& hour_cycle() const { return m_hour_cycle.value(); } + void set_hour_cycle(DeprecatedString hour_cycle) { m_hour_cycle = move(hour_cycle); } bool has_numbering_system() const { return m_numbering_system.has_value(); } - String const& numbering_system() const { return m_numbering_system.value(); } - void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); } + DeprecatedString const& numbering_system() const { return m_numbering_system.value(); } + void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); } bool numeric() const { return m_numeric; } void set_numeric(bool numeric) { m_numeric = numeric; } @@ -66,13 +66,13 @@ private: explicit Locale(Object& prototype); Locale(::Locale::LocaleID const&, Object& prototype); - String m_locale; // [[Locale]] - Optional<String> m_calendar; // [[Calendar]] - Optional<String> m_case_first; // [[CaseFirst]] - Optional<String> m_collation; // [[Collation]] - Optional<String> m_hour_cycle; // [[HourCycle]] - Optional<String> m_numbering_system; // [[NumberingSystem]] - bool m_numeric { false }; // [[Numeric]] + DeprecatedString m_locale; // [[Locale]] + Optional<DeprecatedString> m_calendar; // [[Calendar]] + Optional<DeprecatedString> m_case_first; // [[CaseFirst]] + Optional<DeprecatedString> m_collation; // [[Collation]] + Optional<DeprecatedString> m_hour_cycle; // [[HourCycle]] + Optional<DeprecatedString> m_numbering_system; // [[NumberingSystem]] + bool m_numeric { false }; // [[Numeric]] }; // Table 1: WeekInfo Record Fields, https://tc39.es/proposal-intl-locale-info/#table-locale-weekinfo-record diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp index 6f10534e8b..9b07636973 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <AK/DeprecatedString.h> #include <AK/Optional.h> -#include <AK/String.h> #include <AK/TypeCasts.h> #include <LibJS/Runtime/AbstractOperations.h> #include <LibJS/Runtime/GlobalObject.h> @@ -17,21 +17,21 @@ namespace JS::Intl { struct LocaleAndKeys { - String locale; - Optional<String> ca; - Optional<String> co; - Optional<String> hc; - Optional<String> kf; - Optional<String> kn; - Optional<String> nu; + DeprecatedString locale; + Optional<DeprecatedString> ca; + Optional<DeprecatedString> co; + Optional<DeprecatedString> hc; + Optional<DeprecatedString> kf; + Optional<DeprecatedString> kn; + Optional<DeprecatedString> nu; }; // Note: This is not an AO in the spec. This just serves to abstract very similar steps in ApplyOptionsToTag and the Intl.Locale constructor. -static ThrowCompletionOr<Optional<String>> get_string_option(VM& vm, Object const& options, PropertyKey const& property, Function<bool(StringView)> validator, Span<StringView const> values = {}) +static ThrowCompletionOr<Optional<DeprecatedString>> get_string_option(VM& vm, Object const& options, PropertyKey const& property, Function<bool(StringView)> validator, Span<StringView const> values = {}) { auto option = TRY(get_option(vm, options, property, OptionType::String, values, Empty {})); if (option.is_undefined()) - return Optional<String> {}; + return Optional<DeprecatedString> {}; if (validator && !validator(option.as_string().string())) return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, option, property); @@ -40,7 +40,7 @@ static ThrowCompletionOr<Optional<String>> get_string_option(VM& vm, Object cons } // 14.1.2 ApplyOptionsToTag ( tag, options ), https://tc39.es/ecma402/#sec-apply-options-to-tag -static ThrowCompletionOr<String> apply_options_to_tag(VM& vm, StringView tag, Object const& options) +static ThrowCompletionOr<DeprecatedString> apply_options_to_tag(VM& vm, StringView tag, Object const& options) { // 1. Assert: Type(tag) is String. // 2. Assert: Type(options) is Object. @@ -112,7 +112,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey auto locale_id = ::Locale::parse_unicode_locale_id(tag); VERIFY(locale_id.has_value()); - Vector<String> attributes; + Vector<DeprecatedString> attributes; Vector<::Locale::Keyword> keywords; // 3. If tag contains a substring that is a Unicode locale extension sequence, then @@ -134,7 +134,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey // a. Let attributes be a new empty List. // b. Let keywords be a new empty List. - auto field_from_key = [](LocaleAndKeys& value, StringView key) -> Optional<String>& { + auto field_from_key = [](LocaleAndKeys& value, StringView key) -> Optional<DeprecatedString>& { if (key == "ca"sv) return value.ca; if (key == "co"sv) @@ -156,7 +156,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey // 6. For each element key of relevantExtensionKeys, do for (auto const& key : relevant_extension_keys) { // a. Let value be undefined. - Optional<String> value {}; + Optional<DeprecatedString> value {}; ::Locale::Keyword* entry = nullptr; // b. If keywords contains an element whose [[Key]] is the same as key, then @@ -260,7 +260,7 @@ ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_targ // 6. Let locale be ? OrdinaryCreateFromConstructor(NewTarget, "%Locale.prototype%", internalSlotsList). auto* locale = TRY(ordinary_create_from_constructor<Locale>(vm, new_target, &Intrinsics::intl_locale_prototype)); - String tag; + DeprecatedString tag; // 7. If Type(tag) is not String or Object, throw a TypeError exception. if (!tag_value.is_string() && !tag_value.is_object()) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.cpp b/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.cpp index f53a451b8b..ab254b1c0e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.cpp @@ -293,12 +293,12 @@ bool MathematicalValue::is_zero() const [](auto) { return false; }); } -String MathematicalValue::to_string() const +DeprecatedString MathematicalValue::to_string() const { return m_value.visit( [](double value) { return number_to_string(value, NumberToStringMode::WithoutExponent); }, [](Crypto::SignedBigInteger const& value) { return value.to_base(10); }, - [](auto) -> String { VERIFY_NOT_REACHED(); }); + [](auto) -> DeprecatedString { VERIFY_NOT_REACHED(); }); } Value MathematicalValue::to_value(VM& vm) const diff --git a/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.h b/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.h index 53ff627217..25436c290f 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/MathematicalValue.h @@ -87,7 +87,7 @@ public: bool is_positive() const; bool is_zero() const; - String to_string() const; + DeprecatedString to_string() const; Value to_value(VM&) const; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp index b32fe12752..e66e20525a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp @@ -494,10 +494,10 @@ FormatResult format_numeric_to_string(NumberFormatBase const& intl_object, Mathe // 14. If int < minInteger, then if (digits < min_integer) { // a. Let forwardZeros be the String consisting of minInteger–int occurrences of the character "0". - auto forward_zeros = String::repeated('0', min_integer - digits); + auto forward_zeros = DeprecatedString::repeated('0', min_integer - digits); // b. Set string to the string-concatenation of forwardZeros and string. - string = String::formatted("{}{}", forward_zeros, string); + string = DeprecatedString::formatted("{}{}", forward_zeros, string); } // 15. If isNegative and x is 0, then @@ -522,7 +522,7 @@ Vector<PatternPartition> partition_number_pattern(VM& vm, NumberFormat& number_f // 1. Let exponent be 0. int exponent = 0; - String formatted_string; + DeprecatedString formatted_string; // 2. If x is not-a-number, then if (number.is_nan()) { @@ -714,7 +714,7 @@ static Vector<StringView> separate_integer_into_groups(::Locale::NumberGroupings // 15.5.5 PartitionNotationSubPattern ( numberFormat, x, n, exponent ), https://tc39.es/ecma402/#sec-partitionnotationsubpattern // 1.1.7 PartitionNotationSubPattern ( numberFormat, x, n, exponent ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-partitionnotationsubpattern -Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_format, MathematicalValue const& number, String formatted_string, int exponent) +Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_format, MathematicalValue const& number, DeprecatedString formatted_string, int exponent) { // 1. Let result be a new empty List. Vector<PatternPartition> result; @@ -885,7 +885,7 @@ Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_for } // 15.5.6 FormatNumeric ( numberFormat, x ), https://tc39.es/ecma402/#sec-formatnumber -String format_numeric(VM& vm, NumberFormat& number_format, MathematicalValue number) +DeprecatedString format_numeric(VM& vm, NumberFormat& number_format, MathematicalValue number) { // 1. Let parts be ? PartitionNumberPattern(numberFormat, x). // Note: Our implementation of PartitionNumberPattern does not throw. @@ -941,7 +941,7 @@ Array* format_numeric_to_parts(VM& vm, NumberFormat& number_format, Mathematical return result; } -static String cut_trailing_zeroes(StringView string, int cut) +static DeprecatedString cut_trailing_zeroes(StringView string, int cut) { // These steps are exactly the same between ToRawPrecision and ToRawFixed. @@ -1022,7 +1022,7 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis // 2. If x = 0, then if (number.is_zero()) { // a. Let m be the String consisting of p occurrences of the character "0". - result.formatted_string = String::repeated('0', precision); + result.formatted_string = DeprecatedString::repeated('0', precision); // b. Let e be 0. exponent = 0; @@ -1073,10 +1073,10 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis // 4. If e ≥ p–1, then if (exponent >= (precision - 1)) { // a. Let m be the string-concatenation of m and e–p+1 occurrences of the character "0". - result.formatted_string = String::formatted( + result.formatted_string = DeprecatedString::formatted( "{}{}", result.formatted_string, - String::repeated('0', exponent - precision + 1)); + DeprecatedString::repeated('0', exponent - precision + 1)); // b. Let int be e+1. result.digits = exponent + 1; @@ -1084,7 +1084,7 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis // 5. Else if e ≥ 0, then else if (exponent >= 0) { // a. Let m be the string-concatenation of the first e+1 characters of m, the character ".", and the remaining p–(e+1) characters of m. - result.formatted_string = String::formatted( + result.formatted_string = DeprecatedString::formatted( "{}.{}", result.formatted_string.substring_view(0, exponent + 1), result.formatted_string.substring_view(exponent + 1)); @@ -1096,9 +1096,9 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis else { // a. Assert: e < 0. // b. Let m be the string-concatenation of "0.", –(e+1) occurrences of the character "0", and m. - result.formatted_string = String::formatted( + result.formatted_string = DeprecatedString::formatted( "0.{}{}", - String::repeated('0', -1 * (exponent + 1)), + DeprecatedString::repeated('0', -1 * (exponent + 1)), result.formatted_string); // c. Let int be 1. @@ -1206,7 +1206,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction, } // 7. If n = 0, let m be "0". Otherwise, let m be the String consisting of the digits of the decimal representation of n (in order, with no leading zeroes). - result.formatted_string = n.is_zero() ? String("0"sv) : n.to_string(); + result.formatted_string = n.is_zero() ? DeprecatedString("0"sv) : n.to_string(); // 8. If f ≠ 0, then if (fraction != 0) { @@ -1216,10 +1216,10 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction, // b. If k ≤ f, then if (decimals <= static_cast<size_t>(fraction)) { // i. Let z be the String value consisting of f+1–k occurrences of the character "0". - auto zeroes = String::repeated('0', fraction + 1 - decimals); + auto zeroes = DeprecatedString::repeated('0', fraction + 1 - decimals); // ii. Let m be the string-concatenation of z and m. - result.formatted_string = String::formatted("{}{}", zeroes, result.formatted_string); + result.formatted_string = DeprecatedString::formatted("{}{}", zeroes, result.formatted_string); // iii. Let k be f+1. decimals = fraction + 1; @@ -1230,7 +1230,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction, auto b = result.formatted_string.substring_view(decimals - fraction, fraction); // d. Let m be the string-concatenation of a, ".", and b. - result.formatted_string = String::formatted("{}.{}", a, b); + result.formatted_string = DeprecatedString::formatted("{}.{}", a, b); // e. Let int be the number of characters in a. result.digits = a.length(); @@ -1253,7 +1253,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction, // 15.5.11 GetNumberFormatPattern ( numberFormat, x ), https://tc39.es/ecma402/#sec-getnumberformatpattern // 1.1.14 GetNumberFormatPattern ( numberFormat, x ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-getnumberformatpattern -Optional<Variant<StringView, String>> get_number_format_pattern(VM& vm, NumberFormat& number_format, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern) +Optional<Variant<StringView, DeprecatedString>> get_number_format_pattern(VM& vm, NumberFormat& number_format, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern) { // 1. Let localeData be %NumberFormat%.[[LocaleData]]. // 2. Let dataLocale be numberFormat.[[DataLocale]]. @@ -1797,7 +1797,7 @@ Vector<PatternPartitionWithSource> collapse_number_range(Vector<PatternPartition } // 1.1.24 FormatNumericRange( numberFormat, x, y ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatnumericrange -ThrowCompletionOr<String> format_numeric_range(VM& vm, NumberFormat& number_format, MathematicalValue start, MathematicalValue end) +ThrowCompletionOr<DeprecatedString> format_numeric_range(VM& vm, NumberFormat& number_format, MathematicalValue start, MathematicalValue end) { // 1. Let parts be ? PartitionNumberRangePattern(numberFormat, x, y). auto parts = TRY(partition_number_range_pattern(vm, number_format, move(start), move(end))); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.h index c6ad87960e..483e29d78b 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.h @@ -7,8 +7,8 @@ #pragma once #include <AK/Array.h> +#include <AK/DeprecatedString.h> #include <AK/Optional.h> -#include <AK/String.h> #include <LibJS/Runtime/Intl/AbstractOperations.h> #include <LibJS/Runtime/Intl/MathematicalValue.h> #include <LibJS/Runtime/Object.h> @@ -58,11 +58,11 @@ public: virtual ~NumberFormatBase() override = default; - String const& locale() const { return m_locale; } - void set_locale(String locale) { m_locale = move(locale); } + DeprecatedString const& locale() const { return m_locale; } + void set_locale(DeprecatedString locale) { m_locale = move(locale); } - String const& data_locale() const { return m_data_locale; } - void set_data_locale(String data_locale) { m_data_locale = move(data_locale); } + DeprecatedString const& data_locale() const { return m_data_locale; } + void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); } int min_integer_digits() const { return m_min_integer_digits; } void set_min_integer_digits(int min_integer_digits) { m_min_integer_digits = min_integer_digits; } @@ -102,8 +102,8 @@ protected: explicit NumberFormatBase(Object& prototype); private: - String m_locale; // [[Locale]] - String m_data_locale; // [[DataLocale]] + DeprecatedString m_locale; // [[Locale]] + DeprecatedString m_data_locale; // [[DataLocale]] int m_min_integer_digits { 0 }; // [[MinimumIntegerDigits]] Optional<int> m_min_fraction_digits {}; // [[MinimumFractionDigits]] Optional<int> m_max_fraction_digits {}; // [[MaximumFractionDigits]] @@ -178,16 +178,16 @@ public: virtual ~NumberFormat() override = default; - String const& numbering_system() const { return m_numbering_system; } - void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); } + DeprecatedString const& numbering_system() const { return m_numbering_system; } + void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); } Style style() const { return m_style; } StringView style_string() const; void set_style(StringView style); bool has_currency() const { return m_currency.has_value(); } - String const& currency() const { return m_currency.value(); } - void set_currency(String currency) { m_currency = move(currency); } + DeprecatedString const& currency() const { return m_currency.value(); } + void set_currency(DeprecatedString currency) { m_currency = move(currency); } bool has_currency_display() const { return m_currency_display.has_value(); } CurrencyDisplay currency_display() const { return *m_currency_display; } @@ -201,8 +201,8 @@ public: void set_currency_sign(StringView set_currency_sign); bool has_unit() const { return m_unit.has_value(); } - String const& unit() const { return m_unit.value(); } - void set_unit(String unit) { m_unit = move(unit); } + DeprecatedString const& unit() const { return m_unit.value(); } + void set_unit(DeprecatedString unit) { m_unit = move(unit); } bool has_unit_display() const { return m_unit_display.has_value(); } ::Locale::Style unit_display() const { return *m_unit_display; } @@ -238,14 +238,14 @@ private: virtual void visit_edges(Visitor&) override; - String m_locale; // [[Locale]] - String m_data_locale; // [[DataLocale]] - String m_numbering_system; // [[NumberingSystem]] + DeprecatedString m_locale; // [[Locale]] + DeprecatedString m_data_locale; // [[DataLocale]] + DeprecatedString m_numbering_system; // [[NumberingSystem]] Style m_style { Style::Invalid }; // [[Style]] - Optional<String> m_currency {}; // [[Currency]] + Optional<DeprecatedString> m_currency {}; // [[Currency]] Optional<CurrencyDisplay> m_currency_display {}; // [[CurrencyDisplay]] Optional<CurrencySign> m_currency_sign {}; // [[CurrencySign]] - Optional<String> m_unit {}; // [[Unit]] + Optional<DeprecatedString> m_unit {}; // [[Unit]] Optional<::Locale::Style> m_unit_display {}; // [[UnitDisplay]] UseGrouping m_use_grouping { false }; // [[UseGrouping]] Notation m_notation { Notation::Invalid }; // [[Notation]] @@ -261,7 +261,7 @@ private: }; struct FormatResult { - String formatted_string; // [[FormattedString]] + DeprecatedString formatted_string; // [[FormattedString]] MathematicalValue rounded_number { 0.0 }; // [[RoundedNumber]] }; @@ -278,12 +278,12 @@ enum class RoundingDecision { int currency_digits(StringView currency); FormatResult format_numeric_to_string(NumberFormatBase const& intl_object, MathematicalValue number); Vector<PatternPartition> partition_number_pattern(VM&, NumberFormat&, MathematicalValue number); -Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat&, MathematicalValue const& number, String formatted_string, int exponent); -String format_numeric(VM&, NumberFormat&, MathematicalValue number); +Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat&, MathematicalValue const& number, DeprecatedString formatted_string, int exponent); +DeprecatedString format_numeric(VM&, NumberFormat&, MathematicalValue number); Array* format_numeric_to_parts(VM&, NumberFormat&, MathematicalValue number); RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precision, int max_precision, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode); RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction, int max_fraction, int rounding_increment, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode); -Optional<Variant<StringView, String>> get_number_format_pattern(VM&, NumberFormat&, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern); +Optional<Variant<StringView, DeprecatedString>> get_number_format_pattern(VM&, NumberFormat&, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern); Optional<StringView> get_notation_sub_pattern(NumberFormat&, int exponent); int compute_exponent(NumberFormat&, MathematicalValue number); int compute_exponent_for_magnitude(NumberFormat&, int magnitude); @@ -293,7 +293,7 @@ RoundingDecision apply_unsigned_rounding_mode(MathematicalValue const& x, Mathem ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_number_range_pattern(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end); Vector<PatternPartitionWithSource> format_approximately(NumberFormat&, Vector<PatternPartitionWithSource> result); Vector<PatternPartitionWithSource> collapse_number_range(Vector<PatternPartitionWithSource> result); -ThrowCompletionOr<String> format_numeric_range(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end); +ThrowCompletionOr<DeprecatedString> format_numeric_range(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end); ThrowCompletionOr<Array*> format_numeric_range_to_parts(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end); } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp index 2d434de3a9..dbc29898ff 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp @@ -29,7 +29,7 @@ void NumberFormatFunction::initialize(Realm& realm) Base::initialize(realm); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); - define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); + define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); } ThrowCompletionOr<Value> NumberFormatFunction::call() diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.cpp index 2f339bc2f5..b90a3db59f 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.cpp @@ -18,7 +18,7 @@ PluralRules::PluralRules(Object& prototype) } // 16.5.1 GetOperands ( s ), https://tc39.es/ecma402/#sec-getoperands -::Locale::PluralOperands get_operands(String const& string) +::Locale::PluralOperands get_operands(DeprecatedString const& string) { // 1.Let n be ! ToNumber(s). auto number = string.to_double(AK::TrimWhitespace::Yes).release_value(); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.h b/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.h index 2259d40620..3bec8c892e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.h @@ -6,7 +6,7 @@ #pragma once -#include <AK/String.h> +#include <AK/DeprecatedString.h> #include <AK/StringView.h> #include <LibJS/Runtime/Completion.h> #include <LibJS/Runtime/Intl/NumberFormat.h> @@ -31,7 +31,7 @@ private: ::Locale::PluralForm m_type { ::Locale::PluralForm::Cardinal }; // [[Type]] }; -::Locale::PluralOperands get_operands(String const& string); +::Locale::PluralOperands get_operands(DeprecatedString const& string); ::Locale::PluralCategory plural_rule_select(StringView locale, ::Locale::PluralForm type, Value number, ::Locale::PluralOperands operands); ::Locale::PluralCategory resolve_plural(PluralRules const&, Value number); ::Locale::PluralCategory resolve_plural(NumberFormatBase const& number_format, ::Locale::PluralForm type, Value number); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp index be9c00b293..f8184567c1 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp @@ -222,7 +222,7 @@ Vector<PatternPartitionWithUnit> make_parts_list(StringView pattern, StringView } // 17.5.4 FormatRelativeTime ( relativeTimeFormat, value, unit ), https://tc39.es/ecma402/#sec-FormatRelativeTime -ThrowCompletionOr<String> format_relative_time(VM& vm, RelativeTimeFormat& relative_time_format, double value, StringView unit) +ThrowCompletionOr<DeprecatedString> format_relative_time(VM& vm, RelativeTimeFormat& relative_time_format, double value, StringView unit) { // 1. Let parts be ? PartitionRelativeTimePattern(relativeTimeFormat, value, unit). auto parts = TRY(partition_relative_time_pattern(vm, relative_time_format, value, unit)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.h b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.h index 4c1615cd2d..ff64342ee7 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.h @@ -7,7 +7,7 @@ #pragma once #include <AK/Array.h> -#include <AK/String.h> +#include <AK/DeprecatedString.h> #include <AK/StringView.h> #include <LibJS/Runtime/Completion.h> #include <LibJS/Runtime/Intl/AbstractOperations.h> @@ -35,14 +35,14 @@ public: virtual ~RelativeTimeFormat() override = default; - String const& locale() const { return m_locale; } - void set_locale(String locale) { m_locale = move(locale); } + DeprecatedString const& locale() const { return m_locale; } + void set_locale(DeprecatedString locale) { m_locale = move(locale); } - String const& data_locale() const { return m_data_locale; } - void set_data_locale(String data_locale) { m_data_locale = move(data_locale); } + DeprecatedString const& data_locale() const { return m_data_locale; } + void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); } - String const& numbering_system() const { return m_numbering_system; } - void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); } + DeprecatedString const& numbering_system() const { return m_numbering_system; } + void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); } ::Locale::Style style() const { return m_style; } void set_style(StringView style) { m_style = ::Locale::style_from_string(style); } @@ -63,9 +63,9 @@ private: virtual void visit_edges(Cell::Visitor&) override; - String m_locale; // [[Locale]] - String m_data_locale; // [[DataLocale]] - String m_numbering_system; // [[NumberingSystem]] + DeprecatedString m_locale; // [[Locale]] + DeprecatedString m_data_locale; // [[DataLocale]] + DeprecatedString m_numbering_system; // [[NumberingSystem]] ::Locale::Style m_style { ::Locale::Style::Long }; // [[Style]] Numeric m_numeric { Numeric::Always }; // [[Numeric]] NumberFormat* m_number_format { nullptr }; // [[NumberFormat]] @@ -73,7 +73,7 @@ private: }; struct PatternPartitionWithUnit : public PatternPartition { - PatternPartitionWithUnit(StringView type, String value, StringView unit_string = {}) + PatternPartitionWithUnit(StringView type, DeprecatedString value, StringView unit_string = {}) : PatternPartition(type, move(value)) , unit(unit_string) { @@ -85,7 +85,7 @@ struct PatternPartitionWithUnit : public PatternPartition { ThrowCompletionOr<::Locale::TimeUnit> singular_relative_time_unit(VM&, StringView unit); ThrowCompletionOr<Vector<PatternPartitionWithUnit>> partition_relative_time_pattern(VM&, RelativeTimeFormat&, double value, StringView unit); Vector<PatternPartitionWithUnit> make_parts_list(StringView pattern, StringView unit, Vector<PatternPartition> parts); -ThrowCompletionOr<String> format_relative_time(VM&, RelativeTimeFormat&, double value, StringView unit); +ThrowCompletionOr<DeprecatedString> format_relative_time(VM&, RelativeTimeFormat&, double value, StringView unit); ThrowCompletionOr<Array*> format_relative_time_to_parts(VM&, RelativeTimeFormat&, double value, StringView unit); } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.h b/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.h index a8d91070c3..56eb1aa1df 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/Segmenter.h @@ -6,7 +6,7 @@ #pragma once -#include <AK/String.h> +#include <AK/DeprecatedString.h> #include <LibJS/Runtime/Object.h> namespace JS::Intl { @@ -23,8 +23,8 @@ public: virtual ~Segmenter() override = default; - String const& locale() const { return m_locale; } - void set_locale(String locale) { m_locale = move(locale); } + DeprecatedString const& locale() const { return m_locale; } + void set_locale(DeprecatedString locale) { m_locale = move(locale); } SegmenterGranularity segmenter_granularity() const { return m_segmenter_granularity; } void set_segmenter_granularity(StringView); @@ -33,7 +33,7 @@ public: private: explicit Segmenter(Object& prototype); - String m_locale; // [[Locale]] + DeprecatedString m_locale; // [[Locale]] SegmenterGranularity m_segmenter_granularity { SegmenterGranularity::Grapheme }; // [[SegmenterGranularity]] }; diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp index e6a30a04df..138a4ed506 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp @@ -44,7 +44,7 @@ void JSONObject::initialize(Realm& realm) } // 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify -ThrowCompletionOr<String> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space) +ThrowCompletionOr<DeprecatedString> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space) { auto& realm = *vm.current_realm(); @@ -58,10 +58,10 @@ ThrowCompletionOr<String> JSONObject::stringify_impl(VM& vm, Value value, Value if (is_array) { auto& replacer_object = replacer.as_object(); auto replacer_length = TRY(length_of_array_like(vm, replacer_object)); - Vector<String> list; + Vector<DeprecatedString> list; for (size_t i = 0; i < replacer_length; ++i) { auto replacer_value = TRY(replacer_object.get(i)); - String item; + DeprecatedString item; if (replacer_value.is_string()) { item = replacer_value.as_string().string(); } else if (replacer_value.is_number()) { @@ -91,7 +91,7 @@ ThrowCompletionOr<String> JSONObject::stringify_impl(VM& vm, Value value, Value if (space.is_number()) { auto space_mv = MUST(space.to_integer_or_infinity(vm)); space_mv = min(10, space_mv); - state.gap = space_mv < 1 ? String::empty() : String::repeated(' ', space_mv); + state.gap = space_mv < 1 ? DeprecatedString::empty() : DeprecatedString::repeated(' ', space_mv); } else if (space.is_string()) { auto string = space.as_string().string(); if (string.length() <= 10) @@ -99,12 +99,12 @@ ThrowCompletionOr<String> JSONObject::stringify_impl(VM& vm, Value value, Value else state.gap = string.substring(0, 10); } else { - state.gap = String::empty(); + state.gap = DeprecatedString::empty(); } auto* wrapper = Object::create(realm, realm.intrinsics().object_prototype()); - MUST(wrapper->create_data_property_or_throw(String::empty(), value)); - return serialize_json_property(vm, state, String::empty(), wrapper); + MUST(wrapper->create_data_property_or_throw(DeprecatedString::empty(), value)); + return serialize_json_property(vm, state, DeprecatedString::empty(), wrapper); } // 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify @@ -125,7 +125,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::stringify) } // 25.5.2.1 SerializeJSONProperty ( state, key, holder ), https://tc39.es/ecma262/#sec-serializejsonproperty -ThrowCompletionOr<String> JSONObject::serialize_json_property(VM& vm, StringifyState& state, PropertyKey const& key, Object* holder) +ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_property(VM& vm, StringifyState& state, PropertyKey const& key, Object* holder) { // 1. Let value be ? Get(holder, key). auto value = TRY(holder->get(key)); @@ -215,26 +215,26 @@ ThrowCompletionOr<String> JSONObject::serialize_json_property(VM& vm, StringifyS } // 12. Return undefined. - return String {}; + return DeprecatedString {}; } // 25.5.2.4 SerializeJSONObject ( state, value ), https://tc39.es/ecma262/#sec-serializejsonobject -ThrowCompletionOr<String> JSONObject::serialize_json_object(VM& vm, StringifyState& state, Object& object) +ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_object(VM& vm, StringifyState& state, Object& object) { if (state.seen_objects.contains(&object)) return vm.throw_completion<TypeError>(ErrorType::JsonCircular); state.seen_objects.set(&object); - String previous_indent = state.indent; - state.indent = String::formatted("{}{}", state.indent, state.gap); - Vector<String> property_strings; + DeprecatedString previous_indent = state.indent; + state.indent = DeprecatedString::formatted("{}{}", state.indent, state.gap); + Vector<DeprecatedString> property_strings; auto process_property = [&](PropertyKey const& key) -> ThrowCompletionOr<void> { if (key.is_symbol()) return {}; auto serialized_property_string = TRY(serialize_json_property(vm, state, key, &object)); if (!serialized_property_string.is_null()) { - property_strings.append(String::formatted( + property_strings.append(DeprecatedString::formatted( "{}:{}{}", quote_json_string(key.to_string()), state.gap.is_empty() ? "" : " ", @@ -268,7 +268,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_object(VM& vm, StringifySta } else { builder.append('\n'); builder.append(state.indent); - auto separator = String::formatted(",\n{}", state.indent); + auto separator = DeprecatedString::formatted(",\n{}", state.indent); for (auto& property_string : property_strings) { if (!first) builder.append(separator); @@ -287,15 +287,15 @@ ThrowCompletionOr<String> JSONObject::serialize_json_object(VM& vm, StringifySta } // 25.5.2.5 SerializeJSONArray ( state, value ), https://tc39.es/ecma262/#sec-serializejsonarray -ThrowCompletionOr<String> JSONObject::serialize_json_array(VM& vm, StringifyState& state, Object& object) +ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_array(VM& vm, StringifyState& state, Object& object) { if (state.seen_objects.contains(&object)) return vm.throw_completion<TypeError>(ErrorType::JsonCircular); state.seen_objects.set(&object); - String previous_indent = state.indent; - state.indent = String::formatted("{}{}", state.indent, state.gap); - Vector<String> property_strings; + DeprecatedString previous_indent = state.indent; + state.indent = DeprecatedString::formatted("{}{}", state.indent, state.gap); + Vector<DeprecatedString> property_strings; auto length = TRY(length_of_array_like(vm, object)); @@ -328,7 +328,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_array(VM& vm, StringifyStat } else { builder.append("[\n"sv); builder.append(state.indent); - auto separator = String::formatted(",\n{}", state.indent); + auto separator = DeprecatedString::formatted(",\n{}", state.indent); bool first = true; for (auto& property_string : property_strings) { if (!first) @@ -348,7 +348,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_array(VM& vm, StringifyStat } // 25.5.2.2 QuoteJSONString ( value ), https://tc39.es/ecma262/#sec-quotejsonstring -String JSONObject::quote_json_string(String string) +DeprecatedString JSONObject::quote_json_string(DeprecatedString string) { StringBuilder builder; builder.append('"'); @@ -402,7 +402,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse) Value unfiltered = parse_json_value(vm, json.value()); if (reviver.is_function()) { auto* root = Object::create(realm, realm.intrinsics().object_prototype()); - auto root_name = String::empty(); + auto root_name = DeprecatedString::empty(); MUST(root->create_data_property_or_throw(root_name, unfiltered)); return internalize_json_property(vm, root, root_name, reviver.as_function()); } diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.h b/Userland/Libraries/LibJS/Runtime/JSONObject.h index 0779e28b43..fc2d8be9e5 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.h +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.h @@ -19,7 +19,7 @@ public: // The base implementation of stringify is exposed because it is used by // test-js to communicate between the JS tests and the C++ test runner. - static ThrowCompletionOr<String> stringify_impl(VM&, Value value, Value replacer, Value space); + static ThrowCompletionOr<DeprecatedString> stringify_impl(VM&, Value value, Value replacer, Value space); static Value parse_json_value(VM&, JsonValue const&); @@ -29,16 +29,16 @@ private: struct StringifyState { FunctionObject* replacer_function { nullptr }; HashTable<Object*> seen_objects; - String indent { String::empty() }; - String gap; - Optional<Vector<String>> property_list; + DeprecatedString indent { DeprecatedString::empty() }; + DeprecatedString gap; + Optional<Vector<DeprecatedString>> property_list; }; // Stringify helpers - static ThrowCompletionOr<String> serialize_json_property(VM&, StringifyState&, PropertyKey const& key, Object* holder); - static ThrowCompletionOr<String> serialize_json_object(VM&, StringifyState&, Object&); - static ThrowCompletionOr<String> serialize_json_array(VM&, StringifyState&, Object&); - static String quote_json_string(String); + static ThrowCompletionOr<DeprecatedString> serialize_json_property(VM&, StringifyState&, PropertyKey const& key, Object* holder); + static ThrowCompletionOr<DeprecatedString> serialize_json_object(VM&, StringifyState&, Object&); + static ThrowCompletionOr<DeprecatedString> serialize_json_array(VM&, StringifyState&, Object&); + static DeprecatedString quote_json_string(DeprecatedString); // Parse helpers static Object* parse_json_object(VM&, JsonObject const&); diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp index 466a87f217..830e7e0ec7 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp @@ -54,7 +54,7 @@ ThrowCompletionOr<Object*> MapConstructor::construct(FunctionObject& new_target) (void)TRY(get_iterator_values(vm, vm.argument(0), [&](Value iterator_value) -> Optional<Completion> { if (!iterator_value.is_object()) - return vm.throw_completion<TypeError>(ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); auto key = TRY(iterator_value.as_object().get(0)); auto value = TRY(iterator_value.as_object().get(1)); diff --git a/Userland/Libraries/LibJS/Runtime/ModuleRequest.h b/Userland/Libraries/LibJS/Runtime/ModuleRequest.h index c9ed29e74c..90fb7ab5f5 100644 --- a/Userland/Libraries/LibJS/Runtime/ModuleRequest.h +++ b/Userland/Libraries/LibJS/Runtime/ModuleRequest.h @@ -14,8 +14,8 @@ namespace JS { // 2.9 ModuleRequest Records, https://tc39.es/proposal-import-assertions/#sec-modulerequest-record struct ModuleRequest { struct Assertion { - String key; - String value; + DeprecatedString key; + DeprecatedString value; }; ModuleRequest() = default; @@ -27,7 +27,7 @@ struct ModuleRequest { ModuleRequest(FlyString module_specifier, Vector<Assertion> assertions); - void add_assertion(String key, String value) + void add_assertion(DeprecatedString key, DeprecatedString value) { assertions.empend(move(key), move(value)); } diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp index addc6303d9..89a6a467f5 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp @@ -102,7 +102,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential) // 7. Let s be the empty String. auto sign = ""sv; - String number_string; + DeprecatedString number_string; int exponent = 0; // 8. If x < 0, then @@ -117,7 +117,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential) // 9. If x = 0, then if (number == 0) { // a. Let m be the String value consisting of f + 1 occurrences of the code unit 0x0030 (DIGIT ZERO). - number_string = String::repeated('0', fraction_digits + 1); + number_string = DeprecatedString::repeated('0', fraction_digits + 1); // b. Let e be 0. exponent = 0; @@ -157,11 +157,11 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential) auto second = number_string.substring_view(1); // c. Set m to the string-concatenation of a, ".", and b. - number_string = String::formatted("{}.{}", first, second); + number_string = DeprecatedString::formatted("{}.{}", first, second); } char exponent_sign = 0; - String exponent_string; + DeprecatedString exponent_string; // 12. If e = 0, then if (exponent == 0) { @@ -190,12 +190,12 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential) } // c. Let d be the String value consisting of the digits of the decimal representation of e (in order, with no leading zeroes). - exponent_string = String::number(exponent); + exponent_string = DeprecatedString::number(exponent); } // 14. Set m to the string-concatenation of m, "e", c, and d. // 15. Return the string-concatenation of s and m. - return js_string(vm, String::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string)); + return js_string(vm, DeprecatedString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string)); } // 21.1.3.3 Number.prototype.toFixed ( fractionDigits ), https://tc39.es/ecma262/#sec-number.prototype.tofixed @@ -241,7 +241,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed) auto n = round(pow(10.0f, fraction_digits) * number); // b. If n = 0, let m be the String "0". Otherwise, let m be the String value consisting of the digits of the decimal representation of n (in order, with no leading zeroes). - auto m = (n == 0 ? "0" : String::formatted("{}", n)); + auto m = (n == 0 ? "0" : DeprecatedString::formatted("{}", n)); // c. If f ≠ 0, then if (fraction_digits != 0) { @@ -251,10 +251,10 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed) // ii. If k ≤ f, then if (k <= fraction_digits) { // 1. Let z be the String value consisting of f + 1 - k occurrences of the code unit 0x0030 (DIGIT ZERO). - auto z = String::repeated('0', fraction_digits + 1 - k); + auto z = DeprecatedString::repeated('0', fraction_digits + 1 - k); // 2. Set m to the string-concatenation of z and m. - m = String::formatted("{}{}", z, m); + m = DeprecatedString::formatted("{}{}", z, m); // 3. Set k to f + 1. k = fraction_digits + 1; @@ -263,13 +263,13 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed) // iii. Let a be the first k - f code units of m. // iv. Let b be the other f code units of m. // v. Set m to the string-concatenation of a, ".", and b. - m = String::formatted("{}.{}", + m = DeprecatedString::formatted("{}.{}", m.substring_view(0, k - fraction_digits), m.substring_view(k - fraction_digits, fraction_digits)); } // 12. Return the string-concatenation of s and m. - return js_string(vm, String::formatted("{}{}", s, m)); + return js_string(vm, DeprecatedString::formatted("{}{}", s, m)); } // 19.2.1 Number.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-number.prototype.tolocalestring @@ -321,7 +321,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision) // 7. Let s be the empty String. auto sign = ""sv; - String number_string; + DeprecatedString number_string; int exponent = 0; // 8. If x < 0, then @@ -336,7 +336,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision) // 9. If x = 0, then if (number == 0) { // a. Let m be the String value consisting of p occurrences of the code unit 0x0030 (DIGIT ZERO). - number_string = String::repeated('0', precision); + number_string = DeprecatedString::repeated('0', precision); // b. Let e be 0. exponent = 0; @@ -365,7 +365,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision) auto second = number_string.substring_view(1); // 3. Set m to the string-concatenation of a, ".", and b. - number_string = String::formatted("{}.{}", first, second); + number_string = DeprecatedString::formatted("{}.{}", first, second); } char exponent_sign = 0; @@ -388,21 +388,21 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision) } // v. Let d be the String value consisting of the digits of the decimal representation of e (in order, with no leading zeroes). - auto exponent_string = String::number(exponent); + auto exponent_string = DeprecatedString::number(exponent); // vi. Return the string-concatenation of s, m, the code unit 0x0065 (LATIN SMALL LETTER E), c, and d. - return js_string(vm, String::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string)); + return js_string(vm, DeprecatedString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string)); } } // 11. If e = p - 1, return the string-concatenation of s and m. if (exponent == precision - 1) - return js_string(vm, String::formatted("{}{}", sign, number_string)); + return js_string(vm, DeprecatedString::formatted("{}{}", sign, number_string)); // 12. If e ≥ 0, then if (exponent >= 0) { // a. Set m to the string-concatenation of the first e + 1 code units of m, the code unit 0x002E (FULL STOP), and the remaining p - (e + 1) code units of m. - number_string = String::formatted( + number_string = DeprecatedString::formatted( "{}.{}", number_string.substring_view(0, exponent + 1), number_string.substring_view(exponent + 1)); @@ -410,14 +410,14 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision) // 13. Else, else { // a. Set m to the string-concatenation of the code unit 0x0030 (DIGIT ZERO), the code unit 0x002E (FULL STOP), -(e + 1) occurrences of the code unit 0x0030 (DIGIT ZERO), and the String m. - number_string = String::formatted( + number_string = DeprecatedString::formatted( "0.{}{}", - String::repeated('0', -1 * (exponent + 1)), + DeprecatedString::repeated('0', -1 * (exponent + 1)), number_string); } // 14. Return the string-concatenation of s and m. - return js_string(vm, String::formatted("{}{}", sign, number_string)); + return js_string(vm, DeprecatedString::formatted("{}{}", sign, number_string)); } // 21.1.3.6 Number.prototype.toString ( [ radix ] ), https://tc39.es/ecma262/#sec-number.prototype.tostring @@ -499,7 +499,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string) characters.take_last(); } - return js_string(vm, String(characters.data(), characters.size())); + return js_string(vm, DeprecatedString(characters.data(), characters.size())); } // 21.1.3.7 Number.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-number.prototype.valueof diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 6b8d18acc1..714c539ea3 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -5,7 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <AK/String.h> +#include <AK/DeprecatedString.h> #include <AK/TypeCasts.h> #include <LibJS/Interpreter.h> #include <LibJS/Runtime/AbstractOperations.h> @@ -940,7 +940,7 @@ ThrowCompletionOr<MarkedVector<Value>> Object::internal_own_property_keys() cons // 2. For each own property key P of O such that P is an array index, in ascending numeric index order, do for (auto& entry : m_indexed_properties) { // a. Add P as the last element of keys. - keys.append(js_string(vm, String::number(entry.index()))); + keys.append(js_string(vm, DeprecatedString::number(entry.index()))); } // 3. For each own property key P of O such that Type(P) is String and P is not an array index, in ascending chronological order of property creation, do diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index 1f16bb6021..1ed131f8e7 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -8,8 +8,8 @@ #pragma once #include <AK/Badge.h> +#include <AK/DeprecatedString.h> #include <AK/HashMap.h> -#include <AK/String.h> #include <AK/StringView.h> #include <LibJS/Forward.h> #include <LibJS/Heap/Cell.h> diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp index e61ab14896..976e20cdde 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -227,7 +227,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries) (void)TRY(get_iterator_values(vm, iterable, [&](Value iterator_value) -> Optional<Completion> { if (!iterator_value.is_object()) - return vm.throw_completion<TypeError>(ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); auto key = TRY(iterator_value.as_object().get(0)); auto value = TRY(iterator_value.as_object().get(1)); diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp index 3db3320f4f..cb7b30fa3d 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp @@ -5,8 +5,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <AK/DeprecatedString.h> #include <AK/Function.h> -#include <AK/String.h> #include <LibJS/Runtime/AbstractOperations.h> #include <LibJS/Runtime/Accessor.h> #include <LibJS/Runtime/BooleanObject.h> @@ -82,7 +82,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string) // 4. Let isArray be ? IsArray(O). auto is_array = TRY(Value(object).is_array(vm)); - String builtin_tag; + DeprecatedString builtin_tag; // 5. If isArray is true, let builtinTag be "Array". if (is_array) @@ -119,7 +119,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string) auto to_string_tag = TRY(object->get(*vm.well_known_symbol_to_string_tag())); // Optimization: Instead of creating another PrimitiveString from builtin_tag, we separate tag and to_string_tag and add an additional branch to step 16. - String tag; + DeprecatedString tag; // 16. If Type(tag) is not String, set tag to builtinTag. if (!to_string_tag.is_string()) @@ -128,7 +128,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string) tag = to_string_tag.as_string().string(); // 17. Return the string-concatenation of "[object ", tag, and "]". - return js_string(vm, String::formatted("[object {}]", tag)); + return js_string(vm, DeprecatedString::formatted("[object {}]", tag)); } // 20.1.3.5 Object.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-object.prototype.tolocalestring diff --git a/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp b/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp index af421e527c..b2be26ac9d 100644 --- a/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp +++ b/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp @@ -23,7 +23,7 @@ PrimitiveString::PrimitiveString(PrimitiveString& lhs, PrimitiveString& rhs) { } -PrimitiveString::PrimitiveString(String string) +PrimitiveString::PrimitiveString(DeprecatedString string) : m_has_utf8_string(true) , m_utf8_string(move(string)) { @@ -63,7 +63,7 @@ bool PrimitiveString::is_empty() const VERIFY_NOT_REACHED(); } -String const& PrimitiveString::string() const +DeprecatedString const& PrimitiveString::string() const { resolve_rope_if_needed(); if (!m_has_utf8_string) { @@ -137,7 +137,7 @@ PrimitiveString* js_string(VM& vm, Utf16String string) return js_string(vm.heap(), move(string)); } -PrimitiveString* js_string(Heap& heap, String string) +PrimitiveString* js_string(Heap& heap, DeprecatedString string) { if (string.is_empty()) return &heap.vm().empty_string(); @@ -158,7 +158,7 @@ PrimitiveString* js_string(Heap& heap, String string) return it->value; } -PrimitiveString* js_string(VM& vm, String string) +PrimitiveString* js_string(VM& vm, DeprecatedString string) { return js_string(vm.heap(), move(string)); } diff --git a/Userland/Libraries/LibJS/Runtime/PrimitiveString.h b/Userland/Libraries/LibJS/Runtime/PrimitiveString.h index 768034fe62..469b79edac 100644 --- a/Userland/Libraries/LibJS/Runtime/PrimitiveString.h +++ b/Userland/Libraries/LibJS/Runtime/PrimitiveString.h @@ -6,7 +6,7 @@ #pragma once -#include <AK/String.h> +#include <AK/DeprecatedString.h> #include <AK/StringView.h> #include <LibJS/Forward.h> #include <LibJS/Heap/Cell.h> @@ -26,7 +26,7 @@ public: bool is_empty() const; - String const& string() const; + DeprecatedString const& string() const; bool has_utf8_string() const { return m_has_utf8_string; } Utf16String const& utf16_string() const; @@ -37,7 +37,7 @@ public: private: explicit PrimitiveString(PrimitiveString&, PrimitiveString&); - explicit PrimitiveString(String); + explicit PrimitiveString(DeprecatedString); explicit PrimitiveString(Utf16String); virtual void visit_edges(Cell::Visitor&) override; @@ -51,7 +51,7 @@ private: mutable PrimitiveString* m_lhs { nullptr }; mutable PrimitiveString* m_rhs { nullptr }; - mutable String m_utf8_string; + mutable DeprecatedString m_utf8_string; mutable Utf16String m_utf16_string; }; @@ -62,8 +62,8 @@ PrimitiveString* js_string(VM&, Utf16View const&); PrimitiveString* js_string(Heap&, Utf16String); PrimitiveString* js_string(VM&, Utf16String); -PrimitiveString* js_string(Heap&, String); -PrimitiveString* js_string(VM&, String); +PrimitiveString* js_string(Heap&, DeprecatedString); +PrimitiveString* js_string(VM&, DeprecatedString); PrimitiveString* js_rope_string(VM&, PrimitiveString&, PrimitiveString&); diff --git a/Userland/Libraries/LibJS/Runtime/Promise.cpp b/Userland/Libraries/LibJS/Runtime/Promise.cpp index 5d688babdf..46defb8580 100644 --- a/Userland/Libraries/LibJS/Runtime/Promise.cpp +++ b/Userland/Libraries/LibJS/Runtime/Promise.cpp @@ -157,7 +157,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions() // 16. Return undefined. return js_undefined(); }); - resolve_function->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); + resolve_function->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); // 7. Let stepsReject be the algorithm steps defined in Promise Reject Functions. // 8. Let lengthReject be the number of non-optional parameters of the function definition in Promise Reject Functions. @@ -189,7 +189,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions() // 8. Return undefined. return js_undefined(); }); - reject_function->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); + reject_function->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); // 12. Return the Record { [[Resolve]]: resolve, [[Reject]]: reject }. return { *resolve_function, *reject_function }; diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp index 65fed311f1..9cb1fa540e 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -139,7 +139,7 @@ static ThrowCompletionOr<Value> perform_promise_all(VM& vm, Iterator& iterator_r // p. Set onFulfilled.[[Capability]] to resultCapability. // q. Set onFulfilled.[[RemainingElements]] to remainingElementsCount. auto* on_fulfilled = PromiseAllResolveElementFunction::create(realm, index, values, result_capability, remaining_elements_count); - on_fulfilled->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); + on_fulfilled->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); // s. Perform ? Invoke(nextPromise, "then", « onFulfilled, resultCapability.[[Reject]] »). return next_promise.invoke(vm, vm.names.then, on_fulfilled, result_capability.reject()); @@ -171,7 +171,7 @@ static ThrowCompletionOr<Value> perform_promise_all_settled(VM& vm, Iterator& it // q. Set onFulfilled.[[Capability]] to resultCapability. // r. Set onFulfilled.[[RemainingElements]] to remainingElementsCount. auto* on_fulfilled = PromiseAllSettledResolveElementFunction::create(realm, index, values, result_capability, remaining_elements_count); - on_fulfilled->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); + on_fulfilled->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); // s. Let stepsRejected be the algorithm steps defined in Promise.allSettled Reject Element Functions. // t. Let lengthRejected be the number of non-optional parameters of the function definition in Promise.allSettled Reject Element Functions. @@ -182,7 +182,7 @@ static ThrowCompletionOr<Value> perform_promise_all_settled(VM& vm, Iterator& it // y. Set onRejected.[[Capability]] to resultCapability. // z. Set onRejected.[[RemainingElements]] to remainingElementsCount. auto* on_rejected = PromiseAllSettledRejectElementFunction::create(realm, index, values, result_capability, remaining_elements_count); - on_rejected->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); + on_rejected->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); // ab. Perform ? Invoke(nextPromise, "then", « onFulfilled, onRejected »). return next_promise.invoke(vm, vm.names.then, on_fulfilled, on_rejected); @@ -217,7 +217,7 @@ static ThrowCompletionOr<Value> perform_promise_any(VM& vm, Iterator& iterator_r // p. Set onRejected.[[Capability]] to resultCapability. // q. Set onRejected.[[RemainingElements]] to remainingElementsCount. auto* on_rejected = PromiseAnyRejectElementFunction::create(realm, index, errors, result_capability, remaining_elements_count); - on_rejected->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); + on_rejected->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable); // s. Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], onRejected »). return next_promise.invoke(vm, vm.names.then, result_capability.resolve(), on_rejected); diff --git a/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h b/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h index ddeef41f79..dd11fd96fa 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h +++ b/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h @@ -7,8 +7,8 @@ #pragma once +#include <AK/DeprecatedString.h> #include <AK/Format.h> -#include <AK/String.h> #include <AK/Types.h> #include <AK/Vector.h> @@ -76,11 +76,11 @@ template<> struct Formatter<JS::PropertyAttributes> : Formatter<StringView> { ErrorOr<void> format(FormatBuilder& builder, JS::PropertyAttributes const& property_attributes) { - Vector<String> parts; - parts.append(String::formatted("[[Writable]]: {}", property_attributes.is_writable())); - parts.append(String::formatted("[[Enumerable]]: {}", property_attributes.is_enumerable())); - parts.append(String::formatted("[[Configurable]]: {}", property_attributes.is_configurable())); - return Formatter<StringView>::format(builder, String::formatted("PropertyAttributes {{ {} }}", String::join(", "sv, parts))); + Vector<DeprecatedString> parts; + parts.append(DeprecatedString::formatted("[[Writable]]: {}", property_attributes.is_writable())); + parts.append(DeprecatedString::formatted("[[Enumerable]]: {}", property_attributes.is_enumerable())); + parts.append(DeprecatedString::formatted("[[Configurable]]: {}", property_attributes.is_configurable())); + return Formatter<StringView>::format(builder, DeprecatedString::formatted("PropertyAttributes {{ {} }}", DeprecatedString::join(", "sv, parts))); } }; diff --git a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h index 2f9bfcb3b0..755400c362 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h +++ b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h @@ -49,20 +49,20 @@ template<> struct Formatter<JS::PropertyDescriptor> : Formatter<StringView> { ErrorOr<void> format(FormatBuilder& builder, JS::PropertyDescriptor const& property_descriptor) { - Vector<String> parts; + Vector<DeprecatedString> parts; if (property_descriptor.value.has_value()) - parts.append(String::formatted("[[Value]]: {}", property_descriptor.value->to_string_without_side_effects())); + parts.append(DeprecatedString::formatted("[[Value]]: {}", property_descriptor.value->to_string_without_side_effects())); if (property_descriptor.get.has_value()) - parts.append(String::formatted("[[Get]]: JS::Function* @ {:p}", *property_descriptor.get)); + parts.append(DeprecatedString::formatted("[[Get]]: JS::Function* @ {:p}", *property_descriptor.get)); if (property_descriptor.set.has_value()) - parts.append(String::formatted("[[Set]]: JS::Function* @ {:p}", *property_descriptor.set)); + parts.append(DeprecatedString::formatted("[[Set]]: JS::Function* @ {:p}", *property_descriptor.set)); if (property_descriptor.writable.has_value()) - parts.append(String::formatted("[[Writable]]: {}", *property_descriptor.writable)); + parts.append(DeprecatedString::formatted("[[Writable]]: {}", *property_descriptor.writable)); if (property_descriptor.enumerable.has_value()) - parts.append(String::formatted("[[Enumerable]]: {}", *property_descriptor.enumerable)); + parts.append(DeprecatedString::formatted("[[Enumerable]]: {}", *property_descriptor.enumerable)); if (property_descriptor.configurable.has_value()) - parts.append(String::formatted("[[Configurable]]: {}", *property_descriptor.configurable)); - return Formatter<StringView>::format(builder, String::formatted("PropertyDescriptor {{ {} }}", String::join(", "sv, parts))); + parts.append(DeprecatedString::formatted("[[Configurable]]: {}", *property_descriptor.configurable)); + return Formatter<StringView>::format(builder, DeprecatedString::formatted("PropertyDescriptor {{ {} }}", DeprecatedString::join(", "sv, parts))); } }; diff --git a/Userland/Libraries/LibJS/Runtime/PropertyKey.h b/Userland/Libraries/LibJS/Runtime/PropertyKey.h index 5be70863fa..34cd41f4fe 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyKey.h +++ b/Userland/Libraries/LibJS/Runtime/PropertyKey.h @@ -48,7 +48,7 @@ public: VERIFY(index >= 0); if constexpr (NumericLimits<T>::max() >= NumericLimits<u32>::max()) { if (index >= NumericLimits<u32>::max()) { - m_string = String::number(index); + m_string = DeprecatedString::number(index); m_type = Type::String; m_string_may_be_number = false; return; @@ -65,7 +65,7 @@ public: { } - PropertyKey(String const& string) + PropertyKey(DeprecatedString const& string) : m_type(Type::String) , m_string(FlyString(string)) { @@ -164,13 +164,13 @@ public: return m_symbol; } - String to_string() const + DeprecatedString to_string() const { VERIFY(is_valid()); VERIFY(!is_symbol()); if (is_string()) return as_string(); - return String::number(as_number()); + return DeprecatedString::number(as_number()); } StringOrSymbol to_string_or_symbol() const diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index 0769300ed9..89c09dc0f9 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -37,7 +37,7 @@ static Value property_key_to_value(VM& vm, PropertyKey const& property_key) return js_string(vm, property_key.as_string()); VERIFY(property_key.is_number()); - return js_string(vm, String::number(property_key.as_number())); + return js_string(vm, DeprecatedString::number(property_key.as_number())); } // 10.5.1 [[GetPrototypeOf]] ( ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof diff --git a/Userland/Libraries/LibJS/Runtime/Reference.cpp b/Userland/Libraries/LibJS/Runtime/Reference.cpp index 05767c3325..77a6446eac 100644 --- a/Userland/Libraries/LibJS/Runtime/Reference.cpp +++ b/Userland/Libraries/LibJS/Runtime/Reference.cpp @@ -194,7 +194,7 @@ ThrowCompletionOr<bool> Reference::delete_(VM& vm) return m_base_environment->delete_binding(vm, m_name.as_string()); } -String Reference::to_string() const +DeprecatedString Reference::to_string() const { StringBuilder builder; builder.append("Reference { Base="sv); diff --git a/Userland/Libraries/LibJS/Runtime/Reference.h b/Userland/Libraries/LibJS/Runtime/Reference.h index 5e8468b3c4..f7e6aa0bf2 100644 --- a/Userland/Libraries/LibJS/Runtime/Reference.h +++ b/Userland/Libraries/LibJS/Runtime/Reference.h @@ -6,7 +6,7 @@ #pragma once -#include <AK/String.h> +#include <AK/DeprecatedString.h> #include <LibJS/Runtime/Environment.h> #include <LibJS/Runtime/EnvironmentCoordinate.h> #include <LibJS/Runtime/PropertyKey.h> @@ -127,7 +127,7 @@ public: ThrowCompletionOr<Value> get_value(VM&) const; ThrowCompletionOr<bool> delete_(VM&); - String to_string() const; + DeprecatedString to_string() const; bool is_valid_reference() const { return m_name.is_valid() || m_is_private; } diff --git a/Userland/Libraries/LibJS/Runtime/RegExpLegacyStaticProperties.h b/Userland/Libraries/LibJS/Runtime/RegExpLegacyStaticProperties.h index 678010052e..878975ab54 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpLegacyStaticProperties.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpLegacyStaticProperties.h @@ -6,8 +6,8 @@ #pragma once +#include <AK/DeprecatedString.h> #include <AK/Optional.h> -#include <AK/String.h> #include <LibJS/Forward.h> #include <LibJS/Runtime/Utf16String.h> diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp index 89cdd2a455..979081ab1d 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp @@ -16,7 +16,7 @@ namespace JS { -Result<regex::RegexOptions<ECMAScriptFlags>, String> regex_flags_from_string(StringView flags) +Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_string(StringView flags) { bool d = false, g = false, i = false, m = false, s = false, u = false, y = false, v = false; auto options = RegExpObject::default_flags; @@ -25,42 +25,42 @@ Result<regex::RegexOptions<ECMAScriptFlags>, String> regex_flags_from_string(Str switch (ch) { case 'd': if (d) - return String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); + return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); d = true; break; case 'g': if (g) - return String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); + return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); g = true; options |= regex::ECMAScriptFlags::Global; break; case 'i': if (i) - return String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); + return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); i = true; options |= regex::ECMAScriptFlags::Insensitive; break; case 'm': if (m) - return String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); + return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); m = true; options |= regex::ECMAScriptFlags::Multiline; break; case 's': if (s) - return String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); + return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); s = true; options |= regex::ECMAScriptFlags::SingleLine; break; case 'u': if (u) - return String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); + return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); u = true; options |= regex::ECMAScriptFlags::Unicode; break; case 'y': if (y) - return String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); + return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); y = true; // Now for the more interesting flag, 'sticky' actually unsets 'global', part of which is the default. options.reset_flag(regex::ECMAScriptFlags::Global); @@ -72,22 +72,22 @@ Result<regex::RegexOptions<ECMAScriptFlags>, String> regex_flags_from_string(Str break; case 'v': if (v) - return String::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); + return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch); v = true; options |= regex::ECMAScriptFlags::UnicodeSets; break; default: - return String::formatted(ErrorType::RegExpObjectBadFlag.message(), ch); + return DeprecatedString::formatted(ErrorType::RegExpObjectBadFlag.message(), ch); } } return options; } -ErrorOr<String, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets) +ErrorOr<DeprecatedString, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets) { if (unicode && unicode_sets) - return ParseRegexPatternError { String::formatted(ErrorType::RegExpObjectIncompatibleFlags.message(), 'u', 'v') }; + return ParseRegexPatternError { DeprecatedString::formatted(ErrorType::RegExpObjectIncompatibleFlags.message(), 'u', 'v') }; auto utf16_pattern = AK::utf8_to_utf16(pattern); Utf16View utf16_pattern_view { utf16_pattern }; @@ -115,7 +115,7 @@ ErrorOr<String, ParseRegexPatternError> parse_regex_pattern(StringView pattern, return builder.build(); } -ThrowCompletionOr<String> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets) +ThrowCompletionOr<DeprecatedString> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets) { auto result = parse_regex_pattern(pattern, unicode, unicode_sets); if (result.is_error()) @@ -129,7 +129,7 @@ RegExpObject* RegExpObject::create(Realm& realm) return realm.heap().allocate<RegExpObject>(realm, *realm.intrinsics().regexp_prototype()); } -RegExpObject* RegExpObject::create(Realm& realm, Regex<ECMA262> regex, String pattern, String flags) +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()); } @@ -139,7 +139,7 @@ RegExpObject::RegExpObject(Object& prototype) { } -RegExpObject::RegExpObject(Regex<ECMA262> regex, String pattern, String flags, Object& prototype) +RegExpObject::RegExpObject(Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags, Object& prototype) : Object(prototype) , m_pattern(move(pattern)) , m_flags(move(flags)) @@ -164,13 +164,13 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> RegExpObject::regexp_initialize(VM // 1. If pattern is undefined, let P be the empty String. // 2. Else, let P be ? ToString(pattern). auto pattern = pattern_value.is_undefined() - ? String::empty() + ? DeprecatedString::empty() : TRY(pattern_value.to_string(vm)); // 3. If flags is undefined, let F be the empty String. // 4. Else, let F be ? ToString(flags). auto flags = flags_value.is_undefined() - ? String::empty() + ? DeprecatedString::empty() : TRY(flags_value.to_string(vm)); // 5. If F contains any code unit other than "d", "g", "i", "m", "s", "u", or "y" or if it contains the same code unit more than once, throw a SyntaxError exception. @@ -184,7 +184,7 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> RegExpObject::regexp_initialize(VM return vm.throw_completion<SyntaxError>(parsed_flags_or_error.release_error()); auto parsed_flags = parsed_flags_or_error.release_value(); - auto parsed_pattern = String::empty(); + auto parsed_pattern = DeprecatedString::empty(); if (!pattern.is_empty()) { bool unicode = parsed_flags.has_flag_set(regex::ECMAScriptFlags::Unicode); bool unicode_sets = parsed_flags.has_flag_set(regex::ECMAScriptFlags::UnicodeSets); @@ -225,7 +225,7 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> RegExpObject::regexp_initialize(VM } // 22.2.3.2.5 EscapeRegExpPattern ( P, F ), https://tc39.es/ecma262/#sec-escaperegexppattern -String RegExpObject::escape_regexp_pattern() const +DeprecatedString RegExpObject::escape_regexp_pattern() const { // 1. Let S be a String in the form of a Pattern[~UnicodeMode] (Pattern[+UnicodeMode] if F contains "u") equivalent // to P interpreted as UTF-16 encoded Unicode code points (6.1.4), in which certain code points are escaped as diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.h b/Userland/Libraries/LibJS/Runtime/RegExpObject.h index 4f9162ac02..144dc77f5c 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.h @@ -16,12 +16,12 @@ namespace JS { ThrowCompletionOr<NonnullGCPtr<RegExpObject>> regexp_create(VM&, Value pattern, Value flags); ThrowCompletionOr<NonnullGCPtr<RegExpObject>> regexp_alloc(VM&, FunctionObject& new_target); -Result<regex::RegexOptions<ECMAScriptFlags>, String> regex_flags_from_string(StringView flags); +Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_string(StringView flags); struct ParseRegexPatternError { - String error; + DeprecatedString error; }; -ErrorOr<String, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets); -ThrowCompletionOr<String> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets); +ErrorOr<DeprecatedString, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets); +ThrowCompletionOr<DeprecatedString> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets); class RegExpObject : public Object { JS_OBJECT(RegExpObject, Object); @@ -37,16 +37,16 @@ public: }; static RegExpObject* create(Realm&); - static RegExpObject* create(Realm&, Regex<ECMA262> regex, String pattern, String flags); + static RegExpObject* create(Realm&, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags); ThrowCompletionOr<NonnullGCPtr<RegExpObject>> regexp_initialize(VM&, Value pattern, Value flags); - String escape_regexp_pattern() const; + DeprecatedString escape_regexp_pattern() const; virtual void initialize(Realm&) override; virtual ~RegExpObject() override = default; - String const& pattern() const { return m_pattern; } - String const& flags() const { return m_flags; } + DeprecatedString const& pattern() const { return m_pattern; } + DeprecatedString const& flags() const { return m_flags; } Regex<ECMA262> const& regex() { return *m_regex; } Regex<ECMA262> const& regex() const { return *m_regex; } Realm& realm() { return *m_realm; } @@ -57,10 +57,10 @@ public: private: RegExpObject(Object& prototype); - RegExpObject(Regex<ECMA262> regex, String pattern, String flags, Object& prototype); + RegExpObject(Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags, Object& prototype); - String m_pattern; - String m_flags; + DeprecatedString m_pattern; + DeprecatedString m_flags; bool m_legacy_features_enabled { false }; // [[LegacyFeaturesEnabled]] // Note: This is initialized in RegExpAlloc, but will be non-null afterwards GCPtr<Realm> m_realm; // [[Realm]] diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp index 3738d38ecb..c7ec95085e 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp @@ -765,7 +765,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace) // j. Let namedCaptures be ? Get(result, "groups"). auto named_captures = TRY(result->get(vm.names.groups)); - String replacement; + DeprecatedString replacement; // k. If functionalReplace is true, then if (replace_value.is_function()) { @@ -920,7 +920,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split) // 8. If flags contains "y", let newFlags be flags. // 9. Else, let newFlags be the string-concatenation of flags and "y". - auto new_flags = flags.find('y').has_value() ? move(flags) : String::formatted("{}y", flags); + auto new_flags = flags.find('y').has_value() ? move(flags) : DeprecatedString::formatted("{}y", flags); // 10. Let splitter be ? Construct(C, « rx, newFlags »). auto* splitter = TRY(construct(vm, *constructor, regexp_object, js_string(vm, move(new_flags)))); @@ -1085,7 +1085,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::to_string) // 5. Let result be the string-concatenation of "/", pattern, "/", and flags. // 6. Return result. - return js_string(vm, String::formatted("/{}/{}", pattern, flags)); + return js_string(vm, DeprecatedString::formatted("/{}/{}", pattern, flags)); } // B.2.4.1 RegExp.prototype.compile ( pattern, flags ), https://tc39.es/ecma262/#sec-regexp.prototype.compile diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp index cf85dd83b1..9db09517f6 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp @@ -83,7 +83,7 @@ ThrowCompletionOr<void> copy_name_and_length(VM& vm, FunctionObject& function, F // 7. If Type(targetName) is not String, set targetName to the empty String. if (!target_name.is_string()) - target_name = js_string(vm, String::empty()); + target_name = js_string(vm, DeprecatedString::empty()); // 8. Perform SetFunctionName(F, targetName, prefix). function.set_function_name({ target_name.as_string().string() }, move(prefix)); @@ -202,7 +202,7 @@ ThrowCompletionOr<Value> perform_shadow_realm_eval(VM& vm, StringView source_tex } // 3.1.4 ShadowRealmImportValue ( specifierString: a String, exportNameString: a String, callerRealm: a Realm Record, evalRealm: a Realm Record, evalContext: an execution context, ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealmimportvalue -ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, String specifier_string, String export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context) +ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, DeprecatedString specifier_string, DeprecatedString export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context) { // FIXME: evalRealm isn't being used anywhere in this AO (spec issue) (void)eval_realm; diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealm.h b/Userland/Libraries/LibJS/Runtime/ShadowRealm.h index f355d3f700..2496500963 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealm.h +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealm.h @@ -36,7 +36,7 @@ private: ThrowCompletionOr<void> copy_name_and_length(VM&, FunctionObject& function, FunctionObject& target, Optional<StringView> prefix = {}, Optional<unsigned> arg_count = {}); ThrowCompletionOr<Value> perform_shadow_realm_eval(VM&, StringView source_text, Realm& caller_realm, Realm& eval_realm); -ThrowCompletionOr<Value> shadow_realm_import_value(VM&, String specifier_string, String export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context); +ThrowCompletionOr<Value> shadow_realm_import_value(VM&, DeprecatedString specifier_string, DeprecatedString export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context); ThrowCompletionOr<Value> get_wrapped_value(VM&, Realm& caller_realm, Value); } diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index 4702ff63cb..13299a6197 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -79,7 +79,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw) StringBuilder builder; for (size_t i = 0; i < literal_segments; ++i) { - auto next_key = String::number(i); + auto next_key = DeprecatedString::number(i); auto next_segment_value = TRY(raw->get(next_key)); auto next_segment = TRY(next_segment_value.to_string(vm)); diff --git a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp index abd8e8f62f..db505c4db7 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp @@ -10,12 +10,12 @@ namespace JS { -StringIterator* StringIterator::create(Realm& realm, String string) +StringIterator* StringIterator::create(Realm& realm, DeprecatedString string) { return realm.heap().allocate<StringIterator>(realm, move(string), *realm.intrinsics().string_iterator_prototype()); } -StringIterator::StringIterator(String string, Object& prototype) +StringIterator::StringIterator(DeprecatedString string, Object& prototype) : Object(prototype) , m_string(move(string)) , m_iterator(Utf8View(m_string).begin()) diff --git a/Userland/Libraries/LibJS/Runtime/StringIterator.h b/Userland/Libraries/LibJS/Runtime/StringIterator.h index 4760cd73b2..f2869fa53f 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIterator.h +++ b/Userland/Libraries/LibJS/Runtime/StringIterator.h @@ -15,7 +15,7 @@ class StringIterator final : public Object { JS_OBJECT(StringIterator, Object); public: - static StringIterator* create(Realm&, String string); + static StringIterator* create(Realm&, DeprecatedString string); virtual ~StringIterator() override = default; @@ -23,11 +23,11 @@ public: bool done() const { return m_done; } private: - explicit StringIterator(String string, Object& prototype); + explicit StringIterator(DeprecatedString string, Object& prototype); friend class StringIteratorPrototype; - String m_string; + DeprecatedString m_string; Utf8CodePointIterator m_iterator; bool m_done { false }; }; diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.cpp b/Userland/Libraries/LibJS/Runtime/StringObject.cpp index 702b36eea4..eb186653e6 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringObject.cpp @@ -138,14 +138,14 @@ ThrowCompletionOr<MarkedVector<Value>> StringObject::internal_own_property_keys( // 5. For each integer i starting with 0 such that i < len, in ascending order, do for (size_t i = 0; i < length; ++i) { // a. Add ! ToString(𝔽(i)) as the last element of keys. - keys.append(js_string(vm, String::number(i))); + keys.append(js_string(vm, DeprecatedString::number(i))); } // 6. For each own property key P of O such that P is an array index and ! ToIntegerOrInfinity(P) ≥ len, in ascending numeric index order, do for (auto& entry : indexed_properties()) { if (entry.index() >= length) { // a. Add P as the last element of keys. - keys.append(js_string(vm, String::number(entry.index()))); + keys.append(js_string(vm, DeprecatedString::number(entry.index()))); } } diff --git a/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h b/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h index a8f5ae6b2a..f6d41cacfa 100644 --- a/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h +++ b/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h @@ -22,7 +22,7 @@ public: { } - StringOrSymbol(String const& string) + StringOrSymbol(DeprecatedString const& string) : StringOrSymbol(FlyString(string)) { } @@ -74,7 +74,7 @@ public: return reinterpret_cast<Symbol const*>(bits() & ~1ul); } - String to_display_string() const + DeprecatedString to_display_string() const { if (is_string()) return as_string(); diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index 6d540def5b..fbbc8bc3fe 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -33,7 +33,7 @@ namespace JS { -static ThrowCompletionOr<String> ak_string_from(VM& vm) +static ThrowCompletionOr<DeprecatedString> ak_string_from(VM& vm) { auto this_value = TRY(require_object_coercible(vm, vm.this_value())); return TRY(this_value.to_string(vm)); @@ -131,7 +131,7 @@ CodePoint code_point_at(Utf16View const& string, size_t position) } StringPrototype::StringPrototype(Realm& realm) - : StringObject(*js_string(realm.vm(), String::empty()), *realm.intrinsics().object_prototype()) + : StringObject(*js_string(realm.vm(), DeprecatedString::empty()), *realm.intrinsics().object_prototype()) { } @@ -246,7 +246,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::char_at) auto string = TRY(utf16_string_from(vm)); auto position = TRY(vm.argument(0).to_integer_or_infinity(vm)); if (position < 0 || position >= string.length_in_code_units()) - return js_string(vm, String::empty()); + return js_string(vm, DeprecatedString::empty()); return js_string(vm, string.substring_view(position, 1)); } @@ -487,7 +487,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::normalize) // 3. If form is undefined, let f be "NFC". // 4. Else, let f be ? ToString(form). - String form = "NFC"; + DeprecatedString form = "NFC"; auto form_value = vm.argument(0); if (!form_value.is_undefined()) form = TRY(form_value.to_string(vm)); @@ -536,8 +536,8 @@ static ThrowCompletionOr<Value> pad_string(VM& vm, Utf16String string, PadPlacem auto filler = filler_builder.build(); auto formatted = placement == PadPlacement::Start - ? String::formatted("{}{}", filler, string.view()) - : String::formatted("{}{}", string.view(), filler); + ? DeprecatedString::formatted("{}{}", filler, string.view()) + : DeprecatedString::formatted("{}{}", string.view(), filler); return js_string(vm, move(formatted)); } @@ -569,11 +569,11 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::repeat) return vm.throw_completion<RangeError>(ErrorType::StringRepeatCountMustBe, "finite"); if (n == 0) - return js_string(vm, String::empty()); + return js_string(vm, DeprecatedString::empty()); // NOTE: This is an optimization, it is not required by the specification but it produces equivalent behavior if (string.is_empty()) - return js_string(vm, String::empty()); + return js_string(vm, DeprecatedString::empty()); StringBuilder builder; for (size_t i = 0; i < n; ++i) @@ -606,7 +606,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace) return js_string(vm, move(string)); auto preserved = string.substring_view(0, position.value()); - String replacement; + DeprecatedString replacement; if (replace_value.is_function()) { auto result = TRY(call(vm, replace_value.as_function(), js_undefined(), js_string(vm, search_string), Value(position.value()), js_string(vm, string))); @@ -671,7 +671,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace_all) for (auto position : match_positions) { auto preserved = string.substring_view(end_of_last_match, position - end_of_last_match); - String replacement; + DeprecatedString replacement; if (replace_value.is_function()) { auto result = TRY(call(vm, replace_value.as_function(), js_undefined(), js_string(vm, search_string), Value(position), js_string(vm, string))); @@ -734,7 +734,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::slice) } if (int_start >= int_end) - return js_string(vm, String::empty()); + return js_string(vm, DeprecatedString::empty()); return js_string(vm, string.substring_view(int_start, int_end - int_start)); } @@ -876,7 +876,7 @@ enum class TargetCase { }; // 19.1.2.1 TransformCase ( S, locales, targetCase ), https://tc39.es/ecma402/#sec-transform-case -static ThrowCompletionOr<String> transform_case(VM& vm, StringView string, Value locales, TargetCase target_case) +static ThrowCompletionOr<DeprecatedString> transform_case(VM& vm, StringView string, Value locales, TargetCase target_case) { // 1. Let requestedLocales be ? CanonicalizeLocaleList(locales). auto requested_locales = TRY(Intl::canonicalize_locale_list(vm, locales)); @@ -909,7 +909,7 @@ static ThrowCompletionOr<String> transform_case(VM& vm, StringView string, Value // 8. Let codePoints be StringToCodePoints(S). - String new_code_points; + DeprecatedString new_code_points; switch (target_case) { // 9. If targetCase is lower, then @@ -1021,7 +1021,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_well_formed) return js_string(vm, result.build()); } -ThrowCompletionOr<String> trim_string(VM& vm, Value input_value, TrimMode where) +ThrowCompletionOr<DeprecatedString> trim_string(VM& vm, Value input_value, TrimMode where) { // 1. Let str be ? RequireObjectCoercible(string). auto input_string = TRY(require_object_coercible(vm, input_value)); @@ -1108,14 +1108,14 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::substr) auto int_end = min((i32)(int_start + int_length), size); if (int_start >= int_end) - return js_string(vm, String::empty()); + return js_string(vm, DeprecatedString::empty()); // 11. Return the substring of S from intStart to intEnd. return js_string(vm, string.substring_view(int_start, int_end - int_start)); } // B.2.2.2.1 CreateHTML ( string, tag, attribute, value ), https://tc39.es/ecma262/#sec-createhtml -static ThrowCompletionOr<Value> create_html(VM& vm, Value string, String const& tag, String const& attribute, Value value) +static ThrowCompletionOr<Value> create_html(VM& vm, Value string, DeprecatedString const& tag, DeprecatedString const& attribute, Value value) { TRY(require_object_coercible(vm, string)); auto str = TRY(string.to_string(vm)); @@ -1147,25 +1147,25 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::anchor) // B.2.2.3 String.prototype.big ( ), https://tc39.es/ecma262/#sec-string.prototype.big JS_DEFINE_NATIVE_FUNCTION(StringPrototype::big) { - return create_html(vm, vm.this_value(), "big", String::empty(), Value()); + return create_html(vm, vm.this_value(), "big", DeprecatedString::empty(), Value()); } // B.2.2.4 String.prototype.blink ( ), https://tc39.es/ecma262/#sec-string.prototype.blink JS_DEFINE_NATIVE_FUNCTION(StringPrototype::blink) { - return create_html(vm, vm.this_value(), "blink", String::empty(), Value()); + return create_html(vm, vm.this_value(), "blink", DeprecatedString::empty(), Value()); } // B.2.2.5 String.prototype.bold ( ), https://tc39.es/ecma262/#sec-string.prototype.bold JS_DEFINE_NATIVE_FUNCTION(StringPrototype::bold) { - return create_html(vm, vm.this_value(), "b", String::empty(), Value()); + return create_html(vm, vm.this_value(), "b", DeprecatedString::empty(), Value()); } // B.2.2.6 String.prototype.fixed ( ), https://tc39.es/ecma262/#sec-string.prototype.fixed JS_DEFINE_NATIVE_FUNCTION(StringPrototype::fixed) { - return create_html(vm, vm.this_value(), "tt", String::empty(), Value()); + return create_html(vm, vm.this_value(), "tt", DeprecatedString::empty(), Value()); } // B.2.2.7 String.prototype.fontcolor ( color ), https://tc39.es/ecma262/#sec-string.prototype.fontcolor @@ -1183,7 +1183,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::fontsize) // B.2.2.9 String.prototype.italics ( ), https://tc39.es/ecma262/#sec-string.prototype.italics JS_DEFINE_NATIVE_FUNCTION(StringPrototype::italics) { - return create_html(vm, vm.this_value(), "i", String::empty(), Value()); + return create_html(vm, vm.this_value(), "i", DeprecatedString::empty(), Value()); } // B.2.2.10 String.prototype.link ( url ), https://tc39.es/ecma262/#sec-string.prototype.link @@ -1195,25 +1195,25 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::link) // B.2.2.11 String.prototype.small ( ), https://tc39.es/ecma262/#sec-string.prototype.small JS_DEFINE_NATIVE_FUNCTION(StringPrototype::small) { - return create_html(vm, vm.this_value(), "small", String::empty(), Value()); + return create_html(vm, vm.this_value(), "small", DeprecatedString::empty(), Value()); } // B.2.2.12 String.prototype.strike ( ), https://tc39.es/ecma262/#sec-string.prototype.strike JS_DEFINE_NATIVE_FUNCTION(StringPrototype::strike) { - return create_html(vm, vm.this_value(), "strike", String::empty(), Value()); + return create_html(vm, vm.this_value(), "strike", DeprecatedString::empty(), Value()); } // B.2.2.13 String.prototype.sub ( ), https://tc39.es/ecma262/#sec-string.prototype.sub JS_DEFINE_NATIVE_FUNCTION(StringPrototype::sub) { - return create_html(vm, vm.this_value(), "sub", String::empty(), Value()); + return create_html(vm, vm.this_value(), "sub", DeprecatedString::empty(), Value()); } // B.2.2.14 String.prototype.sup ( ), https://tc39.es/ecma262/#sec-string.prototype.sup JS_DEFINE_NATIVE_FUNCTION(StringPrototype::sup) { - return create_html(vm, vm.this_value(), "sup", String::empty(), Value()); + return create_html(vm, vm.this_value(), "sup", DeprecatedString::empty(), Value()); } } diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.h b/Userland/Libraries/LibJS/Runtime/StringPrototype.h index 76670eb3a8..71ac983a5e 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.h @@ -19,7 +19,7 @@ struct CodePoint { CodePoint code_point_at(Utf16View const& string, size_t position); static constexpr Utf8View whitespace_characters = Utf8View("\x09\x0A\x0B\x0C\x0D\x20\xC2\xA0\xE1\x9A\x80\xE2\x80\x80\xE2\x80\x81\xE2\x80\x82\xE2\x80\x83\xE2\x80\x84\xE2\x80\x85\xE2\x80\x86\xE2\x80\x87\xE2\x80\x88\xE2\x80\x89\xE2\x80\x8A\xE2\x80\xAF\xE2\x81\x9F\xE3\x80\x80\xE2\x80\xA8\xE2\x80\xA9\xEF\xBB\xBF"sv); -ThrowCompletionOr<String> trim_string(VM&, Value string, TrimMode where); +ThrowCompletionOr<DeprecatedString> trim_string(VM&, Value string, TrimMode where); class StringPrototype final : public StringObject { JS_OBJECT(StringPrototype, StringObject); diff --git a/Userland/Libraries/LibJS/Runtime/Symbol.cpp b/Userland/Libraries/LibJS/Runtime/Symbol.cpp index 6821fe719a..61126cabef 100644 --- a/Userland/Libraries/LibJS/Runtime/Symbol.cpp +++ b/Userland/Libraries/LibJS/Runtime/Symbol.cpp @@ -10,18 +10,18 @@ namespace JS { -Symbol::Symbol(Optional<String> description, bool is_global) +Symbol::Symbol(Optional<DeprecatedString> description, bool is_global) : m_description(move(description)) , m_is_global(is_global) { } -Symbol* js_symbol(Heap& heap, Optional<String> description, bool is_global) +Symbol* js_symbol(Heap& heap, Optional<DeprecatedString> description, bool is_global) { return heap.allocate_without_realm<Symbol>(move(description), is_global); } -Symbol* js_symbol(VM& vm, Optional<String> description, bool is_global) +Symbol* js_symbol(VM& vm, Optional<DeprecatedString> description, bool is_global) { return js_symbol(vm.heap(), move(description), is_global); } diff --git a/Userland/Libraries/LibJS/Runtime/Symbol.h b/Userland/Libraries/LibJS/Runtime/Symbol.h index 3cde01bd1b..3ff1c91f96 100644 --- a/Userland/Libraries/LibJS/Runtime/Symbol.h +++ b/Userland/Libraries/LibJS/Runtime/Symbol.h @@ -6,7 +6,7 @@ #pragma once -#include <AK/String.h> +#include <AK/DeprecatedString.h> #include <AK/StringView.h> #include <LibJS/Heap/Cell.h> @@ -20,19 +20,19 @@ class Symbol final : public Cell { public: virtual ~Symbol() = default; - String description() const { return m_description.value_or(""); } - Optional<String> const& raw_description() const { return m_description; } + DeprecatedString description() const { return m_description.value_or(""); } + Optional<DeprecatedString> const& raw_description() const { return m_description; } bool is_global() const { return m_is_global; } - String to_string() const { return String::formatted("Symbol({})", description()); } + DeprecatedString to_string() const { return DeprecatedString::formatted("Symbol({})", description()); } private: - Symbol(Optional<String>, bool); + Symbol(Optional<DeprecatedString>, bool); - Optional<String> m_description; + Optional<DeprecatedString> m_description; bool m_is_global; }; -Symbol* js_symbol(Heap&, Optional<String> description, bool is_global); -Symbol* js_symbol(VM&, Optional<String> description, bool is_global); +Symbol* js_symbol(Heap&, Optional<DeprecatedString> description, bool is_global); +Symbol* js_symbol(VM&, Optional<DeprecatedString> description, bool is_global); } diff --git a/Userland/Libraries/LibJS/Runtime/SymbolObject.h b/Userland/Libraries/LibJS/Runtime/SymbolObject.h index 7bbe829034..afc0b23519 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolObject.h +++ b/Userland/Libraries/LibJS/Runtime/SymbolObject.h @@ -22,7 +22,7 @@ public: Symbol& primitive_symbol() { return m_symbol; } Symbol const& primitive_symbol() const { return m_symbol; } - String description() const { return m_symbol.description(); } + DeprecatedString description() const { return m_symbol.description(); } bool is_global() const { return m_symbol.is_global(); } private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index 698d9d5076..af5f8fde25 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -156,7 +156,7 @@ ThrowCompletionOr<Value> get_option(VM& vm, Object const& options, PropertyKey c } // 13.4 ToTemporalOverflow ( options ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaloverflow -ThrowCompletionOr<String> to_temporal_overflow(VM& vm, Object const* options) +ThrowCompletionOr<DeprecatedString> to_temporal_overflow(VM& vm, Object const* options) { // 1. If options is undefined, return "constrain". if (options == nullptr) @@ -170,7 +170,7 @@ ThrowCompletionOr<String> to_temporal_overflow(VM& vm, Object const* options) } // 13.5 ToTemporalDisambiguation ( options ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaldisambiguation -ThrowCompletionOr<String> to_temporal_disambiguation(VM& vm, Object const* options) +ThrowCompletionOr<DeprecatedString> to_temporal_disambiguation(VM& vm, Object const* options) { // 1. If options is undefined, return "compatible". if (options == nullptr) @@ -184,7 +184,7 @@ ThrowCompletionOr<String> to_temporal_disambiguation(VM& vm, Object const* optio } // 13.6 ToTemporalRoundingMode ( normalizedOptions, fallback ), https://tc39.es/proposal-temporal/#sec-temporal-totemporalroundingmode -ThrowCompletionOr<String> to_temporal_rounding_mode(VM& vm, Object const& normalized_options, String const& fallback) +ThrowCompletionOr<DeprecatedString> to_temporal_rounding_mode(VM& vm, Object const& normalized_options, DeprecatedString const& fallback) { // 1. Return ? GetOption(normalizedOptions, "roundingMode", "string", « "ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven" », fallback). auto option = TRY(get_option( @@ -207,7 +207,7 @@ ThrowCompletionOr<String> to_temporal_rounding_mode(VM& vm, Object const& normal } // 13.7 NegateTemporalRoundingMode ( roundingMode ), https://tc39.es/proposal-temporal/#sec-temporal-negatetemporalroundingmode -StringView negate_temporal_rounding_mode(String const& rounding_mode) +StringView negate_temporal_rounding_mode(DeprecatedString const& rounding_mode) { // 1. If roundingMode is "ceil", return "floor". if (rounding_mode == "ceil"sv) @@ -230,7 +230,7 @@ StringView negate_temporal_rounding_mode(String const& rounding_mode) } // 13.8 ToTemporalOffset ( options, fallback ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaloffset -ThrowCompletionOr<String> to_temporal_offset(VM& vm, Object const* options, String const& fallback) +ThrowCompletionOr<DeprecatedString> to_temporal_offset(VM& vm, Object const* options, DeprecatedString const& fallback) { // 1. If options is undefined, return fallback. if (options == nullptr) @@ -244,7 +244,7 @@ ThrowCompletionOr<String> to_temporal_offset(VM& vm, Object const* options, Stri } // 13.9 ToCalendarNameOption ( normalizedOptions ), https://tc39.es/proposal-temporal/#sec-temporal-tocalendarnameoption -ThrowCompletionOr<String> to_calendar_name_option(VM& vm, Object const& normalized_options) +ThrowCompletionOr<DeprecatedString> to_calendar_name_option(VM& vm, Object const& normalized_options) { // 1. Return ? GetOption(normalizedOptions, "calendarName", "string", « "auto", "always", "never", "critical" », "auto"). auto option = TRY(get_option(vm, normalized_options, vm.names.calendarName, OptionType::String, { "auto"sv, "always"sv, "never"sv, "critical"sv }, "auto"sv)); @@ -254,7 +254,7 @@ ThrowCompletionOr<String> to_calendar_name_option(VM& vm, Object const& normaliz } // 13.10 ToTimeZoneNameOption ( normalizedOptions ), https://tc39.es/proposal-temporal/#sec-temporal-totimezonenameoption -ThrowCompletionOr<String> to_time_zone_name_option(VM& vm, Object const& normalized_options) +ThrowCompletionOr<DeprecatedString> to_time_zone_name_option(VM& vm, Object const& normalized_options) { // 1. Return ? GetOption(normalizedOptions, "timeZoneName", "string", « "auto", "never", "critical" », "auto"). auto option = TRY(get_option(vm, normalized_options, vm.names.timeZoneName, OptionType::String, { "auto"sv, "never"sv, "critical"sv }, "auto"sv)); @@ -264,7 +264,7 @@ ThrowCompletionOr<String> to_time_zone_name_option(VM& vm, Object const& normali } // 13.11 ToShowOffsetOption ( normalizedOptions ), https://tc39.es/proposal-temporal/#sec-temporal-toshowoffsetoption -ThrowCompletionOr<String> to_show_offset_option(VM& vm, Object const& normalized_options) +ThrowCompletionOr<DeprecatedString> to_show_offset_option(VM& vm, Object const& normalized_options) { // 1. Return ? GetOption(normalizedOptions, "offset", "string", « "auto", "never" », "auto"). auto option = TRY(get_option(vm, normalized_options, vm.names.offset, OptionType::String, { "auto"sv, "never"sv }, "auto"sv)); @@ -458,7 +458,7 @@ static Vector<TemporalUnit> temporal_units = { }; // 13.15 GetTemporalUnit ( normalizedOptions, key, unitGroup, default [ , extraValues ] ), https://tc39.es/proposal-temporal/#sec-temporal-gettemporalunit -ThrowCompletionOr<Optional<String>> get_temporal_unit(VM& vm, Object const& normalized_options, PropertyKey const& key, UnitGroup unit_group, TemporalUnitDefault const& default_, Vector<StringView> const& extra_values) +ThrowCompletionOr<Optional<DeprecatedString>> get_temporal_unit(VM& vm, Object const& normalized_options, PropertyKey const& key, UnitGroup unit_group, TemporalUnitDefault const& default_, Vector<StringView> const& extra_values) { // 1. Let singularNames be a new empty List. Vector<StringView> singular_names; @@ -527,10 +527,10 @@ ThrowCompletionOr<Optional<String>> get_temporal_unit(VM& vm, Object const& norm // 10. If value is undefined and default is required, throw a RangeError exception. if (option_value.is_undefined() && default_.has<TemporalUnitRequired>()) - return vm.throw_completion<RangeError>(ErrorType::IsUndefined, String::formatted("{} option value", key.as_string())); + return vm.throw_completion<RangeError>(ErrorType::IsUndefined, DeprecatedString::formatted("{} option value", key.as_string())); - Optional<String> value = option_value.is_undefined() - ? Optional<String> {} + Optional<DeprecatedString> value = option_value.is_undefined() + ? Optional<DeprecatedString> {} : option_value.as_string().string(); // 11. If value is listed in the Plural column of Table 13, then @@ -735,7 +735,7 @@ StringView larger_of_two_temporal_units(StringView unit1, StringView unit2) } // 13.18 MergeLargestUnitOption ( options, largestUnit ), https://tc39.es/proposal-temporal/#sec-temporal-mergelargestunitoption -ThrowCompletionOr<Object*> merge_largest_unit_option(VM& vm, Object const& options, String largest_unit) +ThrowCompletionOr<Object*> merge_largest_unit_option(VM& vm, Object const& options, DeprecatedString largest_unit) { auto& realm = *vm.current_realm(); @@ -824,7 +824,7 @@ ThrowCompletionOr<void> reject_object_with_calendar_or_time_zone(VM& vm, Object& } // 13.21 FormatSecondsStringPart ( second, millisecond, microsecond, nanosecond, precision ), https://tc39.es/proposal-temporal/#sec-temporal-formatsecondsstringpart -String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision) +DeprecatedString format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision) { // 1. Assert: second, millisecond, microsecond, and nanosecond are integers. @@ -834,15 +834,15 @@ String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u // 2. If precision is "minute", return "". if (precision.has<StringView>() && precision.get<StringView>() == "minute"sv) - return String::empty(); + return DeprecatedString::empty(); // 3. Let secondsString be the string-concatenation of the code unit 0x003A (COLON) and ToZeroPaddedDecimalString(second, 2). - auto seconds_string = String::formatted(":{:02}", second); + auto seconds_string = DeprecatedString::formatted(":{:02}", second); // 4. Let fraction be millisecond × 10^6 + microsecond × 10^3 + nanosecond. u32 fraction = millisecond * 1'000'000 + microsecond * 1'000 + nanosecond; - String fraction_string; + DeprecatedString fraction_string; // 5. If precision is "auto", then if (precision.has<StringView>() && precision.get<StringView>() == "auto"sv) { @@ -851,7 +851,7 @@ String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u return seconds_string; // b. Set fraction to ToZeroPaddedDecimalString(fraction, 9). - fraction_string = String::formatted("{:09}", fraction); + fraction_string = DeprecatedString::formatted("{:09}", fraction); // c. Set fraction to the longest possible substring of fraction starting at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO). fraction_string = fraction_string.trim("0"sv, TrimMode::Right); @@ -863,14 +863,14 @@ String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u return seconds_string; // b. Set fraction to ToZeroPaddedDecimalString(fraction, 9) - fraction_string = String::formatted("{:09}", fraction); + fraction_string = DeprecatedString::formatted("{:09}", fraction); // c. Set fraction to the substring of fraction from 0 to precision. fraction_string = fraction_string.substring(0, precision.get<u8>()); } // 7. Return the string-concatenation of secondsString, the code unit 0x002E (FULL STOP), and fraction. - return String::formatted("{}.{}", seconds_string, fraction_string); + return DeprecatedString::formatted("{}.{}", seconds_string, fraction_string); } // 13.23 GetUnsignedRoundingMode ( roundingMode, isNegative ), https://tc39.es/proposal-temporal/#sec-temporal-getunsignedroundingmode @@ -1225,11 +1225,11 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM& vm, ParseResult const& pa auto f_seconds = parse_result.time_fraction; // 5. If the first code point of year is U+2212 (MINUS SIGN), replace the first code point with U+002D (HYPHEN-MINUS). - Optional<String> normalized_year; + Optional<DeprecatedString> normalized_year; if (year.has_value()) { normalized_year = year->starts_with("\xE2\x88\x92"sv) - ? String::formatted("-{}", year->substring_view(3)) - : String { *year }; + ? DeprecatedString::formatted("-{}", year->substring_view(3)) + : DeprecatedString { *year }; } // 6. Let yearMV be ! ToIntegerOrInfinity(CodePointsToString(year)). @@ -1272,7 +1272,7 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM& vm, ParseResult const& pa auto f_seconds_digits = f_seconds->substring_view(1); // b. Let fSecondsDigitsExtended be the string-concatenation of fSecondsDigits and "000000000". - auto f_seconds_digits_extended = String::formatted("{}000000000", f_seconds_digits); + auto f_seconds_digits_extended = DeprecatedString::formatted("{}000000000", f_seconds_digits); // c. Let millisecond be the substring of fSecondsDigitsExtended from 0 to 3. auto millisecond = f_seconds_digits_extended.substring(0, 3); @@ -1342,7 +1342,7 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM& vm, ParseResult const& pa } // 23. Let calendar be undefined. - Optional<String> calendar; + Optional<DeprecatedString> calendar; // 24. For each Annotation Parse Node annotation contained within parseResult, do for (auto const& annotation : parse_result.annotations) { @@ -1373,7 +1373,7 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM& vm, ParseResult const& pa } // 13.29 ParseTemporalInstantString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalinstantstring -ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM& vm, String const& iso_string) +ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM& vm, DeprecatedString const& iso_string) { // 1. If ParseText(StringToCodePoints(isoString), TemporalInstantString) is a List of errors, throw a RangeError exception. auto parse_result = parse_iso8601(Production::TemporalInstantString, iso_string); @@ -1384,7 +1384,7 @@ ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM& vm, String auto result = TRY(parse_iso_date_time(vm, *parse_result)); // 3. Let offsetString be result.[[TimeZone]].[[OffsetString]]. - Optional<String> offset_string = result.time_zone.offset_string; + Optional<DeprecatedString> offset_string = result.time_zone.offset_string; // 4. If result.[[TimeZone]].[[Z]] is true, then if (result.time_zone.z) { @@ -1400,7 +1400,7 @@ ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM& vm, String } // 13.30 ParseTemporalZonedDateTimeString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalzoneddatetimestring -ThrowCompletionOr<ISODateTime> parse_temporal_zoned_date_time_string(VM& vm, String const& iso_string) +ThrowCompletionOr<ISODateTime> parse_temporal_zoned_date_time_string(VM& vm, DeprecatedString const& iso_string) { // 1. If ParseText(StringToCodePoints(isoString), TemporalZonedDateTimeString) is a List of errors, throw a RangeError exception. auto parse_result = parse_iso8601(Production::TemporalZonedDateTimeString, iso_string); @@ -1412,7 +1412,7 @@ ThrowCompletionOr<ISODateTime> parse_temporal_zoned_date_time_string(VM& vm, Str } // 13.31 ParseTemporalCalendarString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalcalendarstring -ThrowCompletionOr<String> parse_temporal_calendar_string(VM& vm, String const& iso_string) +ThrowCompletionOr<DeprecatedString> parse_temporal_calendar_string(VM& vm, DeprecatedString const& iso_string) { // 1. Let parseResult be Completion(ParseISODateTime(isoString)). auto parse_result_completion = parse_iso_date_time(vm, iso_string); @@ -1444,7 +1444,7 @@ ThrowCompletionOr<String> parse_temporal_calendar_string(VM& vm, String const& i } // 13.32 ParseTemporalDateString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaldatestring -ThrowCompletionOr<TemporalDate> parse_temporal_date_string(VM& vm, String const& iso_string) +ThrowCompletionOr<TemporalDate> parse_temporal_date_string(VM& vm, DeprecatedString const& iso_string) { // 1. Let parts be ? ParseTemporalDateTimeString(isoString). auto parts = TRY(parse_temporal_date_time_string(vm, iso_string)); @@ -1454,7 +1454,7 @@ ThrowCompletionOr<TemporalDate> parse_temporal_date_string(VM& vm, String const& } // 13.33 ParseTemporalDateTimeString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaldatetimestring -ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(VM& vm, String const& iso_string) +ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(VM& vm, DeprecatedString const& iso_string) { // 1. Let parseResult be ParseText(StringToCodePoints(isoString), TemporalDateTimeString). auto parse_result = parse_iso8601(Production::TemporalDateTimeString, iso_string); @@ -1472,7 +1472,7 @@ ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(VM& vm, String co } // 13.34 ParseTemporalDurationString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaldurationstring -ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM& vm, String const& iso_string) +ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM& vm, DeprecatedString const& iso_string) { // 1. Let duration be ParseText(StringToCodePoints(isoString), TemporalDurationString). auto parse_result = parse_iso8601(Production::TemporalDurationString, iso_string); @@ -1608,7 +1608,7 @@ ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM& vm, String } // 13.35 ParseTemporalMonthDayString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalmonthdaystring -ThrowCompletionOr<TemporalMonthDay> parse_temporal_month_day_string(VM& vm, String const& iso_string) +ThrowCompletionOr<TemporalMonthDay> parse_temporal_month_day_string(VM& vm, DeprecatedString const& iso_string) { // 1. Let parseResult be ParseText(StringToCodePoints(isoString), TemporalMonthDayString). auto parse_result = parse_iso8601(Production::TemporalMonthDayString, iso_string); @@ -1638,7 +1638,7 @@ ThrowCompletionOr<TemporalMonthDay> parse_temporal_month_day_string(VM& vm, Stri } // 13.36 ParseTemporalRelativeToString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalrelativetostring -ThrowCompletionOr<ISODateTime> parse_temporal_relative_to_string(VM& vm, String const& iso_string) +ThrowCompletionOr<ISODateTime> parse_temporal_relative_to_string(VM& vm, DeprecatedString const& iso_string) { // 1. Let parseResult be ParseText(StringToCodePoints(isoString), TemporalDateTimeString). auto parse_result = parse_iso8601(Production::TemporalDateTimeString, iso_string); @@ -1656,7 +1656,7 @@ ThrowCompletionOr<ISODateTime> parse_temporal_relative_to_string(VM& vm, String } // 13.37 ParseTemporalTimeString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaltimestring -ThrowCompletionOr<TemporalTime> parse_temporal_time_string(VM& vm, String const& iso_string) +ThrowCompletionOr<TemporalTime> parse_temporal_time_string(VM& vm, DeprecatedString const& iso_string) { // 1. Let parseResult be ParseText(StringToCodePoints(isoString), TemporalTimeString). auto parse_result = parse_iso8601(Production::TemporalTimeString, iso_string); @@ -1677,7 +1677,7 @@ ThrowCompletionOr<TemporalTime> parse_temporal_time_string(VM& vm, String const& } // 13.38 ParseTemporalTimeZoneString ( timeZoneString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaltimezonestring -ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(VM& vm, String const& time_zone_string) +ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(VM& vm, DeprecatedString const& time_zone_string) { // 1. Let parseResult be ParseText(StringToCodePoints(timeZoneString), TimeZoneIdentifier). auto parse_result = parse_iso8601(Production::TimeZoneIdentifier, time_zone_string); @@ -1703,7 +1703,7 @@ ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(VM& vm, Stri } // 13.39 ParseTemporalYearMonthString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalyearmonthstring -ThrowCompletionOr<TemporalYearMonth> parse_temporal_year_month_string(VM& vm, String const& iso_string) +ThrowCompletionOr<TemporalYearMonth> parse_temporal_year_month_string(VM& vm, DeprecatedString const& iso_string) { // 1. Let parseResult be ParseText(StringToCodePoints(isoString), TemporalYearMonthString). auto parse_result = parse_iso8601(Production::TemporalYearMonthString, iso_string); @@ -1740,7 +1740,7 @@ ThrowCompletionOr<double> to_positive_integer(VM& vm, Value argument) } // 13.43 PrepareTemporalFields ( fields, fieldNames, requiredFields ), https://tc39.es/proposal-temporal/#sec-temporal-preparetemporalfields -ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields, Vector<String> const& field_names, Variant<PrepareTemporalFieldsPartial, Vector<StringView>> const& required_fields) +ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields, Vector<DeprecatedString> const& field_names, Variant<PrepareTemporalFieldsPartial, Vector<StringView>> const& required_fields) { auto& realm = *vm.current_realm(); @@ -1807,7 +1807,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields, // 4. If requiredFields is partial and any is false, then if (required_fields.has<PrepareTemporalFieldsPartial>() && !any) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(ErrorType::TemporalObjectMustHaveOneOf, String::join(", "sv, field_names)); + return vm.throw_completion<TypeError>(ErrorType::TemporalObjectMustHaveOneOf, DeprecatedString::join(", "sv, field_names)); } // 5. Return result. diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h index e9e93f4895..cfe3b36829 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h @@ -7,8 +7,8 @@ #pragma once +#include <AK/DeprecatedString.h> #include <AK/Forward.h> -#include <AK/String.h> #include <AK/Variant.h> #include <LibJS/Forward.h> #include <LibJS/Runtime/Completion.h> @@ -57,14 +57,14 @@ struct TemporalInstant { u16 millisecond; u16 microsecond; u16 nanosecond; - Optional<String> time_zone_offset; + Optional<DeprecatedString> time_zone_offset; }; struct TemporalDate { i32 year; u8 month; u8 day; - Optional<String> calendar; + Optional<DeprecatedString> calendar; }; struct TemporalTime { @@ -74,27 +74,27 @@ struct TemporalTime { u16 millisecond; u16 microsecond; u16 nanosecond; - Optional<String> calendar = {}; + Optional<DeprecatedString> calendar = {}; }; struct TemporalTimeZone { bool z; - Optional<String> offset_string; - Optional<String> name; + Optional<DeprecatedString> offset_string; + Optional<DeprecatedString> name; }; struct TemporalYearMonth { i32 year; u8 month; u8 day; - Optional<String> calendar = {}; + Optional<DeprecatedString> calendar = {}; }; struct TemporalMonthDay { Optional<i32> year; u8 month; u8 day; - Optional<String> calendar = {}; + Optional<DeprecatedString> calendar = {}; }; struct ISODateTime { @@ -108,19 +108,19 @@ struct ISODateTime { u16 microsecond; u16 nanosecond; TemporalTimeZone time_zone { .z = false, .offset_string = {}, .name = {} }; - Optional<String> calendar = {}; + Optional<DeprecatedString> calendar = {}; }; struct SecondsStringPrecision { Variant<StringView, u8> precision; - String unit; + DeprecatedString unit; u32 increment; }; struct DifferenceSettings { - String smallest_unit; - String largest_unit; - String rounding_mode; + DeprecatedString smallest_unit; + DeprecatedString largest_unit; + DeprecatedString rounding_mode; u64 rounding_increment; Object& options; }; @@ -135,24 +135,24 @@ using TemporalUnitDefault = Variant<TemporalUnitRequired, Optional<StringView>>; ThrowCompletionOr<MarkedVector<Value>> iterable_to_list_of_type(VM&, Value items, Vector<OptionType> const& element_types); ThrowCompletionOr<Object*> get_options_object(VM&, Value options); ThrowCompletionOr<Value> get_option(VM&, Object const& options, PropertyKey const& property, OptionType type, Span<StringView const> values, OptionDefault const&); -ThrowCompletionOr<String> to_temporal_overflow(VM&, Object const* options); -ThrowCompletionOr<String> to_temporal_disambiguation(VM&, Object const* options); -ThrowCompletionOr<String> to_temporal_rounding_mode(VM&, Object const& normalized_options, String const& fallback); -StringView negate_temporal_rounding_mode(String const& rounding_mode); -ThrowCompletionOr<String> to_temporal_offset(VM&, Object const* options, String const& fallback); -ThrowCompletionOr<String> to_calendar_name_option(VM&, Object const& normalized_options); -ThrowCompletionOr<String> to_time_zone_name_option(VM&, Object const& normalized_options); -ThrowCompletionOr<String> to_show_offset_option(VM&, Object const& normalized_options); +ThrowCompletionOr<DeprecatedString> to_temporal_overflow(VM&, Object const* options); +ThrowCompletionOr<DeprecatedString> to_temporal_disambiguation(VM&, Object const* options); +ThrowCompletionOr<DeprecatedString> to_temporal_rounding_mode(VM&, Object const& normalized_options, DeprecatedString const& fallback); +StringView negate_temporal_rounding_mode(DeprecatedString const& rounding_mode); +ThrowCompletionOr<DeprecatedString> to_temporal_offset(VM&, Object const* options, DeprecatedString const& fallback); +ThrowCompletionOr<DeprecatedString> to_calendar_name_option(VM&, Object const& normalized_options); +ThrowCompletionOr<DeprecatedString> to_time_zone_name_option(VM&, Object const& normalized_options); +ThrowCompletionOr<DeprecatedString> to_show_offset_option(VM&, Object const& normalized_options); ThrowCompletionOr<u64> to_temporal_rounding_increment(VM&, Object const& normalized_options, Optional<double> dividend, bool inclusive); ThrowCompletionOr<u64> to_temporal_date_time_rounding_increment(VM&, Object const& normalized_options, StringView smallest_unit); ThrowCompletionOr<SecondsStringPrecision> to_seconds_string_precision(VM&, Object const& normalized_options); -ThrowCompletionOr<Optional<String>> get_temporal_unit(VM&, Object const& normalized_options, PropertyKey const&, UnitGroup, TemporalUnitDefault const& default_, Vector<StringView> const& extra_values = {}); +ThrowCompletionOr<Optional<DeprecatedString>> get_temporal_unit(VM&, Object const& normalized_options, PropertyKey const&, UnitGroup, TemporalUnitDefault const& default_, Vector<StringView> const& extra_values = {}); ThrowCompletionOr<Value> to_relative_temporal_object(VM&, Object const& options); StringView larger_of_two_temporal_units(StringView, StringView); -ThrowCompletionOr<Object*> merge_largest_unit_option(VM&, Object const& options, String largest_unit); +ThrowCompletionOr<Object*> merge_largest_unit_option(VM&, Object const& options, DeprecatedString largest_unit); Optional<u16> maximum_temporal_duration_rounding_increment(StringView unit); ThrowCompletionOr<void> reject_object_with_calendar_or_time_zone(VM&, Object&); -String format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision); +DeprecatedString format_seconds_string_part(u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision); double sign(double); double sign(Crypto::SignedBigInteger const&); UnsignedRoundingMode get_unsigned_rounding_mode(StringView rounding_mode, bool is_negative); @@ -163,19 +163,19 @@ Crypto::SignedBigInteger round_number_to_increment(Crypto::SignedBigInteger cons Crypto::SignedBigInteger round_number_to_increment_as_if_positive(Crypto::SignedBigInteger const&, u64 increment, StringView rounding_mode); ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM&, StringView iso_string); ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM&, ParseResult const& parse_result); -ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM&, String const& iso_string); -ThrowCompletionOr<ISODateTime> parse_temporal_zoned_date_time_string(VM&, String const& iso_string); -ThrowCompletionOr<String> parse_temporal_calendar_string(VM&, String const& iso_string); -ThrowCompletionOr<TemporalDate> parse_temporal_date_string(VM&, String const& iso_string); -ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(VM&, String const& iso_string); -ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM&, String const& iso_string); -ThrowCompletionOr<TemporalMonthDay> parse_temporal_month_day_string(VM&, String const& iso_string); -ThrowCompletionOr<ISODateTime> parse_temporal_relative_to_string(VM&, String const& iso_string); -ThrowCompletionOr<TemporalTime> parse_temporal_time_string(VM&, String const& iso_string); -ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(VM&, String const& iso_string); -ThrowCompletionOr<TemporalYearMonth> parse_temporal_year_month_string(VM&, String const& iso_string); +ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM&, DeprecatedString const& iso_string); +ThrowCompletionOr<ISODateTime> parse_temporal_zoned_date_time_string(VM&, DeprecatedString const& iso_string); +ThrowCompletionOr<DeprecatedString> parse_temporal_calendar_string(VM&, DeprecatedString const& iso_string); +ThrowCompletionOr<TemporalDate> parse_temporal_date_string(VM&, DeprecatedString const& iso_string); +ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(VM&, DeprecatedString const& iso_string); +ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(VM&, DeprecatedString const& iso_string); +ThrowCompletionOr<TemporalMonthDay> parse_temporal_month_day_string(VM&, DeprecatedString const& iso_string); +ThrowCompletionOr<ISODateTime> parse_temporal_relative_to_string(VM&, DeprecatedString const& iso_string); +ThrowCompletionOr<TemporalTime> parse_temporal_time_string(VM&, DeprecatedString const& iso_string); +ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(VM&, DeprecatedString const& iso_string); +ThrowCompletionOr<TemporalYearMonth> parse_temporal_year_month_string(VM&, DeprecatedString const& iso_string); ThrowCompletionOr<double> to_positive_integer(VM&, Value argument); -ThrowCompletionOr<Object*> prepare_temporal_fields(VM&, Object const& fields, Vector<String> const& field_names, Variant<PrepareTemporalFieldsPartial, Vector<StringView>> const& required_fields); +ThrowCompletionOr<Object*> prepare_temporal_fields(VM&, Object const& fields, Vector<DeprecatedString> const& field_names, Variant<PrepareTemporalFieldsPartial, Vector<StringView>> const& required_fields); ThrowCompletionOr<DifferenceSettings> get_difference_settings(VM&, DifferenceOperation, Value options_value, UnitGroup unit_group, Vector<StringView> const& disallowed_units, TemporalUnitDefault const& fallback_smallest_unit, StringView smallest_largest_default_unit); template<size_t Size> diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp index a15716f682..3d82029cdc 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp @@ -27,14 +27,14 @@ namespace JS::Temporal { // 12 Temporal.Calendar Objects, https://tc39.es/proposal-temporal/#sec-temporal-calendar-objects -Calendar::Calendar(String identifier, Object& prototype) +Calendar::Calendar(DeprecatedString identifier, Object& prototype) : Object(prototype) , m_identifier(move(identifier)) { } // 12.1.1 IsBuiltinCalendar ( id ), https://tc39.es/proposal-temporal/#sec-temporal-isbuiltincalendar -bool is_builtin_calendar(String const& identifier) +bool is_builtin_calendar(DeprecatedString const& identifier) { // 1. Let calendars be AvailableCalendars(). auto calendars = available_calendars(); @@ -65,7 +65,7 @@ Span<StringView const> available_calendars() } // 12.2.1 CreateTemporalCalendar ( identifier [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporalcalendar -ThrowCompletionOr<Calendar*> create_temporal_calendar(VM& vm, String const& identifier, FunctionObject const* new_target) +ThrowCompletionOr<Calendar*> create_temporal_calendar(VM& vm, DeprecatedString const& identifier, FunctionObject const* new_target) { auto& realm = *vm.current_realm(); @@ -85,7 +85,7 @@ ThrowCompletionOr<Calendar*> create_temporal_calendar(VM& vm, String const& iden } // 12.2.2 GetBuiltinCalendar ( id ), https://tc39.es/proposal-temporal/#sec-temporal-getbuiltincalendar -ThrowCompletionOr<Calendar*> get_builtin_calendar(VM& vm, String const& identifier) +ThrowCompletionOr<Calendar*> get_builtin_calendar(VM& vm, DeprecatedString const& identifier) { // 1. If IsBuiltinCalendar(id) is false, throw a RangeError exception. if (!is_builtin_calendar(identifier)) @@ -103,7 +103,7 @@ Calendar* get_iso8601_calendar(VM& vm) } // 12.2.4 CalendarFields ( calendar, fieldNames ), https://tc39.es/proposal-temporal/#sec-temporal-calendarfields -ThrowCompletionOr<Vector<String>> calendar_fields(VM& vm, Object& calendar, Vector<StringView> const& field_names) +ThrowCompletionOr<Vector<DeprecatedString>> calendar_fields(VM& vm, Object& calendar, Vector<StringView> const& field_names) { auto& realm = *vm.current_realm(); @@ -112,7 +112,7 @@ ThrowCompletionOr<Vector<String>> calendar_fields(VM& vm, Object& calendar, Vect // 2. If fields is undefined, return fieldNames. if (!fields) { - Vector<String> result; + Vector<DeprecatedString> result; for (auto& value : field_names) result.append(value); return result; @@ -124,7 +124,7 @@ ThrowCompletionOr<Vector<String>> calendar_fields(VM& vm, Object& calendar, Vect // 4. Return ? IterableToListOfType(fieldsArray, « String »). auto list = TRY(iterable_to_list_of_type(vm, fields_array, { OptionType::String })); - Vector<String> result; + Vector<DeprecatedString> result; for (auto& value : list) result.append(value.as_string().string()); return result; @@ -232,7 +232,7 @@ ThrowCompletionOr<double> calendar_month(VM& vm, Object& calendar, Object& date_ } // 12.2.10 CalendarMonthCode ( calendar, dateLike ), https://tc39.es/proposal-temporal/#sec-temporal-calendarmonthcode -ThrowCompletionOr<String> calendar_month_code(VM& vm, Object& calendar, Object& date_like) +ThrowCompletionOr<DeprecatedString> calendar_month_code(VM& vm, Object& calendar, Object& date_like) { // 1. Assert: Type(calendar) is Object. @@ -573,11 +573,11 @@ ThrowCompletionOr<PlainMonthDay*> calendar_month_day_from_fields(VM& vm, Object& } // 12.2.26 MaybeFormatCalendarAnnotation ( calendarObject, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-maybeformatcalendarannotation -ThrowCompletionOr<String> maybe_format_calendar_annotation(VM& vm, Object const* calendar_object, StringView show_calendar) +ThrowCompletionOr<DeprecatedString> maybe_format_calendar_annotation(VM& vm, Object const* calendar_object, StringView show_calendar) { // 1. If showCalendar is "never", return the empty String. if (show_calendar == "never"sv) - return String::empty(); + return DeprecatedString::empty(); // 2. Assert: Type(calendarObject) is Object. VERIFY(calendar_object); @@ -590,23 +590,23 @@ ThrowCompletionOr<String> maybe_format_calendar_annotation(VM& vm, Object const* } // 12.2.27 FormatCalendarAnnotation ( id, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-formatcalendarannotation -String format_calendar_annotation(StringView id, StringView show_calendar) +DeprecatedString format_calendar_annotation(StringView id, StringView show_calendar) { VERIFY(show_calendar == "auto"sv || show_calendar == "always"sv || show_calendar == "never"sv || show_calendar == "critical"sv); // 1. If showCalendar is "never", return the empty String. if (show_calendar == "never"sv) - return String::empty(); + return DeprecatedString::empty(); // 2. If showCalendar is "auto" and id is "iso8601", return the empty String. if (show_calendar == "auto"sv && id == "iso8601"sv) - return String::empty(); + return DeprecatedString::empty(); // 3. If showCalendar is "critical", let flag be "!"; else, let flag be the empty String. auto flag = show_calendar == "critical"sv ? "!"sv : ""sv; // 4. Return the string-concatenation of "[", flag, "u-ca=", id, and "]". - return String::formatted("[{}u-ca={}]", flag, id); + return DeprecatedString::formatted("[{}u-ca={}]", flag, id); } // 12.2.28 CalendarEquals ( one, two ), https://tc39.es/proposal-temporal/#sec-temporal-calendarequals @@ -758,11 +758,11 @@ u8 to_iso_week_of_year(i32 year, u8 month, u8 day) } // 12.2.32 ISOMonthCode ( month ), https://tc39.es/proposal-temporal/#sec-temporal-isomonthcode -String iso_month_code(u8 month) +DeprecatedString iso_month_code(u8 month) { // 1. Let numberPart be ToZeroPaddedDecimalString(month, 2). // 2. Return the string-concatenation of "M" and numberPart. - return String::formatted("M{:02}", month); + return DeprecatedString::formatted("M{:02}", month); } // 12.2.33 ResolveISOMonth ( fields ), https://tc39.es/proposal-temporal/#sec-temporal-resolveisomonth diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h index 69b4e0084e..405a1f0a8a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h @@ -22,27 +22,27 @@ class Calendar final : public Object { public: virtual ~Calendar() override = default; - [[nodiscard]] String const& identifier() const { return m_identifier; } + [[nodiscard]] DeprecatedString const& identifier() const { return m_identifier; } private: - Calendar(String identifier, Object& prototype); + Calendar(DeprecatedString identifier, Object& prototype); // 12.5 Properties of Temporal.Calendar Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-calendar-instances - String m_identifier; // [[Identifier]] + DeprecatedString m_identifier; // [[Identifier]] }; -bool is_builtin_calendar(String const& identifier); +bool is_builtin_calendar(DeprecatedString const& identifier); Span<StringView const> available_calendars(); -ThrowCompletionOr<Calendar*> create_temporal_calendar(VM&, String const& identifier, FunctionObject const* new_target = nullptr); -ThrowCompletionOr<Calendar*> get_builtin_calendar(VM&, String const& identifier); +ThrowCompletionOr<Calendar*> create_temporal_calendar(VM&, DeprecatedString const& identifier, FunctionObject const* new_target = nullptr); +ThrowCompletionOr<Calendar*> get_builtin_calendar(VM&, DeprecatedString const& identifier); Calendar* get_iso8601_calendar(VM&); -ThrowCompletionOr<Vector<String>> calendar_fields(VM&, Object& calendar, Vector<StringView> const& field_names); +ThrowCompletionOr<Vector<DeprecatedString>> calendar_fields(VM&, Object& calendar, Vector<StringView> const& field_names); ThrowCompletionOr<Object*> calendar_merge_fields(VM&, Object& calendar, Object& fields, Object& additional_fields); ThrowCompletionOr<PlainDate*> calendar_date_add(VM&, Object& calendar, Value date, Duration&, Object* options = nullptr, FunctionObject* date_add = nullptr); ThrowCompletionOr<Duration*> calendar_date_until(VM&, Object& calendar, Value one, Value two, Object& options, FunctionObject* date_until = nullptr); ThrowCompletionOr<double> calendar_year(VM&, Object& calendar, Object& date_like); ThrowCompletionOr<double> calendar_month(VM&, Object& calendar, Object& date_like); -ThrowCompletionOr<String> calendar_month_code(VM&, Object& calendar, Object& date_like); +ThrowCompletionOr<DeprecatedString> calendar_month_code(VM&, Object& calendar, Object& date_like); ThrowCompletionOr<double> calendar_day(VM&, Object& calendar, Object& date_like); ThrowCompletionOr<Value> calendar_day_of_week(VM&, Object& calendar, Object& date_like); ThrowCompletionOr<Value> calendar_day_of_year(VM&, Object& calendar, Object& date_like); @@ -60,13 +60,13 @@ ThrowCompletionOr<Object*> get_temporal_calendar_with_iso_default(VM&, Object&); ThrowCompletionOr<PlainDate*> calendar_date_from_fields(VM&, Object& calendar, Object const& fields, Object const* options = nullptr); ThrowCompletionOr<PlainYearMonth*> calendar_year_month_from_fields(VM&, Object& calendar, Object const& fields, Object const* options = nullptr); ThrowCompletionOr<PlainMonthDay*> calendar_month_day_from_fields(VM&, Object& calendar, Object const& fields, Object const* options = nullptr); -ThrowCompletionOr<String> maybe_format_calendar_annotation(VM&, Object const* calendar_object, StringView show_calendar); -String format_calendar_annotation(StringView id, StringView show_calendar); +ThrowCompletionOr<DeprecatedString> maybe_format_calendar_annotation(VM&, Object const* calendar_object, StringView show_calendar); +DeprecatedString format_calendar_annotation(StringView id, StringView show_calendar); ThrowCompletionOr<bool> calendar_equals(VM&, Object& one, Object& two); ThrowCompletionOr<Object*> consolidate_calendars(VM&, Object& one, Object& two); u8 iso_days_in_month(i32 year, u8 month); u8 to_iso_week_of_year(i32 year, u8 month, u8 day); -String iso_month_code(u8 month); +DeprecatedString iso_month_code(u8 month); ThrowCompletionOr<double> resolve_iso_month(VM&, Object const& fields); ThrowCompletionOr<ISODateRecord> iso_date_from_fields(VM&, Object const& fields, Object const& options); ThrowCompletionOr<ISOYearMonth> iso_year_month_from_fields(VM&, Object const& fields, Object const& options); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp index 33d1d5744b..829938cfb6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp @@ -481,7 +481,7 @@ Crypto::SignedBigInteger total_duration_nanoseconds(double days, double hours, d } // 7.5.18 BalanceDuration ( days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, largestUnit [ , relativeTo ] ), https://tc39.es/proposal-temporal/#sec-temporal-balanceduration -ThrowCompletionOr<TimeDurationRecord> balance_duration(VM& vm, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, String const& largest_unit, Object* relative_to) +ThrowCompletionOr<TimeDurationRecord> balance_duration(VM& vm, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, DeprecatedString const& largest_unit, Object* relative_to) { // 1. If relativeTo is not present, set relativeTo to undefined. @@ -627,7 +627,7 @@ ThrowCompletionOr<TimeDurationRecord> balance_duration(VM& vm, double days, doub } // 7.5.19 UnbalanceDurationRelative ( years, months, weeks, days, largestUnit, relativeTo ), https://tc39.es/proposal-temporal/#sec-temporal-unbalancedurationrelative -ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double years, double months, double weeks, double days, String const& largest_unit, Value relative_to) +ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double years, double months, double weeks, double days, DeprecatedString const& largest_unit, Value relative_to) { auto& realm = *vm.current_realm(); @@ -816,7 +816,7 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double } // 7.5.20 BalanceDurationRelative ( years, months, weeks, days, largestUnit, relativeTo ), https://tc39.es/proposal-temporal/#sec-temporal-balancedurationrelative -ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double years, double months, double weeks, double days, String const& largest_unit, Value relative_to_value) +ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double years, double months, double weeks, double days, DeprecatedString const& largest_unit, Value relative_to_value) { auto& realm = *vm.current_realm(); @@ -1655,7 +1655,7 @@ ThrowCompletionOr<DurationRecord> adjust_rounded_duration_days(VM& vm, double ye } // 7.5.27 TemporalDurationToString ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, precision ), https://tc39.es/proposal-temporal/#sec-temporal-temporaldurationtostring -String temporal_duration_to_string(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Variant<StringView, u8> const& precision) +DeprecatedString temporal_duration_to_string(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Variant<StringView, u8> const& precision) { if (precision.has<StringView>()) VERIFY(precision.get<StringView>() == "auto"sv); @@ -1736,7 +1736,7 @@ String temporal_duration_to_string(double years, double months, double weeks, do // b. Let decimalPart be ToZeroPaddedDecimalString(fraction, 9). // NOTE: padding with zeros leads to weird results when applied to a double. Not sure if that's a bug in AK/Format.h or if I'm doing this wrong. - auto decimal_part = String::formatted("{:09}", (u64)fraction); + auto decimal_part = DeprecatedString::formatted("{:09}", (u64)fraction); // c. If precision is "auto", then if (precision.has<StringView>() && precision.get<StringView>() == "auto"sv) { @@ -1748,7 +1748,7 @@ String temporal_duration_to_string(double years, double months, double weeks, do // d. Else if precision = 0, then else if (precision.get<u8>() == 0) { // i. Set decimalPart to "". - decimal_part = String::empty(); + decimal_part = DeprecatedString::empty(); } // e. Else, else { diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h index a9eeba5645..a647045b56 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h @@ -132,15 +132,15 @@ ThrowCompletionOr<Duration*> create_temporal_duration(VM&, double years, double Duration* create_negated_temporal_duration(VM&, Duration const& duration); ThrowCompletionOr<double> calculate_offset_shift(VM&, Value relative_to_value, double years, double months, double weeks, double days); Crypto::SignedBigInteger total_duration_nanoseconds(double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, double offset_shift); -ThrowCompletionOr<TimeDurationRecord> balance_duration(VM&, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, String const& largest_unit, Object* relative_to = nullptr); -ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM&, double years, double months, double weeks, double days, String const& largest_unit, Value relative_to); -ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM&, double years, double months, double weeks, double days, String const& largest_unit, Value relative_to); +ThrowCompletionOr<TimeDurationRecord> balance_duration(VM&, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, Crypto::SignedBigInteger const& nanoseconds, DeprecatedString const& largest_unit, Object* relative_to = nullptr); +ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM&, double years, double months, double weeks, double days, DeprecatedString const& largest_unit, Value relative_to); +ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM&, double years, double months, double weeks, double days, DeprecatedString const& largest_unit, Value relative_to); ThrowCompletionOr<DurationRecord> add_duration(VM&, double years1, double months1, double weeks1, double days1, double hours1, double minutes1, double seconds1, double milliseconds1, double microseconds1, double nanoseconds1, double years2, double months2, double weeks2, double days2, double hours2, double minutes2, double seconds2, double milliseconds2, double microseconds2, double nanoseconds2, Value relative_to_value); ThrowCompletionOr<MoveRelativeDateResult> move_relative_date(VM&, Object& calendar, PlainDate& relative_to, Duration& duration, FunctionObject* date_add); ThrowCompletionOr<ZonedDateTime*> move_relative_zoned_date_time(VM&, ZonedDateTime&, double years, double months, double weeks, double days); ThrowCompletionOr<RoundedDuration> round_duration(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, u32 increment, StringView unit, StringView rounding_mode, Object* relative_to_object = nullptr); ThrowCompletionOr<DurationRecord> adjust_rounded_duration_days(VM&, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, u32 increment, StringView unit, StringView rounding_mode, Object* relative_to_object); -String temporal_duration_to_string(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Variant<StringView, u8> const& precision); +DeprecatedString temporal_duration_to_string(double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Variant<StringView, u8> const& precision); ThrowCompletionOr<Duration*> add_duration_to_or_subtract_duration_from_duration(VM&, ArithmeticOperation, Duration const&, Value other_value, Value options_value); // 7.5.22 DaysUntil ( earlier, later ), https://tc39.es/proposal-temporal/#sec-temporal-daysuntil diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp index 08521c4451..4215d9ca6a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp @@ -110,7 +110,7 @@ ThrowCompletionOr<Instant*> to_temporal_instant(VM& vm, Value item) } // 8.5.4 ParseTemporalInstant ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalinstant -ThrowCompletionOr<BigInt*> parse_temporal_instant(VM& vm, String const& iso_string) +ThrowCompletionOr<BigInt*> parse_temporal_instant(VM& vm, DeprecatedString const& iso_string) { // 1. Assert: Type(isoString) is String. @@ -239,7 +239,7 @@ BigInt* round_temporal_instant(VM& vm, BigInt const& nanoseconds, u64 increment, } // 8.5.9 TemporalInstantToString ( instant, timeZone, precision ), https://tc39.es/proposal-temporal/#sec-temporal-temporalinstanttostring -ThrowCompletionOr<String> temporal_instant_to_string(VM& vm, Instant& instant, Value time_zone, Variant<StringView, u8> const& precision) +ThrowCompletionOr<DeprecatedString> temporal_instant_to_string(VM& vm, Instant& instant, Value time_zone, Variant<StringView, u8> const& precision) { // 1. Assert: Type(instant) is Object. // 2. Assert: instant has an [[InitializedTemporalInstant]] internal slot. @@ -262,7 +262,7 @@ ThrowCompletionOr<String> temporal_instant_to_string(VM& vm, Instant& instant, V // 7. Let dateTimeString be ? TemporalDateTimeToString(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], undefined, precision, "never"). auto date_time_string = TRY(temporal_date_time_to_string(vm, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), nullptr, precision, "never"sv)); - String time_zone_string; + DeprecatedString time_zone_string; // 8. If timeZone is undefined, then if (time_zone.is_undefined()) { @@ -279,7 +279,7 @@ ThrowCompletionOr<String> temporal_instant_to_string(VM& vm, Instant& instant, V } // 10. Return the string-concatenation of dateTimeString and timeZoneString. - return String::formatted("{}{}", date_time_string, time_zone_string); + return DeprecatedString::formatted("{}{}", date_time_string, time_zone_string); } // 8.5.10 DifferenceTemporalInstant ( operation, instant, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalinstant diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.h b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.h index 3ec4dca6cd..ba8e15dfe8 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.h @@ -45,12 +45,12 @@ bool is_valid_epoch_nanoseconds(BigInt const& epoch_nanoseconds); bool is_valid_epoch_nanoseconds(Crypto::SignedBigInteger const& epoch_nanoseconds); ThrowCompletionOr<Instant*> create_temporal_instant(VM&, BigInt const& nanoseconds, FunctionObject const* new_target = nullptr); ThrowCompletionOr<Instant*> to_temporal_instant(VM&, Value item); -ThrowCompletionOr<BigInt*> parse_temporal_instant(VM&, String const& iso_string); +ThrowCompletionOr<BigInt*> parse_temporal_instant(VM&, DeprecatedString const& iso_string); i32 compare_epoch_nanoseconds(BigInt const&, BigInt const&); ThrowCompletionOr<BigInt*> add_instant(VM&, BigInt const& epoch_nanoseconds, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds); BigInt* difference_instant(VM&, BigInt const& nanoseconds1, BigInt const& nanoseconds2, u64 rounding_increment, StringView smallest_unit, StringView rounding_mode); BigInt* round_temporal_instant(VM&, BigInt const& nanoseconds, u64 increment, StringView unit, StringView rounding_mode); -ThrowCompletionOr<String> temporal_instant_to_string(VM&, Instant&, Value time_zone, Variant<StringView, u8> const& precision); +ThrowCompletionOr<DeprecatedString> temporal_instant_to_string(VM&, Instant&, Value time_zone, Variant<StringView, u8> const& precision); ThrowCompletionOr<Duration*> difference_temporal_instant(VM&, DifferenceOperation, Instant const&, Value other, Value options); ThrowCompletionOr<Instant*> add_duration_to_or_subtract_duration_from_instant(VM&, ArithmeticOperation, Instant const&, Value temporal_duration_like); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp index c5fb989873..5b4cd4970b 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp @@ -395,14 +395,14 @@ ISODateRecord balance_iso_date(double year, double month, double day) } // 3.5.7 PadISOYear ( y ), https://tc39.es/proposal-temporal/#sec-temporal-padisoyear -String pad_iso_year(i32 y) +DeprecatedString pad_iso_year(i32 y) { // 1. Assert: y is an integer. // 2. If y ≥ 0 and y ≤ 9999, then if (y >= 0 && y <= 9999) { // a. Return ToZeroPaddedDecimalString(y, 4). - return String::formatted("{:04}", y); + return DeprecatedString::formatted("{:04}", y); } // 3. If y > 0, let yearSign be "+"; otherwise, let yearSign be "-". @@ -410,11 +410,11 @@ String pad_iso_year(i32 y) // 4. Let year be ToZeroPaddedDecimalString(abs(y), 6). // 5. Return the string-concatenation of yearSign and year. - return String::formatted("{}{:06}", year_sign, abs(y)); + return DeprecatedString::formatted("{}{:06}", year_sign, abs(y)); } // 3.5.8 TemporalDateToString ( temporalDate, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-temporaldatetostring -ThrowCompletionOr<String> temporal_date_to_string(VM& vm, PlainDate& temporal_date, StringView show_calendar) +ThrowCompletionOr<DeprecatedString> temporal_date_to_string(VM& vm, PlainDate& temporal_date, StringView show_calendar) { // 1. Assert: Type(temporalDate) is Object. // 2. Assert: temporalDate has an [[InitializedTemporalDate]] internal slot. @@ -423,16 +423,16 @@ ThrowCompletionOr<String> temporal_date_to_string(VM& vm, PlainDate& temporal_da auto year = pad_iso_year(temporal_date.iso_year()); // 4. Let month be ToZeroPaddedDecimalString(monthDay.[[ISOMonth]], 2). - auto month = String::formatted("{:02}", temporal_date.iso_month()); + auto month = DeprecatedString::formatted("{:02}", temporal_date.iso_month()); // 5. Let day be ToZeroPaddedDecimalString(monthDay.[[ISODay]], 2). - auto day = String::formatted("{:02}", temporal_date.iso_day()); + auto day = DeprecatedString::formatted("{:02}", temporal_date.iso_day()); // 6. Let calendar be ? MaybeFormatCalendarAnnotation(temporalDate.[[Calendar]], showCalendar). auto calendar = TRY(maybe_format_calendar_annotation(vm, &temporal_date.calendar(), show_calendar)); // 7. Return the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), month, the code unit 0x002D (HYPHEN-MINUS), day, and calendar. - return String::formatted("{}-{}-{}{}", year, month, day, calendar); + return DeprecatedString::formatted("{}-{}-{}{}", year, month, day, calendar); } // 3.5.9 AddISODate ( year, month, day, years, months, weeks, days, overflow ), https://tc39.es/proposal-temporal/#sec-temporal-addisodate diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h index b26b104808..a3ad5773bd 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h @@ -52,8 +52,8 @@ DateDurationRecord difference_iso_date(VM&, i32 year1, u8 month1, u8 day1, i32 y ThrowCompletionOr<ISODateRecord> regulate_iso_date(VM&, double year, double month, double day, StringView overflow); bool is_valid_iso_date(i32 year, u8 month, u8 day); ISODateRecord balance_iso_date(double year, double month, double day); -String pad_iso_year(i32 y); -ThrowCompletionOr<String> temporal_date_to_string(VM&, PlainDate&, StringView show_calendar); +DeprecatedString pad_iso_year(i32 y); +ThrowCompletionOr<DeprecatedString> temporal_date_to_string(VM&, PlainDate&, StringView show_calendar); ThrowCompletionOr<ISODateRecord> add_iso_date(VM&, i32 year, u8 month, u8 day, double years, double months, double weeks, double days, StringView overflow); i8 compare_iso_date(i32 year1, u8 month1, u8 day1, i32 year2, u8 month2, u8 day2); ThrowCompletionOr<Duration*> difference_temporal_plain_date(VM&, DifferenceOperation, PlainDate&, Value other, Value options); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp index 2f8e4419f8..beff49f146 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp @@ -247,7 +247,7 @@ ThrowCompletionOr<PlainDateTime*> create_temporal_date_time(VM& vm, i32 iso_year } // 5.5.6 TemporalDateTimeToString ( isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar, precision, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-temporaldatetimetostring -ThrowCompletionOr<String> temporal_date_time_to_string(VM& vm, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object const* calendar, Variant<StringView, u8> const& precision, StringView show_calendar) +ThrowCompletionOr<DeprecatedString> temporal_date_time_to_string(VM& vm, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object const* calendar, Variant<StringView, u8> const& precision, StringView show_calendar) { // 1. Assert: isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, and nanosecond are integers. @@ -264,7 +264,7 @@ ThrowCompletionOr<String> temporal_date_time_to_string(VM& vm, i32 iso_year, u8 auto calendar_string = TRY(maybe_format_calendar_annotation(vm, calendar, show_calendar)); // 9. Return the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), month, the code unit 0x002D (HYPHEN-MINUS), day, 0x0054 (LATIN CAPITAL LETTER T), hour, the code unit 0x003A (COLON), minute, seconds, and calendarString. - return String::formatted("{}-{:02}-{:02}T{:02}:{:02}{}{}", pad_iso_year(iso_year), iso_month, iso_day, hour, minute, seconds, calendar_string); + return DeprecatedString::formatted("{}-{:02}-{:02}T{:02}:{:02}{}{}", pad_iso_year(iso_year), iso_month, iso_day, hour, minute, seconds, calendar_string); } // 5.5.7 CompareISODateTime ( y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, d2, h2, min2, s2, ms2, mus2, ns2 ), https://tc39.es/proposal-temporal/#sec-temporal-compareisodatetime diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.h index 7b3f0aa046..658e01189a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.h @@ -69,7 +69,7 @@ ThrowCompletionOr<ISODateTime> interpret_temporal_date_time_fields(VM&, Object& ThrowCompletionOr<PlainDateTime*> to_temporal_date_time(VM&, Value item, Object const* options = nullptr); ISODateTime balance_iso_date_time(i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, i64 nanosecond); ThrowCompletionOr<PlainDateTime*> create_temporal_date_time(VM&, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object& calendar, FunctionObject const* new_target = nullptr); -ThrowCompletionOr<String> temporal_date_time_to_string(VM&, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object const* calendar, Variant<StringView, u8> const& precision, StringView show_calendar); +ThrowCompletionOr<DeprecatedString> temporal_date_time_to_string(VM&, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object const* calendar, Variant<StringView, u8> const& precision, StringView show_calendar); i8 compare_iso_date_time(i32 year1, u8 month1, u8 day1, u8 hour1, u8 minute1, u8 second1, u16 millisecond1, u16 microsecond1, u16 nanosecond1, i32 year2, u8 month2, u8 day2, u8 hour2, u8 minute2, u8 second2, u16 millisecond2, u16 microsecond2, u16 nanosecond2); ThrowCompletionOr<TemporalPlainDateTime> add_date_time(VM&, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object& calendar, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Object* options); ISODateTime round_iso_date_time(i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, u64 increment, StringView unit, StringView rounding_mode, Optional<double> day_length = {}); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp index 999418e31d..04033ee121 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp @@ -174,7 +174,7 @@ ThrowCompletionOr<PlainMonthDay*> create_temporal_month_day(VM& vm, u8 iso_month } // 10.5.3 TemporalMonthDayToString ( monthDay, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-temporalmonthdaytostring -ThrowCompletionOr<String> temporal_month_day_to_string(VM& vm, PlainMonthDay& month_day, StringView show_calendar) +ThrowCompletionOr<DeprecatedString> temporal_month_day_to_string(VM& vm, PlainMonthDay& month_day, StringView show_calendar) { // 1. Assert: Type(monthDay) is Object. // 2. Assert: monthDay has an [[InitializedTemporalMonthDay]] internal slot. @@ -182,7 +182,7 @@ ThrowCompletionOr<String> temporal_month_day_to_string(VM& vm, PlainMonthDay& mo // 3. Let month be ToZeroPaddedDecimalString(temporalDate.[[ISOMonth]], 2). // 4. Let day be ToZeroPaddedDecimalString(temporalDate.[[ISODay]], 2). // 5. Let result be the string-concatenation of month, the code unit 0x002D (HYPHEN-MINUS), and day. - auto result = String::formatted("{:02}-{:02}", month_day.iso_month(), month_day.iso_day()); + auto result = DeprecatedString::formatted("{:02}-{:02}", month_day.iso_month(), month_day.iso_day()); // 6. Let calendarID be ? ToString(monthDay.[[Calendar]]). auto calendar_id = TRY(Value(&month_day.calendar()).to_string(vm)); @@ -191,7 +191,7 @@ ThrowCompletionOr<String> temporal_month_day_to_string(VM& vm, PlainMonthDay& mo if (show_calendar.is_one_of("always"sv, "critical"sv) || calendar_id != "iso8601"sv) { // a. Let year be ! PadISOYear(monthDay.[[ISOYear]]). // b. Set result to the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), and result. - result = String::formatted("{}-{}", pad_iso_year(month_day.iso_year()), result); + result = DeprecatedString::formatted("{}-{}", pad_iso_year(month_day.iso_year()), result); } // 8. Let calendarString be ! FormatCalendarAnnotation(calendarID, showCalendar). @@ -199,7 +199,7 @@ ThrowCompletionOr<String> temporal_month_day_to_string(VM& vm, PlainMonthDay& mo // 9. Set result to the string-concatenation of result and calendarString. // 10. Return result. - return String::formatted("{}{}", result, calendar_string); + return DeprecatedString::formatted("{}{}", result, calendar_string); } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.h index 62dce155c5..3d38f13298 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.h @@ -42,6 +42,6 @@ struct ISOMonthDay { ThrowCompletionOr<PlainMonthDay*> to_temporal_month_day(VM&, Value item, Object const* options = nullptr); ThrowCompletionOr<PlainMonthDay*> create_temporal_month_day(VM&, u8 iso_month, u8 iso_day, Object& calendar, i32 reference_iso_year, FunctionObject const* new_target = nullptr); -ThrowCompletionOr<String> temporal_month_day_to_string(VM&, PlainMonthDay&, StringView show_calendar); +ThrowCompletionOr<DeprecatedString> temporal_month_day_to_string(VM&, PlainMonthDay&, StringView show_calendar); } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp index 2cebb8fb31..fa3ca3ab30 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp @@ -434,7 +434,7 @@ ThrowCompletionOr<TemporalTimeLikeRecord> to_temporal_time_record(VM& vm, Object } // 4.5.9 TemporalTimeToString ( hour, minute, second, millisecond, microsecond, nanosecond, precision ), https://tc39.es/proposal-temporal/#sec-temporal-temporaltimetostring -String temporal_time_to_string(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision) +DeprecatedString temporal_time_to_string(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision) { // 1. Assert: hour, minute, second, millisecond, microsecond and nanosecond are integers. @@ -445,7 +445,7 @@ String temporal_time_to_string(u8 hour, u8 minute, u8 second, u16 millisecond, u auto seconds = format_seconds_string_part(second, millisecond, microsecond, nanosecond, precision); // 5. Return the string-concatenation of hour, the code unit 0x003A (COLON), minute, and seconds. - return String::formatted("{:02}:{:02}{}", hour, minute, seconds); + return DeprecatedString::formatted("{:02}:{:02}{}", hour, minute, seconds); } // 4.5.10 CompareTemporalTime ( h1, min1, s1, ms1, mus1, ns1, h2, min2, s2, ms2, mus2, ns2 ), https://tc39.es/proposal-temporal/#sec-temporal-comparetemporaltime diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h index 8349bbcd81..6266b56d07 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.h @@ -85,7 +85,7 @@ DaysAndTime balance_time(double hour, double minute, double second, double milli TemporalTime constrain_time(double hour, double minute, double second, double millisecond, double microsecond, double nanosecond); ThrowCompletionOr<PlainTime*> create_temporal_time(VM&, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, FunctionObject const* new_target = nullptr); ThrowCompletionOr<TemporalTimeLikeRecord> to_temporal_time_record(VM&, Object const& temporal_time_like, ToTemporalTimeRecordCompleteness = ToTemporalTimeRecordCompleteness::Complete); -String temporal_time_to_string(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision); +DeprecatedString temporal_time_to_string(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Variant<StringView, u8> const& precision); i8 compare_temporal_time(u8 hour1, u8 minute1, u8 second1, u16 millisecond1, u16 microsecond1, u16 nanosecond1, u8 hour2, u8 minute2, u8 second2, u16 millisecond2, u16 microsecond2, u16 nanosecond2); DaysAndTime add_time(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds); DaysAndTime round_time(u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, u64 increment, StringView unit, StringView rounding_mode, Optional<double> day_length_ns = {}); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp index 2ab9aa2bd7..9548bc99f1 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp @@ -201,7 +201,7 @@ ThrowCompletionOr<PlainYearMonth*> create_temporal_year_month(VM& vm, i32 iso_ye } // 9.5.6 TemporalYearMonthToString ( yearMonth, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-temporalyearmonthtostring -ThrowCompletionOr<String> temporal_year_month_to_string(VM& vm, PlainYearMonth& year_month, StringView show_calendar) +ThrowCompletionOr<DeprecatedString> temporal_year_month_to_string(VM& vm, PlainYearMonth& year_month, StringView show_calendar) { // 1. Assert: Type(yearMonth) is Object. // 2. Assert: yearMonth has an [[InitializedTemporalYearMonth]] internal slot. @@ -209,7 +209,7 @@ ThrowCompletionOr<String> temporal_year_month_to_string(VM& vm, PlainYearMonth& // 3. Let year be ! PadISOYear(yearMonth.[[ISOYear]]). // 4. Let month be ToZeroPaddedDecimalString(yearMonth.[[ISOMonth]], 2). // 5. Let result be the string-concatenation of year, the code unit 0x002D (HYPHEN-MINUS), and month. - auto result = String::formatted("{}-{:02}", pad_iso_year(year_month.iso_year()), year_month.iso_month()); + auto result = DeprecatedString::formatted("{}-{:02}", pad_iso_year(year_month.iso_year()), year_month.iso_month()); // 6. Let calendarID be ? ToString(yearMonth.[[Calendar]]). auto calendar_id = TRY(Value(&year_month.calendar()).to_string(vm)); @@ -218,7 +218,7 @@ ThrowCompletionOr<String> temporal_year_month_to_string(VM& vm, PlainYearMonth& if (show_calendar.is_one_of("always"sv, "critical"sv) || calendar_id != "iso8601") { // a. Let day be ToZeroPaddedDecimalString(yearMonth.[[ISODay]], 2). // b. Set result to the string-concatenation of result, the code unit 0x002D (HYPHEN-MINUS), and day. - result = String::formatted("{}-{:02}", result, year_month.iso_day()); + result = DeprecatedString::formatted("{}-{:02}", result, year_month.iso_day()); } // 8. Let calendarString be ! FormatCalendarAnnotation(calendarID, showCalendar). @@ -226,7 +226,7 @@ ThrowCompletionOr<String> temporal_year_month_to_string(VM& vm, PlainYearMonth& // 9. Set result to the string-concatenation of result and calendarString. // 10. Return result. - return String::formatted("{}{}", result, calendar_string); + return DeprecatedString::formatted("{}{}", result, calendar_string); } // 9.5.7 DifferenceTemporalPlainYearMonth ( operation, yearMonth, other, options ), https://tc39.es/proposal-temporal/#sec-temporal-differencetemporalplainyearmonth diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.h index f1744e209e..3d06096f90 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.h @@ -46,7 +46,7 @@ ThrowCompletionOr<ISOYearMonth> regulate_iso_year_month(VM&, double year, double bool iso_year_month_within_limits(i32 year, u8 month); ISOYearMonth balance_iso_year_month(double year, double month); ThrowCompletionOr<PlainYearMonth*> create_temporal_year_month(VM&, i32 iso_year, u8 iso_month, Object& calendar, u8 reference_iso_day, FunctionObject const* new_target = nullptr); -ThrowCompletionOr<String> temporal_year_month_to_string(VM&, PlainYearMonth&, StringView show_calendar); +ThrowCompletionOr<DeprecatedString> temporal_year_month_to_string(VM&, PlainYearMonth&, StringView show_calendar); ThrowCompletionOr<Duration*> difference_temporal_plain_year_month(VM&, DifferenceOperation, PlainYearMonth&, Value other, Value options); ThrowCompletionOr<PlainYearMonth*> add_duration_to_or_subtract_duration_from_plain_year_month(VM&, ArithmeticOperation, PlainYearMonth&, Value temporal_duration_like, Value options_value); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp index 9e419fae42..dd662d4512 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp @@ -43,7 +43,7 @@ bool is_available_time_zone_name(StringView time_zone) // 11.1.2 CanonicalizeTimeZoneName ( timeZone ), https://tc39.es/proposal-temporal/#sec-canonicalizetimezonename // 15.1.2 CanonicalizeTimeZoneName ( timeZone ), https://tc39.es/proposal-temporal/#sup-canonicalizetimezonename -String canonicalize_time_zone_name(String const& time_zone) +DeprecatedString canonicalize_time_zone_name(DeprecatedString const& time_zone) { // 1. Let ianaTimeZone be the String value of the Zone or Link name of the IANA Time Zone Database that is an ASCII-case-insensitive match of timeZone as described in 6.1. // 2. If ianaTimeZone is a Link name, let ianaTimeZone be the String value of the corresponding Zone name as specified in the file backward of the IANA Time Zone Database. @@ -57,7 +57,7 @@ String canonicalize_time_zone_name(String const& time_zone) } // 11.6.1 CreateTemporalTimeZone ( identifier [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporaltimezone -ThrowCompletionOr<TimeZone*> create_temporal_time_zone(VM& vm, String const& identifier, FunctionObject const* new_target) +ThrowCompletionOr<TimeZone*> create_temporal_time_zone(VM& vm, DeprecatedString const& identifier, FunctionObject const* new_target) { auto& realm = *vm.current_realm(); @@ -166,7 +166,7 @@ BigInt* get_named_time_zone_previous_transition(VM&, [[maybe_unused]] StringView } // https://tc39.es/proposal-temporal/#prod-TimeZoneNumericUTCOffset -static bool parse_time_zone_numeric_utc_offset_syntax(String const& offset_string, StringView& sign, StringView& hours, Optional<StringView>& minutes, Optional<StringView>& seconds, Optional<StringView>& fraction) +static bool parse_time_zone_numeric_utc_offset_syntax(DeprecatedString const& offset_string, StringView& sign, StringView& hours, Optional<StringView>& minutes, Optional<StringView>& seconds, Optional<StringView>& fraction) { DateTimeLexer lexer(offset_string); auto sign_part = lexer.consume_sign(); @@ -200,7 +200,7 @@ static bool parse_time_zone_numeric_utc_offset_syntax(String const& offset_strin return !lexer.tell_remaining(); } -bool is_valid_time_zone_numeric_utc_offset_syntax(String const& offset_string) +bool is_valid_time_zone_numeric_utc_offset_syntax(DeprecatedString const& offset_string) { StringView discarded; Optional<StringView> optionally_discarded; @@ -209,7 +209,7 @@ bool is_valid_time_zone_numeric_utc_offset_syntax(String const& offset_string) } // 11.6.5 FormatTimeZoneOffsetString ( offsetNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal-formattimezoneoffsetstring -String format_time_zone_offset_string(double offset_nanoseconds) +DeprecatedString format_time_zone_offset_string(double offset_nanoseconds) { auto offset = static_cast<i64>(offset_nanoseconds); @@ -248,7 +248,7 @@ String format_time_zone_offset_string(double offset_nanoseconds) // a. Let fraction be ToZeroPaddedDecimalString(nanoseconds, 9). // b. Set fraction to the longest possible substring of fraction starting at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO). // c. Let post be the string-concatenation of the code unit 0x003A (COLON), s, the code unit 0x002E (FULL STOP), and fraction. - builder.appendff(":{:02}.{}", seconds, String::formatted("{:09}", nanoseconds).trim("0"sv, TrimMode::Right)); + builder.appendff(":{:02}.{}", seconds, DeprecatedString::formatted("{:09}", nanoseconds).trim("0"sv, TrimMode::Right)); } // 12. Else if seconds ≠ 0, then else if (seconds != 0) { @@ -263,7 +263,7 @@ String format_time_zone_offset_string(double offset_nanoseconds) } // 11.6.6 FormatISOTimeZoneOffsetString ( offsetNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal-formatisotimezoneoffsetstring -String format_iso_time_zone_offset_string(double offset_nanoseconds) +DeprecatedString format_iso_time_zone_offset_string(double offset_nanoseconds) { // 1. Assert: offsetNanoseconds is an integer. VERIFY(trunc(offset_nanoseconds) == offset_nanoseconds); @@ -286,7 +286,7 @@ String format_iso_time_zone_offset_string(double offset_nanoseconds) // 7. Let h be ToZeroPaddedDecimalString(hours, 2). // 8. Let m be ToZeroPaddedDecimalString(minutes, 2). // 9. Return the string-concatenation of sign, h, the code unit 0x003A (COLON), and m. - return String::formatted("{}{:02}:{:02}", sign, (u32)hours, (u32)minutes); + return DeprecatedString::formatted("{}{:02}:{:02}", sign, (u32)hours, (u32)minutes); } // 11.6.7 ToTemporalTimeZone ( temporalTimeZoneLike ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaltimezone @@ -393,7 +393,7 @@ ThrowCompletionOr<double> get_offset_nanoseconds_for(VM& vm, Value time_zone, In } // 11.6.9 BuiltinTimeZoneGetOffsetStringFor ( timeZone, instant ), https://tc39.es/proposal-temporal/#sec-temporal-builtintimezonegetoffsetstringfor -ThrowCompletionOr<String> builtin_time_zone_get_offset_string_for(VM& vm, Value time_zone, Instant& instant) +ThrowCompletionOr<DeprecatedString> builtin_time_zone_get_offset_string_for(VM& vm, Value time_zone, Instant& instant) { // 1. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant). auto offset_nanoseconds = TRY(get_offset_nanoseconds_for(vm, time_zone, instant)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.h b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.h index dc20ea26eb..1892196bd5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.h @@ -22,37 +22,37 @@ public: virtual ~TimeZone() override = default; - [[nodiscard]] String const& identifier() const { return m_identifier; } + [[nodiscard]] DeprecatedString const& identifier() const { return m_identifier; } [[nodiscard]] Optional<OffsetType> const& offset_nanoseconds() const { return m_offset_nanoseconds; } - void set_identifier(String identifier) { m_identifier = move(identifier); }; + void set_identifier(DeprecatedString identifier) { m_identifier = move(identifier); }; void set_offset_nanoseconds(OffsetType offset_nanoseconds) { m_offset_nanoseconds = offset_nanoseconds; }; private: explicit TimeZone(Object& prototype); // 11.5 Properties of Temporal.TimeZone Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-timezone-instances - String m_identifier; // [[Identifier]] + DeprecatedString m_identifier; // [[Identifier]] Optional<OffsetType> m_offset_nanoseconds; // [[OffsetNanoseconds]] }; bool is_available_time_zone_name(StringView time_zone); -String canonicalize_time_zone_name(String const& time_zone); -ThrowCompletionOr<TimeZone*> create_temporal_time_zone(VM&, String const& identifier, FunctionObject const* new_target = nullptr); +DeprecatedString canonicalize_time_zone_name(DeprecatedString const& time_zone); +ThrowCompletionOr<TimeZone*> create_temporal_time_zone(VM&, DeprecatedString const& identifier, FunctionObject const* new_target = nullptr); ISODateTime get_iso_parts_from_epoch(VM&, Crypto::SignedBigInteger const& epoch_nanoseconds); BigInt* get_named_time_zone_next_transition(VM&, StringView time_zone_identifier, BigInt const& epoch_nanoseconds); BigInt* get_named_time_zone_previous_transition(VM&, StringView time_zone_identifier, BigInt const& epoch_nanoseconds); -String format_time_zone_offset_string(double offset_nanoseconds); -String format_iso_time_zone_offset_string(double offset_nanoseconds); +DeprecatedString format_time_zone_offset_string(double offset_nanoseconds); +DeprecatedString format_iso_time_zone_offset_string(double offset_nanoseconds); ThrowCompletionOr<Object*> to_temporal_time_zone(VM&, Value temporal_time_zone_like); ThrowCompletionOr<double> get_offset_nanoseconds_for(VM&, Value time_zone, Instant&); -ThrowCompletionOr<String> builtin_time_zone_get_offset_string_for(VM&, Value time_zone, Instant&); +ThrowCompletionOr<DeprecatedString> builtin_time_zone_get_offset_string_for(VM&, Value time_zone, Instant&); ThrowCompletionOr<PlainDateTime*> builtin_time_zone_get_plain_date_time_for(VM&, Value time_zone, Instant&, Object& calendar); ThrowCompletionOr<Instant*> builtin_time_zone_get_instant_for(VM&, Value time_zone, PlainDateTime&, StringView disambiguation); ThrowCompletionOr<Instant*> disambiguate_possible_instants(VM&, MarkedVector<Instant*> const& possible_instants, Value time_zone, PlainDateTime&, StringView disambiguation); ThrowCompletionOr<MarkedVector<Instant*>> get_possible_instants_for(VM&, Value time_zone, PlainDateTime&); ThrowCompletionOr<bool> time_zone_equals(VM&, Object& one, Object& two); -bool is_valid_time_zone_numeric_utc_offset_syntax(String const&); +bool is_valid_time_zone_numeric_utc_offset_syntax(DeprecatedString const&); } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index e40545dd89..d50f8e4465 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -130,7 +130,7 @@ ThrowCompletionOr<ZonedDateTime*> to_temporal_zoned_date_time(VM& vm, Value item Object* calendar = nullptr; Object* time_zone = nullptr; - Optional<String> offset_string; + Optional<DeprecatedString> offset_string; ISODateTime result; // 5. If Type(item) is Object, then @@ -284,7 +284,7 @@ ThrowCompletionOr<ZonedDateTime*> create_temporal_zoned_date_time(VM& vm, BigInt } // 6.5.4 TemporalZonedDateTimeToString ( zonedDateTime, precision, showCalendar, showTimeZone, showOffset [ , increment, unit, roundingMode ] ), https://tc39.es/proposal-temporal/#sec-temporal-temporalzoneddatetimetostring -ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM& vm, ZonedDateTime& zoned_date_time, Variant<StringView, u8> const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional<u64> increment, Optional<StringView> unit, Optional<StringView> rounding_mode) +ThrowCompletionOr<DeprecatedString> temporal_zoned_date_time_to_string(VM& vm, ZonedDateTime& zoned_date_time, Variant<StringView, u8> const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional<u64> increment, Optional<StringView> unit, Optional<StringView> rounding_mode) { // 1. If increment is not present, set increment to 1. if (!increment.has_value()) @@ -316,12 +316,12 @@ ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM& vm, ZonedDateTi // 9. Let dateTimeString be ? TemporalDateTimeToString(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]], isoCalendar, precision, "never"). auto date_time_string = TRY(temporal_date_time_to_string(vm, temporal_date_time->iso_year(), temporal_date_time->iso_month(), temporal_date_time->iso_day(), temporal_date_time->iso_hour(), temporal_date_time->iso_minute(), temporal_date_time->iso_second(), temporal_date_time->iso_millisecond(), temporal_date_time->iso_microsecond(), temporal_date_time->iso_nanosecond(), iso_calendar, precision, "never"sv)); - String offset_string; + DeprecatedString offset_string; // 10. If showOffset is "never", then if (show_offset == "never"sv) { // a. Let offsetString be the empty String. - offset_string = String::empty(); + offset_string = DeprecatedString::empty(); } // 11. Else, else { @@ -332,12 +332,12 @@ ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM& vm, ZonedDateTi offset_string = format_iso_time_zone_offset_string(offset_ns); } - String time_zone_string; + DeprecatedString time_zone_string; // 12. If showTimeZone is "never", then if (show_time_zone == "never"sv) { // a. Let timeZoneString be the empty String. - time_zone_string = String::empty(); + time_zone_string = DeprecatedString::empty(); } // 13. Else, else { @@ -348,14 +348,14 @@ ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM& vm, ZonedDateTi auto flag = show_time_zone == "critical"sv ? "!"sv : ""sv; // c. Let timeZoneString be the string-concatenation of the code unit 0x005B (LEFT SQUARE BRACKET), flag, timeZoneID, and the code unit 0x005D (RIGHT SQUARE BRACKET). - time_zone_string = String::formatted("[{}{}]", flag, time_zone_id); + time_zone_string = DeprecatedString::formatted("[{}{}]", flag, time_zone_id); } // 14. Let calendarString be ? MaybeFormatCalendarAnnotation(zonedDateTime.[[Calendar]], showCalendar). auto calendar_string = TRY(maybe_format_calendar_annotation(vm, &zoned_date_time.calendar(), show_calendar)); // 15. Return the string-concatenation of dateTimeString, offsetString, timeZoneString, and calendarString. - return String::formatted("{}{}{}{}", date_time_string, offset_string, time_zone_string, calendar_string); + return DeprecatedString::formatted("{}{}{}{}", date_time_string, offset_string, time_zone_string, calendar_string); } // 6.5.5 AddZonedDateTime ( epochNanoseconds, timeZone, calendar, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal-addzoneddatetime diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h index 972962b0e8..0c70fe8732 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h @@ -55,7 +55,7 @@ enum class MatchBehavior { ThrowCompletionOr<BigInt const*> interpret_iso_date_time_offset(VM&, i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, OffsetBehavior offset_behavior, double offset_nanoseconds, Value time_zone, StringView disambiguation, StringView offset_option, MatchBehavior match_behavior); ThrowCompletionOr<ZonedDateTime*> to_temporal_zoned_date_time(VM&, Value item, Object const* options = nullptr); ThrowCompletionOr<ZonedDateTime*> create_temporal_zoned_date_time(VM&, BigInt const& epoch_nanoseconds, Object& time_zone, Object& calendar, FunctionObject const* new_target = nullptr); -ThrowCompletionOr<String> temporal_zoned_date_time_to_string(VM&, ZonedDateTime& zoned_date_time, Variant<StringView, u8> const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional<u64> increment = {}, Optional<StringView> unit = {}, Optional<StringView> rounding_mode = {}); +ThrowCompletionOr<DeprecatedString> temporal_zoned_date_time_to_string(VM&, ZonedDateTime& zoned_date_time, Variant<StringView, u8> const& precision, StringView show_calendar, StringView show_time_zone, StringView show_offset, Optional<u64> increment = {}, Optional<StringView> unit = {}, Optional<StringView> rounding_mode = {}); ThrowCompletionOr<BigInt*> add_zoned_date_time(VM&, BigInt const& epoch_nanoseconds, Value time_zone, Object& calendar, double years, double months, double weeks, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds, Object* options = nullptr); ThrowCompletionOr<DurationRecord> difference_zoned_date_time(VM&, BigInt const& nanoseconds1, BigInt const& nanoseconds2, Object& time_zone, Object& calendar, StringView largest_unit, Object const& options); ThrowCompletionOr<NanosecondsToDaysResult> nanoseconds_to_days(VM&, Crypto::SignedBigInteger nanoseconds, Value relative_to); diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h index 5b48d7b0c2..9af87fb998 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h @@ -390,7 +390,7 @@ public: // a. For each integer i starting with 0 such that i < O.[[ArrayLength]], in ascending order, do for (size_t i = 0; i < m_array_length; ++i) { // i. Add ! ToString(𝔽(i)) as the last element of keys. - keys.append(js_string(vm, String::number(i))); + keys.append(js_string(vm, DeprecatedString::number(i))); } } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp index 10d2c920a7..acb6d96cd3 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp @@ -87,7 +87,7 @@ static ThrowCompletionOr<TypedArrayBase*> validate_typed_array_from_this(VM& vm) return typed_array; } -static ThrowCompletionOr<FunctionObject*> callback_from_args(VM& vm, String const& name) +static ThrowCompletionOr<FunctionObject*> callback_from_args(VM& vm, DeprecatedString const& name) { if (vm.argument_count() < 1) return vm.throw_completion<TypeError>(ErrorType::TypedArrayPrototypeOneArg, name); @@ -97,7 +97,7 @@ static ThrowCompletionOr<FunctionObject*> callback_from_args(VM& vm, String cons return &callback.as_function(); } -static ThrowCompletionOr<void> for_each_item(VM& vm, String const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback) +static ThrowCompletionOr<void> for_each_item(VM& vm, DeprecatedString const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback) { auto* typed_array = TRY(validate_typed_array_from_this(vm)); @@ -119,7 +119,7 @@ static ThrowCompletionOr<void> for_each_item(VM& vm, String const& name, Functio return {}; } -static ThrowCompletionOr<void> for_each_item_from_last(VM& vm, String const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback) +static ThrowCompletionOr<void> for_each_item_from_last(VM& vm, DeprecatedString const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback) { auto* typed_array = TRY(validate_typed_array_from_this(vm)); @@ -751,7 +751,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::join) // 4. If separator is undefined, let sep be ",". // 5. Else, let sep be ? ToString(separator). - String separator = ","; + DeprecatedString separator = ","; if (!vm.argument(0).is_undefined()) separator = TRY(vm.argument(0).to_string(vm)); diff --git a/Userland/Libraries/LibJS/Runtime/Utf16String.cpp b/Userland/Libraries/LibJS/Runtime/Utf16String.cpp index 0a34b95783..b9aacbaa5e 100644 --- a/Userland/Libraries/LibJS/Runtime/Utf16String.cpp +++ b/Userland/Libraries/LibJS/Runtime/Utf16String.cpp @@ -97,7 +97,7 @@ Utf16View Utf16String::substring_view(size_t code_unit_offset) const return view().substring_view(code_unit_offset); } -String Utf16String::to_utf8() const +DeprecatedString Utf16String::to_utf8() const { return view().to_utf8(Utf16View::AllowInvalidCodeUnits::Yes); } diff --git a/Userland/Libraries/LibJS/Runtime/Utf16String.h b/Userland/Libraries/LibJS/Runtime/Utf16String.h index a18161e208..32ffa733c8 100644 --- a/Userland/Libraries/LibJS/Runtime/Utf16String.h +++ b/Userland/Libraries/LibJS/Runtime/Utf16String.h @@ -6,9 +6,9 @@ #pragma once +#include <AK/DeprecatedString.h> #include <AK/NonnullRefPtr.h> #include <AK/RefCounted.h> -#include <AK/String.h> #include <AK/Types.h> #include <AK/Vector.h> @@ -48,7 +48,7 @@ public: Utf16View substring_view(size_t code_unit_offset, size_t code_unit_length) const; Utf16View substring_view(size_t code_unit_offset) const; - String to_utf8() const; + DeprecatedString to_utf8() const; u16 code_unit_at(size_t index) const; size_t length_in_code_units() const; diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index f6a36846f6..c6aebf655f 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -41,9 +41,9 @@ VM::VM(OwnPtr<CustomData> custom_data) : m_heap(*this) , m_custom_data(move(custom_data)) { - m_empty_string = m_heap.allocate_without_realm<PrimitiveString>(String::empty()); + m_empty_string = m_heap.allocate_without_realm<PrimitiveString>(DeprecatedString::empty()); for (size_t i = 0; i < 128; ++i) { - m_single_ascii_character_strings[i] = m_heap.allocate_without_realm<PrimitiveString>(String::formatted("{:c}", i)); + m_single_ascii_character_strings[i] = m_heap.allocate_without_realm<PrimitiveString>(DeprecatedString::formatted("{:c}", i)); } // Default hook implementations. These can be overridden by the host, for example, LibWeb overrides the default hooks to place promise jobs on the microtask queue. @@ -110,7 +110,7 @@ VM::VM(OwnPtr<CustomData> custom_data) }; host_get_supported_import_assertions = [&] { - return Vector<String> { "type" }; + return Vector<DeprecatedString> { "type" }; }; // 19.2.1.2 HostEnsureCanCompileStrings ( callerRealm, calleeRealm ), https://tc39.es/ecma262/#sec-hostensurecancompilestrings @@ -231,7 +231,7 @@ void VM::gather_roots(HashTable<Cell*>& roots) roots.set(finalization_registry); } -Symbol* VM::get_global_symbol(String const& description) +Symbol* VM::get_global_symbol(DeprecatedString const& description) { auto result = m_global_symbol_map.get(description); if (result.has_value()) @@ -631,7 +631,7 @@ ThrowCompletionOr<Value> VM::resolve_this_binding() return TRY(environment.get_this_binding(vm)); } -String VM::join_arguments(size_t start_index) const +DeprecatedString VM::join_arguments(size_t start_index) const { StringBuilder joined_arguments; for (size_t i = start_index; i < argument_count(); ++i) { @@ -769,7 +769,7 @@ ScriptOrModule VM::get_active_script_or_module() const return m_execution_context_stack[0]->script_or_module; } -VM::StoredModule* VM::get_stored_module(ScriptOrModule const&, String const& filename, String const&) +VM::StoredModule* VM::get_stored_module(ScriptOrModule const&, DeprecatedString const& filename, DeprecatedString const&) { // Note the spec says: // Each time this operation is called with a specific referencingScriptOrModule, specifier pair as arguments @@ -812,7 +812,7 @@ ThrowCompletionOr<void> VM::link_and_eval_module(Module& module) m_loaded_modules.empend( NonnullGCPtr(module), module.filename(), - String {}, // Null type + DeprecatedString {}, // Null type module, true); stored_module = &m_loaded_modules.last(); @@ -851,7 +851,7 @@ ThrowCompletionOr<void> VM::link_and_eval_module(Module& module) return {}; } -static String resolve_module_filename(StringView filename, StringView module_type) +static DeprecatedString resolve_module_filename(StringView filename, StringView module_type) { auto extensions = Vector<StringView, 2> { "js"sv, "mjs"sv }; if (module_type == "json"sv) @@ -859,14 +859,14 @@ static String resolve_module_filename(StringView filename, StringView module_typ if (!Core::File::exists(filename)) { for (auto extension : extensions) { // import "./foo" -> import "./foo.ext" - auto resolved_filepath = String::formatted("{}.{}", filename, extension); + auto resolved_filepath = DeprecatedString::formatted("{}.{}", filename, extension); if (Core::File::exists(resolved_filepath)) return resolved_filepath; } } else if (Core::File::is_directory(filename)) { for (auto extension : extensions) { // import "./foo" -> import "./foo/index.ext" - auto resolved_filepath = LexicalPath::join(filename, String::formatted("index.{}", extension)).string(); + auto resolved_filepath = LexicalPath::join(filename, DeprecatedString::formatted("index.{}", extension)).string(); if (Core::File::exists(resolved_filepath)) return resolved_filepath; } @@ -893,7 +893,7 @@ ThrowCompletionOr<NonnullGCPtr<Module>> VM::resolve_imported_module(ScriptOrModu // We only allow "type" as a supported assertion so it is the only valid key that should ever arrive here. VERIFY(module_request.assertions.is_empty() || (module_request.assertions.size() == 1 && module_request.assertions.first().key == "type")); - auto module_type = module_request.assertions.is_empty() ? String {} : module_request.assertions.first().value; + auto module_type = module_request.assertions.is_empty() ? DeprecatedString {} : module_request.assertions.first().value; dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] module at {} has type {} [is_null={}]", module_request.module_specifier, module_type, module_type.is_null()); @@ -916,15 +916,15 @@ ThrowCompletionOr<NonnullGCPtr<Module>> VM::resolve_imported_module(ScriptOrModu dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] resolved filename: '{}'", filename); #if JS_MODULE_DEBUG - String referencing_module_string = referencing_script_or_module.visit( - [&](Empty) -> String { + DeprecatedString referencing_module_string = referencing_script_or_module.visit( + [&](Empty) -> DeprecatedString { return "."; }, [&](auto& script_or_module) { if constexpr (IsSame<Script*, decltype(script_or_module)>) { - return String::formatted("Script @ {}", script_or_module.ptr()); + return DeprecatedString::formatted("Script @ {}", script_or_module.ptr()); } - return String::formatted("Module @ {}", script_or_module.ptr()); + return DeprecatedString::formatted("Module @ {}", script_or_module.ptr()); }); dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] resolve_imported_module({}, {})", referencing_module_string, filename); @@ -1012,7 +1012,7 @@ void VM::import_module_dynamically(ScriptOrModule referencing_script_or_module, // If there is no ScriptOrModule in any of the execution contexts if (referencing_script_or_module.has<Empty>()) { // Throw an error for now - promise->reject(InternalError::create(realm, String::formatted(ErrorType::ModuleNotFoundNoReferencingScript.message(), module_request.module_specifier))); + promise->reject(InternalError::create(realm, DeprecatedString::formatted(ErrorType::ModuleNotFoundNoReferencingScript.message(), module_request.module_specifier))); return; } } diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index 63e5a2e52c..e0c5200422 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -73,9 +73,9 @@ public: JS_ENUMERATE_WELL_KNOWN_SYMBOLS #undef __JS_ENUMERATE - Symbol* get_global_symbol(String const& description); + Symbol* get_global_symbol(DeprecatedString const& description); - HashMap<String, PrimitiveString*>& string_cache() { return m_string_cache; } + HashMap<DeprecatedString, PrimitiveString*>& string_cache() { return m_string_cache; } PrimitiveString& empty_string() { return *m_empty_string; } PrimitiveString& single_ascii_character_string(u8 character) { @@ -179,12 +179,12 @@ public: template<typename T, typename... Args> Completion throw_completion(ErrorType type, Args&&... args) { - return throw_completion<T>(String::formatted(type.message(), forward<Args>(args)...)); + return throw_completion<T>(DeprecatedString::formatted(type.message(), forward<Args>(args)...)); } Value construct(FunctionObject&, FunctionObject& new_target, Optional<MarkedVector<Value>> arguments); - String join_arguments(size_t start_index = 0) const; + DeprecatedString join_arguments(size_t start_index = 0) const; Value get_new_target(); @@ -229,7 +229,7 @@ public: Function<HashMap<PropertyKey, Value>(SourceTextModule const&)> host_get_import_meta_properties; Function<void(Object*, SourceTextModule const&)> host_finalize_import_meta; - Function<Vector<String>()> host_get_supported_import_assertions; + Function<Vector<DeprecatedString>()> host_get_supported_import_assertions; void enable_default_host_import_module_dynamically_hook(); @@ -253,7 +253,7 @@ private: void import_module_dynamically(ScriptOrModule referencing_script_or_module, ModuleRequest module_request, PromiseCapability const& promise_capability); void finish_dynamic_import(ScriptOrModule referencing_script_or_module, ModuleRequest module_request, PromiseCapability const& promise_capability, Promise* inner_promise); - HashMap<String, PrimitiveString*> m_string_cache; + HashMap<DeprecatedString, PrimitiveString*> m_string_cache; Heap m_heap; Vector<Interpreter*> m_interpreters; @@ -264,7 +264,7 @@ private: StackInfo m_stack_info; - HashMap<String, Symbol*> m_global_symbol_map; + HashMap<DeprecatedString, Symbol*> m_global_symbol_map; Vector<Function<ThrowCompletionOr<Value>()>> m_promise_jobs; @@ -275,13 +275,13 @@ private: struct StoredModule { ScriptOrModule referencing_script_or_module; - String filename; - String type; + DeprecatedString filename; + DeprecatedString type; Handle<Module> module; bool has_once_started_linking { false }; }; - StoredModule* get_stored_module(ScriptOrModule const& script_or_module, String const& filename, String const& type); + StoredModule* get_stored_module(ScriptOrModule const& script_or_module, DeprecatedString const& filename, DeprecatedString const& type); Vector<StoredModule> m_loaded_modules; diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 7a7a0e3756..2f4ffcdaf0 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -9,8 +9,8 @@ #include <AK/AllOf.h> #include <AK/Assertions.h> #include <AK/CharacterTypes.h> +#include <AK/DeprecatedString.h> #include <AK/FloatingPointStringConversions.h> -#include <AK/String.h> #include <AK/StringBuilder.h> #include <AK/StringFloatingPointConversions.h> #include <AK/Utf8View.h> @@ -71,7 +71,7 @@ ALWAYS_INLINE bool both_bigint(Value const& lhs, Value const& rhs) // 6.1.6.1.20 Number::toString ( x ), https://tc39.es/ecma262/#sec-numeric-types-number-tostring // Implementation for radix = 10 -String number_to_string(double d, NumberToStringMode mode) +DeprecatedString number_to_string(double d, NumberToStringMode mode) { auto convert_to_decimal_digits_array = [](auto x, auto& digits, auto& length) { for (; x; x /= 10) @@ -270,7 +270,7 @@ ThrowCompletionOr<bool> Value::is_regexp(VM& vm) const } // 13.5.3 The typeof Operator, https://tc39.es/ecma262/#sec-typeof-operator -String Value::typeof() const +DeprecatedString Value::typeof() const { if (is_number()) return "number"; @@ -300,7 +300,7 @@ String Value::typeof() const } } -String Value::to_string_without_side_effects() const +DeprecatedString Value::to_string_without_side_effects() const { if (is_double()) return number_to_string(m_value.as_double); @@ -313,7 +313,7 @@ String Value::to_string_without_side_effects() const case BOOLEAN_TAG: return as_bool() ? "true" : "false"; case INT32_TAG: - return String::number(as_i32()); + return DeprecatedString::number(as_i32()); case STRING_TAG: return as_string().string(); case SYMBOL_TAG: @@ -321,7 +321,7 @@ String Value::to_string_without_side_effects() const case BIGINT_TAG: return as_bigint().to_string(); case OBJECT_TAG: - return String::formatted("[object {}]", as_object().class_name()); + return DeprecatedString::formatted("[object {}]", as_object().class_name()); case ACCESSOR_TAG: return "<accessor>"; default: @@ -338,7 +338,7 @@ ThrowCompletionOr<PrimitiveString*> Value::to_primitive_string(VM& vm) } // 7.1.17 ToString ( argument ), https://tc39.es/ecma262/#sec-tostring -ThrowCompletionOr<String> Value::to_string(VM& vm) const +ThrowCompletionOr<DeprecatedString> Value::to_string(VM& vm) const { if (is_double()) return number_to_string(m_value.as_double); @@ -351,7 +351,7 @@ ThrowCompletionOr<String> Value::to_string(VM& vm) const case BOOLEAN_TAG: return as_bool() ? "true"sv : "false"sv; case INT32_TAG: - return String::number(as_i32()); + return DeprecatedString::number(as_i32()); case STRING_TAG: return as_string().string(); case SYMBOL_TAG: @@ -412,7 +412,7 @@ bool Value::to_boolean() const // 7.1.1 ToPrimitive ( input [ , preferredType ] ), https://tc39.es/ecma262/#sec-toprimitive ThrowCompletionOr<Value> Value::to_primitive(VM& vm, PreferredType preferred_type) const { - auto get_hint_for_preferred_type = [&]() -> String { + auto get_hint_for_preferred_type = [&]() -> DeprecatedString { switch (preferred_type) { case PreferredType::Default: return "default"; @@ -532,7 +532,7 @@ static Optional<NumberParseResult> parse_number_text(StringView text) Optional<Value> string_to_number(StringView string) { // 1. Let text be StringToCodePoints(str). - String text = Utf8View(string).trim(whitespace_characters, AK::TrimMode::Both).as_string(); + DeprecatedString text = Utf8View(string).trim(whitespace_characters, AK::TrimMode::Both).as_string(); // 2. Let literal be ParseText(text, StringNumericLiteral). if (text.is_empty()) diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index 4c3fcdcc92..2adbffd8ff 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -11,11 +11,11 @@ #include <AK/Assertions.h> #include <AK/BitCast.h> #include <AK/Concepts.h> +#include <AK/DeprecatedString.h> #include <AK/Format.h> #include <AK/Forward.h> #include <AK/Function.h> #include <AK/Result.h> -#include <AK/String.h> #include <AK/Types.h> #include <LibJS/Forward.h> #include <LibJS/Heap/GCPtr.h> @@ -368,7 +368,7 @@ public: u64 encoded() const { return m_value.encoded; } - ThrowCompletionOr<String> to_string(VM&) const; + ThrowCompletionOr<DeprecatedString> to_string(VM&) const; ThrowCompletionOr<Utf16String> to_utf16_string(VM&) const; ThrowCompletionOr<PrimitiveString*> to_primitive_string(VM&); ThrowCompletionOr<Value> to_primitive(VM&, PreferredType preferred_type = PreferredType::Default) const; @@ -395,7 +395,7 @@ public: ThrowCompletionOr<Value> get(VM&, PropertyKey const&) const; ThrowCompletionOr<FunctionObject*> get_method(VM&, PropertyKey const&) const; - String to_string_without_side_effects() const; + DeprecatedString to_string_without_side_effects() const; Value value_or(Value fallback) const { @@ -404,7 +404,7 @@ public: return *this; } - String typeof() const; + DeprecatedString typeof() const; bool operator==(Value const&) const; @@ -568,7 +568,7 @@ enum class NumberToStringMode { WithExponent, WithoutExponent, }; -String number_to_string(double, NumberToStringMode = NumberToStringMode::WithExponent); +DeprecatedString number_to_string(double, NumberToStringMode = NumberToStringMode::WithExponent); Optional<Value> string_to_number(StringView); inline bool Value::operator==(Value const& value) const { return same_value(*this, value); } diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp index 0e69d09882..509c9711e1 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp @@ -52,7 +52,7 @@ ThrowCompletionOr<Object*> WeakMapConstructor::construct(FunctionObject& new_tar (void)TRY(get_iterator_values(vm, vm.argument(0), [&](Value iterator_value) -> Optional<Completion> { if (!iterator_value.is_object()) - return vm.throw_completion<TypeError>(ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); auto key = TRY(iterator_value.as_object().get(0)); auto value = TRY(iterator_value.as_object().get(1)); |