forked from lix-project/lix
add cout debugging
This commit is contained in:
parent
1e04b2568d
commit
cd8c232b55
2
Makefile
2
Makefile
|
@ -15,7 +15,7 @@ makefiles = \
|
||||||
misc/systemd/local.mk \
|
misc/systemd/local.mk \
|
||||||
misc/launchd/local.mk \
|
misc/launchd/local.mk \
|
||||||
misc/upstart/local.mk \
|
misc/upstart/local.mk \
|
||||||
doc/manual/local.mk \
|
# doc/manual/local.mk \
|
||||||
tests/local.mk \
|
tests/local.mk \
|
||||||
tests/plugins/local.mk
|
tests/plugins/local.mk
|
||||||
|
|
||||||
|
|
|
@ -99,8 +99,6 @@ EvalCommand::EvalCommand()
|
||||||
// extern std::function<void(const Error & error, const std::map<std::string, Value *> & env)> debuggerHook;
|
// 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)> debuggerHook;
|
extern std::function<void(const Error & error, const Env & env)> debuggerHook;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ref<EvalState> EvalCommand::getEvalState()
|
ref<EvalState> EvalCommand::getEvalState()
|
||||||
{
|
{
|
||||||
std::cout << "EvalCommand::getEvalState()" << startReplOnEvalErrors << std::endl;
|
std::cout << "EvalCommand::getEvalState()" << startReplOnEvalErrors << std::endl;
|
||||||
|
|
|
@ -918,6 +918,8 @@ LocalNoInlineNoReturn(void throwUndefinedVarError(const Pos & pos, const char *
|
||||||
.errPos = pos
|
.errPos = pos
|
||||||
});
|
});
|
||||||
|
|
||||||
|
std::cout << "pre debuggerHook" << std::endl;
|
||||||
|
|
||||||
if (debuggerHook)
|
if (debuggerHook)
|
||||||
debuggerHook(error, env);
|
debuggerHook(error, env);
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
@ -283,6 +283,7 @@ void ExprVar::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
||||||
enclosing `with'. If there is no `with', then we can issue an
|
enclosing `with'. If there is no `with', then we can issue an
|
||||||
"undefined variable" error now. */
|
"undefined variable" error now. */
|
||||||
if (withLevel == -1)
|
if (withLevel == -1)
|
||||||
|
std::cout << " throw UndefinedVarError({" << std::endl;
|
||||||
throw UndefinedVarError({
|
throw UndefinedVarError({
|
||||||
.msg = hintfmt("undefined variable '%1%'", name),
|
.msg = hintfmt("undefined variable '%1%'", name),
|
||||||
.errPos = pos
|
.errPos = pos
|
||||||
|
@ -310,11 +311,12 @@ void ExprOpHasAttr::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
||||||
|
|
||||||
void ExprAttrs::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
void ExprAttrs::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
||||||
{
|
{
|
||||||
const StaticEnv * dynamicEnv = env.get();
|
std::cout << "ExprAttrs::bindVars" << std::endl;
|
||||||
auto newEnv = std::shared_ptr<StaticEnv>(new StaticEnv(false, env.get())); // also make shared_ptr?
|
// auto dynamicEnv(env);
|
||||||
|
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
dynamicEnv = newEnv.get();
|
// dynamicEnv = newEnv.get();
|
||||||
|
auto newEnv = std::shared_ptr<StaticEnv>(new StaticEnv(false, env.get())); // also make shared_ptr?
|
||||||
|
|
||||||
unsigned int displ = 0;
|
unsigned int displ = 0;
|
||||||
for (auto & i : attrs)
|
for (auto & i : attrs)
|
||||||
|
@ -322,16 +324,25 @@ void ExprAttrs::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
||||||
|
|
||||||
for (auto & i : attrs)
|
for (auto & i : attrs)
|
||||||
i.second.e->bindVars(i.second.inherited ? env : newEnv);
|
i.second.e->bindVars(i.second.inherited ? env : newEnv);
|
||||||
|
|
||||||
|
for (auto & i : dynamicAttrs) {
|
||||||
|
i.nameExpr->bindVars(newEnv);
|
||||||
|
i.valueExpr->bindVars(newEnv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
for (auto & i : attrs)
|
for (auto & i : attrs)
|
||||||
i.second.e->bindVars(env);
|
i.second.e->bindVars(env);
|
||||||
|
|
||||||
for (auto & i : dynamicAttrs) {
|
for (auto & i : dynamicAttrs) {
|
||||||
i.nameExpr->bindVars(newEnv);
|
i.nameExpr->bindVars(env);
|
||||||
i.valueExpr->bindVars(newEnv);
|
i.valueExpr->bindVars(env);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "ExprAttrs::bindVars end" << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExprList::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
void ExprList::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
||||||
|
@ -375,6 +386,7 @@ void ExprLet::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
||||||
|
|
||||||
void ExprWith::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
void ExprWith::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
||||||
{
|
{
|
||||||
|
std::cout << " ExprWith::bindVars " << std::endl;
|
||||||
/* Does this `with' have an enclosing `with'? If so, record its
|
/* Does this `with' have an enclosing `with'? If so, record its
|
||||||
level so that `lookupVar' can look up variables in the previous
|
level so that `lookupVar' can look up variables in the previous
|
||||||
`with' if this one doesn't contain the desired attribute. */
|
`with' if this one doesn't contain the desired attribute. */
|
||||||
|
@ -387,9 +399,23 @@ void ExprWith::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << " ExprWith::bindVars 1" << std::endl;
|
||||||
|
attrs->show(std::cout);
|
||||||
|
std::cout << std::endl;
|
||||||
attrs->bindVars(env);
|
attrs->bindVars(env);
|
||||||
auto newEnv = std::shared_ptr<StaticEnv>(new StaticEnv(false, env.get())); // also make shared_ptr?
|
auto newEnv = std::shared_ptr<StaticEnv>(new StaticEnv(false, env.get())); // also make shared_ptr?
|
||||||
|
std::cout << " ExprWith::bindVars 2" << std::endl;
|
||||||
|
std::cout << " body: " << std::endl;
|
||||||
|
body->show(std::cout);
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
std::cout << "ExprWith::newenv: " << 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;
|
||||||
|
|
||||||
|
|
||||||
body->bindVars(newEnv);
|
body->bindVars(newEnv);
|
||||||
|
std::cout << " ExprWith::bindVars 3" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExprIf::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
void ExprIf::bindVars(const std::shared_ptr<const StaticEnv> &env)
|
||||||
|
|
|
@ -20,6 +20,7 @@ MakeError(UndefinedVarError, Error);
|
||||||
MakeError(MissingArgumentError, EvalError);
|
MakeError(MissingArgumentError, EvalError);
|
||||||
MakeError(RestrictedPathError, Error);
|
MakeError(RestrictedPathError, Error);
|
||||||
|
|
||||||
|
extern std::function<void(const Error & error, const Env & env)> debuggerHook;
|
||||||
|
|
||||||
/* Position objects. */
|
/* Position objects. */
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "eval.hh"
|
#include "eval.hh"
|
||||||
#include "globals.hh"
|
#include "globals.hh"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
struct ParseData
|
struct ParseData
|
||||||
|
@ -572,6 +574,10 @@ namespace nix {
|
||||||
Expr * EvalState::parse(const char * text, FileOrigin origin,
|
Expr * EvalState::parse(const char * text, FileOrigin origin,
|
||||||
const Path & path, const Path & basePath, std::shared_ptr<StaticEnv> & staticEnv)
|
const Path & path, const Path & basePath, std::shared_ptr<StaticEnv> & staticEnv)
|
||||||
{
|
{
|
||||||
|
std::cout << "EvalState::parse " << std::endl;
|
||||||
|
for (auto i = staticEnv->vars.begin(); i != staticEnv->vars.end(); ++i)
|
||||||
|
std::cout << "EvalState::parse staticEnv " << i->first << std::endl;
|
||||||
|
|
||||||
yyscan_t scanner;
|
yyscan_t scanner;
|
||||||
ParseData data(*this);
|
ParseData data(*this);
|
||||||
data.origin = origin;
|
data.origin = origin;
|
||||||
|
@ -595,8 +601,13 @@ Expr * EvalState::parse(const char * text, FileOrigin origin,
|
||||||
|
|
||||||
if (res) throw ParseError(data.error.value());
|
if (res) throw ParseError(data.error.value());
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "EvalState::parse pre bindvars " << std::endl;
|
||||||
|
|
||||||
data.result->bindVars(staticEnv);
|
data.result->bindVars(staticEnv);
|
||||||
|
|
||||||
|
std::cout << "EvalState::parse post bindVars " << std::endl;
|
||||||
|
|
||||||
return data.result;
|
return data.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,8 @@ static void mkOutputString(EvalState & state, Value & v,
|
||||||
argument. */
|
argument. */
|
||||||
static void import(EvalState & state, const Pos & pos, Value & vPath, Value * vScope, Value & v)
|
static void import(EvalState & state, const Pos & pos, Value & vPath, Value * vScope, Value & v)
|
||||||
{
|
{
|
||||||
|
std::cout << " import " << std::endl;
|
||||||
|
|
||||||
PathSet context;
|
PathSet context;
|
||||||
Path path = state.coerceToPath(pos, vPath, context);
|
Path path = state.coerceToPath(pos, vPath, context);
|
||||||
|
|
||||||
|
@ -194,6 +196,8 @@ static void import(EvalState & state, const Pos & pos, Value & vPath, Value * vS
|
||||||
env->values[displ++] = attr.value;
|
env->values[displ++] = attr.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "import staticenv: {} " << staticEnv << std::endl;
|
||||||
|
|
||||||
printTalkative("evaluating file '%1%'", realPath);
|
printTalkative("evaluating file '%1%'", realPath);
|
||||||
Expr * e = state.parseExprFromFile(resolveExprPath(realPath), staticEnv);
|
Expr * e = state.parseExprFromFile(resolveExprPath(realPath), staticEnv);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue