From d02c260619e5d068b6893d4948de0487d0f1f66d Mon Sep 17 00:00:00 2001 From: Max Graey Date: Fri, 29 Jul 2022 07:15:35 +0300 Subject: [JS Api] Reuse C-Api for emitText and emitStackIR (#4832) Make the C API match the JS API and fix an old bug where extra newlines were emitted. --- src/passes/Print.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/passes/Print.cpp') diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index a6a0f7919..797ce46b1 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -3627,15 +3627,18 @@ printStackIR(StackIR* ir, std::ostream& o, Function* func) { default: WASM_UNREACHABLE("unexpeted op"); } - std::cout << '\n'; + o << '\n'; } assert(controlFlowDepth == 0); return o; } -std::ostream& printStackIR(std::ostream& o, Module* module) { +std::ostream& printStackIR(std::ostream& o, Module* module, bool optimize) { wasm::PassRunner runner(module); runner.add("generate-stack-ir"); + if (optimize) { + runner.add("optimize-stack-ir"); + } runner.add(std::make_unique(&o)); runner.run(); return o; -- cgit v1.2.3