git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Runtime handling of unsigned long
0301a73Andy Arvanitis
runtime/purescript.h+8
@@ -50,6 +50,14 @@ namespace purescript {
50#endif // !defined(NDEBUG)
50#endif // !defined(NDEBUG)
51 }
51 }
52
52
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+
53 boxed(const double n) : std::shared_ptr<void>(std::make_shared<double>(n)) {}
61 boxed(const double n) : std::shared_ptr<void>(std::make_shared<double>(n)) {}
54 boxed(const bool b) : std::shared_ptr<void>(std::make_shared<bool>(b)) {}
62 boxed(const bool b) : std::shared_ptr<void>(std::make_shared<bool>(b)) {}
55 boxed(const char s[]) : std::shared_ptr<void>(std::make_shared<string>(s)) {}
63 boxed(const char s[]) : std::shared_ptr<void>(std::make_shared<string>(s)) {}