diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-03 10:18:14 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-03 10:18:14 -0800 |
commit | aa122695e53bb2c39175e2d04f626b2cd6c2e911 (patch) | |
tree | 50b7d08231582457793a9285a578a9e1745e6662 /src/wasm.h | |
parent | 3b0fc2374d042ba81e16ee09f57cdef9891be065 (diff) | |
download | binaryen-aa122695e53bb2c39175e2d04f626b2cd6c2e911.tar.gz binaryen-aa122695e53bb2c39175e2d04f626b2cd6c2e911.tar.bz2 binaryen-aa122695e53bb2c39175e2d04f626b2cd6c2e911.zip |
refactor pretty printing code
Diffstat (limited to 'src/wasm.h')
-rw-r--r-- | src/wasm.h | 67 |
1 files changed, 1 insertions, 66 deletions
diff --git a/src/wasm.h b/src/wasm.h index 1fce6692b..d4ecabca3 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -12,29 +12,10 @@ #include <vector> #include "simple_ast.h" -#include "colors.h" +#include "pretty_printing.h" namespace wasm { -// Utilities - -std::ostream &doIndent(std::ostream &o, unsigned indent) { - for (unsigned i = 0; i < indent; i++) { - o << " "; - } - return o; -} -std::ostream &incIndent(std::ostream &o, unsigned& indent) { - o << '\n'; - indent++; - return o; -} -std::ostream &decIndent(std::ostream &o, unsigned& indent) { - indent--; - doIndent(o, indent); - return o << ')'; -} - // Basics struct Name : public cashew::IString { @@ -93,36 +74,6 @@ WasmType getWasmType(unsigned size, bool float_) { abort(); } -std::ostream &prepareMajorColor(std::ostream &o) { - Colors::red(o); - Colors::bold(o); - return o; -} - -std::ostream &prepareColor(std::ostream &o) { - Colors::magenta(o); - Colors::bold(o); - return o; -} - -std::ostream &prepareMinorColor(std::ostream &o) { - Colors::orange(o); - return o; -} - -std::ostream &restoreNormalColor(std::ostream &o) { - Colors::normal(o); - return o; -} - -std::ostream& printText(std::ostream &o, const char *str) { - o << '"'; - Colors::green(o); - o << str; - Colors::normal(o); - return o << '"'; -} - struct Literal { WasmType type; union { @@ -251,22 +202,6 @@ std::ostream& printFullLine(std::ostream &o, unsigned indent, Expression *expres return o << '\n'; } -std::ostream& printOpening(std::ostream &o, const char *str, bool major=false) { - o << '('; - major ? prepareMajorColor(o) : prepareColor(o); - o << str; - restoreNormalColor(o); - return o; -} - -std::ostream& printMinorOpening(std::ostream &o, const char *str) { - o << '('; - prepareMinorColor(o); - o << str; - restoreNormalColor(o); - return o; -} - typedef std::vector<Expression*> ExpressionList; // TODO: optimize class Nop : public Expression { |