mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:57:35 +00:00
LibWasm: Add a module pretty printer
This commit is contained in:
parent
7a12f23c28
commit
bd8dac111c
5 changed files with 885 additions and 16 deletions
|
@ -7,14 +7,17 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/FileStream.h>
|
||||
#include <LibWasm/Printer/Printer.h>
|
||||
#include <LibWasm/Types.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* filename = nullptr;
|
||||
bool print = false;
|
||||
|
||||
Core::ArgsParser parser;
|
||||
parser.add_positional_argument(filename, "File name to parse", "file");
|
||||
parser.add_option(print, "Print the parsed module", "print", 'p');
|
||||
parser.parse(argc, argv);
|
||||
|
||||
auto result = Core::File::open(filename, Core::OpenMode::ReadOnly);
|
||||
|
@ -31,5 +34,11 @@ int main(int argc, char* argv[])
|
|||
return 2;
|
||||
}
|
||||
|
||||
if (print) {
|
||||
auto out_stream = Core::OutputFileStream::standard_output();
|
||||
Wasm::Printer printer(out_stream);
|
||||
printer.print(parse_result.value());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue