summaryrefslogtreecommitdiff
path: root/src/wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-12 12:45:34 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-12 12:45:34 -0800
commit3a2768127856e7113317e5d907ead6cc41f60299 (patch)
tree6aa85f7676dc23c7086c729a9b1049c7a9187a9a /src/wasm.h
parent7725a4b87feead9416e419b3c95228c4515813da (diff)
parentafce1de1495cc5782ec55b016d4e864b316d9920 (diff)
downloadbinaryen-3a2768127856e7113317e5d907ead6cc41f60299.tar.gz
binaryen-3a2768127856e7113317e5d907ead6cc41f60299.tar.bz2
binaryen-3a2768127856e7113317e5d907ead6cc41f60299.zip
Merge branch 'binaryen'
Diffstat (limited to 'src/wasm.h')
-rw-r--r--src/wasm.h23
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 {