1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

* 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.
This commit is contained in:
Eelco Dolstra 2010-05-06 16:46:48 +00:00
parent c82782f9a5
commit 84ce7ac76f
6 changed files with 56 additions and 56 deletions

View file

@ -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);
}