mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 07:46:21 +02:00
* Inherited attributes in recursive attribute sets are in scope of the
non-inherited attributes.
This commit is contained in:
parent
76c0e85929
commit
fbc48a469c
2 changed files with 18 additions and 10 deletions
|
@ -100,22 +100,25 @@ static Expr substArgs(Expr body, ATermList formals, Expr arg)
|
||||||
ATerm expandRec(ATerm e, ATermList rbnds, ATermList nrbnds)
|
ATerm expandRec(ATerm e, ATermList rbnds, ATermList nrbnds)
|
||||||
{
|
{
|
||||||
ATMatcher m;
|
ATMatcher m;
|
||||||
|
ATerm name;
|
||||||
|
Expr e2;
|
||||||
|
|
||||||
/* Create the substitution list. */
|
/* Create the substitution list. */
|
||||||
ATermMap subs;
|
ATermMap subs;
|
||||||
for (ATermIterator i(rbnds); i; ++i) {
|
for (ATermIterator i(rbnds); i; ++i) {
|
||||||
ATerm name;
|
|
||||||
Expr e2;
|
|
||||||
if (!(atMatch(m, *i) >> "Bind" >> name >> e2))
|
if (!(atMatch(m, *i) >> "Bind" >> name >> e2))
|
||||||
abort(); /* can't happen */
|
abort(); /* can't happen */
|
||||||
subs.set(name, ATmake("Select(<term>, <term>)", e, name));
|
subs.set(name, ATmake("Select(<term>, <term>)", e, name));
|
||||||
}
|
}
|
||||||
|
for (ATermIterator i(nrbnds); i; ++i) {
|
||||||
|
if (!(atMatch(m, *i) >> "Bind" >> name >> e2))
|
||||||
|
abort(); /* can't happen */
|
||||||
|
subs.set(name, e2);
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the non-recursive set. */
|
/* Create the non-recursive set. */
|
||||||
ATermMap as;
|
ATermMap as;
|
||||||
for (ATermIterator i(rbnds); i; ++i) {
|
for (ATermIterator i(rbnds); i; ++i) {
|
||||||
ATerm name;
|
|
||||||
Expr e2;
|
|
||||||
if (!(atMatch(m, *i) >> "Bind" >> name >> e2))
|
if (!(atMatch(m, *i) >> "Bind" >> name >> e2))
|
||||||
abort(); /* can't happen */
|
abort(); /* can't happen */
|
||||||
as.set(name, substitute(subs, e2));
|
as.set(name, substitute(subs, e2));
|
||||||
|
@ -123,8 +126,6 @@ ATerm expandRec(ATerm e, ATermList rbnds, ATermList nrbnds)
|
||||||
|
|
||||||
/* Copy the non-recursive bindings. !!! inefficient */
|
/* Copy the non-recursive bindings. !!! inefficient */
|
||||||
for (ATermIterator i(nrbnds); i; ++i) {
|
for (ATermIterator i(nrbnds); i; ++i) {
|
||||||
ATerm name;
|
|
||||||
Expr e2;
|
|
||||||
if (!(atMatch(m, *i) >> "Bind" >> name >> e2))
|
if (!(atMatch(m, *i) >> "Bind" >> name >> e2))
|
||||||
abort(); /* can't happen */
|
abort(); /* can't happen */
|
||||||
as.set(name, e2);
|
as.set(name, e2);
|
||||||
|
|
|
@ -205,8 +205,11 @@ Expr substitute(const ATermMap & subs, Expr e)
|
||||||
for (ATermIterator i(rbnds); i; ++i)
|
for (ATermIterator i(rbnds); i; ++i)
|
||||||
if (atMatch(m, *i) >> "Bind" >> name)
|
if (atMatch(m, *i) >> "Bind" >> name)
|
||||||
subs2.remove(name);
|
subs2.remove(name);
|
||||||
else
|
else abort(); /* can't happen */
|
||||||
abort(); /* can't happen */
|
for (ATermIterator i(nrbnds); i; ++i)
|
||||||
|
if (atMatch(m, *i) >> "Bind" >> name)
|
||||||
|
subs2.remove(name);
|
||||||
|
else abort(); /* can't happen */
|
||||||
return ATmake("Rec(<term>, <term>)",
|
return ATmake("Rec(<term>, <term>)",
|
||||||
substitute(subs2, (ATerm) rbnds),
|
substitute(subs2, (ATerm) rbnds),
|
||||||
substitute(subs, (ATerm) nrbnds));
|
substitute(subs, (ATerm) nrbnds));
|
||||||
|
@ -264,14 +267,18 @@ void checkVarDefs(const ATermMap & defs, Expr e)
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (atMatch(m, e) >> "Rec" >> rbnds >> nrbnds) {
|
else if (atMatch(m, e) >> "Rec" >> rbnds >> nrbnds) {
|
||||||
checkVarDefs(defs
|
checkVarDefs(defs, (ATerm) nrbnds);
|
||||||
, (ATerm) nrbnds);
|
|
||||||
ATermMap defs2(defs);
|
ATermMap defs2(defs);
|
||||||
for (ATermIterator i(rbnds); i; ++i) {
|
for (ATermIterator i(rbnds); i; ++i) {
|
||||||
if (!(atMatch(m, *i) >> "Bind" >> name))
|
if (!(atMatch(m, *i) >> "Bind" >> name))
|
||||||
abort(); /* can't happen */
|
abort(); /* can't happen */
|
||||||
defs2.set(name, (ATerm) ATempty);
|
defs2.set(name, (ATerm) ATempty);
|
||||||
}
|
}
|
||||||
|
for (ATermIterator i(nrbnds); i; ++i) {
|
||||||
|
if (!(atMatch(m, *i) >> "Bind" >> name))
|
||||||
|
abort(); /* can't happen */
|
||||||
|
defs2.set(name, (ATerm) ATempty);
|
||||||
|
}
|
||||||
checkVarDefs(defs2, (ATerm) rbnds);
|
checkVarDefs(defs2, (ATerm) rbnds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue