summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passes/Print.cpp16
-rw-r--r--src/wasm/wasm-type.cpp18
2 files changed, 33 insertions, 1 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index c9ef1a224..70e32e5d7 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -274,6 +274,22 @@ static std::ostream& printType(std::ostream& o, Type type, Module* wasm) {
TypeNamePrinter(o, wasm).print(rtt.heapType);
o << ')';
} else if (type.isRef() && !type.isBasic()) {
+ auto heapType = type.getHeapType();
+ if (type.isNullable() && heapType.isBasic()) {
+ // Print shorthands for certain nullable basic heap types.
+ switch (heapType.getBasic()) {
+ case HeapType::string:
+ return o << "stringref";
+ case HeapType::stringview_wtf8:
+ return o << "stringview_wtf8";
+ case HeapType::stringview_wtf16:
+ return o << "stringview_wtf16";
+ case HeapType::stringview_iter:
+ return o << "stringview_iter";
+ default:
+ break;
+ }
+ }
o << "(ref ";
if (type.isNullable()) {
o << "null ";
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index b79080121..85f3f0cfc 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -2103,11 +2103,27 @@ std::ostream& TypePrinter::print(Type type) {
if (type.isTuple()) {
print(type.getTuple());
} else if (type.isRef()) {
+ auto heapType = type.getHeapType();
+ if (type.isNullable() && heapType.isBasic()) {
+ // Print shorthands for certain nullable basic heap types.
+ switch (heapType.getBasic()) {
+ case HeapType::string:
+ return os << "stringref";
+ case HeapType::stringview_wtf8:
+ return os << "stringview_wtf8";
+ case HeapType::stringview_wtf16:
+ return os << "stringview_wtf16";
+ case HeapType::stringview_iter:
+ return os << "stringview_iter";
+ default:
+ break;
+ }
+ }
os << "(ref ";
if (type.isNullable()) {
os << "null ";
}
- printHeapTypeName(type.getHeapType());
+ printHeapTypeName(heapType);
os << ')';
} else if (type.isRtt()) {
print(type.getRtt());