about summary refs log tree commit diff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-11-03T18·12+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-11-03T18·12+0000
commitcb7ccb528bbaeb30d09fbb41e57ab75d3121e1bc (patch)
treed27270a2b3c6abc86f56956d906899374778f028 /src/libexpr
parent4cbd845aa491b5cf534f8c031d285fc454933868 (diff)
* string2ATerm -> overloaded toATerm.
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc8
-rw-r--r--src/libexpr/nixexpr.cc6
-rw-r--r--src/libexpr/parser.cc2
-rw-r--r--src/libexpr/parser.y9
-rw-r--r--src/libexpr/primops.cc10
5 files changed, 20 insertions, 15 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index cef346002962..d4593b5c0ec0 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -328,11 +328,11 @@ Expr evalExpr2(EvalState & state, Expr e)
         e2 = evalExpr(state, e2);
         ATerm s1, s2;
         if (matchStr(e1, s1) && matchStr(e2, s2))
-            return makeStr(string2ATerm((
-                (string) aterm2String(s1) + (string) aterm2String(s2)).c_str()));
+            return makeStr(toATerm(
+                (string) aterm2String(s1) + (string) aterm2String(s2)));
         else if (matchPath(e1, s1) && matchPath(e2, s2))
-            return makePath(string2ATerm(canonPath(
-                (string) aterm2String(s1) + "/" + (string) aterm2String(s2)).c_str()));
+            return makePath(toATerm(canonPath(
+                (string) aterm2String(s1) + "/" + (string) aterm2String(s2))));
         else throw Error("wrong argument types in `+' operator");
     }
 
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index 56e053fd7ae4..d806a9130afd 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -42,7 +42,7 @@ void ATermMap::set(ATerm key, ATerm value)
 
 void ATermMap::set(const string & key, ATerm value)
 {
-    set(string2ATerm(key.c_str()), value);
+    set(toATerm(key), value);
 }
 
 
@@ -54,7 +54,7 @@ ATerm ATermMap::get(ATerm key) const
 
 ATerm ATermMap::get(const string & key) const
 {
-    return get(string2ATerm(key.c_str()));
+    return get(toATerm(key));
 }
 
 
@@ -66,7 +66,7 @@ void ATermMap::remove(ATerm key)
 
 void ATermMap::remove(const string & key)
 {
-    remove(string2ATerm(key.c_str()));
+    remove(toATerm(key));
 }
 
 
diff --git a/src/libexpr/parser.cc b/src/libexpr/parser.cc
index 8a199c00263f..8232b0de5f4a 100644
--- a/src/libexpr/parser.cc
+++ b/src/libexpr/parser.cc
@@ -35,7 +35,7 @@ void setParseResult(ParseData * data, ATerm t)
 
 ATerm absParsedPath(ParseData * data, ATerm t)
 {
-    return string2ATerm(absPath(aterm2String(t), data->basePath).c_str());
+    return toATerm(absPath(aterm2String(t), data->basePath));
 }
     
 void parseError(ParseData * data, char * error, int line, int column)
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 8573697b634d..1f204a228009 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -31,9 +31,14 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, void * data, char * s)
     parseError(data, s, loc->first_line, loc->first_column);
 }
 
+ATerm toATerm(const char * s)
+{
+    return (ATerm) ATmakeAppl0(ATmakeAFun((char *) s, 0, ATtrue));
+}
+
 static Pos makeCurPos(YYLTYPE * loc, void * data)
 {
-    return makePos(string2ATerm(getPath(data)),
+    return makePos(toATerm(getPath(data)),
         loc->first_line, loc->first_column);
 }
 
@@ -122,7 +127,7 @@ expr_simple
   /* Let expressions `let {..., body = ...}' are just desugared
      into `(rec {..., body = ...}).body'. */
   | LET '{' binds '}'
-    { $$ = makeSelect(fixAttrs(1, $3), string2ATerm("body")); }
+    { $$ = makeSelect(fixAttrs(1, $3), toATerm("body")); }
   | REC '{' binds '}'
     { $$ = fixAttrs(1, $3); }
   | '{' binds '}'
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 830a2c095839..41b444b20d44 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -269,11 +269,11 @@ static Expr primDerivation(EvalState & state, const ATermVector & _args)
     printMsg(lvlChatty, format("instantiated `%1%' -> `%2%'")
         % drvName % drvPath);
 
-    attrs.set("outPath", makeAttrRHS(makePath(string2ATerm(outPath.c_str())), makeNoPos()));
-    attrs.set("drvPath", makeAttrRHS(makePath(string2ATerm(drvPath.c_str())), makeNoPos()));
+    attrs.set("outPath", makeAttrRHS(makePath(toATerm(outPath)), makeNoPos()));
+    attrs.set("drvPath", makeAttrRHS(makePath(toATerm(drvPath)), makeNoPos()));
     attrs.set("drvHash",
-        makeAttrRHS(makeStr(string2ATerm(((string) drvHash).c_str())), makeNoPos()));
-    attrs.set("type", makeAttrRHS(makeStr(string2ATerm("derivation")), makeNoPos()));
+        makeAttrRHS(makeStr(toATerm((string) drvHash)), makeNoPos()));
+    attrs.set("type", makeAttrRHS(makeStr(toATerm("derivation")), makeNoPos()));
 
     return makeAttrs(attrs);
 }
@@ -283,7 +283,7 @@ static Expr primDerivation(EvalState & state, const ATermVector & _args)
    following the last slash. */
 static Expr primBaseNameOf(EvalState & state, const ATermVector & args)
 {
-    return makeStr(string2ATerm(baseNameOf(evalString(state, args[0])).c_str()));
+    return makeStr(toATerm(baseNameOf(evalString(state, args[0]))));
 }