diff options
author | Thomas Lively <tlively@google.com> | 2024-02-09 15:42:43 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-09 15:42:43 -0800 |
commit | 7e20a3b1bdc1a3d26b13c2597d0286c79851e9ac (patch) | |
tree | 13fdf3350ee496ba9b944a457fa70a8900cf6eb3 /src/parser/parsers.h | |
parent | 90087f0972aa34ee37860b70072cb8fc33c89ce3 (diff) | |
download | binaryen-7e20a3b1bdc1a3d26b13c2597d0286c79851e9ac.tar.gz binaryen-7e20a3b1bdc1a3d26b13c2597d0286c79851e9ac.tar.bz2 binaryen-7e20a3b1bdc1a3d26b13c2597d0286c79851e9ac.zip |
[Parser] Parse `resume` (#6295)
Diffstat (limited to 'src/parser/parsers.h')
-rw-r--r-- | src/parser/parsers.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/parser/parsers.h b/src/parser/parsers.h index db4c716f1..960ccb26d 100644 --- a/src/parser/parsers.h +++ b/src/parser/parsers.h @@ -1228,7 +1228,7 @@ template<typename Ctx> MaybeResult<typename Ctx::CatchT> catchinstr(Ctx& ctx) { return result; } -// trytable ::= 'try_table' label blocktype catchinstr* instr* end id? +// trytable ::= 'try_table' label blocktype catchinstr* instr* 'end' id? // | '(' 'try_table' label blocktype catchinstr* instr* ')' template<typename Ctx> MaybeResult<> trytable(Ctx& ctx, bool folded) { auto pos = ctx.in.getPos(); @@ -1992,8 +1992,24 @@ template<typename Ctx> Result<> makeStringSliceIter(Ctx& ctx, Index pos) { return ctx.makeStringSliceIter(pos); } +// resume ::= 'resume' typeidx ('(' 'tag' tagidx labelidx ')')* template<typename Ctx> Result<> makeResume(Ctx& ctx, Index pos) { - return ctx.in.err("unimplemented instruction"); + auto type = typeidx(ctx); + CHECK_ERR(type); + + auto tagLabels = ctx.makeTagLabelList(); + while (ctx.in.takeSExprStart("tag"sv)) { + auto tag = tagidx(ctx); + CHECK_ERR(tag); + auto label = labelidx(ctx); + CHECK_ERR(label); + ctx.appendTagLabel(tagLabels, *tag, *label); + if (!ctx.in.takeRParen()) { + return ctx.in.err("expected ')' at end of handler clause"); + } + } + + return ctx.makeResume(pos, *type, tagLabels); } // ======= |