diff options
author | Thomas Lively <tlively@google.com> | 2024-01-03 14:04:26 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-03 14:04:26 -0800 |
commit | 328bd7a7d6cce32e893c5839b95574f8a3d8bd9a (patch) | |
tree | bbf0cd57bb1940d7102dedc371b21df88d62ebc4 /src/parser | |
parent | c923521a61205dd2358201e311b009886e095381 (diff) | |
download | binaryen-328bd7a7d6cce32e893c5839b95574f8a3d8bd9a.tar.gz binaryen-328bd7a7d6cce32e893c5839b95574f8a3d8bd9a.tar.bz2 binaryen-328bd7a7d6cce32e893c5839b95574f8a3d8bd9a.zip |
[Parser] Parse br_on_cast{_fail} input annotations (#6198)
And validate in IRBuilder both that the input annotation is valid and that the
input matches it.
Diffstat (limited to 'src/parser')
-rw-r--r-- | src/parser/contexts.h | 12 | ||||
-rw-r--r-- | src/parser/parsers.h | 8 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 2565a4817..1cefb288d 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -443,7 +443,8 @@ struct NullInstrParserCtx { Result<> makeBrOn(Index, LabelIdxT, BrOnOp) { return Ok{}; } - template<typename TypeT> Result<> makeBrOn(Index, LabelIdxT, BrOnOp, TypeT) { + template<typename TypeT> + Result<> makeBrOn(Index, LabelIdxT, BrOnOp, TypeT, TypeT) { return Ok{}; } @@ -1690,9 +1691,12 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> { return withLoc(pos, irBuilder.makeRefCast(type)); } - Result<> - makeBrOn(Index pos, Index label, BrOnOp op, Type castType = Type::none) { - return withLoc(pos, irBuilder.makeBrOn(label, op, castType)); + Result<> makeBrOn(Index pos, + Index label, + BrOnOp op, + Type in = Type::none, + Type out = Type::none) { + return withLoc(pos, irBuilder.makeBrOn(label, op, in, out)); } Result<> makeStructNew(Index pos, HeapType type) { diff --git a/src/parser/parsers.h b/src/parser/parsers.h index 9302f4fc9..1d786f363 100644 --- a/src/parser/parsers.h +++ b/src/parser/parsers.h @@ -1594,9 +1594,11 @@ template<typename Ctx> Result<> makeBrOnNull(Ctx& ctx, Index pos, bool onFail) { template<typename Ctx> Result<> makeBrOnCast(Ctx& ctx, Index pos, bool onFail) { auto label = labelidx(ctx); CHECK_ERR(label); - auto type = reftype(ctx); - CHECK_ERR(type); - return ctx.makeBrOn(pos, *label, onFail ? BrOnCastFail : BrOnCast, *type); + auto in = reftype(ctx); + CHECK_ERR(in); + auto out = reftype(ctx); + CHECK_ERR(out); + return ctx.makeBrOn(pos, *label, onFail ? BrOnCastFail : BrOnCast, *in, *out); } template<typename Ctx> |