diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-08-09 10:05:01 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-07 09:54:57 -0700 |
commit | ef82c858b9ca6e1a9e34e79398195e7b549507aa (patch) | |
tree | 8d2649cb53f8ce01732117ad8cb7ad05609a133d /src | |
parent | 15240ea1537d00f03af1abec8633e3890918be8e (diff) | |
download | binaryen-ef82c858b9ca6e1a9e34e79398195e7b549507aa.tar.gz binaryen-ef82c858b9ca6e1a9e34e79398195e7b549507aa.tar.bz2 binaryen-ef82c858b9ca6e1a9e34e79398195e7b549507aa.zip |
wasm-shell improvements: print out which module is built, add option to skip lines
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/wasm-shell.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/tools/wasm-shell.cpp b/src/tools/wasm-shell.cpp index 32bc746b2..a95ced87f 100644 --- a/src/tools/wasm-shell.cpp +++ b/src/tools/wasm-shell.cpp @@ -136,9 +136,8 @@ static void run_asserts(size_t* i, bool* checked, Module* wasm, assert(wasm); Invocation invocation(curr, instance.get(), *builder->get()); invocation.invoke(); - } else { + } else if (wasm) { // if no wasm, we skipped the module // an invoke test - assert(wasm); bool trapped = false; WASM_UNUSED(trapped); Literal result; @@ -175,6 +174,7 @@ static void run_asserts(size_t* i, bool* checked, Module* wasm, int main(int argc, const char* argv[]) { Name entry; + std::set<size_t> skipped; Options options("wasm-shell", "Execute .wast files"); options @@ -182,6 +182,21 @@ int main(int argc, const char* argv[]) { "--entry", "-e", "call the entry point after parsing the module", Options::Arguments::One, [&entry](Options*, const std::string& argument) { entry = argument; }) + .add( + "--skip", "-s", "skip input on certain lines (comma-separated-list)", + Options::Arguments::One, + [&skipped](Options*, const std::string& argument) { + size_t i = 0; + while (i < argument.size()) { + auto ending = argument.find(',', i); + if (ending == std::string::npos) { + ending = argument.size(); + } + auto sub = argument.substr(i, ending - i); + skipped.insert(atoi(sub.c_str())); + i = ending + 1; + } + }) .add_positional("INFILE", Options::Arguments::One, [](Options* o, const std::string& argument) { o->extra["infile"] = argument; @@ -201,9 +216,19 @@ int main(int argc, const char* argv[]) { size_t i = 0; while (i < root.size()) { Element& curr = *root[i]; + if (skipped.count(curr.line) > 0) { + Colors::green(std::cerr); + std::cerr << "SKIPPING [line: " << curr.line << "]\n"; + Colors::normal(std::cerr); + i++; + continue; + } IString id = curr[0]->str(); if (id == MODULE) { if (options.debug) std::cerr << "parsing s-expressions to wasm...\n"; + Colors::green(std::cerr); + std::cerr << "BUILDING MODULE [line: " << curr.line << "]\n"; + Colors::normal(std::cerr); Module wasm; std::unique_ptr<SExpressionWasmBuilder> builder; builder = wasm::make_unique<SExpressionWasmBuilder>(wasm, *root[i]); |