aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-03-25 19:58:11 +0100
committerGitHub <noreply@github.com>2019-03-25 19:58:11 +0100
commit5c05c238e60998b9fd276b3c4a39c860dc291200 (patch)
tree0291bf82b32516f682b438eafb0bd39047abe211 /src
parent63e7fc509628874bf60d9e436af387bfb1bc00a5 (diff)
parent514b3c7f8345cfcbbe166981214497ed9d93ae18 (diff)
Merge pull request #1828 from zimbatm/isPath
Add isPath primop
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/primops.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 6b0c55e72..39073725e 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -315,6 +315,12 @@ static void prim_isBool(EvalState & state, const Pos & pos, Value * * args, Valu
mkBool(v, args[0]->type == tBool);
}
+/* Determine whether the argument is a path. */
+static void prim_isPath(EvalState & state, const Pos & pos, Value * * args, Value & v)
+{
+ state.forceValue(*args[0]);
+ mkBool(v, args[0]->type == tPath);
+}
struct CompareValues
{
@@ -2169,6 +2175,7 @@ void EvalState::createBaseEnv()
addPrimOp("__isInt", 1, prim_isInt);
addPrimOp("__isFloat", 1, prim_isFloat);
addPrimOp("__isBool", 1, prim_isBool);
+ addPrimOp("__isPath", 1, prim_isPath);
addPrimOp("__genericClosure", 1, prim_genericClosure);
addPrimOp("abort", 1, prim_abort);
addPrimOp("__addErrorContext", 2, prim_addErrorContext);