more cleanup

This commit is contained in:
Ben Burdette 2021-11-25 08:23:07 -07:00
parent 7e2a3db4eb
commit 69e26c5c4b
3 changed files with 13 additions and 15 deletions

View file

@ -81,8 +81,8 @@ ref<EvalState> EvalCommand::getEvalState()
if (expr.staticenv) if (expr.staticenv)
{ {
auto vm = mapStaticEnvBindings(*expr.staticenv.get(), env); auto vm = mapStaticEnvBindings(*expr.staticenv.get(), env);
runRepl(evalState, *vm); runRepl(evalState, *vm);
} }
}; };
} }

View file

@ -620,7 +620,7 @@ std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
void printStaticEnvBindings(const StaticEnv &se, int lvl) void printStaticEnvBindings(const StaticEnv &se, int lvl)
{ {
for (auto i = se.vars.begin(); i != se.vars.end(); ++i) for (auto i = se.vars.begin(); i != se.vars.end(); ++i)
{ {
std::cout << lvl << i->first << std::endl; std::cout << lvl << i->first << std::endl;
} }
@ -628,22 +628,21 @@ void printStaticEnvBindings(const StaticEnv &se, int lvl)
if (se.up) { if (se.up) {
printStaticEnvBindings(*se.up, ++lvl); printStaticEnvBindings(*se.up, ++lvl);
} }
} }
void printStaticEnvBindings(const Expr &expr) void printStaticEnvBindings(const Expr &expr)
{ {
// just print the names for now // just print the names for now
if (expr.staticenv) if (expr.staticenv)
{ {
printStaticEnvBindings(*expr.staticenv.get(), 0); printStaticEnvBindings(*expr.staticenv.get(), 0);
} }
} }
void mapStaticEnvBindings(const StaticEnv &se, const Env &env, valmap & vm) void mapStaticEnvBindings(const StaticEnv &se, const Env &env, valmap & vm)
{ {
// add bindings for the next level up first, so that the bindings for this level // add bindings for the next level up first, so that the bindings for this level
// override the higher levels. // override the higher levels.
if (env.up && se.up) { if (env.up && se.up) {
mapStaticEnvBindings( *se.up, *env.up,vm); mapStaticEnvBindings( *se.up, *env.up,vm);
@ -651,13 +650,13 @@ void mapStaticEnvBindings(const StaticEnv &se, const Env &env, valmap & vm)
// iterate through staticenv bindings and add them. // iterate through staticenv bindings and add them.
auto map = valmap(); auto map = valmap();
for (auto iter = se.vars.begin(); iter != se.vars.end(); ++iter) for (auto iter = se.vars.begin(); iter != se.vars.end(); ++iter)
{ {
map[iter->first] = env.values[iter->second]; map[iter->first] = env.values[iter->second];
} }
vm.merge(map); vm.merge(map);
} }

View file

@ -3,7 +3,6 @@
#include "util.hh" #include "util.hh"
#include <cstdlib> #include <cstdlib>
#include <iostream>
namespace nix { namespace nix {