From c5f20ea158fdf2228d34211b6aac7682f3f71ece Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 19 Aug 2010 14:42:18 +0000 Subject: [PATCH] A little cleanup of logical and/or since those are now separate evals. --- .../chaiscript/language/chaiscript_eval.hpp | 64 +++++-------------- 1 file changed, 16 insertions(+), 48 deletions(-) diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index c70969c..4775c1e 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -276,33 +276,17 @@ namespace chaiscript catch (const bad_boxed_cast &) { throw Eval_Error("Condition not boolean"); } - if (this->children[i]->text == "&&") { - if (lhs) { - try { - retval = this->children[i+1]->eval(ss); - } - catch (Eval_Error &ee) { - ee.call_stack.push_back(this->children[i+1]); - throw; - } + if (lhs) { + try { + retval = this->children[i+1]->eval(ss); } - else { - retval = Boxed_Value(false); + catch (Eval_Error &ee) { + ee.call_stack.push_back(this->children[i+1]); + throw; } } - else if (this->children[i]->text == "||") { - if (lhs) { - retval = Boxed_Value(true); - } - else { - try { - retval = this->children[i+1]->eval(ss); - } - catch (Eval_Error &ee) { - ee.call_stack.push_back(this->children[i+1]); - throw; - } - } + else { + retval = Boxed_Value(false); } } } @@ -330,32 +314,16 @@ namespace chaiscript catch (const bad_boxed_cast &) { throw Eval_Error("Condition not boolean"); } - if (this->children[i]->text == "&&") { - if (lhs) { - try { - retval = this->children[i+1]->eval(ss); - } - catch (Eval_Error &ee) { - ee.call_stack.push_back(this->children[i+1]); - throw; - } - } - else { - retval = Boxed_Value(false); - } + if (lhs) { + retval = Boxed_Value(true); } - else if (this->children[i]->text == "||") { - if (lhs) { - retval = Boxed_Value(true); - } - else { - try { - retval = this->children[i+1]->eval(ss); - } - catch (Eval_Error &ee) { - ee.call_stack.push_back(this->children[i+1]); - throw; + else { + try { + retval = this->children[i+1]->eval(ss); } + catch (Eval_Error &ee) { + ee.call_stack.push_back(this->children[i+1]); + throw; } } }