aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2020-12-12 02:09:10 +0100
committerSilvan Mosberger <contact@infinisil.com>2020-12-12 03:31:48 +0100
commit22ead43a0b8f94f5a4fb64cff14bf6a2a35d671c (patch)
treed2262f82e8e1032fa285a2ad6ad87f876feb93f7 /src/nix
parent9f056f7afdb85b8c3bd59638197e356f269129b2 (diff)
Use Value::normalType on all forced values instead of Value::type
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/eval.cc4
-rw-r--r--src/nix/flake.cc2
-rw-r--r--src/nix/repl.cc47
3 files changed, 25 insertions, 28 deletions
diff --git a/src/nix/eval.cc b/src/nix/eval.cc
index 0f02919de..bba3b1bc6 100644
--- a/src/nix/eval.cc
+++ b/src/nix/eval.cc
@@ -97,10 +97,10 @@ struct CmdEval : MixJSON, InstallableCommand
recurse = [&](Value & v, const Pos & pos, const Path & path)
{
state->forceValue(v);
- if (v.type == tString)
+ if (v.normalType() == nString)
// FIXME: disallow strings with contexts?
writeFile(path, v.string.s);
- else if (v.type == tAttrs) {
+ else if (v.normalType() == nAttrs) {
if (mkdir(path.c_str(), 0777) == -1)
throw SysError("creating directory '%s'", path);
for (auto & attr : *v.attrs)
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 7a7c71676..80b050091 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -279,7 +279,7 @@ struct CmdFlakeCheck : FlakeCommand
if (v.type == tLambda) {
if (!v.lambda.fun->matchAttrs || !v.lambda.fun->formals->ellipsis)
throw Error("module must match an open attribute set ('{ config, ... }')");
- } else if (v.type == tAttrs) {
+ } else if (v.normalType() == nAttrs) {
for (auto & attr : *v.attrs)
try {
state->forceValue(*attr.value, *attr.pos);
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index 3cee81b49..56184efb9 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -446,7 +446,7 @@ bool NixRepl::processLine(string line)
Pos pos;
- if (v.type == tPath || v.type == tString) {
+ if (v.normalType() == nPath || v.normalType() == nString) {
PathSet context;
auto filename = state->coerceToString(noPos, v, context);
pos.file = state->symbols.create(filename);
@@ -669,31 +669,31 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
state->forceValue(v);
- switch (v.type) {
+ switch (v.normalType()) {
- case tInt:
+ case nInt:
str << ANSI_CYAN << v.integer << ANSI_NORMAL;
break;
- case tBool:
+ case nBool:
str << ANSI_CYAN << (v.boolean ? "true" : "false") << ANSI_NORMAL;
break;
- case tString:
+ case nString:
str << ANSI_YELLOW;
printStringValue(str, v.string.s);
str << ANSI_NORMAL;
break;
- case tPath:
+ case nPath:
str << ANSI_GREEN << v.path << ANSI_NORMAL; // !!! escaping?
break;
- case tNull:
+ case nNull:
str << ANSI_CYAN "null" ANSI_NORMAL;
break;
- case tAttrs: {
+ case nAttrs: {
seen.insert(&v);
bool isDrv = state->isDerivation(v);
@@ -738,9 +738,7 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
break;
}
- case tList1:
- case tList2:
- case tListN:
+ case nList:
seen.insert(&v);
str << "[ ";
@@ -761,22 +759,21 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
str << "]";
break;
- case tLambda: {
- std::ostringstream s;
- s << v.lambda.fun->pos;
- str << ANSI_BLUE "«lambda @ " << filterANSIEscapes(s.str()) << "»" ANSI_NORMAL;
- break;
- }
-
- case tPrimOp:
- str << ANSI_MAGENTA "«primop»" ANSI_NORMAL;
- break;
-
- case tPrimOpApp:
- str << ANSI_BLUE "«primop-app»" ANSI_NORMAL;
+ case nFunction:
+ if (v.type == tLambda) {
+ std::ostringstream s;
+ s << v.lambda.fun->pos;
+ str << ANSI_BLUE "«lambda @ " << filterANSIEscapes(s.str()) << "»" ANSI_NORMAL;
+ } else if (v.type == tPrimOp) {
+ str << ANSI_MAGENTA "«primop»" ANSI_NORMAL;
+ } else if (v.type == tPrimOpApp) {
+ str << ANSI_BLUE "«primop-app»" ANSI_NORMAL;
+ } else {
+ abort();
+ }
break;
- case tFloat:
+ case nFloat:
str << v.fpoint;
break;