From ae5b76a5a438662d5206ce21e0d55858ca87f08c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 23 Apr 2019 00:39:14 +0200 Subject: [PATCH] Checkpoint --- src/libexpr/eval.cc | 5 +++-- src/libexpr/gc.hh | 7 +++++-- src/libexpr/primops.cc | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 5b19e7001..152cc6494 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -1330,8 +1330,9 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v) bool first = !forceString; Tag firstType = tString; + auto vTmp = state.allocValue(); + for (auto & i : *es) { - Root vTmp; i->eval(state, env, vTmp); /* If the first element is a path, then the result will also @@ -1534,7 +1535,7 @@ string EvalState::coerceToString(const Pos & pos, Value & v, PathSet & context, if (v.type == tAttrs) { auto i = v.attrs->find(sToString); if (i != v.attrs->end()) { - Root v1; + auto v1 = allocValue(); callFunction(*i->value, v, v1, pos); return coerceToString(pos, v1, context, coerceMore, copyToStore); } diff --git a/src/libexpr/gc.hh b/src/libexpr/gc.hh index 20841d568..411883e87 100644 --- a/src/libexpr/gc.hh +++ b/src/libexpr/gc.hh @@ -225,7 +225,7 @@ private: ArenaList(); }; - std::array arenaLists; + std::array arenaLists; public: @@ -235,7 +235,10 @@ public: template Ptr alloc(Size size, const Args & ... args) { - ArenaList & arenaList = size == 3 ? arenaLists[0] : arenaLists[1]; + ArenaList & arenaList = + size == 3 ? arenaLists[0] : + size == 4 ? arenaLists[1] : + arenaLists[2]; for (int i = 0; i < 3; i++) { diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index a8a6d13eb..6f6fb7e79 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -119,7 +119,7 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args mkString(*(outputsVal->listElems()[outputs_index++]), o.first); } w->attrs->sort(); - Root fun; + auto fun = state.allocValue(); state.evalFile(settings.nixDataDir + "/nix/corepkgs/imported-drv-to-derivation.nix", fun); state.forceFunction(fun, pos); mkApp(v, fun, w); @@ -1497,7 +1497,7 @@ static void prim_foldlStrict(EvalState & state, const Pos & pos, Value * * args, Ptr vCur = args[1]; for (unsigned int n = 0; n < args[2]->listSize(); ++n) { - Root vTmp; + Root vTmp; // FIXME: correct? state.callFunction(*args[0], *vCur, vTmp, pos); vCur = n == args[2]->listSize() - 1 ? Ptr(&v) : state.allocValue(); state.callFunction(vTmp, *args[2]->listElems()[n], *vCur, pos); @@ -1580,7 +1580,7 @@ static void prim_sort(EvalState & state, const Pos & pos, Value * * args, Value if (args[0]->type == tPrimOp && args[0]->primOp->fun == prim_lessThan) return CompareValues()(a, b); - Root vTmp1, vTmp2; + Root vTmp1, vTmp2; // FIXME state.callFunction(*args[0], *a, vTmp1, pos); state.callFunction(vTmp1, *b, vTmp2, pos); return state.forceBool(vTmp2, pos);