about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 02df4a4a325a..3334e4bbded8 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -176,6 +176,16 @@ Path evalPath(EvalState & state, Expr e)
 }
 
 
+int evalInt(EvalState & state, Expr e)
+{
+    e = evalExpr(state, e);
+    int i;
+    if (!matchInt(e, i))
+        throw TypeError(format("value is %1% while an integer was expected") % showType(e));
+    return i;
+}
+
+
 bool evalBool(EvalState & state, Expr e)
 {
     e = evalExpr(state, e);