aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2021-09-22 16:22:53 -0600
committerBen Burdette <bburdette@gmail.com>2021-09-22 16:22:53 -0600
commitc7e3d830c1f305797b7a4c8b8199ba913d6b8a02 (patch)
tree7b1be463539f3e27a905470fc1e5c6aa40118586 /src
parent037d53d9d932dab0e24d919e3fcbf1a6c5538030 (diff)
more debug stuff
Diffstat (limited to 'src')
-rw-r--r--src/libcmd/installables.cc4
-rw-r--r--src/libexpr/nixexpr.cc41
-rw-r--r--src/libexpr/parser.y2
-rw-r--r--src/libexpr/primops.cc3
4 files changed, 45 insertions, 5 deletions
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index fd3e5cbba..bce666de5 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -619,6 +619,10 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
state->evalFile(lookupFileArg(*state, *file), *vFile);
else {
auto e = state->parseExprFromString(*expr, absPath("."));
+
+ int x = 5;
+ std::cout << "x =" << x << std::endl;
+
state->eval(e, *vFile);
}
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index f8ded2157..6db047bf7 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -315,12 +315,16 @@ void ExprAttrs::bindVars(const std::shared_ptr<const StaticEnv> &env)
// auto dynamicEnv(env);
if (recursive) {
+ std::cout << "recursive" << std::endl;
// dynamicEnv = newEnv.get();
- auto newEnv = std::shared_ptr<StaticEnv>(new StaticEnv(false, env.get())); // also make shared_ptr?
+ // also make shared_ptr?
+ auto newEnv = std::shared_ptr<StaticEnv>(new StaticEnv(false, env.get()));
unsigned int displ = 0;
- for (auto & i : attrs)
+ for (auto & i : attrs) {
+ std::cout << "newenvvar: " << i.first << std::endl;
newEnv->vars[i.first] = i.second.displ = displ++;
+ }
for (auto & i : attrs)
i.second.e->bindVars(i.second.inherited ? env : newEnv);
@@ -330,8 +334,8 @@ void ExprAttrs::bindVars(const std::shared_ptr<const StaticEnv> &env)
i.valueExpr->bindVars(newEnv);
}
}
-
else {
+ std::cout << "NOT recursive" << std::endl;
for (auto & i : attrs)
i.second.e->bindVars(env);
@@ -409,7 +413,7 @@ void ExprWith::bindVars(const std::shared_ptr<const StaticEnv> &env)
body->show(std::cout);
std::cout << std::endl;
- std::cout << "ExprWith::newenv: " << newEnv->vars.size() << std::endl;
+ std::cout << "ExprWith::newenv: (iswith, size); (" << newEnv->isWith << ", " << newEnv->vars.size() << ") " << std::endl;
for (auto i = newEnv->vars.begin(); i != newEnv->vars.end(); ++i)
std::cout << "EvalState::parse newEnv " << i->first << std::endl;
@@ -418,6 +422,35 @@ void ExprWith::bindVars(const std::shared_ptr<const StaticEnv> &env)
std::cout << " ExprWith::bindVars 3" << std::endl;
}
+/*
+void ExprWith::bindVars(const StaticEnv & env)
+{
+ // Does this `with' have an enclosing `with'? If so, record its
+ // level so that `lookupVar' can look up variables in the previous
+ // `with' if this one doesn't contain the desired attribute.
+ const StaticEnv * curEnv;
+ unsigned int level;
+ prevWith = 0;
+ for (curEnv = &env, level = 1; curEnv; curEnv = curEnv->up, level++)
+ if (curEnv->isWith) {
+ prevWith = level;
+ break;
+ }
+
+ attrs->bindVars(env);
+ std::cout << "ExprWith::bindVars env: " << env.vars.size(); // add std::endl;
+ for (auto i = env.vars.begin(); i != env.vars.end(); ++i)
+ {
+ std::cout << i->first << std::endl;
+ }
+
+ StaticEnv newEnv(true, &env);
+ body->bindVars(newEnv);
+}
+*/
+
+
+
void ExprIf::bindVars(const std::shared_ptr<const StaticEnv> &env)
{
cond->bindVars(env);
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index a3432eb32..f10e73cda 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -574,7 +574,7 @@ namespace nix {
Expr * EvalState::parse(const char * text, FileOrigin origin,
const Path & path, const Path & basePath, std::shared_ptr<StaticEnv> & staticEnv)
{
- std::cout << "EvalState::parse " << std::endl;
+ std::cout << "EvalState::parse " << text << std::endl;
for (auto i = staticEnv->vars.begin(); i != staticEnv->vars.end(); ++i)
std::cout << "EvalState::parse staticEnv " << i->first << std::endl;
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 7a277a7f5..246a3140b 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -110,6 +110,9 @@ static void mkOutputString(EvalState & state, Value & v,
argument. */
static void import(EvalState & state, const Pos & pos, Value & vPath, Value * vScope, Value & v)
{
+ std::cout << " IMPORT " << std::endl;
+ std::cout << " import " << std::endl;
+ std::cout << " IMPORT " << std::endl;
std::cout << " import " << std::endl;
PathSet context;