diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index 1f519dc..6776e9f 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -629,14 +629,13 @@ namespace chaiscript {fun(&AST_Node::start), "start"}, {fun(&AST_Node::end), "end"}, {fun(&AST_Node::to_string), "to_string"}, - {fun(std::function (const chaiscript::AST_Node &t_node)>([](const chaiscript::AST_Node &t_node) -> std::vector { + {fun([](const chaiscript::AST_Node &t_node) -> std::vector { std::vector retval; std::transform(t_node.children.begin(), t_node.children.end(), std::back_inserter(retval), &chaiscript::var &>); return retval; - })), "children"}, - {fun(&AST_Node::replace_child), "replace_child"} + }), "children"} } ); diff --git a/include/chaiscript/language/chaiscript_common.hpp b/include/chaiscript/language/chaiscript_common.hpp index cb1266d..14b9034 100644 --- a/include/chaiscript/language/chaiscript_common.hpp +++ b/include/chaiscript/language/chaiscript_common.hpp @@ -508,11 +508,6 @@ namespace chaiscript } - void replace_child(const AST_NodePtr &t_child, const AST_NodePtr &t_new_child) - { - std::replace(children.begin(), children.end(), t_child, t_new_child); - } - virtual ~AST_Node() = default; AST_Node(AST_Node &&) = default; AST_Node &operator=(AST_Node &&) = default; diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index bc00f7a..84f25bc 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -619,16 +619,14 @@ namespace chaiscript std::string errstring; - for (std::vector::const_iterator itr = errors.begin(); - itr != errors.end(); - ++itr) + for (const auto &err : errors) { if (!errstring.empty()) { errstring += "; "; } - errstring += itr->what(); + errstring += err.what(); } throw chaiscript::exception::load_module_error("Unable to find module: " + t_module_name + " Errors: " + errstring); @@ -668,14 +666,7 @@ namespace chaiscript /// \throw chaiscript::exception::eval_error In the case that evaluation fails. Boxed_Value operator()(const std::string &t_script, const Exception_Handler &t_handler = Exception_Handler()) { - try { - return do_eval(t_script); - } catch (Boxed_Value &bv) { - if (t_handler) { - t_handler->handle(bv, m_engine); - } - throw; - } + return eval(t_script, t_handler); } /// \brief Evaluates a string and returns a typesafe result. @@ -694,14 +685,7 @@ namespace chaiscript template T eval(const std::string &t_input, const Exception_Handler &t_handler = Exception_Handler(), const std::string &t_filename="__EVAL__") { - try { - return m_engine.boxed_cast(do_eval(t_input, t_filename)); - } catch (Boxed_Value &bv) { - if (t_handler) { - t_handler->handle(bv, m_engine); - } - throw; - } + return m_engine.boxed_cast(eval(t_input, t_handler, t_filename)); } /// \brief casts an object while applying any Dynamic_Conversion available @@ -740,14 +724,7 @@ namespace chaiscript /// \return result of the script execution /// \throw chaiscript::exception::eval_error In the case that evaluation fails. Boxed_Value eval_file(const std::string &t_filename, const Exception_Handler &t_handler = Exception_Handler()) { - try { - return do_eval(load_file(t_filename), t_filename); - } catch (Boxed_Value &bv) { - if (t_handler) { - t_handler->handle(bv, m_engine); - } - throw; - } + return eval(load_file(t_filename), t_handler, t_filename); } /// \brief Loads the file specified by filename, evaluates it, and returns the type safe result. @@ -760,14 +737,7 @@ namespace chaiscript /// to the requested type. template T eval_file(const std::string &t_filename, const Exception_Handler &t_handler = Exception_Handler()) { - try { - return m_engine.boxed_cast(do_eval(load_file(t_filename), t_filename)); - } catch (Boxed_Value &bv) { - if (t_handler) { - t_handler->handle(bv, m_engine); - } - throw; - } + return m_engine.boxed_cast(eval_file(t_filename, t_handler)); } };