From aa3b46f7fd0699aa5ae0df5f83eee6e067c0c532 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 14 Jan 2016 11:52:47 -0800 Subject: break/switch fixes --- src/wasm-binary.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/wasm-binary.h') 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; -- cgit v1.2.3