mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:17:36 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -579,7 +579,7 @@ ThrowCompletionOr<Value> perform_eval(VM& vm, Value x, CallerMode strict_caller,
|
|||
.in_class_field_initializer = in_class_field_initializer,
|
||||
};
|
||||
|
||||
Parser parser { Lexer { code_string.deprecated_string() }, Program::Type::Script, move(initial_state) };
|
||||
Parser parser { Lexer { code_string.byte_string() }, Program::Type::Script, move(initial_state) };
|
||||
auto program = parser.parse_program(strict_caller == CallerMode::Strict);
|
||||
|
||||
// b. If script is a List of errors, throw a SyntaxError exception.
|
||||
|
@ -1289,7 +1289,7 @@ ThrowCompletionOr<String> get_substitution(VM& vm, Utf16View const& matched, Utf
|
|||
TRY_OR_THROW_OOM(vm, result.try_append(curr));
|
||||
} else {
|
||||
auto group_name_view = replace_view.substring_view(start_position, *end_position - start_position);
|
||||
auto group_name = TRY_OR_THROW_OOM(vm, group_name_view.to_deprecated_string(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
auto group_name = TRY_OR_THROW_OOM(vm, group_name_view.to_byte_string(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
|
||||
auto capture = TRY(named_captures.as_object().get(group_name));
|
||||
|
||||
|
@ -1505,7 +1505,7 @@ ThrowCompletionOr<Value> perform_import_call(VM& vm, Value specifier, Value opti
|
|||
|
||||
// 8. Let specifierString be Completion(ToString(specifier)).
|
||||
// 9. IfAbruptRejectPromise(specifierString, promiseCapability).
|
||||
auto specifier_string = TRY_OR_REJECT_WITH_VALUE(vm, promise_capability, specifier.to_deprecated_string(vm));
|
||||
auto specifier_string = TRY_OR_REJECT_WITH_VALUE(vm, promise_capability, specifier.to_byte_string(vm));
|
||||
|
||||
// 10. Let attributes be a new empty List.
|
||||
Vector<ImportAttribute> attributes;
|
||||
|
@ -1569,7 +1569,7 @@ ThrowCompletionOr<Value> perform_import_call(VM& vm, Value specifier, Value opti
|
|||
}
|
||||
|
||||
// 4. Append the ImportAttribute Record { [[Key]]: key, [[Value]]: value } to attributes.
|
||||
attributes.empend(key.as_string().deprecated_string(), value.as_string().deprecated_string());
|
||||
attributes.empend(key.as_string().byte_string(), value.as_string().byte_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> AggregateErrorConstructor::construct(Fun
|
|||
// 3. If message is not undefined, then
|
||||
if (!message.is_undefined()) {
|
||||
// a. Let msg be ? ToString(message).
|
||||
auto msg = TRY(message.to_deprecated_string(vm));
|
||||
auto msg = TRY(message.to_byte_string(vm));
|
||||
|
||||
// b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg).
|
||||
aggregate_error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, msg));
|
||||
|
|
|
@ -261,10 +261,10 @@ ThrowCompletionOr<double> compare_array_elements(VM& vm, Value x, Value y, Funct
|
|||
}
|
||||
|
||||
// 5. Let xString be ? ToString(x).
|
||||
auto x_string = PrimitiveString::create(vm, TRY(x.to_deprecated_string(vm)));
|
||||
auto x_string = PrimitiveString::create(vm, TRY(x.to_byte_string(vm)));
|
||||
|
||||
// 6. Let yString be ? ToString(y).
|
||||
auto y_string = PrimitiveString::create(vm, TRY(y.to_deprecated_string(vm)));
|
||||
auto y_string = PrimitiveString::create(vm, TRY(y.to_byte_string(vm)));
|
||||
|
||||
// 7. Let xSmaller be ! IsLessThan(xString, yString, true).
|
||||
auto x_smaller = MUST(is_less_than(vm, x_string, y_string, true));
|
||||
|
|
|
@ -838,9 +838,9 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join)
|
|||
};
|
||||
|
||||
auto length = TRY(length_of_array_like(vm, this_object));
|
||||
DeprecatedString separator = ",";
|
||||
ByteString separator = ",";
|
||||
if (!vm.argument(0).is_undefined())
|
||||
separator = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
separator = TRY(vm.argument(0).to_byte_string(vm));
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
if (i > 0)
|
||||
|
@ -848,11 +848,11 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join)
|
|||
auto value = TRY(this_object->get(i));
|
||||
if (value.is_nullish())
|
||||
continue;
|
||||
auto string = TRY(value.to_deprecated_string(vm));
|
||||
auto string = TRY(value.to_byte_string(vm));
|
||||
builder.append(string);
|
||||
}
|
||||
|
||||
return PrimitiveString::create(vm, builder.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, builder.to_byte_string());
|
||||
}
|
||||
|
||||
// 23.1.3.19 Array.prototype.keys ( ), https://tc39.es/ecma262/#sec-array.prototype.keys
|
||||
|
@ -1650,7 +1650,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string)
|
|||
auto locale_string_result = TRY(value.invoke(vm, vm.names.toLocaleString, locales, options));
|
||||
|
||||
// ii. Set R to the string-concatenation of R and S.
|
||||
auto string = TRY(locale_string_result.to_deprecated_string(vm));
|
||||
auto string = TRY(locale_string_result.to_byte_string(vm));
|
||||
builder.append(string);
|
||||
}
|
||||
|
||||
|
@ -1658,7 +1658,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string)
|
|||
}
|
||||
|
||||
// 7. Return R.
|
||||
return PrimitiveString::create(vm, builder.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, builder.to_byte_string());
|
||||
}
|
||||
|
||||
// 23.1.3.33 Array.prototype.toReversed ( ), https://tc39.es/ecma262/#sec-array.prototype.toreversed
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; }
|
||||
|
||||
ErrorOr<String> to_string() const;
|
||||
DeprecatedString to_deprecated_string() const { return DeprecatedString::formatted("{}n", m_big_integer.to_base_deprecated(10)); }
|
||||
ByteString to_byte_string() const { return ByteString::formatted("{}n", m_big_integer.to_base_deprecated(10)); }
|
||||
|
||||
private:
|
||||
explicit BigInt(Crypto::SignedBigInteger);
|
||||
|
|
|
@ -40,7 +40,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(DeprecatedString::formatted("bound {}", bound_target_function.name()))
|
||||
, m_name(ByteString::formatted("bound {}", bound_target_function.name()))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -719,7 +719,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 = DeprecatedString::formatted("{}000000000", parsed_fraction);
|
||||
auto fraction = ByteString::formatted("{}000000000", parsed_fraction);
|
||||
|
||||
// c. Let nanosecondsString be the substring of fraction from 1 to 10.
|
||||
auto nanoseconds_string = fraction.substring_view(1, 9);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace JS {
|
|||
JS_DEFINE_ALLOCATOR(DateConstructor);
|
||||
|
||||
// 21.4.3.2 Date.parse ( string ), https://tc39.es/ecma262/#sec-date.parse
|
||||
static double parse_simplified_iso8601(DeprecatedString const& iso_8601)
|
||||
static double parse_simplified_iso8601(ByteString const& iso_8601)
|
||||
{
|
||||
// 21.4.1.15 Date Time String Format, https://tc39.es/ecma262/#sec-date-time-string-format
|
||||
GenericLexer lexer(iso_8601);
|
||||
|
@ -150,7 +150,7 @@ static double parse_simplified_iso8601(DeprecatedString const& iso_8601)
|
|||
return time_clip(time_ms);
|
||||
}
|
||||
|
||||
static double parse_date_string(DeprecatedString const& date_string)
|
||||
static double parse_date_string(ByteString const& date_string)
|
||||
{
|
||||
auto value = parse_simplified_iso8601(date_string);
|
||||
if (isfinite(value))
|
||||
|
@ -246,7 +246,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> DateConstructor::construct(FunctionObjec
|
|||
if (primitive.is_string()) {
|
||||
// 1. Assert: The next step never returns an abrupt completion because Type(v) is String.
|
||||
// 2. Let tv be the result of parsing v as a date, in exactly the same manner as for the parse method (21.4.3.2).
|
||||
time_value = parse_date_string(primitive.as_string().deprecated_string());
|
||||
time_value = parse_date_string(primitive.as_string().byte_string());
|
||||
}
|
||||
// iii. Else,
|
||||
else {
|
||||
|
@ -321,7 +321,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateConstructor::parse)
|
|||
if (!vm.argument_count())
|
||||
return js_nan();
|
||||
|
||||
auto date_string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto date_string = TRY(vm.argument(0).to_byte_string(vm));
|
||||
|
||||
return Value(parse_date_string(date_string));
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/DateConstants.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
|
@ -1068,7 +1068,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_string)
|
|||
}
|
||||
|
||||
// 21.4.4.41.1 TimeString ( tv ), https://tc39.es/ecma262/#sec-timestring
|
||||
DeprecatedString time_string(double time)
|
||||
ByteString time_string(double time)
|
||||
{
|
||||
// 1. Let hour be ToZeroPaddedDecimalString(ℝ(HourFromTime(tv)), 2).
|
||||
auto hour = hour_from_time(time);
|
||||
|
@ -1080,11 +1080,11 @@ DeprecatedString 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 DeprecatedString::formatted("{:02}:{:02}:{:02} GMT", hour, minute, second);
|
||||
return ByteString::formatted("{:02}:{:02}:{:02} GMT", hour, minute, second);
|
||||
}
|
||||
|
||||
// 21.4.4.41.2 DateString ( tv ), https://tc39.es/ecma262/#sec-datestring
|
||||
DeprecatedString date_string(double time)
|
||||
ByteString 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)];
|
||||
|
@ -1103,11 +1103,11 @@ DeprecatedString 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 DeprecatedString::formatted("{} {} {:02} {}{:04}", weekday, month, day, year_sign, abs(year));
|
||||
return ByteString::formatted("{} {} {:02} {}{:04}", weekday, month, day, year_sign, abs(year));
|
||||
}
|
||||
|
||||
// 21.4.4.41.3 TimeZoneString ( tv ), https://tc39.es/ecma262/#sec-timezoneestring
|
||||
DeprecatedString time_zone_string(double time)
|
||||
ByteString time_zone_string(double time)
|
||||
{
|
||||
// 1. Let systemTimeZoneIdentifier be SystemTimeZoneIdentifier().
|
||||
auto system_time_zone_identifier = JS::system_time_zone_identifier();
|
||||
|
@ -1161,11 +1161,11 @@ DeprecatedString time_zone_string(double time)
|
|||
}
|
||||
|
||||
// 10. Return the string-concatenation of offsetSign, offsetHour, offsetMin, and tzName.
|
||||
return DeprecatedString::formatted("{}{:02}{:02} ({})", offset_sign, offset_hour, offset_min, tz_name);
|
||||
return ByteString::formatted("{}{:02}{:02} ({})", offset_sign, offset_hour, offset_min, tz_name);
|
||||
}
|
||||
|
||||
// 21.4.4.41.4 ToDateString ( tv ), https://tc39.es/ecma262/#sec-todatestring
|
||||
DeprecatedString to_date_string(double time)
|
||||
ByteString to_date_string(double time)
|
||||
{
|
||||
// 1. If tv is NaN, return "Invalid Date".
|
||||
if (Value(time).is_nan())
|
||||
|
@ -1175,7 +1175,7 @@ DeprecatedString 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 DeprecatedString::formatted("{} {}{}", date_string(time), time_string(time), time_zone_string(time));
|
||||
return ByteString::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
|
||||
|
@ -1205,7 +1205,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 = DeprecatedString::formatted("{}{}", time_string(local_time(time)), time_zone_string(time));
|
||||
auto string = ByteString::formatted("{}{}", time_string(local_time(time)), time_zone_string(time));
|
||||
return PrimitiveString::create(vm, move(string));
|
||||
}
|
||||
|
||||
|
@ -1237,7 +1237,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 = DeprecatedString::formatted("{}, {:02} {} {}{:04} {}", weekday, day, month, year_sign, abs(year), time_string(time));
|
||||
auto string = ByteString::formatted("{}, {:02} {} {}{:04} {}", weekday, day, month, year_sign, abs(year), time_string(time));
|
||||
return PrimitiveString::create(vm, move(string));
|
||||
}
|
||||
|
||||
|
@ -1250,7 +1250,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::symbol_to_primitive)
|
|||
auto hint_value = vm.argument(0);
|
||||
if (!hint_value.is_string())
|
||||
return vm.throw_completion<TypeError>(ErrorType::InvalidHint, hint_value.to_string_without_side_effects());
|
||||
auto hint = hint_value.as_string().deprecated_string();
|
||||
auto hint = hint_value.as_string().byte_string();
|
||||
Value::PreferredType try_first;
|
||||
if (hint == "string" || hint == "default")
|
||||
try_first = Value::PreferredType::String;
|
||||
|
|
|
@ -74,9 +74,9 @@ private:
|
|||
};
|
||||
|
||||
ThrowCompletionOr<double> this_time_value(VM&, Value value);
|
||||
DeprecatedString time_string(double time);
|
||||
DeprecatedString date_string(double time);
|
||||
DeprecatedString time_zone_string(double time);
|
||||
DeprecatedString to_date_string(double time);
|
||||
ByteString time_string(double time);
|
||||
ByteString date_string(double time);
|
||||
ByteString time_zone_string(double time);
|
||||
ByteString to_date_string(double time);
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace JS {
|
|||
|
||||
JS_DEFINE_ALLOCATOR(ECMAScriptFunctionObject);
|
||||
|
||||
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, 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)
|
||||
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, 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) {
|
||||
|
@ -53,12 +53,12 @@ NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& r
|
|||
return realm.heap().allocate<ECMAScriptFunctionObject>(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, move(local_variables_names), 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));
|
||||
}
|
||||
|
||||
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, 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)
|
||||
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, Object& prototype, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, 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, move(local_variables_names), 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(DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> formal_parameters, i32 function_length, Vector<DeprecatedFlyString> local_variables_names, 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(DeprecatedFlyString name, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> formal_parameters, i32 function_length, Vector<DeprecatedFlyString> local_variables_names, 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)
|
||||
|
@ -1186,7 +1186,7 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
|
|||
if (!parameter.default_value)
|
||||
continue;
|
||||
if (parameter.bytecode_executable.is_null()) {
|
||||
auto executable = TRY(Bytecode::compile(vm, *parameter.default_value, FunctionKind::Normal, DeprecatedString::formatted("default parameter #{} for {}", default_parameter_index++, m_name)));
|
||||
auto executable = TRY(Bytecode::compile(vm, *parameter.default_value, FunctionKind::Normal, ByteString::formatted("default parameter #{} for {}", default_parameter_index++, m_name)));
|
||||
const_cast<FunctionParameter&>(parameter).bytecode_executable = executable;
|
||||
m_default_parameter_bytecode_executables.append(move(executable));
|
||||
} else {
|
||||
|
|
|
@ -38,8 +38,8 @@ public:
|
|||
Global,
|
||||
};
|
||||
|
||||
static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, 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 NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, 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 NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, 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 NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, Object& prototype, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, 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;
|
||||
|
@ -73,8 +73,8 @@ public:
|
|||
Object* home_object() const { return m_home_object; }
|
||||
void set_home_object(Object* home_object) { m_home_object = home_object; }
|
||||
|
||||
DeprecatedString const& source_text() const { return m_source_text; }
|
||||
void set_source_text(DeprecatedString source_text) { m_source_text = move(source_text); }
|
||||
ByteString const& source_text() const { return m_source_text; }
|
||||
void set_source_text(ByteString 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)); }
|
||||
|
@ -104,7 +104,7 @@ protected:
|
|||
virtual Completion ordinary_call_evaluate_body();
|
||||
|
||||
private:
|
||||
ECMAScriptFunctionObject(DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, 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(DeprecatedFlyString name, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, 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;
|
||||
|
@ -130,7 +130,7 @@ private:
|
|||
GCPtr<Realm> m_realm; // [[Realm]]
|
||||
ScriptOrModule m_script_or_module; // [[ScriptOrModule]]
|
||||
GCPtr<Object> m_home_object; // [[HomeObject]]
|
||||
DeprecatedString m_source_text; // [[SourceText]]
|
||||
ByteString 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]]
|
||||
|
|
|
@ -85,7 +85,7 @@ void Error::populate_stack()
|
|||
if (element.source_range.has_value())
|
||||
range = element.source_range.value();
|
||||
TracebackFrame frame {
|
||||
.function_name = context->function_name ? context->function_name->deprecated_string() : "",
|
||||
.function_name = context->function_name ? context->function_name->byte_string() : "",
|
||||
.source_range_storage = range,
|
||||
};
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
|
|||
auto arg_count = args.size();
|
||||
|
||||
// 9. Let P be the empty String.
|
||||
DeprecatedString parameters_string = "";
|
||||
ByteString parameters_string = "";
|
||||
|
||||
Optional<Value> body_arg;
|
||||
|
||||
|
@ -140,29 +140,29 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
|
|||
size_t k = 0;
|
||||
|
||||
// e. Repeat, while k < argCount - 1,
|
||||
Vector<DeprecatedString> parameters;
|
||||
Vector<ByteString> parameters;
|
||||
for (; k < arg_count - 1; ++k) {
|
||||
// i. Let nextArg be args[k].
|
||||
auto next_arg = args[k];
|
||||
|
||||
// ii. Let nextArgString be ? ToString(nextArg).
|
||||
// iii. Set P to the string-concatenation of P, "," (a comma), and nextArgString.
|
||||
parameters.append(TRY(next_arg.to_deprecated_string(vm)));
|
||||
parameters.append(TRY(next_arg.to_byte_string(vm)));
|
||||
|
||||
// iv. Set k to k + 1.
|
||||
}
|
||||
parameters_string = DeprecatedString::join(',', parameters);
|
||||
parameters_string = ByteString::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 = DeprecatedString::formatted("\n{}\n", body_arg.has_value() ? TRY(body_arg->to_deprecated_string(vm)) : "");
|
||||
auto body_string = ByteString::formatted("\n{}\n", body_arg.has_value() ? TRY(body_arg->to_byte_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 = DeprecatedString::formatted("{} anonymous({}\n) {{{}}}", prefix, parameters_string, body_string);
|
||||
auto source_text = ByteString::formatted("{} anonymous({}\n) {{{}}}", prefix, parameters_string, body_string);
|
||||
|
||||
u8 parse_options = FunctionNodeParseOptions::CheckForFunctionAndName;
|
||||
if (kind == FunctionKind::Async || kind == FunctionKind::AsyncGenerator)
|
||||
|
|
|
@ -32,7 +32,7 @@ void FunctionObject::set_function_name(Variant<PropertyKey, PrivateName> const&
|
|||
VERIFY(m_is_extensible);
|
||||
VERIFY(!storage_has(vm.names.name));
|
||||
|
||||
DeprecatedString name;
|
||||
ByteString 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 = DeprecatedString::empty();
|
||||
name = ByteString::empty();
|
||||
// c. Else, set name to the string-concatenation of "[", description, and "]".
|
||||
else
|
||||
name = DeprecatedString::formatted("[{}]", *description);
|
||||
name = ByteString::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 = DeprecatedString::formatted("{} {}", *prefix, name);
|
||||
name = ByteString::formatted("{} {}", *prefix, name);
|
||||
|
||||
// b. If F has an [[InitialName]] internal slot, then
|
||||
if (is<NativeFunction>(this)) {
|
||||
|
|
|
@ -160,7 +160,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 PrimitiveString::create(vm, DeprecatedString::formatted("function {}() {{ [native code] }}", name));
|
||||
return PrimitiveString::create(vm, ByteString::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.
|
||||
|
|
|
@ -387,7 +387,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_int)
|
|||
}
|
||||
|
||||
// 19.2.6.5 Encode ( string, extraUnescaped ), https://tc39.es/ecma262/#sec-encode
|
||||
static ThrowCompletionOr<DeprecatedString> encode(VM& vm, DeprecatedString const& string, StringView unescaped_set)
|
||||
static ThrowCompletionOr<ByteString> encode(VM& vm, ByteString const& string, StringView unescaped_set)
|
||||
{
|
||||
auto utf16_string = Utf16String::create(string);
|
||||
|
||||
|
@ -441,12 +441,12 @@ static ThrowCompletionOr<DeprecatedString> encode(VM& vm, DeprecatedString const
|
|||
VERIFY(nwritten > 0);
|
||||
}
|
||||
}
|
||||
return encoded_builder.to_deprecated_string();
|
||||
return encoded_builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 19.2.6.6 Decode ( string, preserveEscapeSet ), https://tc39.es/ecma262/#sec-decode
|
||||
// FIXME: Add spec comments to this implementation. It deviates a lot, so that's a bit tricky.
|
||||
static ThrowCompletionOr<DeprecatedString> decode(VM& vm, DeprecatedString const& string, StringView reserved_set)
|
||||
static ThrowCompletionOr<ByteString> decode(VM& vm, ByteString const& string, StringView reserved_set)
|
||||
{
|
||||
StringBuilder decoded_builder;
|
||||
auto code_point_start_offset = 0u;
|
||||
|
@ -500,14 +500,14 @@ static ThrowCompletionOr<DeprecatedString> decode(VM& vm, DeprecatedString const
|
|||
}
|
||||
if (expected_continuation_bytes > 0)
|
||||
return vm.throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
return decoded_builder.to_deprecated_string();
|
||||
return decoded_builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 19.2.6.1 decodeURI ( encodedURI ), https://tc39.es/ecma262/#sec-decodeuri-encodeduri
|
||||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri)
|
||||
{
|
||||
// 1. Let uriString be ? ToString(encodedURI).
|
||||
auto uri_string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto uri_string = TRY(vm.argument(0).to_byte_string(vm));
|
||||
|
||||
// 2. Let preserveEscapeSet be ";/?:@&=+$,#".
|
||||
// 3. Return ? Decode(uriString, preserveEscapeSet).
|
||||
|
@ -521,7 +521,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri_component)
|
|||
auto encoded_uri_component = vm.argument(0);
|
||||
|
||||
// 1. Let componentString be ? ToString(encodedURIComponent).
|
||||
auto uri_string = TRY(encoded_uri_component.to_deprecated_string(vm));
|
||||
auto uri_string = TRY(encoded_uri_component.to_byte_string(vm));
|
||||
|
||||
// 2. Let preserveEscapeSet be the empty String.
|
||||
// 3. Return ? Decode(componentString, preserveEscapeSet).
|
||||
|
@ -535,7 +535,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri)
|
|||
auto uri = vm.argument(0);
|
||||
|
||||
// 1. Let uriString be ? ToString(uri).
|
||||
auto uri_string = TRY(uri.to_deprecated_string(vm));
|
||||
auto uri_string = TRY(uri.to_byte_string(vm));
|
||||
|
||||
// 2. Let extraUnescaped be ";/?:@&=+$,#".
|
||||
// 3. Return ? Encode(uriString, extraUnescaped).
|
||||
|
@ -549,7 +549,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri_component)
|
|||
auto uri_component = vm.argument(0);
|
||||
|
||||
// 1. Let componentString be ? ToString(uriComponent).
|
||||
auto uri_string = TRY(uri_component.to_deprecated_string(vm));
|
||||
auto uri_string = TRY(uri_component.to_byte_string(vm));
|
||||
|
||||
// 2. Let extraUnescaped be the empty String.
|
||||
// 3. Return ? Encode(componentString, extraUnescaped).
|
||||
|
@ -561,7 +561,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri_component)
|
|||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::escape)
|
||||
{
|
||||
// 1. Set string to ? ToString(string).
|
||||
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto string = TRY(vm.argument(0).to_byte_string(vm));
|
||||
|
||||
// 3. Let R be the empty String.
|
||||
StringBuilder escaped;
|
||||
|
@ -601,14 +601,14 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::escape)
|
|||
}
|
||||
|
||||
// 7. Return R.
|
||||
return PrimitiveString::create(vm, escaped.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, escaped.to_byte_string());
|
||||
}
|
||||
|
||||
// B.2.1.2 unescape ( string ), https://tc39.es/ecma262/#sec-unescape-string
|
||||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::unescape)
|
||||
{
|
||||
// 1. Set string to ? ToString(string).
|
||||
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto string = TRY(vm.argument(0).to_byte_string(vm));
|
||||
|
||||
// 2. Let length be the length of string.
|
||||
ssize_t length = string.length();
|
||||
|
@ -658,7 +658,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::unescape)
|
|||
}
|
||||
|
||||
// 6. Return R.
|
||||
return PrimitiveString::create(vm, unescaped.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, unescaped.to_byte_string());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ bool is_valid_duration_record(Temporal::DurationRecord const& record)
|
|||
ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String const& unit, Object const& options, StringView base_style, ReadonlySpan<StringView> 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.to_deprecated_string(), OptionType::String, styles_list, Empty {}));
|
||||
auto style_value = TRY(get_option(vm, options, unit.to_byte_string(), OptionType::String, styles_list, Empty {}));
|
||||
|
||||
// 2. Let displayDefault be "always".
|
||||
auto display_default = "always"sv;
|
||||
|
@ -319,7 +319,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String
|
|||
auto display_field = MUST(String::formatted("{}Display", unit));
|
||||
|
||||
// 5. Let display be ? GetOption(options, displayField, string, « "auto", "always" », displayDefault).
|
||||
auto display = TRY(get_option(vm, options, display_field.to_deprecated_string(), OptionType::String, { "auto"sv, "always"sv }, display_default));
|
||||
auto display = TRY(get_option(vm, options, display_field.to_byte_string(), OptionType::String, { "auto"sv, "always"sv }, display_default));
|
||||
|
||||
// 6. If prevStyle is "numeric" or "2-digit", then
|
||||
if (previous_style == "numeric"sv || previous_style == "2-digit"sv) {
|
||||
|
|
|
@ -47,7 +47,7 @@ void JSONObject::initialize(Realm& realm)
|
|||
}
|
||||
|
||||
// 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify
|
||||
ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space)
|
||||
ThrowCompletionOr<Optional<ByteString>> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -61,18 +61,18 @@ ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::stringify_impl(VM& vm,
|
|||
if (is_array) {
|
||||
auto& replacer_object = replacer.as_object();
|
||||
auto replacer_length = TRY(length_of_array_like(vm, replacer_object));
|
||||
Vector<DeprecatedString> list;
|
||||
Vector<ByteString> list;
|
||||
for (size_t i = 0; i < replacer_length; ++i) {
|
||||
auto replacer_value = TRY(replacer_object.get(i));
|
||||
Optional<DeprecatedString> item;
|
||||
Optional<ByteString> item;
|
||||
if (replacer_value.is_string()) {
|
||||
item = replacer_value.as_string().deprecated_string();
|
||||
item = replacer_value.as_string().byte_string();
|
||||
} else if (replacer_value.is_number()) {
|
||||
item = MUST(replacer_value.to_deprecated_string(vm));
|
||||
item = MUST(replacer_value.to_byte_string(vm));
|
||||
} else if (replacer_value.is_object()) {
|
||||
auto& value_object = replacer_value.as_object();
|
||||
if (is<StringObject>(value_object) || is<NumberObject>(value_object))
|
||||
item = TRY(replacer_value.to_deprecated_string(vm));
|
||||
item = TRY(replacer_value.to_byte_string(vm));
|
||||
}
|
||||
if (item.has_value() && !list.contains_slow(*item)) {
|
||||
list.append(*item);
|
||||
|
@ -94,20 +94,20 @@ ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::stringify_impl(VM& vm,
|
|||
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 ? DeprecatedString::empty() : DeprecatedString::repeated(' ', space_mv);
|
||||
state.gap = space_mv < 1 ? ByteString::empty() : ByteString::repeated(' ', space_mv);
|
||||
} else if (space.is_string()) {
|
||||
auto string = space.as_string().deprecated_string();
|
||||
auto string = space.as_string().byte_string();
|
||||
if (string.length() <= 10)
|
||||
state.gap = string;
|
||||
else
|
||||
state.gap = string.substring(0, 10);
|
||||
} else {
|
||||
state.gap = DeprecatedString::empty();
|
||||
state.gap = ByteString::empty();
|
||||
}
|
||||
|
||||
auto wrapper = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
MUST(wrapper->create_data_property_or_throw(DeprecatedString::empty(), value));
|
||||
return serialize_json_property(vm, state, DeprecatedString::empty(), wrapper);
|
||||
MUST(wrapper->create_data_property_or_throw(ByteString::empty(), value));
|
||||
return serialize_json_property(vm, state, ByteString::empty(), wrapper);
|
||||
}
|
||||
|
||||
// 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify
|
||||
|
@ -128,7 +128,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::stringify)
|
|||
}
|
||||
|
||||
// 25.5.2.1 SerializeJSONProperty ( state, key, holder ), https://tc39.es/ecma262/#sec-serializejsonproperty
|
||||
ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::serialize_json_property(VM& vm, StringifyState& state, PropertyKey const& key, Object* holder)
|
||||
ThrowCompletionOr<Optional<ByteString>> 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));
|
||||
|
@ -188,13 +188,13 @@ ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::serialize_json_propert
|
|||
|
||||
// 8. If Type(value) is String, return QuoteJSONString(value).
|
||||
if (value.is_string())
|
||||
return quote_json_string(value.as_string().deprecated_string());
|
||||
return quote_json_string(value.as_string().byte_string());
|
||||
|
||||
// 9. If Type(value) is Number, then
|
||||
if (value.is_number()) {
|
||||
// a. If value is finite, return ! ToString(value).
|
||||
if (value.is_finite_number())
|
||||
return MUST(value.to_deprecated_string(vm));
|
||||
return MUST(value.to_byte_string(vm));
|
||||
|
||||
// b. Return "null".
|
||||
return "null"sv;
|
||||
|
@ -218,26 +218,26 @@ ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::serialize_json_propert
|
|||
}
|
||||
|
||||
// 12. Return undefined.
|
||||
return Optional<DeprecatedString> {};
|
||||
return Optional<ByteString> {};
|
||||
}
|
||||
|
||||
// 25.5.2.4 SerializeJSONObject ( state, value ), https://tc39.es/ecma262/#sec-serializejsonobject
|
||||
ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_object(VM& vm, StringifyState& state, Object& object)
|
||||
ThrowCompletionOr<ByteString> 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);
|
||||
DeprecatedString previous_indent = state.indent;
|
||||
state.indent = DeprecatedString::formatted("{}{}", state.indent, state.gap);
|
||||
Vector<DeprecatedString> property_strings;
|
||||
ByteString previous_indent = state.indent;
|
||||
state.indent = ByteString::formatted("{}{}", state.indent, state.gap);
|
||||
Vector<ByteString> 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.has_value()) {
|
||||
property_strings.append(DeprecatedString::formatted(
|
||||
property_strings.append(ByteString::formatted(
|
||||
"{}:{}{}",
|
||||
quote_json_string(key.to_string()),
|
||||
state.gap.is_empty() ? "" : " ",
|
||||
|
@ -253,7 +253,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_object(VM& vm, St
|
|||
} else {
|
||||
auto property_list = TRY(object.enumerable_own_property_names(PropertyKind::Key));
|
||||
for (auto& property : property_list)
|
||||
TRY(process_property(property.as_string().deprecated_string()));
|
||||
TRY(process_property(property.as_string().byte_string()));
|
||||
}
|
||||
StringBuilder builder;
|
||||
if (property_strings.is_empty()) {
|
||||
|
@ -271,7 +271,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_object(VM& vm, St
|
|||
} else {
|
||||
builder.append('\n');
|
||||
builder.append(state.indent);
|
||||
auto separator = DeprecatedString::formatted(",\n{}", state.indent);
|
||||
auto separator = ByteString::formatted(",\n{}", state.indent);
|
||||
for (auto& property_string : property_strings) {
|
||||
if (!first)
|
||||
builder.append(separator);
|
||||
|
@ -286,19 +286,19 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_object(VM& vm, St
|
|||
|
||||
state.seen_objects.remove(&object);
|
||||
state.indent = previous_indent;
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 25.5.2.5 SerializeJSONArray ( state, value ), https://tc39.es/ecma262/#sec-serializejsonarray
|
||||
ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_array(VM& vm, StringifyState& state, Object& object)
|
||||
ThrowCompletionOr<ByteString> 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);
|
||||
DeprecatedString previous_indent = state.indent;
|
||||
state.indent = DeprecatedString::formatted("{}{}", state.indent, state.gap);
|
||||
Vector<DeprecatedString> property_strings;
|
||||
ByteString previous_indent = state.indent;
|
||||
state.indent = ByteString::formatted("{}{}", state.indent, state.gap);
|
||||
Vector<ByteString> property_strings;
|
||||
|
||||
auto length = TRY(length_of_array_like(vm, object));
|
||||
|
||||
|
@ -331,7 +331,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_array(VM& vm, Str
|
|||
} else {
|
||||
builder.append("[\n"sv);
|
||||
builder.append(state.indent);
|
||||
auto separator = DeprecatedString::formatted(",\n{}", state.indent);
|
||||
auto separator = ByteString::formatted(",\n{}", state.indent);
|
||||
bool first = true;
|
||||
for (auto& property_string : property_strings) {
|
||||
if (!first)
|
||||
|
@ -347,11 +347,11 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_array(VM& vm, Str
|
|||
|
||||
state.seen_objects.remove(&object);
|
||||
state.indent = previous_indent;
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 25.5.2.2 QuoteJSONString ( value ), https://tc39.es/ecma262/#sec-quotejsonstring
|
||||
DeprecatedString JSONObject::quote_json_string(DeprecatedString string)
|
||||
ByteString JSONObject::quote_json_string(ByteString string)
|
||||
{
|
||||
// 1. Let product be the String value consisting solely of the code unit 0x0022 (QUOTATION MARK).
|
||||
StringBuilder builder;
|
||||
|
@ -402,7 +402,7 @@ DeprecatedString JSONObject::quote_json_string(DeprecatedString string)
|
|||
builder.append('"');
|
||||
|
||||
// 4. Return product.
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 25.5.1 JSON.parse ( text [ , reviver ] ), https://tc39.es/ecma262/#sec-json.parse
|
||||
|
@ -410,7 +410,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse)
|
|||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto string = TRY(vm.argument(0).to_byte_string(vm));
|
||||
auto reviver = vm.argument(1);
|
||||
|
||||
auto json = JsonValue::from_string(string);
|
||||
|
@ -419,7 +419,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 = DeprecatedString::empty();
|
||||
auto root_name = ByteString::empty();
|
||||
MUST(root->create_data_property_or_throw(root_name, unfiltered));
|
||||
return internalize_json_property(vm, root, root_name, reviver.as_function());
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ Value JSONObject::parse_json_value(VM& vm, JsonValue const& value)
|
|||
if (value.is_number())
|
||||
return Value(value.to_double(0));
|
||||
if (value.is_string())
|
||||
return PrimitiveString::create(vm, value.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, value.to_byte_string());
|
||||
if (value.is_bool())
|
||||
return Value(static_cast<bool>(value.as_bool()));
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -490,7 +490,7 @@ ThrowCompletionOr<Value> JSONObject::internalize_json_property(VM& vm, Object* h
|
|||
} else {
|
||||
auto property_list = TRY(value_object.enumerable_own_property_names(Object::PropertyKind::Key));
|
||||
for (auto& property_key : property_list)
|
||||
TRY(process_property(property_key.as_string().deprecated_string()));
|
||||
TRY(process_property(property_key.as_string().byte_string()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,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<Optional<DeprecatedString>> stringify_impl(VM&, Value value, Value replacer, Value space);
|
||||
static ThrowCompletionOr<Optional<ByteString>> stringify_impl(VM&, Value value, Value replacer, Value space);
|
||||
|
||||
static Value parse_json_value(VM&, JsonValue const&);
|
||||
|
||||
|
@ -30,16 +30,16 @@ private:
|
|||
struct StringifyState {
|
||||
GCPtr<FunctionObject> replacer_function;
|
||||
HashTable<GCPtr<Object>> seen_objects;
|
||||
DeprecatedString indent { DeprecatedString::empty() };
|
||||
DeprecatedString gap;
|
||||
Optional<Vector<DeprecatedString>> property_list;
|
||||
ByteString indent { ByteString::empty() };
|
||||
ByteString gap;
|
||||
Optional<Vector<ByteString>> property_list;
|
||||
};
|
||||
|
||||
// Stringify helpers
|
||||
static ThrowCompletionOr<Optional<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);
|
||||
static ThrowCompletionOr<Optional<ByteString>> serialize_json_property(VM&, StringifyState&, PropertyKey const& key, Object* holder);
|
||||
static ThrowCompletionOr<ByteString> serialize_json_object(VM&, StringifyState&, Object&);
|
||||
static ThrowCompletionOr<ByteString> serialize_json_array(VM&, StringifyState&, Object&);
|
||||
static ByteString quote_json_string(ByteString);
|
||||
|
||||
// Parse helpers
|
||||
static Object* parse_json_object(VM&, JsonObject const&);
|
||||
|
|
|
@ -60,7 +60,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> MapConstructor::construct(FunctionObject
|
|||
|
||||
(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, DeprecatedString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, ByteString::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));
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
namespace JS {
|
||||
|
||||
struct ModuleWithSpecifier {
|
||||
DeprecatedString specifier; // [[Specifier]]
|
||||
ByteString specifier; // [[Specifier]]
|
||||
NonnullGCPtr<Module> module; // [[Module]]
|
||||
};
|
||||
|
||||
// https://tc39.es/proposal-import-attributes/#importattribute-record
|
||||
struct ImportAttribute {
|
||||
DeprecatedString key;
|
||||
DeprecatedString value;
|
||||
ByteString key;
|
||||
ByteString value;
|
||||
};
|
||||
|
||||
// https://tc39.es/proposal-import-attributes/#modulerequest-record
|
||||
|
@ -35,7 +35,7 @@ struct ModuleRequest {
|
|||
|
||||
ModuleRequest(DeprecatedFlyString specifier, Vector<ImportAttribute> attributes);
|
||||
|
||||
void add_attribute(DeprecatedString key, DeprecatedString value)
|
||||
void add_attribute(ByteString key, ByteString value)
|
||||
{
|
||||
attributes.empend(move(key), move(value));
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
|
|||
|
||||
// 4. If x is not finite, return Number::toString(x).
|
||||
if (!number_value.is_finite_number())
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_byte_string(vm)));
|
||||
|
||||
// 5. If f < 0 or f > 100, throw a RangeError exception.
|
||||
if (fraction_digits < 0 || fraction_digits > 100)
|
||||
|
@ -104,7 +104,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
|
|||
// 7. Let s be the empty String.
|
||||
auto sign = ""sv;
|
||||
|
||||
DeprecatedString number_string;
|
||||
ByteString number_string;
|
||||
int exponent = 0;
|
||||
|
||||
// 8. If x < 0, then
|
||||
|
@ -119,7 +119,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 = DeprecatedString::repeated('0', fraction_digits + 1);
|
||||
number_string = ByteString::repeated('0', fraction_digits + 1);
|
||||
|
||||
// b. Let e be 0.
|
||||
exponent = 0;
|
||||
|
@ -147,7 +147,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
|
|||
number = round(number / pow(10, exponent - fraction_digits));
|
||||
|
||||
// c. Let m be the String value consisting of the digits of the decimal representation of n (in order, with no leading zeroes).
|
||||
number_string = number_to_deprecated_string(number, NumberToStringMode::WithoutExponent);
|
||||
number_string = number_to_byte_string(number, NumberToStringMode::WithoutExponent);
|
||||
}
|
||||
|
||||
// 11. If f ≠ 0, then
|
||||
|
@ -159,11 +159,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 = DeprecatedString::formatted("{}.{}", first, second);
|
||||
number_string = ByteString::formatted("{}.{}", first, second);
|
||||
}
|
||||
|
||||
char exponent_sign = 0;
|
||||
DeprecatedString exponent_string;
|
||||
ByteString exponent_string;
|
||||
|
||||
// 12. If e = 0, then
|
||||
if (exponent == 0) {
|
||||
|
@ -192,12 +192,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 = DeprecatedString::number(exponent);
|
||||
exponent_string = ByteString::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 PrimitiveString::create(vm, DeprecatedString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string));
|
||||
return PrimitiveString::create(vm, ByteString::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
|
||||
|
@ -220,7 +220,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed)
|
|||
|
||||
// 6. If x is not finite, return Number::toString(x).
|
||||
if (!number_value.is_finite_number())
|
||||
return PrimitiveString::create(vm, TRY(number_value.to_deprecated_string(vm)));
|
||||
return PrimitiveString::create(vm, TRY(number_value.to_byte_string(vm)));
|
||||
|
||||
// 7. Set x to ℝ(x).
|
||||
auto number = number_value.as_double();
|
||||
|
@ -236,7 +236,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed)
|
|||
// 10. If x ≥ 10^21, then
|
||||
// a. Let m be ! ToString(𝔽(x)).
|
||||
if (number >= 1e+21)
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_byte_string(vm)));
|
||||
|
||||
// 11. Else,
|
||||
// a. Let n be an integer for which n / (10^f) - x is as close to zero as possible. If there are two such n, pick the larger n.
|
||||
|
@ -256,8 +256,8 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed)
|
|||
// `number` double. Instead of generating a huge, unwieldy `n`, we format
|
||||
// the double using our existing formatting code.
|
||||
|
||||
auto number_format_string = DeprecatedString::formatted("{{}}{{:.{}f}}", fraction_digits);
|
||||
return PrimitiveString::create(vm, DeprecatedString::formatted(number_format_string, s, number));
|
||||
auto number_format_string = ByteString::formatted("{{}}{{:.{}f}}", fraction_digits);
|
||||
return PrimitiveString::create(vm, ByteString::formatted(number_format_string, s, number));
|
||||
}
|
||||
|
||||
// 19.2.1 Number.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-number.prototype.tolocalestring
|
||||
|
@ -289,14 +289,14 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
|
|||
|
||||
// 2. If precision is undefined, return ! ToString(x).
|
||||
if (precision_value.is_undefined())
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_byte_string(vm)));
|
||||
|
||||
// 3. Let p be ? ToIntegerOrInfinity(precision).
|
||||
auto precision = TRY(precision_value.to_integer_or_infinity(vm));
|
||||
|
||||
// 4. If x is not finite, return Number::toString(x).
|
||||
if (!number_value.is_finite_number())
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_byte_string(vm)));
|
||||
|
||||
// 5. If p < 1 or p > 100, throw a RangeError exception.
|
||||
if ((precision < 1) || (precision > 100))
|
||||
|
@ -308,7 +308,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
|
|||
// 7. Let s be the empty String.
|
||||
auto sign = ""sv;
|
||||
|
||||
DeprecatedString number_string;
|
||||
ByteString number_string;
|
||||
int exponent = 0;
|
||||
|
||||
// 8. If x < 0, then
|
||||
|
@ -323,7 +323,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 = DeprecatedString::repeated('0', precision);
|
||||
number_string = ByteString::repeated('0', precision);
|
||||
|
||||
// b. Let e be 0.
|
||||
exponent = 0;
|
||||
|
@ -336,7 +336,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
|
|||
number = round(number / pow(10, exponent - precision + 1));
|
||||
|
||||
// b. Let m be the String value consisting of the digits of the decimal representation of n (in order, with no leading zeroes).
|
||||
number_string = number_to_deprecated_string(number, NumberToStringMode::WithoutExponent);
|
||||
number_string = number_to_byte_string(number, NumberToStringMode::WithoutExponent);
|
||||
|
||||
// c. If e < -6 or e ≥ p, then
|
||||
if ((exponent < -6) || (exponent >= precision)) {
|
||||
|
@ -352,7 +352,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 = DeprecatedString::formatted("{}.{}", first, second);
|
||||
number_string = ByteString::formatted("{}.{}", first, second);
|
||||
}
|
||||
|
||||
char exponent_sign = 0;
|
||||
|
@ -375,21 +375,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 = DeprecatedString::number(exponent);
|
||||
auto exponent_string = ByteString::number(exponent);
|
||||
|
||||
// vi. Return the string-concatenation of s, m, the code unit 0x0065 (LATIN SMALL LETTER E), c, and d.
|
||||
return PrimitiveString::create(vm, DeprecatedString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string));
|
||||
return PrimitiveString::create(vm, ByteString::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 PrimitiveString::create(vm, DeprecatedString::formatted("{}{}", sign, number_string));
|
||||
return PrimitiveString::create(vm, ByteString::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 = DeprecatedString::formatted(
|
||||
number_string = ByteString::formatted(
|
||||
"{}.{}",
|
||||
number_string.substring_view(0, exponent + 1),
|
||||
number_string.substring_view(exponent + 1));
|
||||
|
@ -397,14 +397,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 = DeprecatedString::formatted(
|
||||
number_string = ByteString::formatted(
|
||||
"0.{}{}",
|
||||
DeprecatedString::repeated('0', -1 * (exponent + 1)),
|
||||
ByteString::repeated('0', -1 * (exponent + 1)),
|
||||
number_string);
|
||||
}
|
||||
|
||||
// 14. Return the string-concatenation of s and m.
|
||||
return PrimitiveString::create(vm, DeprecatedString::formatted("{}{}", sign, number_string));
|
||||
return PrimitiveString::create(vm, ByteString::formatted("{}{}", sign, number_string));
|
||||
}
|
||||
|
||||
// 21.1.3.6 Number.prototype.toString ( [ radix ] ), https://tc39.es/ecma262/#sec-number.prototype.tostring
|
||||
|
@ -428,7 +428,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string)
|
|||
|
||||
// 5. If radixMV = 10, return ! ToString(x).
|
||||
if (radix_mv == 10)
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_byte_string(vm)));
|
||||
|
||||
// 6. Return the String representation of this Number value using the radix specified by radixMV. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in 6.1.6.1.20.
|
||||
if (number_value.is_positive_infinity())
|
||||
|
@ -487,7 +487,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string)
|
|||
characters.take_last();
|
||||
}
|
||||
|
||||
return PrimitiveString::create(vm, DeprecatedString(characters.data(), characters.size()));
|
||||
return PrimitiveString::create(vm, ByteString(characters.data(), characters.size()));
|
||||
}
|
||||
|
||||
// 21.1.3.7 Number.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-number.prototype.valueof
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Accessor.h>
|
||||
|
@ -1042,7 +1042,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(PrimitiveString::create(vm, DeprecatedString::number(entry.index())));
|
||||
keys.append(PrimitiveString::create(vm, ByteString::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
|
||||
|
@ -1347,7 +1347,7 @@ Optional<Completion> Object::enumerate_object_properties(Function<Optional<Compl
|
|||
for (auto& key : own_keys) {
|
||||
if (!key.is_string())
|
||||
continue;
|
||||
DeprecatedFlyString property_key = key.as_string().deprecated_string();
|
||||
DeprecatedFlyString property_key = key.as_string().byte_string();
|
||||
if (visited.contains(property_key))
|
||||
continue;
|
||||
auto descriptor = TRY(target->internal_get_own_property(property_key));
|
||||
|
|
|
@ -278,7 +278,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries)
|
|||
// 6. Return ? AddEntriesFromIterable(obj, iterable, adder).
|
||||
(void)TRY(get_iterator_values(vm, iterable, [&](Value iterator_value) -> Optional<Completion> {
|
||||
if (!iterator_value.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, ByteString::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));
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Accessor.h>
|
||||
|
@ -147,7 +147,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string)
|
|||
// 4. Let isArray be ? IsArray(O).
|
||||
auto is_array = TRY(Value(object).is_array(vm));
|
||||
|
||||
DeprecatedString builtin_tag;
|
||||
ByteString builtin_tag;
|
||||
|
||||
// 5. If isArray is true, let builtinTag be "Array".
|
||||
if (is_array)
|
||||
|
@ -184,16 +184,16 @@ 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.
|
||||
DeprecatedString tag;
|
||||
ByteString tag;
|
||||
|
||||
// 16. If Type(tag) is not String, set tag to builtinTag.
|
||||
if (!to_string_tag.is_string())
|
||||
tag = move(builtin_tag);
|
||||
else
|
||||
tag = to_string_tag.as_string().deprecated_string();
|
||||
tag = to_string_tag.as_string().byte_string();
|
||||
|
||||
// 17. Return the string-concatenation of "[object ", tag, and "]".
|
||||
return PrimitiveString::create(vm, DeprecatedString::formatted("[object {}]", tag));
|
||||
return PrimitiveString::create(vm, ByteString::formatted("[object {}]", tag));
|
||||
}
|
||||
|
||||
// 20.1.3.7 Object.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-object.prototype.valueof
|
||||
|
|
|
@ -33,8 +33,8 @@ PrimitiveString::PrimitiveString(String string)
|
|||
{
|
||||
}
|
||||
|
||||
PrimitiveString::PrimitiveString(DeprecatedString string)
|
||||
: m_deprecated_string(move(string))
|
||||
PrimitiveString::PrimitiveString(ByteString string)
|
||||
: m_byte_string(move(string))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,8 @@ PrimitiveString::~PrimitiveString()
|
|||
{
|
||||
if (has_utf8_string())
|
||||
vm().string_cache().remove(*m_utf8_string);
|
||||
if (has_deprecated_string())
|
||||
vm().deprecated_string_cache().remove(*m_deprecated_string);
|
||||
if (has_byte_string())
|
||||
vm().byte_string_cache().remove(*m_byte_string);
|
||||
}
|
||||
|
||||
void PrimitiveString::visit_edges(Cell::Visitor& visitor)
|
||||
|
@ -71,8 +71,8 @@ bool PrimitiveString::is_empty() const
|
|||
return m_utf16_string->is_empty();
|
||||
if (has_utf8_string())
|
||||
return m_utf8_string->is_empty();
|
||||
if (has_deprecated_string())
|
||||
return m_deprecated_string->is_empty();
|
||||
if (has_byte_string())
|
||||
return m_byte_string->is_empty();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
|
@ -81,8 +81,8 @@ String PrimitiveString::utf8_string() const
|
|||
resolve_rope_if_needed(EncodingPreference::UTF8);
|
||||
|
||||
if (!has_utf8_string()) {
|
||||
if (has_deprecated_string())
|
||||
m_utf8_string = MUST(String::from_deprecated_string(*m_deprecated_string));
|
||||
if (has_byte_string())
|
||||
m_utf8_string = MUST(String::from_byte_string(*m_byte_string));
|
||||
else if (has_utf16_string())
|
||||
m_utf8_string = m_utf16_string->to_utf8();
|
||||
else
|
||||
|
@ -98,20 +98,20 @@ StringView PrimitiveString::utf8_string_view() const
|
|||
return m_utf8_string->bytes_as_string_view();
|
||||
}
|
||||
|
||||
DeprecatedString PrimitiveString::deprecated_string() const
|
||||
ByteString PrimitiveString::byte_string() const
|
||||
{
|
||||
resolve_rope_if_needed(EncodingPreference::UTF8);
|
||||
|
||||
if (!has_deprecated_string()) {
|
||||
if (!has_byte_string()) {
|
||||
if (has_utf8_string())
|
||||
m_deprecated_string = m_utf8_string->to_deprecated_string();
|
||||
m_byte_string = m_utf8_string->to_byte_string();
|
||||
else if (has_utf16_string())
|
||||
m_deprecated_string = m_utf16_string->to_deprecated_string();
|
||||
m_byte_string = m_utf16_string->to_byte_string();
|
||||
else
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
return *m_deprecated_string;
|
||||
return *m_byte_string;
|
||||
}
|
||||
|
||||
Utf16String PrimitiveString::utf16_string() const
|
||||
|
@ -122,8 +122,8 @@ Utf16String PrimitiveString::utf16_string() const
|
|||
if (has_utf8_string()) {
|
||||
m_utf16_string = Utf16String::create(m_utf8_string->bytes_as_string_view());
|
||||
} else {
|
||||
VERIFY(has_deprecated_string());
|
||||
m_utf16_string = Utf16String::create(*m_deprecated_string);
|
||||
VERIFY(has_byte_string());
|
||||
m_utf16_string = Utf16String::create(*m_byte_string);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, StringView string)
|
|||
return create(vm, String::from_utf8(string).release_value());
|
||||
}
|
||||
|
||||
NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, DeprecatedString string)
|
||||
NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, ByteString string)
|
||||
{
|
||||
if (string.is_empty())
|
||||
return vm.empty_string();
|
||||
|
@ -211,7 +211,7 @@ NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, DeprecatedString s
|
|||
return vm.single_ascii_character_string(ch);
|
||||
}
|
||||
|
||||
auto& string_cache = vm.deprecated_string_cache();
|
||||
auto& string_cache = vm.byte_string_cache();
|
||||
auto it = string_cache.find(string);
|
||||
if (it == string_cache.end()) {
|
||||
auto new_string = vm.heap().allocate_without_realm<PrimitiveString>(string);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
|
@ -28,7 +28,7 @@ public:
|
|||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, Utf16String);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, String);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, FlyString const&);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, DeprecatedString);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, ByteString);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, DeprecatedFlyString const&);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, PrimitiveString&, PrimitiveString&);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, StringView);
|
||||
|
@ -44,8 +44,8 @@ public:
|
|||
[[nodiscard]] StringView utf8_string_view() const;
|
||||
bool has_utf8_string() const { return m_utf8_string.has_value(); }
|
||||
|
||||
[[nodiscard]] DeprecatedString deprecated_string() const;
|
||||
bool has_deprecated_string() const { return m_deprecated_string.has_value(); }
|
||||
[[nodiscard]] ByteString byte_string() const;
|
||||
bool has_byte_string() const { return m_byte_string.has_value(); }
|
||||
|
||||
[[nodiscard]] Utf16String utf16_string() const;
|
||||
[[nodiscard]] Utf16View utf16_string_view() const;
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
private:
|
||||
explicit PrimitiveString(PrimitiveString&, PrimitiveString&);
|
||||
explicit PrimitiveString(String);
|
||||
explicit PrimitiveString(DeprecatedString);
|
||||
explicit PrimitiveString(ByteString);
|
||||
explicit PrimitiveString(Utf16String);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
@ -73,7 +73,7 @@ private:
|
|||
mutable GCPtr<PrimitiveString> m_rhs;
|
||||
|
||||
mutable Optional<String> m_utf8_string;
|
||||
mutable Optional<DeprecatedString> m_deprecated_string;
|
||||
mutable Optional<ByteString> m_byte_string;
|
||||
mutable Optional<Utf16String> m_utf16_string;
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Format.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<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)));
|
||||
Vector<ByteString> parts;
|
||||
parts.append(ByteString::formatted("[[Writable]]: {}", property_attributes.is_writable()));
|
||||
parts.append(ByteString::formatted("[[Enumerable]]: {}", property_attributes.is_enumerable()));
|
||||
parts.append(ByteString::formatted("[[Configurable]]: {}", property_attributes.is_configurable()));
|
||||
return Formatter<StringView>::format(builder, ByteString::formatted("PropertyAttributes {{ {} }}", ByteString::join(", "sv, parts)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
return PropertyKey { value.as_symbol() };
|
||||
if (value.is_integral_number() && value.as_double() >= 0 && value.as_double() < NumericLimits<u32>::max())
|
||||
return static_cast<u32>(value.as_double());
|
||||
return TRY(value.to_deprecated_string(vm));
|
||||
return TRY(value.to_byte_string(vm));
|
||||
}
|
||||
|
||||
PropertyKey() = default;
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
VERIFY(index >= 0);
|
||||
if constexpr (NumericLimits<T>::max() >= NumericLimits<u32>::max()) {
|
||||
if (index >= NumericLimits<u32>::max()) {
|
||||
m_string = DeprecatedString::number(index);
|
||||
m_string = ByteString::number(index);
|
||||
m_type = Type::String;
|
||||
m_string_may_be_number = false;
|
||||
return;
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
PropertyKey(DeprecatedString const& string)
|
||||
PropertyKey(ByteString const& string)
|
||||
: m_type(Type::String)
|
||||
, m_string(DeprecatedFlyString(string))
|
||||
{
|
||||
|
@ -164,13 +164,13 @@ public:
|
|||
return m_symbol;
|
||||
}
|
||||
|
||||
DeprecatedString to_string() const
|
||||
ByteString to_string() const
|
||||
{
|
||||
VERIFY(is_valid());
|
||||
VERIFY(!is_symbol());
|
||||
if (is_string())
|
||||
return as_string();
|
||||
return DeprecatedString::number(as_number());
|
||||
return ByteString::number(as_number());
|
||||
}
|
||||
|
||||
StringOrSymbol to_string_or_symbol() const
|
||||
|
|
|
@ -40,7 +40,7 @@ static Value property_key_to_value(VM& vm, PropertyKey const& property_key)
|
|||
return PrimitiveString::create(vm, property_key.as_string());
|
||||
|
||||
VERIFY(property_key.is_number());
|
||||
return PrimitiveString::create(vm, DeprecatedString::number(property_key.as_number()));
|
||||
return PrimitiveString::create(vm, ByteString::number(property_key.as_number()));
|
||||
}
|
||||
|
||||
// 10.5.1 [[GetPrototypeOf]] ( ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace JS {
|
|||
|
||||
JS_DEFINE_ALLOCATOR(RegExpObject);
|
||||
|
||||
Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_string(StringView flags)
|
||||
Result<regex::RegexOptions<ECMAScriptFlags>, ByteString> 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;
|
||||
|
@ -27,42 +27,42 @@ Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_
|
|||
switch (ch) {
|
||||
case 'd':
|
||||
if (d)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
d = true;
|
||||
break;
|
||||
case 'g':
|
||||
if (g)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
g = true;
|
||||
options |= regex::ECMAScriptFlags::Global;
|
||||
break;
|
||||
case 'i':
|
||||
if (i)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
i = true;
|
||||
options |= regex::ECMAScriptFlags::Insensitive;
|
||||
break;
|
||||
case 'm':
|
||||
if (m)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
m = true;
|
||||
options |= regex::ECMAScriptFlags::Multiline;
|
||||
break;
|
||||
case 's':
|
||||
if (s)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
s = true;
|
||||
options |= regex::ECMAScriptFlags::SingleLine;
|
||||
break;
|
||||
case 'u':
|
||||
if (u)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
u = true;
|
||||
options |= regex::ECMAScriptFlags::Unicode;
|
||||
break;
|
||||
case 'y':
|
||||
if (y)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::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);
|
||||
|
@ -74,12 +74,12 @@ Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_
|
|||
break;
|
||||
case 'v':
|
||||
if (v)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
v = true;
|
||||
options |= regex::ECMAScriptFlags::UnicodeSets;
|
||||
break;
|
||||
default:
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectBadFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectBadFlag.message(), ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,10 +87,10 @@ Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_
|
|||
}
|
||||
|
||||
// 22.2.3.4 Static Semantics: ParsePattern ( patternText, u, v ), https://tc39.es/ecma262/#sec-parsepattern
|
||||
ErrorOr<DeprecatedString, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets)
|
||||
ErrorOr<ByteString, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets)
|
||||
{
|
||||
if (unicode && unicode_sets)
|
||||
return ParseRegexPatternError { DeprecatedString::formatted(ErrorType::RegExpObjectIncompatibleFlags.message(), 'u', 'v') };
|
||||
return ParseRegexPatternError { ByteString::formatted(ErrorType::RegExpObjectIncompatibleFlags.message(), 'u', 'v') };
|
||||
|
||||
auto utf16_pattern_result = AK::utf8_to_utf16(pattern);
|
||||
if (utf16_pattern_result.is_error())
|
||||
|
@ -132,11 +132,11 @@ ErrorOr<DeprecatedString, ParseRegexPatternError> parse_regex_pattern(StringView
|
|||
previous_code_unit_was_backslash = false;
|
||||
}
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 22.2.3.4 Static Semantics: ParsePattern ( patternText, u, v ), https://tc39.es/ecma262/#sec-parsepattern
|
||||
ThrowCompletionOr<DeprecatedString> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets)
|
||||
ThrowCompletionOr<ByteString> 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())
|
||||
|
@ -150,7 +150,7 @@ NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm)
|
|||
return realm.heap().allocate<RegExpObject>(realm, realm.intrinsics().regexp_prototype());
|
||||
}
|
||||
|
||||
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags)
|
||||
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> regex, ByteString pattern, ByteString flags)
|
||||
{
|
||||
return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), realm.intrinsics().regexp_prototype());
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ RegExpObject::RegExpObject(Object& prototype)
|
|||
{
|
||||
}
|
||||
|
||||
RegExpObject::RegExpObject(Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags, Object& prototype)
|
||||
RegExpObject::RegExpObject(Regex<ECMA262> regex, ByteString pattern, ByteString flags, Object& prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_pattern(move(pattern))
|
||||
, m_flags(move(flags))
|
||||
|
@ -183,14 +183,14 @@ 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()
|
||||
? DeprecatedString::empty()
|
||||
: TRY(pattern_value.to_deprecated_string(vm));
|
||||
? ByteString::empty()
|
||||
: TRY(pattern_value.to_byte_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()
|
||||
? DeprecatedString::empty()
|
||||
: TRY(flags_value.to_deprecated_string(vm));
|
||||
? ByteString::empty()
|
||||
: TRY(flags_value.to_byte_string(vm));
|
||||
|
||||
// 5. If F contains any code unit other than "d", "g", "i", "m", "s", "u", "v", or "y", or if F contains any code unit more than once, throw a SyntaxError exception.
|
||||
// 6. If F contains "i", let i be true; else let i be false.
|
||||
|
@ -203,7 +203,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 = DeprecatedString::empty();
|
||||
auto parsed_pattern = ByteString::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);
|
||||
|
@ -244,7 +244,7 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> RegExpObject::regexp_initialize(VM
|
|||
}
|
||||
|
||||
// 22.2.6.13.1 EscapeRegExpPattern ( P, F ), https://tc39.es/ecma262/#sec-escaperegexppattern
|
||||
DeprecatedString RegExpObject::escape_regexp_pattern() const
|
||||
ByteString 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
|
||||
|
@ -301,7 +301,7 @@ DeprecatedString RegExpObject::escape_regexp_pattern() const
|
|||
}
|
||||
}
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 22.2.3.1 RegExpCreate ( P, F ), https://tc39.es/ecma262/#sec-regexpcreate
|
||||
|
|
|
@ -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>, DeprecatedString> regex_flags_from_string(StringView flags);
|
||||
Result<regex::RegexOptions<ECMAScriptFlags>, ByteString> regex_flags_from_string(StringView flags);
|
||||
struct ParseRegexPatternError {
|
||||
DeprecatedString error;
|
||||
ByteString error;
|
||||
};
|
||||
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);
|
||||
ErrorOr<ByteString, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets);
|
||||
ThrowCompletionOr<ByteString> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets);
|
||||
|
||||
class RegExpObject : public Object {
|
||||
JS_OBJECT(RegExpObject, Object);
|
||||
|
@ -38,16 +38,16 @@ public:
|
|||
};
|
||||
|
||||
static NonnullGCPtr<RegExpObject> create(Realm&);
|
||||
static NonnullGCPtr<RegExpObject> create(Realm&, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags);
|
||||
static NonnullGCPtr<RegExpObject> create(Realm&, Regex<ECMA262> regex, ByteString pattern, ByteString flags);
|
||||
|
||||
ThrowCompletionOr<NonnullGCPtr<RegExpObject>> regexp_initialize(VM&, Value pattern, Value flags);
|
||||
DeprecatedString escape_regexp_pattern() const;
|
||||
ByteString escape_regexp_pattern() const;
|
||||
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ~RegExpObject() override = default;
|
||||
|
||||
DeprecatedString const& pattern() const { return m_pattern; }
|
||||
DeprecatedString const& flags() const { return m_flags; }
|
||||
ByteString const& pattern() const { return m_pattern; }
|
||||
ByteString 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; }
|
||||
|
@ -58,10 +58,10 @@ public:
|
|||
|
||||
private:
|
||||
RegExpObject(Object& prototype);
|
||||
RegExpObject(Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags, Object& prototype);
|
||||
RegExpObject(Regex<ECMA262> regex, ByteString pattern, ByteString flags, Object& prototype);
|
||||
|
||||
DeprecatedString m_pattern;
|
||||
DeprecatedString m_flags;
|
||||
ByteString m_pattern;
|
||||
ByteString 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]]
|
||||
|
|
|
@ -513,7 +513,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::flags)
|
|||
#undef __JS_ENUMERATE
|
||||
|
||||
// 20. Return result.
|
||||
return PrimitiveString::create(vm, builder.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, builder.to_byte_string());
|
||||
}
|
||||
|
||||
// 22.2.6.8 RegExp.prototype [ @@match ] ( string ), https://tc39.es/ecma262/#sec-regexp.prototype-@@match
|
||||
|
@ -530,7 +530,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match)
|
|||
|
||||
// 4. Let flags be ? ToString(? Get(rx, "flags")).
|
||||
auto flags_value = TRY(regexp_object->get(vm.names.flags));
|
||||
auto flags = TRY(flags_value.to_deprecated_string(vm));
|
||||
auto flags = TRY(flags_value.to_byte_string(vm));
|
||||
|
||||
// 5. If flags does not contain "g", then
|
||||
if (!flags.contains('g')) {
|
||||
|
@ -573,7 +573,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match)
|
|||
|
||||
// 1. Let matchStr be ? ToString(? Get(result, "0")).
|
||||
auto match_value = TRY(result.get(0));
|
||||
auto match_str = TRY(match_value.to_deprecated_string(vm));
|
||||
auto match_str = TRY(match_value.to_byte_string(vm));
|
||||
|
||||
// 2. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(n)), matchStr).
|
||||
MUST(array->create_data_property_or_throw(n, PrimitiveString::create(vm, match_str)));
|
||||
|
@ -606,7 +606,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match_all)
|
|||
|
||||
// 5. Let flags be ? ToString(? Get(R, "flags")).
|
||||
auto flags_value = TRY(regexp_object->get(vm.names.flags));
|
||||
auto flags = TRY(flags_value.to_deprecated_string(vm));
|
||||
auto flags = TRY(flags_value.to_byte_string(vm));
|
||||
|
||||
// Steps 9-12 are performed early so that flags can be moved.
|
||||
|
||||
|
@ -651,13 +651,13 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
// 6. If functionalReplace is false, then
|
||||
if (!replace_value.is_function()) {
|
||||
// a. Set replaceValue to ? ToString(replaceValue).
|
||||
auto replace_string = TRY(replace_value.to_deprecated_string(vm));
|
||||
auto replace_string = TRY(replace_value.to_byte_string(vm));
|
||||
replace_value = PrimitiveString::create(vm, move(replace_string));
|
||||
}
|
||||
|
||||
// 7. Let flags be ? ToString(? Get(rx, "flags")).
|
||||
auto flags_value = TRY(regexp_object->get(vm.names.flags));
|
||||
auto flags = TRY(flags_value.to_deprecated_string(vm));
|
||||
auto flags = TRY(flags_value.to_byte_string(vm));
|
||||
|
||||
// 8. If flags contains "g", let global be true. Otherwise, let global be false.
|
||||
bool global = flags.contains('g');
|
||||
|
@ -694,7 +694,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
|
||||
// 1. Let matchStr be ? ToString(? Get(result, "0")).
|
||||
auto match_value = TRY(result.get(vm, 0));
|
||||
auto match_str = TRY(match_value.to_deprecated_string(vm));
|
||||
auto match_str = TRY(match_value.to_byte_string(vm));
|
||||
|
||||
// 2. If matchStr is the empty String, then
|
||||
if (match_str.is_empty()) {
|
||||
|
@ -746,7 +746,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
// ii. If capN is not undefined, then
|
||||
if (!capture.is_undefined()) {
|
||||
// 1. Set capN to ? ToString(capN).
|
||||
capture = PrimitiveString::create(vm, TRY(capture.to_deprecated_string(vm)));
|
||||
capture = PrimitiveString::create(vm, TRY(capture.to_byte_string(vm)));
|
||||
}
|
||||
|
||||
// iii. Append capN as the last element of captures.
|
||||
|
@ -810,13 +810,13 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
|
||||
// 16. If nextSourcePosition ≥ lengthS, return accumulatedResult.
|
||||
if (next_source_position >= string.length_in_code_units())
|
||||
return PrimitiveString::create(vm, accumulated_result.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, accumulated_result.to_byte_string());
|
||||
|
||||
// 17. Return the string-concatenation of accumulatedResult and the substring of S from nextSourcePosition.
|
||||
auto substring = string.substring_view(next_source_position);
|
||||
accumulated_result.append(substring);
|
||||
|
||||
return PrimitiveString::create(vm, accumulated_result.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, accumulated_result.to_byte_string());
|
||||
}
|
||||
|
||||
// 22.2.6.12 RegExp.prototype [ @@search ] ( string ), https://tc39.es/ecma262/#sec-regexp.prototype-@@search
|
||||
|
@ -901,7 +901,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split)
|
|||
|
||||
// 5. Let flags be ? ToString(? Get(rx, "flags")).
|
||||
auto flags_value = TRY(regexp_object->get(vm.names.flags));
|
||||
auto flags = TRY(flags_value.to_deprecated_string(vm));
|
||||
auto flags = TRY(flags_value.to_byte_string(vm));
|
||||
|
||||
// 6. If flags contains "u" or flags contains "v", let unicodeMatching be true.
|
||||
// 7. Else, let unicodeMatching be false.
|
||||
|
@ -909,7 +909,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) : DeprecatedString::formatted("{}y", flags);
|
||||
auto new_flags = flags.find('y').has_value() ? move(flags) : ByteString::formatted("{}y", flags);
|
||||
|
||||
// 10. Let splitter be ? Construct(C, « rx, newFlags »).
|
||||
auto splitter = TRY(construct(vm, *constructor, regexp_object, PrimitiveString::create(vm, move(new_flags))));
|
||||
|
@ -1066,15 +1066,15 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::to_string)
|
|||
|
||||
// 3. Let pattern be ? ToString(? Get(R, "source")).
|
||||
auto source_attr = TRY(regexp_object->get(vm.names.source));
|
||||
auto pattern = TRY(source_attr.to_deprecated_string(vm));
|
||||
auto pattern = TRY(source_attr.to_byte_string(vm));
|
||||
|
||||
// 4. Let flags be ? ToString(? Get(R, "flags")).
|
||||
auto flags_attr = TRY(regexp_object->get(vm.names.flags));
|
||||
auto flags = TRY(flags_attr.to_deprecated_string(vm));
|
||||
auto flags = TRY(flags_attr.to_byte_string(vm));
|
||||
|
||||
// 5. Let result be the string-concatenation of "/", pattern, "/", and flags.
|
||||
// 6. Return result.
|
||||
return PrimitiveString::create(vm, DeprecatedString::formatted("/{}/{}", pattern, flags));
|
||||
return PrimitiveString::create(vm, ByteString::formatted("/{}/{}", pattern, flags));
|
||||
}
|
||||
|
||||
// B.2.4.1 RegExp.prototype.compile ( pattern, flags ), https://tc39.es/ecma262/#sec-regexp.prototype.compile
|
||||
|
|
|
@ -53,7 +53,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpStringIteratorPrototype::next)
|
|||
|
||||
auto match_object = TRY(match.to_object(vm));
|
||||
auto match_string_value = TRY(match_object->get(0));
|
||||
auto match_string = TRY(match_string_value.to_deprecated_string(vm));
|
||||
auto match_string = TRY(match_string_value.to_byte_string(vm));
|
||||
if (match_string.is_empty()) {
|
||||
auto last_index_value = TRY(iterator->regexp_object().get(vm.names.lastIndex));
|
||||
auto last_index = TRY(last_index_value.to_length(vm));
|
||||
|
|
|
@ -89,7 +89,7 @@ ThrowCompletionOr<void> copy_name_and_length(VM& vm, FunctionObject& function, F
|
|||
target_name = PrimitiveString::create(vm, String {});
|
||||
|
||||
// 8. Perform SetFunctionName(F, targetName, prefix).
|
||||
function.set_function_name({ target_name.as_string().deprecated_string() }, move(prefix));
|
||||
function.set_function_name({ target_name.as_string().byte_string() }, move(prefix));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -214,7 +214,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, DeprecatedString specifier_string, DeprecatedString export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context)
|
||||
ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, ByteString specifier_string, ByteString 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;
|
||||
|
|
|
@ -37,7 +37,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&, DeprecatedString specifier_string, DeprecatedString export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context);
|
||||
ThrowCompletionOr<Value> shadow_realm_import_value(VM&, ByteString specifier_string, ByteString export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context);
|
||||
ThrowCompletionOr<Value> get_wrapped_value(VM&, Realm& caller_realm, Value);
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::evaluate)
|
|||
auto& eval_realm = object->shadow_realm();
|
||||
|
||||
// 6. Return ? PerformShadowRealmEval(sourceText, callerRealm, evalRealm).
|
||||
return perform_shadow_realm_eval(vm, source_text.as_string().deprecated_string(), *caller_realm, eval_realm);
|
||||
return perform_shadow_realm_eval(vm, source_text.as_string().byte_string(), *caller_realm, eval_realm);
|
||||
}
|
||||
|
||||
// 3.4.2 ShadowRealm.prototype.importValue ( specifier, exportName ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype.importvalue
|
||||
|
@ -65,7 +65,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
|
|||
auto object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let specifierString be ? ToString(specifier).
|
||||
auto specifier_string = TRY(specifier.to_deprecated_string(vm));
|
||||
auto specifier_string = TRY(specifier.to_byte_string(vm));
|
||||
|
||||
// 4. If Type(exportName) is not String, throw a TypeError exception.
|
||||
if (!export_name.is_string())
|
||||
|
@ -81,7 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
|
|||
auto& eval_context = object->execution_context();
|
||||
|
||||
// 8. Return ? ShadowRealmImportValue(specifierString, exportNameString, callerRealm, evalRealm, evalContext).
|
||||
return shadow_realm_import_value(vm, move(specifier_string), export_name.as_string().deprecated_string(), *caller_realm, eval_realm, eval_context);
|
||||
return shadow_realm_import_value(vm, move(specifier_string), export_name.as_string().byte_string(), *caller_realm, eval_realm, eval_context);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -167,13 +167,13 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
|
|||
// 7. Let nextIndex be 0.
|
||||
// 8. Repeat,
|
||||
for (size_t i = 0; i < literal_count; ++i) {
|
||||
auto next_key = DeprecatedString::number(i);
|
||||
auto next_key = ByteString::number(i);
|
||||
|
||||
// a. Let nextLiteralVal be ? Get(literals, ! ToString(𝔽(nextIndex))).
|
||||
auto next_literal_value = TRY(literals->get(next_key));
|
||||
|
||||
// b. Let nextLiteral be ? ToString(nextLiteralVal).
|
||||
auto next_literal = TRY(next_literal_value.to_deprecated_string(vm));
|
||||
auto next_literal = TRY(next_literal_value.to_byte_string(vm));
|
||||
|
||||
// c. Set R to the string-concatenation of R and nextLiteral.
|
||||
builder.append(next_literal);
|
||||
|
@ -188,7 +188,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
|
|||
auto next_substitution_value = vm.argument(i + 1);
|
||||
|
||||
// ii. Let nextSub be ? ToString(nextSubVal).
|
||||
auto next_substitution = TRY(next_substitution_value.to_deprecated_string(vm));
|
||||
auto next_substitution = TRY(next_substitution_value.to_byte_string(vm));
|
||||
|
||||
// iii. Set R to the string-concatenation of R and nextSub.
|
||||
builder.append(next_substitution);
|
||||
|
@ -196,7 +196,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
|
|||
|
||||
// f. Set nextIndex to nextIndex + 1.
|
||||
}
|
||||
return PrimitiveString::create(vm, builder.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, builder.to_byte_string());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
StringOrSymbol(DeprecatedString const& string)
|
||||
StringOrSymbol(ByteString const& string)
|
||||
: StringOrSymbol(DeprecatedFlyString(string))
|
||||
{
|
||||
}
|
||||
|
@ -74,12 +74,12 @@ public:
|
|||
return reinterpret_cast<Symbol const*>(bits() & ~1ul);
|
||||
}
|
||||
|
||||
DeprecatedString to_display_string() const
|
||||
ByteString to_display_string() const
|
||||
{
|
||||
if (is_string())
|
||||
return as_string();
|
||||
if (is_symbol())
|
||||
return as_symbol()->descriptive_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
|
||||
return as_symbol()->descriptive_string().release_value_but_fixme_should_propagate_errors().to_byte_string();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
|
|
|
@ -527,7 +527,7 @@ 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, DeprecatedString::formatted("{} option value", key.as_string()));
|
||||
return vm.throw_completion<RangeError>(ErrorType::IsUndefined, ByteString::formatted("{} option value", key.as_string()));
|
||||
|
||||
auto value = option_value.is_undefined()
|
||||
? Optional<String> {}
|
||||
|
@ -1794,7 +1794,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields,
|
|||
// 3. For each value property of fieldNames, do
|
||||
for (auto& property : field_names) {
|
||||
// a. Let value be ? Get(fields, property).
|
||||
auto value = TRY(fields.get(property.to_deprecated_string()));
|
||||
auto value = TRY(fields.get(property.to_byte_string()));
|
||||
|
||||
// b. If value is not undefined, then
|
||||
if (!value.is_undefined()) {
|
||||
|
@ -1823,7 +1823,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields,
|
|||
}
|
||||
|
||||
// iii. Perform ! CreateDataPropertyOrThrow(result, property, value).
|
||||
MUST(result->create_data_property_or_throw(property.to_deprecated_string(), value));
|
||||
MUST(result->create_data_property_or_throw(property.to_byte_string(), value));
|
||||
}
|
||||
// c. Else if requiredFields is a List, then
|
||||
else if (required_fields.has<Vector<StringView>>()) {
|
||||
|
@ -1840,7 +1840,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields,
|
|||
}
|
||||
|
||||
// iii. Perform ! CreateDataPropertyOrThrow(result, property, value).
|
||||
MUST(result->create_data_property_or_throw(property.to_deprecated_string(), value));
|
||||
MUST(result->create_data_property_or_throw(property.to_byte_string(), value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -787,7 +787,7 @@ ThrowCompletionOr<double> resolve_iso_month(VM& vm, Object const& fields)
|
|||
|
||||
// 6. Assert: Type(monthCode) is String.
|
||||
VERIFY(month_code.is_string());
|
||||
auto month_code_string = month_code.as_string().deprecated_string();
|
||||
auto month_code_string = month_code.as_string().byte_string();
|
||||
|
||||
// 7. If the length of monthCode is not 3, throw a RangeError exception.
|
||||
auto month_length = month_code_string.length();
|
||||
|
@ -963,7 +963,7 @@ ThrowCompletionOr<Object*> default_merge_calendar_fields(VM& vm, Object const& f
|
|||
// 3. For each element key of fieldsKeys, do
|
||||
for (auto& key : fields_keys) {
|
||||
// a. If key is not "month" or "monthCode", then
|
||||
if (!key.as_string().deprecated_string().is_one_of(vm.names.month.as_string(), vm.names.monthCode.as_string())) {
|
||||
if (!key.as_string().byte_string().is_one_of(vm.names.month.as_string(), vm.names.monthCode.as_string())) {
|
||||
auto property_key = MUST(PropertyKey::from_value(vm, key));
|
||||
|
||||
// i. Let propValue be ? Get(fields, key).
|
||||
|
@ -997,7 +997,7 @@ ThrowCompletionOr<Object*> default_merge_calendar_fields(VM& vm, Object const& f
|
|||
}
|
||||
|
||||
// See comment above.
|
||||
additional_fields_keys_contains_month_or_month_code_property |= key.as_string().deprecated_string() == vm.names.month.as_string() || key.as_string().deprecated_string() == vm.names.monthCode.as_string();
|
||||
additional_fields_keys_contains_month_or_month_code_property |= key.as_string().byte_string() == vm.names.month.as_string() || key.as_string().byte_string() == vm.names.monthCode.as_string();
|
||||
}
|
||||
|
||||
// 6. If additionalFieldsKeys does not contain either "month" or "monthCode", then
|
||||
|
|
|
@ -402,7 +402,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(PrimitiveString::create(vm, DeprecatedString::number(i)));
|
||||
keys.append(PrimitiveString::create(vm, ByteString::number(i)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ static ThrowCompletionOr<TypedArrayBase*> validate_typed_array_from_this(VM& vm)
|
|||
return typed_array;
|
||||
}
|
||||
|
||||
static ThrowCompletionOr<FunctionObject*> callback_from_args(VM& vm, DeprecatedString const& name)
|
||||
static ThrowCompletionOr<FunctionObject*> callback_from_args(VM& vm, ByteString const& name)
|
||||
{
|
||||
if (vm.argument_count() < 1)
|
||||
return vm.throw_completion<TypeError>(ErrorType::TypedArrayPrototypeOneArg, name);
|
||||
|
@ -100,7 +100,7 @@ static ThrowCompletionOr<FunctionObject*> callback_from_args(VM& vm, DeprecatedS
|
|||
return &callback.as_function();
|
||||
}
|
||||
|
||||
static ThrowCompletionOr<void> for_each_item(VM& vm, DeprecatedString const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback)
|
||||
static ThrowCompletionOr<void> for_each_item(VM& vm, ByteString const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback)
|
||||
{
|
||||
auto* typed_array = TRY(validate_typed_array_from_this(vm));
|
||||
|
||||
|
@ -122,7 +122,7 @@ static ThrowCompletionOr<void> for_each_item(VM& vm, DeprecatedString const& nam
|
|||
return {};
|
||||
}
|
||||
|
||||
static ThrowCompletionOr<void> for_each_item_from_last(VM& vm, DeprecatedString const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback)
|
||||
static ThrowCompletionOr<void> for_each_item_from_last(VM& vm, ByteString const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback)
|
||||
{
|
||||
auto* typed_array = TRY(validate_typed_array_from_this(vm));
|
||||
|
||||
|
@ -803,9 +803,9 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::join)
|
|||
|
||||
// 4. If separator is undefined, let sep be ",".
|
||||
// 5. Else, let sep be ? ToString(separator).
|
||||
DeprecatedString separator = ",";
|
||||
ByteString separator = ",";
|
||||
if (!vm.argument(0).is_undefined())
|
||||
separator = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
separator = TRY(vm.argument(0).to_byte_string(vm));
|
||||
|
||||
// 6. Let R be the empty String.
|
||||
StringBuilder builder;
|
||||
|
@ -823,7 +823,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::join)
|
|||
// c. If element is undefined, let next be the empty String; otherwise, let next be ! ToString(element).
|
||||
if (element.is_undefined())
|
||||
continue;
|
||||
auto next = MUST(element.to_deprecated_string(vm));
|
||||
auto next = MUST(element.to_byte_string(vm));
|
||||
|
||||
// d. Set R to the string-concatenation of R and next.
|
||||
builder.append(next);
|
||||
|
@ -832,7 +832,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::join)
|
|||
}
|
||||
|
||||
// 9. Return R.
|
||||
return PrimitiveString::create(vm, builder.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, builder.to_byte_string());
|
||||
}
|
||||
|
||||
// 23.2.3.19 %TypedArray%.prototype.keys ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys
|
||||
|
@ -1643,7 +1643,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::to_locale_string)
|
|||
if (!next_element.is_nullish()) {
|
||||
// i. Let S be ? ToString(? Invoke(nextElement, "toLocaleString", « locales, options »)).
|
||||
auto locale_string_value = TRY(next_element.invoke(vm, vm.names.toLocaleString, locales, options));
|
||||
auto locale_string = TRY(locale_string_value.to_deprecated_string(vm));
|
||||
auto locale_string = TRY(locale_string_value.to_byte_string(vm));
|
||||
|
||||
// ii. Set R to the string-concatenation of R and S.
|
||||
builder.append(locale_string);
|
||||
|
@ -1653,7 +1653,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::to_locale_string)
|
|||
}
|
||||
|
||||
// 7. Return R.
|
||||
return PrimitiveString::create(vm, builder.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, builder.to_byte_string());
|
||||
}
|
||||
|
||||
// 23.2.3.32 %TypedArray%.prototype.toReversed ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.toreversed
|
||||
|
|
|
@ -107,9 +107,9 @@ String Utf16String::to_utf8() const
|
|||
return MUST(view().to_utf8(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
}
|
||||
|
||||
DeprecatedString Utf16String::to_deprecated_string() const
|
||||
ByteString Utf16String::to_byte_string() const
|
||||
{
|
||||
return MUST(view().to_deprecated_string(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
return MUST(view().to_byte_string(Utf16View::AllowInvalidCodeUnits::Yes));
|
||||
}
|
||||
|
||||
u16 Utf16String::code_unit_at(size_t index) const
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Types.h>
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
Utf16View substring_view(size_t code_unit_offset) const;
|
||||
|
||||
[[nodiscard]] String to_utf8() const;
|
||||
[[nodiscard]] DeprecatedString to_deprecated_string() const;
|
||||
[[nodiscard]] ByteString to_byte_string() const;
|
||||
u16 code_unit_at(size_t index) const;
|
||||
|
||||
size_t length_in_code_units() const;
|
||||
|
|
|
@ -106,7 +106,7 @@ VM::VM(OwnPtr<CustomData> custom_data, ErrorMessages error_messages)
|
|||
};
|
||||
|
||||
host_get_supported_import_attributes = [&] {
|
||||
return Vector<DeprecatedString> { "type" };
|
||||
return Vector<ByteString> { "type" };
|
||||
};
|
||||
|
||||
// 19.2.1.2 HostEnsureCanCompileStrings ( callerRealm, calleeRealm ), https://tc39.es/ecma262/#sec-hostensurecancompilestrings
|
||||
|
@ -746,7 +746,7 @@ ScriptOrModule VM::get_active_script_or_module() const
|
|||
return m_execution_context_stack[0]->script_or_module;
|
||||
}
|
||||
|
||||
VM::StoredModule* VM::get_stored_module(ImportedModuleReferrer const&, DeprecatedString const& filename, DeprecatedString const&)
|
||||
VM::StoredModule* VM::get_stored_module(ImportedModuleReferrer const&, ByteString const& filename, ByteString const&)
|
||||
{
|
||||
// Note the spec says:
|
||||
// If this operation is called multiple times with the same (referrer, specifier) pair and it performs
|
||||
|
@ -803,7 +803,7 @@ ThrowCompletionOr<void> VM::link_and_eval_module(CyclicModule& module)
|
|||
return {};
|
||||
}
|
||||
|
||||
static DeprecatedString resolve_module_filename(StringView filename, StringView module_type)
|
||||
static ByteString resolve_module_filename(StringView filename, StringView module_type)
|
||||
{
|
||||
auto extensions = Vector<StringView, 2> { "js"sv, "mjs"sv };
|
||||
if (module_type == "json"sv)
|
||||
|
@ -811,14 +811,14 @@ static DeprecatedString resolve_module_filename(StringView filename, StringView
|
|||
if (!FileSystem::exists(filename)) {
|
||||
for (auto extension : extensions) {
|
||||
// import "./foo" -> import "./foo.ext"
|
||||
auto resolved_filepath = DeprecatedString::formatted("{}.{}", filename, extension);
|
||||
auto resolved_filepath = ByteString::formatted("{}.{}", filename, extension);
|
||||
if (FileSystem::exists(resolved_filepath))
|
||||
return resolved_filepath;
|
||||
}
|
||||
} else if (FileSystem::is_directory(filename)) {
|
||||
for (auto extension : extensions) {
|
||||
// import "./foo" -> import "./foo/index.ext"
|
||||
auto resolved_filepath = LexicalPath::join(filename, DeprecatedString::formatted("index.{}", extension)).string();
|
||||
auto resolved_filepath = LexicalPath::join(filename, ByteString::formatted("index.{}", extension)).string();
|
||||
if (FileSystem::exists(resolved_filepath))
|
||||
return resolved_filepath;
|
||||
}
|
||||
|
@ -853,7 +853,7 @@ void VM::load_imported_module(ImportedModuleReferrer referrer, ModuleRequest con
|
|||
return;
|
||||
}
|
||||
|
||||
DeprecatedString module_type;
|
||||
ByteString module_type;
|
||||
for (auto& attribute : module_request.attributes) {
|
||||
if (attribute.key == "type"sv) {
|
||||
module_type = attribute.value;
|
||||
|
@ -890,15 +890,15 @@ void VM::load_imported_module(ImportedModuleReferrer referrer, ModuleRequest con
|
|||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] resolved filename: '{}'", filename);
|
||||
|
||||
#if JS_MODULE_DEBUG
|
||||
DeprecatedString referencing_module_string = referrer.visit(
|
||||
[&](Empty) -> DeprecatedString {
|
||||
ByteString referencing_module_string = referrer.visit(
|
||||
[&](Empty) -> ByteString {
|
||||
return ".";
|
||||
},
|
||||
[&](auto& script_or_module) {
|
||||
if constexpr (IsSame<Script*, decltype(script_or_module)>) {
|
||||
return DeprecatedString::formatted("Script @ {}", script_or_module.ptr());
|
||||
return ByteString::formatted("Script @ {}", script_or_module.ptr());
|
||||
}
|
||||
return DeprecatedString::formatted("Module @ {}", script_or_module.ptr());
|
||||
return ByteString::formatted("Module @ {}", script_or_module.ptr());
|
||||
});
|
||||
|
||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] load_imported_module({}, {})", referencing_module_string, filename);
|
||||
|
@ -949,14 +949,14 @@ void VM::load_imported_module(ImportedModuleReferrer referrer, ModuleRequest con
|
|||
|
||||
if (module_or_errors.is_error()) {
|
||||
VERIFY(module_or_errors.error().size() > 0);
|
||||
return throw_completion<SyntaxError>(module_or_errors.error().first().to_deprecated_string());
|
||||
return throw_completion<SyntaxError>(module_or_errors.error().first().to_byte_string());
|
||||
}
|
||||
|
||||
auto module = module_or_errors.release_value();
|
||||
m_loaded_modules.empend(
|
||||
referrer,
|
||||
module->filename(),
|
||||
DeprecatedString {}, // Null type
|
||||
ByteString {}, // Null type
|
||||
make_handle<Module>(*module),
|
||||
true);
|
||||
|
||||
|
|
|
@ -65,9 +65,9 @@ public:
|
|||
return m_string_cache;
|
||||
}
|
||||
|
||||
HashMap<DeprecatedString, GCPtr<PrimitiveString>>& deprecated_string_cache()
|
||||
HashMap<ByteString, GCPtr<PrimitiveString>>& byte_string_cache()
|
||||
{
|
||||
return m_deprecated_string_cache;
|
||||
return m_byte_string_cache;
|
||||
}
|
||||
|
||||
PrimitiveString& empty_string() { return *m_empty_string; }
|
||||
|
@ -186,7 +186,7 @@ public:
|
|||
template<typename T, typename... Args>
|
||||
Completion throw_completion(ErrorType type, Args&&... args)
|
||||
{
|
||||
return throw_completion<T>(DeprecatedString::formatted(type.message(), forward<Args>(args)...));
|
||||
return throw_completion<T>(ByteString::formatted(type.message(), forward<Args>(args)...));
|
||||
}
|
||||
|
||||
Value get_new_target();
|
||||
|
@ -234,7 +234,7 @@ public:
|
|||
Function<HashMap<PropertyKey, Value>(SourceTextModule&)> host_get_import_meta_properties;
|
||||
Function<void(Object*, SourceTextModule const&)> host_finalize_import_meta;
|
||||
|
||||
Function<Vector<DeprecatedString>()> host_get_supported_import_attributes;
|
||||
Function<Vector<ByteString>()> host_get_supported_import_attributes;
|
||||
|
||||
void set_dynamic_imports_allowed(bool value) { m_dynamic_imports_allowed = value; }
|
||||
|
||||
|
@ -275,7 +275,7 @@ private:
|
|||
Vector<FlatPtr> get_native_stack_trace() const;
|
||||
|
||||
HashMap<String, GCPtr<PrimitiveString>> m_string_cache;
|
||||
HashMap<DeprecatedString, GCPtr<PrimitiveString>> m_deprecated_string_cache;
|
||||
HashMap<ByteString, GCPtr<PrimitiveString>> m_byte_string_cache;
|
||||
|
||||
Heap m_heap;
|
||||
|
||||
|
@ -298,13 +298,13 @@ private:
|
|||
|
||||
struct StoredModule {
|
||||
ImportedModuleReferrer referrer;
|
||||
DeprecatedString filename;
|
||||
DeprecatedString type;
|
||||
ByteString filename;
|
||||
ByteString type;
|
||||
Handle<Module> module;
|
||||
bool has_once_started_linking { false };
|
||||
};
|
||||
|
||||
StoredModule* get_stored_module(ImportedModuleReferrer const& script_or_module, DeprecatedString const& filename, DeprecatedString const& type);
|
||||
StoredModule* get_stored_module(ImportedModuleReferrer const& script_or_module, ByteString const& filename, ByteString const& type);
|
||||
|
||||
Vector<StoredModule> m_loaded_modules;
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include <AK/AllOf.h>
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/FloatingPointStringConversions.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringFloatingPointConversions.h>
|
||||
|
@ -212,11 +212,11 @@ String number_to_string(double d, NumberToStringMode mode)
|
|||
return builder.to_string().release_value();
|
||||
}
|
||||
|
||||
DeprecatedString number_to_deprecated_string(double d, NumberToStringMode mode)
|
||||
ByteString number_to_byte_string(double d, NumberToStringMode mode)
|
||||
{
|
||||
StringBuilder builder;
|
||||
number_to_string_impl(builder, d, mode);
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 7.2.2 IsArray ( argument ), https://tc39.es/ecma262/#sec-isarray
|
||||
|
@ -439,9 +439,9 @@ ThrowCompletionOr<String> Value::to_string(VM& vm) const
|
|||
}
|
||||
|
||||
// 7.1.17 ToString ( argument ), https://tc39.es/ecma262/#sec-tostring
|
||||
ThrowCompletionOr<DeprecatedString> Value::to_deprecated_string(VM& vm) const
|
||||
ThrowCompletionOr<ByteString> Value::to_byte_string(VM& vm) const
|
||||
{
|
||||
return TRY(to_string(vm)).to_deprecated_string();
|
||||
return TRY(to_string(vm)).to_byte_string();
|
||||
}
|
||||
|
||||
ThrowCompletionOr<Utf16String> Value::to_utf16_string(VM& vm) const
|
||||
|
@ -500,7 +500,7 @@ ThrowCompletionOr<Value> Value::to_primitive_slow_case(VM& vm, PreferredType pre
|
|||
|
||||
// b. If exoticToPrim is not undefined, then
|
||||
if (exotic_to_primitive) {
|
||||
auto hint = [&]() -> DeprecatedString {
|
||||
auto hint = [&]() -> ByteString {
|
||||
switch (preferred_type) {
|
||||
// i. If preferredType is not present, let hint be "default".
|
||||
case PreferredType::Default:
|
||||
|
@ -655,7 +655,7 @@ static Optional<NumberParseResult> parse_number_text(StringView text)
|
|||
double string_to_number(StringView string)
|
||||
{
|
||||
// 1. Let text be StringToCodePoints(str).
|
||||
DeprecatedString text = Utf8View(string).trim(whitespace_characters, AK::TrimMode::Both).as_string();
|
||||
ByteString text = Utf8View(string).trim(whitespace_characters, AK::TrimMode::Both).as_string();
|
||||
|
||||
// 2. Let literal be ParseText(text, StringNumericLiteral).
|
||||
if (text.is_empty())
|
||||
|
@ -710,7 +710,7 @@ ThrowCompletionOr<Value> Value::to_number_slow_case(VM& vm) const
|
|||
return Value(as_bool() ? 1 : 0);
|
||||
// 6. If argument is a String, return StringToNumber(argument).
|
||||
case STRING_TAG:
|
||||
return string_to_number(as_string().deprecated_string());
|
||||
return string_to_number(as_string().byte_string());
|
||||
// 7. Assert: argument is an Object.
|
||||
case OBJECT_TAG: {
|
||||
// 8. Let primValue be ? ToPrimitive(argument, number).
|
||||
|
@ -764,7 +764,7 @@ ThrowCompletionOr<NonnullGCPtr<BigInt>> Value::to_bigint(VM& vm) const
|
|||
return primitive.as_bigint();
|
||||
case STRING_TAG: {
|
||||
// 1. Let n be ! StringToBigInt(prim).
|
||||
auto bigint = string_to_bigint(vm, primitive.as_string().deprecated_string());
|
||||
auto bigint = string_to_bigint(vm, primitive.as_string().byte_string());
|
||||
|
||||
// 2. If n is undefined, throw a SyntaxError exception.
|
||||
if (!bigint.has_value())
|
||||
|
@ -894,7 +894,7 @@ ThrowCompletionOr<PropertyKey> Value::to_property_key(VM& vm) const
|
|||
}
|
||||
|
||||
// 3. Return ! ToString(key).
|
||||
return MUST(key.to_deprecated_string(vm));
|
||||
return MUST(key.to_byte_string(vm));
|
||||
}
|
||||
|
||||
// 7.1.6 ToInt32 ( argument ), https://tc39.es/ecma262/#sec-toint32
|
||||
|
@ -2212,7 +2212,7 @@ bool same_value_non_number(Value lhs, Value rhs)
|
|||
// 5. If x is a String, then
|
||||
if (lhs.is_string()) {
|
||||
// a. If x and y are exactly the same sequence of code units (same length and same code units at corresponding indices), return true; otherwise, return false.
|
||||
return lhs.as_string().deprecated_string() == rhs.as_string().deprecated_string();
|
||||
return lhs.as_string().byte_string() == rhs.as_string().byte_string();
|
||||
}
|
||||
|
||||
// 3. If x is undefined, return true.
|
||||
|
@ -2293,7 +2293,7 @@ ThrowCompletionOr<bool> is_loosely_equal(VM& vm, Value lhs, Value rhs)
|
|||
// 7. If Type(x) is BigInt and Type(y) is String, then
|
||||
if (lhs.is_bigint() && rhs.is_string()) {
|
||||
// a. Let n be StringToBigInt(y).
|
||||
auto bigint = string_to_bigint(vm, rhs.as_string().deprecated_string());
|
||||
auto bigint = string_to_bigint(vm, rhs.as_string().byte_string());
|
||||
|
||||
// b. If n is undefined, return false.
|
||||
if (!bigint.has_value())
|
||||
|
@ -2374,8 +2374,8 @@ ThrowCompletionOr<TriState> is_less_than(VM& vm, Value lhs, Value rhs, bool left
|
|||
|
||||
// 3. If px is a String and py is a String, then
|
||||
if (x_primitive.is_string() && y_primitive.is_string()) {
|
||||
auto x_string = x_primitive.as_string().deprecated_string();
|
||||
auto y_string = y_primitive.as_string().deprecated_string();
|
||||
auto x_string = x_primitive.as_string().byte_string();
|
||||
auto y_string = y_primitive.as_string().byte_string();
|
||||
|
||||
Utf8View x_code_points { x_string };
|
||||
Utf8View y_code_points { y_string };
|
||||
|
@ -2410,7 +2410,7 @@ ThrowCompletionOr<TriState> is_less_than(VM& vm, Value lhs, Value rhs, bool left
|
|||
// a. If px is a BigInt and py is a String, then
|
||||
if (x_primitive.is_bigint() && y_primitive.is_string()) {
|
||||
// i. Let ny be StringToBigInt(py).
|
||||
auto y_bigint = string_to_bigint(vm, y_primitive.as_string().deprecated_string());
|
||||
auto y_bigint = string_to_bigint(vm, y_primitive.as_string().byte_string());
|
||||
|
||||
// ii. If ny is undefined, return undefined.
|
||||
if (!y_bigint.has_value())
|
||||
|
@ -2425,7 +2425,7 @@ ThrowCompletionOr<TriState> is_less_than(VM& vm, Value lhs, Value rhs, bool left
|
|||
// b. If px is a String and py is a BigInt, then
|
||||
if (x_primitive.is_string() && y_primitive.is_bigint()) {
|
||||
// i. Let nx be StringToBigInt(px).
|
||||
auto x_bigint = string_to_bigint(vm, x_primitive.as_string().deprecated_string());
|
||||
auto x_bigint = string_to_bigint(vm, x_primitive.as_string().byte_string());
|
||||
|
||||
// ii. If nx is undefined, return undefined.
|
||||
if (!x_bigint.has_value())
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/BitCast.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Function.h>
|
||||
|
@ -374,7 +374,7 @@ public:
|
|||
u64 encoded() const { return m_value.encoded; }
|
||||
|
||||
ThrowCompletionOr<String> to_string(VM&) const;
|
||||
ThrowCompletionOr<DeprecatedString> to_deprecated_string(VM&) const;
|
||||
ThrowCompletionOr<ByteString> to_byte_string(VM&) const;
|
||||
ThrowCompletionOr<Utf16String> to_utf16_string(VM&) const;
|
||||
ThrowCompletionOr<NonnullGCPtr<PrimitiveString>> to_primitive_string(VM&);
|
||||
ThrowCompletionOr<Value> to_primitive(VM&, PreferredType preferred_type = PreferredType::Default) const;
|
||||
|
@ -575,7 +575,7 @@ enum class NumberToStringMode {
|
|||
WithoutExponent,
|
||||
};
|
||||
[[nodiscard]] String number_to_string(double, NumberToStringMode = NumberToStringMode::WithExponent);
|
||||
[[nodiscard]] DeprecatedString number_to_deprecated_string(double, NumberToStringMode = NumberToStringMode::WithExponent);
|
||||
[[nodiscard]] ByteString number_to_byte_string(double, NumberToStringMode = NumberToStringMode::WithExponent);
|
||||
double string_to_number(StringView);
|
||||
|
||||
inline bool Value::operator==(Value const& value) const { return same_value(*this, value); }
|
||||
|
|
|
@ -19,7 +19,7 @@ struct ValueTraits : public Traits<Value> {
|
|||
VERIFY(!value.is_empty());
|
||||
if (value.is_string()) {
|
||||
// FIXME: Propagate this error.
|
||||
return value.as_string().deprecated_string().hash();
|
||||
return value.as_string().byte_string().hash();
|
||||
}
|
||||
|
||||
if (value.is_bigint())
|
||||
|
|
|
@ -64,7 +64,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> WeakMapConstructor::construct(FunctionOb
|
|||
// 7. Return ? AddEntriesFromIterable(map, iterable, adder).
|
||||
(void)TRY(get_iterator_values(vm, iterable, [&](Value iterator_value) -> Optional<Completion> {
|
||||
if (!iterator_value.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, ByteString::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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue