[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
218/376: Make forceValueDeep work on values with cycles
From: |
Ludovic Courtès |
Subject: |
218/376: Make forceValueDeep work on values with cycles |
Date: |
Wed, 28 Jan 2015 22:05:10 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit 831fc8ea21fc730388e9359fcafed279c8ec413d
Author: Eelco Dolstra <address@hidden>
Date: Mon Sep 22 15:16:09 2014 +0200
Make forceValueDeep work on values with cycles
---
src/libexpr/eval.cc | 29 ++++++++++++++++++++---------
1 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index f1212cd..43d8f13 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -1183,17 +1183,28 @@ void ExprPos::eval(EvalState & state, Env & env, Value
& v)
void EvalState::forceValueDeep(Value & v)
{
- forceValue(v);
+ std::set<const Value *> seen;
- if (v.type == tAttrs) {
- foreach (Bindings::iterator, i, *v.attrs)
- forceValueDeep(*i->value);
- }
+ std::function<void(Value & v)> recurse;
- else if (v.type == tList) {
- for (unsigned int n = 0; n < v.list.length; ++n)
- forceValueDeep(*v.list.elems[n]);
- }
+ recurse = [&](Value & v) {
+ if (seen.find(&v) != seen.end()) return;
+ seen.insert(&v);
+
+ forceValue(v);
+
+ if (v.type == tAttrs) {
+ foreach (Bindings::iterator, i, *v.attrs)
+ recurse(*i->value);
+ }
+
+ else if (v.type == tList) {
+ for (unsigned int n = 0; n < v.list.length; ++n)
+ recurse(*v.list.elems[n]);
+ }
+ };
+
+ recurse(v);
}
- 219/376: Add ‘deepSeq’ primop, (continued)
- 219/376: Add ‘deepSeq’ primop, Ludovic Courtès, 2015/01/28
- 225/376: Pass through --set from nix-install-package command line to nix-env, Ludovic Courtès, 2015/01/28
- 214/376: Add a function ‘valueSize’, Ludovic Courtès, 2015/01/28
- 145/376: Use proper quotes everywhere, Ludovic Courtès, 2015/01/28
- 226/376: Add --force-name support for --set in nix-env, to support nix-install-package --set, Ludovic Courtès, 2015/01/28
- 220/376: Don't evaluate inside a "throw", Ludovic Courtès, 2015/01/28
- 217/376: Rename strictForceValue -> forceValueDeep, Ludovic Courtès, 2015/01/28
- 227/376: Updated documentation for nix-install-package to mention --set flag, Ludovic Courtès, 2015/01/28
- 228/376: Fix use of PAGER during tests, Ludovic Courtès, 2015/01/28
- 221/376: Remove release notes Hydra product, Ludovic Courtès, 2015/01/28
- 218/376: Make forceValueDeep work on values with cycles,
Ludovic Courtès <=
- 229/376: Remove bash requirement, Ludovic Courtès, 2015/01/28
- 231/376: nix-daemon: Close unnecessary fd, Ludovic Courtès, 2015/01/28
- 230/376: Bindings: Remove copy constructor, Ludovic Courtès, 2015/01/28
- 222/376: Add missing static, Ludovic Courtès, 2015/01/28
- 223/376: manual: add a note that lists are strict in length, Ludovic Courtès, 2015/01/28
- 232/376: printMissing(): Print derivations in approximate build order, Ludovic Courtès, 2015/01/28
- 234/376: printValue(): Don't print <CYCLE> for repeated values, Ludovic Courtès, 2015/01/28
- 233/376: Support control characters in JSON output, Ludovic Courtès, 2015/01/28
- 235/376: createDirs(): Handle ‘path’ being a symlink, Ludovic Courtès, 2015/01/28
- 238/376: Add test for readDir primop, Ludovic Courtès, 2015/01/28