From bdd96e8c21d23a57a99dcca9d4d802ff471243c3 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 14 Dec 2023 10:27:53 -0800 Subject: [Parser] Parse explicit exports (#6179) --- src/parser/contexts.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/parser/contexts.h') diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 3ed455043..e09f8bbd0 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -548,6 +548,9 @@ struct ParseDeclsCtx : NullTypeParserCtx, NullInstrParserCtx { std::vector dataDefs; std::vector tagDefs; + // Positions of export definitions. + std::vector exportDefs; + // Positions of typeuses that might implicitly define new types. std::vector implicitTypeDefs; @@ -684,6 +687,11 @@ struct ParseDeclsCtx : NullTypeParserCtx, NullInstrParserCtx { ImportNames* import, TypeUseT type, Index pos); + + Result<> addExport(Index pos, Ok, Name, ExternalKind) { + exportDefs.push_back(pos); + return Ok{}; + } }; // Phase 2: Parse type definitions into a TypeBuilder. @@ -1265,6 +1273,11 @@ struct ParseDefsCtx : TypeParserCtx { Result<> addData(Name, Name* mem, std::optional offset, DataStringT, Index pos); + Result<> addExport(Index, Name value, Name name, ExternalKind kind) { + wasm.addExport(builder.makeExport(name, value, kind)); + return Ok{}; + } + Result addScratchLocal(Index pos, Type type) { if (!func) { return in.err(pos, -- cgit v1.2.3