summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/Print.cpp5
-rw-r--r--src/wasm-interpreter.h6
-rw-r--r--src/wasm.h4
3 files changed, 12 insertions, 3 deletions
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<Module&, Expression*>;
+// Utility for printing an type with a name, if the module defines a name.
+using ModuleType = std::pair<Module&, Type>;
+
// 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