diff options
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r-- | src/wasm/wasm.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 1c9c1389d..574eb5c47 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -1336,6 +1336,10 @@ ElementSegment* Module::getElementSegment(Name name) { return getModuleElement(elementSegmentsMap, name, "getElementSegment"); } +Memory* Module::getMemory(Name name) { + return getModuleElement(memoriesMap, name, "getMemory"); +} + DataSegment* Module::getDataSegment(Name name) { return getModuleElement(dataSegmentsMap, name, "getDataSegment"); } @@ -1373,6 +1377,10 @@ ElementSegment* Module::getElementSegmentOrNull(Name name) { return getModuleElementOrNull(elementSegmentsMap, name); } +Memory* Module::getMemoryOrNull(Name name) { + return getModuleElementOrNull(memoriesMap, name); +} + DataSegment* Module::getDataSegmentOrNull(Name name) { return getModuleElementOrNull(dataSegmentsMap, name); } @@ -1452,6 +1460,10 @@ Module::addElementSegment(std::unique_ptr<ElementSegment>&& curr) { elementSegments, elementSegmentsMap, std::move(curr), "addElementSegment"); } +Memory* Module::addMemory(std::unique_ptr<Memory>&& curr) { + return addModuleElement(memories, memoriesMap, std::move(curr), "addMemory"); +} + DataSegment* Module::addDataSegment(std::unique_ptr<DataSegment>&& curr) { return addModuleElement( dataSegments, dataSegmentsMap, std::move(curr), "addDataSegment"); @@ -1490,6 +1502,9 @@ void Module::removeTable(Name name) { void Module::removeElementSegment(Name name) { removeModuleElement(elementSegments, elementSegmentsMap, name); } +void Module::removeMemory(Name name) { + removeModuleElement(memories, memoriesMap, name); +} void Module::removeDataSegment(Name name) { removeModuleElement(dataSegments, dataSegmentsMap, name); } @@ -1526,6 +1541,9 @@ void Module::removeTables(std::function<bool(Table*)> pred) { void Module::removeElementSegments(std::function<bool(ElementSegment*)> pred) { removeModuleElements(elementSegments, elementSegmentsMap, pred); } +void Module::removeMemories(std::function<bool(Memory*)> pred) { + removeModuleElements(memories, memoriesMap, pred); +} void Module::removeDataSegments(std::function<bool(DataSegment*)> pred) { removeModuleElements(dataSegments, dataSegmentsMap, pred); } @@ -1536,6 +1554,13 @@ void Module::removeTags(std::function<bool(Tag*)> pred) { removeModuleElements(tags, tagsMap, pred); } +void Module::updateDataSegmentsMap() { + dataSegmentsMap.clear(); + for (auto& curr : dataSegments) { + dataSegmentsMap[curr->name] = curr.get(); + } +} + void Module::updateMaps() { functionsMap.clear(); for (auto& curr : functions) { @@ -1553,10 +1578,11 @@ void Module::updateMaps() { for (auto& curr : elementSegments) { elementSegmentsMap[curr->name] = curr.get(); } - dataSegmentsMap.clear(); - for (auto& curr : dataSegments) { - dataSegmentsMap[curr->name] = curr.get(); + memoriesMap.clear(); + for (auto& curr : memories) { + memoriesMap[curr->name] = curr.get(); } + updateDataSegmentsMap(); globalsMap.clear(); for (auto& curr : globals) { globalsMap[curr->name] = curr.get(); |