mirror of
https://github.com/NixOS/nix
synced 2025-06-25 14:51:16 +02:00
Simplify inherited attribute handling
This reduces the difference between inherited and non-inherited attribute handling to the choice of which env to use (in recs and lets) by setting the AttrDef::e to a new ExprVar in the parser rather than carrying a separate AttrDef::v VarRef member. As an added bonus, this allows inherited attributes that inherit from a with to delay forcing evaluation of the with's attributes. Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
parent
6cd6ce5608
commit
afc6c1bad6
7 changed files with 46 additions and 38 deletions
|
@ -230,14 +230,12 @@ void ExprAttrs::bindVars(const StaticEnv & env)
|
|||
newEnv.vars[i->first] = i->second.displ = displ++;
|
||||
|
||||
foreach (AttrDefs::iterator, i, attrs)
|
||||
if (i->second.inherited) i->second.var.bind(env);
|
||||
else i->second.e->bindVars(newEnv);
|
||||
i->second.e->bindVars(i->second.inherited ? env : newEnv);
|
||||
}
|
||||
|
||||
else
|
||||
foreach (AttrDefs::iterator, i, attrs)
|
||||
if (i->second.inherited) i->second.var.bind(env);
|
||||
else i->second.e->bindVars(env);
|
||||
i->second.e->bindVars(env);
|
||||
}
|
||||
|
||||
void ExprList::bindVars(const StaticEnv & env)
|
||||
|
@ -274,8 +272,7 @@ void ExprLet::bindVars(const StaticEnv & env)
|
|||
newEnv.vars[i->first] = i->second.displ = displ++;
|
||||
|
||||
foreach (ExprAttrs::AttrDefs::iterator, i, attrs->attrs)
|
||||
if (i->second.inherited) i->second.var.bind(env);
|
||||
else i->second.e->bindVars(newEnv);
|
||||
i->second.e->bindVars(i->second.inherited ? env : newEnv);
|
||||
|
||||
body->bindVars(newEnv);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue