diff options
author | Ben Burdette <bburdette@protonmail.com> | 2022-05-06 08:47:21 -0600 |
---|---|---|
committer | Ben Burdette <bburdette@protonmail.com> | 2022-05-06 08:47:21 -0600 |
commit | 2c9fafdc9e43f6da39c289888dedbbbf0ea0b208 (patch) | |
tree | 8756b9a7c6be51c139ee54c7bbd552a2b3aba878 /src/libexpr/eval.cc | |
parent | 99d69ac23faf06598ca0aabd61d22a575db848df (diff) |
trying debugThrow
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r-- | src/libexpr/eval.cc | 103 |
1 files changed, 33 insertions, 70 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 659b97658..54872669a 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -802,8 +802,9 @@ std::unique_ptr<ValMap> mapStaticEnvBindings(const SymbolTable & st, const Stati return vm; } -void EvalState::debugLastTrace(Error & e) const +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. @@ -811,6 +812,18 @@ void EvalState::debugLastTrace(Error & e) const 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 @@ -824,10 +837,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, Env & env, Expr .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::throwEvalError(const PosIdx pos, const char * s) const @@ -837,18 +847,14 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s) const .errPos = positions[pos] }); - debugLastTrace(error); - - throw error; + debugThrowLastTrace(error); } void EvalState::throwEvalError(const char * s, const std::string & s2) const { auto error = EvalError(s, s2); - debugLastTrace(error); - - throw error; + debugThrowLastTrace(error); } void EvalState::throwEvalError(const PosIdx pos, const Suggestions & suggestions, const char * s, @@ -860,10 +866,7 @@ void EvalState::throwEvalError(const PosIdx pos, const Suggestions & suggestions .suggestions = suggestions, }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2) const @@ -873,9 +876,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri .errPos = positions[pos] }); - debugLastTrace(error); - - throw error; + debugThrowLastTrace(error); } void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2, Env & env, Expr & expr) const @@ -885,10 +886,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::throwEvalError(const char * s, const std::string & s2, @@ -899,9 +897,7 @@ void EvalState::throwEvalError(const char * s, const std::string & s2, .errPos = positions[noPos] }); - debugLastTrace(error); - - throw error; + debugThrowLastTrace(error); } void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2, @@ -912,9 +908,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri .errPos = positions[pos] }); - debugLastTrace(error); - - throw error; + debugThrowLastTrace(error); } void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2, @@ -925,10 +919,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::throwEvalError(const PosIdx p1, const char * s, const Symbol sym, const PosIdx p2, Env & env, Expr & expr) const @@ -939,10 +930,7 @@ void EvalState::throwEvalError(const PosIdx p1, const char * s, const Symbol sym .errPos = positions[p1] }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v) const @@ -952,9 +940,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v .errPos = positions[pos] }); - debugLastTrace(error); - - throw error; + debugThrowLastTrace(error); } void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v, Env & env, Expr & expr) const @@ -964,10 +950,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::throwTypeError(const PosIdx pos, const char * s) const @@ -977,9 +960,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s) const .errPos = positions[pos] }); - debugLastTrace(error); - - throw error; + debugThrowLastTrace(error); } void EvalState::throwTypeError(const PosIdx pos, const char * s, const ExprLambda & fun, @@ -990,10 +971,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const ExprLambd .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::throwTypeError(const PosIdx pos, const Suggestions & suggestions, const char * s, @@ -1005,10 +983,7 @@ void EvalState::throwTypeError(const PosIdx pos, const Suggestions & suggestions .suggestions = suggestions, }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::throwTypeError(const char * s, const Value & v, Env & env, Expr &expr) const @@ -1018,10 +993,7 @@ void EvalState::throwTypeError(const char * s, const Value & v, Env & env, Expr .errPos = positions[expr.getPos()], }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::throwAssertionError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const @@ -1031,10 +1003,7 @@ void EvalState::throwAssertionError(const PosIdx pos, const char * s, const std: .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::throwUndefinedVarError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const @@ -1044,10 +1013,7 @@ void EvalState::throwUndefinedVarError(const PosIdx pos, const char * s, const s .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::throwMissingArgumentError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const @@ -1057,10 +1023,7 @@ void EvalState::throwMissingArgumentError(const PosIdx pos, const char * s, cons .errPos = positions[pos] }); - if (debuggerHook) - debuggerHook(&error, env, expr); - - throw error; + debugThrow(error, env, expr); } void EvalState::addErrorTrace(Error & e, const char * s, const std::string & s2) const |