diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-02T16·31+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-02T16·31+0000 |
commit | adf9a45469f55258446d383333aa2ca79cfb0536 (patch) | |
tree | 26fc7e4ac62f45385b78f468c1cbc96426c78d71 /src/fix-ng/primops.cc | |
parent | c8268ca9917061466a3448028ea524d9842e1ac9 (diff) |
* Primops: baseNameOf, toString.
Diffstat (limited to 'src/fix-ng/primops.cc')
-rw-r--r-- | src/fix-ng/primops.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/fix-ng/primops.cc b/src/fix-ng/primops.cc index f86f9eb38d7b..7d060124b74c 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); +} |