mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
template-ize debugThrow
This commit is contained in:
parent
2c9fafdc9e
commit
1ea13084c9
2 changed files with 22 additions and 26 deletions
|
@ -802,30 +802,6 @@ std::unique_ptr<ValMap> mapStaticEnvBindings(const SymbolTable & st, const Stati
|
||||||
return vm;
|
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
|
/* Every "format" object (even temporary) takes up a few hundred bytes
|
||||||
of stack space, which is a real killer in the recursive
|
of stack space, which is a real killer in the recursive
|
||||||
evaluator. So here are some helper functions for throwing
|
evaluator. So here are some helper functions for throwing
|
||||||
|
|
|
@ -128,10 +128,30 @@ public:
|
||||||
bool debugQuit;
|
bool debugQuit;
|
||||||
std::list<DebugTrace> debugTraces;
|
std::list<DebugTrace> debugTraces;
|
||||||
|
|
||||||
|
template<class E>
|
||||||
[[gnu::noinline, gnu::noreturn]]
|
[[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]]
|
[[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:
|
private:
|
||||||
SrcToStore srcToStore;
|
SrcToStore srcToStore;
|
||||||
|
|
Loading…
Reference in a new issue