aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc24
-rw-r--r--src/libexpr/eval.hh24
2 files changed, 22 insertions, 26 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 54872669a..8ba3688d8 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -802,30 +802,6 @@ std::unique_ptr<ValMap> mapStaticEnvBindings(const SymbolTable & st, const Stati
return vm;
}
-void EvalState::debugThrowLastTrace(Error & e) const
-{
- std::cout << "debugThrowLastTrace(Error & e) const" << (debuggerHook == nullptr) << std::endl;
- // Call this in the situation where Expr and Env are inaccessible.
- // The debugger will start in the last context that's in the
- // DebugTrace stack.
- if (debuggerHook && !debugTraces.empty()) {
- const DebugTrace & last = debugTraces.front();
- debuggerHook(&e, last.env, last.expr);
- }
-
- throw e;
-}
-
-
-void EvalState::debugThrow(const Error &error, const Env & env, const Expr & expr) const
-{
- std::cout << "debugThrow" << (debuggerHook == nullptr) << std::endl;
- if (debuggerHook)
- debuggerHook(&error, env, expr);
-
- throw error;
-}
-
/* Every "format" object (even temporary) takes up a few hundred bytes
of stack space, which is a real killer in the recursive
evaluator. So here are some helper functions for throwing
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index add104a84..1e728002a 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -128,10 +128,30 @@ public:
bool debugQuit;
std::list<DebugTrace> debugTraces;
+ template<class E>
[[gnu::noinline, gnu::noreturn]]
- void debugThrow(const Error &error, const Env & env, const Expr & expr) const;
+ void debugThrow(const E &error, const Env & env, const Expr & expr) const
+ {
+ if (debuggerHook)
+ debuggerHook(&error, env, expr);
+
+ throw error;
+ }
+
+ template<class E>
[[gnu::noinline, gnu::noreturn]]
- void debugThrowLastTrace(Error & e) const;
+ void debugThrowLastTrace(E & e) const
+ {
+ // Call this in the situation where Expr and Env are inaccessible.
+ // The debugger will start in the last context that's in the
+ // DebugTrace stack.
+ if (debuggerHook && !debugTraces.empty()) {
+ const DebugTrace & last = debugTraces.front();
+ debuggerHook(&e, last.env, last.expr);
+ }
+
+ throw e;
+ }
private:
SrcToStore srcToStore;