summaryrefslogtreecommitdiff
path: root/src/tools/wasm-dis.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/wasm-dis.cpp')
-rw-r--r--src/tools/wasm-dis.cpp54
1 files changed, 35 insertions, 19 deletions
diff --git a/src/tools/wasm-dis.cpp b/src/tools/wasm-dis.cpp
index 3ff6819a5..5b9cb9804 100644
--- a/src/tools/wasm-dis.cpp
+++ b/src/tools/wasm-dis.cpp
@@ -27,25 +27,37 @@
using namespace cashew;
using namespace wasm;
-int main(int argc, const char *argv[]) {
+int main(int argc, const char* argv[]) {
std::string sourceMapFilename;
- Options options("wasm-dis", "Un-assemble a .wasm (WebAssembly binary format) into a .wast (WebAssembly text format)");
- options.add("--output", "-o", "Output file (stdout if not specified)",
- Options::Arguments::One,
- [](Options *o, const std::string& argument) {
- o->extra["output"] = argument;
- Colors::disable();
- })
- .add("--source-map", "-sm", "Consume source map from the specified file to add location information",
- Options::Arguments::One,
- [&sourceMapFilename](Options *o, const std::string& argument) { sourceMapFilename = argument; })
- .add_positional("INFILE", Options::Arguments::One,
- [](Options *o, const std::string& argument) {
- o->extra["infile"] = argument;
- });
+ Options options("wasm-dis",
+ "Un-assemble a .wasm (WebAssembly binary format) into a "
+ ".wast (WebAssembly text format)");
+ options
+ .add("--output",
+ "-o",
+ "Output file (stdout if not specified)",
+ Options::Arguments::One,
+ [](Options* o, const std::string& argument) {
+ o->extra["output"] = argument;
+ Colors::disable();
+ })
+ .add(
+ "--source-map",
+ "-sm",
+ "Consume source map from the specified file to add location information",
+ Options::Arguments::One,
+ [&sourceMapFilename](Options* o, const std::string& argument) {
+ sourceMapFilename = argument;
+ })
+ .add_positional("INFILE",
+ Options::Arguments::One,
+ [](Options* o, const std::string& argument) {
+ o->extra["infile"] = argument;
+ });
options.parse(argc, argv);
- if (options.debug) std::cerr << "parsing binary..." << std::endl;
+ if (options.debug)
+ std::cerr << "parsing binary..." << std::endl;
Module wasm;
try {
ModuleReader().readBinary(options.extra["infile"], wasm, sourceMapFilename);
@@ -59,10 +71,14 @@ int main(int argc, const char *argv[]) {
Fatal() << "error in parsing wasm source mapping";
}
- if (options.debug) std::cerr << "Printing..." << std::endl;
- Output output(options.extra["output"], Flags::Text, options.debug ? Flags::Debug : Flags::Release);
+ if (options.debug)
+ std::cerr << "Printing..." << std::endl;
+ Output output(options.extra["output"],
+ Flags::Text,
+ options.debug ? Flags::Debug : Flags::Release);
WasmPrinter::printModule(&wasm, output.getStream());
output << '\n';
- if (options.debug) std::cerr << "Done." << std::endl;
+ if (options.debug)
+ std::cerr << "Done." << std::endl;
}