From 4f5f46a2e53ddf4c26feb19edc82dd356cbbc82d Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 24 Apr 2015 22:36:22 -0600 Subject: [PATCH] Don't use scopes around arithmetic operators --- .../codeanalysis/heterogenous_array_loop.chai | 19 ++++++++++++++----- .../chaiscript/language/chaiscript_eval.hpp | 8 +++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/contrib/codeanalysis/heterogenous_array_loop.chai b/contrib/codeanalysis/heterogenous_array_loop.chai index 5c688d1..d94d53f 100644 --- a/contrib/codeanalysis/heterogenous_array_loop.chai +++ b/contrib/codeanalysis/heterogenous_array_loop.chai @@ -1,10 +1,19 @@ -var my_array=["1", 4, 6.6l, 10ul, "1000", 100, 10.9f ]; - -for (var j = 0; j < 10000; ++j) +def go() { - for (var i = 0; i < 6; ++i) + var my_array=["1", 4, 6.6l, 10ul, "1000", 100, 10.9f ]; + + var q = 0; + + for (var j = 0; j < 10000; ++j) { - to_string(my_array[i]); + for (var i = 0; i < 6; ++i) + { + to_string(my_array[i]); + } + + q += j; } } + +go(); diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 5b2b495..38c588b 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -90,9 +90,6 @@ namespace chaiscript Operators::Opers t_oper, const std::string &t_oper_string, const Boxed_Value &t_lhs, const Boxed_Value &t_rhs) const { try { - chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); - fpp.save_params({t_lhs, t_rhs}); - if (t_oper != Operators::invalid && t_lhs.get_type_info().is_arithmetic() && t_rhs.get_type_info().is_arithmetic()) { // If it's an arithmetic operation we want to short circuit dispatch @@ -103,8 +100,9 @@ namespace chaiscript } catch (...) { throw exception::eval_error("Error with numeric operator calling: " + t_oper_string); } - } else { + chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); + fpp.save_params({t_lhs, t_rhs}); chaiscript::eval::detail::Stack_Push_Pop spp(t_ss); return t_ss.call_function(t_oper_string, t_lhs, t_rhs); } @@ -1218,7 +1216,6 @@ namespace chaiscript virtual ~Prefix_AST_Node() {} virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) const CHAISCRIPT_OVERRIDE{ - chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); Boxed_Value bv(this->children[1]->eval(t_ss)); try { @@ -1227,6 +1224,7 @@ namespace chaiscript { return Boxed_Number::do_oper(m_oper, std::move(bv)); } else { + chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); chaiscript::eval::detail::Stack_Push_Pop spp(t_ss); fpp.save_params({bv}); return t_ss.call_function(this->children[0]->text, std::move(bv));