summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-04-25 13:56:47 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-04-25 13:56:47 -0700
commitcb417c68cd75e01b9eaef7bb9d06c38c3068e19b (patch)
tree75e0ab8fb53f2c28c13fee21ad204dde907653fa /src
parent27ef6de772ca90824018819b91b8a230136f56c3 (diff)
downloadbinaryen-cb417c68cd75e01b9eaef7bb9d06c38c3068e19b.tar.gz
binaryen-cb417c68cd75e01b9eaef7bb9d06c38c3068e19b.tar.bz2
binaryen-cb417c68cd75e01b9eaef7bb9d06c38c3068e19b.zip
use arities on breaks
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 954521365..decac5564 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -842,12 +842,10 @@ public:
if (debug) std::cerr << "zz node: Break" << std::endl;
if (curr->value) {
recurse(curr->value);
- } else {
- visitNop(nullptr);
}
if (curr->condition) recurse(curr->condition);
o << int8_t(curr->condition ? BinaryConsts::BrIf : BinaryConsts::Br)
- << U32LEB(getBreakIndex(curr->name));
+ << U32LEB(curr->value ? 1 : 0) << U32LEB(getBreakIndex(curr->name));
}
void visitSwitch(Switch *curr) {
if (debug) std::cerr << "zz node: Switch" << std::endl;
@@ -1730,9 +1728,11 @@ public:
void visitBreak(Break *curr, uint8_t code) {
if (debug) std::cerr << "zz node: Break" << std::endl;
+ auto arity = getU32LEB();
+ assert(arity == 0 || arity == 1);
curr->name = getBreakName(getU32LEB());
if (code == BinaryConsts::BrIf) curr->condition = popExpression();
- curr->value = popExpression();
+ if (arity == 1) curr->value = popExpression();
}
void visitSwitch(Switch *curr) {
if (debug) std::cerr << "zz node: Switch" << std::endl;