aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/value-to-json.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-09-15 20:33:44 +0200
committerGitHub <noreply@github.com>2021-09-15 20:33:44 +0200
commit79152e307e7eef667c3de9c21571d017654a7c32 (patch)
tree67fd413bcf0b42c5ada7eddc41a04f7bd99df3a8 /src/libexpr/value-to-json.cc
parent7349f257da8278af9aae35544b15c9a204e2a57b (diff)
parent3b82c1a5fef521ebadea5df12384390c8c24100c (diff)
Merge pull request #5212 from mkenigs/auto-uid-allocation
Merge master into #3600
Diffstat (limited to 'src/libexpr/value-to-json.cc')
-rw-r--r--src/libexpr/value-to-json.cc25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/libexpr/value-to-json.cc b/src/libexpr/value-to-json.cc
index 6ec8315ba..bfea24d40 100644
--- a/src/libexpr/value-to-json.cc
+++ b/src/libexpr/value-to-json.cc
@@ -16,30 +16,30 @@ void printValueAsJSON(EvalState & state, bool strict,
if (strict) state.forceValue(v);
- switch (v.type) {
+ switch (v.type()) {
- case tInt:
+ case nInt:
out.write(v.integer);
break;
- case tBool:
+ case nBool:
out.write(v.boolean);
break;
- case tString:
+ case nString:
copyContext(v, context);
out.write(v.string.s);
break;
- case tPath:
+ case nPath:
out.write(state.copyPathToStore(context, v.path));
break;
- case tNull:
+ case nNull:
out.write(nullptr);
break;
- case tAttrs: {
+ case nAttrs: {
auto maybeString = state.tryAttrsToString(noPos, v, context, false, false);
if (maybeString) {
out.write(*maybeString);
@@ -61,7 +61,7 @@ void printValueAsJSON(EvalState & state, bool strict,
break;
}
- case tList1: case tList2: case tListN: {
+ case nList: {
auto list(out.list());
for (unsigned int n = 0; n < v.listSize(); ++n) {
auto placeholder(list.placeholder());
@@ -70,15 +70,18 @@ void printValueAsJSON(EvalState & state, bool strict,
break;
}
- case tExternal:
+ case nExternal:
v.external->printValueAsJSON(state, strict, out, context);
break;
- case tFloat:
+ case nFloat:
out.write(v.fpoint);
break;
- default:
+ case nThunk:
+ throw TypeError("cannot convert %1% to JSON", showType(v));
+
+ case nFunction:
throw TypeError("cannot convert %1% to JSON", showType(v));
}
}