From 2da69a84b69a316409d5af65f66443a27422a353 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 30 Sep 2024 12:33:30 -0700 Subject: [NFC] Print type names in more places when logging (#6975) --- src/passes/Print.cpp | 5 +++++ src/wasm-interpreter.h | 6 +++--- src/wasm.h | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 854934204..0533b9786 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -3714,4 +3714,9 @@ std::ostream& operator<<(std::ostream& o, wasm::StackInst& inst) { return wasm::printStackInst(&inst, o); } +std::ostream& operator<<(std::ostream& o, wasm::ModuleType pair) { + wasm::printTypeOrName(pair.second, o, &pair.first); + return o; +} + } // namespace std diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 9659a5c34..c5019b2f3 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -237,9 +237,9 @@ public: if (type.isConcrete() || curr->type.isConcrete()) { #if 1 // def WASM_INTERPRETER_DEBUG if (!Type::isSubType(type, curr->type)) { - std::cerr << "expected " << curr->type << ", seeing " << type - << " from\n" - << *curr << '\n'; + std::cerr << "expected " << ModuleType(*module, curr->type) + << ", seeing " << ModuleType(*module, type) << " from\n" + << ModuleExpression(*module, curr) << '\n'; } #endif assert(Type::isSubType(type, curr->type)); diff --git a/src/wasm.h b/src/wasm.h index e54d628bd..ede3e50c1 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2401,6 +2401,9 @@ public: // Utility for printing an expression with named types. using ModuleExpression = std::pair; +// Utility for printing an type with a name, if the module defines a name. +using ModuleType = std::pair; + // Utility for printing only the top level of an expression. Named types will be // used if `module` is non-null. struct ShallowExpression { @@ -2422,6 +2425,7 @@ std::ostream& operator<<(std::ostream& o, wasm::Function& func); std::ostream& operator<<(std::ostream& o, wasm::Expression& expression); std::ostream& operator<<(std::ostream& o, wasm::ModuleExpression pair); std::ostream& operator<<(std::ostream& o, wasm::ShallowExpression expression); +std::ostream& operator<<(std::ostream& o, wasm::ModuleType pair); } // namespace std -- cgit v1.2.3