about summary refs log tree commit diff
path: root/src/fix-ng/primops.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/fix-ng/primops.cc')
-rw-r--r--src/fix-ng/primops.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/fix-ng/primops.cc b/src/fix-ng/primops.cc
index f86f9eb38d..7d060124b7 100644
--- a/src/fix-ng/primops.cc
+++ b/src/fix-ng/primops.cc
@@ -204,3 +204,22 @@ Expr primDerivation(EvalState & state, Expr args)
 
     return makeAttrs(attrs);
 }
+
+
+Expr primBaseNameOf(EvalState & state, Expr arg)
+{
+    string s = evalString(state, arg);
+    return ATmake("Str(<str>)", baseNameOf(s).c_str());
+}
+
+
+Expr primToString(EvalState & state, Expr arg)
+{
+    arg = evalExpr(state, arg);
+    char * s;
+    if (ATmatch(arg, "Str(<str>)", &s) ||
+        ATmatch(arg, "Path(<str>)", &s) ||
+        ATmatch(arg, "Uri(<str>)", &s))
+        return ATmake("Str(<str>)", s);
+    else throw badTerm("cannot coerce to string", arg);
+}