summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-03-18 14:09:15 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-03-18 14:09:15 -0700
commitcd87eb847378d038342a8e9b73960e74352d29ed (patch)
treee1a04607c372006c5daa78e6c750d7b57d4196a2
parenta3312f5f2390bf3fe515c99d29d22dff201eeaf9 (diff)
parentac74a808876a27f44a0eb66cef7cb441be1c2017 (diff)
downloadbinaryen-cd87eb847378d038342a8e9b73960e74352d29ed.tar.gz
binaryen-cd87eb847378d038342a8e9b73960e74352d29ed.tar.bz2
binaryen-cd87eb847378d038342a8e9b73960e74352d29ed.zip
Merge pull request #256 from WebAssembly/debug
Make --debug a boolean
-rw-r--r--src/asm2wasm.h12
-rw-r--r--src/support/command-line.cpp8
-rw-r--r--src/support/command-line.h2
3 files changed, 9 insertions, 13 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index c4f73b57a..2d024665e 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -150,7 +150,7 @@ class Asm2WasmBuilder {
std::map<CallIndirect*, IString> callIndirects; // track these, as we need to fix them after we know the functionTableStarts. this maps call => its function table
bool memoryGrowth;
- int debug;
+ bool debug;
public:
std::map<IString, MappedGlobal> mappedGlobals;
@@ -254,7 +254,7 @@ private:
}
public:
- Asm2WasmBuilder(AllocatingModule& wasm, bool memoryGrowth, int debug)
+ Asm2WasmBuilder(AllocatingModule& wasm, bool memoryGrowth, bool debug)
: wasm(wasm),
allocator(wasm.allocator),
nextGlobal(8),
@@ -729,10 +729,8 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
if (debug) {
std::cout << "\nfunc: " << ast[1]->getIString().str << '\n';
- if (debug >= 2) {
- ast->stringify(std::cout);
- std::cout << '\n';
- }
+ ast->stringify(std::cout);
+ std::cout << '\n';
}
auto function = allocator.alloc<Function>();
@@ -802,7 +800,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
std::function<Expression* (Ref)> process = [&](Ref ast) -> Expression* {
AstStackHelper astStackHelper(ast); // TODO: only create one when we need it?
- if (debug >= 2) {
+ if (debug) {
std::cout << "at: ";
ast->stringify(std::cout);
std::cout << '\n';
diff --git a/src/support/command-line.cpp b/src/support/command-line.cpp
index b4f8a4d62..f3aa4dc08 100644
--- a/src/support/command-line.cpp
+++ b/src/support/command-line.cpp
@@ -19,7 +19,7 @@
using namespace wasm;
Options::Options(const std::string &command, const std::string &description)
- : debug(0), positional(Arguments::Zero) {
+ : debug(false), positional(Arguments::Zero) {
add("--help", "-h", "Show this help message and exit", Arguments::Zero,
[this, command, description](Options *o, const std::string &) {
std::cerr << command;
@@ -41,10 +41,8 @@ Options::Options(const std::string &command, const std::string &description)
std::cerr << '\n';
exit(EXIT_SUCCESS);
});
- add("--debug", "-d", "Print debug information to stderr", Arguments::Optional,
- [](Options *o, const std::string &arguments) {
- o->debug = arguments.size() ? std::stoi(arguments) : 1;
- });
+ add("--debug", "-d", "Print debug information to stderr", Arguments::Zero,
+ [](Options *o, const std::string &arguments) {});
}
Options::~Options() {}
diff --git a/src/support/command-line.h b/src/support/command-line.h
index 6e0af846e..7c3ae528f 100644
--- a/src/support/command-line.h
+++ b/src/support/command-line.h
@@ -37,7 +37,7 @@ class Options {
typedef std::function<void(Options *, const std::string &)> Action;
enum class Arguments { Zero, One, N, Optional };
- int debug;
+ bool debug;
std::map<std::string, std::string> extra;
Options(const std::string &command, const std::string &description);