summaryrefslogtreecommitdiff
path: root/src/passes/pass.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-02-27 14:04:45 -0800
committerGitHub <noreply@github.com>2018-02-27 14:04:45 -0800
commit89daa028fec6b627f1cbad3285b3176361f36e3d (patch)
tree7b3d4a596c6ce38a60f7617302439e23de40dc0e /src/passes/pass.cpp
parentde999c4673688e1b6f29a9a3023e1295fca33446 (diff)
downloadbinaryen-89daa028fec6b627f1cbad3285b3176361f36e3d.tar.gz
binaryen-89daa028fec6b627f1cbad3285b3176361f36e3d.tar.bz2
binaryen-89daa028fec6b627f1cbad3285b3176361f36e3d.zip
Flexible param numbers in asm2wasm (#1439)
* refactor BINARYEN_PASS_DEBUG code for writing byn-* files, make it easy to emit binaries instead of text * fix up bad argument numbers in asm2wasm. This can be caused by undefined behavior on the LLVM side, which happens to work natively. it's nicer to fix it up like it would be in a native build, and give a warning, instead of failing to compile * update build-js.sh * updated builds
Diffstat (limited to 'src/passes/pass.cpp')
-rw-r--r--src/passes/pass.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp
index c9fc7c40e..37c59f570 100644
--- a/src/passes/pass.cpp
+++ b/src/passes/pass.cpp
@@ -21,6 +21,7 @@
#include <passes/passes.h>
#include <pass.h>
#include <wasm-validator.h>
+#include <wasm-io.h>
namespace wasm {
@@ -193,13 +194,11 @@ void PassRunner::addDefaultGlobalOptimizationPostPasses() {
static void dumpWast(Name name, Module* wasm) {
// write out the wast
- Colors::disable();
static int counter = 0;
- std::stringstream text;
- WasmPrinter::printModule(wasm, text);
- FILE* f = fopen((std::string("byn-") + std::to_string(counter++) + "-" + name.str + ".wast").c_str(), "w");
- fputs(text.str().c_str(), f);
- fclose(f);
+ auto fullName = std::string("byn-") + std::to_string(counter++) + "-" + name.str + ".wasm";
+ ModuleWriter writer;
+ writer.setBinary(false); // TODO: add an option for binary
+ writer.write(*wasm, fullName);
}
void PassRunner::run() {