diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-06-07 19:23:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-07 19:23:49 -0700 |
commit | 7676221b837bbd20daf1889dbdabf3cb76721658 (patch) | |
tree | 32f5721cdcf90cf0e4316fc2ba131549c8a90f8e /src/tools/wasm-as.cpp | |
parent | 3af404435b3cfa90704810370703f20921c055dd (diff) | |
download | binaryen-7676221b837bbd20daf1889dbdabf3cb76721658.tar.gz binaryen-7676221b837bbd20daf1889dbdabf3cb76721658.tar.bz2 binaryen-7676221b837bbd20daf1889dbdabf3cb76721658.zip |
wasm-opt source map support (#1557)
* support source map input in wasm-opt, refactoring the loading code into wasm-io
* use wasm-io in wasm-as
* support output source maps in wasm-opt
* add a test for wasm-opt and source maps
Diffstat (limited to 'src/tools/wasm-as.cpp')
-rw-r--r-- | src/tools/wasm-as.cpp | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/tools/wasm-as.cpp b/src/tools/wasm-as.cpp index b01bae0e3..46885dec0 100644 --- a/src/tools/wasm-as.cpp +++ b/src/tools/wasm-as.cpp @@ -21,8 +21,9 @@ #include "support/colors.h" #include "support/command-line.h" #include "support/file.h" -#include "wasm-binary.h" +#include "wasm-io.h" #include "wasm-s-parser.h" +#include "wasm-validator.h" #include "tool-utils.h" @@ -99,26 +100,18 @@ int main(int argc, const char *argv[]) { } } - if (options.debug) std::cerr << "binarification..." << std::endl; - BufferWithRandomAccess buffer(options.debug); - WasmBinaryWriter writer(&wasm, buffer, options.debug); - // if debug info is used, then we want to emit the names section - writer.setNamesSection(debugInfo); - std::unique_ptr<std::ofstream> sourceMapStream = nullptr; + if (options.debug) std::cerr << "writing..." << std::endl; + ModuleWriter writer; + writer.setBinary(true); + writer.setDebugInfo(debugInfo); if (sourceMapFilename.size()) { - sourceMapStream = make_unique<std::ofstream>(); - sourceMapStream->open(sourceMapFilename); - writer.setSourceMap(sourceMapStream.get(), sourceMapUrl); + writer.setSourceMapFilename(sourceMapFilename); + writer.setSourceMapUrl(sourceMapUrl); } - if (symbolMap.size() > 0) writer.setSymbolMap(symbolMap); - writer.write(); - - if (options.debug) std::cerr << "writing to output..." << std::endl; - Output output(options.extra["output"], Flags::Binary, options.debug ? Flags::Debug : Flags::Release); - buffer.writeTo(output); - if (sourceMapStream) { - sourceMapStream->close(); + if (symbolMap.size() > 0) { + writer.setSymbolMap(symbolMap); } + writer.write(wasm, options.extra["output"]); if (options.debug) std::cerr << "Done." << std::endl; } |