about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-05-02T13·39+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-05-02T13·39+0000
commitdc719e6ba57fc877574bd3bc023a25676c555b3c (patch)
treec7a2351f4f0e3aa777ec2454167912ad9b5c8df7 /src/libexpr/eval.cc
parentae55e79541ffbce7a051794d6d25e9e8c7b63b2d (diff)
* Some preliminaries towards NIX-45.
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index d70ac9f76a23..384d87a269ee 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -29,6 +29,19 @@ static Expr substArgs(Expr body, ATermList formals, Expr arg)
     ATermMap subs(ATgetLength(formals) * 2);
     Expr undefined = makeUndefined();
 
+    /* ({x ? E1; y ? E2, z}: E3) {x = E4; z = E5;}
+
+       => let {x = E4; y = E2; z = E5; body = E3; }
+
+       => subst(E3, s)
+          s = {
+            R = rec {x = E4; y = E2; z = E5}
+            x -> R.x
+            y -> R.y
+            z -> R.z
+          }
+    */
+    
     /* Get the formal arguments. */
     for (ATermIterator i(formals); i; ++i) {
         Expr name, def;
@@ -278,7 +291,7 @@ Expr evalExpr2(EvalState & state, Expr e)
     if (matchVar(e, name)) {
         ATerm primOp = state.primOps.get(name);
         if (!primOp)
-            throw Error(format("impossible: undefined variable `%1%'") % name);
+            throw Error(format("impossible: undefined variable `%1%'") % aterm2String(name));
         int arity;
         ATermBlob fun;
         if (!matchPrimOpDef(primOp, arity, fun)) abort();
@@ -509,9 +522,16 @@ Expr evalFile(EvalState & state, const Path & path)
 }
 
 
+/* Yes, this is a really bad idea... */
+extern "C" {
+    unsigned long AT_calcAllocatedSize();
+}
+
 void printEvalStats(EvalState & state)
 {
-    debug(format("evaluated %1% expressions, %2% cache hits, %3%%% efficiency")
+    printMsg(lvlInfo,
+        format("evaluated %1% expressions, %2% cache hits, %3%%% efficiency, used %4% ATerm bytes")
         % state.nrEvaluated % state.nrCached
-        % ((float) state.nrCached / (float) state.nrEvaluated * 100));
+        % ((float) state.nrCached / (float) state.nrEvaluated * 100)
+        % AT_calcAllocatedSize());
 }