LibJS+Everywhere: Rename Value::to_string to to_deprecated_string
This commit is contained in:
parent
8f5bdce8e7
commit
afeb7273cc
Notes:
sideshowbarker
2024-07-17 01:41:00 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/afeb7273cc Pull-request: https://github.com/SerenityOS/serenity/pull/17014 Reviewed-by: https://github.com/linusg ✅
68 changed files with 193 additions and 193 deletions
|
@ -266,7 +266,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
@cpp_name@.ensure_capacity(vm.argument_count() - @js_suffix@);
|
||||
|
||||
for (size_t i = @js_suffix@; i < vm.argument_count(); ++i) {
|
||||
auto to_string_result = TRY(vm.argument(i).to_string(vm));
|
||||
auto to_string_result = TRY(vm.argument(i).to_deprecated_string(vm));
|
||||
@cpp_name@.append(move(to_string_result));
|
||||
}
|
||||
)~~~");
|
||||
|
@ -277,14 +277,14 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
if (@js_name@@js_suffix@.is_null() && @legacy_null_to_empty_string@) {
|
||||
@cpp_name@ = DeprecatedString::empty();
|
||||
} else {
|
||||
@cpp_name@ = TRY(@js_name@@js_suffix@.to_string(vm));
|
||||
@cpp_name@ = TRY(@js_name@@js_suffix@.to_deprecated_string(vm));
|
||||
}
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
DeprecatedString @cpp_name@;
|
||||
if (!@js_name@@js_suffix@.is_nullish())
|
||||
@cpp_name@ = TRY(@js_name@@js_suffix@.to_string(vm));
|
||||
@cpp_name@ = TRY(@js_name@@js_suffix@.to_deprecated_string(vm));
|
||||
)~~~");
|
||||
}
|
||||
} else {
|
||||
|
@ -294,7 +294,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
if (@js_name@@js_suffix@.is_null() && @legacy_null_to_empty_string@)
|
||||
@cpp_name@ = DeprecatedString::empty();
|
||||
else
|
||||
@cpp_name@ = TRY(@js_name@@js_suffix@.to_string(vm));
|
||||
@cpp_name@ = TRY(@js_name@@js_suffix@.to_deprecated_string(vm));
|
||||
})~~~");
|
||||
if (optional_default_value.has_value() && (!parameter.type->is_nullable() || optional_default_value.value() != "null")) {
|
||||
scoped_generator.append(R"~~~( else {
|
||||
|
@ -586,7 +586,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
}
|
||||
|
||||
enum_generator.append(R"~~~(
|
||||
auto @js_name.as_string@ = TRY(@js_name@@js_suffix@.to_string(vm));
|
||||
auto @js_name.as_string@ = TRY(@js_name@@js_suffix@.to_deprecated_string(vm));
|
||||
)~~~");
|
||||
auto first = true;
|
||||
VERIFY(enumeration.translated_cpp_names.size() >= 1);
|
||||
|
@ -1152,7 +1152,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
// 14. If types includes a string type, then return the result of converting V to that type.
|
||||
// NOTE: Currently all string types are converted to String.
|
||||
union_generator.append(R"~~~(
|
||||
return TRY(@js_name@@js_suffix@.to_string(vm));
|
||||
return TRY(@js_name@@js_suffix@.to_deprecated_string(vm));
|
||||
)~~~");
|
||||
} else if (numeric_type && includes_bigint) {
|
||||
// 15. If types includes a numeric type and bigint, then return the result of converting V to either that numeric type or bigint.
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
auto result = bytecode_interpreter.run(*executable); \
|
||||
EXPECT(!result.is_error()); \
|
||||
if (result.is_error()) \
|
||||
dbgln("Error: {}", MUST(result.throw_completion().value()->to_string(vm)));
|
||||
dbgln("Error: {}", MUST(result.throw_completion().value()->to_deprecated_string(vm)));
|
||||
|
||||
#define EXPECT_NO_EXCEPTION_WITH_OPTIMIZATIONS(executable) \
|
||||
auto& passes = JS::Bytecode::Interpreter::optimization_pipeline(); \
|
||||
|
@ -38,7 +38,7 @@
|
|||
\
|
||||
EXPECT(!result_with_optimizations.is_error()); \
|
||||
if (result_with_optimizations.is_error()) \
|
||||
dbgln("Error: {}", MUST(result_with_optimizations.throw_completion().value()->to_string(vm)));
|
||||
dbgln("Error: {}", MUST(result_with_optimizations.throw_completion().value()->to_deprecated_string(vm)));
|
||||
|
||||
#define EXPECT_NO_EXCEPTION_ALL(source) \
|
||||
SETUP_AND_PARSE("(() => {\n" source "\n})()") \
|
||||
|
|
|
@ -19,7 +19,7 @@ TESTJS_GLOBAL_FUNCTION(is_strict_mode, isStrictMode, 0)
|
|||
|
||||
TESTJS_GLOBAL_FUNCTION(can_parse_source, canParseSource)
|
||||
{
|
||||
auto source = TRY(vm.argument(0).to_string(vm));
|
||||
auto source = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto parser = JS::Parser(JS::Lexer(source));
|
||||
(void)parser.parse_program();
|
||||
return JS::Value(!parser.has_errors());
|
||||
|
|
|
@ -15,7 +15,7 @@ TEST_ROOT("Userland/Libraries/LibWasm/Tests");
|
|||
TESTJS_GLOBAL_FUNCTION(read_binary_wasm_file, readBinaryWasmFile)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto filename = TRY(vm.argument(0).to_string(vm));
|
||||
auto filename = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto file = Core::Stream::File::open(filename, Core::Stream::OpenMode::Read);
|
||||
if (file.is_error())
|
||||
return vm.throw_completion<JS::TypeError>(strerror(file.error().code()));
|
||||
|
@ -159,7 +159,7 @@ void WebAssemblyModule::initialize(JS::Realm& realm)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export)
|
||||
{
|
||||
auto name = TRY(vm.argument(0).to_string(vm));
|
||||
auto name = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto this_value = vm.this_value();
|
||||
auto* object = TRY(this_value.to_object(vm));
|
||||
if (!is<WebAssemblyModule>(object))
|
||||
|
|
|
@ -22,7 +22,7 @@ JS::ThrowCompletionOr<DeprecatedString> IdentityCell::display(Cell& cell, CellTy
|
|||
if (!metadata.format.is_empty())
|
||||
data = TRY(cell.sheet().evaluate(metadata.format, &cell));
|
||||
|
||||
return data.to_string(vm);
|
||||
return data.to_deprecated_string(vm);
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Value> IdentityCell::js_value(Cell& cell, CellTypeMetadata const&) const
|
||||
|
|
|
@ -24,7 +24,7 @@ JS::ThrowCompletionOr<DeprecatedString> NumericCell::display(Cell& cell, CellTyp
|
|||
auto value = TRY(js_value(cell, metadata));
|
||||
DeprecatedString string;
|
||||
if (metadata.format.is_empty())
|
||||
string = TRY(value.to_string(vm));
|
||||
string = TRY(value.to_deprecated_string(vm));
|
||||
else
|
||||
string = format_double(metadata.format.characters(), TRY(value.to_double(vm)));
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ StringCell::StringCell()
|
|||
JS::ThrowCompletionOr<DeprecatedString> StringCell::display(Cell& cell, CellTypeMetadata const& metadata) const
|
||||
{
|
||||
auto& vm = cell.sheet().global_object().vm();
|
||||
auto string = TRY(cell.js_data().to_string(vm));
|
||||
auto string = TRY(cell.js_data().to_deprecated_string(vm));
|
||||
if (metadata.length >= 0)
|
||||
return string.substring(0, metadata.length);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
|
|||
auto& object = value.as_object();
|
||||
if (is<JS::Error>(object)) {
|
||||
auto message = object.get_without_side_effects("message");
|
||||
auto error = message.to_string(vm);
|
||||
auto error = message.to_deprecated_string(vm);
|
||||
if (error.is_throw_completion())
|
||||
builder.append(message.to_string_without_side_effects());
|
||||
else
|
||||
|
@ -39,7 +39,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
|
|||
return builder.to_deprecated_string();
|
||||
}
|
||||
}
|
||||
auto error_message = value.to_string(vm);
|
||||
auto error_message = value.to_deprecated_string(vm);
|
||||
|
||||
if (error_message.is_throw_completion())
|
||||
return to_deprecated_string_as_exception(*error_message.release_error().value());
|
||||
|
|
|
@ -3385,7 +3385,7 @@ Completion ImportCall::execute(Interpreter& interpreter) const
|
|||
|
||||
// 7. Let specifierString be Completion(ToString(specifier)).
|
||||
// 8. IfAbruptRejectPromise(specifierString, promiseCapability).
|
||||
auto specifier_string = TRY_OR_REJECT_WITH_VALUE(vm, promise_capability, specifier->to_string(vm));
|
||||
auto specifier_string = TRY_OR_REJECT_WITH_VALUE(vm, promise_capability, specifier->to_deprecated_string(vm));
|
||||
|
||||
// 9. Let assertions be a new empty List.
|
||||
Vector<ModuleRequest::Assertion> assertions;
|
||||
|
@ -3623,7 +3623,7 @@ Completion TemplateLiteral::execute(Interpreter& interpreter) const
|
|||
auto sub = TRY(expression.execute(interpreter)).release_value();
|
||||
|
||||
// 4. Let middle be ? ToString(sub).
|
||||
auto string = TRY(sub.to_string(vm));
|
||||
auto string = TRY(sub.to_deprecated_string(vm));
|
||||
string_builder.append(string);
|
||||
|
||||
// 5. Let tail be the result of evaluating TemplateSpans.
|
||||
|
|
|
@ -120,7 +120,7 @@ ThrowCompletionOr<Value> Console::count()
|
|||
auto& vm = realm().vm();
|
||||
|
||||
// NOTE: "default" is the default value in the IDL. https://console.spec.whatwg.org/#ref-for-count
|
||||
auto label = vm.argument_count() ? TRY(vm.argument(0).to_string(vm)) : "default";
|
||||
auto label = vm.argument_count() ? TRY(vm.argument(0).to_deprecated_string(vm)) : "default";
|
||||
|
||||
// 1. Let map be the associated count map.
|
||||
auto& map = m_counters;
|
||||
|
@ -151,7 +151,7 @@ ThrowCompletionOr<Value> Console::count_reset()
|
|||
auto& vm = realm().vm();
|
||||
|
||||
// NOTE: "default" is the default value in the IDL. https://console.spec.whatwg.org/#ref-for-countreset
|
||||
auto label = vm.argument_count() ? TRY(vm.argument(0).to_string(vm)) : "default";
|
||||
auto label = vm.argument_count() ? TRY(vm.argument(0).to_deprecated_string(vm)) : "default";
|
||||
|
||||
// 1. Let map be the associated count map.
|
||||
auto& map = m_counters;
|
||||
|
@ -212,7 +212,7 @@ ThrowCompletionOr<Value> Console::assert_()
|
|||
// 3. Otherwise:
|
||||
else {
|
||||
// 1. Let concat be the concatenation of message, U+003A (:), U+0020 SPACE, and first.
|
||||
auto concat = PrimitiveString::create(vm, DeprecatedString::formatted("{}: {}", TRY(message->deprecated_string()), first.to_string(vm).value()));
|
||||
auto concat = PrimitiveString::create(vm, DeprecatedString::formatted("{}: {}", TRY(message->deprecated_string()), first.to_deprecated_string(vm).value()));
|
||||
// 2. Set data[0] to concat.
|
||||
data[0] = concat;
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ ThrowCompletionOr<Value> Console::time()
|
|||
auto& vm = realm().vm();
|
||||
|
||||
// NOTE: "default" is the default value in the IDL. https://console.spec.whatwg.org/#ref-for-time
|
||||
auto label = vm.argument_count() ? TRY(vm.argument(0).to_string(vm)) : "default";
|
||||
auto label = vm.argument_count() ? TRY(vm.argument(0).to_deprecated_string(vm)) : "default";
|
||||
|
||||
// 1. If the associated timer table contains an entry with key label, return, optionally reporting
|
||||
// a warning to the console indicating that a timer with label `label` has already been started.
|
||||
|
@ -336,7 +336,7 @@ ThrowCompletionOr<Value> Console::time_log()
|
|||
auto& vm = realm().vm();
|
||||
|
||||
// NOTE: "default" is the default value in the IDL. https://console.spec.whatwg.org/#ref-for-timelog
|
||||
auto label = vm.argument_count() ? TRY(vm.argument(0).to_string(vm)) : "default";
|
||||
auto label = vm.argument_count() ? TRY(vm.argument(0).to_deprecated_string(vm)) : "default";
|
||||
|
||||
// 1. Let timerTable be the associated timer table.
|
||||
|
||||
|
@ -379,7 +379,7 @@ ThrowCompletionOr<Value> Console::time_end()
|
|||
auto& vm = realm().vm();
|
||||
|
||||
// NOTE: "default" is the default value in the IDL. https://console.spec.whatwg.org/#ref-for-timeend
|
||||
auto label = vm.argument_count() ? TRY(vm.argument(0).to_string(vm)) : "default";
|
||||
auto label = vm.argument_count() ? TRY(vm.argument(0).to_deprecated_string(vm)) : "default";
|
||||
|
||||
// 1. Let timerTable be the associated timer table.
|
||||
|
||||
|
@ -464,7 +464,7 @@ ThrowCompletionOr<DeprecatedString> Console::value_vector_to_deprecated_string(M
|
|||
for (auto const& item : values) {
|
||||
if (!builder.is_empty())
|
||||
builder.append(' ');
|
||||
builder.append(TRY(item.to_string(vm)));
|
||||
builder.append(TRY(item.to_deprecated_string(vm)));
|
||||
}
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ ThrowCompletionOr<MarkedVector<Value>> ConsoleClient::formatter(MarkedVector<Val
|
|||
return args;
|
||||
|
||||
// 2. Let target be the first element of args.
|
||||
auto target = (!args.is_empty()) ? TRY(args.first().to_string(vm)) : "";
|
||||
auto target = (!args.is_empty()) ? TRY(args.first().to_deprecated_string(vm)) : "";
|
||||
|
||||
// 3. Let current be the second element of args.
|
||||
auto current = (args.size() > 1) ? args[1] : js_undefined();
|
||||
|
@ -621,13 +621,13 @@ ThrowCompletionOr<MarkedVector<Value>> ConsoleClient::formatter(MarkedVector<Val
|
|||
// 6. TODO: process %c
|
||||
else if (specifier == "%c"sv) {
|
||||
// NOTE: This has no spec yet. `%c` specifiers treat the argument as CSS styling for the log message.
|
||||
add_css_style_to_current_message(TRY(current.to_string(vm)));
|
||||
add_css_style_to_current_message(TRY(current.to_deprecated_string(vm)));
|
||||
converted = PrimitiveString::create(vm, "");
|
||||
}
|
||||
|
||||
// 7. If any of the previous steps set converted, replace specifier in target with converted.
|
||||
if (converted.has_value())
|
||||
target = target.replace(specifier, TRY(converted->to_string(vm)), ReplaceMode::FirstOnly);
|
||||
target = target.replace(specifier, TRY(converted->to_deprecated_string(vm)), ReplaceMode::FirstOnly);
|
||||
}
|
||||
|
||||
// 7. Let result be a list containing target together with the elements of args starting from the third onward.
|
||||
|
|
|
@ -80,7 +80,7 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::detach_array_buffer)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION($262Object::eval_script)
|
||||
{
|
||||
auto source_text = TRY(vm.argument(0).to_string(vm));
|
||||
auto source_text = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// 1. Let hostDefined be any host-defined values for the provided sourceText (obtained in an implementation dependent manner)
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ void GlobalObject::visit_edges(Cell::Visitor& visitor)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::print)
|
||||
{
|
||||
auto string = TRY(vm.argument(0).to_string(vm));
|
||||
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
outln("{}", string);
|
||||
return js_undefined();
|
||||
}
|
||||
|
|
|
@ -53,7 +53,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_string(vm));
|
||||
auto msg = TRY(message.to_deprecated_string(vm));
|
||||
|
||||
// b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg).
|
||||
aggregate_error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, msg));
|
||||
|
|
|
@ -186,10 +186,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_string(vm)));
|
||||
auto x_string = PrimitiveString::create(vm, TRY(x.to_deprecated_string(vm)));
|
||||
|
||||
// 6. Let yString be ? ToString(y).
|
||||
auto y_string = PrimitiveString::create(vm, TRY(y.to_string(vm)));
|
||||
auto y_string = PrimitiveString::create(vm, TRY(y.to_deprecated_string(vm)));
|
||||
|
||||
// 7. Let xSmaller be ! IsLessThan(xString, yString, true).
|
||||
auto x_smaller = MUST(is_less_than(vm, x_string, y_string, true));
|
||||
|
|
|
@ -1000,7 +1000,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join)
|
|||
auto length = TRY(length_of_array_like(vm, *this_object));
|
||||
DeprecatedString separator = ",";
|
||||
if (!vm.argument(0).is_undefined())
|
||||
separator = TRY(vm.argument(0).to_string(vm));
|
||||
separator = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
if (i > 0)
|
||||
|
@ -1008,7 +1008,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join)
|
|||
auto value = TRY(this_object->get(i));
|
||||
if (value.is_nullish())
|
||||
continue;
|
||||
auto string = TRY(value.to_string(vm));
|
||||
auto string = TRY(value.to_deprecated_string(vm));
|
||||
builder.append(string);
|
||||
}
|
||||
|
||||
|
@ -1735,7 +1735,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_string(vm));
|
||||
auto string = TRY(locale_string_result.to_deprecated_string(vm));
|
||||
builder.append(string);
|
||||
}
|
||||
|
||||
|
|
|
@ -316,7 +316,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateConstructor::parse)
|
|||
if (!vm.argument_count())
|
||||
return js_nan();
|
||||
|
||||
auto date_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto date_string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
return Value(parse_date_string(date_string));
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ErrorConstructor::construct(FunctionObje
|
|||
// 3. If message is not undefined, then
|
||||
if (!message.is_undefined()) {
|
||||
// a. Let msg be ? ToString(message).
|
||||
auto msg = TRY(message.to_string(vm));
|
||||
auto msg = TRY(message.to_deprecated_string(vm));
|
||||
|
||||
// b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg).
|
||||
error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, move(msg)));
|
||||
|
@ -101,7 +101,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ErrorConstructor::construct(FunctionObje
|
|||
/* 3. If message is not undefined, then */ \
|
||||
if (!message.is_undefined()) { \
|
||||
/* a. Let msg be ? ToString(message). */ \
|
||||
auto msg = TRY(message.to_string(vm)); \
|
||||
auto msg = TRY(message.to_deprecated_string(vm)); \
|
||||
\
|
||||
/* b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg). */ \
|
||||
error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, move(msg))); \
|
||||
|
|
|
@ -46,7 +46,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()
|
||||
? DeprecatedString { "Error"sv }
|
||||
: TRY(name_property.to_string(vm));
|
||||
: TRY(name_property.to_deprecated_string(vm));
|
||||
|
||||
// 5. Let msg be ? Get(O, "message").
|
||||
auto message_property = TRY(this_object->get(vm.names.message));
|
||||
|
@ -54,7 +54,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string)
|
|||
// 6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
|
||||
auto message = message_property.is_undefined()
|
||||
? DeprecatedString::empty()
|
||||
: TRY(message_property.to_string(vm));
|
||||
: TRY(message_property.to_deprecated_string(vm));
|
||||
|
||||
// 7. If name is the empty String, return msg.
|
||||
if (name.is_empty())
|
||||
|
@ -87,12 +87,12 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_getter)
|
|||
DeprecatedString name = "Error";
|
||||
auto name_property = TRY(error.get(vm.names.name));
|
||||
if (!name_property.is_undefined())
|
||||
name = TRY(name_property.to_string(vm));
|
||||
name = TRY(name_property.to_deprecated_string(vm));
|
||||
|
||||
DeprecatedString message = "";
|
||||
auto message_property = TRY(error.get(vm.names.message));
|
||||
if (!message_property.is_undefined())
|
||||
message = TRY(message_property.to_string(vm));
|
||||
message = TRY(message_property.to_deprecated_string(vm));
|
||||
|
||||
DeprecatedString header = name;
|
||||
if (!message.is_empty())
|
||||
|
|
|
@ -145,7 +145,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
|
|||
|
||||
// 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_string(vm)));
|
||||
parameters.append(TRY(next_arg.to_deprecated_string(vm)));
|
||||
|
||||
// iv. Set k to k + 1.
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
|
|||
}
|
||||
|
||||
// 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_string(vm)) : "");
|
||||
auto body_string = DeprecatedString::formatted("\n{}\n", body_arg.has_value() ? TRY(body_arg->to_deprecated_string(vm)) : "");
|
||||
|
||||
// 14. Let sourceString be the string-concatenation of prefix, " anonymous(", P, 0x000A (LINE FEED), ") {", bodyString, and "}".
|
||||
// 15. Let sourceText be StringToCodePoints(sourceString).
|
||||
|
|
|
@ -225,7 +225,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_float)
|
|||
{
|
||||
if (vm.argument(0).is_number())
|
||||
return vm.argument(0);
|
||||
auto input_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto input_string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto trimmed_string = MUST(trim_string(vm, PrimitiveString::create(vm, input_string), TrimMode::Left));
|
||||
if (trimmed_string.is_empty())
|
||||
return js_nan();
|
||||
|
@ -250,7 +250,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_float)
|
|||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_int)
|
||||
{
|
||||
// 1. Let inputString be ? ToString(string).
|
||||
auto input_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto input_string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// 2. Let S be ! TrimString(inputString, start).
|
||||
auto string = MUST(trim_string(vm, PrimitiveString::create(vm, input_string), TrimMode::Left));
|
||||
|
@ -456,7 +456,7 @@ static ThrowCompletionOr<DeprecatedString> decode(VM& vm, DeprecatedString const
|
|||
// 19.2.6.4 encodeURI ( uri ), https://tc39.es/ecma262/#sec-encodeuri-uri
|
||||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri)
|
||||
{
|
||||
auto uri_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto uri_string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto encoded = TRY(encode(vm, uri_string, ";/?:@&=+$,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'()#"sv));
|
||||
return PrimitiveString::create(vm, move(encoded));
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri)
|
|||
// 19.2.6.2 decodeURI ( encodedURI ), https://tc39.es/ecma262/#sec-decodeuri-encodeduri
|
||||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri)
|
||||
{
|
||||
auto uri_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto uri_string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto decoded = TRY(decode(vm, uri_string, ";/?:@&=+$,#"sv));
|
||||
return PrimitiveString::create(vm, move(decoded));
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri)
|
|||
// 19.2.6.5 encodeURIComponent ( uriComponent ), https://tc39.es/ecma262/#sec-encodeuricomponent-uricomponent
|
||||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri_component)
|
||||
{
|
||||
auto uri_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto uri_string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto encoded = TRY(encode(vm, uri_string, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'()"sv));
|
||||
return PrimitiveString::create(vm, move(encoded));
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri_component)
|
|||
// 19.2.6.3 decodeURIComponent ( encodedURIComponent ), https://tc39.es/ecma262/#sec-decodeuricomponent-encodeduricomponent
|
||||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri_component)
|
||||
{
|
||||
auto uri_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto uri_string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto decoded = TRY(decode(vm, uri_string, ""sv));
|
||||
return PrimitiveString::create(vm, move(decoded));
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri_component)
|
|||
// B.2.1.1 escape ( string ), https://tc39.es/ecma262/#sec-escape-string
|
||||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::escape)
|
||||
{
|
||||
auto string = TRY(vm.argument(0).to_string(vm));
|
||||
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
StringBuilder escaped;
|
||||
for (auto code_point : TRY_OR_THROW_OOM(vm, utf8_to_utf16(string))) {
|
||||
if (code_point < 256) {
|
||||
|
@ -506,7 +506,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::escape)
|
|||
// B.2.1.2 unescape ( string ), https://tc39.es/ecma262/#sec-unescape-string
|
||||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::unescape)
|
||||
{
|
||||
auto string = TRY(vm.argument(0).to_string(vm));
|
||||
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
ssize_t length = string.length();
|
||||
StringBuilder unescaped(length);
|
||||
for (auto k = 0; k < length; ++k) {
|
||||
|
|
|
@ -240,7 +240,7 @@ ThrowCompletionOr<Vector<DeprecatedString>> canonicalize_locale_list(VM& vm, Val
|
|||
// iv. Else,
|
||||
else {
|
||||
// 1. Let tag be ? ToString(kValue).
|
||||
tag = TRY(key_value.to_string(vm));
|
||||
tag = TRY(key_value.to_deprecated_string(vm));
|
||||
}
|
||||
|
||||
// v. If ! IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
|
||||
|
@ -628,7 +628,7 @@ ThrowCompletionOr<StringOrBoolean> get_string_or_boolean_option(VM& vm, Object c
|
|||
return falsy_value;
|
||||
|
||||
// 6. Let value be ? ToString(value).
|
||||
auto value_string = TRY(value.to_string(vm));
|
||||
auto value_string = TRY(value.to_deprecated_string(vm));
|
||||
|
||||
// 7. NOTE: For historical reasons, the strings "true" and "false" are treated the same as the boolean value true.
|
||||
// 8. If value is "true" or "false", return fallback.
|
||||
|
|
|
@ -58,9 +58,9 @@ ThrowCompletionOr<Value> CollatorCompareFunction::call()
|
|||
// 4. If y is not provided, let y be undefined.
|
||||
|
||||
// 5. Let X be ? ToString(x).
|
||||
auto x = TRY(vm.argument(0).to_string(vm));
|
||||
auto x = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
// 6. Let Y be ? ToString(y).
|
||||
auto y = TRY(vm.argument(1).to_string(vm));
|
||||
auto y = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
|
||||
// 7. Return CompareStrings(collator, X, Y).
|
||||
return compare_strings(m_collator, Utf8View(x), Utf8View(y));
|
||||
|
|
|
@ -63,7 +63,7 @@ static ThrowCompletionOr<Collator*> initialize_collator(VM& vm, Collator& collat
|
|||
// a. Let numeric be ! ToString(numeric).
|
||||
// 15. Set opt.[[kn]] to numeric.
|
||||
if (!numeric.is_undefined())
|
||||
opt.kn = MUST(numeric.to_string(vm));
|
||||
opt.kn = MUST(numeric.to_deprecated_string(vm));
|
||||
|
||||
// 16. Let caseFirst be ? GetOption(options, "caseFirst", string, « "upper", "lower", "false" », undefined).
|
||||
// 17. Set opt.[[kf]] to caseFirst.
|
||||
|
|
|
@ -224,7 +224,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
|
|||
// 31. Else,
|
||||
else {
|
||||
// a. Set timeZone to ? ToString(timeZone).
|
||||
time_zone = TRY(time_zone_value.to_string(vm));
|
||||
time_zone = TRY(time_zone_value.to_deprecated_string(vm));
|
||||
|
||||
// b. If IsAvailableTimeZoneName(timeZone) is false, then
|
||||
if (!Temporal::is_available_time_zone_name(time_zone)) {
|
||||
|
|
|
@ -43,7 +43,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
|
|||
auto* display_names = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let code be ? ToString(code).
|
||||
auto code_string = TRY(code.to_string(vm));
|
||||
auto code_string = TRY(code.to_deprecated_string(vm));
|
||||
code = PrimitiveString::create(vm, move(code_string));
|
||||
|
||||
// 4. Let code be ? CanonicalCodeForDisplayNames(displayNames.[[Type]], code).
|
||||
|
|
|
@ -111,7 +111,7 @@ JS_DEFINE_NATIVE_FUNCTION(Intl::supported_values_of)
|
|||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Let key be ? ToString(key).
|
||||
auto key = TRY(vm.argument(0).to_string(vm));
|
||||
auto key = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
Span<StringView const> list;
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> LocaleConstructor::construct(FunctionObj
|
|||
// 9. Else,
|
||||
else {
|
||||
// a. Let tag be ? ToString(tag).
|
||||
tag = TRY(tag_value.to_string(vm));
|
||||
tag = TRY(tag_value.to_deprecated_string(vm));
|
||||
}
|
||||
|
||||
// 10. Set options to ? CoerceOptionsToObject(options).
|
||||
|
@ -313,7 +313,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> LocaleConstructor::construct(FunctionObj
|
|||
// 24. If kn is not undefined, set kn to ! ToString(kn).
|
||||
// 25. Set opt.[[kn]] to kn.
|
||||
if (!kn.is_undefined())
|
||||
opt.kn = TRY(kn.to_string(vm));
|
||||
opt.kn = TRY(kn.to_deprecated_string(vm));
|
||||
|
||||
// 26. Let numberingSystem be ? GetOption(options, "numberingSystem", string, empty, undefined).
|
||||
// 27. If numberingSystem is not undefined, then
|
||||
|
|
|
@ -141,7 +141,7 @@ ThrowCompletionOr<Vector<PatternPartitionWithUnit>> partition_relative_time_patt
|
|||
// 16. If numeric is equal to "auto", then
|
||||
if (relative_time_format.numeric() == RelativeTimeFormat::Numeric::Auto) {
|
||||
// a. Let valueString be ToString(value).
|
||||
auto value_string = MUST(Value(value).to_string(vm));
|
||||
auto value_string = MUST(Value(value).to_deprecated_string(vm));
|
||||
|
||||
// b. If patterns has a field [[<valueString>]], then
|
||||
if (auto patterns = find_patterns_for_tense_or_number(value_string); !patterns.is_empty()) {
|
||||
|
|
|
@ -42,7 +42,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format)
|
|||
auto value = TRY(vm.argument(0).to_number(vm));
|
||||
|
||||
// 4. Let unit be ? ToString(unit).
|
||||
auto unit = TRY(vm.argument(1).to_string(vm));
|
||||
auto unit = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
|
||||
// 5. Return ? FormatRelativeTime(relativeTimeFormat, value, unit).
|
||||
auto formatted = TRY(format_relative_time(vm, *relative_time_format, value.as_double(), unit));
|
||||
|
@ -60,7 +60,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format_to_parts)
|
|||
auto value = TRY(vm.argument(0).to_number(vm));
|
||||
|
||||
// 4. Let unit be ? ToString(unit).
|
||||
auto unit = TRY(vm.argument(1).to_string(vm));
|
||||
auto unit = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
|
||||
// 5. Return ? FormatRelativeTimeToParts(relativeTimeFormat, value, unit).
|
||||
return TRY(format_relative_time_to_parts(vm, *relative_time_format, value.as_double(), unit));
|
||||
|
|
|
@ -65,11 +65,11 @@ ThrowCompletionOr<DeprecatedString> JSONObject::stringify_impl(VM& vm, Value val
|
|||
if (replacer_value.is_string()) {
|
||||
item = TRY(replacer_value.as_string().deprecated_string());
|
||||
} else if (replacer_value.is_number()) {
|
||||
item = MUST(replacer_value.to_string(vm));
|
||||
item = MUST(replacer_value.to_deprecated_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_string(vm));
|
||||
item = TRY(replacer_value.to_deprecated_string(vm));
|
||||
}
|
||||
if (!item.is_null() && !list.contains_slow(item)) {
|
||||
list.append(item);
|
||||
|
@ -191,7 +191,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_property(VM& vm,
|
|||
if (value.is_number()) {
|
||||
// a. If value is finite, return ! ToString(value).
|
||||
if (value.is_finite_number())
|
||||
return MUST(value.to_string(vm));
|
||||
return MUST(value.to_deprecated_string(vm));
|
||||
|
||||
// b. Return "null".
|
||||
return "null"sv;
|
||||
|
@ -393,7 +393,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse)
|
|||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto string = TRY(vm.argument(0).to_string(vm));
|
||||
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto reviver = vm.argument(1);
|
||||
|
||||
auto json = JsonValue::from_string(string);
|
||||
|
|
|
@ -90,7 +90,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_string(vm)));
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
|
||||
|
||||
// 5. If f < 0 or f > 100, throw a RangeError exception.
|
||||
if (fraction_digits < 0 || fraction_digits > 100)
|
||||
|
@ -218,7 +218,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_string(vm)));
|
||||
return PrimitiveString::create(vm, TRY(number_value.to_deprecated_string(vm)));
|
||||
|
||||
// 7. Set x to ℝ(x).
|
||||
auto number = number_value.as_double();
|
||||
|
@ -233,7 +233,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed)
|
|||
|
||||
// 10. If x ≥ 10^21, then
|
||||
if (fabs(number) >= 1e+21)
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_string(vm)));
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_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.
|
||||
|
@ -302,14 +302,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_string(vm)));
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_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_string(vm)));
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
|
||||
|
||||
// 5. If p < 1 or p > 100, throw a RangeError exception.
|
||||
if ((precision < 1) || (precision > 100))
|
||||
|
@ -441,7 +441,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_string(vm)));
|
||||
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_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())
|
||||
|
|
|
@ -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_string(vm));
|
||||
return TRY(value.to_deprecated_string(vm));
|
||||
}
|
||||
|
||||
PropertyKey() = default;
|
||||
|
|
|
@ -169,13 +169,13 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> RegExpObject::regexp_initialize(VM
|
|||
// 2. Else, let P be ? ToString(pattern).
|
||||
auto pattern = pattern_value.is_undefined()
|
||||
? DeprecatedString::empty()
|
||||
: TRY(pattern_value.to_string(vm));
|
||||
: TRY(pattern_value.to_deprecated_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_string(vm));
|
||||
: TRY(flags_value.to_deprecated_string(vm));
|
||||
|
||||
// 5. If F contains any code unit other than "d", "g", "i", "m", "s", "u", or "y" or if it contains the same code unit more than once, throw a SyntaxError exception.
|
||||
// 6. If F contains "i", let i be true; else let i be false.
|
||||
|
|
|
@ -528,7 +528,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_string(vm));
|
||||
auto flags = TRY(flags_value.to_deprecated_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_string(vm));
|
||||
auto match_str = TRY(match_value.to_deprecated_string(vm));
|
||||
|
||||
// 2. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(n)), matchStr).
|
||||
MUST(array->create_data_property_or_throw(n, PrimitiveString::create(vm, match_str)));
|
||||
|
@ -607,7 +607,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_string(vm));
|
||||
auto flags = TRY(flags_value.to_deprecated_string(vm));
|
||||
|
||||
// Steps 9-12 are performed early so that flags can be moved.
|
||||
|
||||
|
@ -653,13 +653,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_string(vm));
|
||||
auto replace_string = TRY(replace_value.to_deprecated_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_string(vm));
|
||||
auto flags = TRY(flags_value.to_deprecated_string(vm));
|
||||
|
||||
// 8. If flags contains "g", let global be true. Otherwise, let global be false.
|
||||
bool global = flags.contains('g');
|
||||
|
@ -702,7 +702,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_string(vm));
|
||||
auto match_str = TRY(match_value.to_deprecated_string(vm));
|
||||
|
||||
// 2. If matchStr is the empty String, then
|
||||
if (match_str.is_empty()) {
|
||||
|
@ -752,7 +752,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_string(vm)));
|
||||
capture = PrimitiveString::create(vm, TRY(capture.to_deprecated_string(vm)));
|
||||
}
|
||||
|
||||
// iii. Append capN as the last element of captures.
|
||||
|
@ -790,7 +790,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
auto replace_result = TRY(call(vm, replace_value.as_function(), js_undefined(), move(replacer_args)));
|
||||
|
||||
// vi. Let replacement be ? ToString(replValue).
|
||||
replacement = TRY(replace_result.to_string(vm));
|
||||
replacement = TRY(replace_result.to_deprecated_string(vm));
|
||||
}
|
||||
// l. Else,
|
||||
else {
|
||||
|
@ -912,7 +912,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_string(vm));
|
||||
auto flags = TRY(flags_value.to_deprecated_string(vm));
|
||||
|
||||
// 6. If flags contains "u" or flags contains "v", let unicodeMatching be true.
|
||||
// 7. Else, let unicodeMatching be false.
|
||||
|
@ -1077,11 +1077,11 @@ 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_string(vm));
|
||||
auto pattern = TRY(source_attr.to_deprecated_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_string(vm));
|
||||
auto flags = TRY(flags_attr.to_deprecated_string(vm));
|
||||
|
||||
// 5. Let result be the string-concatenation of "/", pattern, "/", and flags.
|
||||
// 6. Return result.
|
||||
|
|
|
@ -51,7 +51,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_string(vm));
|
||||
auto match_string = TRY(match_string_value.to_deprecated_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));
|
||||
|
|
|
@ -63,7 +63,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_string(vm));
|
||||
auto specifier_string = TRY(specifier.to_deprecated_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(StringConstructor::raw)
|
|||
for (size_t i = 0; i < literal_segments; ++i) {
|
||||
auto next_key = DeprecatedString::number(i);
|
||||
auto next_segment_value = TRY(raw->get(next_key));
|
||||
auto next_segment = TRY(next_segment_value.to_string(vm));
|
||||
auto next_segment = TRY(next_segment_value.to_deprecated_string(vm));
|
||||
|
||||
builder.append(next_segment);
|
||||
|
||||
|
@ -90,7 +90,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
|
|||
|
||||
if (i < number_of_substituions) {
|
||||
auto next = vm.argument(i + 1);
|
||||
auto next_sub = TRY(next.to_string(vm));
|
||||
auto next_sub = TRY(next.to_deprecated_string(vm));
|
||||
builder.append(next_sub);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace JS {
|
|||
static ThrowCompletionOr<DeprecatedString> ak_string_from(VM& vm)
|
||||
{
|
||||
auto this_value = TRY(require_object_coercible(vm, vm.this_value()));
|
||||
return TRY(this_value.to_string(vm));
|
||||
return TRY(this_value.to_deprecated_string(vm));
|
||||
}
|
||||
|
||||
static ThrowCompletionOr<Utf16String> utf16_string_from(VM& vm)
|
||||
|
@ -427,10 +427,10 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::locale_compare)
|
|||
auto object = TRY(require_object_coercible(vm, vm.this_value()));
|
||||
|
||||
// 2. Let S be ? ToString(O).
|
||||
auto string = TRY(object.to_string(vm));
|
||||
auto string = TRY(object.to_deprecated_string(vm));
|
||||
|
||||
// 3. Let thatValue be ? ToString(that).
|
||||
auto that_value = TRY(vm.argument(0).to_string(vm));
|
||||
auto that_value = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// 4. Let collator be ? Construct(%Collator%, « locales, options »).
|
||||
auto collator = TRY(construct(vm, *realm.intrinsics().intl_collator_constructor(), vm.argument(1), vm.argument(2)));
|
||||
|
@ -465,7 +465,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all)
|
|||
if (is_regexp) {
|
||||
auto flags = TRY(regexp.as_object().get("flags"));
|
||||
auto flags_object = TRY(require_object_coercible(vm, flags));
|
||||
auto flags_string = TRY(flags_object.to_string(vm));
|
||||
auto flags_string = TRY(flags_object.to_deprecated_string(vm));
|
||||
if (!flags_string.contains('g'))
|
||||
return vm.throw_completion<TypeError>(ErrorType::StringNonGlobalRegExp);
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::normalize)
|
|||
DeprecatedString form = "NFC";
|
||||
auto form_value = vm.argument(0);
|
||||
if (!form_value.is_undefined())
|
||||
form = TRY(form_value.to_string(vm));
|
||||
form = TRY(form_value.to_deprecated_string(vm));
|
||||
|
||||
// 5. If f is not one of "NFC", "NFD", "NFKC", or "NFKD", throw a RangeError exception.
|
||||
if (!form.is_one_of("NFC"sv, "NFD"sv, "NFKC"sv, "NFKD"sv))
|
||||
|
@ -611,7 +611,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace)
|
|||
|
||||
if (replace_value.is_function()) {
|
||||
auto result = TRY(call(vm, replace_value.as_function(), js_undefined(), PrimitiveString::create(vm, search_string), Value(position.value()), PrimitiveString::create(vm, string)));
|
||||
replacement = TRY(result.to_string(vm));
|
||||
replacement = TRY(result.to_deprecated_string(vm));
|
||||
} else {
|
||||
replacement = TRY(get_substitution(vm, search_string.view(), string.view(), *position, {}, js_undefined(), replace_value));
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace_all)
|
|||
if (is_regexp) {
|
||||
auto flags = TRY(search_value.as_object().get(vm.names.flags));
|
||||
auto flags_object = TRY(require_object_coercible(vm, flags));
|
||||
auto flags_string = TRY(flags_object.to_string(vm));
|
||||
auto flags_string = TRY(flags_object.to_deprecated_string(vm));
|
||||
if (!flags_string.contains('g'))
|
||||
return vm.throw_completion<TypeError>(ErrorType::StringNonGlobalRegExp);
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace_all)
|
|||
|
||||
if (replace_value.is_function()) {
|
||||
auto result = TRY(call(vm, replace_value.as_function(), js_undefined(), PrimitiveString::create(vm, search_string), Value(position), PrimitiveString::create(vm, string)));
|
||||
replacement = TRY(result.to_string(vm));
|
||||
replacement = TRY(result.to_deprecated_string(vm));
|
||||
} else {
|
||||
replacement = TRY(get_substitution(vm, search_string.view(), string.view(), position, {}, js_undefined(), replace_value));
|
||||
}
|
||||
|
@ -1028,7 +1028,7 @@ ThrowCompletionOr<DeprecatedString> trim_string(VM& vm, Value input_value, TrimM
|
|||
auto input_string = TRY(require_object_coercible(vm, input_value));
|
||||
|
||||
// 2. Let S be ? ToString(str).
|
||||
auto string = TRY(input_string.to_string(vm));
|
||||
auto string = TRY(input_string.to_deprecated_string(vm));
|
||||
|
||||
// 3. If where is start, let T be the String value that is a copy of S with leading white space removed.
|
||||
// 4. Else if where is end, let T be the String value that is a copy of S with trailing white space removed.
|
||||
|
@ -1071,7 +1071,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::symbol_iterator)
|
|||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto this_object = TRY(require_object_coercible(vm, vm.this_value()));
|
||||
auto string = TRY(this_object.to_string(vm));
|
||||
auto string = TRY(this_object.to_deprecated_string(vm));
|
||||
return StringIterator::create(realm, string);
|
||||
}
|
||||
|
||||
|
@ -1119,12 +1119,12 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::substr)
|
|||
static ThrowCompletionOr<Value> create_html(VM& vm, Value string, DeprecatedString const& tag, DeprecatedString const& attribute, Value value)
|
||||
{
|
||||
TRY(require_object_coercible(vm, string));
|
||||
auto str = TRY(string.to_string(vm));
|
||||
auto str = TRY(string.to_deprecated_string(vm));
|
||||
ThrowableStringBuilder builder(vm);
|
||||
TRY(builder.append('<'));
|
||||
TRY(builder.append(tag));
|
||||
if (!attribute.is_empty()) {
|
||||
auto value_string = TRY(value.to_string(vm));
|
||||
auto value_string = TRY(value.to_deprecated_string(vm));
|
||||
TRY(builder.append(' '));
|
||||
TRY(builder.append(attribute));
|
||||
TRY(builder.append("=\""sv));
|
||||
|
|
|
@ -42,7 +42,7 @@ ThrowCompletionOr<Value> SymbolConstructor::call()
|
|||
auto& vm = this->vm();
|
||||
if (vm.argument(0).is_undefined())
|
||||
return Symbol::create(vm, {}, false);
|
||||
return Symbol::create(vm, TRY(vm.argument(0).to_string(vm)), false);
|
||||
return Symbol::create(vm, TRY(vm.argument(0).to_deprecated_string(vm)), false);
|
||||
}
|
||||
|
||||
// 20.4.1.1 Symbol ( [ description ] ), https://tc39.es/ecma262/#sec-symbol-description
|
||||
|
@ -55,7 +55,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> SymbolConstructor::construct(FunctionObj
|
|||
JS_DEFINE_NATIVE_FUNCTION(SymbolConstructor::for_)
|
||||
{
|
||||
// 1. Let stringKey be ? ToString(key).
|
||||
auto string_key = TRY(vm.argument(0).to_string(vm));
|
||||
auto string_key = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// 2. For each element e of the GlobalSymbolRegistry List, do
|
||||
auto result = vm.global_symbol_registry().get(string_key);
|
||||
|
|
|
@ -390,7 +390,7 @@ ThrowCompletionOr<SecondsStringPrecision> to_seconds_string_precision(VM& vm, Ob
|
|||
// a. If fractionalDigitsVal is not undefined, then
|
||||
if (!fractional_digits_value.is_undefined()) {
|
||||
// i. If ? ToString(fractionalDigitsVal) is not "auto", throw a RangeError exception.
|
||||
if (TRY(fractional_digits_value.to_string(vm)) != "auto"sv)
|
||||
if (TRY(fractional_digits_value.to_deprecated_string(vm)) != "auto"sv)
|
||||
return vm.template throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, fractional_digits_value, "fractionalSecondDigits"sv);
|
||||
}
|
||||
|
||||
|
@ -628,7 +628,7 @@ ThrowCompletionOr<Value> to_relative_temporal_object(VM& vm, Object const& optio
|
|||
// 7. Else,
|
||||
else {
|
||||
// a. Let string be ? ToString(value).
|
||||
auto string = TRY(value.to_string(vm));
|
||||
auto string = TRY(value.to_deprecated_string(vm));
|
||||
|
||||
// b. Let result be ? ParseTemporalRelativeToString(string).
|
||||
result = TRY(parse_temporal_relative_to_string(vm, string));
|
||||
|
@ -690,7 +690,7 @@ ThrowCompletionOr<Value> to_relative_temporal_object(VM& vm, Object const& optio
|
|||
if (offset_behavior == OffsetBehavior::Option) {
|
||||
// a. Set offsetString to ? ToString(offsetString).
|
||||
// NOTE: offsetString is not used after this path, so we don't need to put this into the original offset_string which is of type JS::Value.
|
||||
auto actual_offset_string = TRY(offset_string.to_string(vm));
|
||||
auto actual_offset_string = TRY(offset_string.to_deprecated_string(vm));
|
||||
|
||||
// b. If IsTimeZoneOffsetString(offsetString) is false, throw a RangeError exception.
|
||||
if (!is_time_zone_offset_string(actual_offset_string))
|
||||
|
|
|
@ -238,7 +238,7 @@ ThrowCompletionOr<DeprecatedString> calendar_month_code(VM& vm, Object& calendar
|
|||
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.monthCode.as_string(), vm.names.undefined.as_string());
|
||||
|
||||
// 3. Return ? ToString(result).
|
||||
return result.to_string(vm);
|
||||
return result.to_deprecated_string(vm);
|
||||
}
|
||||
|
||||
// 12.2.11 CalendarDay ( calendar, dateLike ), https://tc39.es/proposal-temporal/#sec-temporal-calendarday
|
||||
|
@ -387,7 +387,7 @@ ThrowCompletionOr<Value> calendar_era(VM& vm, Object& calendar, Object& date_lik
|
|||
|
||||
// 3. If result is not undefined, set result to ? ToString(result).
|
||||
if (!result.is_undefined())
|
||||
result = PrimitiveString::create(vm, TRY(result.to_string(vm)));
|
||||
result = PrimitiveString::create(vm, TRY(result.to_deprecated_string(vm)));
|
||||
|
||||
// 4. Return result.
|
||||
return result;
|
||||
|
@ -461,7 +461,7 @@ ThrowCompletionOr<Object*> to_temporal_calendar(VM& vm, Value temporal_calendar_
|
|||
}
|
||||
|
||||
// 2. Let identifier be ? ToString(temporalCalendarLike).
|
||||
auto identifier = TRY(temporal_calendar_like.to_string(vm));
|
||||
auto identifier = TRY(temporal_calendar_like.to_deprecated_string(vm));
|
||||
|
||||
// 3. Set identifier to ? ParseTemporalCalendarString(identifier).
|
||||
identifier = TRY(parse_temporal_calendar_string(vm, identifier));
|
||||
|
@ -573,7 +573,7 @@ ThrowCompletionOr<DeprecatedString> maybe_format_calendar_annotation(VM& vm, Obj
|
|||
VERIFY(calendar_object);
|
||||
|
||||
// 3. Let calendarID be ? ToString(calendarObject).
|
||||
auto calendar_id = TRY(Value(calendar_object).to_string(vm));
|
||||
auto calendar_id = TRY(Value(calendar_object).to_deprecated_string(vm));
|
||||
|
||||
// 4. Return FormatCalendarAnnotation(calendarID, showCalendar).
|
||||
return format_calendar_annotation(calendar_id, show_calendar);
|
||||
|
@ -607,10 +607,10 @@ ThrowCompletionOr<bool> calendar_equals(VM& vm, Object& one, Object& two)
|
|||
return true;
|
||||
|
||||
// 2. Let calendarOne be ? ToString(one).
|
||||
auto calendar_one = TRY(Value(&one).to_string(vm));
|
||||
auto calendar_one = TRY(Value(&one).to_deprecated_string(vm));
|
||||
|
||||
// 3. Let calendarTwo be ? ToString(two).
|
||||
auto calendar_two = TRY(Value(&two).to_string(vm));
|
||||
auto calendar_two = TRY(Value(&two).to_deprecated_string(vm));
|
||||
|
||||
// 4. If calendarOne is calendarTwo, return true.
|
||||
if (calendar_one == calendar_two)
|
||||
|
@ -628,10 +628,10 @@ ThrowCompletionOr<Object*> consolidate_calendars(VM& vm, Object& one, Object& tw
|
|||
return &two;
|
||||
|
||||
// 2. Let calendarOne be ? ToString(one).
|
||||
auto calendar_one = TRY(Value(&one).to_string(vm));
|
||||
auto calendar_one = TRY(Value(&one).to_deprecated_string(vm));
|
||||
|
||||
// 3. Let calendarTwo be ? ToString(two).
|
||||
auto calendar_two = TRY(Value(&two).to_string(vm));
|
||||
auto calendar_two = TRY(Value(&two).to_deprecated_string(vm));
|
||||
|
||||
// 4. If calendarOne is calendarTwo, return two.
|
||||
if (calendar_one == calendar_two)
|
||||
|
|
|
@ -47,7 +47,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> CalendarConstructor::construct(FunctionO
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 2. Set id to ? ToString(id).
|
||||
auto identifier = TRY(vm.argument(0).to_string(vm));
|
||||
auto identifier = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// 3. If IsBuiltinCalendar(id) is false, then
|
||||
if (!is_builtin_calendar(identifier)) {
|
||||
|
|
|
@ -627,7 +627,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::to_json)
|
|||
auto* calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? ToString(calendar).
|
||||
return PrimitiveString::create(vm, TRY(Value(calendar).to_string(vm)));
|
||||
return PrimitiveString::create(vm, TRY(Value(calendar).to_deprecated_string(vm)));
|
||||
}
|
||||
|
||||
// 15.6.2.6 Temporal.Calendar.prototype.era ( temporalDateLike ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.era
|
||||
|
|
|
@ -143,7 +143,7 @@ ThrowCompletionOr<DurationRecord> to_temporal_duration_record(VM& vm, Value temp
|
|||
// 1. If Type(temporalDurationLike) is not Object, then
|
||||
if (!temporal_duration_like.is_object()) {
|
||||
// a. Let string be ? ToString(temporalDurationLike).
|
||||
auto string = TRY(temporal_duration_like.to_string(vm));
|
||||
auto string = TRY(temporal_duration_like.to_deprecated_string(vm));
|
||||
|
||||
// b. Return ? ParseTemporalDurationString(string).
|
||||
return parse_temporal_duration_string(vm, string);
|
||||
|
|
|
@ -100,7 +100,7 @@ ThrowCompletionOr<Instant*> to_temporal_instant(VM& vm, Value item)
|
|||
}
|
||||
|
||||
// 2. Let string be ? ToString(item).
|
||||
auto string = TRY(item.to_string(vm));
|
||||
auto string = TRY(item.to_deprecated_string(vm));
|
||||
|
||||
// 3. Let epochNanoseconds be ? ParseTemporalInstant(string).
|
||||
auto* epoch_nanoseconds = TRY(parse_temporal_instant(vm, string));
|
||||
|
|
|
@ -140,7 +140,7 @@ ThrowCompletionOr<PlainDate*> to_temporal_date(VM& vm, Value item, Object const*
|
|||
(void)TRY(to_temporal_overflow(vm, options));
|
||||
|
||||
// 5. Let string be ? ToString(item).
|
||||
auto string = TRY(item.to_string(vm));
|
||||
auto string = TRY(item.to_deprecated_string(vm));
|
||||
|
||||
// 6. Let result be ? ParseTemporalDateString(string).
|
||||
auto result = TRY(parse_temporal_date_string(vm, string));
|
||||
|
|
|
@ -165,7 +165,7 @@ ThrowCompletionOr<PlainDateTime*> to_temporal_date_time(VM& vm, Value item, Obje
|
|||
(void)TRY(to_temporal_overflow(vm, options));
|
||||
|
||||
// b. Let string be ? ToString(item).
|
||||
auto string = TRY(item.to_string(vm));
|
||||
auto string = TRY(item.to_deprecated_string(vm));
|
||||
|
||||
// c. Let result be ? ParseTemporalDateTimeString(string).
|
||||
result = TRY(parse_temporal_date_time_string(vm, string));
|
||||
|
|
|
@ -120,7 +120,7 @@ ThrowCompletionOr<PlainMonthDay*> to_temporal_month_day(VM& vm, Value item, Obje
|
|||
(void)TRY(to_temporal_overflow(vm, options));
|
||||
|
||||
// 6. Let string be ? ToString(item).
|
||||
auto string = TRY(item.to_string(vm));
|
||||
auto string = TRY(item.to_deprecated_string(vm));
|
||||
|
||||
// 7. Let result be ? ParseTemporalMonthDayString(string).
|
||||
auto result = TRY(parse_temporal_month_day_string(vm, string));
|
||||
|
@ -185,7 +185,7 @@ ThrowCompletionOr<DeprecatedString> temporal_month_day_to_string(VM& vm, PlainMo
|
|||
auto result = DeprecatedString::formatted("{:02}-{:02}", month_day.iso_month(), month_day.iso_day());
|
||||
|
||||
// 6. Let calendarID be ? ToString(monthDay.[[Calendar]]).
|
||||
auto calendar_id = TRY(Value(&month_day.calendar()).to_string(vm));
|
||||
auto calendar_id = TRY(Value(&month_day.calendar()).to_deprecated_string(vm));
|
||||
|
||||
// 7. If showCalendar is one of "always" or "critical", or if calendarID is not "iso8601", then
|
||||
if (show_calendar.is_one_of("always"sv, "critical"sv) || calendar_id != "iso8601"sv) {
|
||||
|
|
|
@ -122,7 +122,7 @@ ThrowCompletionOr<PlainTime*> to_temporal_time(VM& vm, Value item, Optional<Stri
|
|||
auto* calendar = TRY(get_temporal_calendar_with_iso_default(vm, item_object));
|
||||
|
||||
// e. If ? ToString(calendar) is not "iso8601", then
|
||||
auto calendar_identifier = TRY(Value(calendar).to_string(vm));
|
||||
auto calendar_identifier = TRY(Value(calendar).to_deprecated_string(vm));
|
||||
if (calendar_identifier != "iso8601"sv) {
|
||||
// i. Throw a RangeError exception.
|
||||
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarIdentifier, calendar_identifier);
|
||||
|
@ -137,7 +137,7 @@ ThrowCompletionOr<PlainTime*> to_temporal_time(VM& vm, Value item, Optional<Stri
|
|||
// 4. Else,
|
||||
else {
|
||||
// a. Let string be ? ToString(item).
|
||||
auto string = TRY(item.to_string(vm));
|
||||
auto string = TRY(item.to_deprecated_string(vm));
|
||||
|
||||
// b. Let result be ? ParseTemporalTimeString(string).
|
||||
result = TRY(parse_temporal_time_string(vm, string));
|
||||
|
|
|
@ -66,7 +66,7 @@ ThrowCompletionOr<PlainYearMonth*> to_temporal_year_month(VM& vm, Value item, Ob
|
|||
(void)TRY(to_temporal_overflow(vm, options));
|
||||
|
||||
// 5. Let string be ? ToString(item).
|
||||
auto string = TRY(item.to_string(vm));
|
||||
auto string = TRY(item.to_deprecated_string(vm));
|
||||
|
||||
// 6. Let result be ? ParseTemporalYearMonthString(string).
|
||||
auto result = TRY(parse_temporal_year_month_string(vm, string));
|
||||
|
@ -212,7 +212,7 @@ ThrowCompletionOr<DeprecatedString> temporal_year_month_to_string(VM& vm, PlainY
|
|||
auto result = DeprecatedString::formatted("{}-{:02}", pad_iso_year(year_month.iso_year()), year_month.iso_month());
|
||||
|
||||
// 6. Let calendarID be ? ToString(yearMonth.[[Calendar]]).
|
||||
auto calendar_id = TRY(Value(&year_month.calendar()).to_string(vm));
|
||||
auto calendar_id = TRY(Value(&year_month.calendar()).to_deprecated_string(vm));
|
||||
|
||||
// 7. If showCalendar is one of "always" or "critical", or if calendarID is not "iso8601", then
|
||||
if (show_calendar.is_one_of("always"sv, "critical"sv) || calendar_id != "iso8601") {
|
||||
|
|
|
@ -332,7 +332,7 @@ ThrowCompletionOr<Object*> to_temporal_time_zone(VM& vm, Value temporal_time_zon
|
|||
}
|
||||
|
||||
// 2. Let identifier be ? ToString(temporalTimeZoneLike).
|
||||
auto identifier = TRY(temporal_time_zone_like.to_string(vm));
|
||||
auto identifier = TRY(temporal_time_zone_like.to_deprecated_string(vm));
|
||||
|
||||
// 3. Let parseResult be ? ParseTemporalTimeZoneString(identifier).
|
||||
auto parse_result = TRY(parse_temporal_time_zone_string(vm, identifier));
|
||||
|
@ -603,10 +603,10 @@ ThrowCompletionOr<bool> time_zone_equals(VM& vm, Object& one, Object& two)
|
|||
return true;
|
||||
|
||||
// 2. Let timeZoneOne be ? ToString(one).
|
||||
auto time_zone_one = TRY(Value(&one).to_string(vm));
|
||||
auto time_zone_one = TRY(Value(&one).to_deprecated_string(vm));
|
||||
|
||||
// 3. Let timeZoneTwo be ? ToString(two).
|
||||
auto time_zone_two = TRY(Value(&two).to_string(vm));
|
||||
auto time_zone_two = TRY(Value(&two).to_deprecated_string(vm));
|
||||
|
||||
// 4. If timeZoneOne is timeZoneTwo, return true.
|
||||
if (time_zone_one == time_zone_two)
|
||||
|
|
|
@ -48,7 +48,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> TimeZoneConstructor::construct(FunctionO
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 2. Set identifier to ? ToString(identifier).
|
||||
auto identifier = TRY(vm.argument(0).to_string(vm));
|
||||
auto identifier = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// 3. If IsTimeZoneOffsetString(identifier) is false, then
|
||||
if (!is_time_zone_offset_string(identifier)) {
|
||||
|
|
|
@ -244,7 +244,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_json)
|
|||
auto* time_zone = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? ToString(timeZone).
|
||||
return PrimitiveString::create(vm, TRY(Value(time_zone).to_string(vm)));
|
||||
return PrimitiveString::create(vm, TRY(Value(time_zone).to_deprecated_string(vm)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ ThrowCompletionOr<ZonedDateTime*> to_temporal_zoned_date_time(VM& vm, Value item
|
|||
// k. Else,
|
||||
else {
|
||||
// i. Set offsetString to ? ToString(offsetString).
|
||||
offset_string = TRY(offset_string_value.to_string(vm));
|
||||
offset_string = TRY(offset_string_value.to_deprecated_string(vm));
|
||||
}
|
||||
|
||||
// l. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, options).
|
||||
|
@ -187,7 +187,7 @@ ThrowCompletionOr<ZonedDateTime*> to_temporal_zoned_date_time(VM& vm, Value item
|
|||
(void)TRY(to_temporal_overflow(vm, options));
|
||||
|
||||
// b. Let string be ? ToString(item).
|
||||
auto string = TRY(item.to_string(vm));
|
||||
auto string = TRY(item.to_deprecated_string(vm));
|
||||
|
||||
// c. Let result be ? ParseTemporalZonedDateTimeString(string).
|
||||
result = TRY(parse_temporal_zoned_date_time_string(vm, string));
|
||||
|
@ -342,7 +342,7 @@ ThrowCompletionOr<DeprecatedString> temporal_zoned_date_time_to_string(VM& vm, Z
|
|||
// 13. Else,
|
||||
else {
|
||||
// a. Let timeZoneID be ? ToString(timeZone).
|
||||
auto time_zone_id = TRY(Value(&time_zone).to_string(vm));
|
||||
auto time_zone_id = TRY(Value(&time_zone).to_deprecated_string(vm));
|
||||
|
||||
// b. If showTimeZone is "critical", let flag be "!"; else let flag be the empty String.
|
||||
auto flag = show_time_zone == "critical"sv ? "!"sv : ""sv;
|
||||
|
|
|
@ -753,7 +753,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::join)
|
|||
// 5. Else, let sep be ? ToString(separator).
|
||||
DeprecatedString separator = ",";
|
||||
if (!vm.argument(0).is_undefined())
|
||||
separator = TRY(vm.argument(0).to_string(vm));
|
||||
separator = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// 6. Let R be the empty String.
|
||||
StringBuilder builder;
|
||||
|
@ -771,7 +771,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_string(vm));
|
||||
auto next = MUST(element.to_deprecated_string(vm));
|
||||
|
||||
// d. Set R to the string-concatenation of R and next.
|
||||
builder.append(next);
|
||||
|
@ -1556,7 +1556,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_string(vm));
|
||||
auto locale_string = TRY(locale_string_value.to_deprecated_string(vm));
|
||||
|
||||
// ii. Set R to the string-concatenation of R and S.
|
||||
builder.append(locale_string);
|
||||
|
|
|
@ -388,12 +388,12 @@ ThrowCompletionOr<PrimitiveString*> Value::to_primitive_string(VM& vm)
|
|||
{
|
||||
if (is_string())
|
||||
return &as_string();
|
||||
auto string = TRY(to_string(vm));
|
||||
auto string = TRY(to_deprecated_string(vm));
|
||||
return PrimitiveString::create(vm, string).ptr();
|
||||
}
|
||||
|
||||
// 7.1.17 ToString ( argument ), https://tc39.es/ecma262/#sec-tostring
|
||||
ThrowCompletionOr<DeprecatedString> Value::to_string(VM& vm) const
|
||||
ThrowCompletionOr<DeprecatedString> Value::to_deprecated_string(VM& vm) const
|
||||
{
|
||||
if (is_double())
|
||||
return number_to_deprecated_string(m_value.as_double);
|
||||
|
@ -430,7 +430,7 @@ ThrowCompletionOr<DeprecatedString> Value::to_string(VM& vm) const
|
|||
VERIFY(!primitive_value.is_object());
|
||||
|
||||
// 12. Return ? ToString(primValue).
|
||||
return primitive_value.to_string(vm);
|
||||
return primitive_value.to_deprecated_string(vm);
|
||||
}
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -442,7 +442,7 @@ ThrowCompletionOr<Utf16String> Value::to_utf16_string(VM& vm) const
|
|||
if (is_string())
|
||||
return TRY(as_string().utf16_string());
|
||||
|
||||
auto utf8_string = TRY(to_string(vm));
|
||||
auto utf8_string = TRY(to_deprecated_string(vm));
|
||||
return Utf16String::create(vm, utf8_string);
|
||||
}
|
||||
|
||||
|
@ -887,7 +887,7 @@ ThrowCompletionOr<PropertyKey> Value::to_property_key(VM& vm) const
|
|||
}
|
||||
|
||||
// 3. Return ! ToString(key).
|
||||
return MUST(key.to_string(vm));
|
||||
return MUST(key.to_deprecated_string(vm));
|
||||
}
|
||||
|
||||
// 7.1.6 ToInt32 ( argument ), https://tc39.es/ecma262/#sec-toint32
|
||||
|
|
|
@ -367,7 +367,7 @@ public:
|
|||
|
||||
u64 encoded() const { return m_value.encoded; }
|
||||
|
||||
ThrowCompletionOr<DeprecatedString> to_string(VM&) const;
|
||||
ThrowCompletionOr<DeprecatedString> to_deprecated_string(VM&) const;
|
||||
ThrowCompletionOr<Utf16String> to_utf16_string(VM&) const;
|
||||
ThrowCompletionOr<PrimitiveString*> to_primitive_string(VM&);
|
||||
ThrowCompletionOr<Value> to_primitive(VM&, PreferredType preferred_type = PreferredType::Default) const;
|
||||
|
|
|
@ -52,7 +52,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> AudioConstructor::construct(
|
|||
// 4. If src is given, then set an attribute value for audio using "src" and src.
|
||||
// (This will cause the user agent to invoke the object's resource selection algorithm before returning.)
|
||||
if (!src_value.is_undefined()) {
|
||||
auto src = TRY(src_value.to_string(vm));
|
||||
auto src = TRY(src_value.to_deprecated_string(vm));
|
||||
MUST(audio->set_attribute(HTML::AttributeNames::src, move(src)));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::escape)
|
|||
if (!vm.argument_count())
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountAtLeastOne, "CSS.escape");
|
||||
|
||||
auto identifier = TRY(vm.argument(0).to_string(vm));
|
||||
auto identifier = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
return JS::PrimitiveString::create(vm, Web::CSS::serialize_an_identifier(identifier));
|
||||
}
|
||||
|
||||
|
@ -44,13 +44,13 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::supports)
|
|||
|
||||
if (vm.argument_count() >= 2) {
|
||||
// When the supports(property, value) method is invoked with two arguments property and value:
|
||||
auto property_name = TRY(vm.argument(0).to_string(vm));
|
||||
auto property_name = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// If property is an ASCII case-insensitive match for any defined CSS property that the UA supports,
|
||||
// and value successfully parses according to that property’s grammar, return true.
|
||||
auto property = CSS::property_id_from_string(property_name);
|
||||
if (property != CSS::PropertyID::Invalid) {
|
||||
auto value_string = TRY(vm.argument(1).to_string(vm));
|
||||
auto value_string = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
if (parse_css_value({}, value_string, property))
|
||||
return JS::Value(true);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::supports)
|
|||
return JS::Value(false);
|
||||
} else {
|
||||
// When the supports(conditionText) method is invoked with a single conditionText argument:
|
||||
auto supports_text = TRY(vm.argument(0).to_string(vm));
|
||||
auto supports_text = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// If conditionText, parsed and evaluated as a <supports-condition>, would return true, return true.
|
||||
if (auto supports = parse_css_supports({}, supports_text); supports && supports->matches())
|
||||
|
|
|
@ -61,7 +61,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
return JS::make_handle(static_cast<Request&>(arg0_object));
|
||||
}
|
||||
}
|
||||
return TRY(arg0.to_string(vm));
|
||||
return TRY(arg0.to_deprecated_string(vm));
|
||||
};
|
||||
Variant<JS::Handle<Request>, DeprecatedString> input = TRY(arg0_to_variant(arg0));
|
||||
auto arg1 = vm.argument(1);
|
||||
|
@ -89,7 +89,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (is<JS::ArrayBuffer>(body_property_value_object))
|
||||
return JS::make_handle(body_property_value_object);
|
||||
}
|
||||
return TRY(body_property_value.to_string(vm));
|
||||
return TRY(body_property_value.to_deprecated_string(vm));
|
||||
};
|
||||
Optional<Variant<JS::Handle<ReadableStream>, JS::Handle<Blob>, JS::Handle<JS::Object>, JS::Handle<URLSearchParams>, DeprecatedString>> body_value;
|
||||
if (!body_property_value.is_nullish())
|
||||
|
@ -102,7 +102,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!cache_property_value.is_undefined()) {
|
||||
RequestCache cache_value { RequestCache::Default };
|
||||
if (!cache_property_value.is_undefined()) {
|
||||
auto cache_property_value_string = TRY(cache_property_value.to_string(vm));
|
||||
auto cache_property_value_string = TRY(cache_property_value.to_deprecated_string(vm));
|
||||
if (cache_property_value_string == "only-if-cached"sv)
|
||||
cache_value = RequestCache::OnlyIfCached;
|
||||
else if (cache_property_value_string == "default"sv)
|
||||
|
@ -126,7 +126,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!credentials_property_value.is_undefined()) {
|
||||
RequestCredentials credentials_value { RequestCredentials::Omit };
|
||||
if (!credentials_property_value.is_undefined()) {
|
||||
auto credentials_property_value_string = TRY(credentials_property_value.to_string(vm));
|
||||
auto credentials_property_value_string = TRY(credentials_property_value.to_deprecated_string(vm));
|
||||
if (credentials_property_value_string == "same-origin"sv)
|
||||
credentials_value = RequestCredentials::SameOrigin;
|
||||
else if (credentials_property_value_string == "include"sv)
|
||||
|
@ -144,7 +144,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!duplex_property_value.is_undefined()) {
|
||||
RequestDuplex duplex_value { RequestDuplex::Half };
|
||||
if (!duplex_property_value.is_undefined()) {
|
||||
auto duplex_property_value_string = TRY(duplex_property_value.to_string(vm));
|
||||
auto duplex_property_value_string = TRY(duplex_property_value.to_deprecated_string(vm));
|
||||
if (duplex_property_value_string == "half"sv)
|
||||
duplex_value = RequestDuplex::Half;
|
||||
else
|
||||
|
@ -187,7 +187,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (next_item2.is_null() && false) {
|
||||
sequence_item2 = DeprecatedString::empty();
|
||||
} else {
|
||||
sequence_item2 = TRY(next_item2.to_string(vm));
|
||||
sequence_item2 = TRY(next_item2.to_deprecated_string(vm));
|
||||
}
|
||||
sequence_item1.append(sequence_item2);
|
||||
}
|
||||
|
@ -206,14 +206,14 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (key1.is_null() && false) {
|
||||
typed_key1 = DeprecatedString::empty();
|
||||
} else {
|
||||
typed_key1 = TRY(key1.to_string(vm));
|
||||
typed_key1 = TRY(key1.to_deprecated_string(vm));
|
||||
}
|
||||
auto value1 = TRY(headers_property_value_object.get(property_key1));
|
||||
DeprecatedString typed_value1;
|
||||
if (value1.is_null() && false) {
|
||||
typed_value1 = DeprecatedString::empty();
|
||||
} else {
|
||||
typed_value1 = TRY(value1.to_string(vm));
|
||||
typed_value1 = TRY(value1.to_deprecated_string(vm));
|
||||
}
|
||||
record_union_type.set(typed_key1, typed_value1);
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (integrity_property_value.is_null() && false)
|
||||
integrity_value = DeprecatedString::empty();
|
||||
else
|
||||
integrity_value = TRY(integrity_property_value.to_string(vm));
|
||||
integrity_value = TRY(integrity_property_value.to_deprecated_string(vm));
|
||||
}
|
||||
init.integrity = integrity_value;
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (method_property_value.is_null() && false)
|
||||
method_value = DeprecatedString::empty();
|
||||
else
|
||||
method_value = TRY(method_property_value.to_string(vm));
|
||||
method_value = TRY(method_property_value.to_deprecated_string(vm));
|
||||
}
|
||||
init.method = method_value;
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!mode_property_value.is_undefined()) {
|
||||
RequestMode mode_value { RequestMode::Navigate };
|
||||
if (!mode_property_value.is_undefined()) {
|
||||
auto mode_property_value_string = TRY(mode_property_value.to_string(vm));
|
||||
auto mode_property_value_string = TRY(mode_property_value.to_deprecated_string(vm));
|
||||
if (mode_property_value_string == "navigate"sv)
|
||||
mode_value = RequestMode::Navigate;
|
||||
else if (mode_property_value_string == "same-origin"sv)
|
||||
|
@ -287,7 +287,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!redirect_property_value.is_undefined()) {
|
||||
RequestRedirect redirect_value { RequestRedirect::Follow };
|
||||
if (!redirect_property_value.is_undefined()) {
|
||||
auto redirect_property_value_string = TRY(redirect_property_value.to_string(vm));
|
||||
auto redirect_property_value_string = TRY(redirect_property_value.to_deprecated_string(vm));
|
||||
if (redirect_property_value_string == "follow"sv)
|
||||
redirect_value = RequestRedirect::Follow;
|
||||
else if (redirect_property_value_string == "manual"sv)
|
||||
|
@ -308,7 +308,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (referrer_property_value.is_null() && false)
|
||||
referrer_value = DeprecatedString::empty();
|
||||
else
|
||||
referrer_value = TRY(referrer_property_value.to_string(vm));
|
||||
referrer_value = TRY(referrer_property_value.to_deprecated_string(vm));
|
||||
}
|
||||
init.referrer = referrer_value;
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
|||
if (!referrer_policy_property_value.is_undefined()) {
|
||||
ReferrerPolicy referrer_policy_value { ReferrerPolicy::Empty };
|
||||
if (!referrer_policy_property_value.is_undefined()) {
|
||||
auto referrer_policy_property_value_string = TRY(referrer_policy_property_value.to_string(vm));
|
||||
auto referrer_policy_property_value_string = TRY(referrer_policy_property_value.to_deprecated_string(vm));
|
||||
if (referrer_policy_property_value_string == ""sv)
|
||||
referrer_policy_value = ReferrerPolicy::Empty;
|
||||
else if (referrer_policy_property_value_string == "same-origin"sv)
|
||||
|
|
|
@ -109,7 +109,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_setter)
|
|||
// FIXME: 1. If this's relevant Document is null, then return.
|
||||
|
||||
// 2. Parse the given value relative to the entry settings object. If that failed, throw a TypeError exception.
|
||||
auto new_href = TRY(vm.argument(0).to_string(vm));
|
||||
auto new_href = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto href_url = window.associated_document().parse_url(new_href);
|
||||
if (!href_url.is_valid())
|
||||
return vm.throw_completion<JS::URIError>(DeprecatedString::formatted("Invalid URL '{}'", new_href));
|
||||
|
@ -247,7 +247,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::reload)
|
|||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::replace)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
|
||||
auto url = TRY(vm.argument(0).to_string(vm));
|
||||
auto url = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
// FIXME: This needs spec compliance work.
|
||||
window.did_call_location_replace({}, move(url));
|
||||
return JS::js_undefined();
|
||||
|
|
|
@ -49,7 +49,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> OptionConstructor::construct
|
|||
|
||||
// 3. If text is not the empty string, then append to option a new Text node whose data is text.
|
||||
if (vm.argument_count() > 0) {
|
||||
auto text = TRY(vm.argument(0).to_string(vm));
|
||||
auto text = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
if (!text.is_empty()) {
|
||||
auto new_text_node = vm.heap().allocate<DOM::Text>(realm, document, text);
|
||||
MUST(option_element->append_child(*new_text_node));
|
||||
|
@ -58,7 +58,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> OptionConstructor::construct
|
|||
|
||||
// 4. If value is given, then set an attribute value for option using "value" and value.
|
||||
if (vm.argument_count() > 1) {
|
||||
auto value = TRY(vm.argument(1).to_string(vm));
|
||||
auto value = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
MUST(option_element->set_attribute(HTML::AttributeNames::value, value));
|
||||
}
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ JS::ThrowCompletionOr<bool> CSSStyleDeclaration::internal_set(JS::PropertyKey co
|
|||
if (property_id == CSS::PropertyID::Invalid)
|
||||
return Base::internal_set(name, value, receiver);
|
||||
|
||||
auto css_text = TRY(value.to_string(vm));
|
||||
auto css_text = TRY(value.to_deprecated_string(vm));
|
||||
|
||||
TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return set_property(property_id, css_text); }));
|
||||
return true;
|
||||
|
|
|
@ -1203,17 +1203,17 @@ JS_DEFINE_NATIVE_FUNCTION(Window::open)
|
|||
// optional USVString url = ""
|
||||
DeprecatedString url = "";
|
||||
if (!vm.argument(0).is_undefined())
|
||||
url = TRY(vm.argument(0).to_string(vm));
|
||||
url = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
// optional DOMString target = "_blank"
|
||||
DeprecatedString target = "_blank";
|
||||
if (!vm.argument(1).is_undefined())
|
||||
target = TRY(vm.argument(1).to_string(vm));
|
||||
target = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
|
||||
// optional [LegacyNullToEmptyString] DOMString features = "")
|
||||
DeprecatedString features = "";
|
||||
if (!vm.argument(2).is_nullish())
|
||||
features = TRY(vm.argument(2).to_string(vm));
|
||||
features = TRY(vm.argument(2).to_deprecated_string(vm));
|
||||
|
||||
return TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return impl->open_impl(url, target, features); }));
|
||||
}
|
||||
|
@ -1227,7 +1227,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::alert)
|
|||
auto* impl = TRY(impl_from(vm));
|
||||
DeprecatedString message = "";
|
||||
if (vm.argument_count())
|
||||
message = TRY(vm.argument(0).to_string(vm));
|
||||
message = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
impl->alert_impl(message);
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
@ -1237,7 +1237,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::confirm)
|
|||
auto* impl = TRY(impl_from(vm));
|
||||
DeprecatedString message = "";
|
||||
if (!vm.argument(0).is_undefined())
|
||||
message = TRY(vm.argument(0).to_string(vm));
|
||||
message = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
return JS::Value(impl->confirm_impl(message));
|
||||
}
|
||||
|
||||
|
@ -1247,9 +1247,9 @@ JS_DEFINE_NATIVE_FUNCTION(Window::prompt)
|
|||
DeprecatedString message = "";
|
||||
DeprecatedString default_ = "";
|
||||
if (!vm.argument(0).is_undefined())
|
||||
message = TRY(vm.argument(0).to_string(vm));
|
||||
message = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
if (!vm.argument(1).is_undefined())
|
||||
default_ = TRY(vm.argument(1).to_string(vm));
|
||||
default_ = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
auto response = impl->prompt_impl(message, default_);
|
||||
if (response.is_null())
|
||||
return JS::js_null();
|
||||
|
@ -1260,7 +1260,7 @@ static JS::ThrowCompletionOr<TimerHandler> make_timer_handler(JS::VM& vm, JS::Va
|
|||
{
|
||||
if (handler.is_function())
|
||||
return JS::make_handle(vm.heap().allocate_without_realm<WebIDL::CallbackType>(handler.as_function(), HTML::incumbent_settings_object()));
|
||||
return TRY(handler.to_string(vm));
|
||||
return TRY(handler.to_deprecated_string(vm));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
|
||||
|
@ -1400,7 +1400,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::atob)
|
|||
{
|
||||
if (!vm.argument_count())
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountOne, "atob");
|
||||
auto deprecated_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto deprecated_string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto string = String::from_utf8(deprecated_string).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// must throw an "InvalidCharacterError" DOMException if data contains any character whose code point is greater than U+00FF
|
||||
|
@ -1428,7 +1428,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::btoa)
|
|||
{
|
||||
if (!vm.argument_count())
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::BadArgCountOne, "btoa");
|
||||
auto string = TRY(vm.argument(0).to_string(vm));
|
||||
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
Vector<u8> byte_string;
|
||||
byte_string.ensure_capacity(string.length());
|
||||
|
@ -1665,7 +1665,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::get_selection)
|
|||
JS_DEFINE_NATIVE_FUNCTION(Window::match_media)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
auto media = TRY(vm.argument(0).to_string(vm));
|
||||
auto media = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
return impl->match_media_impl(move(media));
|
||||
}
|
||||
|
||||
|
@ -1721,7 +1721,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::scroll)
|
|||
|
||||
auto behavior_string_value = TRY(options->get("behavior"));
|
||||
if (!behavior_string_value.is_undefined())
|
||||
behavior_string = TRY(behavior_string_value.to_string(vm));
|
||||
behavior_string = TRY(behavior_string_value.to_deprecated_string(vm));
|
||||
if (behavior_string != "smooth" && behavior_string != "auto")
|
||||
return vm.throw_completion<JS::TypeError>("Behavior is not one of 'smooth' or 'auto'");
|
||||
|
||||
|
@ -1784,7 +1784,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::scroll_by)
|
|||
top = top + static_cast<double>(current_scroll_position.y());
|
||||
|
||||
auto behavior_string_value = TRY(options->get("behavior"));
|
||||
auto behavior_string = behavior_string_value.is_undefined() ? "auto" : TRY(behavior_string_value.to_string(vm));
|
||||
auto behavior_string = behavior_string_value.is_undefined() ? "auto" : TRY(behavior_string_value.to_deprecated_string(vm));
|
||||
if (behavior_string != "smooth" && behavior_string != "auto")
|
||||
return vm.throw_completion<JS::TypeError>("Behavior is not one of 'smooth' or 'auto'");
|
||||
ScrollBehavior behavior = (behavior_string == "smooth") ? ScrollBehavior::Smooth : ScrollBehavior::Auto;
|
||||
|
@ -1841,7 +1841,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::outer_height_getter)
|
|||
JS_DEFINE_NATIVE_FUNCTION(Window::post_message)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
auto target_origin = TRY(vm.argument(1).to_string(vm));
|
||||
auto target_origin = TRY(vm.argument(1).to_deprecated_string(vm));
|
||||
TRY(Bindings::throw_dom_exception_if_needed(vm, [&] {
|
||||
return impl->post_message_impl(vm.argument(0), target_origin);
|
||||
}));
|
||||
|
@ -1884,7 +1884,7 @@ JS_DEFINE_NATIVE_FUNCTION(Window::name_getter)
|
|||
JS_DEFINE_NATIVE_FUNCTION(Window::name_setter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
impl->set_name(TRY(vm.argument(0).to_string(vm)));
|
||||
impl->set_name(TRY(vm.argument(0).to_deprecated_string(vm)));
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ JS::ThrowCompletionOr<WebGLContextAttributes> convert_value_to_context_attribute
|
|||
WebGLPowerPreference power_preference_value { WebGLPowerPreference::Default };
|
||||
|
||||
if (!power_preference.is_undefined()) {
|
||||
auto power_preference_string = TRY(power_preference.to_string(vm));
|
||||
auto power_preference_string = TRY(power_preference.to_deprecated_string(vm));
|
||||
|
||||
if (power_preference_string == "high-performance"sv)
|
||||
power_preference_value = WebGLPowerPreference::HighPerformance;
|
||||
|
|
|
@ -68,7 +68,7 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalEnvironmentExtensions::$_function)
|
|||
auto* console_global_object = TRY(get_console(vm));
|
||||
auto& window = *console_global_object->m_window_object;
|
||||
|
||||
auto selector = TRY(vm.argument(0).to_string(vm));
|
||||
auto selector = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
if (vm.argument_count() > 1) {
|
||||
auto element_value = vm.argument(1);
|
||||
|
@ -92,7 +92,7 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalEnvironmentExtensions::$$_function)
|
|||
auto* console_global_object = TRY(get_console(vm));
|
||||
auto& window = *console_global_object->m_window_object;
|
||||
|
||||
auto selector = TRY(vm.argument(0).to_string(vm));
|
||||
auto selector = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
|
||||
Web::DOM::ParentNode* element = &window.associated_document();
|
||||
|
||||
|
|
|
@ -1033,7 +1033,7 @@ Messages::WebDriverClient::GetElementPropertyResponse WebDriverConnection::get_e
|
|||
|
||||
// 5. Let result be the value of property if not undefined, or null.
|
||||
if (!property.is_undefined()) {
|
||||
if (auto string_or_error = property.to_string(element->vm()); !string_or_error.is_error())
|
||||
if (auto string_or_error = property.to_deprecated_string(element->vm()); !string_or_error.is_error())
|
||||
result = string_or_error.release_value();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm)
|
|||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto filename = TRY(vm.argument(0).to_string(vm));
|
||||
auto filename = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto file_or_error = Core::Stream::File::open(filename, Core::Stream::OpenMode::Read);
|
||||
if (file_or_error.is_error())
|
||||
return vm.throw_completion<JS::Error>(DeprecatedString::formatted("Failed to open '{}': {}", filename, file_or_error.error()));
|
||||
|
@ -365,7 +365,7 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm)
|
|||
|
||||
static JS::ThrowCompletionOr<JS::Value> load_json_impl(JS::VM& vm)
|
||||
{
|
||||
auto filename = TRY(vm.argument(0).to_string(vm));
|
||||
auto filename = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto file_or_error = Core::Stream::File::open(filename, Core::Stream::OpenMode::Read);
|
||||
if (file_or_error.is_error())
|
||||
return vm.throw_completion<JS::Error>(DeprecatedString::formatted("Failed to open '{}': {}", filename, file_or_error.error()));
|
||||
|
|
Loading…
Add table
Reference in a new issue