1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:34:57 +00:00

LibWasm: Use AllocatingMemoryStream around Wasm::Printer

This commit is contained in:
Tim Schumacher 2023-01-09 12:06:13 +01:00 committed by Linus Groh
parent 7d4a30af56
commit 52cb066cae
2 changed files with 12 additions and 6 deletions

View file

@ -9,6 +9,7 @@
#include <LibCore/File.h>
#include <LibCore/FileStream.h>
#include <LibCore/MappedFile.h>
#include <LibCore/MemoryStream.h>
#include <LibLine/Editor.h>
#include <LibMain/Main.h>
#include <LibWasm/AbstractMachine/AbstractMachine.h>
@ -396,13 +397,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
StringBuilder argument_builder;
bool first = true;
for (auto& argument : arguments) {
DuplexMemoryStream stream;
Wasm::Printer { stream }.print(argument);
Core::Stream::AllocatingMemoryStream stream;
Core::Stream::WrapInAKOutputStream wrapped_stream { stream };
Wasm::Printer { wrapped_stream }.print(argument);
if (first)
first = false;
else
argument_builder.append(", "sv);
ByteBuffer buffer = stream.copy_into_contiguous_buffer();
auto buffer = ByteBuffer::create_uninitialized(stream.used_buffer_size()).release_value_but_fixme_should_propagate_errors();
stream.read_entire_buffer(buffer).release_value_but_fixme_should_propagate_errors();
argument_builder.append(StringView(buffer).trim_whitespace());
}
dbgln("[wasm runtime] Stub function {} was called with the following arguments: {}", name, argument_builder.to_deprecated_string());