diff options
author | Ben Burdette <bburdette@gmail.com> | 2021-12-27 17:35:27 -0700 |
---|---|---|
committer | Ben Burdette <bburdette@gmail.com> | 2021-12-27 17:35:27 -0700 |
commit | 9760fa8661f7562e0b8979338200904053cc4631 (patch) | |
tree | d96cb7e58f63c63ccaa505ae3666e06cdbe8fc65 /src/libexpr/eval.hh | |
parent | 6801a423fc9abdfd2cb7307f2970553bcfad089d (diff) |
add DebugTrace for the current error
Diffstat (limited to 'src/libexpr/eval.hh')
-rw-r--r-- | src/libexpr/eval.hh | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index c7a19e100..2f8cc82b0 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -76,11 +76,10 @@ std::shared_ptr<RegexCache> makeRegexCache(); struct DebugTrace { std::optional<ErrPos> pos; - Expr &expr; + const Expr &expr; hintformat hint; }; - class EvalState { public: @@ -406,6 +405,21 @@ private: friend void prim_match(EvalState & state, const Pos & pos, Value * * args, Value & v); }; +class DebugTraceStacker { + public: + DebugTraceStacker(EvalState &evalState, DebugTrace t) + :evalState(evalState), trace(t) + { + evalState.debugTraces.push_front(t); + } + ~DebugTraceStacker() + { + // assert(evalState.debugTraces.front() == trace); + evalState.debugTraces.pop_front(); + } + EvalState &evalState; + DebugTrace trace; +}; /* Return a string representing the type of the value `v'. */ string showType(ValueType type); |