summaryrefslogtreecommitdiff
path: root/src/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm')
-rw-r--r--src/wasm/wasm-binary.cpp7
-rw-r--r--src/wasm/wasm-type.cpp9
2 files changed, 7 insertions, 9 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 9c8b83325..6ce2c7979 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -251,12 +251,11 @@ void WasmBinaryWriter::writeTypes() {
WASM_UNREACHABLE("TODO GC type writing");
}
if (nominal) {
- HeapType super;
- bool hasSuper = type.getSuperType(super);
- if (!hasSuper) {
+ auto super = type.getSuperType();
+ if (!super) {
super = type.isFunction() ? HeapType::func : HeapType::data;
}
- writeHeapType(super);
+ writeHeapType(*super);
}
}
finishSection(start);
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index 284a7e23b..94c6e96c6 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -1206,16 +1206,15 @@ Array HeapType::getArray() const {
return getHeapTypeInfo(*this)->array;
}
-bool HeapType::getSuperType(HeapType& out) const {
+std::optional<HeapType> HeapType::getSuperType() const {
if (isBasic()) {
- return false;
+ return {};
}
HeapTypeInfo* super = getHeapTypeInfo(*this)->supertype;
if (super != nullptr) {
- out = HeapType(uintptr_t(super));
- return true;
+ return HeapType(uintptr_t(super));
}
- return false;
+ return {};
}
bool HeapType::isNominal() const {