diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-01-14 11:52:47 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-01-14 11:52:47 -0800 |
commit | aa3b46f7fd0699aa5ae0df5f83eee6e067c0c532 (patch) | |
tree | 4cd7a69a1c63076f2c0ed8db1c25f16e8581c3f8 | |
parent | db7285b8f8e1a536fdfee60103bafc4ecfe3ed1f (diff) | |
download | binaryen-aa3b46f7fd0699aa5ae0df5f83eee6e067c0c532.tar.gz binaryen-aa3b46f7fd0699aa5ae0df5f83eee6e067c0c532.tar.bz2 binaryen-aa3b46f7fd0699aa5ae0df5f83eee6e067c0c532.zip |
break/switch fixes
-rw-r--r-- | src/wasm-binary.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 16b9419e5..2fad499fe 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -601,7 +601,10 @@ public: break; } } - assert(found); + if (!found) { + std::cerr << "bad break: " << curr->name << std::endl; + abort(); + } if (curr->condition) recurse(curr->condition); } void visitSwitch(Switch *curr) { @@ -615,10 +618,12 @@ public: for (auto target : curr->targets) { o << mapping[target]; } + breakStack.push_back(curr->name); recurse(curr->value); for (auto c : curr->cases) { recurse(c.body); } + breakStack.pop_back(); } void visitCall(Call *curr) { if (debug) std::cerr << "zz node: Call" << std::endl; @@ -1270,6 +1275,8 @@ public: for (auto i = 0; i < numTargets; i++) { curr->targets.push_back(getCaseLabel(getInt16())); } + curr->name = getNextLabel(); + breakStack.push_back(curr->name); readExpression(curr->value); for (auto i = 0; i < numCases; i++) { Switch::Case c; @@ -1277,6 +1284,7 @@ public: readExpression(c.body); curr->cases.push_back(c); } + breakStack.pop_back(); } void visitCall(Call *curr, Name target) { if (debug) std::cerr << "zz node: Call" << std::endl; |