summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm/wasm-type.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index f98077961..5e4d5e07f 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -383,15 +383,28 @@ bool Type::isRtt() const {
}
bool Type::operator<(const Type& other) const {
- return std::lexicographical_compare(begin(),
- end(),
- other.begin(),
- other.end(),
- [](const Type& a, const Type& b) {
- TODO_SINGLE_COMPOUND(a);
- TODO_SINGLE_COMPOUND(b);
- return a.getBasic() < b.getBasic();
- });
+ auto comp = [](const Type& a, const Type& b) {
+ if (a.isBasic() && b.isBasic()) {
+ return a.getBasic() < b.getBasic();
+ }
+ if (a.isBasic()) {
+ return true;
+ }
+ if (b.isBasic()) {
+ return false;
+ }
+ // Both are compound.
+ auto aHeap = a.getHeapType();
+ auto bHeap = b.getHeapType();
+ if (aHeap.isSignature() && bHeap.isSignature()) {
+ return aHeap.getSignature() < bHeap.getSignature();
+ }
+ TODO_SINGLE_COMPOUND(a);
+ TODO_SINGLE_COMPOUND(b);
+ WASM_UNREACHABLE("unimplemented type comparison");
+ };
+ return std::lexicographical_compare(
+ begin(), end(), other.begin(), other.end(), comp);
}
unsigned Type::getByteSize() const {