From c277231b7d8c11b8612acda578f759a6fd427c8f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 16 Apr 2020 16:54:34 +0200 Subject: [PATCH] Use RootValue --- src/libexpr/flake/flake.cc | 14 +++++++------- src/libexpr/flake/flake.hh | 4 ++-- src/nix/installables.cc | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index 212eceeac..cb50bd013 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -254,10 +254,10 @@ static Flake getFlake( if (auto outputs = vInfo.attrs->get(sOutputs)) { expectType(state, tLambda, *outputs->value, *outputs->pos); - flake.vOutputs = outputs->value; + flake.vOutputs = allocRootValue(outputs->value); - if (flake.vOutputs->lambda.fun->matchAttrs) { - for (auto & formal : flake.vOutputs->lambda.fun->formals->formals) { + if ((*flake.vOutputs)->lambda.fun->matchAttrs) { + for (auto & formal : (*flake.vOutputs)->lambda.fun->formals->formals) { if (formal.name != state.sSelf) flake.inputs.emplace(formal.name, FlakeInput { .ref = parseFlakeRef(formal.name) @@ -613,16 +613,16 @@ void callFlake(EvalState & state, mkString(*vRootSubdir, lockedFlake.flake.lockedRef.subdir); - static Value * vCallFlake = nullptr; + static RootValue vCallFlake = nullptr; if (!vCallFlake) { - vCallFlake = state.allocValue(); + vCallFlake = allocRootValue(state.allocValue()); state.eval(state.parseExprFromString( #include "call-flake.nix.gen.hh" - , "/"), *vCallFlake); + , "/"), **vCallFlake); } - state.callFunction(*vCallFlake, *vLocks, *vTmp1, noPos); + state.callFunction(**vCallFlake, *vLocks, *vTmp1, noPos); state.callFunction(*vTmp1, *vRootSrc, *vTmp2, noPos); state.callFunction(*vTmp2, *vRootSubdir, vRes, noPos); } diff --git a/src/libexpr/flake/flake.hh b/src/libexpr/flake/flake.hh index 107498c1b..59a1adb3b 100644 --- a/src/libexpr/flake/flake.hh +++ b/src/libexpr/flake/flake.hh @@ -3,10 +3,10 @@ #include "types.hh" #include "flakeref.hh" #include "lockfile.hh" +#include "value.hh" namespace nix { -struct Value; class EvalState; namespace fetchers { struct Tree; } @@ -33,7 +33,7 @@ struct Flake std::optional description; std::shared_ptr sourceInfo; FlakeInputs inputs; - Value * vOutputs; // FIXME: gc + RootValue vOutputs; ~Flake(); }; diff --git a/src/nix/installables.cc b/src/nix/installables.cc index 99bbe9769..b8c75aaaf 100644 --- a/src/nix/installables.cc +++ b/src/nix/installables.cc @@ -239,18 +239,18 @@ struct InstallableExpr : InstallableValue struct InstallableAttrPath : InstallableValue { - Value * v; + RootValue v; std::string attrPath; InstallableAttrPath(SourceExprCommand & cmd, Value * v, const std::string & attrPath) - : InstallableValue(cmd), v(v), attrPath(attrPath) + : InstallableValue(cmd), v(allocRootValue(v)), attrPath(attrPath) { } std::string what() override { return attrPath; } std::pair toValue(EvalState & state) override { - auto [vRes, pos] = findAlongAttrPath(state, attrPath, *cmd.getAutoArgs(state), *v); + auto [vRes, pos] = findAlongAttrPath(state, attrPath, *cmd.getAutoArgs(state), **v); state.forceValue(*vRes); return {vRes, pos}; }