diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-04 21:46:48 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-04 21:46:48 -0800 |
commit | 69f0f91c03f593ea6b5c30515afdf33d5c7827fb (patch) | |
tree | 3c1296c96d7003076d807f98ede73e21e8f119df /src | |
parent | e2b0a2a26eac53661964739c2be344c90850626d (diff) | |
download | binaryen-69f0f91c03f593ea6b5c30515afdf33d5c7827fb.tar.gz binaryen-69f0f91c03f593ea6b5c30515afdf33d5c7827fb.tar.bz2 binaryen-69f0f91c03f593ea6b5c30515afdf33d5c7827fb.zip |
infinity
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-s-parser.h | 23 | ||||
-rw-r--r-- | src/wasm-shell.cpp | 2 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index a49fa7bd5..26abdec8e 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -3,6 +3,7 @@ // Parses WebAssembly code in S-Expression format, as in .wast files. // +#include <cmath> #include <sstream> #include "wasm.h" @@ -30,7 +31,9 @@ IString MODULE("module"), TYPE("type"), CALL("call"), CALL_IMPORT("call_import"), - CALL_INDIRECT("call_indirect"); + CALL_INDIRECT("call_indirect"), + INFINITY_("infinity"), + NEG_INFINITY("-infinity"); // // An element in an S-Expression: a list or a string @@ -497,6 +500,24 @@ private: Expression* makeConst(Element& s, WasmType type) { auto ret = allocator.alloc<Const>(); ret->type = ret->value.type = type; + if (isWasmTypeFloat(type)) { + if (s[1]->str() == INFINITY_) { + switch (type) { + case f32: ret->value.f32 = std::numeric_limits<float>::infinity(); break; + case f64: ret->value.f64 = std::numeric_limits<double>::infinity(); break; + default: abort(); + } + return ret; + } + if (s[1]->str() == NEG_INFINITY) { + switch (type) { + case f32: ret->value.f32 = -std::numeric_limits<float>::infinity(); break; + case f64: ret->value.f64 = -std::numeric_limits<double>::infinity(); break; + default: abort(); + } + return ret; + } + } const char *str = s[1]->c_str(); std::istringstream istr(str); switch (type) { diff --git a/src/wasm-shell.cpp b/src/wasm-shell.cpp index 1f8d1373c..808ed2ea4 100644 --- a/src/wasm-shell.cpp +++ b/src/wasm-shell.cpp @@ -146,7 +146,7 @@ int main(int argc, char **argv) { Element& curr = *root[i]; IString id = curr[0]->str(); if (id == MODULE) break; - std::cerr << curr << '\n'; + std::cerr << "CHECKING| " << curr << '\n'; Element& invoke = *curr[1]; assert(invoke[0]->str() == INVOKE); IString name = invoke[1]->str(); |