diff options
author | Ben Burdette <bburdette@protonmail.com> | 2022-05-06 09:09:49 -0600 |
---|---|---|
committer | Ben Burdette <bburdette@protonmail.com> | 2022-05-06 09:09:49 -0600 |
commit | fc66f48812383dad59ebdbabdd29bec34ed31921 (patch) | |
tree | f4cbb7e451a6eb0006180746be2363c5006896f8 /src | |
parent | 99d69ac23faf06598ca0aabd61d22a575db848df (diff) |
debugError()
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/eval.cc | 43 | ||||
-rw-r--r-- | src/libexpr/eval.hh | 2 |
2 files changed, 21 insertions, 24 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 659b97658..c5e33a279 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -813,6 +813,13 @@ void EvalState::debugLastTrace(Error & e) const } } +void debugError(Error * e, Env & env, Expr & expr) +{ + if (debuggerHook) + debuggerHook(e, env, expr); +} + + /* 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 @@ -824,8 +831,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, Env & env, Expr .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } @@ -860,8 +866,7 @@ void EvalState::throwEvalError(const PosIdx pos, const Suggestions & suggestions .suggestions = suggestions, }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } @@ -885,8 +890,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } @@ -925,8 +929,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } @@ -939,8 +942,7 @@ void EvalState::throwEvalError(const PosIdx p1, const char * s, const Symbol sym .errPos = positions[p1] }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } @@ -964,8 +966,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } @@ -990,8 +991,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const ExprLambd .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } @@ -1005,8 +1005,7 @@ void EvalState::throwTypeError(const PosIdx pos, const Suggestions & suggestions .suggestions = suggestions, }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } @@ -1018,8 +1017,7 @@ void EvalState::throwTypeError(const char * s, const Value & v, Env & env, Expr .errPos = positions[expr.getPos()], }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } @@ -1031,8 +1029,7 @@ void EvalState::throwAssertionError(const PosIdx pos, const char * s, const std: .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } @@ -1044,8 +1041,7 @@ void EvalState::throwUndefinedVarError(const PosIdx pos, const char * s, const s .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } @@ -1057,8 +1053,7 @@ void EvalState::throwMissingArgumentError(const PosIdx pos, const char * s, cons .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); + debugError(&error, env, expr); throw error; } diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 65b1466ea..db78e29b5 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -85,6 +85,8 @@ struct DebugTrace { bool isError; }; +void debugError(Error * e, Env & env, Expr & expr); + class EvalState { public: |