diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-11 20:38:18 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-11 20:38:18 -0800 |
commit | a43caa75ce7293a4aea91228daf379f06817f5d8 (patch) | |
tree | cf19d50e137e9c4a80180bfb90d084f418e337f5 /src | |
parent | ed47fbc9ce48e712548d937195e0f7d333da55c4 (diff) | |
download | binaryen-a43caa75ce7293a4aea91228daf379f06817f5d8.tar.gz binaryen-a43caa75ce7293a4aea91228daf379f06817f5d8.tar.bz2 binaryen-a43caa75ce7293a4aea91228daf379f06817f5d8.zip |
add simple example
Diffstat (limited to 'src')
-rw-r--r-- | src/asm2wasm.h | 2 | ||||
-rw-r--r-- | src/pretty_printing.h | 2 | ||||
-rw-r--r-- | src/wasm.h | 21 |
3 files changed, 18 insertions, 7 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 61c67c5d8..ce5b669d1 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -5,7 +5,7 @@ // #include "wasm.h" -#include "optimizer.h" +#include "emscripten-optimizer/optimizer.h" #include "mixed_arena.h" namespace wasm { diff --git a/src/pretty_printing.h b/src/pretty_printing.h index cc2d88272..88028fdec 100644 --- a/src/pretty_printing.h +++ b/src/pretty_printing.h @@ -5,7 +5,7 @@ #include <ostream> -#include "colors.h" +#include "emscripten-optimizer/colors.h" std::ostream &doIndent(std::ostream &o, unsigned indent) { for (unsigned i = 0; i < indent; i++) { diff --git a/src/wasm.h b/src/wasm.h index 769c0ecad..dfd540155 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -24,7 +24,7 @@ #include <map> #include <vector> -#include "simple_ast.h" +#include "emscripten-optimizer/simple_ast.h" #include "pretty_printing.h" namespace wasm { @@ -263,12 +263,10 @@ public: }; Id _id; - Expression() : _id(InvalidId) {} - Expression(Id id) : _id(id) {} - 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 + Expression() : _id(InvalidId), type(none) {} + Expression(Id id) : _id(id), type(none) {} template<class T> bool is() { @@ -280,6 +278,12 @@ public: return _id == T()._id ? (T*)this : nullptr; } + std::ostream& print(std::ostream &o, unsigned indent); // avoid virtual here, for performance + + friend std::ostream& operator<<(std::ostream &o, Expression* expression) { + return expression->print(o, 0); + } + static std::ostream& printFullLine(std::ostream &o, unsigned indent, Expression *expression) { doIndent(o, indent); expression->print(o, indent); @@ -704,6 +708,11 @@ public: printFullLine(o, indent, right); return decIndent(o, indent); } + + // the type is always the type of the operands + void finalize() { + type = left->type; + } }; class Compare : public Expression { @@ -849,6 +858,8 @@ public: Name type; // if null, it is implicit in params and result Expression *body; + Function() : result(none) {} + std::ostream& print(std::ostream &o, unsigned indent) { printOpening(o, "func ", true) << name; if (params.size() > 0) { |