forked from lix-project/lix
Use RootValue
This commit is contained in:
parent
f89349f07e
commit
c277231b7d
3 changed files with 12 additions and 12 deletions
|
@ -254,10 +254,10 @@ static Flake getFlake(
|
||||||
|
|
||||||
if (auto outputs = vInfo.attrs->get(sOutputs)) {
|
if (auto outputs = vInfo.attrs->get(sOutputs)) {
|
||||||
expectType(state, tLambda, *outputs->value, *outputs->pos);
|
expectType(state, tLambda, *outputs->value, *outputs->pos);
|
||||||
flake.vOutputs = outputs->value;
|
flake.vOutputs = allocRootValue(outputs->value);
|
||||||
|
|
||||||
if (flake.vOutputs->lambda.fun->matchAttrs) {
|
if ((*flake.vOutputs)->lambda.fun->matchAttrs) {
|
||||||
for (auto & formal : flake.vOutputs->lambda.fun->formals->formals) {
|
for (auto & formal : (*flake.vOutputs)->lambda.fun->formals->formals) {
|
||||||
if (formal.name != state.sSelf)
|
if (formal.name != state.sSelf)
|
||||||
flake.inputs.emplace(formal.name, FlakeInput {
|
flake.inputs.emplace(formal.name, FlakeInput {
|
||||||
.ref = parseFlakeRef(formal.name)
|
.ref = parseFlakeRef(formal.name)
|
||||||
|
@ -613,16 +613,16 @@ void callFlake(EvalState & state,
|
||||||
|
|
||||||
mkString(*vRootSubdir, lockedFlake.flake.lockedRef.subdir);
|
mkString(*vRootSubdir, lockedFlake.flake.lockedRef.subdir);
|
||||||
|
|
||||||
static Value * vCallFlake = nullptr;
|
static RootValue vCallFlake = nullptr;
|
||||||
|
|
||||||
if (!vCallFlake) {
|
if (!vCallFlake) {
|
||||||
vCallFlake = state.allocValue();
|
vCallFlake = allocRootValue(state.allocValue());
|
||||||
state.eval(state.parseExprFromString(
|
state.eval(state.parseExprFromString(
|
||||||
#include "call-flake.nix.gen.hh"
|
#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(*vTmp1, *vRootSrc, *vTmp2, noPos);
|
||||||
state.callFunction(*vTmp2, *vRootSubdir, vRes, noPos);
|
state.callFunction(*vTmp2, *vRootSubdir, vRes, noPos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
#include "flakeref.hh"
|
#include "flakeref.hh"
|
||||||
#include "lockfile.hh"
|
#include "lockfile.hh"
|
||||||
|
#include "value.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
struct Value;
|
|
||||||
class EvalState;
|
class EvalState;
|
||||||
|
|
||||||
namespace fetchers { struct Tree; }
|
namespace fetchers { struct Tree; }
|
||||||
|
@ -33,7 +33,7 @@ struct Flake
|
||||||
std::optional<std::string> description;
|
std::optional<std::string> description;
|
||||||
std::shared_ptr<const fetchers::Tree> sourceInfo;
|
std::shared_ptr<const fetchers::Tree> sourceInfo;
|
||||||
FlakeInputs inputs;
|
FlakeInputs inputs;
|
||||||
Value * vOutputs; // FIXME: gc
|
RootValue vOutputs;
|
||||||
~Flake();
|
~Flake();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -239,18 +239,18 @@ struct InstallableExpr : InstallableValue
|
||||||
|
|
||||||
struct InstallableAttrPath : InstallableValue
|
struct InstallableAttrPath : InstallableValue
|
||||||
{
|
{
|
||||||
Value * v;
|
RootValue v;
|
||||||
std::string attrPath;
|
std::string attrPath;
|
||||||
|
|
||||||
InstallableAttrPath(SourceExprCommand & cmd, Value * v, const 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::string what() override { return attrPath; }
|
||||||
|
|
||||||
std::pair<Value *, Pos> toValue(EvalState & state) override
|
std::pair<Value *, Pos> 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);
|
state.forceValue(*vRes);
|
||||||
return {vRes, pos};
|
return {vRes, pos};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue