about summary refs log tree commit diff
path: root/src/fix-ng/primops.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-11-03T20·30+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-11-03T20·30+0000
commit0690c1c9c01dd5889dbfccf2da6cb99f5c4e151b (patch)
treec388986ad9539ecf0a238fabfec07873e553021f /src/fix-ng/primops.cc
parentff3132427839888933c3779844bf35ca9e189cb9 (diff)
* Work around problems with the ATerm library.
  The ATerm library doesn't search the heap for pointers to ATerms
  when garbage collecting.  As a result, C++ containers such as
  `map<ATerm, ATerm>' will cause pointer to be hidden from the garbage
  collector, causing crashes.  Instead, we now use ATermTables.

Diffstat (limited to 'src/fix-ng/primops.cc')
-rw-r--r--src/fix-ng/primops.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/fix-ng/primops.cc b/src/fix-ng/primops.cc
index f887d265f3..ef0fd354ef 100644
--- a/src/fix-ng/primops.cc
+++ b/src/fix-ng/primops.cc
@@ -123,7 +123,7 @@ Expr primDerivation(EvalState & state, Expr args)
 {
     Nest nest(lvlVomit, "evaluating derivation");
 
-    Attrs attrs;
+    ATermMap attrs;
     args = evalExpr(state, args);
     queryAllAttrs(args, attrs);
 
@@ -136,9 +136,11 @@ Expr primDerivation(EvalState & state, Expr args)
     Hash outHash;
     bool outHashGiven = false;
 
-    for (Attrs::iterator i = attrs.begin(); i != attrs.end(); i++) {
-        string key = i->first;
-        Expr value = i->second;
+    for (ATermList keys = attrs.keys(); !ATisEmpty(keys); 
+         keys = ATgetNext(keys))
+    {
+        string key = aterm2String(ATgetFirst(keys));
+        Expr value = attrs.get(key);
         Nest nest(lvlVomit, format("processing attribute `%1%'") % key);
 
         /* The `args' attribute is special: it supplies the
@@ -198,9 +200,9 @@ Expr primDerivation(EvalState & state, Expr args)
     msg(lvlChatty, format("instantiated `%1%' -> `%2%'")
         % drvName % drvPath);
 
-    attrs["outPath"] = ATmake("Path(<str>)", outPath.c_str());
-    attrs["drvPath"] = ATmake("Path(<str>)", drvPath.c_str());
-    attrs["type"] = ATmake("Str(\"derivation\")");
+    attrs.set("outPath", ATmake("Path(<str>)", outPath.c_str()));
+    attrs.set("drvPath", ATmake("Path(<str>)", drvPath.c_str()));
+    attrs.set("type", ATmake("Str(\"derivation\")"));
 
     return makeAttrs(attrs);
 }