aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libcmd/command.cc7
-rw-r--r--src/libcmd/command.hh3
-rw-r--r--src/libcmd/repl.cc4
-rw-r--r--src/libexpr/eval.cc38
-rw-r--r--src/libexpr/eval.hh48
-rw-r--r--src/libexpr/nixexpr.cc2
-rw-r--r--src/libexpr/nixexpr.hh2
7 files changed, 54 insertions, 50 deletions
diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc
index 9cf2ff5e3..a7d7bfb17 100644
--- a/src/libcmd/command.cc
+++ b/src/libcmd/command.cc
@@ -118,9 +118,10 @@ ref<EvalState> EvalCommand::getEvalState()
searchPath, getEvalStore(), getStore())
#endif
;
+ // TODO move this somewhere else. Its only here to get the evalState ptr!
if (startReplOnEvalErrors)
// debuggerHook = [evalState{ref<EvalState>(evalState)}](const Error * error, const Env & env, const Expr & expr) {
- debuggerHook = [](const EvalState & evalState, const Error * error, const Env & env, const Expr & expr) {
+ debuggerHook = [](EvalState & evalState, const Error * error, const Env & env, const Expr & expr) {
auto dts =
error && expr.getPos()
? std::make_unique<DebugTraceStacker>(
@@ -137,9 +138,9 @@ ref<EvalState> EvalCommand::getEvalState()
if (error)
printError("%s\n\n" ANSI_BOLD "Starting REPL to allow you to inspect the current state of the evaluator.\n" ANSI_NORMAL, error->what());
- auto se = evalState->getStaticEnv(expr);
+ auto se = evalState.getStaticEnv(expr);
if (se) {
- auto vm = mapStaticEnvBindings(evalState->symbols, *se.get(), env);
+ auto vm = mapStaticEnvBindings(evalState.symbols, *se.get(), env);
runRepl(evalState, *vm);
}
};
diff --git a/src/libcmd/command.hh b/src/libcmd/command.hh
index 8b37be901..04bffa8df 100644
--- a/src/libcmd/command.hh
+++ b/src/libcmd/command.hh
@@ -274,7 +274,8 @@ void printClosureDiff(
void runRepl(
- EvalState & evalState,
+ ref<EvalState> evalState,
+ // EvalState & evalState,
const ValMap & extraEnv);
}
diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc
index 5b17f2fb2..5aecf3ac3 100644
--- a/src/libcmd/repl.cc
+++ b/src/libcmd/repl.cc
@@ -96,6 +96,7 @@ std::string removeWhitespace(std::string s)
}
+// NixRepl::NixRepl(ref<EvalState> state)
NixRepl::NixRepl(ref<EvalState> state)
: state(state)
, debugTraceIndex(0)
@@ -1012,7 +1013,8 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
}
void runRepl(
- EvalState& evalState,
+ ref<EvalState> evalState,
+ // EvalState& evalState,
const ValMap & extraEnv)
{
auto repl = std::make_unique<NixRepl>(evalState);
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index bd1cbaab5..f95ff4931 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -814,7 +814,7 @@ std::unique_ptr<ValMap> mapStaticEnvBindings(const SymbolTable & st, const Stati
of stack space, which is a real killer in the recursive
evaluator. So here are some helper functions for throwing
exceptions. */
-void EvalState::throwEvalError(const PosIdx pos, const char * s, Env & env, Expr & expr) const
+void EvalState::throwEvalError(const PosIdx pos, const char * s, Env & env, Expr & expr)
{
auto error = EvalError({
.msg = hintfmt(s),
@@ -824,7 +824,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, Env & env, Expr
debugThrow(error, env, expr);
}
-void EvalState::throwEvalError(const PosIdx pos, const char * s) const
+void EvalState::throwEvalError(const PosIdx pos, const char * s)
{
auto error = EvalError({
.msg = hintfmt(s),
@@ -834,7 +834,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s) const
debugThrowLastTrace(error);
}
-void EvalState::throwEvalError(const char * s, const std::string & s2) const
+void EvalState::throwEvalError(const char * s, const std::string & s2)
{
auto error = EvalError(s, s2);
@@ -842,7 +842,7 @@ void EvalState::throwEvalError(const char * s, const std::string & s2) const
}
void EvalState::throwEvalError(const PosIdx pos, const Suggestions & suggestions, const char * s,
- const std::string & s2, Env & env, Expr & expr) const
+ const std::string & s2, Env & env, Expr & expr)
{
auto error = EvalError(ErrorInfo{
.msg = hintfmt(s, s2),
@@ -853,7 +853,7 @@ void EvalState::throwEvalError(const PosIdx pos, const Suggestions & suggestions
debugThrow(error, env, expr);
}
-void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2) const
+void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2)
{
auto error = EvalError({
.msg = hintfmt(s, s2),
@@ -863,7 +863,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri
debugThrowLastTrace(error);
}
-void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2, Env & env, Expr & expr) const
+void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2, Env & env, Expr & expr)
{
auto error = EvalError({
.msg = hintfmt(s, s2),
@@ -874,7 +874,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri
}
void EvalState::throwEvalError(const char * s, const std::string & s2,
- const std::string & s3) const
+ const std::string & s3)
{
auto error = EvalError({
.msg = hintfmt(s, s2),
@@ -885,7 +885,7 @@ void EvalState::throwEvalError(const char * s, const std::string & s2,
}
void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2,
- const std::string & s3) const
+ const std::string & s3)
{
auto error = EvalError({
.msg = hintfmt(s, s2),
@@ -896,7 +896,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri
}
void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2,
- const std::string & s3, Env & env, Expr & expr) const
+ const std::string & s3, Env & env, Expr & expr)
{
auto error = EvalError({
.msg = hintfmt(s, s2),
@@ -906,7 +906,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri
debugThrow(error, env, expr);
}
-void EvalState::throwEvalError(const PosIdx p1, const char * s, const Symbol sym, const PosIdx p2, Env & env, Expr & expr) const
+void EvalState::throwEvalError(const PosIdx p1, const char * s, const Symbol sym, const PosIdx p2, Env & env, Expr & expr)
{
// p1 is where the error occurred; p2 is a position mentioned in the message.
auto error = EvalError({
@@ -917,7 +917,7 @@ void EvalState::throwEvalError(const PosIdx p1, const char * s, const Symbol sym
debugThrow(error, env, expr);
}
-void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v) const
+void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v)
{
auto error = TypeError({
.msg = hintfmt(s, showType(v)),
@@ -927,7 +927,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v
debugThrowLastTrace(error);
}
-void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v, Env & env, Expr & expr) const
+void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v, Env & env, Expr & expr)
{
auto error = TypeError({
.msg = hintfmt(s, showType(v)),
@@ -937,7 +937,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v
debugThrow(error, env, expr);
}
-void EvalState::throwTypeError(const PosIdx pos, const char * s) const
+void EvalState::throwTypeError(const PosIdx pos, const char * s)
{
auto error = TypeError({
.msg = hintfmt(s),
@@ -948,7 +948,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s) const
}
void EvalState::throwTypeError(const PosIdx pos, const char * s, const ExprLambda & fun,
- const Symbol s2, Env & env, Expr &expr) const
+ const Symbol s2, Env & env, Expr &expr)
{
auto error = TypeError({
.msg = hintfmt(s, fun.showNamePos(*this), symbols[s2]),
@@ -959,7 +959,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const ExprLambd
}
void EvalState::throwTypeError(const PosIdx pos, const Suggestions & suggestions, const char * s,
- const ExprLambda & fun, const Symbol s2, Env & env, Expr &expr) const
+ const ExprLambda & fun, const Symbol s2, Env & env, Expr &expr)
{
auto error = TypeError(ErrorInfo {
.msg = hintfmt(s, fun.showNamePos(*this), symbols[s2]),
@@ -970,7 +970,7 @@ void EvalState::throwTypeError(const PosIdx pos, const Suggestions & suggestions
debugThrow(error, env, expr);
}
-void EvalState::throwTypeError(const char * s, const Value & v, Env & env, Expr &expr) const
+void EvalState::throwTypeError(const char * s, const Value & v, Env & env, Expr &expr)
{
auto error = TypeError({
.msg = hintfmt(s, showType(v)),
@@ -980,7 +980,7 @@ void EvalState::throwTypeError(const char * s, const Value & v, Env & env, Expr
debugThrow(error, env, expr);
}
-void EvalState::throwAssertionError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const
+void EvalState::throwAssertionError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr)
{
auto error = AssertionError({
.msg = hintfmt(s, s1),
@@ -990,7 +990,7 @@ void EvalState::throwAssertionError(const PosIdx pos, const char * s, const std:
debugThrow(error, env, expr);
}
-void EvalState::throwUndefinedVarError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const
+void EvalState::throwUndefinedVarError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr)
{
auto error = UndefinedVarError({
.msg = hintfmt(s, s1),
@@ -1000,7 +1000,7 @@ void EvalState::throwUndefinedVarError(const PosIdx pos, const char * s, const s
debugThrow(error, env, expr);
}
-void EvalState::throwMissingArgumentError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const
+void EvalState::throwMissingArgumentError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr)
{
auto error = MissingArgumentError({
.msg = hintfmt(s, s1),
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index 5227c7ce1..763150dae 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -143,7 +143,7 @@ public:
template<class E>
[[gnu::noinline, gnu::noreturn]]
- void debugThrow(const E &error, const Env & env, const Expr & expr) const
+ void debugThrow(const E &error, const Env & env, const Expr & expr)
{
if (debuggerHook)
debuggerHook(*this, &error, env, expr);
@@ -153,7 +153,7 @@ public:
template<class E>
[[gnu::noinline, gnu::noreturn]]
- void debugThrowLastTrace(E & e) const
+ void debugThrowLastTrace(E & e)
{
// Call this in the situation where Expr and Env are inaccessible.
// The debugger will start in the last context that's in the
@@ -312,68 +312,68 @@ public:
std::string_view forceStringNoCtx(Value & v, const PosIdx pos = noPos);
[[gnu::noinline, gnu::noreturn]]
- void throwEvalError(const PosIdx pos, const char * s) const;
+ void throwEvalError(const PosIdx pos, const char * s);
[[gnu::noinline, gnu::noreturn]]
void throwEvalError(const PosIdx pos, const char * s,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
- void throwEvalError(const char * s, const std::string & s2) const;
+ void throwEvalError(const char * s, const std::string & s2);
[[gnu::noinline, gnu::noreturn]]
- void throwEvalError(const PosIdx pos, const char * s, const std::string & s2) const;
+ void throwEvalError(const PosIdx pos, const char * s, const std::string & s2);
[[gnu::noinline, gnu::noreturn]]
void throwEvalError(const char * s, const std::string & s2,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
void throwEvalError(const PosIdx pos, const char * s, const std::string & s2,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
void throwEvalError(const char * s, const std::string & s2, const std::string & s3,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
void throwEvalError(const PosIdx pos, const char * s, const std::string & s2, const std::string & s3,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
- void throwEvalError(const PosIdx pos, const char * s, const std::string & s2, const std::string & s3) const;
+ void throwEvalError(const PosIdx pos, const char * s, const std::string & s2, const std::string & s3);
[[gnu::noinline, gnu::noreturn]]
- void throwEvalError(const char * s, const std::string & s2, const std::string & s3) const;
+ void throwEvalError(const char * s, const std::string & s2, const std::string & s3);
[[gnu::noinline, gnu::noreturn]]
void throwEvalError(const PosIdx pos, const Suggestions & suggestions, const char * s, const std::string & s2,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
void throwEvalError(const PosIdx p1, const char * s, const Symbol sym, const PosIdx p2,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
- void throwTypeError(const PosIdx pos, const char * s, const Value & v) const;
+ void throwTypeError(const PosIdx pos, const char * s, const Value & v);
[[gnu::noinline, gnu::noreturn]]
void throwTypeError(const PosIdx pos, const char * s, const Value & v,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
- void throwTypeError(const PosIdx pos, const char * s) const;
+ void throwTypeError(const PosIdx pos, const char * s);
[[gnu::noinline, gnu::noreturn]]
void throwTypeError(const PosIdx pos, const char * s,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
void throwTypeError(const PosIdx pos, const char * s, const ExprLambda & fun, const Symbol s2,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
void throwTypeError(const PosIdx pos, const Suggestions & suggestions, const char * s, const ExprLambda & fun, const Symbol s2,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
void throwTypeError(const char * s, const Value & v,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
void throwAssertionError(const PosIdx pos, const char * s, const std::string & s1,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
void throwUndefinedVarError(const PosIdx pos, const char * s, const std::string & s1,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline, gnu::noreturn]]
void throwMissingArgumentError(const PosIdx pos, const char * s, const std::string & s1,
- Env & env, Expr & expr) const;
+ Env & env, Expr & expr);
[[gnu::noinline]]
void addErrorTrace(Error & e, const char * s, const std::string & s2) const;
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index cb5e1c3f2..21b71d7c9 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -10,7 +10,7 @@ namespace nix {
/* Launch the nix debugger */
-std::function<void(const EvalState & evalState,const Error * error, const Env & env, const Expr & expr)> debuggerHook;
+std::function<void(EvalState & evalState,const Error * error, const Env & env, const Expr & expr)> debuggerHook;
/* Displaying abstract syntax trees. */
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index 80b6afa3e..fdafb1711 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -22,7 +22,7 @@ MakeError(UndefinedVarError, Error);
MakeError(MissingArgumentError, EvalError);
MakeError(RestrictedPathError, Error);
-extern std::function<void(const EvalState & evalState, const Error * error, const Env & env, const Expr & expr)> debuggerHook;
+extern std::function<void(EvalState & evalState, const Error * error, const Env & env, const Expr & expr)> debuggerHook;
/* Position objects. */