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-05-06T16·46+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-05-06T16·46+0000
commit84ce7ac76feab6e9a5c074bd1b9550ae543d1db8 (patch)
tree6fe85234390d62dd3e712cf2169d0963e4e87af2 /src/libexpr/nixexpr.cc
parentc82782f9a5190c7489fb8e9bd6876b247b0de0bf (diff)
* Store attribute positions in the AST and report duplicate attribute
  errors with position info.
* For all positions, use the position of the first character of the
  first token, rather than the last character of the first token plus
  one.

Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r--src/libexpr/nixexpr.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index a9c83108e950..af0632a94d6e 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -58,7 +58,7 @@ void ExprAttrs::show(std::ostream & str)
     foreach (list<VarRef>::iterator, i, inherited)
         str << "inherit " << i->name << "; ";
     foreach (Attrs::iterator, i, attrs)
-        str << i->first << " = " << *i->second << "; ";
+        str << i->first << " = " << *i->second.first << "; ";
     str << "}";
 }
 
@@ -94,7 +94,7 @@ void ExprLet::show(std::ostream & str)
     foreach (list<VarRef>::iterator, i, attrs->inherited)
         str << "inherit " << i->name << "; ";
     foreach (ExprAttrs::Attrs::iterator, i, attrs->attrs)
-        str << i->first << " = " << *i->second << "; ";
+        str << i->first << " = " << *i->second.first << "; ";
     str << "in " << *body;
 }
 
@@ -138,6 +138,9 @@ std::ostream & operator << (std::ostream & str, const Pos & pos)
 }
 
 
+Pos noPos;
+
+
 /* Computing levels/displacements for variables. */
 
 void Expr::bindVars(const StaticEnv & env)
@@ -218,12 +221,12 @@ void ExprAttrs::bindVars(const StaticEnv & env)
         }
 
         foreach (ExprAttrs::Attrs::iterator, i, attrs)
-            i->second->bindVars(newEnv);
+            i->second.first->bindVars(newEnv);
     }
 
     else {
         foreach (ExprAttrs::Attrs::iterator, i, attrs)
-            i->second->bindVars(env);
+            i->second.first->bindVars(env);
 
         foreach (list<VarRef>::iterator, i, inherited)
             i->bind(env);
@@ -270,7 +273,7 @@ void ExprLet::bindVars(const StaticEnv & env)
     }
 
     foreach (ExprAttrs::Attrs::iterator, i, attrs->attrs)
-        i->second->bindVars(newEnv);
+        i->second.first->bindVars(newEnv);
     
     body->bindVars(newEnv);
 }