about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2008-01-15T04·32+0000
committerMichael Raskin <7c6f434c@mail.ru>2008-01-15T04·32+0000
commit5eb5c23447b5c2bfa097416aab340d172eb416d3 (patch)
tree195f97007d857bfa97cef03392ffc010d9a5f16a /src/libexpr/primops.cc
parent7d0f6aed59b11ef1037e7b0ee4dae1c7288ebb45 (diff)
Fixed exportBuildReferenceGraph
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 94410e2bdade..883e99ad0dfb 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -949,6 +949,20 @@ static Expr prim_unsafeDiscardStringContext(EvalState & state, const ATermVector
     return makeStr(s, PathSet());
 }
 
+static Expr prim_ExprToString ( EvalState & state, const ATermVector & args)
+{
+	return makeStr ( atPrint ( evalExpr ( state, args [ 0 ] ) ) );
+}
+
+static Expr prim_StringToExpr ( EvalState & state, const ATermVector & args)
+{
+	string s;
+	PathSet l;
+	if (! matchStr ( evalExpr ( state, args[0] ), s, l )) {
+		throw EvalError("__stringToExpr needs string argument!");
+	}
+	return toATerm ( s );
+}
 
 /*************************************************************
  * Primop registration
@@ -975,6 +989,10 @@ void EvalState::addPrimOps()
     addPrimOp("throw", 1, prim_throw);
     addPrimOp("__getEnv", 1, prim_getEnv);
     addPrimOp("__trace", 2, prim_trace);
+    
+    // Expr <-> String
+    addPrimOp("__exprToString", 1, prim_ExprToString);
+    addPrimOp("__stringToExpr", 1, prim_StringToExpr);
 
     addPrimOp("relativise", 2, prim_relativise);