summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-06-29 18:17:32 -0700
committerGitHub <noreply@github.com>2022-06-29 18:17:32 -0700
commitdde06039e7327351a27a574d37d64f289f420ab2 (patch)
tree065f4d4a3dade57fe4f3159c981208499908e4bd /src/passes/Print.cpp
parent19f4db6ef5263a578baef7e64bf9c9169bb771e6 (diff)
downloadbinaryen-dde06039e7327351a27a574d37d64f289f420ab2.tar.gz
binaryen-dde06039e7327351a27a574d37d64f289f420ab2.tar.bz2
binaryen-dde06039e7327351a27a574d37d64f289f420ab2.zip
[Strings] Print shorthand types where possible (#4763)
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp16
1 files changed, 16 insertions, 0 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 ";