diff options
-rw-r--r-- | src/asm2wasm.cpp | 9 | ||||
-rw-r--r-- | test/emcc_hello_world.wast | 8 |
2 files changed, 5 insertions, 12 deletions
diff --git a/src/asm2wasm.cpp b/src/asm2wasm.cpp index 267e36bf6..ac2c1d5e8 100644 --- a/src/asm2wasm.cpp +++ b/src/asm2wasm.cpp @@ -343,13 +343,6 @@ private: return asmToWasmType(detectType(ast, data)); } - bool isInteger(double num) { - return fmod(num, 1) == 0 && double(int(num)) == num; - } - bool isInteger(Ref ast) { - return ast[0] == NUM && isInteger(ast[1]->getNumber()); - } - bool isUnsignedCoercion(Ref ast) { // TODO: use detectSign? if (ast[0] == BINARY && ast[1] == TRSHIFT) return true; return false; @@ -765,7 +758,7 @@ Function* Asm2WasmModule::processFunction(Ref ast) { } else if (what == NUM) { auto ret = allocator.alloc<Const>(); double num = ast[1]->getNumber(); - if (isInteger(num)) { + if (isInteger32(num)) { ret->value.type = BasicType::i32; ret->value.i32 = num; } else { diff --git a/test/emcc_hello_world.wast b/test/emcc_hello_world.wast index 3303d930c..129b8e5de 100644 --- a/test/emcc_hello_world.wast +++ b/test/emcc_hello_world.wast @@ -4420,7 +4420,7 @@ (get_local $$r) (i32.const 0) ) - (f64.const 4.29496e+09) + (i32.const -2147483648) ) ) (if @@ -9503,7 +9503,7 @@ (get_local $$0) (i32.const 0) ) - (f64.const 4.29497e+09) + (i32.const -2147483648) ) ) (set_local $$4 @@ -9601,7 +9601,7 @@ (get_local $$7) (i32.const 0) ) - (f64.const 4.29497e+09) + (i32.const -2147483648) ) ) (set_local $$17 @@ -13393,7 +13393,7 @@ (get_local $$bytes) (i32.const 0) ) - (f64.const 4.29497e+09) + (i32.const -2147483648) ) ) (if |