about summary refs log tree commit diff
path: root/src/libexpr/value-to-xml.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-04-12T18·30+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-04-12T18·30+0000
commit4d6ad5be1738c64b1de4274cafbd4b8f23ca287c (patch)
tree212ef4ad291875c8409d4b22c2ec07c9a1bbbacb /src/libexpr/value-to-xml.cc
parented711f73bce8786b1a37bd718eb97276d0916484 (diff)
* Don't use ATerms for the abstract syntax trees anymore. Not
  finished yet.

Diffstat (limited to 'src/libexpr/value-to-xml.cc')
-rw-r--r--src/libexpr/value-to-xml.cc43
1 files changed, 14 insertions, 29 deletions
diff --git a/src/libexpr/value-to-xml.cc b/src/libexpr/value-to-xml.cc
index eff414aba3b5..c8a067aacf77 100644
--- a/src/libexpr/value-to-xml.cc
+++ b/src/libexpr/value-to-xml.cc
@@ -1,7 +1,5 @@
 #include "value-to-xml.hh"
 #include "xml-writer.hh"
-#include "nixexpr-ast.hh"
-#include "aterm.hh"
 #include "util.hh"
 
 #include <cstdlib>
@@ -27,31 +25,10 @@ static void showAttrs(EvalState & state, bool strict, Bindings & attrs,
 {
     StringSet names;
     foreach (Bindings::iterator, i, attrs)
-        names.insert(aterm2String(i->first));
+        names.insert(i->first);
     foreach (StringSet::iterator, i, names) {
         XMLOpenElement _(doc, "attr", singletonAttrs("name", *i));
-        printValueAsXML(state, strict, attrs[toATerm(*i)], doc, context, drvsSeen);
-    }
-}
-
-
-static void printPatternAsXML(Pattern pat, XMLWriter & doc)
-{
-    ATerm name;
-    ATermList formals;
-    ATermBool ellipsis;
-    if (matchVarPat(pat, name))
-        doc.writeEmptyElement("varpat", singletonAttrs("name", aterm2String(name)));
-    else if (matchAttrsPat(pat, formals, ellipsis, name)) {
-        XMLAttrs attrs;
-        if (name != sNoAlias) attrs["name"] = aterm2String(name);
-        if (ellipsis == eTrue) attrs["ellipsis"] = "1";
-        XMLOpenElement _(doc, "attrspat", attrs);
-        for (ATermIterator i(formals); i; ++i) {
-            Expr name; ATerm dummy;
-            if (!matchFormal(*i, name, dummy)) abort();
-            doc.writeEmptyElement("attr", singletonAttrs("name", aterm2String(name)));
-        }
+        printValueAsXML(state, strict, attrs[*i], doc, context, drvsSeen);
     }
 }
 
@@ -90,14 +67,14 @@ static void printValueAsXML(EvalState & state, bool strict, Value & v,
             if (state.isDerivation(v)) {
                 XMLAttrs xmlAttrs;
             
-                Bindings::iterator a = v.attrs->find(toATerm("derivation"));
+                Bindings::iterator a = v.attrs->find("derivation");
 
                 Path drvPath;
-                a = v.attrs->find(toATerm("drvPath"));
+                a = v.attrs->find("drvPath");
                 if (a != v.attrs->end() && a->second.type == tString)
                     xmlAttrs["drvPath"] = drvPath = a->second.string.s;
         
-                a = v.attrs->find(toATerm("outPath"));
+                a = v.attrs->find("outPath");
                 if (a != v.attrs->end() && a->second.type == tString)
                     xmlAttrs["outPath"] = a->second.string.s;
 
@@ -126,7 +103,15 @@ static void printValueAsXML(EvalState & state, bool strict, Value & v,
 
         case tLambda: {
             XMLOpenElement _(doc, "function");
-            printPatternAsXML(v.lambda.pat, doc);
+            if (v.lambda.fun->matchAttrs) {
+                XMLAttrs attrs;
+                if (!v.lambda.fun->arg.empty()) attrs["name"] = v.lambda.fun->arg;
+                if (v.lambda.fun->formals->ellipsis) attrs["ellipsis"] = "1";
+                XMLOpenElement _(doc, "attrspat", attrs);
+                foreach (Formals::Formals_::iterator, i, v.lambda.fun->formals->formals)
+                    doc.writeEmptyElement("attr", singletonAttrs("name", i->name));
+            } else
+                doc.writeEmptyElement("varpat", singletonAttrs("name", v.lambda.fun->arg));
             break;
         }