From dce3791b402cc1e49da000cfe918bb21e81b4a6a Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 30 Oct 2015 16:47:22 -0700 Subject: fix double compares --- src/asm2wasm.cpp | 2 ++ src/wasm.h | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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()->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; -- cgit v1.2.3