mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:57:35 +00:00
Everywhere: Use _{short_,}string to create Strings from literals
This commit is contained in:
parent
85414d9338
commit
09d40bfbb2
92 changed files with 334 additions and 310 deletions
|
@ -147,7 +147,7 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Executable const& e
|
|||
for (size_t i = 0; i < registers().size(); ++i) {
|
||||
String value_string;
|
||||
if (registers()[i].is_empty())
|
||||
value_string = MUST(String::from_utf8("(empty)"sv));
|
||||
value_string = MUST("(empty)"_string);
|
||||
else
|
||||
value_string = MUST(registers()[i].to_string_without_side_effects());
|
||||
dbgln("[{:3}] {}", i, value_string);
|
||||
|
|
|
@ -104,7 +104,7 @@ ThrowCompletionOr<Value> Console::trace()
|
|||
for (ssize_t i = execution_context_stack.size() - 2; i >= 0; --i) {
|
||||
auto const& function_name = execution_context_stack[i]->function_name;
|
||||
trace.stack.append(function_name.is_empty()
|
||||
? TRY_OR_THROW_OOM(vm, String::from_utf8("<anonymous>"sv))
|
||||
? TRY_OR_THROW_OOM(vm, "<anonymous>"_string)
|
||||
: TRY_OR_THROW_OOM(vm, String::from_deprecated_string(function_name)));
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ ThrowCompletionOr<Value> Console::group()
|
|||
}
|
||||
// ... Otherwise, let groupLabel be an implementation-chosen label representing a group.
|
||||
else {
|
||||
group_label = TRY_OR_THROW_OOM(vm, String::from_utf8("Group"sv));
|
||||
group_label = TRY_OR_THROW_OOM(vm, "Group"_string);
|
||||
}
|
||||
|
||||
// 3. Incorporate groupLabel as a label for group.
|
||||
|
@ -289,7 +289,7 @@ ThrowCompletionOr<Value> Console::group_collapsed()
|
|||
}
|
||||
// ... Otherwise, let groupLabel be an implementation-chosen label representing a group.
|
||||
else {
|
||||
group_label = TRY_OR_THROW_OOM(vm, String::from_utf8("Group"sv));
|
||||
group_label = TRY_OR_THROW_OOM(vm, "Group"_string);
|
||||
}
|
||||
|
||||
// 3. Incorporate groupLabel as a label for group.
|
||||
|
|
|
@ -836,7 +836,7 @@ Token Lexer::next()
|
|||
|
||||
if (m_hit_invalid_unicode.has_value()) {
|
||||
value_start = m_hit_invalid_unicode.value() - 1;
|
||||
m_current_token = Token(TokenType::Invalid, String::from_utf8("Invalid unicode codepoint in source"sv).release_value_but_fixme_should_propagate_errors(),
|
||||
m_current_token = Token(TokenType::Invalid, "Invalid unicode codepoint in source"_string.release_value_but_fixme_should_propagate_errors(),
|
||||
""sv, // Since the invalid unicode can occur anywhere in the current token the trivia is not correct
|
||||
m_source.substring_view(value_start + 1, min(4u, m_source.length() - value_start - 2)),
|
||||
m_filename,
|
||||
|
|
|
@ -47,7 +47,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string)
|
|||
|
||||
// 4. If name is undefined, set name to "Error"; otherwise set name to ? ToString(name).
|
||||
auto name = name_property.is_undefined()
|
||||
? TRY_OR_THROW_OOM(vm, String::from_utf8("Error"sv))
|
||||
? TRY_OR_THROW_OOM(vm, "Error"_string)
|
||||
: TRY(name_property.to_string(vm));
|
||||
|
||||
// 5. Let msg be ? Get(O, "message").
|
||||
|
@ -90,7 +90,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_getter)
|
|||
if (auto name_property = TRY(error.get(vm.names.name)); !name_property.is_undefined())
|
||||
name = TRY(name_property.to_string(vm));
|
||||
else
|
||||
name = TRY_OR_THROW_OOM(vm, String::from_utf8("Error"sv));
|
||||
name = TRY_OR_THROW_OOM(vm, "Error"_string);
|
||||
|
||||
String message {};
|
||||
if (auto message_property = TRY(error.get(vm.names.message)); !message_property.is_undefined())
|
||||
|
|
|
@ -464,7 +464,7 @@ ThrowCompletionOr<LocaleResult> resolve_locale(VM& vm, Vector<String> const& req
|
|||
// 4. Else if keyLocaleData contains "true", then
|
||||
else if (key_locale_data.contains_slow("true"sv)) {
|
||||
// a. Let value be "true".
|
||||
value = TRY_OR_THROW_OOM(vm, String::from_utf8("true"sv));
|
||||
value = TRY_OR_THROW_OOM(vm, "true"_string);
|
||||
|
||||
// b. Let supportedExtensionAddition be the string-concatenation of "-" and key.
|
||||
supported_extension_addition = ::Locale::Keyword { TRY_OR_THROW_OOM(vm, String::from_utf8(key)), {} };
|
||||
|
@ -487,7 +487,7 @@ ThrowCompletionOr<LocaleResult> resolve_locale(VM& vm, Vector<String> const& req
|
|||
// 3. If optionsValue is the empty String, then
|
||||
if (options_value->is_empty()) {
|
||||
// a. Let optionsValue be "true".
|
||||
options_value = TRY_OR_THROW_OOM(vm, String::from_utf8("true"sv));
|
||||
options_value = TRY_OR_THROW_OOM(vm, "true"_string);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ static ThrowCompletionOr<Collator*> initialize_collator(VM& vm, Collator& collat
|
|||
// 21. Let collation be r.[[co]].
|
||||
// 22. If collation is null, let collation be "default".
|
||||
// 23. Set collator.[[Collation]] to collation.
|
||||
collator.set_collation(result.co.has_value() ? result.co.release_value() : TRY_OR_THROW_OOM(vm, String::from_utf8("default"sv)));
|
||||
collator.set_collation(result.co.has_value() ? result.co.release_value() : TRY_OR_THROW_OOM(vm, "default"_string));
|
||||
|
||||
// 24. If relevantExtensionKeys contains "kn", then
|
||||
if (relevant_extension_keys.span().contains_slow("kn"sv) && result.kn.has_value()) {
|
||||
|
|
|
@ -1241,7 +1241,7 @@ ThrowCompletionOr<RawFormatResult> to_raw_fixed(VM& vm, MathematicalValue const&
|
|||
|
||||
// 7. If n = 0, let m be "0". Otherwise, let m be the String consisting of the digits of the decimal representation of n (in order, with no leading zeroes).
|
||||
result.formatted_string = n.is_zero()
|
||||
? String::from_utf8_short_string("0"sv)
|
||||
? "0"_short_string
|
||||
: MUST_OR_THROW_OOM(n.to_string(vm));
|
||||
|
||||
// 8. If f ≠ 0, then
|
||||
|
|
|
@ -450,9 +450,9 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string)
|
|||
if (number_value.is_negative_infinity())
|
||||
return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "-Infinity"sv));
|
||||
if (number_value.is_nan())
|
||||
return PrimitiveString::create(vm, String::from_utf8_short_string("NaN"sv));
|
||||
return PrimitiveString::create(vm, "NaN"_short_string);
|
||||
if (number_value.is_positive_zero() || number_value.is_negative_zero())
|
||||
return PrimitiveString::create(vm, String::from_utf8_short_string("0"sv));
|
||||
return PrimitiveString::create(vm, "0"_short_string);
|
||||
|
||||
double number = number_value.as_double();
|
||||
bool negative = number < 0;
|
||||
|
|
|
@ -494,7 +494,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all)
|
|||
|
||||
auto string = TRY(this_object.to_utf16_string(vm));
|
||||
|
||||
auto rx = TRY(regexp_create(vm, regexp, PrimitiveString::create(vm, String::from_utf8_short_string("g"sv))));
|
||||
auto rx = TRY(regexp_create(vm, regexp, PrimitiveString::create(vm, "g"_short_string)));
|
||||
return TRY(Value(rx).invoke(vm, *vm.well_known_symbol_match_all(), PrimitiveString::create(vm, move(string))));
|
||||
}
|
||||
|
||||
|
@ -509,7 +509,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::normalize)
|
|||
|
||||
// 3. If form is undefined, let f be "NFC".
|
||||
if (auto form_value = vm.argument(0); form_value.is_undefined()) {
|
||||
form = String::from_utf8_short_string("NFC"sv);
|
||||
form = "NFC"_short_string;
|
||||
}
|
||||
// 4. Else, let f be ? ToString(form).
|
||||
else {
|
||||
|
|
|
@ -159,7 +159,7 @@ ThrowCompletionOr<String> to_temporal_overflow(VM& vm, Object const* options)
|
|||
{
|
||||
// 1. If options is undefined, return "constrain".
|
||||
if (options == nullptr)
|
||||
return TRY_OR_THROW_OOM(vm, String::from_utf8("constrain"sv));
|
||||
return TRY_OR_THROW_OOM(vm, "constrain"_string);
|
||||
|
||||
// 2. Return ? GetOption(options, "overflow", "string", « "constrain", "reject" », "constrain").
|
||||
auto option = TRY(get_option(vm, *options, vm.names.overflow, OptionType::String, { "constrain"sv, "reject"sv }, "constrain"sv));
|
||||
|
@ -173,7 +173,7 @@ ThrowCompletionOr<String> to_temporal_disambiguation(VM& vm, Object const* optio
|
|||
{
|
||||
// 1. If options is undefined, return "compatible".
|
||||
if (options == nullptr)
|
||||
return TRY_OR_THROW_OOM(vm, String::from_utf8("compatible"sv));
|
||||
return TRY_OR_THROW_OOM(vm, "compatible"_string);
|
||||
|
||||
// 2. Return ? GetOption(options, "disambiguation", "string", « "compatible", "earlier", "later", "reject" », "compatible").
|
||||
auto option = TRY(get_option(vm, *options, vm.names.disambiguation, OptionType::String, { "compatible"sv, "earlier"sv, "later"sv, "reject"sv }, "compatible"sv));
|
||||
|
@ -1269,7 +1269,7 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM& vm, ParseResult const& pa
|
|||
}
|
||||
|
||||
// 7. Let yearMV be ! ToIntegerOrInfinity(CodePointsToString(year)).
|
||||
auto year_mv = *normalized_year.value_or(String::from_utf8_short_string("0"sv)).to_number<i32>();
|
||||
auto year_mv = *normalized_year.value_or("0"_short_string).to_number<i32>();
|
||||
|
||||
// 8. If month is empty, then
|
||||
// a. Let monthMV be 1.
|
||||
|
@ -1425,7 +1425,7 @@ ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(VM& vm, StringV
|
|||
// 4. If result.[[TimeZone]].[[Z]] is true, then
|
||||
if (result.time_zone.z) {
|
||||
// a. Set offsetString to "+00:00".
|
||||
offset_string = TRY_OR_THROW_OOM(vm, String::from_utf8("+00:00"sv));
|
||||
offset_string = TRY_OR_THROW_OOM(vm, "+00:00"_string);
|
||||
}
|
||||
|
||||
// 6. Assert: offsetString is not undefined.
|
||||
|
@ -1460,7 +1460,7 @@ ThrowCompletionOr<String> parse_temporal_calendar_string(VM& vm, StringView iso_
|
|||
|
||||
// b. If calendar is undefined, return "iso8601".
|
||||
if (!calendar.has_value())
|
||||
return TRY_OR_THROW_OOM(vm, String::from_utf8("iso8601"sv));
|
||||
return TRY_OR_THROW_OOM(vm, "iso8601"_string);
|
||||
// c. Else, return calendar.
|
||||
else
|
||||
return calendar.release_value();
|
||||
|
|
|
@ -99,7 +99,7 @@ ThrowCompletionOr<Calendar*> get_builtin_calendar(VM& vm, String const& identifi
|
|||
Calendar* get_iso8601_calendar(VM& vm)
|
||||
{
|
||||
// 1. Return ! GetBuiltinCalendar("iso8601").
|
||||
return MUST(get_builtin_calendar(vm, String::from_utf8("iso8601"sv).release_value_but_fixme_should_propagate_errors()));
|
||||
return MUST(get_builtin_calendar(vm, "iso8601"_string.release_value_but_fixme_should_propagate_errors()));
|
||||
}
|
||||
|
||||
// 12.2.4 CalendarFields ( calendar, fieldNames ), https://tc39.es/proposal-temporal/#sec-temporal-calendarfields
|
||||
|
@ -824,10 +824,10 @@ ThrowCompletionOr<ISODateRecord> iso_date_from_fields(VM& vm, Object const& fiel
|
|||
|
||||
// 2. Set fields to ? PrepareTemporalFields(fields, « "day", "month", "monthCode", "year" », « "year", "day" »).
|
||||
auto* prepared_fields = TRY(prepare_temporal_fields(vm, fields,
|
||||
{ String::from_utf8_short_string("day"sv),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("month"sv)),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("monthCode"sv)),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("year"sv)) },
|
||||
{ "day"_short_string,
|
||||
TRY_OR_THROW_OOM(vm, "month"_string),
|
||||
TRY_OR_THROW_OOM(vm, "monthCode"_string),
|
||||
TRY_OR_THROW_OOM(vm, "year"_string) },
|
||||
Vector<StringView> { "year"sv, "day"sv }));
|
||||
|
||||
// 3. Let overflow be ? ToTemporalOverflow(options).
|
||||
|
@ -859,9 +859,9 @@ ThrowCompletionOr<ISOYearMonth> iso_year_month_from_fields(VM& vm, Object const&
|
|||
|
||||
// 2. Set fields to ? PrepareTemporalFields(fields, « "month", "monthCode", "year" », « "year" »).
|
||||
auto* prepared_fields = TRY(prepare_temporal_fields(vm, fields,
|
||||
{ TRY_OR_THROW_OOM(vm, String::from_utf8("month"sv)),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("monthCode"sv)),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("year"sv)) },
|
||||
{ TRY_OR_THROW_OOM(vm, "month"_string),
|
||||
TRY_OR_THROW_OOM(vm, "monthCode"_string),
|
||||
TRY_OR_THROW_OOM(vm, "year"_string) },
|
||||
Vector<StringView> { "year"sv }));
|
||||
|
||||
// 3. Let overflow be ? ToTemporalOverflow(options).
|
||||
|
@ -890,10 +890,10 @@ ThrowCompletionOr<ISOMonthDay> iso_month_day_from_fields(VM& vm, Object const& f
|
|||
|
||||
// 2. Set fields to ? PrepareTemporalFields(fields, « "day", "month", "monthCode", "year" », « "day" »).
|
||||
auto* prepared_fields = TRY(prepare_temporal_fields(vm, fields,
|
||||
{ String::from_utf8_short_string("day"sv),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("month"sv)),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("monthCode"sv)),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("year"sv)) },
|
||||
{ "day"_short_string,
|
||||
TRY_OR_THROW_OOM(vm, "month"_string),
|
||||
TRY_OR_THROW_OOM(vm, "monthCode"_string),
|
||||
TRY_OR_THROW_OOM(vm, "year"_string) },
|
||||
Vector<StringView> { "day"sv }));
|
||||
|
||||
// 3. Let overflow be ? ToTemporalOverflow(options).
|
||||
|
|
|
@ -216,7 +216,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_until)
|
|||
|
||||
// 8. If largestUnit is "auto", set largestUnit to "day".
|
||||
if (largest_unit == "auto")
|
||||
largest_unit = String::from_utf8_short_string("day"sv);
|
||||
largest_unit = "day"_short_string;
|
||||
|
||||
// 9. Let result be DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit).
|
||||
auto result = difference_iso_date(vm, one->iso_year(), one->iso_month(), one->iso_day(), two->iso_year(), two->iso_month(), two->iso_day(), *largest_unit);
|
||||
|
|
|
@ -369,7 +369,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::round)
|
|||
smallest_unit_present = false;
|
||||
|
||||
// b. Set smallestUnit to "nanosecond".
|
||||
smallest_unit = TRY_OR_THROW_OOM(vm, String::from_utf8("nanosecond"sv));
|
||||
smallest_unit = TRY_OR_THROW_OOM(vm, "nanosecond"_string);
|
||||
}
|
||||
|
||||
// 10. Let defaultLargestUnit be ! DefaultTemporalLargestUnit(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]]).
|
||||
|
|
|
@ -267,7 +267,7 @@ ThrowCompletionOr<String> temporal_instant_to_string(VM& vm, Instant& instant, V
|
|||
// 8. If timeZone is undefined, then
|
||||
if (time_zone.is_undefined()) {
|
||||
// a. Let timeZoneString be "Z".
|
||||
time_zone_string = String::from_utf8_short_string("Z"sv);
|
||||
time_zone_string = "Z"_short_string;
|
||||
}
|
||||
// 9. Else,
|
||||
else {
|
||||
|
|
|
@ -344,12 +344,12 @@ ThrowCompletionOr<TemporalTimeLikeRecord> to_temporal_time_record(VM& vm, Object
|
|||
|
||||
// 2. Let partial be ? PrepareTemporalFields(temporalTimeLike, « "hour", "microsecond", "millisecond", "minute", "nanosecond", "second" », partial).
|
||||
auto* partial = TRY(prepare_temporal_fields(vm, temporal_time_like,
|
||||
{ TRY_OR_THROW_OOM(vm, String::from_utf8("hour"sv)),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("microsecond"sv)),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("millisecond"sv)),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("minute"sv)),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("nanosecond"sv)),
|
||||
TRY_OR_THROW_OOM(vm, String::from_utf8("second"sv)) },
|
||||
{ TRY_OR_THROW_OOM(vm, "hour"_string),
|
||||
TRY_OR_THROW_OOM(vm, "microsecond"_string),
|
||||
TRY_OR_THROW_OOM(vm, "millisecond"_string),
|
||||
TRY_OR_THROW_OOM(vm, "minute"_string),
|
||||
TRY_OR_THROW_OOM(vm, "nanosecond"_string),
|
||||
TRY_OR_THROW_OOM(vm, "second"_string) },
|
||||
PrepareTemporalFieldsPartial {}));
|
||||
|
||||
TemporalTimeLikeRecord result;
|
||||
|
|
|
@ -150,10 +150,10 @@ ThrowCompletionOr<ZonedDateTime*> to_temporal_zoned_date_time(VM& vm, Value item
|
|||
auto field_names = TRY(calendar_fields(vm, *calendar, { "day"sv, "hour"sv, "microsecond"sv, "millisecond"sv, "minute"sv, "month"sv, "monthCode"sv, "nanosecond"sv, "second"sv, "year"sv }));
|
||||
|
||||
// d. Append "timeZone" to fieldNames.
|
||||
field_names.append(TRY_OR_THROW_OOM(vm, String::from_utf8("timeZone"sv)));
|
||||
field_names.append(TRY_OR_THROW_OOM(vm, "timeZone"_string));
|
||||
|
||||
// e. Append "offset" to fieldNames.
|
||||
field_names.append(TRY_OR_THROW_OOM(vm, String::from_utf8("offset"sv)));
|
||||
field_names.append(TRY_OR_THROW_OOM(vm, "offset"_string));
|
||||
|
||||
// f. Let fields be ? PrepareTemporalFields(item, fieldNames, « "timeZone" »).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, item_object, field_names, Vector<StringView> { "timeZone"sv }));
|
||||
|
|
|
@ -769,7 +769,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with)
|
|||
auto field_names = TRY(calendar_fields(vm, calendar, { "day"sv, "hour"sv, "microsecond"sv, "millisecond"sv, "minute"sv, "month"sv, "monthCode"sv, "nanosecond"sv, "second"sv, "year"sv }));
|
||||
|
||||
// 7. Append "offset" to fieldNames.
|
||||
field_names.append(TRY_OR_THROW_OOM(vm, String::from_utf8("offset"sv)));
|
||||
field_names.append(TRY_OR_THROW_OOM(vm, "offset"_string));
|
||||
|
||||
// 8. Let partialZonedDateTime be ? PrepareTemporalFields(temporalZonedDateTimeLike, fieldNames, partial).
|
||||
auto* partial_zoned_date_time = TRY(prepare_temporal_fields(vm, temporal_zoned_date_time_like.as_object(), field_names, PrepareTemporalFieldsPartial {}));
|
||||
|
@ -787,7 +787,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 13. Append "timeZone" to fieldNames.
|
||||
field_names.append(TRY_OR_THROW_OOM(vm, String::from_utf8("timeZone"sv)));
|
||||
field_names.append(TRY_OR_THROW_OOM(vm, "timeZone"_string));
|
||||
|
||||
// 14. Let fields be ? PrepareTemporalFields(zonedDateTime, fieldNames, « "timeZone", "offset" »).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *zoned_date_time, field_names, Vector<StringView> { "timeZone"sv, "offset"sv }));
|
||||
|
|
|
@ -362,11 +362,11 @@ ErrorOr<String> Value::to_string_without_side_effects() const
|
|||
|
||||
switch (m_value.tag) {
|
||||
case UNDEFINED_TAG:
|
||||
return String::from_utf8("undefined"sv);
|
||||
return "undefined"_string;
|
||||
case NULL_TAG:
|
||||
return String::from_utf8("null"sv);
|
||||
return "null"_string;
|
||||
case BOOLEAN_TAG:
|
||||
return String::from_utf8(as_bool() ? "true"sv : "false"sv);
|
||||
return as_bool() ? "true"_string : "false"_string;
|
||||
case INT32_TAG:
|
||||
return String::number(as_i32());
|
||||
case STRING_TAG:
|
||||
|
@ -389,7 +389,7 @@ ErrorOr<String> Value::to_string_without_side_effects() const
|
|||
case OBJECT_TAG:
|
||||
return String::formatted("[object {}]", as_object().class_name());
|
||||
case ACCESSOR_TAG:
|
||||
return String::from_utf8("<accessor>"sv);
|
||||
return "<accessor>"_string;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -418,14 +418,14 @@ ThrowCompletionOr<String> Value::to_string(VM& vm) const
|
|||
return vm.throw_completion<TypeError>(ErrorType::Convert, "symbol", "string");
|
||||
// 3. If argument is undefined, return "undefined".
|
||||
case UNDEFINED_TAG:
|
||||
return TRY_OR_THROW_OOM(vm, String::from_utf8("undefined"sv));
|
||||
return TRY_OR_THROW_OOM(vm, "undefined"_string);
|
||||
// 4. If argument is null, return "null".
|
||||
case NULL_TAG:
|
||||
return TRY_OR_THROW_OOM(vm, String::from_utf8("null"sv));
|
||||
return TRY_OR_THROW_OOM(vm, "null"_string);
|
||||
// 5. If argument is true, return "true".
|
||||
// 6. If argument is false, return "false".
|
||||
case BOOLEAN_TAG:
|
||||
return TRY_OR_THROW_OOM(vm, String::from_utf8(as_bool() ? "true"sv : "false"sv));
|
||||
return TRY_OR_THROW_OOM(vm, as_bool() ? "true"_string : "false"_string);
|
||||
// 7. If argument is a Number, return Number::toString(argument, 10).
|
||||
case INT32_TAG:
|
||||
return TRY_OR_THROW_OOM(vm, String::number(as_i32()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue