summaryrefslogtreecommitdiff
path: root/src/tools/wasm2wast.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/wasm2wast.cc')
-rw-r--r--src/tools/wasm2wast.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/tools/wasm2wast.cc b/src/tools/wasm2wast.cc
index 94dd3fa8..9cf46072 100644
--- a/src/tools/wasm2wast.cc
+++ b/src/tools/wasm2wast.cc
@@ -38,6 +38,7 @@ static int s_verbose;
static const char* s_infile;
static const char* s_outfile;
static ReadBinaryOptions s_read_binary_options = {nullptr, true};
+static WriteWatOptions s_write_wat_options;
static bool s_generate_names;
static std::unique_ptr<FileStream> s_log_stream;
@@ -50,6 +51,7 @@ enum {
FLAG_OUTPUT,
FLAG_NO_DEBUG_NAMES,
FLAG_GENERATE_NAMES,
+ FLAG_FOLD_EXPRS,
NUM_FLAGS
};
@@ -70,6 +72,8 @@ static Option s_options[] = {
{FLAG_HELP, 'h', "help", nullptr, NOPE, "print this help message"},
{FLAG_OUTPUT, 'o', "output", "FILENAME", YEP,
"output file for the generated wast file, by default use stdout"},
+ {FLAG_FOLD_EXPRS, 'f', "fold-exprs", nullptr, NOPE,
+ "Write folded expressions where possible"},
{FLAG_NO_DEBUG_NAMES, 0, "no-debug-names", nullptr, NOPE,
"Ignore debug names in the binary file"},
{FLAG_GENERATE_NAMES, 0, "generate-names", nullptr, NOPE,
@@ -96,6 +100,10 @@ static void on_option(struct OptionParser* parser,
s_outfile = argument;
break;
+ case FLAG_FOLD_EXPRS:
+ s_write_wat_options.fold_exprs = true;
+ break;
+
case FLAG_NO_DEBUG_NAMES:
s_read_binary_options.read_debug_names = false;
break;
@@ -159,7 +167,7 @@ int ProgramMain(int argc, char** argv) {
if (WABT_SUCCEEDED(result)) {
FileWriter writer(s_outfile ? FileWriter(s_outfile)
: FileWriter(stdout));
- result = write_wat(&writer, &module);
+ result = write_wat(&writer, &module, &s_write_wat_options);
}
}
delete[] data;