summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 4e9ebcc45..df01a18d8 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -843,6 +843,18 @@ void SExpressionWasmBuilder::preParseHeapTypes(Element& module) {
});
types = builder.build();
+
+ for (auto& pair : typeIndices) {
+ auto name = pair.first;
+ auto type = types[pair.second];
+ // A type may appear in the type section more than once, but we canonicalize
+ // types internally, so there will be a single name chosen for that type. Do
+ // so determistically.
+ if (wasm.typeNames.count(type) && wasm.typeNames[type].name.str < name) {
+ continue;
+ }
+ wasm.typeNames[type].name = name;
+ }
}
void SExpressionWasmBuilder::preParseFunctionType(Element& s) {