summaryrefslogtreecommitdiff
path: root/src/wasm-s-parser.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-08 12:40:01 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-08 12:40:01 -0800
commita0d9673cf965c72f7ea8f4484f23e98e5ec3ba65 (patch)
tree9ba088ba9396ae27dca06c90f68389baa974c810 /src/wasm-s-parser.h
parent57481a28ac4935928bca3deae8d202d88c780789 (diff)
downloadbinaryen-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.h30
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;
}