diff --git a/include/chaiscript/dispatchkit/proxy_functions.hpp b/include/chaiscript/dispatchkit/proxy_functions.hpp index 731aa7d..bb420d3 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -809,7 +809,7 @@ namespace chaiscript std::transform(tis.begin() + 1, tis.end(), plist.begin(), std::back_inserter(newplist), - [](const Type_Info &ti, const Boxed_Value ¶m) { + [](const Type_Info &ti, const Boxed_Value ¶m) -> Boxed_Value { if (ti.is_arithmetic() && param.get_type_info().is_arithmetic()) { return Boxed_Number(param).get_as(ti).bv; } else { diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 6f8442c..8d1f6e1 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -282,29 +282,6 @@ namespace chaiscript }; - struct Fun_Lookup_AST_Node : public AST_Node { - public: - Fun_Lookup_AST_Node(const std::string &t_fun_name) - : AST_Node(t_fun_name, 0, Parse_Location("")) - { - } - - virtual ~Fun_Lookup_AST_Node() {} - - virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) const CHAISCRIPT_OVERRIDE { - try { - Boxed_Value bv = t_ss.get_object(text); - t_ss.add_object(text, bv); - std::cout << " Saved fun lookup: " << text << '\n'; - return bv; - } catch (...) { - return Boxed_Value(); - } - } - }; - - - /// Used in the context of in-string ${} evals, so that no new scope is created diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index 7588d40..e39b632 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -216,28 +216,6 @@ namespace chaiscript } - static void optimize_fun_lookups(AST_NodePtr &p) - { - for (auto &c : p->children) - { - - if (c->identifier == AST_Node_Type::Def - || c->identifier == AST_Node_Type::Method - || c->identifier == AST_Node_Type::Lambda) { - std::vector children_to_add; - auto counts = count_fun_calls(c, false); - for (const auto &count : counts) { - // std::cout << " Fun Call Count: " << count.first << " " << count.second << '\n'; - if (count.second > 1) { - children_to_add.push_back(chaiscript::make_shared(count.first)); - } - } - c->children.back()->children.insert(c->children.back()->children.begin(), children_to_add.begin(), children_to_add.end()); - } - optimize_fun_lookups(c); - } - } - static void optimize_blocks(AST_NodePtr &p) { @@ -282,12 +260,11 @@ namespace chaiscript return count; } - AST_NodePtr optimized_ast(bool t_optimize_blocks = false, bool t_optimize_returns = true, bool t_optimize_fun_lookups = false) { + AST_NodePtr optimized_ast(bool t_optimize_blocks = false, bool t_optimize_returns = true) { AST_NodePtr p = m_match_stack.front(); //Note, optimize_blocks is currently broken; it breaks stack management if (t_optimize_blocks) { optimize_blocks(p); } if (t_optimize_returns) { optimize_returns(p); } - if (t_optimize_fun_lookups) { optimize_fun_lookups(p); } return p; }