summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/asm2wasm.cpp2
-rw-r--r--src/wasm.h7
2 files changed, 6 insertions, 3 deletions
diff --git a/src/asm2wasm.cpp b/src/asm2wasm.cpp
index 609909ab8..b02b4aa52 100644
--- a/src/asm2wasm.cpp
+++ b/src/asm2wasm.cpp
@@ -780,6 +780,7 @@ Function* Asm2WasmModule::processFunction(Ref ast) {
ret->op = relational;
ret->left = process(ast[2]);
ret->right = process(ast[3]);
+ ret->inputType = ret->left->type;
return ret;
}
} else if (what == NUM) {
@@ -899,6 +900,7 @@ Function* Asm2WasmModule::processFunction(Ref ast) {
ret->op = Eq;
ret->left = process(ast[2]);
ret->right = allocator.alloc<Const>()->set(Literal(0));
+ ret->inputType = ret->left->type;
return ret;
}
abort_on("bad unary", ast);
diff --git a/src/wasm.h b/src/wasm.h
index 5a48aa3f2..2e383d83b 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -225,7 +225,7 @@ enum HostOp {
class Expression {
public:
- WasmType type;
+ WasmType type; // the type of the expression: its output, not necessarily its input(s)
Expression() : type(type) {}
@@ -607,15 +607,16 @@ public:
class Compare : public Expression {
public:
RelationalOp op;
+ WasmType inputType;
Expression *left, *right;
Compare() {
- type = WasmType::i32;
+ type = WasmType::i32; // output is always i32
}
std::ostream& print(std::ostream &o, unsigned indent) override {
o << '(';
- prepareColor(o) << printWasmType(type) << '.';
+ prepareColor(o) << printWasmType(inputType) << '.';
switch (op) {
case Eq: o << "eq"; break;
case Ne: o << "ne"; break;