LibJS: Convert remaining usages of Value::TDSWOSE to Value::TSWOSE

Note the couple of cases using MUST are just debugging statements.
This commit is contained in:
Timothy Flynn 2023-02-12 21:54:02 -05:00 committed by Linus Groh
parent c17589a402
commit 24e9cea524
Notes: sideshowbarker 2024-07-17 00:19:13 +09:00
8 changed files with 28 additions and 22 deletions

View file

@ -53,7 +53,7 @@ TESTJS_GLOBAL_FUNCTION(mark_as_garbage, markAsGarbage)
{
auto argument = vm.argument(0);
if (!argument.is_string())
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAString, argument.to_deprecated_string_without_side_effects());
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAString, TRY_OR_THROW_OOM(vm, argument.to_string_without_side_effects()));
auto& variable_name = argument.as_string();

View file

@ -112,22 +112,22 @@ static Result<void, TestError> run_program(InterpreterT& interpreter, ScriptOrMo
auto name = object.get_without_side_effects("name");
if (!name.is_empty() && !name.is_accessor()) {
error.type = name.to_deprecated_string_without_side_effects();
error.type = name.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
} else {
auto constructor = object.get_without_side_effects("constructor");
if (constructor.is_object()) {
name = constructor.as_object().get_without_side_effects("name");
if (!name.is_undefined())
error.type = name.to_deprecated_string_without_side_effects();
error.type = name.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
}
}
auto message = object.get_without_side_effects("message");
if (!message.is_empty() && !message.is_accessor())
error.details = message.to_deprecated_string_without_side_effects();
error.details = message.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
}
if (error.type.is_empty())
error.type = error_value.to_deprecated_string_without_side_effects();
error.type = error_value.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
return error;
}
return {};

View file

@ -145,11 +145,11 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Executable const& e
if constexpr (JS_BYTECODE_DEBUG) {
for (size_t i = 0; i < registers().size(); ++i) {
DeprecatedString value_string;
String value_string;
if (registers()[i].is_empty())
value_string = "(empty)";
value_string = MUST(String::from_utf8("(empty)"sv));
else
value_string = registers()[i].to_deprecated_string_without_side_effects();
value_string = MUST(registers()[i].to_string_without_side_effects());
dbgln("[{:3}] {}", i, value_string);
}
}

View file

