Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/parser/contexts.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ struct NullTypeParserCtx {
BlockTypeT getBlockTypeFromResult(size_t results) { return Ok{}; }

Result<> getBlockTypeFromTypeUse(Index, TypeUseT) { return Ok{}; }

bool skipFunctionBody() { return false; }
};

template<typename Ctx> struct TypeParserCtx {
Expand Down Expand Up @@ -310,6 +312,8 @@ template<typename Ctx> struct TypeParserCtx {
assert(results.size() == 1);
return HeapType(Signature(Type::none, results[0]));
}

bool skipFunctionBody() { return false; }
};

struct NullInstrParserCtx {
Expand Down Expand Up @@ -1198,6 +1202,8 @@ struct ParseModuleTypesCtx : TypeParserCtx<ParseModuleTypesCtx>,
types(types), implicitTypes(implicitTypes),
implicitElemIndices(implicitElemIndices) {}

bool skipFunctionBody() { return true; }

Result<HeapTypeT> getHeapTypeFromIdx(Index idx) {
if (idx >= types.size()) {
return in.err("type index out of bounds");
Expand Down
8 changes: 5 additions & 3 deletions src/parser/parsers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3028,11 +3028,13 @@ template<typename Ctx> MaybeResult<> func(Ctx& ctx) {
CHECK_ERR(l);
localVars = *l;
}
CHECK_ERR(instrs(ctx));
ctx.setSrcLoc(ctx.in.takeAnnotations());
if (!ctx.skipFunctionBody()) {
CHECK_ERR(instrs(ctx));
ctx.setSrcLoc(ctx.in.takeAnnotations());
}
}

if (!ctx.in.takeRParen()) {
if (!ctx.skipFunctionBody() && !ctx.in.takeRParen()) {
return ctx.in.err("expected end of function");
}

Expand Down