diff options
Diffstat (limited to 'src/parser/contexts.h')
-rw-r--r-- | src/parser/contexts.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 210945e8d..dae938f7f 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -312,7 +312,12 @@ struct NullInstrParserCtx { InstrT makeBlock(Index, std::optional<Name>, BlockTypeT) { return Ok{}; } - InstrT finishBlock(Index, InstrsT) { return Ok{}; } + template<typename BlockTypeT> + InstrT makeIf(Index, std::optional<Name>, BlockTypeT) { + return Ok{}; + } + InstrT visitEnd(Index, InstrsT) { return Ok{}; } + InstrT visitElse(Index) { return Ok{}; } InstrT makeUnreachable(Index) { return Ok{}; } InstrT makeNop(Index) { return Ok{}; } @@ -994,10 +999,20 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> { type.getSignature().results)); } - Result<> finishBlock(Index pos, InstrsT) { + Result<> makeIf(Index pos, std::optional<Name> label, HeapType type) { + // TODO: validate labels? + // TODO: Move error on input types to here? + return withLoc( + pos, + irBuilder.makeIf(label ? *label : Name{}, type.getSignature().results)); + } + + Result<> visitEnd(Index pos, InstrsT) { return withLoc(pos, irBuilder.visitEnd()); } + Result<> visitElse(Index pos) { return withLoc(pos, irBuilder.visitElse()); } + Result<> makeUnreachable(Index pos) { return withLoc(pos, irBuilder.makeUnreachable()); } |