about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/value-to-xml.cc
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-05-18T15·39+0200
committerclbot <clbot@tvl.fyi>2022-05-19T14·08+0000
commitd127f9bd0e7b9b2e0df2de8a2227f77c0907468d (patch)
tree68455040d88b8e0c2817601db88ede450873ff8e /third_party/nix/src/libexpr/value-to-xml.cc
parentc85291c602ac666421627d6934ebc6d5be1b93e1 (diff)
chore(3p/nix): unvendor tvix 0.1 r/4098
Nothing is using this now, and we'll likely never pick this up again,
but we learned a lot in the process.

Every now and then this breaks in some bizarre way on channel bumps
and it's just a waste of time to maintain that.

Change-Id: Idcf2f5acd4ca7070ce18d7149cbfc0d967dc0a44
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5632
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: lukegb <lukegb@tvl.fyi>
Autosubmit: tazjin <tazjin@tvl.su>
Diffstat (limited to 'third_party/nix/src/libexpr/value-to-xml.cc')
-rw-r--r--third_party/nix/src/libexpr/value-to-xml.cc184
1 files changed, 0 insertions, 184 deletions
diff --git a/third_party/nix/src/libexpr/value-to-xml.cc b/third_party/nix/src/libexpr/value-to-xml.cc
deleted file mode 100644
index 921973881f50..000000000000
--- a/third_party/nix/src/libexpr/value-to-xml.cc
+++ /dev/null
@@ -1,184 +0,0 @@
-#include "libexpr/value-to-xml.hh"
-
-#include <cstdlib>
-
-#include "libexpr/eval-inline.hh"
-#include "libutil/util.hh"
-#include "libutil/xml-writer.hh"
-
-namespace nix {
-
-static XMLAttrs singletonAttrs(const std::string& name,
-                               const std::string& value) {
-  XMLAttrs attrs;
-  attrs[name] = value;
-  return attrs;
-}
-
-static void printValueAsXML(EvalState& state, bool strict, bool location,
-                            Value& v, XMLWriter& doc, PathSet& context,
-                            PathSet& drvsSeen);
-
-static void posToXML(XMLAttrs& xmlAttrs, const Pos& pos) {
-  xmlAttrs["path"] = pos.file.value();
-  xmlAttrs["line"] = (format("%1%") % pos.line).str();
-  xmlAttrs["column"] = (format("%1%") % pos.column).str();
-}
-
-static void showAttrs(EvalState& state, bool strict, bool location,
-                      Bindings& attrs, XMLWriter& doc, PathSet& context,
-                      PathSet& drvsSeen) {
-  StringSet names;
-
-  for (auto& i : attrs) {
-    names.insert(i.second.name);
-  }
-
-  for (auto& i : names) {
-    auto& [_, a] = *attrs.find(state.symbols.Create(i));
-
-    XMLAttrs xmlAttrs;
-    xmlAttrs["name"] = i;
-    if (location && a.pos != &noPos) {
-      posToXML(xmlAttrs, *a.pos);
-    }
-
-    XMLOpenElement elem(doc, "attr", xmlAttrs);
-    printValueAsXML(state, strict, location, *a.value, doc, context, drvsSeen);
-  }
-}
-
-static void printValueAsXML(EvalState& state, bool strict, bool location,
-                            Value& v, XMLWriter& doc, PathSet& context,
-                            PathSet& drvsSeen) {
-  checkInterrupt();
-
-  if (strict) {
-    state.forceValue(v);
-  }
-
-  switch (v.type) {
-    case tInt:
-      doc.writeEmptyElement(
-          "int", singletonAttrs("value", (format("%1%") % v.integer).str()));
-      break;
-
-    case tBool:
-      doc.writeEmptyElement(
-          "bool", singletonAttrs("value", v.boolean ? "true" : "false"));
-      break;
-
-    case tString:
-      /* !!! show the context? */
-      copyContext(v, context);
-      doc.writeEmptyElement("string", singletonAttrs("value", v.string.s));
-      break;
-
-    case tPath:
-      doc.writeEmptyElement("path", singletonAttrs("value", v.path));
-      break;
-
-    case tNull:
-      doc.writeEmptyElement("null");
-      break;
-
-    case tAttrs:
-      if (state.isDerivation(v)) {
-        XMLAttrs xmlAttrs;
-
-        Bindings::iterator a =
-            v.attrs->find(state.symbols.Create("derivation"));
-
-        Path drvPath;
-        a = v.attrs->find(state.sDrvPath);
-        if (a != v.attrs->end()) {
-          if (strict) {
-            state.forceValue(*a->second.value);
-          }
-          if (a->second.value->type == tString) {
-            xmlAttrs["drvPath"] = drvPath = a->second.value->string.s;
-          }
-        }
-
-        a = v.attrs->find(state.sOutPath);
-        if (a != v.attrs->end()) {
-          if (strict) {
-            state.forceValue(*a->second.value);
-          }
-          if (a->second.value->type == tString) {
-            xmlAttrs["outPath"] = a->second.value->string.s;
-          }
-        }
-
-        XMLOpenElement _(doc, "derivation", xmlAttrs);
-
-        if (!drvPath.empty() && drvsSeen.find(drvPath) == drvsSeen.end()) {
-          drvsSeen.insert(drvPath);
-          showAttrs(state, strict, location, *v.attrs, doc, context, drvsSeen);
-        } else {
-          doc.writeEmptyElement("repeated");
-        }
-      }
-
-      else {
-        XMLOpenElement _(doc, "attrs");
-        showAttrs(state, strict, location, *v.attrs, doc, context, drvsSeen);
-      }
-
-      break;
-
-    case tList: {
-      XMLOpenElement _(doc, "list");
-      for (unsigned int n = 0; n < v.listSize(); ++n) {
-        printValueAsXML(state, strict, location, *(*v.list)[n], doc, context,
-                        drvsSeen);
-      }
-      break;
-    }
-
-    case tLambda: {
-      XMLAttrs xmlAttrs;
-      if (location) {
-        posToXML(xmlAttrs, v.lambda.fun->pos);
-      }
-      XMLOpenElement _(doc, "function", xmlAttrs);
-
-      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);
-        for (auto& i : v.lambda.fun->formals->formals) {
-          doc.writeEmptyElement("attr", singletonAttrs("name", i.name));
-        }
-      } else {
-        doc.writeEmptyElement("varpat",
-                              singletonAttrs("name", v.lambda.fun->arg));
-      }
-
-      break;
-    }
-
-    case tFloat:
-      doc.writeEmptyElement(
-          "float", singletonAttrs("value", (format("%1%") % v.fpoint).str()));
-      break;
-
-    default:
-      doc.writeEmptyElement("unevaluated");
-  }
-}
-
-void printValueAsXML(EvalState& state, bool strict, bool location, Value& v,
-                     std::ostream& out, PathSet& context) {
-  XMLWriter doc(true, out);
-  XMLOpenElement root(doc, "expr");
-  PathSet drvsSeen;
-  printValueAsXML(state, strict, location, v, doc, context, drvsSeen);
-}
-
-}  // namespace nix