diff options
author | Thomas Lively <tlively@google.com> | 2023-12-14 10:27:53 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-14 10:27:53 -0800 |
commit | bdd96e8c21d23a57a99dcca9d4d802ff471243c3 (patch) | |
tree | bca67e3db39d12835263086ac200f44a658ee3a4 /src/parser/contexts.h | |
parent | 7adc82b5da6ad2b36d2f335af6619601ccc8e36b (diff) | |
download | binaryen-bdd96e8c21d23a57a99dcca9d4d802ff471243c3.tar.gz binaryen-bdd96e8c21d23a57a99dcca9d4d802ff471243c3.tar.bz2 binaryen-bdd96e8c21d23a57a99dcca9d4d802ff471243c3.zip |
[Parser] Parse explicit exports (#6179)
Diffstat (limited to 'src/parser/contexts.h')
-rw-r--r-- | src/parser/contexts.h | 13 |
1 files changed, 13 insertions, 0 deletions
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<DefPos> dataDefs; std::vector<DefPos> tagDefs; + // Positions of export definitions. + std::vector<Index> exportDefs; + // Positions of typeuses that might implicitly define new types. std::vector<Index> 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<ParseDefsCtx> { Result<> addData(Name, Name* mem, std::optional<ExprT> offset, DataStringT, Index pos); + Result<> addExport(Index, Name value, Name name, ExternalKind kind) { + wasm.addExport(builder.makeExport(name, value, kind)); + return Ok{}; + } + Result<Index> addScratchLocal(Index pos, Type type) { if (!func) { return in.err(pos, |