From 2ab4bc44c780d2e28647f7559664675b756f38b9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 22 Sep 2006 15:29:21 +0000 Subject: * Builtin function `add' to add integers. * Put common test functions in tests/lang/lib.nix. --- src/libexpr/eval.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libexpr/eval.cc') diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 02df4a4a3..3334e4bbd 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); -- cgit v1.2.3