mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-06 16:57:04 +08:00
Add noexcept where appropriate
This modifies no logic, it simply adds the keyword `noexcept` I believe this is 100% correct. It calls methods that are not guaranteed to be `noexcept`, such as `operator[]` but have no logically way of throwing.
This commit is contained in:
parent
f20cdc7c8f
commit
e07cd88659
@ -104,17 +104,17 @@ namespace chaiscript {
|
||||
}
|
||||
|
||||
struct Build_Info {
|
||||
static int version_major()
|
||||
static int version_major() noexcept
|
||||
{
|
||||
return chaiscript::version_major;
|
||||
}
|
||||
|
||||
static int version_minor()
|
||||
static int version_minor() noexcept
|
||||
{
|
||||
return chaiscript::version_minor;
|
||||
}
|
||||
|
||||
static int version_patch()
|
||||
static int version_patch() noexcept
|
||||
{
|
||||
return chaiscript::version_patch;
|
||||
}
|
||||
@ -144,7 +144,7 @@ namespace chaiscript {
|
||||
return chaiscript::compiler_name;
|
||||
}
|
||||
|
||||
static bool debug_build()
|
||||
static bool debug_build() noexcept
|
||||
{
|
||||
return chaiscript::debug_build;
|
||||
}
|
||||
@ -152,7 +152,7 @@ namespace chaiscript {
|
||||
|
||||
|
||||
template<typename T>
|
||||
auto parse_num(const char *t_str) -> typename std::enable_if<std::is_integral<T>::value, T>::type
|
||||
auto parse_num(const char *t_str) noexcept -> typename std::enable_if<std::is_integral<T>::value, T>::type
|
||||
{
|
||||
T t = 0;
|
||||
for (char c = *t_str; (c = *t_str) != 0; ++t_str) {
|
||||
@ -167,7 +167,7 @@ namespace chaiscript {
|
||||
|
||||
|
||||
template<typename T>
|
||||
auto parse_num(const char *t_str) -> typename std::enable_if<!std::is_integral<T>::value, T>::type
|
||||
auto parse_num(const char *t_str) noexcept -> typename std::enable_if<!std::is_integral<T>::value, T>::type
|
||||
{
|
||||
T t = 0;
|
||||
T base = 0;
|
||||
@ -211,7 +211,7 @@ namespace chaiscript {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T parse_num(const std::string &t_str)
|
||||
T parse_num(const std::string &t_str) noexcept
|
||||
{
|
||||
return parse_num<T>(t_str.c_str());
|
||||
}
|
||||
|
||||
@ -114,25 +114,25 @@ namespace chaiscript
|
||||
class unique_lock
|
||||
{
|
||||
public:
|
||||
explicit unique_lock(T &) {}
|
||||
void lock() {}
|
||||
void unlock() {}
|
||||
explicit unique_lock(T &) noexcept {}
|
||||
void lock() noexcept {}
|
||||
void unlock() noexcept {}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class shared_lock
|
||||
{
|
||||
public:
|
||||
explicit shared_lock(T &) {}
|
||||
void lock() {}
|
||||
void unlock() {}
|
||||
explicit shared_lock(T &) noexcept {}
|
||||
void lock() noexcept {}
|
||||
void unlock() noexcept {}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class lock_guard
|
||||
{
|
||||
public:
|
||||
explicit lock_guard(T &) {}
|
||||
explicit lock_guard(T &) noexcept {}
|
||||
};
|
||||
|
||||
class shared_mutex { };
|
||||
@ -144,16 +144,16 @@ namespace chaiscript
|
||||
class Thread_Storage
|
||||
{
|
||||
public:
|
||||
explicit Thread_Storage()
|
||||
explicit Thread_Storage() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
inline T *operator->() const
|
||||
inline T *operator->() const noexcept
|
||||
{
|
||||
return &obj;
|
||||
}
|
||||
|
||||
inline T &operator*() const
|
||||
inline T &operator*() const noexcept
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -43,16 +43,16 @@ namespace chaiscript {
|
||||
private:
|
||||
struct Data
|
||||
{
|
||||
explicit Data(const std::type_info &t_type)
|
||||
explicit Data(const std::type_info &t_type) noexcept
|
||||
: m_type(t_type)
|
||||
{
|
||||
}
|
||||
|
||||
Data &operator=(const Data &) = delete;
|
||||
|
||||
virtual ~Data() = default;
|
||||
virtual ~Data() noexcept = default;
|
||||
|
||||
virtual void *data() = 0;
|
||||
virtual void *data() noexcept = 0;
|
||||
|
||||
const std::type_info &type() const
|
||||
{
|
||||
@ -72,7 +72,7 @@ namespace chaiscript {
|
||||
{
|
||||
}
|
||||
|
||||
void *data() override
|
||||
void *data() noexcept override
|
||||
{
|
||||
return &m_data;
|
||||
}
|
||||
@ -141,12 +141,12 @@ namespace chaiscript {
|
||||
}
|
||||
|
||||
// queries
|
||||
bool empty() const
|
||||
bool empty() const noexcept
|
||||
{
|
||||
return !bool(m_data);
|
||||
}
|
||||
|
||||
const std::type_info & type() const
|
||||
const std::type_info & type() const noexcept
|
||||
{
|
||||
if (m_data) {
|
||||
return m_data->type();
|
||||
|
||||
@ -19,13 +19,13 @@ namespace chaiscript
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
T* get_pointer(T *t)
|
||||
T* get_pointer(T *t) noexcept
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* get_pointer(const std::reference_wrapper<T> &t)
|
||||
T* get_pointer(const std::reference_wrapper<T> &t) noexcept
|
||||
{
|
||||
return &t.get();
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
bool empty() const noexcept
|
||||
{
|
||||
return m_begin == m_end;
|
||||
}
|
||||
|
||||
@ -90,11 +90,11 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline void check_divide_by_zero(T, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr)
|
||||
static inline void check_divide_by_zero(T, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr) noexcept
|
||||
{
|
||||
}
|
||||
|
||||
static Common_Types get_common_type(size_t t_size, bool t_signed)
|
||||
static Common_Types get_common_type(size_t t_size, bool t_signed) noexcept
|
||||
{
|
||||
return (t_size == 1 && t_signed)?(Common_Types::t_int8)
|
||||
:(t_size == 1)?(Common_Types::t_uint8)
|
||||
|
||||
@ -221,30 +221,30 @@ namespace chaiscript
|
||||
return *this;
|
||||
}
|
||||
|
||||
const Type_Info &get_type_info() const
|
||||
const Type_Info &get_type_info() const noexcept
|
||||
{
|
||||
return m_data->m_type_info;
|
||||
}
|
||||
|
||||
/// return true if the object is uninitialized
|
||||
bool is_undef() const
|
||||
bool is_undef() const noexcept
|
||||
{
|
||||
return m_data->m_type_info.is_undef();
|
||||
}
|
||||
|
||||
bool is_const() const
|
||||
bool is_const() const noexcept
|
||||
{
|
||||
return m_data->m_type_info.is_const();
|
||||
}
|
||||
|
||||
bool is_type(const Type_Info &ti) const
|
||||
bool is_type(const Type_Info &ti) const noexcept
|
||||
{
|
||||
return m_data->m_type_info.bare_equal(ti);
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
auto pointer_sentinel(std::shared_ptr<T> &ptr) const
|
||||
auto pointer_sentinel(std::shared_ptr<T> &ptr) const noexcept
|
||||
{
|
||||
struct Sentinel {
|
||||
Sentinel(std::shared_ptr<T> &t_ptr, Data &data)
|
||||
@ -263,7 +263,7 @@ namespace chaiscript
|
||||
Sentinel& operator=(Sentinel&&s) = default;
|
||||
Sentinel(Sentinel &&s) = default;
|
||||
|
||||
operator std::shared_ptr<T>&() const
|
||||
operator std::shared_ptr<T>&() const noexcept
|
||||
{
|
||||
return m_ptr.get();
|
||||
}
|
||||
@ -278,42 +278,42 @@ namespace chaiscript
|
||||
return Sentinel(ptr, *(m_data.get()));
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
bool is_null() const noexcept
|
||||
{
|
||||
return (m_data->m_data_ptr == nullptr && m_data->m_const_data_ptr == nullptr);
|
||||
}
|
||||
|
||||
const chaiscript::detail::Any & get() const
|
||||
const chaiscript::detail::Any & get() const noexcept
|
||||
{
|
||||
return m_data->m_obj;
|
||||
}
|
||||
|
||||
bool is_ref() const
|
||||
bool is_ref() const noexcept
|
||||
{
|
||||
return m_data->m_is_ref;
|
||||
}
|
||||
|
||||
bool is_return_value() const
|
||||
bool is_return_value() const noexcept
|
||||
{
|
||||
return m_data->m_return_value;
|
||||
}
|
||||
|
||||
void reset_return_value() const
|
||||
void reset_return_value() const noexcept
|
||||
{
|
||||
m_data->m_return_value = false;
|
||||
}
|
||||
|
||||
bool is_pointer() const
|
||||
bool is_pointer() const noexcept
|
||||
{
|
||||
return !is_ref();
|
||||
}
|
||||
|
||||
void *get_ptr() const
|
||||
void *get_ptr() const noexcept
|
||||
{
|
||||
return m_data->m_data_ptr;
|
||||
}
|
||||
|
||||
const void *get_const_ptr() const
|
||||
const void *get_const_ptr() const noexcept
|
||||
{
|
||||
return m_data->m_const_data_ptr;
|
||||
}
|
||||
@ -353,7 +353,7 @@ namespace chaiscript
|
||||
|
||||
|
||||
/// \returns true if the two Boxed_Values share the same internal type
|
||||
static bool type_match(const Boxed_Value &l, const Boxed_Value &r)
|
||||
static bool type_match(const Boxed_Value &l, const Boxed_Value &r) noexcept
|
||||
{
|
||||
return l.get_type_info() == r.get_type_info();
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
|
||||
static int calculate_arity(const std::vector<Proxy_Function> &t_funcs)
|
||||
static int calculate_arity(const std::vector<Proxy_Function> &t_funcs) noexcept
|
||||
{
|
||||
if (t_funcs.empty()) {
|
||||
return -1;
|
||||
@ -312,7 +312,7 @@ namespace chaiscript
|
||||
return arity;
|
||||
}
|
||||
|
||||
bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const noexcept override
|
||||
{
|
||||
return std::any_of(std::begin(m_funcs), std::end(m_funcs),
|
||||
[&vals, &t_conversions](const Proxy_Function &f){ return f->call_match(vals, t_conversions); });
|
||||
@ -820,7 +820,7 @@ namespace chaiscript
|
||||
|
||||
|
||||
/// Return true if a function exists
|
||||
bool function_exists(const std::string &name) const
|
||||
bool function_exists(const std::string &name) const noexcept
|
||||
{
|
||||
chaiscript::detail::threading::shared_lock<chaiscript::detail::threading::shared_mutex> l(m_mutex);
|
||||
|
||||
@ -930,13 +930,13 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
|
||||
const Type_Conversions &conversions() const
|
||||
const Type_Conversions &conversions() const noexcept
|
||||
{
|
||||
return m_conversions;
|
||||
}
|
||||
|
||||
static bool is_attribute_call(const std::vector<Proxy_Function> &t_funs, const std::vector<Boxed_Value> &t_params,
|
||||
bool t_has_params, const Type_Conversions_State &t_conversions)
|
||||
bool t_has_params, const Type_Conversions_State &t_conversions) noexcept
|
||||
{
|
||||
if (!t_has_params || t_params.empty()) {
|
||||
return false;
|
||||
@ -1166,7 +1166,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
/// return true if the Boxed_Value matches the registered type by name
|
||||
bool is_type(const Boxed_Value &r, const std::string &user_typename) const
|
||||
bool is_type(const Boxed_Value &r, const std::string &user_typename) const noexcept
|
||||
{
|
||||
try {
|
||||
if (get_type(user_typename).bare_equal(r.get_type_info()))
|
||||
@ -1272,66 +1272,66 @@ namespace chaiscript
|
||||
pop_function_call(*m_stack_holder, m_conversions.conversion_saves());
|
||||
}
|
||||
|
||||
Stack_Holder &get_stack_holder()
|
||||
Stack_Holder &get_stack_holder() noexcept
|
||||
{
|
||||
return *m_stack_holder;
|
||||
}
|
||||
|
||||
/// Returns the current stack
|
||||
/// make const/non const versions
|
||||
const StackData &get_stack_data() const
|
||||
const StackData &get_stack_data() const noexcept
|
||||
{
|
||||
return m_stack_holder->stacks.back();
|
||||
}
|
||||
|
||||
static StackData &get_stack_data(Stack_Holder &t_holder)
|
||||
static StackData &get_stack_data(Stack_Holder &t_holder) noexcept
|
||||
{
|
||||
return t_holder.stacks.back();
|
||||
}
|
||||
|
||||
StackData &get_stack_data()
|
||||
StackData &get_stack_data() noexcept
|
||||
{
|
||||
return m_stack_holder->stacks.back();
|
||||
}
|
||||
|
||||
parser::ChaiScript_Parser_Base &get_parser()
|
||||
parser::ChaiScript_Parser_Base &get_parser() noexcept
|
||||
{
|
||||
return m_parser.get();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const std::vector<std::pair<std::string, Boxed_Value>> &get_boxed_functions_int() const
|
||||
const std::vector<std::pair<std::string, Boxed_Value>> &get_boxed_functions_int() const noexcept
|
||||
{
|
||||
return m_state.m_boxed_functions;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, Boxed_Value>> &get_boxed_functions_int()
|
||||
std::vector<std::pair<std::string, Boxed_Value>> &get_boxed_functions_int() noexcept
|
||||
{
|
||||
return m_state.m_boxed_functions;
|
||||
}
|
||||
|
||||
const std::vector<std::pair<std::string, Proxy_Function>> &get_function_objects_int() const
|
||||
const std::vector<std::pair<std::string, Proxy_Function>> &get_function_objects_int() const noexcept
|
||||
{
|
||||
return m_state.m_function_objects;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, Proxy_Function>> &get_function_objects_int()
|
||||
std::vector<std::pair<std::string, Proxy_Function>> &get_function_objects_int() noexcept
|
||||
{
|
||||
return m_state.m_function_objects;
|
||||
}
|
||||
|
||||
const std::vector<std::pair<std::string, std::shared_ptr<std::vector<Proxy_Function>>>> &get_functions_int() const
|
||||
const std::vector<std::pair<std::string, std::shared_ptr<std::vector<Proxy_Function>>>> &get_functions_int() const noexcept
|
||||
{
|
||||
return m_state.m_functions;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::shared_ptr<std::vector<Proxy_Function>>>> &get_functions_int()
|
||||
std::vector<std::pair<std::string, std::shared_ptr<std::vector<Proxy_Function>>>> &get_functions_int() noexcept
|
||||
{
|
||||
return m_state.m_functions;
|
||||
}
|
||||
|
||||
static bool function_less_than(const Proxy_Function &lhs, const Proxy_Function &rhs)
|
||||
static bool function_less_than(const Proxy_Function &lhs, const Proxy_Function &rhs) noexcept
|
||||
{
|
||||
|
||||
auto dynamic_lhs(std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(lhs));
|
||||
@ -1432,7 +1432,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
template<typename Container, typename Key>
|
||||
static typename Container::iterator find_keyed_value(Container &t_c, const Key &t_key)
|
||||
static typename Container::iterator find_keyed_value(Container &t_c, const Key &t_key) noexcept
|
||||
{
|
||||
return std::find_if(t_c.begin(), t_c.end(),
|
||||
[&t_key](const typename Container::value_type &o) {
|
||||
@ -1441,7 +1441,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
template<typename Container, typename Key>
|
||||
static typename Container::const_iterator find_keyed_value(const Container &t_c, const Key &t_key)
|
||||
static typename Container::const_iterator find_keyed_value(const Container &t_c, const Key &t_key) noexcept
|
||||
{
|
||||
return std::find_if(t_c.begin(), t_c.end(),
|
||||
[&t_key](const typename Container::value_type &o) {
|
||||
@ -1450,7 +1450,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
template<typename Container, typename Key>
|
||||
static typename Container::const_iterator find_keyed_value(const Container &t_c, const Key &t_key, const size_t t_hint)
|
||||
static typename Container::const_iterator find_keyed_value(const Container &t_c, const Key &t_key, const size_t t_hint) noexcept
|
||||
{
|
||||
if (t_c.size() > t_hint && t_c[t_hint].first == t_key) {
|
||||
return std::next(t_c.begin(), static_cast<typename std::iterator_traits<typename Container::const_iterator>::difference_type>(t_hint));
|
||||
@ -1527,23 +1527,23 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
Dispatch_Engine *operator->() const {
|
||||
Dispatch_Engine *operator->() const noexcept {
|
||||
return &m_engine.get();
|
||||
}
|
||||
|
||||
Dispatch_Engine &operator*() const {
|
||||
Dispatch_Engine &operator*() const noexcept {
|
||||
return m_engine.get();
|
||||
}
|
||||
|
||||
Stack_Holder &stack_holder() const {
|
||||
Stack_Holder &stack_holder() const noexcept {
|
||||
return m_stack_holder.get();
|
||||
}
|
||||
|
||||
const Type_Conversions_State &conversions() const {
|
||||
const Type_Conversions_State &conversions() const noexcept {
|
||||
return m_conversions;
|
||||
}
|
||||
|
||||
Type_Conversions::Conversion_Saves &conversion_saves() const {
|
||||
Type_Conversions::Conversion_Saves &conversion_saves() const noexcept {
|
||||
return m_conversions.saves();
|
||||
}
|
||||
|
||||
|
||||
@ -50,12 +50,12 @@ namespace chaiscript
|
||||
|
||||
Dynamic_Object() = default;
|
||||
|
||||
bool is_explicit() const
|
||||
bool is_explicit() const noexcept
|
||||
{
|
||||
return m_option_explicit;
|
||||
}
|
||||
|
||||
void set_explicit(const bool t_explicit)
|
||||
void set_explicit(const bool t_explicit) noexcept
|
||||
{
|
||||
m_option_explicit = t_explicit;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ namespace chaiscript
|
||||
Dynamic_Object_Function &operator=(const Dynamic_Object_Function) = delete;
|
||||
Dynamic_Object_Function(Dynamic_Object_Function &) = delete;
|
||||
|
||||
bool operator==(const Proxy_Function_Base &f) const override
|
||||
bool operator==(const Proxy_Function_Base &f) const noexcept override
|
||||
{
|
||||
if (const auto *df = dynamic_cast<const Dynamic_Object_Function *>(&f))
|
||||
{
|
||||
@ -81,9 +81,9 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
bool is_attribute_function() const override { return m_is_attribute; }
|
||||
bool is_attribute_function() const noexcept override { return m_is_attribute; }
|
||||
|
||||
bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const noexcept override
|
||||
{
|
||||
if (dynamic_object_typename_match(vals, m_type_name, m_ti, t_conversions))
|
||||
{
|
||||
@ -127,7 +127,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
bool dynamic_object_typename_match(const Boxed_Value &bv, const std::string &name,
|
||||
const std::unique_ptr<Type_Info> &ti, const Type_Conversions_State &t_conversions) const
|
||||
const std::unique_ptr<Type_Info> &ti, const Type_Conversions_State &t_conversions) const noexcept
|
||||
{
|
||||
if (bv.get_type_info().bare_equal(m_doti))
|
||||
{
|
||||
@ -149,7 +149,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
bool dynamic_object_typename_match(const std::vector<Boxed_Value> &bvs, const std::string &name,
|
||||
const std::unique_ptr<Type_Info> &ti, const Type_Conversions_State &t_conversions) const
|
||||
const std::unique_ptr<Type_Info> &ti, const Type_Conversions_State &t_conversions) const noexcept
|
||||
{
|
||||
if (!bvs.empty())
|
||||
{
|
||||
@ -199,7 +199,7 @@ namespace chaiscript
|
||||
return std::vector<Type_Info>(begin, end);
|
||||
}
|
||||
|
||||
bool operator==(const Proxy_Function_Base &f) const override
|
||||
bool operator==(const Proxy_Function_Base &f) const noexcept override
|
||||
{
|
||||
const Dynamic_Object_Constructor *dc = dynamic_cast<const Dynamic_Object_Constructor*>(&f);
|
||||
return (dc != nullptr) && dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func);
|
||||
|
||||
@ -70,7 +70,7 @@ namespace chaiscript
|
||||
update_has_types();
|
||||
}
|
||||
|
||||
bool operator==(const Param_Types &t_rhs) const
|
||||
bool operator==(const Param_Types &t_rhs) const noexcept
|
||||
{
|
||||
return m_types == t_rhs.m_types;
|
||||
}
|
||||
@ -114,7 +114,7 @@ namespace chaiscript
|
||||
|
||||
// first result: is a match
|
||||
// second result: needs conversions
|
||||
std::pair<bool, bool> match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const
|
||||
std::pair<bool, bool> match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const noexcept
|
||||
{
|
||||
bool needs_conversion = false;
|
||||
|
||||
@ -158,7 +158,7 @@ namespace chaiscript
|
||||
return std::make_pair(true, needs_conversion);
|
||||
}
|
||||
|
||||
const std::vector<std::pair<std::string, Type_Info>> &types() const
|
||||
const std::vector<std::pair<std::string, Type_Info>> &types() const noexcept
|
||||
{
|
||||
return m_types;
|
||||
}
|
||||
@ -210,14 +210,14 @@ namespace chaiscript
|
||||
/// if the function is variadic or takes no arguments (arity of 0 or -1), the returned
|
||||
/// value contains exactly 1 Type_Info object: the return type
|
||||
/// \returns the types of all parameters.
|
||||
const std::vector<Type_Info> &get_param_types() const { return m_types; }
|
||||
const std::vector<Type_Info> &get_param_types() const noexcept { return m_types; }
|
||||
|
||||
virtual bool operator==(const Proxy_Function_Base &) const = 0;
|
||||
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const = 0;
|
||||
|
||||
virtual bool is_attribute_function() const { return false; }
|
||||
virtual bool is_attribute_function() const noexcept { return false; }
|
||||
|
||||
bool has_arithmetic_param() const
|
||||
bool has_arithmetic_param() const noexcept
|
||||
{
|
||||
return m_has_arithmetic_param;
|
||||
}
|
||||
@ -229,7 +229,7 @@ namespace chaiscript
|
||||
|
||||
//! Return true if the function is a possible match
|
||||
//! to the passed in values
|
||||
bool filter(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const
|
||||
bool filter(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const noexcept
|
||||
{
|
||||
assert(m_arity == -1 || (m_arity > 0 && static_cast<int>(vals.size()) == m_arity));
|
||||
|
||||
@ -244,12 +244,12 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
/// \returns the number of arguments the function takes or -1 if it is variadic
|
||||
int get_arity() const
|
||||
int get_arity() const noexcept
|
||||
{
|
||||
return m_arity;
|
||||
}
|
||||
|
||||
static bool compare_type_to_param(const Type_Info &ti, const Boxed_Value &bv, const Type_Conversions_State &t_conversions)
|
||||
static bool compare_type_to_param(const Type_Info &ti, const Boxed_Value &bv, const Type_Conversions_State &t_conversions) noexcept
|
||||
{
|
||||
if (ti.is_undef()
|
||||
|| ti.bare_equal(user_type<Boxed_Value>())
|
||||
@ -292,7 +292,7 @@ namespace chaiscript
|
||||
|
||||
|
||||
static bool compare_types(const std::vector<Type_Info> &tis, const std::vector<Boxed_Value> &bvs,
|
||||
const Type_Conversions_State &t_conversions)
|
||||
const Type_Conversions_State &t_conversions) noexcept
|
||||
{
|
||||
if (tis.size() - 1 != bvs.size())
|
||||
{
|
||||
@ -358,7 +358,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
|
||||
bool operator==(const Proxy_Function_Base &rhs) const override
|
||||
bool operator==(const Proxy_Function_Base &rhs) const noexcept override
|
||||
{
|
||||
const Dynamic_Proxy_Function *prhs = dynamic_cast<const Dynamic_Proxy_Function *>(&rhs);
|
||||
|
||||
@ -369,7 +369,7 @@ namespace chaiscript
|
||||
&& this->m_param_types == prhs->m_param_types);
|
||||
}
|
||||
|
||||
bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const noexcept override
|
||||
{
|
||||
return call_match_internal(vals, t_conversions).first;
|
||||
}
|
||||
@ -380,7 +380,7 @@ namespace chaiscript
|
||||
return m_guard;
|
||||
}
|
||||
|
||||
bool has_parse_tree() const {
|
||||
bool has_parse_tree() const noexcept {
|
||||
return static_cast<bool>(m_parsenode);
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ namespace chaiscript
|
||||
|
||||
// first result: is a match
|
||||
// second result: needs conversions
|
||||
std::pair<bool, bool> call_match_internal(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const
|
||||
std::pair<bool, bool> call_match_internal(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const noexcept
|
||||
{
|
||||
const auto comparison_result = [&](){
|
||||
if (m_arity < 0) {
|
||||
@ -528,7 +528,7 @@ namespace chaiscript
|
||||
assert(m_f->get_arity() < 0 || m_f->get_arity() == static_cast<int>(m_args.size()));
|
||||
}
|
||||
|
||||
bool operator==(const Proxy_Function_Base &t_f) const override
|
||||
bool operator==(const Proxy_Function_Base &t_f) const noexcept override
|
||||
{
|
||||
return &t_f == this;
|
||||
}
|
||||
@ -620,13 +620,13 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const noexcept override
|
||||
{
|
||||
return static_cast<int>(vals.size()) == get_arity()
|
||||
&& (compare_types(m_types, vals, t_conversions) && compare_types_with_cast(vals, t_conversions));
|
||||
}
|
||||
|
||||
virtual bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const = 0;
|
||||
virtual bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const noexcept = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -642,12 +642,12 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const noexcept override
|
||||
{
|
||||
return detail::compare_types_cast(static_cast<Func *>(nullptr), vals, t_conversions);
|
||||
}
|
||||
|
||||
bool operator==(const Proxy_Function_Base &t_func) const override
|
||||
bool operator==(const Proxy_Function_Base &t_func) const noexcept override
|
||||
{
|
||||
return dynamic_cast<const Proxy_Function_Callable_Impl<Func, Callable> *>(&t_func) != nullptr;
|
||||
}
|
||||
@ -686,12 +686,12 @@ namespace chaiscript
|
||||
assert(!m_shared_ptr_holder || m_shared_ptr_holder.get() == &m_f.get());
|
||||
}
|
||||
|
||||
bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const override
|
||||
bool compare_types_with_cast(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &t_conversions) const noexcept override
|
||||
{
|
||||
return detail::compare_types_cast(static_cast<Func *>(nullptr), vals, t_conversions);
|
||||
}
|
||||
|
||||
bool operator==(const Proxy_Function_Base &t_func) const override
|
||||
bool operator==(const Proxy_Function_Base &t_func) const noexcept override
|
||||
{
|
||||
return dynamic_cast<const Assignable_Proxy_Function_Impl<Func> *>(&t_func) != nullptr;
|
||||
}
|
||||
@ -729,9 +729,9 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
bool is_attribute_function() const override { return true; }
|
||||
bool is_attribute_function() const noexcept override { return true; }
|
||||
|
||||
bool operator==(const Proxy_Function_Base &t_func) const override
|
||||
bool operator==(const Proxy_Function_Base &t_func) const noexcept override
|
||||
{
|
||||
const Attribute_Access<T, Class> * aa
|
||||
= dynamic_cast<const Attribute_Access<T, Class> *>(&t_func);
|
||||
@ -743,7 +743,7 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &) const override
|
||||
bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions_State &) const noexcept override
|
||||
{
|
||||
if (vals.size() != 1)
|
||||
{
|
||||
@ -841,7 +841,7 @@ namespace chaiscript
|
||||
{
|
||||
template<typename FuncType>
|
||||
bool types_match_except_for_arithmetic(const FuncType &t_func, const std::vector<Boxed_Value> &plist,
|
||||
const Type_Conversions_State &t_conversions)
|
||||
const Type_Conversions_State &t_conversions) noexcept
|
||||
{
|
||||
const std::vector<Type_Info> &types = t_func->get_param_types();
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ namespace chaiscript
|
||||
*/
|
||||
template<typename Ret, typename ... Params>
|
||||
bool compare_types_cast(Ret (*)(Params...),
|
||||
const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions)
|
||||
const std::vector<Boxed_Value> ¶ms, const Type_Conversions_State &t_conversions) noexcept
|
||||
{
|
||||
try {
|
||||
std::vector<Boxed_Value>::size_type i = 0;
|
||||
|
||||
@ -87,16 +87,16 @@ namespace chaiscript
|
||||
virtual Boxed_Value convert(const Boxed_Value &from) const = 0;
|
||||
virtual Boxed_Value convert_down(const Boxed_Value &to) const = 0;
|
||||
|
||||
const Type_Info &to() const
|
||||
const Type_Info &to() const noexcept
|
||||
{
|
||||
return m_to;
|
||||
}
|
||||
const Type_Info &from() const
|
||||
const Type_Info &from() const noexcept
|
||||
{
|
||||
return m_from;
|
||||
}
|
||||
|
||||
virtual bool bidir() const
|
||||
virtual bool bidir() const noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -272,7 +272,7 @@ namespace chaiscript
|
||||
"Unable to cast down inheritance hierarchy with non-polymorphic types");
|
||||
}
|
||||
|
||||
bool bidir() const override
|
||||
bool bidir() const noexcept override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -306,7 +306,7 @@ namespace chaiscript
|
||||
return m_func(t_from);
|
||||
}
|
||||
|
||||
bool bidir() const override
|
||||
bool bidir() const noexcept override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -328,7 +328,7 @@ namespace chaiscript
|
||||
|
||||
struct Less_Than
|
||||
{
|
||||
bool operator()(const std::type_info *t_lhs, const std::type_info *t_rhs) const
|
||||
bool operator()(const std::type_info *t_lhs, const std::type_info *t_rhs) const noexcept
|
||||
{
|
||||
return *t_lhs != *t_rhs && t_lhs->before(*t_rhs);
|
||||
}
|
||||
|
||||
@ -46,49 +46,49 @@ namespace chaiscript
|
||||
|
||||
Type_Info() = default;
|
||||
|
||||
bool operator<(const Type_Info &ti) const
|
||||
bool operator<(const Type_Info &ti) const noexcept
|
||||
{
|
||||
return m_type_info < ti.m_type_info;
|
||||
}
|
||||
|
||||
bool operator!=(const Type_Info &ti) const
|
||||
bool operator!=(const Type_Info &ti) const noexcept
|
||||
{
|
||||
return !(operator==(ti));
|
||||
}
|
||||
|
||||
bool operator!=(const std::type_info &ti) const
|
||||
bool operator!=(const std::type_info &ti) const noexcept
|
||||
{
|
||||
return !(operator==(ti));
|
||||
}
|
||||
|
||||
bool operator==(const Type_Info &ti) const
|
||||
bool operator==(const Type_Info &ti) const noexcept
|
||||
{
|
||||
return ti.m_type_info == m_type_info
|
||||
|| *ti.m_type_info == *m_type_info;
|
||||
}
|
||||
|
||||
bool operator==(const std::type_info &ti) const
|
||||
bool operator==(const std::type_info &ti) const noexcept
|
||||
{
|
||||
return !is_undef() && (*m_type_info) == ti;
|
||||
}
|
||||
|
||||
bool bare_equal(const Type_Info &ti) const
|
||||
bool bare_equal(const Type_Info &ti) const noexcept
|
||||
{
|
||||
return ti.m_bare_type_info == m_bare_type_info
|
||||
|| *ti.m_bare_type_info == *m_bare_type_info;
|
||||
}
|
||||
|
||||
bool bare_equal_type_info(const std::type_info &ti) const
|
||||
bool bare_equal_type_info(const std::type_info &ti) const noexcept
|
||||
{
|
||||
return !is_undef() && (*m_bare_type_info) == ti;
|
||||
}
|
||||
|
||||
bool is_const() const { return (m_flags & (1 << is_const_flag)) != 0; }
|
||||
bool is_reference() const { return (m_flags & (1 << is_reference_flag)) != 0; }
|
||||
bool is_void() const { return (m_flags & (1 << is_void_flag)) != 0; }
|
||||
bool is_arithmetic() const { return (m_flags & (1 << is_arithmetic_flag)) != 0; }
|
||||
bool is_undef() const { return (m_flags & (1 << is_undef_flag)) != 0; }
|
||||
bool is_pointer() const { return (m_flags & (1 << is_pointer_flag)) != 0; }
|
||||
bool is_const() const noexcept { return (m_flags & (1 << is_const_flag)) != 0; }
|
||||
bool is_reference() const noexcept { return (m_flags & (1 << is_reference_flag)) != 0; }
|
||||
bool is_void() const noexcept { return (m_flags & (1 << is_void_flag)) != 0; }
|
||||
bool is_arithmetic() const noexcept { return (m_flags & (1 << is_arithmetic_flag)) != 0; }
|
||||
bool is_undef() const noexcept { return (m_flags & (1 << is_undef_flag)) != 0; }
|
||||
bool is_pointer() const noexcept { return (m_flags & (1 << is_pointer_flag)) != 0; }
|
||||
|
||||
std::string name() const
|
||||
{
|
||||
@ -110,7 +110,7 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
const std::type_info *bare_type_info() const
|
||||
const std::type_info *bare_type_info() const noexcept
|
||||
{
|
||||
return m_bare_type_info;
|
||||
}
|
||||
@ -135,7 +135,7 @@ namespace chaiscript
|
||||
template<typename T>
|
||||
struct Get_Type_Info
|
||||
{
|
||||
static Type_Info get()
|
||||
static Type_Info get() noexcept
|
||||
{
|
||||
return Type_Info(std::is_const<typename std::remove_pointer<typename std::remove_reference<T>::type>::type>::value,
|
||||
std::is_reference<T>::value, std::is_pointer<T>::value,
|
||||
@ -152,7 +152,7 @@ namespace chaiscript
|
||||
{
|
||||
// typedef T type;
|
||||
|
||||
static Type_Info get()
|
||||
static Type_Info get() noexcept
|
||||
{
|
||||
return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value,
|
||||
std::is_void<T>::value,
|
||||
@ -170,7 +170,7 @@ namespace chaiscript
|
||||
template<typename T>
|
||||
struct Get_Type_Info<const std::shared_ptr<T> &>
|
||||
{
|
||||
static Type_Info get()
|
||||
static Type_Info get() noexcept
|
||||
{
|
||||
return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value,
|
||||
std::is_void<T>::value,
|
||||
@ -183,7 +183,7 @@ namespace chaiscript
|
||||
template<typename T>
|
||||
struct Get_Type_Info<std::reference_wrapper<T> >
|
||||
{
|
||||
static Type_Info get()
|
||||
static Type_Info get() noexcept
|
||||
{
|
||||
return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value,
|
||||
std::is_void<T>::value,
|
||||
@ -196,7 +196,7 @@ namespace chaiscript
|
||||
template<typename T>
|
||||
struct Get_Type_Info<const std::reference_wrapper<T> &>
|
||||
{
|
||||
static Type_Info get()
|
||||
static Type_Info get() noexcept
|
||||
{
|
||||
return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value,
|
||||
std::is_void<T>::value,
|
||||
@ -218,7 +218,7 @@ namespace chaiscript
|
||||
/// chaiscript::Type_Info ti = chaiscript::user_type(i);
|
||||
/// \endcode
|
||||
template<typename T>
|
||||
Type_Info user_type(const T &/*t*/)
|
||||
Type_Info user_type(const T &/*t*/) noexcept
|
||||
{
|
||||
return detail::Get_Type_Info<T>::get();
|
||||
}
|
||||
@ -233,7 +233,7 @@ namespace chaiscript
|
||||
/// chaiscript::Type_Info ti = chaiscript::user_type<int>();
|
||||
/// \endcode
|
||||
template<typename T>
|
||||
Type_Info user_type()
|
||||
Type_Info user_type() noexcept
|
||||
{
|
||||
return detail::Get_Type_Info<T>::get();
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ namespace chaiscript
|
||||
return opers[static_cast<int>(t_oper)];
|
||||
}
|
||||
|
||||
static Opers to_operator(const std::string &t_str, bool t_is_unary = false)
|
||||
static Opers to_operator(const std::string &t_str, bool t_is_unary = false) noexcept
|
||||
{
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
#pragma warning(push)
|
||||
|
||||
@ -76,7 +76,7 @@ namespace chaiscript
|
||||
namespace
|
||||
{
|
||||
/// Helper lookup to get the name of each node type
|
||||
inline const char *ast_node_type_to_string(AST_Node_Type ast_node_type) {
|
||||
inline const char *ast_node_type_to_string(AST_Node_Type ast_node_type) noexcept {
|
||||
static const char * const ast_node_types[] = { "Id", "Fun_Call", "Unused_Return_Fun_Call", "Arg_List", "Equation", "Var_Decl",
|
||||
"Array_Call", "Dot_Access",
|
||||
"Lambda", "Block", "Scopeless_Block", "Def", "While", "If", "For", "Ranged_For", "Inline_Array", "Inline_Map", "Return", "File", "Prefix", "Break", "Continue", "Map_Pair", "Value_Range",
|
||||
@ -89,13 +89,13 @@ namespace chaiscript
|
||||
|
||||
/// \brief Convenience type for file positions
|
||||
struct File_Position {
|
||||
int line;
|
||||
int column;
|
||||
int line = 0;
|
||||
int column = 0;
|
||||
|
||||
File_Position(int t_file_line, int t_file_column)
|
||||
File_Position(int t_file_line, int t_file_column) noexcept
|
||||
: line(t_file_line), column(t_file_column) { }
|
||||
|
||||
File_Position() : line(0), column(0) { }
|
||||
File_Position() noexcept = default;
|
||||
};
|
||||
|
||||
struct Parse_Location {
|
||||
@ -228,7 +228,7 @@ namespace chaiscript
|
||||
private:
|
||||
|
||||
template<typename T>
|
||||
static AST_Node_Type id(const T& t)
|
||||
static AST_Node_Type id(const T& t) noexcept
|
||||
{
|
||||
return t.identifier;
|
||||
}
|
||||
@ -240,7 +240,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static const std::string &fname(const T& t)
|
||||
static const std::string &fname(const T& t) noexcept
|
||||
{
|
||||
return t.filename();
|
||||
}
|
||||
@ -497,15 +497,15 @@ namespace chaiscript
|
||||
const std::string text;
|
||||
Parse_Location location;
|
||||
|
||||
const std::string &filename() const {
|
||||
const std::string &filename() const noexcept {
|
||||
return *location.filename;
|
||||
}
|
||||
|
||||
const File_Position &start() const {
|
||||
const File_Position &start() const noexcept {
|
||||
return location.start;
|
||||
}
|
||||
|
||||
const File_Position &end() const {
|
||||
const File_Position &end() const noexcept {
|
||||
return location.end;
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
|
||||
virtual ~AST_Node() = default;
|
||||
virtual ~AST_Node() noexcept = default;
|
||||
AST_Node(AST_Node &&) = default;
|
||||
AST_Node &operator=(AST_Node &&) = default;
|
||||
AST_Node(const AST_Node &) = delete;
|
||||
@ -573,15 +573,15 @@ namespace chaiscript
|
||||
const std::string text;
|
||||
Parse_Location location;
|
||||
|
||||
const std::string &filename() const {
|
||||
const std::string &filename() const noexcept {
|
||||
return *location.filename;
|
||||
}
|
||||
|
||||
const File_Position &start() const {
|
||||
const File_Position &start() const noexcept {
|
||||
return location.start;
|
||||
}
|
||||
|
||||
const File_Position &end() const {
|
||||
const File_Position &end() const noexcept {
|
||||
return location.end;
|
||||
}
|
||||
|
||||
@ -629,7 +629,7 @@ namespace chaiscript
|
||||
ChaiScript_Parser_Base &operator=(const ChaiScript_Parser_Base &&) = delete;
|
||||
|
||||
template<typename T>
|
||||
T &get_tracer()
|
||||
T &get_tracer() noexcept
|
||||
{
|
||||
// to do type check this somehow?
|
||||
return *static_cast<T*>(get_tracer_ptr());
|
||||
|
||||
@ -124,7 +124,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
/// Returns the current evaluation m_engine
|
||||
chaiscript::detail::Dispatch_Engine &get_eval_engine() {
|
||||
chaiscript::detail::Dispatch_Engine &get_eval_engine() noexcept {
|
||||
return m_engine;
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ explicit ChaiScript_Basic(std::unique_ptr<parser::ChaiScript_Parser_Base> &&pars
|
||||
const std::vector<chaiscript::Options> &t_opts = chaiscript::default_options()) = delete;
|
||||
#endif
|
||||
|
||||
parser::ChaiScript_Parser_Base &get_parser()
|
||||
parser::ChaiScript_Parser_Base &get_parser() noexcept
|
||||
{
|
||||
return *m_parser;
|
||||
}
|
||||
|
||||
@ -667,7 +667,7 @@ namespace chaiscript
|
||||
);
|
||||
}
|
||||
|
||||
static bool has_this_capture(const std::vector<AST_Node_Impl_Ptr<T>> &children) {
|
||||
static bool has_this_capture(const std::vector<AST_Node_Impl_Ptr<T>> &children) noexcept {
|
||||
return std::any_of(std::begin(children), std::end(children),
|
||||
[](const auto &child){
|
||||
return child->children[0]->text == "this";
|
||||
|
||||
@ -30,7 +30,7 @@ namespace chaiscript {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
eval::AST_Node_Impl<T> &child_at(eval::AST_Node_Impl<T> &node, const size_t offset) {
|
||||
eval::AST_Node_Impl<T> &child_at(eval::AST_Node_Impl<T> &node, const size_t offset) noexcept {
|
||||
if (node.children[offset]->identifier == AST_Node_Type::Compiled) {
|
||||
return *(dynamic_cast<eval::Compiled_AST_Node<T> &>(*node.children[offset]).m_original_node);
|
||||
} else {
|
||||
@ -39,7 +39,7 @@ namespace chaiscript {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const eval::AST_Node_Impl<T> &child_at(const eval::AST_Node_Impl<T> &node, const size_t offset) {
|
||||
const eval::AST_Node_Impl<T> &child_at(const eval::AST_Node_Impl<T> &node, const size_t offset) noexcept {
|
||||
if (node.children[offset]->identifier == AST_Node_Type::Compiled) {
|
||||
return *(dynamic_cast<const eval::Compiled_AST_Node<T> &>(*node.children[offset]).m_original_node);
|
||||
} else {
|
||||
@ -57,7 +57,7 @@ namespace chaiscript {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto child_count(const eval::AST_Node_Impl<T> &node) {
|
||||
auto child_count(const eval::AST_Node_Impl<T> &node) noexcept {
|
||||
if (node.identifier == AST_Node_Type::Compiled) {
|
||||
return dynamic_cast<const eval::Compiled_AST_Node<T>&>(node).m_original_node->children.size();
|
||||
} else {
|
||||
@ -95,7 +95,7 @@ namespace chaiscript {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
bool contains_var_decl_in_scope(const eval::AST_Node_Impl<T> &node)
|
||||
bool contains_var_decl_in_scope(const eval::AST_Node_Impl<T> &node) noexcept
|
||||
{
|
||||
if (node.identifier == AST_Node_Type::Var_Decl) {
|
||||
return true;
|
||||
|
||||
@ -120,11 +120,11 @@ namespace chaiscript
|
||||
|
||||
template<typename Tracer, typename Optimizer>
|
||||
class ChaiScript_Parser final : public ChaiScript_Parser_Base {
|
||||
void *get_tracer_ptr() override {
|
||||
void *get_tracer_ptr() noexcept override {
|
||||
return &m_tracer;
|
||||
}
|
||||
|
||||
static std::array<std::array<bool, detail::lengthof_alphabet>, detail::max_alphabet> build_alphabet()
|
||||
static std::array<std::array<bool, detail::lengthof_alphabet>, detail::max_alphabet> build_alphabet() noexcept
|
||||
{
|
||||
std::array<std::array<bool, detail::lengthof_alphabet>, detail::max_alphabet> alphabet;
|
||||
|
||||
@ -185,7 +185,7 @@ namespace chaiscript
|
||||
return alphabet;
|
||||
}
|
||||
|
||||
static const std::array<std::array<bool, detail::lengthof_alphabet>, detail::max_alphabet> &create_alphabet()
|
||||
static const std::array<std::array<bool, detail::lengthof_alphabet>, detail::max_alphabet> &create_alphabet() noexcept
|
||||
{
|
||||
static const auto alpha = build_alphabet();
|
||||
return alpha;
|
||||
@ -213,7 +213,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
|
||||
static const std::array<Operator_Precidence, 12> &create_operators() {
|
||||
static const std::array<Operator_Precidence, 12> &create_operators() noexcept {
|
||||
static const std::array<Operator_Precidence, 12> operators = { {
|
||||
Operator_Precidence::Ternary_Cond,
|
||||
Operator_Precidence::Logical_Or,
|
||||
@ -231,31 +231,31 @@ namespace chaiscript
|
||||
return operators;
|
||||
}
|
||||
|
||||
static const utility::Static_String &multiline_comment_end()
|
||||
static const utility::Static_String &multiline_comment_end() noexcept
|
||||
{
|
||||
static const utility::Static_String s("*/");
|
||||
return s;
|
||||
}
|
||||
|
||||
static const utility::Static_String &multiline_comment_begin()
|
||||
static const utility::Static_String &multiline_comment_begin() noexcept
|
||||
{
|
||||
static const utility::Static_String s("/*");
|
||||
return s;
|
||||
}
|
||||
|
||||
static const utility::Static_String &singleline_comment()
|
||||
static const utility::Static_String &singleline_comment() noexcept
|
||||
{
|
||||
static const utility::Static_String s("//");
|
||||
return s;
|
||||
}
|
||||
|
||||
static const utility::Static_String &annotation()
|
||||
static const utility::Static_String &annotation() noexcept
|
||||
{
|
||||
static const utility::Static_String s("#");
|
||||
return s;
|
||||
}
|
||||
|
||||
static const utility::Static_String &cr_lf()
|
||||
static const utility::Static_String &cr_lf() noexcept
|
||||
{
|
||||
static const utility::Static_String s("\r\n");
|
||||
return s;
|
||||
@ -271,18 +271,18 @@ namespace chaiscript
|
||||
|
||||
struct Position
|
||||
{
|
||||
Position() = default;
|
||||
Position() noexcept = default;
|
||||
|
||||
Position(std::string::const_iterator t_pos, std::string::const_iterator t_end)
|
||||
Position(std::string::const_iterator t_pos, std::string::const_iterator t_end) noexcept
|
||||
: line(1), col(1), m_pos(t_pos), m_end(t_end), m_last_col(1)
|
||||
{
|
||||
}
|
||||
|
||||
static std::string str(const Position &t_begin, const Position &t_end) {
|
||||
static std::string str(const Position &t_begin, const Position &t_end) noexcept {
|
||||
return std::string(t_begin.m_pos, t_end.m_pos);
|
||||
}
|
||||
|
||||
Position &operator++() {
|
||||
Position &operator++() noexcept {
|
||||
if (m_pos != m_end) {
|
||||
if (*m_pos == '\n') {
|
||||
++line;
|
||||
@ -296,7 +296,7 @@ namespace chaiscript
|
||||
return *this;
|
||||
}
|
||||
|
||||
Position &operator--() {
|
||||
Position &operator--() noexcept {
|
||||
--m_pos;
|
||||
if (*m_pos == '\n') {
|
||||
--line;
|
||||
@ -307,12 +307,12 @@ namespace chaiscript
|
||||
return *this;
|
||||
}
|
||||
|
||||
Position &operator+=(size_t t_distance) {
|
||||
Position &operator+=(size_t t_distance) noexcept {
|
||||
*this = (*this) + t_distance;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Position operator+(size_t t_distance) const {
|
||||
Position operator+(size_t t_distance) const noexcept {
|
||||
Position ret(*this);
|
||||
for (size_t i = 0; i < t_distance; ++i) {
|
||||
++ret;
|
||||
@ -320,12 +320,12 @@ namespace chaiscript
|
||||
return ret;
|
||||
}
|
||||
|
||||
Position &operator-=(size_t t_distance) {
|
||||
Position &operator-=(size_t t_distance) noexcept {
|
||||
*this = (*this) - t_distance;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Position operator-(size_t t_distance) const {
|
||||
Position operator-(size_t t_distance) const noexcept {
|
||||
Position ret(*this);
|
||||
for (size_t i = 0; i < t_distance; ++i) {
|
||||
--ret;
|
||||
@ -333,23 +333,23 @@ namespace chaiscript
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool operator==(const Position &t_rhs) const {
|
||||
bool operator==(const Position &t_rhs) const noexcept {
|
||||
return m_pos == t_rhs.m_pos;
|
||||
}
|
||||
|
||||
bool operator!=(const Position &t_rhs) const {
|
||||
bool operator!=(const Position &t_rhs) const noexcept {
|
||||
return m_pos != t_rhs.m_pos;
|
||||
}
|
||||
|
||||
bool has_more() const {
|
||||
bool has_more() const noexcept {
|
||||
return m_pos != m_end;
|
||||
}
|
||||
|
||||
size_t remaining() const {
|
||||
size_t remaining() const noexcept {
|
||||
return static_cast<size_t>(std::distance(m_pos, m_end));
|
||||
}
|
||||
|
||||
const char& operator*() const {
|
||||
const char& operator*() const noexcept {
|
||||
if (m_pos == m_end) {
|
||||
static const char ktmp ='\0';
|
||||
return ktmp;
|
||||
@ -387,12 +387,12 @@ namespace chaiscript
|
||||
m_match_stack.reserve(2);
|
||||
}
|
||||
|
||||
Tracer &get_tracer()
|
||||
Tracer &get_tracer() noexcept
|
||||
{
|
||||
return m_tracer;
|
||||
}
|
||||
|
||||
Optimizer &get_optimizer()
|
||||
Optimizer &get_optimizer() noexcept
|
||||
{
|
||||
return m_optimizer;
|
||||
}
|
||||
@ -403,7 +403,7 @@ namespace chaiscript
|
||||
ChaiScript_Parser &operator=(ChaiScript_Parser &&) = delete;
|
||||
|
||||
/// test a char in an m_alphabet
|
||||
bool char_in_alphabet(char c, detail::Alphabet a) const { return m_alphabet[a][static_cast<uint8_t>(c)]; }
|
||||
bool char_in_alphabet(char c, detail::Alphabet a) const noexcept { return m_alphabet[a][static_cast<uint8_t>(c)]; }
|
||||
|
||||
/// Prints the parsed ast_nodes as a tree
|
||||
void debug_print(const AST_Node &t, std::string prepend = "") const override {
|
||||
@ -461,7 +461,7 @@ namespace chaiscript
|
||||
|
||||
|
||||
/// Reads a symbol group from input if it matches the parameter, without skipping initial whitespace
|
||||
inline auto Symbol_(const utility::Static_String &sym)
|
||||
inline auto Symbol_(const utility::Static_String &sym) noexcept
|
||||
{
|
||||
const auto len = sym.size();
|
||||
if (m_position.remaining() >= len) {
|
||||
@ -549,7 +549,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
/// Reads the optional exponent (scientific notation) and suffix for a Float
|
||||
bool read_exponent_and_suffix() {
|
||||
bool read_exponent_and_suffix() noexcept {
|
||||
// Support a form of scientific notation: 1e-5, 35.5E+8, 0.01e19
|
||||
if (m_position.has_more() && (std::tolower(*m_position) == 'e')) {
|
||||
++m_position;
|
||||
@ -577,7 +577,7 @@ namespace chaiscript
|
||||
|
||||
|
||||
/// Reads a floating point value from input, without skipping initial whitespace
|
||||
bool Float_() {
|
||||
bool Float_() noexcept {
|
||||
if (m_position.has_more() && char_in_alphabet(*m_position,detail::float_alphabet) ) {
|
||||
while (m_position.has_more() && char_in_alphabet(*m_position,detail::int_alphabet) ) {
|
||||
++m_position;
|
||||
@ -605,7 +605,7 @@ namespace chaiscript
|
||||
}
|
||||
|
||||
/// Reads a hex value from input, without skipping initial whitespace
|
||||
bool Hex_() {
|
||||
bool Hex_() noexcept {
|
||||
if (m_position.has_more() && (*m_position == '0')) {
|
||||
++m_position;
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
static T cast_symbol(void *p)
|
||||
static T cast_symbol(void *p) noexcept
|
||||
{
|
||||
union cast_union
|
||||
{
|
||||
|
||||
@ -14,7 +14,7 @@ namespace chaiscript {
|
||||
struct Noop_Tracer_Detail
|
||||
{
|
||||
template<typename T>
|
||||
void trace(const chaiscript::detail::Dispatch_State &, const AST_Node_Impl<T> *)
|
||||
void trace(const chaiscript::detail::Dispatch_State &, const AST_Node_Impl<T> *) noexcept
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@ -20,7 +20,7 @@ namespace chaiscript
|
||||
{
|
||||
|
||||
|
||||
static constexpr std::uint32_t fnv1a_32(const char *s, std::uint32_t h = 0x811c9dc5) {
|
||||
static constexpr std::uint32_t fnv1a_32(const char *s, std::uint32_t h = 0x811c9dc5) noexcept {
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
|
||||
@ -50,32 +50,32 @@ class JSON
|
||||
|
||||
struct QuickFlatMap
|
||||
{
|
||||
auto find(const std::string &s) {
|
||||
auto find(const std::string &s) noexcept {
|
||||
return std::find_if(std::begin(data), std::end(data), [&s](const auto &d) { return d.first == s; });
|
||||
}
|
||||
|
||||
auto find(const std::string &s) const {
|
||||
auto find(const std::string &s) const noexcept {
|
||||
return std::find_if(std::begin(data), std::end(data), [&s](const auto &d) { return d.first == s; });
|
||||
}
|
||||
|
||||
auto size() const {
|
||||
auto size() const noexcept {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
auto begin() const {
|
||||
auto begin() const noexcept {
|
||||
return data.begin();
|
||||
}
|
||||
|
||||
auto end() const {
|
||||
auto end() const noexcept {
|
||||
return data.end();
|
||||
}
|
||||
|
||||
|
||||
auto begin() {
|
||||
auto begin() noexcept {
|
||||
return data.begin();
|
||||
}
|
||||
|
||||
auto end() {
|
||||
auto end() noexcept {
|
||||
return data.end();
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ class JSON
|
||||
}
|
||||
}
|
||||
|
||||
size_t count(const std::string &s) const {
|
||||
size_t count(const std::string &s) const noexcept {
|
||||
return (find(s) != data.end())?1:0;
|
||||
}
|
||||
|
||||
@ -224,8 +224,8 @@ class JSON
|
||||
JSONConstWrapper( const Container *val ) : object( val ) {}
|
||||
JSONConstWrapper( std::nullptr_t ) {}
|
||||
|
||||
typename Container::const_iterator begin() const { return object ? object->begin() : typename Container::const_iterator(); }
|
||||
typename Container::const_iterator end() const { return object ? object->end() : typename Container::const_iterator(); }
|
||||
typename Container::const_iterator begin() const noexcept { return object ? object->begin() : typename Container::const_iterator(); }
|
||||
typename Container::const_iterator end() const noexcept { return object ? object->end() : typename Container::const_iterator(); }
|
||||
};
|
||||
|
||||
JSON() = default;
|
||||
@ -245,13 +245,13 @@ class JSON
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
explicit JSON( T b, typename enable_if<is_same<T,bool>::value>::type* = nullptr ) : internal( static_cast<bool>(b) ) {}
|
||||
explicit JSON( T b, typename enable_if<is_same<T,bool>::value>::type* = nullptr ) noexcept : internal( static_cast<bool>(b) ) {}
|
||||
|
||||
template <typename T>
|
||||
explicit JSON( T i, typename enable_if<is_integral<T>::value && !is_same<T,bool>::value>::type* = nullptr ) : internal( static_cast<long>(i) ) {}
|
||||
explicit JSON( T i, typename enable_if<is_integral<T>::value && !is_same<T,bool>::value>::type* = nullptr ) noexcept : internal( static_cast<long>(i) ) {}
|
||||
|
||||
template <typename T>
|
||||
explicit JSON( T f, typename enable_if<is_floating_point<T>::value>::type* = nullptr ) : internal( static_cast<double>(f) ) {}
|
||||
explicit JSON( T f, typename enable_if<is_floating_point<T>::value>::type* = nullptr ) noexcept : internal( static_cast<double>(f) ) {}
|
||||
|
||||
template <typename T>
|
||||
explicit JSON( T s, typename enable_if<is_convertible<T,std::string>::value>::type* = nullptr ) : internal( static_cast<std::string>(s) ) {}
|
||||
@ -292,7 +292,7 @@ class JSON
|
||||
}
|
||||
|
||||
|
||||
long length() const {
|
||||
long length() const noexcept {
|
||||
if( internal.Type == Class::Array ) {
|
||||
return static_cast<long>(internal.List->size());
|
||||
} else {
|
||||
@ -308,7 +308,7 @@ class JSON
|
||||
return false;
|
||||
}
|
||||
|
||||
int size() const {
|
||||
int size() const noexcept {
|
||||
if( internal.Type == Class::Object ) {
|
||||
return static_cast<int>(internal.Map->size());
|
||||
} else if( internal.Type == Class::Array ) {
|
||||
@ -329,20 +329,20 @@ class JSON
|
||||
return ok ? *internal.String : std::string("");
|
||||
}
|
||||
|
||||
double to_float() const { bool b; return to_float( b ); }
|
||||
double to_float( bool &ok ) const {
|
||||
double to_float() const noexcept { bool b; return to_float( b ); }
|
||||
double to_float( bool &ok ) const noexcept {
|
||||
ok = (internal.Type == Class::Floating);
|
||||
return ok ? internal.Float : 0.0;
|
||||
}
|
||||
|
||||
long to_int() const { bool b; return to_int( b ); }
|
||||
long to_int( bool &ok ) const {
|
||||
long to_int() const noexcept { bool b; return to_int( b ); }
|
||||
long to_int( bool &ok ) const noexcept {
|
||||
ok = (internal.Type == Class::Integral);
|
||||
return ok ? internal.Int : 0;
|
||||
}
|
||||
|
||||
bool to_bool() const { bool b; return to_bool( b ); }
|
||||
bool to_bool( bool &ok ) const {
|
||||
bool to_bool() const noexcept { bool b; return to_bool( b ); }
|
||||
bool to_bool( bool &ok ) const noexcept {
|
||||
ok = (internal.Type == Class::Boolean);
|
||||
return ok ? internal.Bool : false;
|
||||
}
|
||||
@ -447,7 +447,7 @@ class JSON
|
||||
|
||||
|
||||
struct JSONParser {
|
||||
static bool isspace(const char c)
|
||||
static bool isspace(const char c) noexcept
|
||||
{
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
// MSVC warns on these line in some circumstances
|
||||
|
||||
@ -15,16 +15,16 @@ namespace chaiscript
|
||||
struct Static_String
|
||||
{
|
||||
template<size_t N>
|
||||
Static_String(const char (&str)[N])
|
||||
Static_String(const char (&str)[N]) noexcept
|
||||
: m_size(N-1), data(&str[0])
|
||||
{
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
size_t size() const noexcept {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
const char *c_str() const {
|
||||
const char *c_str() const noexcept {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user