1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 17:51:15 +02:00

refactor: Extract EvalState::addCallDepth

This commit is contained in:
Robert Hensing 2024-08-15 11:36:44 +02:00
parent d8c1550189
commit 6068e32aa7
3 changed files with 29 additions and 18 deletions

View file

@ -41,6 +41,21 @@ namespace eval_cache {
class EvalCache;
}
/**
* Increments a count on construction and decrements on destruction.
*/
class CallDepth {
size_t & count;
public:
CallDepth(size_t & count) : count(count) {
++count;
}
~CallDepth() {
--count;
}
};
/**
* Function that implements a primop.
*/
@ -649,6 +664,11 @@ private:
public:
/**
* Check that the call depth is within limits, and increment it, until the returned object is destroyed.
*/
inline CallDepth addCallDepth(const PosIdx pos);
/**
* Do a deep equality test between two values. That is, list
* elements and attributes are compared recursively.