summaryrefslogtreecommitdiff
path: root/src/wasm-binary.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-01-14 11:52:47 -0800
committerAlon Zakai <alonzakai@gmail.com>2016-01-14 11:52:47 -0800
commitaa3b46f7fd0699aa5ae0df5f83eee6e067c0c532 (patch)
tree4cd7a69a1c63076f2c0ed8db1c25f16e8581c3f8 /src/wasm-binary.h
parentdb7285b8f8e1a536fdfee60103bafc4ecfe3ed1f (diff)
downloadbinaryen-aa3b46f7fd0699aa5ae0df5f83eee6e067c0c532.tar.gz
binaryen-aa3b46f7fd0699aa5ae0df5f83eee6e067c0c532.tar.bz2
binaryen-aa3b46f7fd0699aa5ae0df5f83eee6e067c0c532.zip
break/switch fixes
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r--src/wasm-binary.h10
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;