summaryrefslogtreecommitdiff
path: root/src/wasm-binary.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-04-21 16:06:47 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-04-21 16:06:47 -0700
commit10766f949b05379f543ed1f2f4e148fdc9e9ea96 (patch)
treed643c36abb943673125ea4f9c697d98b9d2e309d /src/wasm-binary.h
parent07c4e7b75f91e1d332a33073838098e23befe8c4 (diff)
downloadbinaryen-10766f949b05379f543ed1f2f4e148fdc9e9ea96.tar.gz
binaryen-10766f949b05379f543ed1f2f4e148fdc9e9ea96.tar.bz2
binaryen-10766f949b05379f543ed1f2f4e148fdc9e9ea96.zip
update br_table in binary format
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r--src/wasm-binary.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 8e9faa15a..fad98386d 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -847,19 +847,17 @@ public:
}
void visitSwitch(Switch *curr) {
if (debug) std::cerr << "zz node: Switch" << std::endl;
- o << int8_t(BinaryConsts::TableSwitch) << U32LEB(curr->targets.size());
- for (auto target : curr->targets) {
- o << U32LEB(getBreakIndex(target));
- }
- o << U32LEB(getBreakIndex(curr->default_));
- recurse(curr->condition);
- o << int8_t(BinaryConsts::End); // XXX
if (curr->value) {
recurse(curr->value);
} else {
visitNop(nullptr);
}
- o << int8_t(BinaryConsts::End); // XXX
+ recurse(curr->condition);
+ o << int8_t(BinaryConsts::TableSwitch) << U32LEB(curr->targets.size());
+ for (auto target : curr->targets) {
+ o << U32LEB(getBreakIndex(target));
+ }
+ o << U32LEB(getBreakIndex(curr->default_));
}
void visitCall(Call *curr) {
if (debug) std::cerr << "zz node: Call" << std::endl;
@@ -1714,16 +1712,13 @@ public:
}
void visitSwitch(Switch *curr) {
if (debug) std::cerr << "zz node: Switch" << std::endl;
+ curr->condition = popExpression();
+ curr->value = popExpression();
auto numTargets = getU32LEB();
for (size_t i = 0; i < numTargets; i++) {
curr->targets.push_back(getBreakName(getU32LEB()));
}
curr->default_ = getBreakName(getU32LEB());
- processExpressions();
- curr->condition = popExpression();
- processExpressions();
- curr->value = popExpression();
- if (curr->value->is<Nop>()) curr->value = nullptr;
}
void visitCall(Call *curr) {
if (debug) std::cerr << "zz node: Call" << std::endl;