summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-03-05 16:18:13 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-03-05 16:18:13 +0100
commit2caab8166045135bb78fd93dc9778a4d25d9499f (patch)
tree0fdcc3fad7963ddfcbc8fef29854dfdc2d8445c7
parentf7e077ad275a0f405b750e2b19fedbeadc6f8a15 (diff)
downloadguix-2caab8166045135bb78fd93dc9778a4d25d9499f.tar.gz
Revert "Make ifs and asserts tail-recursive"
This reverts commit 273322c7732093a354e86df82cf75d6604b8bce8.
-rw-r--r--src/libexpr/eval.cc14
-rw-r--r--src/libexpr/eval.hh1
2 files changed, 4 insertions, 11 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index b8c623b1a4..350a4fbe14 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -540,8 +540,9 @@ void EvalState::eval(Expr * e, Value & v)
 }
 
 
-inline bool EvalState::evalBool(Env & env, Expr * e, Value & v)
+inline bool EvalState::evalBool(Env & env, Expr * e)
 {
+    Value v;
     e->eval(*this, env, v);
     if (v.type != tBool)
         throwTypeError("value is %1% while a Boolean was expected", v);
@@ -549,13 +550,6 @@ inline bool EvalState::evalBool(Env & env, Expr * e, Value & v)
 }
 
 
-inline bool EvalState::evalBool(Env & env, Expr * e)
-{
-    Value v;
-    return evalBool(env, e, v);
-}
-
-
 inline void EvalState::evalAttrs(Env & env, Expr * e, Value & v)
 {
     e->eval(*this, env, v);
@@ -945,13 +939,13 @@ void ExprWith::eval(EvalState & state, Env & env, Value & v)
 
 void ExprIf::eval(EvalState & state, Env & env, Value & v)
 {
-    (state.evalBool(env, cond, v) ? then : else_)->eval(state, env, v);
+    (state.evalBool(env, cond) ? then : else_)->eval(state, env, v);
 }
 
 
 void ExprAssert::eval(EvalState & state, Env & env, Value & v)
 {
-    if (!state.evalBool(env, cond, v))
+    if (!state.evalBool(env, cond))
         throwAssertionError("assertion failed at %1%", pos);
     body->eval(state, env, v);
 }
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index 6da89c58a6..58d1318c2a 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -144,7 +144,6 @@ public:
 
     /* Evaluation the expression, then verify that it has the expected
        type. */
-    inline bool evalBool(Env & env, Expr * e, Value & v);
     inline bool evalBool(Env & env, Expr * e);
     inline void evalAttrs(Env & env, Expr * e, Value & v);