From 5a40ce442b95ebd5f23871b4ec684ba12d5f7356 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Mon, 11 Mar 2024 22:57:59 +0100 Subject: [PATCH] LibWasm: Remove uses of AK::Result Closes #23500. --- .../LibWasm/AbstractMachine/AbstractMachine.cpp | 2 +- .../LibWasm/AbstractMachine/AbstractMachine.h | 4 ++-- .../AbstractMachine/BytecodeInterpreter.cpp | 4 ++-- .../Libraries/LibWasm/AbstractMachine/Operators.h | 14 +++++++------- Userland/Libraries/LibWasm/Parser/Parser.cpp | 2 +- Userland/Libraries/LibWasm/Types.h | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp index 70d40456e5..c8c292b88d 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp @@ -551,7 +551,7 @@ void Linker::link(HashMap const& exports) m_unresolved_imports.remove(entry); } -AK::Result, LinkError> Linker::finish() +AK::ErrorOr, LinkError> Linker::finish() { populate(); if (!m_unresolved_imports.is_empty()) { diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h index c4e5441dad..37355a5e5a 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h @@ -604,7 +604,7 @@ private: Vector m_data; }; -using InstantiationResult = AK::Result, InstantiationError>; +using InstantiationResult = AK::ErrorOr, InstantiationError>; class AbstractMachine { public: @@ -655,7 +655,7 @@ public: return m_unresolved_imports; } - AK::Result, LinkError> finish(); + AK::ErrorOr, LinkError> finish(); private: void populate(); diff --git a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp index af61128e24..61e335b7a9 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp @@ -307,7 +307,7 @@ void BytecodeInterpreter::binary_numeric_operation(Configuration& configuration, auto lhs = lhs_ptr->to(); PushType result; auto call_result = Operator { forward(args)... }(lhs.value(), rhs.value()); - if constexpr (IsSpecializationOf) { + if constexpr (IsSpecializationOf) { if (call_result.is_error()) { trap_if_not(false, call_result.error()); return; @@ -328,7 +328,7 @@ void BytecodeInterpreter::unary_operation(Configuration& configuration, Args&&.. auto value = entry_ptr->to(); auto call_result = Operator { forward(args)... }(*value); PushType result; - if constexpr (IsSpecializationOf) { + if constexpr (IsSpecializationOf) { if (call_result.is_error()) { trap_if_not(false, call_result.error()); return; diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Operators.h b/Userland/Libraries/LibWasm/AbstractMachine/Operators.h index 20542e7dce..1628105d99 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Operators.h +++ b/Userland/Libraries/LibWasm/AbstractMachine/Operators.h @@ -58,8 +58,8 @@ struct Divide { Checked value(lhs); value /= rhs; if (value.has_overflow()) - return AK::Result("Integer division overflow"sv); - return AK::Result(value.value()); + return AK::ErrorOr("Integer division overflow"sv); + return AK::ErrorOr(value.value()); } } @@ -71,12 +71,12 @@ struct Modulo { auto operator()(Lhs lhs, Rhs rhs) const { if (rhs == 0) - return AK::Result("Integer division overflow"sv); + return AK::ErrorOr("Integer division overflow"sv); if constexpr (IsSigned) { if (rhs == -1) - return AK::Result(0); // Spec weirdness right here, signed division overflow is ignored. + return AK::ErrorOr(0); // Spec weirdness right here, signed division overflow is ignored. } - return AK::Result(lhs % rhs); + return AK::ErrorOr(lhs % rhs); } static StringView name() { return "%"sv; } @@ -479,7 +479,7 @@ struct Floor { struct Truncate { template - AK::Result operator()(Lhs lhs) const + AK::ErrorOr operator()(Lhs lhs) const { if constexpr (IsSame) return truncf(lhs); @@ -536,7 +536,7 @@ struct Wrap { template struct CheckedTruncate { template - AK::Result operator()(Lhs lhs) const + AK::ErrorOr operator()(Lhs lhs) const { if (isnan(lhs) || isinf(lhs)) // "undefined", let's just trap. return "Truncation undefined behavior"sv; diff --git a/Userland/Libraries/LibWasm/Parser/Parser.cpp b/Userland/Libraries/LibWasm/Parser/Parser.cpp index 8a11fbdba4..53012875a3 100644 --- a/Userland/Libraries/LibWasm/Parser/Parser.cpp +++ b/Userland/Libraries/LibWasm/Parser/Parser.cpp @@ -28,7 +28,7 @@ static auto parse_vector(Stream& stream) { ScopeLogger logger; if constexpr (requires { T::parse(stream); }) { - using ResultT = typename decltype(T::parse(stream))::ValueType; + using ResultT = typename decltype(T::parse(stream))::ResultType; auto count_or_error = stream.read_value>(); if (count_or_error.is_error()) return ParseResult> { with_eof_check(stream, ParseError::ExpectedSize) }; diff --git a/Userland/Libraries/LibWasm/Types.h b/Userland/Libraries/LibWasm/Types.h index 6135e00046..aff3feee46 100644 --- a/Userland/Libraries/LibWasm/Types.h +++ b/Userland/Libraries/LibWasm/Types.h @@ -61,7 +61,7 @@ enum class ParseError { ByteString parse_error_to_byte_string(ParseError); template -using ParseResult = Result; +using ParseResult = ErrorOr; AK_TYPEDEF_DISTINCT_ORDERED_ID(size_t, TypeIndex); AK_TYPEDEF_DISTINCT_ORDERED_ID(size_t, FunctionIndex);