more cleanup

This commit is contained in:
Ben Burdette 2021-12-27 18:29:55 -07:00
parent 4610e02d04
commit 5954cbf3e9
5 changed files with 18 additions and 49 deletions

View file

@ -73,14 +73,6 @@ ref<EvalState> EvalCommand::getEvalState()
debuggerHook = [evalState{ref<EvalState>(evalState)}](const Error & error, const Env & env, const Expr & expr) { debuggerHook = [evalState{ref<EvalState>(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()); 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) if (expr.staticenv)
{ {
auto vm = mapStaticEnvBindings(*expr.staticenv.get(), env); auto vm = mapStaticEnvBindings(*expr.staticenv.get(), env);

View file

@ -434,7 +434,6 @@ bool NixRepl::processLine(string line)
<< " :doc <expr> Show documentation of a builtin function\n" << " :doc <expr> Show documentation of a builtin function\n"
<< " :d <cmd> Debug mode commands\n" << " :d <cmd> Debug mode commands\n"
<< " :d stack Show call stack\n" << " :d stack Show call stack\n"
// << " :d stack <int> Detail for stack level N\n"
<< " :d env Show env stack\n" << " :d env Show env stack\n"
<< " :d error Show current error\n"; << " :d error Show current error\n";
} }
@ -708,19 +707,6 @@ void NixRepl::addVarToScope(const Symbol & name, Value & v)
varNames.insert((string) name); 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 * NixRepl::parseString(string s)
{ {
Expr * e = state->parseExprFromString(s, curDir, staticEnv); Expr * e = state->parseExprFromString(s, curDir, staticEnv);

View file

@ -672,8 +672,6 @@ std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
return {}; return {};
} }
void printStaticEnvBindings(const StaticEnv &se, int lvl) void printStaticEnvBindings(const StaticEnv &se, int lvl)
{ {
std::cout << "Env level " << lvl << std::endl; std::cout << "Env level " << lvl << std::endl;
@ -1112,8 +1110,6 @@ void EvalState::resetFileCache()
} }
void EvalState::cacheFile( void EvalState::cacheFile(
const Path & path, const Path & path,
const Path & resolvedPath, const Path & resolvedPath,

View file

@ -99,10 +99,9 @@ struct ExprInt : Expr
NixInt n; NixInt n;
Value v; Value v;
ExprInt(NixInt n) : n(n) { mkInt(v, n); }; ExprInt(NixInt n) : n(n) { mkInt(v, n); };
COMMON_METHODS
Value * maybeThunk(EvalState & state, Env & env); Value * maybeThunk(EvalState & state, Env & env);
Pos* getPos() { return 0; } Pos* getPos() { return 0; }
COMMON_METHODS
}; };
struct ExprFloat : Expr struct ExprFloat : Expr
@ -110,10 +109,9 @@ struct ExprFloat : Expr
NixFloat nf; NixFloat nf;
Value v; Value v;
ExprFloat(NixFloat nf) : nf(nf) { mkFloat(v, nf); }; ExprFloat(NixFloat nf) : nf(nf) { mkFloat(v, nf); };
COMMON_METHODS
Value * maybeThunk(EvalState & state, Env & env); Value * maybeThunk(EvalState & state, Env & env);
Pos* getPos() { return 0; } Pos* getPos() { return 0; }
COMMON_METHODS
}; };
struct ExprString : Expr struct ExprString : Expr
@ -121,10 +119,9 @@ struct ExprString : Expr
Symbol s; Symbol s;
Value v; Value v;
ExprString(const Symbol & s) : s(s) { mkString(v, s); }; ExprString(const Symbol & s) : s(s) { mkString(v, s); };
COMMON_METHODS
Value * maybeThunk(EvalState & state, Env & env); Value * maybeThunk(EvalState & state, Env & env);
Pos* getPos() { return 0; } Pos* getPos() { return 0; }
COMMON_METHODS
}; };
/* Temporary class used during parsing of indented strings. */ /* Temporary class used during parsing of indented strings. */
@ -132,7 +129,6 @@ struct ExprIndStr : Expr
{ {
string s; string s;
ExprIndStr(const string & s) : s(s) { }; ExprIndStr(const string & s) : s(s) { };
Pos* getPos() { return 0; } Pos* getPos() { return 0; }
}; };
@ -141,9 +137,9 @@ struct ExprPath : Expr
string s; string s;
Value v; Value v;
ExprPath(const string & s) : s(s) { v.mkPath(this->s.c_str()); }; ExprPath(const string & s) : s(s) { v.mkPath(this->s.c_str()); };
COMMON_METHODS
Value * maybeThunk(EvalState & state, Env & env); Value * maybeThunk(EvalState & state, Env & env);
Pos* getPos() { return 0; } Pos* getPos() { return 0; }
COMMON_METHODS
}; };
typedef uint32_t Level; typedef uint32_t Level;
@ -169,9 +165,9 @@ struct ExprVar : Expr
ExprVar(const Symbol & name) : name(name) { }; ExprVar(const Symbol & name) : name(name) { };
ExprVar(const Pos & pos, const Symbol & name) : pos(pos), name(name) { }; ExprVar(const Pos & pos, const Symbol & name) : pos(pos), name(name) { };
COMMON_METHODS
Value * maybeThunk(EvalState & state, Env & env); Value * maybeThunk(EvalState & state, Env & env);
Pos* getPos() { return &pos; } Pos* getPos() { return &pos; }
COMMON_METHODS
}; };
struct ExprSelect : Expr struct ExprSelect : Expr
@ -181,8 +177,8 @@ struct ExprSelect : Expr
AttrPath attrPath; 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 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)); }; 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; } Pos* getPos() { return &pos; }
COMMON_METHODS
}; };
struct ExprOpHasAttr : Expr struct ExprOpHasAttr : Expr
@ -190,8 +186,8 @@ struct ExprOpHasAttr : Expr
Expr * e; Expr * e;
AttrPath attrPath; AttrPath attrPath;
ExprOpHasAttr(Expr * e, const AttrPath & attrPath) : e(e), attrPath(attrPath) { }; ExprOpHasAttr(Expr * e, const AttrPath & attrPath) : e(e), attrPath(attrPath) { };
COMMON_METHODS
Pos* getPos() { return e->getPos(); } Pos* getPos() { return e->getPos(); }
COMMON_METHODS
}; };
struct ExprAttrs : Expr struct ExprAttrs : Expr
@ -219,16 +215,16 @@ struct ExprAttrs : Expr
DynamicAttrDefs dynamicAttrs; DynamicAttrDefs dynamicAttrs;
ExprAttrs(const Pos &pos) : recursive(false), pos(pos) { }; ExprAttrs(const Pos &pos) : recursive(false), pos(pos) { };
ExprAttrs() : recursive(false), pos(noPos) { }; ExprAttrs() : recursive(false), pos(noPos) { };
COMMON_METHODS
Pos* getPos() { return &pos; } Pos* getPos() { return &pos; }
COMMON_METHODS
}; };
struct ExprList : Expr struct ExprList : Expr
{ {
std::vector<Expr *> elems; std::vector<Expr *> elems;
ExprList() { }; ExprList() { };
COMMON_METHODS
Pos* getPos() { return 0; } Pos* getPos() { return 0; }
COMMON_METHODS
}; };
struct Formal struct Formal
@ -266,8 +262,8 @@ struct ExprLambda : Expr
void setName(Symbol & name); void setName(Symbol & name);
string showNamePos() const; string showNamePos() const;
inline bool hasFormals() const { return formals != nullptr; } inline bool hasFormals() const { return formals != nullptr; }
COMMON_METHODS
Pos* getPos() { return &pos; } Pos* getPos() { return &pos; }
COMMON_METHODS
}; };
struct ExprCall : Expr struct ExprCall : Expr
@ -278,8 +274,8 @@ struct ExprCall : Expr
ExprCall(const Pos & pos, Expr * fun, std::vector<Expr *> && args) ExprCall(const Pos & pos, Expr * fun, std::vector<Expr *> && args)
: fun(fun), args(args), pos(pos) : fun(fun), args(args), pos(pos)
{ } { }
COMMON_METHODS
Pos* getPos() { return &pos; } Pos* getPos() { return &pos; }
COMMON_METHODS
}; };
struct ExprLet : Expr struct ExprLet : Expr
@ -287,8 +283,8 @@ struct ExprLet : Expr
ExprAttrs * attrs; ExprAttrs * attrs;
Expr * body; Expr * body;
ExprLet(ExprAttrs * attrs, Expr * body) : attrs(attrs), body(body) { }; ExprLet(ExprAttrs * attrs, Expr * body) : attrs(attrs), body(body) { };
COMMON_METHODS
Pos* getPos() { return 0; } Pos* getPos() { return 0; }
COMMON_METHODS
}; };
struct ExprWith : Expr struct ExprWith : Expr
@ -297,8 +293,8 @@ struct ExprWith : Expr
Expr * attrs, * body; Expr * attrs, * body;
size_t prevWith; size_t prevWith;
ExprWith(const Pos & pos, Expr * attrs, Expr * body) : pos(pos), attrs(attrs), body(body) { }; ExprWith(const Pos & pos, Expr * attrs, Expr * body) : pos(pos), attrs(attrs), body(body) { };
COMMON_METHODS
Pos* getPos() { return &pos; } Pos* getPos() { return &pos; }
COMMON_METHODS
}; };
struct ExprIf : Expr struct ExprIf : Expr
@ -306,8 +302,8 @@ struct ExprIf : Expr
Pos pos; Pos pos;
Expr * cond, * then, * else_; Expr * cond, * then, * else_;
ExprIf(const Pos & pos, Expr * cond, Expr * then, Expr * else_) : pos(pos), cond(cond), then(then), else_(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; } Pos* getPos() { return &pos; }
COMMON_METHODS
}; };
struct ExprAssert : Expr struct ExprAssert : Expr
@ -315,16 +311,16 @@ struct ExprAssert : Expr
Pos pos; Pos pos;
Expr * cond, * body; Expr * cond, * body;
ExprAssert(const Pos & pos, Expr * cond, Expr * body) : pos(pos), cond(cond), body(body) { }; ExprAssert(const Pos & pos, Expr * cond, Expr * body) : pos(pos), cond(cond), body(body) { };
COMMON_METHODS
Pos* getPos() { return &pos; } Pos* getPos() { return &pos; }
COMMON_METHODS
}; };
struct ExprOpNot : Expr struct ExprOpNot : Expr
{ {
Expr * e; Expr * e;
ExprOpNot(Expr * e) : e(e) { }; ExprOpNot(Expr * e) : e(e) { };
COMMON_METHODS
Pos* getPos() { return 0; } Pos* getPos() { return 0; }
COMMON_METHODS
}; };
#define MakeBinOp(name, s) \ #define MakeBinOp(name, s) \
@ -361,16 +357,16 @@ struct ExprConcatStrings : Expr
vector<Expr *> * es; vector<Expr *> * es;
ExprConcatStrings(const Pos & pos, bool forceString, vector<Expr *> * es) ExprConcatStrings(const Pos & pos, bool forceString, vector<Expr *> * es)
: pos(pos), forceString(forceString), es(es) { }; : pos(pos), forceString(forceString), es(es) { };
COMMON_METHODS
Pos* getPos() { return &pos; } Pos* getPos() { return &pos; }
COMMON_METHODS
}; };
struct ExprPos : Expr struct ExprPos : Expr
{ {
Pos pos; Pos pos;
ExprPos(const Pos & pos) : pos(pos) { }; ExprPos(const Pos & pos) : pos(pos) { };
COMMON_METHODS
Pos* getPos() { return &pos; } Pos* getPos() { return &pos; }
COMMON_METHODS
}; };

View file

@ -38,7 +38,6 @@ typedef uint64_t ActivityId;
struct LoggerSettings : Config struct LoggerSettings : Config
{ {
Setting<bool> showTrace{ Setting<bool> showTrace{
// this, false, "show-trace",
this, false, "show-trace", this, false, "show-trace",
R"( R"(
Where Nix should print out a stack trace in case of Nix Where Nix should print out a stack trace in case of Nix