From 54bd283275124f0aa8aa4aa11fd2ed203896ba84 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 12 Sep 2025 17:45:50 -0700 Subject: [PATCH] [Experimental] Do not print vtable types --- src/passes/Print.cpp | 6 ++++++ src/wasm/wasm-type.cpp | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 75c5452f238..52ccd8330be 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -3518,6 +3518,12 @@ void PrintSExpression::visitModule(Module* curr) { incIndent(); } } + if (auto it = curr->typeNames.find(type); it != curr->typeNames.end()) { + auto name = it->second.name.str; + if (name.find(".vtable") == name.size() - 7) { + continue; + } + } doIndent(o, indent); o << typePrinter(type) << maybeNewLine; } diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index b54116258e8..042a4ea52f3 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -1919,17 +1919,24 @@ TypePrinter::print(HeapType type, const auto& struct_ = type.getStruct(); os << "(struct"; if (auto desc = type.getDescriptorType()) { - os << " (field $vtable "; - print(Type(*desc, NonNullable)); + os << " (field $vtable"; + // print(Type(*desc, NonNullable)); os << ')'; } for (Index i = 0; i < struct_.fields.size(); ++i) { // TODO: move this to the function for printing fields. os << " (field "; + bool isVTable = false; if (auto it = fieldNames.find(i); it != fieldNames.end()) { - it->second.print(os) << ' '; + if (it->second == Name("vtable")) { + isVTable = true; + } + it->second.print(os); + } + if (!isVTable) { + os << ' '; + print(struct_.fields[i]); } - print(struct_.fields[i]); os << ')'; } return os << ")";