printEnvPosChain

This commit is contained in:
Ben Burdette 2021-09-13 11:57:25 -06:00
parent 310c689d31
commit 176911102c
11 changed files with 32193 additions and 4 deletions

8926
doc/manual/manual.html Normal file

File diff suppressed because one or more lines are too long

View file

20139
doc/manual/manual.xmli Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,52 @@
# Name
`nix.conf` - Nix configuration file
# Description
By default Nix reads settings from the following places:
- The system-wide configuration file `sysconfdir/nix/nix.conf` (i.e.
`/etc/nix/nix.conf` on most systems), or `$NIX_CONF_DIR/nix.conf` if
`NIX_CONF_DIR` is set. Values loaded in this file are not forwarded
to the Nix daemon. The client assumes that the daemon has already
loaded them.
- If `NIX_USER_CONF_FILES` is set, then each path separated by `:`
will be loaded in reverse order.
Otherwise it will look for `nix/nix.conf` files in `XDG_CONFIG_DIRS`
and `XDG_CONFIG_HOME`. If these are unset, it will look in
`$HOME/.config/nix.conf`.
- If `NIX_CONFIG` is set, its contents is treated as the contents of
a configuration file.
The configuration files consist of `name = value` pairs, one per
line. Other files can be included with a line like `include path`,
where *path* is interpreted relative to the current conf file and a
missing file is an error unless `!include` is used instead. Comments
start with a `#` character. Here is an example configuration file:
keep-outputs = true # Nice for developers
keep-derivations = true # Idem
You can override settings on the command line using the `--option`
flag, e.g. `--option keep-outputs false`. Every configuration setting
also has a corresponding command line flag, e.g. `--max-jobs 16`; for
Boolean settings, there are two flags to enable or disable the setting
(e.g. `--keep-failed` and `--no-keep-failed`).
A configuration setting usually overrides any previous value. However,
you can prefix the name of the setting by `extra-` to *append* to the
previous value. For instance,
substituters = a b
extra-substituters = c d
defines the `substituters` setting to be `a b c d`. This is also
available as a command line flag (e.g. `--extra-substituters`).
The following settings are currently available:
EvalCommand::getEvalState()0

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,16 @@
# Built-in Functions
This section lists the functions built into the Nix expression
evaluator. (The built-in function `derivation` is discussed above.)
Some built-ins, such as `derivation`, are always in scope of every Nix
expression; you can just access them right away. But to prevent
polluting the namespace too much, most built-ins are not in
scope. Instead, you can access them through the `builtins` built-in
value, which is a set that contains all built-in functions and values.
For instance, `derivation` is also available as `builtins.derivation`.
- `derivation` *attrs*; `builtins.derivation` *attrs*\
`derivation` is described in [its own section](derivations.md).
EvalCommand::getEvalState()0

1
doc/manual/version.txt Normal file
View file

@ -0,0 +1 @@
3.0

View file

@ -109,6 +109,7 @@ ref<EvalState> EvalCommand::getEvalState()
if (startReplOnEvalErrors)
debuggerHook = [evalState{ref<EvalState>(evalState)}](const Error & error, const Env & 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());
// printEnvPosChain(env);
printEnvBindings(env);
auto vm = mapEnvBindings(env);
runRepl(evalState, *vm);

View file

@ -648,13 +648,11 @@ std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
// 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;
// }
@ -668,12 +666,13 @@ std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
// }
// }
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]++;
@ -690,6 +689,33 @@ void printEnvBindings(const Env &env, int lv )
}
}
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.
@ -699,7 +725,7 @@ void mapEnvBindings(const Env &env, valmap & vm)
// merge - and write over - higher level bindings.
// note; skipping HasWithExpr that haven't been evaled yet.
if (env.values[0]->type() == nAttrs) {
if (env.values[0] && env.values[0]->type() == nAttrs) {
auto map = valmap();
Bindings::iterator j = env.values[0]->attrs->begin();

View file

@ -45,6 +45,7 @@ struct Env
void printEnvBindings(const Env &env, int lv = 0);
valmap * mapEnvBindings(const Env &env);
void printEnvPosChain(const Env &env, int lv = 0);
Value & mkString(Value & v, std::string_view s, const PathSet & context = PathSet());

View file

@ -100,6 +100,12 @@ struct ErrPos {
}
};
std::optional<LinesOfCode> getCodeLines(const ErrPos & errPos);
void printCodeLines(std::ostream & out,
const string & prefix,
const ErrPos & errPos,
const LinesOfCode & loc);
struct Trace {
std::optional<ErrPos> pos;
hintformat hint;