about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-04-14T15·01+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-04-14T15·01+0000
commit110d1557782fac4f8cafa27e5cbbcdebefb7a4c7 (patch)
tree4ddae428d11619534363f4e9be8dc10e35e7e5ce /src/libexpr/nixexpr.cc
parent9985230c00226826949473c3862c0c3afea74aaf (diff)
* Implemented withs.
Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r--src/libexpr/nixexpr.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index 46cbb48ac5e5..ab4fa6cba3cb 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -264,6 +264,18 @@ void ExprLet::bindVars(const StaticEnv & env)
 
 void ExprWith::bindVars(const StaticEnv & env)
 {
+    /* Does this `with' have an enclosing `with'?  If so, record its
+       level so that we can copy the attributes of the enclosing
+       `with'. */
+    const StaticEnv * curEnv;
+    unsigned int level;
+    prevWith = -1;
+    for (curEnv = &env, level = 0; curEnv; curEnv = curEnv->up, level++)
+        if (curEnv->isWith) {
+            prevWith = level;
+            break;
+        }
+    
     attrs->bindVars(env);    
     StaticEnv newEnv(true, &env);
     body->bindVars(newEnv);