diff options
author | eldritch horrors <pennae@lix.systems> | 2024-03-08 07:48:31 +0100 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-03-09 04:47:05 -0700 |
commit | f536696b732bc81c0aa05e20ff0e37dd0d02a2d4 (patch) | |
tree | d5b0e2497e5795e06d95e8479037c9d67837ad68 /src/libexpr/eval-error.hh | |
parent | f27a27f49e650b13ec3857c7ff6429e24010e160 (diff) |
Add comments
(cherry picked from commit 474fc4078acbe062fcc31ce91c69c8f33bf00d5f)
Change-Id: I9f78f7afd8468d0ab676c0f60c4f7d6140128583
Diffstat (limited to 'src/libexpr/eval-error.hh')
-rw-r--r-- | src/libexpr/eval-error.hh | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/libexpr/eval-error.hh b/src/libexpr/eval-error.hh index 1faf76781..e9076f28b 100644 --- a/src/libexpr/eval-error.hh +++ b/src/libexpr/eval-error.hh @@ -57,6 +57,11 @@ public: } }; +/** + * `EvalErrorBuilder`s may only be constructed by `EvalState`. The `debugThrow` + * method must be the final method in any such `EvalErrorBuilder` usage, and it + * handles deleting the object. + */ template<class T> class EvalErrorBuilder final { @@ -91,29 +96,10 @@ public: [[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & addTrace(PosIdx pos, std::string_view formatString, const Args &... formatArgs); + /** + * Delete the `EvalErrorBuilder` and throw the underlying exception. + */ [[gnu::noinline, gnu::noreturn]] void debugThrow(); }; -/** - * The size needed to allocate any `EvalErrorBuilder<T>`. - * - * The list of classes here needs to be kept in sync with the list of `template - * class` declarations in `eval-error.cc`. - * - * This is used by `EvalState` to preallocate a buffer of sufficient size for - * any `EvalErrorBuilder<T>` to avoid allocating while evaluating Nix code. - */ -constexpr size_t EVAL_ERROR_BUILDER_SIZE = std::max({ - sizeof(EvalErrorBuilder<EvalError>), - sizeof(EvalErrorBuilder<AssertionError>), - sizeof(EvalErrorBuilder<ThrownError>), - sizeof(EvalErrorBuilder<Abort>), - sizeof(EvalErrorBuilder<TypeError>), - sizeof(EvalErrorBuilder<UndefinedVarError>), - sizeof(EvalErrorBuilder<MissingArgumentError>), - sizeof(EvalErrorBuilder<InfiniteRecursionError>), - sizeof(EvalErrorBuilder<CachedEvalError>), - sizeof(EvalErrorBuilder<InvalidPathError>), -}); - } |