diff options
-rw-r--r-- | src/asm2wasm.cpp | 2 | ||||
-rw-r--r-- | src/wasm.h | 1 | ||||
-rw-r--r-- | test/unit.asm.js | 5 | ||||
-rw-r--r-- | test/unit.wast | 16 |
4 files changed, 24 insertions, 0 deletions
diff --git a/src/asm2wasm.cpp b/src/asm2wasm.cpp index b02b4aa52..c594e520d 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]); + assert(ret->left->type == ret->right->type); ret->inputType = ret->left->type; return ret; } @@ -900,6 +901,7 @@ Function* Asm2WasmModule::processFunction(Ref ast) { ret->op = Eq; ret->left = process(ast[2]); ret->right = allocator.alloc<Const>()->set(Literal(0)); + assert(ret->left->type == ret->right->type); ret->inputType = ret->left->type; return ret; } diff --git a/src/wasm.h b/src/wasm.h index 2e383d83b..7acd65ddd 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -540,6 +540,7 @@ public: Const* set(Literal value_) { value = value_; + type = value.type; return this; } diff --git a/test/unit.asm.js b/test/unit.asm.js index 2b599d99a..db14f721b 100644 --- a/test/unit.asm.js +++ b/test/unit.asm.js @@ -18,9 +18,14 @@ function () { function doubleCompares(x, y) { x = +x; y = +y; + if (x > 0.0) return 0.0; if (x < y) return +x; return +y; } + function intOps() { + var x = 0; + return !x; + } function z() { } diff --git a/test/unit.wast b/test/unit.wast index 9e4b19eb4..72e124b41 100644 --- a/test/unit.wast +++ b/test/unit.wast @@ -54,6 +54,15 @@ (func $doubleCompares (param $x f64) (param $y f64) (result f64) (block $topmost (if + (f64.gt + (get_local $x) + (f64.const 0) + ) + (break $topmost + (f64.const 0) + ) + ) + (if (f64.lt (get_local $x) (get_local $y) @@ -67,6 +76,13 @@ ) ) ) + (func $intOps (result i32) + (local $x i32) + (i32.eq + (get_local $x) + (i32.const 0) + ) + ) (func $z (nop) ) |