diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-08 12:40:01 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-08 12:40:01 -0800 |
commit | a0d9673cf965c72f7ea8f4484f23e98e5ec3ba65 (patch) | |
tree | 9ba088ba9396ae27dca06c90f68389baa974c810 /src/wasm-s-parser.h | |
parent | 57481a28ac4935928bca3deae8d202d88c780789 (diff) | |
download | binaryen-a0d9673cf965c72f7ea8f4484f23e98e5ec3ba65.tar.gz binaryen-a0d9673cf965c72f7ea8f4484f23e98e5ec3ba65.tar.bz2 binaryen-a0d9673cf965c72f7ea8f4484f23e98e5ec3ba65.zip |
parse nans
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r-- | src/wasm-s-parser.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index d50cedd92..c907f51f1 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -703,6 +703,36 @@ private: case f64: ret->value.f64 = std::nan(""); break; default: onError(); } + std::cerr << "make constant " << str << " ==> " << ret->value << '\n'; + return ret; + } + if (str[0] == 'n' && str[1] == 'a' && str[2] == 'n' && str[3] == ':') { + assert(str[4] == '0' && str[5] == 'x'); + switch (type) { + case f32: { + union { + uint32_t pattern; + float f; + } u; + u.pattern = atoi(str + 6); + u.pattern |= 0x7f800000; + assert(isnan(u.f)); + ret->value.f32 = u.f; + break; + } + case f64: { + union { + uint64_t pattern; + double d; + } u; + u.pattern = atol(str + 6); + u.pattern |= 0x7ff0000000000000LL; + assert(isnan(u.d)); + ret->value.f64 = u.d; + break; + } + default: onError(); + } //std::cerr << "make constant " << str << " ==> " << ret->value << '\n'; return ret; } |