@ -593,7 +593,7 @@ static MarkedVector<Value> argument_list_evaluation(Bytecode::Interpreter& inter
auto arguments = interpreter.accumulator();
if (!(arguments.is_object() && is<Array>(arguments.as_object()))) {
dbgln("[{}] Call arguments are not an array, but: {}", interpreter.debug_position(), arguments.to_deprecated_string_without_side_effects());
dbgln("[{}] Call arguments are not an array, but: {}", interpreter.debug_position(), MUST(arguments.to_string_without_side_effects()));
interpreter.current_executable().dump();
VERIFY_NOT_REACHED();
}
@ -1345,7 +1345,11 @@ DeprecatedString GetObjectPropertyIterator::to_deprecated_string_impl(Bytecode::
DeprecatedString IteratorClose::to_deprecated_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("IteratorClose completion_type={} completion_value={}", to_underlying(m_completion_type), m_completion_value.has_value() ? m_completion_value.value().to_deprecated_string_without_side_effects() : "<empty>");
if (!m_completion_value.has_value())
return DeprecatedString::formatted("IteratorClose completion_type={} completion_value=<empty>", to_underlying(m_completion_type));
auto completion_value_string = m_completion_value->to_string_without_side_effects().release_value_but_fixme_should_propagate_errors();
return DeprecatedString::formatted("IteratorClose completion_type={} completion_value={}", to_underlying(m_completion_type), completion_value_string);
}
DeprecatedString IteratorNext::to_deprecated_string_impl(Executable const&) const

View file

@ -81,7 +81,7 @@ ErrorOr<void> MarkupGenerator::value_to_html(Value value, StringBuilder& output_
if (value.is_string())
TRY(output_html.try_append('"'));
TRY(output_html.try_append(escape_html_entities(value.to_deprecated_string_without_side_effects())));
TRY(output_html.try_append(escape_html_entities(TRY(value.to_string_without_side_effects()))));
if (value.is_string())
TRY(output_html.try_append('"'));
@ -167,8 +167,8 @@ ErrorOr<void> MarkupGenerator::error_to_html(Error const& error, StringBuilder&
auto& vm = error.vm();
auto name = error.get_without_side_effects(vm.names.name).value_or(js_undefined());
auto message = error.get_without_side_effects(vm.names.message).value_or(js_undefined());
auto name_string = name.to_deprecated_string_without_side_effects();
auto message_string = message.to_deprecated_string_without_side_effects();
auto name_string = TRY(name.to_string_without_side_effects());
auto message_string = TRY(message.to_string_without_side_effects());
auto uncaught_message = TRY(String::formatted("Uncaught {}[{}]: ", in_promise ? "(in promise) " : "", name_string));
TRY(html_output.try_append(TRY(wrap_string_in_style(uncaught_message, StyleType::Invalid)).bytes_as_string_view()));

View file

@ -230,8 +230,8 @@ ErrorOr<void> print_error(JS::PrintContext& print_context, JS::Object const& obj
if (name.is_accessor() || message.is_accessor()) {
TRY(print_value(print_context, &object, seen_objects));
} else {
auto name_string = name.to_deprecated_string_without_side_effects();
auto message_string = message.to_deprecated_string_without_side_effects();
auto name_string = TRY(name.to_string_without_side_effects());
auto message_string = TRY(message.to_string_without_side_effects());
TRY(print_type(print_context, name_string));
if (!message_string.is_empty())
TRY(js_out(print_context, " \033[31;1m{}\033[0m", message_string));
@ -1018,7 +1018,7 @@ ErrorOr<void> print_value(JS::PrintContext& print_context, JS::Value value, Hash
TRY(js_out(print_context, "\""));
else if (value.is_negative_zero())
TRY(js_out(print_context, "-"));
TRY(js_out(print_context, "{}", value.to_deprecated_string_without_side_effects()));
TRY(js_out(print_context, "{}", TRY(value.to_string_without_side_effects())));
if (value.is_string())
TRY(js_out(print_context, "\""));
TRY(js_out(print_context, "\033[0m"));

View file

@ -683,7 +683,9 @@ template<>
struct Formatter<JS::Value> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, JS::Value value)
{
return Formatter<StringView>::format(builder, value.is_empty() ? "<empty>" : value.to_deprecated_string_without_side_effects());
if (value.is_empty())
return Formatter<StringView>::format(builder, "<empty>"sv);
return Formatter<StringView>::format(builder, TRY(value.to_string_without_side_effects()));
}
};

View file

@ -409,7 +409,7 @@ inline JSFileResult TestRunner::run_file_test(DeprecatedString const& test_path)
auto& arr = user_output.as_array();
for (auto& entry : arr.indexed_properties()) {
auto message = MUST(arr.get(entry.index()));
file_result.logged_messages.append(message.to_deprecated_string_without_side_effects());
file_result.logged_messages.append(message.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors().to_deprecated_string());
}
test_json.value().as_object().for_each_member([&](DeprecatedString const& suite_name, JsonValue const& suite_value) {
@ -475,11 +475,11 @@ inline JSFileResult TestRunner::run_file_test(DeprecatedString const& test_path)
auto message = error_object.get_without_side_effects(g_vm->names.message).value_or(JS::js_undefined());
if (name.is_accessor() || message.is_accessor()) {
detail_builder.append(error.to_deprecated_string_without_side_effects());
detail_builder.append(error.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors());
} else {
detail_builder.append(name.to_deprecated_string_without_side_effects());
detail_builder.append(name.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors());
detail_builder.append(": "sv);
detail_builder.append(message.to_deprecated_string_without_side_effects());
detail_builder.append(message.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors());
}
if (is<JS::Error>(error_object)) {
@ -490,7 +490,7 @@ inline JSFileResult TestRunner::run_file_test(DeprecatedString const& test_path)
test_case.details = detail_builder.to_deprecated_string();
} else {
test_case.details = error.to_deprecated_string_without_side_effects();
test_case.details = error.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
}
suite.tests.append(move(test_case));