diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-02-08 15:16:08 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-02-08 15:16:08 -0800 |
commit | d3bbf5a4ddd70940d22eb3f1690c2637d725e43e (patch) | |
tree | 80c4b64d3e2e605f5d062c8b52065b728f4c0c0c /src | |
parent | 2262204746437423211930d83d8ea336be3efac2 (diff) | |
parent | e9df05441f31bca550cc7f89935f10bf052b1464 (diff) | |
download | binaryen-d3bbf5a4ddd70940d22eb3f1690c2637d725e43e.tar.gz binaryen-d3bbf5a4ddd70940d22eb3f1690c2637d725e43e.tar.bz2 binaryen-d3bbf5a4ddd70940d22eb3f1690c2637d725e43e.zip |
Merge pull request #190 from WebAssembly/br_if-operand-order
Update binaryen and several tests for the new br_if operand order.
Diffstat (limited to 'src')
-rw-r--r-- | src/s2wasm.h | 8 | ||||
-rw-r--r-- | src/wasm-binary.h | 4 | ||||
-rw-r--r-- | src/wasm.h | 4 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h index 31b28f1e2..649b32196 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -952,12 +952,16 @@ class S2WasmBuilder { bstack.pop_back(); } else if (match("br")) { auto curr = allocator.alloc<Break>(); + bool hasCondition = false; if (*s == '_') { mustMatch("_if"); - curr->condition = getInput(); - skipComma(); + hasCondition = true; } curr->name = getBranchLabel(getInt()); + if (hasCondition) { + skipComma(); + curr->condition = getInput(); + } addToBlock(curr); } else if (match("call")) { makeCall(none); diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 440689ea0..2c884a4f5 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -663,12 +663,12 @@ assert(0); o << int8_t(curr->condition ? BinaryConsts::BrIf : BinaryConsts::Br); int offset = getBreakIndex(curr->name); o << int8_t(offset); - if (curr->condition) recurse(curr->condition); if (curr->value) { recurse(curr->value); } else { visitNop(nullptr); } + if (curr->condition) recurse(curr->condition); } void visitSwitch(Switch *curr) { if (debug) std::cerr << "zz node: Switch" << std::endl; @@ -1356,8 +1356,8 @@ public: if (debug) std::cerr << "zz node: Break" << std::endl; auto offset = getInt8(); curr->name = getBreakName(offset); - if (code == BinaryConsts::BrIf) readExpression(curr->condition); readExpression(curr->value); + if (code == BinaryConsts::BrIf) readExpression(curr->condition); } void visitSwitch(Switch *curr) { if (debug) std::cerr << "zz node: Switch" << std::endl; diff --git a/src/wasm.h b/src/wasm.h index 20a7b34ef..e30a891b9 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -501,13 +501,13 @@ public: class Break : public Expression { public: - Break() : Expression(BreakId), condition(nullptr), value(nullptr) { + Break() : Expression(BreakId), value(nullptr), condition(nullptr) { type = unreachable; } - Expression *condition; Name name; Expression *value; + Expression *condition; std::ostream& doPrint(std::ostream &o, unsigned indent) { if (condition) { |