about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libexpr/get-drvs.cc45
-rw-r--r--src/nix-env/nix-env.cc31
2 files changed, 38 insertions, 38 deletions
diff --git a/src/libexpr/get-drvs.cc b/src/libexpr/get-drvs.cc
index 5ff77ff656..93f559cacb 100644
--- a/src/libexpr/get-drvs.cc
+++ b/src/libexpr/get-drvs.cc
@@ -17,14 +17,12 @@ string DrvInfo::queryDrvPath(EvalState & state) const
 }
 
 
-#if 0
 string DrvInfo::queryOutPath(EvalState & state) const
 {
     if (outPath == "") {
-        Expr a = attrs->get(toATerm("outPath"));
-        if (!a) throw TypeError("output path missing");
+        Bindings::iterator i = attrs->find(toATerm("outPath"));
         PathSet context;
-        (string &) outPath = coerceToPath(state, a, context);
+        (string &) outPath = i != attrs->end() ? state.coerceToPath(i->second, context) : "";
     }
     return outPath;
 }
@@ -34,33 +32,26 @@ MetaInfo DrvInfo::queryMetaInfo(EvalState & state) const
 {
     MetaInfo meta;
     
-    Expr a = attrs->get(toATerm("meta"));
-    if (!a) return meta; /* fine, empty meta information */
+    Bindings::iterator a = attrs->find(toATerm("meta"));
+    if (a == attrs->end()) return meta; /* fine, empty meta information */
 
-    ATermMap attrs2;
-    queryAllAttrs(evalExpr(state, a), attrs2);
+    state.forceAttrs(a->second);
 
-    for (ATermMap::const_iterator i = attrs2.begin(); i != attrs2.end(); ++i) {
-        Expr e = evalExpr(state, i->value);
-        string s;
-        PathSet context;
+    foreach (Bindings::iterator, i, *a->second.attrs) {
         MetaValue value;
-        int n;
-        ATermList es;
-        if (matchStr(e, s, context)) {
+        state.forceValue(i->second);
+        if (i->second.type == tString) {
             value.type = MetaValue::tpString;
-            value.stringValue = s;
-            meta[aterm2String(i->key)] = value;
-        } else if (matchInt(e, n)) {
+            value.stringValue = i->second.string.s;
+        } else if (i->second.type == tInt) {
             value.type = MetaValue::tpInt;
-            value.intValue = n;
-            meta[aterm2String(i->key)] = value;
-        } else if (matchList(e, es)) {
+            value.intValue = i->second.integer;
+        } else if (i->second.type == tList) {
             value.type = MetaValue::tpStrings;
-            for (ATermIterator j(es); j; ++j)
-                value.stringValues.push_back(evalStringNoCtx(state, *j));
-            meta[aterm2String(i->key)] = value;
-        }
+            for (unsigned int j = 0; j < i->second.list.length; ++j)
+                value.stringValues.push_back(state.forceStringNoCtx(i->second.list.elems[j]));
+        } else continue;
+        meta[aterm2String(i->first)] = value;
     }
 
     return meta;
@@ -76,6 +67,8 @@ MetaValue DrvInfo::queryMetaInfo(EvalState & state, const string & name) const
 
 void DrvInfo::setMetaInfo(const MetaInfo & meta)
 {
+    throw Error("not implemented");
+#if 0
     ATermMap metaAttrs;
     foreach (MetaInfo::const_iterator, i, meta) {
         Expr e;
@@ -94,8 +87,8 @@ void DrvInfo::setMetaInfo(const MetaInfo & meta)
         metaAttrs.set(toATerm(i->first), makeAttrRHS(e, makeNoPos()));
     }
     attrs->set(toATerm("meta"), makeAttrs(metaAttrs));
-}
 #endif
+}
 
 
 /* Cache for already considered values. */
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 35caf687bf..ea85656a2b 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -164,9 +164,12 @@ static void loadDerivations(EvalState & state, Path nixExprPath,
     string systemFilter, const ATermMap & autoArgs,
     const string & pathPrefix, DrvInfos & elems)
 {
-    getDerivations(state,
-        findAlongAttrPath(state, pathPrefix, autoArgs, loadSourceExpr(state, nixExprPath)),
-        pathPrefix, autoArgs, elems);
+    Value v;
+    state.eval(loadSourceExpr(state, nixExprPath), v);
+
+    // !!! findAlongAttrPath(state, pathPrefix, autoArgs, loadSourceExpr(state, nixExprPath))
+    
+    getDerivations(state, v, pathPrefix, autoArgs, elems);
 
     /* Filter out all derivations not applicable to the current
        system. */
@@ -221,7 +224,7 @@ static DrvInfos queryInstalled(EvalState & state, const Path & userEnv)
     e = bottomupRewrite(addPos, e);
 
     DrvInfos elems;
-    getDerivations(state, e, "", ATermMap(1), elems);
+    // !!! getDerivations(state, e, "", ATermMap(1), elems);
     return elems;
 }
 
@@ -255,6 +258,8 @@ static bool createUserEnv(EvalState & state, DrvInfos & elems,
     const Path & profile, bool keepDerivations,
     const string & lockToken)
 {
+    throw Error("not implemented");
+#if 0
     /* Build the components in the user environment, if they don't
        exist already. */
     PathSet drvsToBuild;
@@ -355,6 +360,7 @@ static bool createUserEnv(EvalState & state, DrvInfos & elems,
     switchLink(profile, generation);
 
     return true;
+#endif
 }
 
 
@@ -518,12 +524,11 @@ static void queryInstSources(EvalState & state,
                 
             Expr e1 = loadSourceExpr(state, instSource.nixExprPath);
 
-            for (Strings::const_iterator i = args.begin();
-                 i != args.end(); ++i)
-            {
+            foreach (Strings::const_iterator, i, args) {
                 Expr e2 = parseExprFromString(state, *i, absPath("."));
                 Expr call = makeCall(e2, e1);
-                getDerivations(state, call, "", instSource.autoArgs, elems);
+                Value v; state.eval(call, v);
+                getDerivations(state, v, "", instSource.autoArgs, elems);
             }
             
             break;
@@ -540,7 +545,7 @@ static void queryInstSources(EvalState & state,
                 Path path = followLinksToStorePath(*i);
 
                 DrvInfo elem;
-                elem.attrs = boost::shared_ptr<ATermMap>(new ATermMap(0)); /* ugh... */
+                elem.attrs = new Bindings;
                 string name = baseNameOf(path);
                 string::size_type dash = name.find('-');
                 if (dash != string::npos)
@@ -574,12 +579,14 @@ static void queryInstSources(EvalState & state,
         }
 
         case srcAttrPath: {
-            for (Strings::const_iterator i = args.begin();
-                 i != args.end(); ++i)
+            throw Error("not implemented");
+#if 0            
+            foreach (Strings::const_iterator, i, args)
                 getDerivations(state,
                     findAlongAttrPath(state, *i, instSource.autoArgs,
                         loadSourceExpr(state, instSource.nixExprPath)),
                     "", instSource.autoArgs, elems);
+#endif
             break;
         }
     }
@@ -1472,7 +1479,7 @@ void run(Strings args)
 
     op(globals, remaining, opFlags, opArgs);
 
-    printEvalStats(globals.state);
+    globals.state.printStats();
 }