diff options
-rw-r--r-- | src/wasm.h | 8 | ||||
-rw-r--r-- | test/unit.asm.js | 6 | ||||
-rw-r--r-- | test/unit.wast | 24 |
3 files changed, 34 insertions, 4 deletions
diff --git a/src/wasm.h b/src/wasm.h index 7acd65ddd..bac19b587 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -650,11 +650,11 @@ public: std::ostream& print(std::ostream &o, unsigned indent) override { o << '('; - prepareColor(o) << printWasmType(type) << ".convert_"; + prepareColor(o); switch (op) { - case ConvertUInt32: o << "u/i32"; break; - case ConvertSInt32: o << "s/i32"; break; - case TruncSFloat64: o << "s/f64"; break; + case ConvertUInt32: o << "f64.convert_u/i32"; break; + case ConvertSInt32: o << "f64.convert_s/i32"; break; + case TruncSFloat64: o << "i32.trunc_s/f64"; break; default: abort(); } restoreNormalColor(o); diff --git a/test/unit.asm.js b/test/unit.asm.js index 987374fe2..4b706eb26 100644 --- a/test/unit.asm.js +++ b/test/unit.asm.js @@ -35,6 +35,12 @@ function () { var x = 0; return !x; } + function conversions() { + var i = 0, d = 0.0; + i = ~~d; + d = +(i | 0); + d = +(i >>> 0); + } function z() { } diff --git a/test/unit.wast b/test/unit.wast index 554751130..b331fa74e 100644 --- a/test/unit.wast +++ b/test/unit.wast @@ -131,6 +131,30 @@ (i32.const 0) ) ) + (func $conversions + (local $i i32) + (local $d f64) + (block + (set_local $i + (i32.trunc_s/f64 + (get_local $d) + ) + ) + (set_local $d + (f64.convert_s/i32 + (get_local $i) + ) + ) + (set_local $d + (f64.convert_u/i32 + (i32.shr_u + (get_local $i) + (i32.const 0) + ) + ) + ) + ) + ) (func $z (nop) ) |