mirror of
https://github.com/NixOS/nix
synced 2025-06-26 20:01:15 +02:00
Add isPath primop
this is added for completeness' sake since all the other possible `builtins.typeOf` results have a corresponding `builtins.is<Type>`
This commit is contained in:
parent
56f1ed5579
commit
514b3c7f83
3 changed files with 17 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue