summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-18 13:48:38 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-18 13:48:38 -0800
commit98c318e18c6fc43e851429a2a5e43bac16ae1ee1 (patch)
treefc52a0dee5f7e454f5b1d0640ba64552b2907b35 /src
parent913114cd027722b8576c83f2bb334701c0b9a518 (diff)
downloadbinaryen-98c318e18c6fc43e851429a2a5e43bac16ae1ee1.tar.gz
binaryen-98c318e18c6fc43e851429a2a5e43bac16ae1ee1.tar.bz2
binaryen-98c318e18c6fc43e851429a2a5e43bac16ae1ee1.zip
handle negative zero properly in asm2wasm
Diffstat (limited to 'src')
-rw-r--r--src/asm2wasm.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index 07e771108..5d88b8f38 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -346,6 +346,9 @@ private:
assert(isInteger32(num));
return Literal((int32_t)num);
}
+ if (ast[1] == PLUS && ast[2][0] == UNARY_PREFIX && ast[2][1] == MINUS && ast[2][2][0] == NUM) {
+ return Literal((double)-ast[2][2][1]->getNumber());
+ }
if (ast[1] == MINUS && ast[2][0] == UNARY_PREFIX && ast[2][1] == PLUS && ast[2][2][0] == NUM) {
return Literal((double)-ast[2][2][1]->getNumber());
}
@@ -785,12 +788,9 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
return ret;
} else if (what == UNARY_PREFIX) {
if (ast[1] == PLUS) {
- if (ast[2][0] == NUM) {
- auto ret = allocator.alloc<Const>();
- ret->value.type = WasmType::f64;
- ret->value.f64 = ast[2][1]->getNumber();
- ret->type = ret->value.type;
- return ret;
+ Literal literal = checkLiteral(ast);
+ if (literal.type != none) {
+ return allocator.alloc<Const>()->set(literal);
}
auto ret = process(ast[2]); // we are a +() coercion
if (ret->type == i32) {