From 77315ae4b9cc71a7d1d9512cfdf641491b5cdd81 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 22 Jun 2017 09:32:49 -0600 Subject: [PATCH] Fix non-shared_ptr tree code --- include/chaiscript/language/chaiscript_eval.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 4388649d..3b9c7837 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -718,7 +718,7 @@ namespace chaiscript Def_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector> t_children) : AST_Node_Impl(std::move(t_ast_node_text), AST_Node_Type::Def, std::move(t_loc), std::vector>(std::make_move_iterator(t_children.begin()), - std::make_move_iterator(std::prev(t_children.end(), has_guard(t_children)?2:1))) + std::make_move_iterator(std::prev(t_children.end(), has_guard(t_children, 1)?2:1))) ), m_body_node(get_body_node(std::move(t_children))), m_guard_node(get_guard_node(std::move(t_children), t_children.size()-this->children.size()==2)) @@ -739,15 +739,15 @@ namespace chaiscript return std::move(vec.back()); } - static bool has_guard(const std::vector> &t_children) + static bool has_guard(const std::vector> &t_children, const std::size_t offset) { - if ((t_children.size() > 2) && (t_children[1]->identifier == AST_Node_Type::Arg_List)) { - if (t_children.size() > 3) { + if ((t_children.size() > 2 + offset) && (t_children[1+offset]->identifier == AST_Node_Type::Arg_List)) { + if (t_children.size() > 3 + offset) { return true; } } else { - if (t_children.size() > 2) { + if (t_children.size() > 2 + offset) { return true; } } @@ -1379,7 +1379,7 @@ namespace chaiscript Method_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector> t_children) : AST_Node_Impl(std::move(t_ast_node_text), AST_Node_Type::Method, std::move(t_loc), std::vector>(std::make_move_iterator(t_children.begin()), - std::make_move_iterator(std::prev(t_children.end(), Def_AST_Node::has_guard(t_children)?2:1))) + std::make_move_iterator(std::prev(t_children.end(), Def_AST_Node::has_guard(t_children, 1)?2:1))) ), m_body_node(Def_AST_Node::get_body_node(std::move(t_children))), m_guard_node(Def_AST_Node::get_guard_node(std::move(t_children), t_children.size()-this->children.size()==2))