aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libcmd/command.cc36
-rw-r--r--src/libexpr/eval.cc157
-rw-r--r--src/libexpr/eval.hh3
3 files changed, 0 insertions, 196 deletions
diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc
index 2d86dbd61..8d5098bc7 100644
--- a/src/libcmd/command.cc
+++ b/src/libcmd/command.cc
@@ -54,7 +54,6 @@ void StoreCommand::run()
run(getStore());
}
-/*
EvalCommand::EvalCommand()
{
addFlag({
@@ -64,39 +63,6 @@ EvalCommand::EvalCommand()
});
}
-extern std::function<void(const Error & error, const std::map<std::string, Value *> & env)> debuggerHook;
-
-ref<EvalState> EvalCommand::getEvalState()
-{
- if (!evalState) {
- evalState = std::make_shared<EvalState>(searchPath, getStore());
- if (startReplOnEvalErrors)
- debuggerHook = [evalState{ref<EvalState>(evalState)}](const Error & error, const std::map<std::string, Value *> & env) {
- printError("%s\n\n" ANSI_BOLD "Starting REPL to allow you to inspect the current state of the evaluator.\n" ANSI_NORMAL, error.what());
- runRepl(evalState, env);
- };
- }
- return ref<EvalState>(evalState);
-}
-*/
-// ref<EvalState> EvalCommand::getEvalState()
-// {
-// if (!evalState)
-// evalState = std::make_shared<EvalState>(searchPath, getStore());
-// return ref<EvalState>(evalState);
-// }
-
-
-EvalCommand::EvalCommand()
-{
- // std::cout << "EvalCommand::EvalCommand()" << std::endl;
- addFlag({
- .longName = "debugger",
- .description = "start an interactive environment if evaluation fails",
- .handler = {&startReplOnEvalErrors, true},
- });
-}
-// extern std::function<void(const Error & error, const std::map<std::string, Value *> & env)> debuggerHook;
extern std::function<void(const Error & error, const Env & env, const Expr & expr)> debuggerHook;
ref<EvalState> EvalCommand::getEvalState()
@@ -114,8 +80,6 @@ ref<EvalState> EvalCommand::getEvalState()
expr.show(std::cout);
std::cout << std::endl;
- // printEnvPosChain(env);
- // printEnvBindings(env);
if (expr.staticenv)
{
auto vm = mapStaticEnvBindings(*expr.staticenv.get(), env);
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 12f7e8979..f286cbeec 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -619,75 +619,7 @@ std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
return {};
}
-// typedef std::map<std::string, Value *> valmap;
-
-/*void addEnv(Value * v, valmap &vmap)
-{
- if (v.isThunk()) {
- Env * env = v.thunk.env;
-
- Expr * expr = v.thunk.expr;
-
-}
-*/
-// LocalNoInline(valmap * map0())
-// {
-// return new valmap();
-// }
-
-// LocalNoInline(valmap * map1(const char *name, Value *v))
-// {
-// return new valmap({{name, v}});
-// }
-
-// LocalNoInline(valmap * map2(const char *name1, Value *v1, const char *name2, Value *v2))
-// {
-// return new valmap({{name1, v1}, {name2, v2}});
-// }
-
-// LocalNoInline(valmap * mapBindings(Bindings &b))
-// {
-// auto map = new valmap();
-// for (auto i = b.begin(); i != b.end(); ++i)
-// {
-// std::string s = i->name;
-// (*map)[s] = i->value;
-// }
-// return map;
-// }
-
-// LocalNoInline(void addBindings(string prefix, Bindings &b, valmap &valmap))
-// {
-// for (auto i = b.begin(); i != b.end(); ++i)
-// {
-// std::string s = prefix;
-// s += i->name;
-// valmap[s] = i->value;
-// }
-// }
-
-void printEnvBindings(const Env &env, int lv )
-{
- std::cout << "env " << lv << " type: " << env.type << std::endl;
- if (env.values[0]->type() == nAttrs) {
- Bindings::iterator j = env.values[0]->attrs->begin();
-
-
- while (j != env.values[0]->attrs->end()) {
- std::cout << lv << " env binding: " << j->name << std::endl;
- // if (countCalls && j->pos) attrSelects[*j->pos]++;
- // return j->value;
- j++;
- }
-
- }
- std::cout << "next env : " << env.up << std::endl;
-
- if (env.up) {
- printEnvBindings(*env.up, ++lv);
- }
-}
void printStaticEnvBindings(const StaticEnv &se, int lvl)
{
@@ -740,95 +672,6 @@ valmap * mapStaticEnvBindings(const StaticEnv &se, const Env &env)
}
-void printEnvPosChain(const Env &env, int lv )
-{
- // std::cout << "printEnvPosChain " << lv << std::endl;
-
- // std::cout << "env" << env.values[0] << std::endl;
-
- if (env.values[0] && env.values[0]->type() == nAttrs) {
- // std::cout << "im in the loop" << std::endl;
- // std::cout << "pos " << env.values[0]->attrs->pos << std::endl;
- if (env.values[0]->attrs->pos) {
- ErrPos ep(*env.values[0]->attrs->pos);
- auto loc = getCodeLines(ep);
- if (loc)
- printCodeLines(std::cout,
- std::__cxx11::to_string(lv),
- ep,
- *loc);
- }
- }
-
- // std::cout << "next env : " << env.up << std::endl;
-
- if (env.up) {
- printEnvPosChain(*env.up, ++lv);
- }
-}
-
-void mapEnvBindings(const Env &env, valmap & vm)
-{
- // add bindings for the next level up first.
- if (env.up) {
- mapEnvBindings(*env.up, vm);
- }
-
- // merge - and write over - higher level bindings.
- // note; skipping HasWithExpr that haven't been evaled yet.
- if (env.values[0] && env.values[0]->type() == nAttrs) {
- auto map = valmap();
-
- Bindings::iterator j = env.values[0]->attrs->begin();
-
- while (j != env.values[0]->attrs->end()) {
- map[j->name] = j->value;
- j++;
- }
- vm.merge(map);
- }
-}
-
-
-valmap * mapEnvBindings(const Env &env)
-{
- auto vm = new valmap();
-
- mapEnvBindings(env, *vm);
-
- return vm;
-}
-
-// LocalNoInline(valmap * mapEnvBindings(Env &env))
-// {
-// // NOT going to use this
-// if (env.valuemap) {
-// std::cout << "got static env" << std::endl;
-// }
-
-// // std::cout << "envsize: " << env.values.size() << std::endl;
-
-// // std::cout << "size_t size: " << sizeof(size_t) << std::endl;
-// // std::cout << "envsize: " << env.size << std::endl;
-// // std::cout << "envup: " << env.up << std::endl;
-
-// valmap *vm = env.up ? mapEnvBindings(*env.up) : new valmap();
-
-// /*
-// size_t i=0;
-// do {
-// std::cout << "env: " << i << " value: " << showType(*env.values[i]) << std::endl;
-// // std::cout << *env.values[i] << std::endl;
-// ++i;
-// } while(i < (std::min(env.size, (size_t)100)));
-
-
-// if (env.values[0]->type() == nAttrs)
-// addBindings(std::to_string((int)env.size), *env.values[0]->attrs, *vm);
-// */
-// return vm;
-// }
-
/* Every "format" object (even temporary) takes up a few hundred bytes
of stack space, which is a real killer in the recursive
evaluator. So here are some helper functions for throwing
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index 29599cc6c..ae1e6ee60 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -45,9 +45,6 @@ struct Env
Value * values[0];
};
-void printEnvBindings(const Env &env, int lv = 0);
-valmap * mapEnvBindings(const Env &env);
-void printEnvPosChain(const Env &env, int lv = 0);
valmap * mapStaticEnvBindings(const StaticEnv &se, const Env &env);
Value & mkString(Value & v, std::string_view s, const PathSet & context = PathSet());