diff options
Diffstat (limited to 'src/wasm.h')
-rw-r--r-- | src/wasm.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/wasm.h b/src/wasm.h index fcee2915c..6fc4ca5aa 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) { @@ -921,7 +932,7 @@ public: size_t initial, max; std::vector<Segment> segments; - Memory() : initial(0), max(-1) {} + Memory() : initial(0), max((uint32_t)-1) {} }; class Module { |