git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Runtime handling of unsigned long
commit0301a73e473d704eee2536e485261a871f4bf6e1 authorAndy Arvanitis <andyarvanitis@gmail.com> dateWed 12 Sep 2018, 21:25 (8 years ago) parent9f812ae
1 file changed+8
runtime/purescript.h+8
runtime/purescript.h+8
@@ -50,6 +50,14 @@ namespace purescript {
5050#endif // !defined(NDEBUG)
5151 }
5252
53+ boxed(const unsigned long n) : std::shared_ptr<void>(std::make_shared<int>(static_cast<int>(n))) {
54+#if !defined(NDEBUG) // if debug build
55+ if (n > std::numeric_limits<int>::max()) {
56+ throw std::runtime_error("integer out of range");
57+ }
58+#endif // !defined(NDEBUG)
59+ }
60+
5361 boxed(const double n) : std::shared_ptr<void>(std::make_shared<double>(n)) {}
5462 boxed(const bool b) : std::shared_ptr<void>(std::make_shared<bool>(b)) {}
5563 boxed(const char s[]) : std::shared_ptr<void>(std::make_shared<string>(s)) {}