diff options
author | Ben Burdette <bburdette@protonmail.com> | 2022-05-22 21:45:24 -0600 |
---|---|---|
committer | Ben Burdette <bburdette@protonmail.com> | 2022-05-22 21:45:24 -0600 |
commit | 13d02af0799f5d2f7a53825936d587e22edcacb6 (patch) | |
tree | 171eafe55521519d5b821aa7bec083cd2d1aa4ed /src/libexpr | |
parent | 7ccb2700c0401c553631e07aeb49e08f976274a3 (diff) |
remove redundant 'debugMode' flag
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval.cc | 12 | ||||
-rw-r--r-- | src/libexpr/eval.hh | 6 | ||||
-rw-r--r-- | src/libexpr/nixexpr.cc | 38 | ||||
-rw-r--r-- | src/libexpr/primops.cc | 2 |
4 files changed, 28 insertions, 30 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 5faecdbe3..c457df380 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -813,7 +813,7 @@ std::unique_ptr<ValMap> mapStaticEnvBindings(const SymbolTable & st, const Stati void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr & expr) { - // double check we've got the debugRepl ftn pointer. + // double check we've got the debugRepl function pointer. if (!debugRepl) return; @@ -1073,7 +1073,7 @@ DebugTraceStacker::DebugTraceStacker(EvalState & evalState, DebugTrace t) , trace(std::move(t)) { evalState.debugTraces.push_front(trace); - if (evalState.debugStop && evalState.debugMode) + if (evalState.debugStop && evalState.debugRepl) evalState.runDebugRepl(nullptr, trace.env, trace.expr); } @@ -1271,7 +1271,7 @@ void EvalState::cacheFile( fileParseCache[resolvedPath] = e; try { - auto dts = debugMode + auto dts = debugRepl ? makeDebugTraceStacker( *this, *e, @@ -1505,7 +1505,7 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v) e->eval(state, env, vTmp); try { - auto dts = state.debugMode + auto dts = state.debugRepl ? makeDebugTraceStacker( state, *this, @@ -1674,7 +1674,7 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value & /* Evaluate the body. */ try { - auto dts = debugMode + auto dts = debugRepl ? makeDebugTraceStacker( *this, *lambda.body, env2, positions[lambda.pos], "while evaluating %s", @@ -2102,7 +2102,7 @@ void EvalState::forceValueDeep(Value & v) for (auto & i : *v.attrs) try { // If the value is a thunk, we're evaling. Otherwise no trace necessary. - auto dts = debugMode && i.value->isThunk() + auto dts = debugRepl && i.value->isThunk() ? makeDebugTraceStacker(*this, *i.value->thunk.expr, *i.value->thunk.env, positions[i.pos], "while evaluating the attribute '%1%'", symbols[i.name]) : nullptr; diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 90bd5497b..c86075ae3 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -128,8 +128,6 @@ public: /* Debugger */ void (* debugRepl)(EvalState & es, const ValMap & extraEnv); - - bool debugMode; bool debugStop; bool debugQuit; std::list<DebugTrace> debugTraces; @@ -149,7 +147,7 @@ public: [[gnu::noinline, gnu::noreturn]] void debugThrow(const E &error, const Env & env, const Expr & expr) { - if (debugMode) + if (debugRepl) runDebugRepl(&error, env, expr); throw error; @@ -162,7 +160,7 @@ public: // 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 (debugMode && !debugTraces.empty()) { + if (debugRepl && !debugTraces.empty()) { const DebugTrace & last = debugTraces.front(); runDebugRepl(&e, last.env, last.expr); } diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index 52d48122c..7c623a07d 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -299,31 +299,31 @@ void Expr::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env void ExprInt::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); } void ExprFloat::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); } void ExprString::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); } void ExprPath::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); } void ExprVar::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); /* Check whether the variable appears in the environment. If so, @@ -359,7 +359,7 @@ void ExprVar::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & void ExprSelect::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); e->bindVars(es, env); @@ -371,7 +371,7 @@ void ExprSelect::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> void ExprOpHasAttr::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); e->bindVars(es, env); @@ -382,7 +382,7 @@ void ExprOpHasAttr::bindVars(EvalState & es, const std::shared_ptr<const StaticE void ExprAttrs::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); if (recursive) { @@ -415,7 +415,7 @@ void ExprAttrs::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> void ExprList::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); for (auto & i : elems) @@ -424,7 +424,7 @@ void ExprList::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & void ExprLambda::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); auto newEnv = std::make_shared<StaticEnv>( @@ -451,7 +451,7 @@ void ExprLambda::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> void ExprCall::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); fun->bindVars(es, env); @@ -461,7 +461,7 @@ void ExprCall::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & void ExprLet::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); auto newEnv = std::make_shared<StaticEnv>(false, env.get(), attrs->attrs.size()); @@ -480,7 +480,7 @@ void ExprLet::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & void ExprWith::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); /* Does this `with' have an enclosing `with'? If so, record its @@ -495,7 +495,7 @@ void ExprWith::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & break; } - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); attrs->bindVars(es, env); @@ -505,7 +505,7 @@ void ExprWith::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & void ExprIf::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); cond->bindVars(es, env); @@ -515,7 +515,7 @@ void ExprIf::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & e void ExprAssert::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); cond->bindVars(es, env); @@ -524,7 +524,7 @@ void ExprAssert::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> void ExprOpNot::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); e->bindVars(es, env); @@ -532,7 +532,7 @@ void ExprOpNot::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> void ExprConcatStrings::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); for (auto & i : *this->es) @@ -541,7 +541,7 @@ void ExprConcatStrings::bindVars(EvalState & es, const std::shared_ptr<const Sta void ExprPos::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) { - if (es.debugMode) + if (es.debugRepl) es.exprEnvs.insert(std::make_pair(this, env)); } diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 60a70f336..b24d4c68a 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -757,7 +757,7 @@ static RegisterPrimOp primop_break({ )", .fun = [](EvalState & state, const PosIdx pos, Value * * args, Value & v) { - if (state.debugMode && !state.debugTraces.empty()) { + if (state.debugRepl && !state.debugTraces.empty()) { auto error = Error(ErrorInfo { .level = lvlInfo, .msg = hintfmt("breakpoint reached"), |