aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.hh
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2021-12-27 17:35:27 -0700
committerBen Burdette <bburdette@gmail.com>2021-12-27 17:35:27 -0700
commit9760fa8661f7562e0b8979338200904053cc4631 (patch)
treed96cb7e58f63c63ccaa505ae3666e06cdbe8fc65 /src/libexpr/eval.hh
parent6801a423fc9abdfd2cb7307f2970553bcfad089d (diff)
add DebugTrace for the current error
Diffstat (limited to 'src/libexpr/eval.hh')
-rw-r--r--src/libexpr/eval.hh18
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);