From c10c61449f954702ae6d8092120321744acd82ff Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 4 Feb 2016 14:28:26 +0100 Subject: Eliminate the "store" global variable Also, move a few free-standing functions into StoreAPI and Derivation. Also, introduce a non-nullable smart pointer, ref, which is just a wrapper around std::shared_ptr ensuring that the pointer is never null. (For reference-counted values, this is better than passing a "T&", because the latter doesn't maintain the refcount. Usually, the caller will have a shared_ptr keeping the value alive, but that's not always the case, e.g., when passing a reference to a std::thread via std::bind.) --- src/libexpr/eval.hh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/libexpr/eval.hh') diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 2d7b7bcdcb62..a4286ce1f065 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -16,6 +16,7 @@ namespace nix { +class StoreAPI; class EvalState; @@ -82,6 +83,8 @@ public: Value vEmptySet; + const ref store; + private: SrcToStore srcToStore; @@ -97,7 +100,7 @@ private: public: - EvalState(const Strings & _searchPath); + EvalState(const Strings & _searchPath, ref store); ~EvalState(); void addToSearchPath(const string & s, bool warn = false); @@ -240,6 +243,8 @@ public: /* Print statistics. */ void printStats(); + void realiseContext(const PathSet & context); + private: unsigned long nrEnvs = 0; @@ -290,7 +295,4 @@ struct InvalidPathError : EvalError #endif }; -/* Realise all paths in `context' */ -void realiseContext(const PathSet & context); - } -- cgit 1.4.1