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

Don't use any syntactic sugar for dynamic attrs

This doesn't change any functionality but moves some behavior out of the
parser and into the evaluator in order to simplify the code.

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy 2013-12-31 23:56:26 +00:00
parent 6f3a51809a
commit cd49fe4f9b
4 changed files with 68 additions and 128 deletions

View file

@ -155,12 +155,19 @@ std::ostream & operator << (std::ostream & str, const Pos & pos)
string showAttrPath(const AttrPath & attrPath)
{
string s;
std::ostringstream out;
bool first = true;
foreach (AttrPath::const_iterator, i, attrPath) {
if (!s.empty()) s += '.';
s += *i;
if (!first)
out << '.';
else
first = false;
if (i->symbol.set())
out << i->symbol;
else
out << "\"${" << *i->expr << "}\"";
}
return s;
return out.str();
}
@ -220,11 +227,17 @@ void ExprSelect::bindVars(const StaticEnv & env)
{
e->bindVars(env);
if (def) def->bindVars(env);
foreach (AttrPath::iterator, i, attrPath)
if (!i->symbol.set())
i->expr->bindVars(env);
}
void ExprOpHasAttr::bindVars(const StaticEnv & env)
{
e->bindVars(env);
foreach (AttrPath::iterator, i, attrPath)
if (!i->symbol.set())
i->expr->bindVars(env);
}
void ExprAttrs::bindVars(const StaticEnv & env)