diff options
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 9cf2f3be9..3075f70d7 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -2130,18 +2130,21 @@ Expression* SExpressionWasmBuilder::makeRefCast(Element& s) { return Builder(wasm).makeRefCast(ref, rtt); } -Expression* SExpressionWasmBuilder::makeBrOnCast(Element& s) { +Expression* SExpressionWasmBuilder::makeBrOn(Element& s, BrOnOp op) { auto name = getLabel(*s[1]); auto* ref = parseExpression(*s[2]); - auto* rtt = parseExpression(*s[3]); + Expression* rtt = nullptr; Builder builder(wasm); - if (rtt->type == Type::unreachable) { - // An unreachable rtt is not supported: the text format does not provide the - // type, so if it's unreachable we should not even create a br_on_cast in - // such a case, as we'd have no idea what it casts to. - return builder.makeSequence(builder.makeDrop(ref), rtt); + if (op == BrOnCast) { + rtt = parseExpression(*s[3]); + if (rtt->type == Type::unreachable) { + // An unreachable rtt is not supported: the text format does not provide + // the type, so if it's unreachable we should not even create a br_on_cast + // in such a case, as we'd have no idea what it casts to. + return builder.makeSequence(builder.makeDrop(ref), rtt); + } } - return builder.makeBrOnCast(name, ref, rtt); + return builder.makeBrOn(op, name, ref, rtt); } Expression* SExpressionWasmBuilder::makeRttCanon(Element& s) { |