Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bburdette committed Dec 28, 2021
1 parent 4610e02 commit 5954cbf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 49 deletions.
8 changes: 0 additions & 8 deletions src/libcmd/command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ ref<EvalState> EvalCommand::getEvalState()
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());

// 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);
Expand Down
14 changes: 0 additions & 14 deletions src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ bool NixRepl::processLine(string line)
<< " :doc <expr> Show documentation of a builtin function\n"
<< " :d <cmd> Debug mode commands\n"
<< " :d stack Show call stack\n"
// << " :d stack <int> Detail for stack level N\n"
<< " :d env Show env stack\n"
<< " :d error Show current error\n";
}
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,6 @@ std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
return {};
}



void printStaticEnvBindings(const StaticEnv &se, int lvl)
{
std::cout << "Env level " << lvl << std::endl;
Expand Down Expand Up @@ -1112,8 +1110,6 @@ void EvalState::resetFileCache()
}




void EvalState::cacheFile(
const Path & path,
const Path & resolvedPath,
Expand Down
40 changes: 18 additions & 22 deletions src/libexpr/nixexpr.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,40 +99,36 @@ 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
{
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
{
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. */
struct ExprIndStr : Expr
{
string s;
ExprIndStr(const string & s) : s(s) { };

Pos* getPos() { return 0; }
};

Expand All @@ -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;
Expand All @@ -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
Expand All @@ -181,17 +177,17 @@ 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
{
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
Expand Down Expand Up @@ -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<Expr *> elems;
ExprList() { };
COMMON_METHODS
Pos* getPos() { return 0; }
COMMON_METHODS
};

struct Formal
Expand Down Expand Up @@ -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
Expand All @@ -278,17 +274,17 @@ struct ExprCall : Expr
ExprCall(const Pos & pos, Expr * fun, std::vector<Expr *> && args)
: fun(fun), args(args), pos(pos)
{ }
COMMON_METHODS
Pos* getPos() { return &pos; }
COMMON_METHODS
};

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
Expand All @@ -297,34 +293,34 @@ 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
{
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
{
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) \
Expand Down Expand Up @@ -361,16 +357,16 @@ struct ExprConcatStrings : Expr
vector<Expr *> * es;
ExprConcatStrings(const Pos & pos, bool forceString, vector<Expr *> * 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
};


Expand Down
1 change: 0 additions & 1 deletion src/libutil/logging.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ typedef uint64_t ActivityId;
struct LoggerSettings : Config
{
Setting<bool> showTrace{
// this, false, "show-trace",
this, false, "show-trace",
R"(
Where Nix should print out a stack trace in case of Nix
Expand Down

0 comments on commit 5954cbf

Please sign in to comment.