diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-29 17:55:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-29 17:55:28 +0200 |
commit | fa4c884f4ebfde185c9d8a3ee4e54f96c57cebed (patch) | |
tree | a41f45f78f42dd7b532d6303fc71ec76ddbdf76d /src/wasm-binary.h | |
parent | e9e5f30212f44927859d3dad5fe48499d860f61c (diff) | |
download | binaryen-fa4c884f4ebfde185c9d8a3ee4e54f96c57cebed.tar.gz binaryen-fa4c884f4ebfde185c9d8a3ee4e54f96c57cebed.tar.bz2 binaryen-fa4c884f4ebfde185c9d8a3ee4e54f96c57cebed.zip |
Prototype extended-name-section proposal (#3162)
Implements the parts of the Extended Name Section Proposal that are trivially applicable to Binaryen, in particular table, memory and global names. Does not yet implement label, type, elem and data names.
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r-- | src/wasm-binary.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 9ac5664d3..c869adf06 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -393,6 +393,14 @@ enum Subsection { NameModule = 0, NameFunction = 1, NameLocal = 2, + // see: https://github.com/WebAssembly/extended-name-section + NameLabel = 3, + NameType = 4, + NameTable = 5, + NameMemory = 6, + NameGlobal = 7, + NameElem = 8, + NameData = 9 }; } // namespace UserSections @@ -1299,8 +1307,8 @@ public: Name getNextLabel(); - // We read functions before we know their names, so we need to backpatch the - // names later + // We read functions and globals before we know their names, so we need to + // backpatch the names later // we store functions here before wasm.addFunction after we know their names std::vector<Function*> functions; @@ -1314,6 +1322,14 @@ public: // function to check Index endOfFunction = -1; + // we store globals here before wasm.addGlobal after we know their names + std::vector<Global*> globals; + // we store global imports here before wasm.addGlobalImport after we know + // their names + std::vector<Global*> globalImports; + // at index i we have all refs to the global i + std::map<Index, std::vector<Expression*>> globalRefs; + // Throws a parsing error if we are not in a function context void requireFunctionContext(const char* error); @@ -1382,7 +1398,7 @@ public: Expression* popTypedExpression(Type type); void validateBinary(); // validations that cannot be performed on the Module - void processFunctions(); + void processNames(); size_t dataCount = 0; bool hasDataCount = false; |