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-14T23·25+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-04-14T23·25+0000
commitd39d3c6264707c466b21dfadd4d48653842a9156 (patch)
treeaf53c72ecf169d82bd501d49b71e8635b35252bd /src/libexpr/nixexpr.cc
parent267dc693d2ca8dea13199f92c265fc35fdb047f6 (diff)
* Implemented inherit.
Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r--src/libexpr/nixexpr.cc26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index 03b849a3897f..3dfbddf5b89f 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -55,8 +55,8 @@ void ExprAttrs::show(std::ostream & str)
 {
     if (recursive) str << "rec ";
     str << "{ ";
-    foreach (list<Symbol>::iterator, i, inherited)
-        str << "inherit " << *i << "; ";
+    foreach (list<VarRef>::iterator, i, inherited)
+        str << "inherit " << i->name << "; ";
     foreach (Attrs::iterator, i, attrs)
         str << i->first << " = " << *i->second << "; ";
     str << "}";
@@ -91,8 +91,8 @@ void ExprLambda::show(std::ostream & str)
 void ExprLet::show(std::ostream & str)
 {
     str << "let ";
-    foreach (list<Symbol>::iterator, i, attrs->inherited)
-        str << "inherit " << *i << "; ";
+    foreach (list<VarRef>::iterator, i, attrs->inherited)
+        str << "inherit " << i->name << "; ";
     foreach (ExprAttrs::Attrs::iterator, i, attrs->attrs)
         str << i->first << " = " << *i->second << "; ";
     str << "in " << *body;
@@ -212,16 +212,22 @@ void ExprAttrs::bindVars(const StaticEnv & env)
         foreach (ExprAttrs::Attrs::iterator, i, attrs)
             newEnv.vars[i->first] = displ++;
 
-        foreach (list<Symbol>::iterator, i, inherited)
-            newEnv.vars[*i] = displ++;
+        foreach (list<VarRef>::iterator, i, inherited) {
+            newEnv.vars[i->name] = displ++;
+            i->bind(env);
+        }
 
         foreach (ExprAttrs::Attrs::iterator, i, attrs)
             i->second->bindVars(newEnv);
     }
 
-    else
+    else {
         foreach (ExprAttrs::Attrs::iterator, i, attrs)
             i->second->bindVars(env);
+
+        foreach (list<VarRef>::iterator, i, inherited)
+            i->bind(env);
+    }
 }
 
 void ExprList::bindVars(const StaticEnv & env)
@@ -258,8 +264,10 @@ void ExprLet::bindVars(const StaticEnv & env)
     foreach (ExprAttrs::Attrs::iterator, i, attrs->attrs)
         newEnv.vars[i->first] = displ++;
 
-    foreach (list<Symbol>::iterator, i, attrs->inherited)
-        newEnv.vars[*i] = displ++;
+    foreach (list<VarRef>::iterator, i, attrs->inherited) {
+        newEnv.vars[i->name] = displ++;
+        i->bind(env);
+    }
 
     foreach (ExprAttrs::Attrs::iterator, i, attrs->attrs)
         i->second->bindVars(newEnv);