Fix debug/clang build issues
This commit is contained in:
@@ -231,8 +231,8 @@ namespace chaiscript
|
||||
auto pointer_sentinel(std::shared_ptr<T> &ptr) const
|
||||
{
|
||||
struct Sentinel {
|
||||
Sentinel(std::shared_ptr<T> &ptr, Data &data)
|
||||
: m_ptr(ptr), m_data(data)
|
||||
Sentinel(std::shared_ptr<T> &t_ptr, Data &data)
|
||||
: m_ptr(t_ptr), m_data(data)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1404,7 +1404,7 @@ namespace chaiscript
|
||||
static typename Container::const_iterator find_keyed_value(const Container &t_c, const Key &t_key, const size_t t_hint)
|
||||
{
|
||||
if (t_c.size() > t_hint && t_c[t_hint].first == t_key) {
|
||||
return std::next(t_c.begin(), t_hint);
|
||||
return std::next(t_c.begin(), static_cast<typename std::iterator_traits<typename Container::const_iterator>::difference_type>(t_hint));
|
||||
} else {
|
||||
return find_keyed_value(t_c, t_key);
|
||||
}
|
||||
|
@@ -26,30 +26,31 @@ struct AST_Node;
|
||||
|
||||
namespace chaiscript
|
||||
{
|
||||
static bool is_reserved_word(const std::string &name)
|
||||
{
|
||||
static const std::set<std::string> m_reserved_words
|
||||
= {"def", "fun", "while", "for", "if", "else", "&&", "||", ",", "auto",
|
||||
"return", "break", "true", "false", "class", "attr", "var", "global", "GLOBAL", "_"};
|
||||
return m_reserved_words.count(name) > 0;
|
||||
}
|
||||
|
||||
static bool valid_object_name(const std::string &name)
|
||||
{
|
||||
return name.find("::") == std::string::npos && !is_reserved_word(name);
|
||||
}
|
||||
|
||||
static void validate_object_name(const std::string &name)
|
||||
{
|
||||
if (is_reserved_word(name)) {
|
||||
throw exception::reserved_word_error(name);
|
||||
struct Name_Validator {
|
||||
static bool is_reserved_word(const std::string &name)
|
||||
{
|
||||
static const std::set<std::string> m_reserved_words
|
||||
= {"def", "fun", "while", "for", "if", "else", "&&", "||", ",", "auto",
|
||||
"return", "break", "true", "false", "class", "attr", "var", "global", "GLOBAL", "_"};
|
||||
return m_reserved_words.count(name) > 0;
|
||||
}
|
||||
|
||||
if (name.find("::") != std::string::npos) {
|
||||
throw exception::illegal_name_error(name);
|
||||
static bool valid_object_name(const std::string &name)
|
||||
{
|
||||
return name.find("::") == std::string::npos && !is_reserved_word(name);
|
||||
}
|
||||
}
|
||||
|
||||
static void validate_object_name(const std::string &name)
|
||||
{
|
||||
if (is_reserved_word(name)) {
|
||||
throw exception::reserved_word_error(name);
|
||||
}
|
||||
|
||||
if (name.find("::") != std::string::npos) {
|
||||
throw exception::illegal_name_error(name);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/// Signature of module entry point that all binary loadable modules must implement.
|
||||
typedef ModulePtr (*Create_Module_Func)();
|
||||
@@ -577,7 +578,7 @@ namespace chaiscript
|
||||
T &get_tracer()
|
||||
{
|
||||
// to do type check this somehow?
|
||||
return static_cast<T&>(*get_tracer_ptr());
|
||||
return *static_cast<T*>(get_tracer_ptr());
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@@ -387,7 +387,7 @@ namespace chaiscript
|
||||
/// \sa Boxed_Value::is_const
|
||||
ChaiScript &add_global_const(const Boxed_Value &t_bv, const std::string &t_name)
|
||||
{
|
||||
validate_object_name(t_name);
|
||||
Name_Validator::validate_object_name(t_name);
|
||||
m_engine.add_global_const(t_bv, t_name);
|
||||
return *this;
|
||||
}
|
||||
@@ -399,14 +399,14 @@ namespace chaiscript
|
||||
/// ChaiScript is thread-safe but provides no threading locking mechanism to the script
|
||||
ChaiScript &add_global(const Boxed_Value &t_bv, const std::string &t_name)
|
||||
{
|
||||
validate_object_name(t_name);
|
||||
Name_Validator::validate_object_name(t_name);
|
||||
m_engine.add_global(t_bv, t_name);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ChaiScript &set_global(const Boxed_Value &t_bv, const std::string &t_name)
|
||||
{
|
||||
validate_object_name(t_name);
|
||||
Name_Validator::validate_object_name(t_name);
|
||||
m_engine.set_global(t_bv, t_name);
|
||||
return *this;
|
||||
}
|
||||
@@ -506,7 +506,7 @@ namespace chaiscript
|
||||
template<typename T>
|
||||
ChaiScript &add(const T &t_t, const std::string &t_name)
|
||||
{
|
||||
validate_object_name(t_name);
|
||||
Name_Validator::validate_object_name(t_name);
|
||||
m_engine.add(t_t, t_name);
|
||||
return *this;
|
||||
}
|
||||
|
@@ -436,7 +436,7 @@ namespace chaiscript
|
||||
Equation_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
|
||||
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Equation, std::move(t_loc), std::move(t_children)),
|
||||
m_oper(Operators::to_operator(this->text))
|
||||
{ assert(children.size() == 2); }
|
||||
{ assert(this->children.size() == 2); }
|
||||
|
||||
|
||||
Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
@@ -1011,7 +1011,7 @@ private:
|
||||
struct Case_AST_Node final : AST_Node_Impl<T> {
|
||||
Case_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
|
||||
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Case, std::move(t_loc), std::move(t_children))
|
||||
{ assert(children.size() == 2); /* how many children does it have? */ }
|
||||
{ assert(this->children.size() == 2); /* how many children does it have? */ }
|
||||
|
||||
Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||
@@ -1026,7 +1026,7 @@ private:
|
||||
struct Default_AST_Node final : AST_Node_Impl<T> {
|
||||
Default_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
|
||||
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Default, std::move(t_loc), std::move(t_children))
|
||||
{ assert(children.size() == 1); }
|
||||
{ assert(this->children.size() == 1); }
|
||||
|
||||
Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
|
||||
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||
@@ -1141,7 +1141,7 @@ private:
|
||||
struct Reference_AST_Node final : AST_Node_Impl<T> {
|
||||
Reference_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_Node_Impl_Ptr<T>> t_children) :
|
||||
AST_Node_Impl<T>(std::move(t_ast_node_text), AST_Node_Type::Reference, std::move(t_loc), std::move(t_children))
|
||||
{ assert(children.size() == 1); }
|
||||
{ assert(this->children.size() == 1); }
|
||||
|
||||
Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override{
|
||||
Boxed_Value bv;
|
||||
|
@@ -262,7 +262,7 @@ namespace chaiscript {
|
||||
} else if (lhs.get_type_info().bare_equal_type_info(typeid(bool)) && oper == "!") {
|
||||
return chaiscript::make_shared<eval::AST_Node_Impl<T>, eval::Constant_AST_Node<T>>(std::move(match), node->location, Boxed_Value(!boxed_cast<bool>(lhs)));
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
} catch (const std::exception &) {
|
||||
//failure to fold, that's OK
|
||||
}
|
||||
} else if ((node->identifier == AST_Node_Type::Logical_And || node->identifier == AST_Node_Type::Logical_Or)
|
||||
|
@@ -113,7 +113,7 @@ namespace chaiscript
|
||||
|
||||
template<typename Tracer, typename Optimizer>
|
||||
class ChaiScript_Parser final : public ChaiScript_Parser_Base {
|
||||
void *get_tracer_ptr() {
|
||||
void *get_tracer_ptr() override {
|
||||
return &m_tracer;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace chaiscript
|
||||
|
||||
void validate_object_name(const std::string &name) const
|
||||
{
|
||||
if (!valid_object_name(name)) {
|
||||
if (!Name_Validator::valid_object_name(name)) {
|
||||
throw exception::eval_error("Invalid Object Name: " + name, File_Position(m_position.line, m_position.col), *m_filename);
|
||||
}
|
||||
}
|
||||
@@ -2256,8 +2256,8 @@ namespace chaiscript
|
||||
build_match<eval::Logical_Or_AST_Node<Tracer>>(prev_stack_top, oper);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw exception::eval_error("Internal error: unhandled ast_node", File_Position(m_position.line, m_position.col), *m_filename);
|
||||
// default:
|
||||
// throw exception::eval_error("Internal error: unhandled ast_node", File_Position(m_position.line, m_position.col), *m_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user