From 5954cbf3e9dca0e3b84e4bf2def74abb3d6f80cd Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Mon, 27 Dec 2021 18:29:55 -0700 Subject: [PATCH] more cleanup --- src/libcmd/command.cc | 8 -------- src/libcmd/repl.cc | 14 -------------- src/libexpr/eval.cc | 4 ---- src/libexpr/nixexpr.hh | 40 ++++++++++++++++++---------------------- src/libutil/logging.hh | 1 - 5 files changed, 18 insertions(+), 49 deletions(-) diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc index b97458b2d..e44c737f5 100644 --- a/src/libcmd/command.cc +++ b/src/libcmd/command.cc @@ -73,14 +73,6 @@ ref EvalCommand::getEvalState() debuggerHook = [evalState{ref(evalState)}](const Error & error, const Env & env, const Expr & expr) { printError("%s\n\n" ANSI_BOLD "Starting REPL to allow you to inspect the current state of the evaluator.\n" ANSI_NORMAL, error.what()); - // printStaticEnvBindings(expr); - - // std::cout << evalState->vCallFlake << std::endl; - - // std::cout << "expr: " << std::endl; - // expr.show(std::cout); - // std::cout << std::endl; - if (expr.staticenv) { auto vm = mapStaticEnvBindings(*expr.staticenv.get(), env); diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 64547344a..cf784db61 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -434,7 +434,6 @@ bool NixRepl::processLine(string line) << " :doc Show documentation of a builtin function\n" << " :d Debug mode commands\n" << " :d stack Show call stack\n" - // << " :d stack Detail for stack level N\n" << " :d env Show env stack\n" << " :d error Show current error\n"; } @@ -708,19 +707,6 @@ void NixRepl::addVarToScope(const Symbol & name, Value & v) varNames.insert((string) name); } -// version from master. -// void NixRepl::addVarToScope(const Symbol & name, Value & v) -// { -// if (displ >= envSize) -// throw Error("environment full; cannot add more variables"); -// if (auto oldVar = staticEnv.find(name); oldVar != staticEnv.vars.end()) -// staticEnv.vars.erase(oldVar); -// staticEnv.vars.emplace_back(name, displ); -// staticEnv.sort(); -// env->values[displ++] = &v; -// varNames.insert((string) name); -// } - Expr * NixRepl::parseString(string s) { Expr * e = state->parseExprFromString(s, curDir, staticEnv); diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 2596fbe3a..ac437e69d 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -672,8 +672,6 @@ std::optional EvalState::getDoc(Value & v) return {}; } - - void printStaticEnvBindings(const StaticEnv &se, int lvl) { std::cout << "Env level " << lvl << std::endl; @@ -1112,8 +1110,6 @@ void EvalState::resetFileCache() } - - void EvalState::cacheFile( const Path & path, const Path & resolvedPath, diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index a9a5f5316..bfa215fda 100644 --- a/src/libexpr/nixexpr.hh +++ b/src/libexpr/nixexpr.hh @@ -99,10 +99,9 @@ struct ExprInt : Expr NixInt n; Value v; ExprInt(NixInt n) : n(n) { mkInt(v, n); }; - COMMON_METHODS Value * maybeThunk(EvalState & state, Env & env); - Pos* getPos() { return 0; } + COMMON_METHODS }; struct ExprFloat : Expr @@ -110,10 +109,9 @@ struct ExprFloat : Expr NixFloat nf; Value v; ExprFloat(NixFloat nf) : nf(nf) { mkFloat(v, nf); }; - COMMON_METHODS Value * maybeThunk(EvalState & state, Env & env); - Pos* getPos() { return 0; } + COMMON_METHODS }; struct ExprString : Expr @@ -121,10 +119,9 @@ struct ExprString : Expr Symbol s; Value v; ExprString(const Symbol & s) : s(s) { mkString(v, s); }; - COMMON_METHODS Value * maybeThunk(EvalState & state, Env & env); - Pos* getPos() { return 0; } + COMMON_METHODS }; /* Temporary class used during parsing of indented strings. */ @@ -132,7 +129,6 @@ struct ExprIndStr : Expr { string s; ExprIndStr(const string & s) : s(s) { }; - Pos* getPos() { return 0; } }; @@ -141,9 +137,9 @@ struct ExprPath : Expr string s; Value v; ExprPath(const string & s) : s(s) { v.mkPath(this->s.c_str()); }; - COMMON_METHODS Value * maybeThunk(EvalState & state, Env & env); Pos* getPos() { return 0; } + COMMON_METHODS }; typedef uint32_t Level; @@ -169,9 +165,9 @@ struct ExprVar : Expr ExprVar(const Symbol & name) : name(name) { }; ExprVar(const Pos & pos, const Symbol & name) : pos(pos), name(name) { }; - COMMON_METHODS Value * maybeThunk(EvalState & state, Env & env); Pos* getPos() { return &pos; } + COMMON_METHODS }; struct ExprSelect : Expr @@ -181,8 +177,8 @@ struct ExprSelect : Expr AttrPath attrPath; ExprSelect(const Pos & pos, Expr * e, const AttrPath & attrPath, Expr * def) : pos(pos), e(e), def(def), attrPath(attrPath) { }; ExprSelect(const Pos & pos, Expr * e, const Symbol & name) : pos(pos), e(e), def(0) { attrPath.push_back(AttrName(name)); }; - COMMON_METHODS Pos* getPos() { return &pos; } + COMMON_METHODS }; struct ExprOpHasAttr : Expr @@ -190,8 +186,8 @@ struct ExprOpHasAttr : Expr Expr * e; AttrPath attrPath; ExprOpHasAttr(Expr * e, const AttrPath & attrPath) : e(e), attrPath(attrPath) { }; - COMMON_METHODS Pos* getPos() { return e->getPos(); } + COMMON_METHODS }; struct ExprAttrs : Expr @@ -219,16 +215,16 @@ struct ExprAttrs : Expr DynamicAttrDefs dynamicAttrs; ExprAttrs(const Pos &pos) : recursive(false), pos(pos) { }; ExprAttrs() : recursive(false), pos(noPos) { }; - COMMON_METHODS Pos* getPos() { return &pos; } + COMMON_METHODS }; struct ExprList : Expr { std::vector elems; ExprList() { }; - COMMON_METHODS Pos* getPos() { return 0; } + COMMON_METHODS }; struct Formal @@ -266,8 +262,8 @@ struct ExprLambda : Expr void setName(Symbol & name); string showNamePos() const; inline bool hasFormals() const { return formals != nullptr; } - COMMON_METHODS Pos* getPos() { return &pos; } + COMMON_METHODS }; struct ExprCall : Expr @@ -278,8 +274,8 @@ struct ExprCall : Expr ExprCall(const Pos & pos, Expr * fun, std::vector && args) : fun(fun), args(args), pos(pos) { } - COMMON_METHODS Pos* getPos() { return &pos; } + COMMON_METHODS }; struct ExprLet : Expr @@ -287,8 +283,8 @@ struct ExprLet : Expr ExprAttrs * attrs; Expr * body; ExprLet(ExprAttrs * attrs, Expr * body) : attrs(attrs), body(body) { }; - COMMON_METHODS Pos* getPos() { return 0; } + COMMON_METHODS }; struct ExprWith : Expr @@ -297,8 +293,8 @@ struct ExprWith : Expr Expr * attrs, * body; size_t prevWith; ExprWith(const Pos & pos, Expr * attrs, Expr * body) : pos(pos), attrs(attrs), body(body) { }; - COMMON_METHODS Pos* getPos() { return &pos; } + COMMON_METHODS }; struct ExprIf : Expr @@ -306,8 +302,8 @@ struct ExprIf : Expr Pos pos; Expr * cond, * then, * else_; ExprIf(const Pos & pos, Expr * cond, Expr * then, Expr * else_) : pos(pos), cond(cond), then(then), else_(else_) { }; - COMMON_METHODS Pos* getPos() { return &pos; } + COMMON_METHODS }; struct ExprAssert : Expr @@ -315,16 +311,16 @@ struct ExprAssert : Expr Pos pos; Expr * cond, * body; ExprAssert(const Pos & pos, Expr * cond, Expr * body) : pos(pos), cond(cond), body(body) { }; - COMMON_METHODS Pos* getPos() { return &pos; } + COMMON_METHODS }; struct ExprOpNot : Expr { Expr * e; ExprOpNot(Expr * e) : e(e) { }; - COMMON_METHODS Pos* getPos() { return 0; } + COMMON_METHODS }; #define MakeBinOp(name, s) \ @@ -361,16 +357,16 @@ struct ExprConcatStrings : Expr vector * es; ExprConcatStrings(const Pos & pos, bool forceString, vector * es) : pos(pos), forceString(forceString), es(es) { }; - COMMON_METHODS Pos* getPos() { return &pos; } + COMMON_METHODS }; struct ExprPos : Expr { Pos pos; ExprPos(const Pos & pos) : pos(pos) { }; - COMMON_METHODS Pos* getPos() { return &pos; } + COMMON_METHODS }; diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh index f10a9af38..96ad69790 100644 --- a/src/libutil/logging.hh +++ b/src/libutil/logging.hh @@ -38,7 +38,6 @@ typedef uint64_t ActivityId; struct LoggerSettings : Config { Setting showTrace{ - // this, false, "show-trace", this, false, "show-trace", R"( Where Nix should print out a stack trace in case of Nix