summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 55f85b4b5..e6b33dbb0 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -1271,6 +1271,7 @@ void WasmBinaryBuilder::readExports() {
curr->kind = (ExternalKind)getU32LEB();
auto index = getU32LEB();
exportIndexes[curr] = index;
+ exportOrder.push_back(curr);
}
}
@@ -1372,16 +1373,16 @@ void WasmBinaryBuilder::processFunctions() {
wasm.start = getFunctionIndexName(startIndex);
}
- for (auto& iter : exportIndexes) {
- Export* curr = iter.first;
+ for (auto* curr : exportOrder) {
+ auto index = exportIndexes[curr];
switch (curr->kind) {
case ExternalKind::Function: {
- curr->value = getFunctionIndexName(iter.second);
+ curr->value = getFunctionIndexName(index);
break;
}
case ExternalKind::Table: curr->value = Name::fromInt(0); break;
case ExternalKind::Memory: curr->value = Name::fromInt(0); break;
- case ExternalKind::Global: curr->value = getGlobalName(iter.second); break;
+ case ExternalKind::Global: curr->value = getGlobalName(index); break;
default: WASM_UNREACHABLE();
}
wasm.addExport(curr);