From d4aa0d30234ac9e553d743bd881a767d96554a4a Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 15 May 2018 15:58:13 -0700 Subject: Clean up printing code (#1548) * make the iostream overrides receive a reference, not a pointer (i.e., like e.g. LLVM IR printing works, and avoiding overriding printing of pointer addresses which is sort of odd) * move more code out of headers, especially unrelated headers. --- src/wasm-printing.h | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/wasm-printing.h') diff --git a/src/wasm-printing.h b/src/wasm-printing.h index 3b5b94cc2..936c118ee 100644 --- a/src/wasm-printing.h +++ b/src/wasm-printing.h @@ -25,18 +25,9 @@ namespace wasm { struct WasmPrinter { - static std::ostream& printModule(Module* module, std::ostream& o) { - PassRunner passRunner(module); - passRunner.setFeatures(Feature::All); - passRunner.setIsNested(true); - passRunner.add(&o); - passRunner.run(); - return o; - } - - static std::ostream& printModule(Module* module) { - return printModule(module, std::cout); - } + static std::ostream& printModule(Module* module, std::ostream& o); + + static std::ostream& printModule(Module* module); static std::ostream& printExpression(Expression* expression, std::ostream& o, bool minify = false, bool full = false); }; @@ -45,12 +36,12 @@ struct WasmPrinter { namespace std { -inline std::ostream& operator<<(std::ostream& o, wasm::Module* module) { - return wasm::WasmPrinter::printModule(module, o); +inline std::ostream& operator<<(std::ostream& o, wasm::Module& module) { + return wasm::WasmPrinter::printModule(&module, o); } -inline std::ostream& operator<<(std::ostream& o, wasm::Expression* expression) { - return wasm::WasmPrinter::printExpression(expression, o); +inline std::ostream& operator<<(std::ostream& o, wasm::Expression& expression) { + return wasm::WasmPrinter::printExpression(&expression, o); } } -- cgit v1.2.3