From da25d80152fb6e51fe695dcd2ebaa4e00a7ee646 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 24 Aug 2006 14:03:39 +0000 Subject: [PATCH] * Strict evaluation and XML printing of lists. --- src/libexpr/eval.cc | 12 +++++++++--- src/nix-instantiate/main.cc | 8 +++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 07f53a56c..703393084 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -589,7 +589,6 @@ Expr strictEvalExpr(EvalState & state, Expr e) e = evalExpr(state, e); ATermList as; - if (matchAttrs(e, as)) { ATermList as2 = ATempty; for (ATermIterator i(as); i; ++i) { @@ -599,10 +598,17 @@ Expr strictEvalExpr(EvalState & state, Expr e) } return makeAttrs(ATreverse(as2)); } - + + ATermList es; + if (matchList(e, es)) { + ATermList es2 = ATempty; + for (ATermIterator i(es); i; ++i) + es2 = ATinsert(es2, strictEvalExpr(state, *i)); + return makeList(ATreverse(es2)); + } + ATermList formals; ATerm body, pos; - if (matchFunction(e, formals, body, pos)) { ATermList formals2 = ATempty; diff --git a/src/nix-instantiate/main.cc b/src/nix-instantiate/main.cc index 5eaaf5b2a..6a0586a2d 100644 --- a/src/nix-instantiate/main.cc +++ b/src/nix-instantiate/main.cc @@ -47,7 +47,7 @@ static void printTermAsXML(Expr e, XMLWriter & doc) XMLAttrs attrs; ATerm s; int i; - ATermList as, formals; + ATermList as, es, formals; ATerm body, pos; if (matchStr(e, s)) @@ -84,6 +84,12 @@ static void printTermAsXML(Expr e, XMLWriter & doc) } } + else if (matchList(e, es)) { + XMLOpenElement _(doc, "list"); + for (ATermIterator i(es); i; ++i) + printTermAsXML(*i, doc); + } + else if (matchFunction(e, formals, body, pos)) { XMLOpenElement _(doc, "function");