diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-02-17 16:53:14 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-02-17 16:53:14 -0800 |
commit | 10b929720a8701ef2a960f5b45e39d7a999cca41 (patch) | |
tree | 8f813863d148fbbab6faabd42324bebbad90db34 | |
parent | 29370f0fc7ad44f506e1bd54441f19111fe9ff5f (diff) | |
download | binaryen-10b929720a8701ef2a960f5b45e39d7a999cca41.tar.gz binaryen-10b929720a8701ef2a960f5b45e39d7a999cca41.tar.bz2 binaryen-10b929720a8701ef2a960f5b45e39d7a999cca41.zip |
overload wasm printing in std namespace
-rw-r--r-- | src/wasm-printing.h | 12 | ||||
-rw-r--r-- | test/example/find_div0s.cpp | 3 |
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"; } } } |