diff --git a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp index dc0f091d15..0c08ec957b 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -201,9 +202,8 @@ struct ConvertToRaw { { LittleEndian res; ReadonlyBytes bytes { &value, sizeof(float) }; - InputMemoryStream stream { bytes }; - stream >> res; - VERIFY(!stream.has_any_error()); + auto stream = Core::Stream::FixedMemoryStream::construct(bytes).release_value_but_fixme_should_propagate_errors(); + stream->read_entire_buffer(res.bytes()).release_value_but_fixme_should_propagate_errors(); return static_cast(res); } }; @@ -214,9 +214,8 @@ struct ConvertToRaw { { LittleEndian res; ReadonlyBytes bytes { &value, sizeof(double) }; - InputMemoryStream stream { bytes }; - stream >> res; - VERIFY(!stream.has_any_error()); + auto stream = Core::Stream::FixedMemoryStream::construct(bytes).release_value_but_fixme_should_propagate_errors(); + stream->read_entire_buffer(res.bytes()).release_value_but_fixme_should_propagate_errors(); return static_cast(res); } }; @@ -253,9 +252,9 @@ template T BytecodeInterpreter::read_value(ReadonlyBytes data) { LittleEndian value; - InputMemoryStream stream { data }; - stream >> value; - if (stream.handle_any_error()) { + auto stream = Core::Stream::FixedMemoryStream::construct(data).release_value_but_fixme_should_propagate_errors(); + auto maybe_error = stream->read_entire_buffer(value.bytes()); + if (maybe_error.is_error()) { dbgln("Read from {} failed", data.data()); m_trap = Trap { "Read from memory failed" }; } @@ -265,10 +264,10 @@ T BytecodeInterpreter::read_value(ReadonlyBytes data) template<> float BytecodeInterpreter::read_value(ReadonlyBytes data) { - InputMemoryStream stream { data }; LittleEndian raw_value; - stream >> raw_value; - if (stream.handle_any_error()) + auto stream = Core::Stream::FixedMemoryStream::construct(data).release_value_but_fixme_should_propagate_errors(); + auto maybe_error = stream->read_entire_buffer(raw_value.bytes()); + if (maybe_error.is_error()) m_trap = Trap { "Read from memory failed" }; return bit_cast(static_cast(raw_value)); } @@ -276,10 +275,10 @@ float BytecodeInterpreter::read_value(ReadonlyBytes data) template<> double BytecodeInterpreter::read_value(ReadonlyBytes data) { - InputMemoryStream stream { data }; LittleEndian raw_value; - stream >> raw_value; - if (stream.handle_any_error()) + auto stream = Core::Stream::FixedMemoryStream::construct(data).release_value_but_fixme_should_propagate_errors(); + auto maybe_error = stream->read_entire_buffer(raw_value.bytes()); + if (maybe_error.is_error()) m_trap = Trap { "Read from memory failed" }; return bit_cast(static_cast(raw_value)); }