diff options
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r-- | src/wasm-binary.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 96927b10e..659e0f58b 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -1158,6 +1158,7 @@ class WasmBinaryWriter { std::unordered_map<Name, Index> globalIndexes; std::unordered_map<Name, Index> tableIndexes; std::unordered_map<Name, Index> elemIndexes; + std::unordered_map<Name, Index> dataIndexes; BinaryIndexes(Module& wasm) { auto addIndexes = [&](auto& source, auto& indexes) { @@ -1185,6 +1186,11 @@ class WasmBinaryWriter { elemIndexes[curr->name] = index; } + for (auto& curr : wasm.dataSegments) { + auto index = dataIndexes.size(); + dataIndexes[curr->name] = index; + } + // Globals may have tuple types in the IR, in which case they lower to // multiple globals, one for each tuple element, in the binary. Tuple // globals therefore occupy multiple binary indices, and we have to take @@ -1486,6 +1492,9 @@ public: // names std::vector<std::unique_ptr<ElementSegment>> elementSegments; + // we store data here after being read from binary, before we know their names + std::vector<std::unique_ptr<DataSegment>> dataSegments; + // we store globals here before wasm.addGlobal after we know their names std::vector<std::unique_ptr<Global>> globals; // we store global imports here before wasm.addGlobalImport after we know @@ -1590,7 +1599,7 @@ public: bool hasDataCount = false; void readDataSegments(); - void readDataCount(); + void readDataSegmentCount(); void readTableDeclarations(); void readElementSegments(); |