summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm-printing.h12
-rw-r--r--test/example/find_div0s.cpp3
2 files changed, 13 insertions, 2 deletions
diff --git a/src/wasm-printing.h b/src/wasm-printing.h
index d7868d52c..6d8ed7c8a 100644
--- a/src/wasm-printing.h
+++ b/src/wasm-printing.h
@@ -33,5 +33,17 @@ extern std::ostream& printWasm(Expression* expression, std::ostream& o);
}
+namespace std {
+
+std::ostream& operator<<(std::ostream& o, wasm::Module* module) {
+ return wasm::printWasm(module, o);
+}
+
+std::ostream& operator<<(std::ostream& o, wasm::Expression* expression) {
+ return wasm::printWasm(expression, o);
+}
+
+}
+
#endif
diff --git a/test/example/find_div0s.cpp b/test/example/find_div0s.cpp
index e74d4781f..dc2872edc 100644
--- a/test/example/find_div0s.cpp
+++ b/test/example/find_div0s.cpp
@@ -46,8 +46,7 @@ int main() {
// Check if the right operand is a constant, and if it is 0
auto right = curr->right->dyn_cast<Const>();
if (right && right->value.getInteger() == 0) {
- std::cout << "We found that ";
- printWasm(curr->left, std::cout) << " is divided by zero\n";
+ std::cout << "We found that " << curr->left << " is divided by zero\n";
}
}
}