///////////////////////////////////////////////////////////////////////////////
//
// Module : purescript.cpp
// Copyright : (c) Andy Arvanitis 2019
// License : BSD
//
// Maintainer : Andy Arvanitis
// Stability : experimental
// Portability :
//
// Basic types and functions to support purescript-to-C++ rendering
//
///////////////////////////////////////////////////////////////////////////////
//
#include "purescript.h"
namespace purescript {
template class _template_::fn_t;
template class _template_::eff_fn_t;
template class _template_::dict_t;
template class _template_::weak;
template class _template_::recur;
boxed::boxed(const long n) : _int_(static_cast(n)) {
#if !defined(NDEBUG) && !defined(PURESCRIPT_DISABLE_EXCEPTIONS)
if (n < std::numeric_limits::min() || n > std::numeric_limits::max()) {
throw std::runtime_error("integer out of range");
}
#endif
}
boxed::boxed(const unsigned long n) : _int_(static_cast(n)) {
#if !defined(NDEBUG) && !defined(PURESCRIPT_DISABLE_EXCEPTIONS)
if (n > std::numeric_limits::max()) {
throw std::runtime_error("integer out of range");
}
#endif
}
auto boxed::operator[](const int index) const -> const boxed& {
#if !defined(NDEBUG)
return static_cast(shared.get())->at(index);
#else
return (*static_cast(shared.get()))[index];
#endif
}
auto boxed::operator[](const int index) -> boxed& {
#if !defined(NDEBUG)
return static_cast(shared.get())->at(index);
#else
return (*static_cast(shared.get()))[index];
#endif
}
const boxed undefined;
} // namespace purescript