summaryrefslogtreecommitdiff
path: root/src/wasm/wasm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r--src/wasm/wasm.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 92e03f579..ef8cfb2f7 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -70,6 +70,9 @@ Name EXPORT("export");
Name IMPORT("import");
Name TABLE("table");
Name ELEM("elem");
+Name DECLARE("declare");
+Name OFFSET("offset");
+Name ITEM("item");
Name LOCAL("local");
Name TYPE("type");
Name REF("ref");
@@ -802,12 +805,9 @@ void MemoryGrow::finalize() {
void RefNull::finalize(HeapType heapType) { type = Type(heapType, Nullable); }
-void RefNull::finalize(Type type_) {
- type = type_;
-}
+void RefNull::finalize(Type type_) { type = type_; }
-void RefNull::finalize() {
-}
+void RefNull::finalize() {}
void RefIs::finalize() {
if (value->type == Type::unreachable) {
@@ -1169,6 +1169,10 @@ Table* Module::getTable(Name name) {
return getModuleElement(tablesMap, name, "getTable");
}
+ElementSegment* Module::getElementSegment(Name name) {
+ return getModuleElement(elementSegmentsMap, name, "getElementSegment");
+}
+
Global* Module::getGlobal(Name name) {
return getModuleElement(globalsMap, name, "getGlobal");
}
@@ -1198,6 +1202,10 @@ Table* Module::getTableOrNull(Name name) {
return getModuleElementOrNull(tablesMap, name);
}
+ElementSegment* Module::getElementSegmentOrNull(Name name) {
+ return getModuleElementOrNull(elementSegmentsMap, name);
+}
+
Global* Module::getGlobalOrNull(Name name) {
return getModuleElementOrNull(globalsMap, name);
}
@@ -1267,6 +1275,12 @@ Table* Module::addTable(std::unique_ptr<Table>&& curr) {
return addModuleElement(tables, tablesMap, std::move(curr), "addTable");
}
+ElementSegment*
+Module::addElementSegment(std::unique_ptr<ElementSegment>&& curr) {
+ return addModuleElement(
+ elementSegments, elementSegmentsMap, std::move(curr), "addElementSegment");
+}
+
Global* Module::addGlobal(std::unique_ptr<Global>&& curr) {
return addModuleElement(globals, globalsMap, std::move(curr), "addGlobal");
}
@@ -1297,6 +1311,9 @@ void Module::removeFunction(Name name) {
void Module::removeTable(Name name) {
removeModuleElement(tables, tablesMap, name);
}
+void Module::removeElementSegment(Name name) {
+ removeModuleElement(elementSegments, elementSegmentsMap, name);
+}
void Module::removeGlobal(Name name) {
removeModuleElement(globals, globalsMap, name);
}
@@ -1329,6 +1346,9 @@ void Module::removeFunctions(std::function<bool(Function*)> pred) {
void Module::removeTables(std::function<bool(Table*)> pred) {
removeModuleElements(tables, tablesMap, pred);
}
+void Module::removeElementSegments(std::function<bool(ElementSegment*)> pred) {
+ removeModuleElements(elementSegments, elementSegmentsMap, pred);
+}
void Module::removeGlobals(std::function<bool(Global*)> pred) {
removeModuleElements(globals, globalsMap, pred);
}
@@ -1349,6 +1369,10 @@ void Module::updateMaps() {
for (auto& curr : tables) {
tablesMap[curr->name] = curr.get();
}
+ elementSegmentsMap.clear();
+ for (auto& curr : elementSegments) {
+ elementSegmentsMap[curr->name] = curr.get();
+ }
globalsMap.clear();
for (auto& curr : globals) {
globalsMap[curr->name] = curr.get();