summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-04-25 14:04:59 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-04-25 14:04:59 -0700
commitef494cae68946b631abeba80ba6556f320475f0b (patch)
tree060f6f4d9906678436c7d0fa5a4d579da7f5fc62 /src
parent15c400329191072a59db433056fbdfcc12b67257 (diff)
downloadbinaryen-ef494cae68946b631abeba80ba6556f320475f0b.tar.gz
binaryen-ef494cae68946b631abeba80ba6556f320475f0b.tar.bz2
binaryen-ef494cae68946b631abeba80ba6556f320475f0b.zip
use arities on switch
Diffstat (limited to 'src')
-rw-r--r--src/wasm-binary.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 3fc1b3f01..bac525b76 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -851,11 +851,9 @@ public:
if (debug) std::cerr << "zz node: Switch" << std::endl;
if (curr->value) {
recurse(curr->value);
- } else {
- visitNop(nullptr);
}
recurse(curr->condition);
- o << int8_t(BinaryConsts::TableSwitch) << U32LEB(curr->targets.size());
+ o << int8_t(BinaryConsts::TableSwitch) << U32LEB(curr->value ? 1 : 0) << U32LEB(curr->targets.size());
for (auto target : curr->targets) {
o << uint32_t(getBreakIndex(target));
}
@@ -1734,8 +1732,10 @@ public:
}
void visitSwitch(Switch *curr) {
if (debug) std::cerr << "zz node: Switch" << std::endl;
+ auto arity = getU32LEB();
+ assert(arity == 0 || arity == 1);
curr->condition = popExpression();
- curr->value = popExpression();
+ if (arity == 1) curr->value = popExpression();
auto numTargets = getU32LEB();
for (size_t i = 0; i < numTargets; i++) {
curr->targets.push_back(getBreakName(getInt32()));