Make forceValueDeep work on values with cycles
This commit is contained in:
parent
1e0a799bef
commit
831fc8ea21
1 changed files with 20 additions and 9 deletions
|
@ -1183,17 +1183,28 @@ void ExprPos::eval(EvalState & state, Env & env, Value & v)
|
||||||
|
|
||||||
void EvalState::forceValueDeep(Value & v)
|
void EvalState::forceValueDeep(Value & v)
|
||||||
{
|
{
|
||||||
|
std::set<const Value *> seen;
|
||||||
|
|
||||||
|
std::function<void(Value & v)> recurse;
|
||||||
|
|
||||||
|
recurse = [&](Value & v) {
|
||||||
|
if (seen.find(&v) != seen.end()) return;
|
||||||
|
seen.insert(&v);
|
||||||
|
|
||||||
forceValue(v);
|
forceValue(v);
|
||||||
|
|
||||||
if (v.type == tAttrs) {
|
if (v.type == tAttrs) {
|
||||||
foreach (Bindings::iterator, i, *v.attrs)
|
foreach (Bindings::iterator, i, *v.attrs)
|
||||||
forceValueDeep(*i->value);
|
recurse(*i->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (v.type == tList) {
|
else if (v.type == tList) {
|
||||||
for (unsigned int n = 0; n < v.list.length; ++n)
|
for (unsigned int n = 0; n < v.list.length; ++n)
|
||||||
forceValueDeep(*v.list.elems[n]);
|
recurse(*v.list.elems[n]);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
recurse(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue