diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-03 10:27:55 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-03 10:27:55 -0800 |
commit | ff95c47b26530d91192ee932ec1a8936ef4758c8 (patch) | |
tree | ac2689c79076836da598d4d93f16b6caea507c9c /src/wasm.h | |
parent | 3505f2162d92fde5edb590254ec9553146b053bf (diff) | |
download | binaryen-ff95c47b26530d91192ee932ec1a8936ef4758c8.tar.gz binaryen-ff95c47b26530d91192ee932ec1a8936ef4758c8.tar.bz2 binaryen-ff95c47b26530d91192ee932ec1a8936ef4758c8.zip |
refactor printFullLine
Diffstat (limited to 'src/wasm.h')
-rw-r--r-- | src/wasm.h | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/wasm.h b/src/wasm.h index 32c6466b8..5d0be97ac 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -1,5 +1,13 @@ // -// WebAssembly representation and processing library +// wasm.js: WebAssembly representation and processing library +// +// This represents WebAssembly in an AST format, with a focus on making +// it easy to process it. For example, some useful forms of processing +// the AST include +// +// * Pretty-printing: Implemented in this file. +// * Interpreting: See wasm-interpreter.h. +// * Optimizing: See asm2wasm.h // #ifndef __wasm_h__ @@ -76,6 +84,8 @@ WasmType getWasmType(unsigned size, bool float_) { abort(); } +// Literals + struct Literal { WasmType type; union { @@ -183,7 +193,7 @@ public: Expression() : _id(InvalidId) {} Expression(Id id) : _id(id) {} - WasmType type; // the type of the expression: its output, not necessarily its input(s) + WasmType type; // the type of the expression: its *output*, not necessarily its input(s) std::ostream& print(std::ostream &o, unsigned indent); // avoid virtual here, for performance @@ -196,15 +206,15 @@ public: T* dyn_cast() { return _id == T()._id ? (T*)this : nullptr; } -}; -std::ostream& printFullLine(std::ostream &o, unsigned indent, Expression *expression) { - doIndent(o, indent); - expression->print(o, indent); - return o << '\n'; -} + static std::ostream& printFullLine(std::ostream &o, unsigned indent, Expression *expression) { + doIndent(o, indent); + expression->print(o, indent); + return o << '\n'; + } +}; -typedef std::vector<Expression*> ExpressionList; // TODO: optimize +typedef std::vector<Expression*> ExpressionList; // TODO: optimize? class Nop : public Expression { public: @@ -720,7 +730,7 @@ public: doIndent(o, indent); printMinorOpening(o, "local ") << local.name << ' ' << printWasmType(local.type) << ")\n"; } - printFullLine(o, indent, body); + Expression::printFullLine(o, indent, body); return decIndent(o, indent); } }; |