diff options
author | Alon Zakai <alonzakai@gmail.com> | 2019-01-23 16:15:38 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-23 16:15:38 -0800 |
commit | 119525ea6078c9af697de0038407ab541f3d4c12 (patch) | |
tree | 16aa2f609ab96975ceb8862e3ece7baaa05f5828 /src/tools/wasm2js.cpp | |
parent | e63c4a7d04c145dafaf4b09de5f9f5de69cee8ef (diff) | |
download | binaryen-119525ea6078c9af697de0038407ab541f3d4c12.tar.gz binaryen-119525ea6078c9af697de0038407ab541f3d4c12.tar.bz2 binaryen-119525ea6078c9af697de0038407ab541f3d4c12.zip |
Validate unique local names, and use validation in wasm2js. Fixes #1885 (#1886)
* Also fixes some bugs in wasm2js tests that did not validate.
* Rename FeatureOptions => ToolOptions, as they now contain all the basic stuff each tool needs for commandline options (validation yes or no, and which features if so).
Diffstat (limited to 'src/tools/wasm2js.cpp')
-rw-r--r-- | src/tools/wasm2js.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/tools/wasm2js.cpp b/src/tools/wasm2js.cpp index 762a89985..277a4e2c9 100644 --- a/src/tools/wasm2js.cpp +++ b/src/tools/wasm2js.cpp @@ -23,13 +23,14 @@ #include "support/file.h" #include "wasm-s-parser.h" #include "wasm2js.h" +#include "tool-options.h" using namespace cashew; using namespace wasm; int main(int argc, const char *argv[]) { Wasm2JSBuilder::Flags builderFlags; - Options options("wasm2js", "Transform .wasm/.wast files to asm.js"); + ToolOptions options("wasm2js", "Transform .wasm/.wast files to asm.js"); options .add("--output", "-o", "Output file (stdout if not specified)", Options::Arguments::One, @@ -97,6 +98,13 @@ int main(int argc, const char *argv[]) { Fatal() << "error in building module, std::bad_alloc (possibly invalid request for silly amounts of memory)"; } + if (options.passOptions.validate) { + if (!WasmValidator().validate(wasm, options.getFeatures())) { + WasmPrinter::printModule(&wasm); + Fatal() << "error in validating input"; + } + } + if (options.debug) std::cerr << "asming..." << std::endl; Wasm2JSBuilder wasm2js(builderFlags); asmjs = wasm2js.processWasm(&wasm); |