summaryrefslogtreecommitdiff
path: root/src/parser/parsers.h
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-11-15 01:41:37 +0100
committerGitHub <noreply@github.com>2023-11-15 01:41:37 +0100
commit8eb4899d8dafe02c0440c5e33aaf37529e8fc941 (patch)
tree61aa3a6a7de63ce0b79253788c30b0e2c52d630c /src/parser/parsers.h
parent9846aaba1e4c4071c496000f4fa9ead3d1d107a5 (diff)
downloadbinaryen-8eb4899d8dafe02c0440c5e33aaf37529e8fc941.tar.gz
binaryen-8eb4899d8dafe02c0440c5e33aaf37529e8fc941.tar.bz2
binaryen-8eb4899d8dafe02c0440c5e33aaf37529e8fc941.zip
[Parser] Parse br_table (#6098)
Diffstat (limited to 'src/parser/parsers.h')
-rw-r--r--src/parser/parsers.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/parser/parsers.h b/src/parser/parsers.h
index eb93fa717..0641e941c 100644
--- a/src/parser/parsers.h
+++ b/src/parser/parsers.h
@@ -1200,7 +1200,20 @@ template<typename Ctx> Result<> makeBreak(Ctx& ctx, Index pos) {
}
template<typename Ctx> Result<> makeBreakTable(Ctx& ctx, Index pos) {
- return ctx.in.err("unimplemented instruction");
+ std::vector<typename Ctx::LabelIdxT> labels;
+ while (true) {
+ // Parse at least one label; return an error only if we parse none.
+ auto label = labelidx(ctx);
+ if (labels.empty()) {
+ CHECK_ERR(label);
+ } else if (label.getErr()) {
+ break;
+ }
+ labels.push_back(*label);
+ }
+ auto defaultLabel = labels.back();
+ labels.pop_back();
+ return ctx.makeSwitch(pos, labels, defaultLabel);
}
template<typename Ctx> Result<> makeReturn(Ctx& ctx, Index pos) {