treewide: don't determinePos for forcing
only attrsets, lambdas, and app nodes can have positions determined, and none of these three types are incomplete. calling determinePos before we force a value is thus only a convoluted copy operation for its argument. Change-Id: I7e647aacca1fc8250f7bb11bb0071a4f7186047f
This commit is contained in:
@@ -291,7 +291,7 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
takesNixShellAttr(vRoot) ? *autoArgsWithInNixShell : *autoArgs,
|
||||
vRoot
|
||||
).first);
|
||||
state->forceValue(v, v.determinePos(noPos));
|
||||
state->forceValue(v, noPos);
|
||||
getDerivations(
|
||||
*state,
|
||||
v,
|
||||
|
||||
@@ -39,7 +39,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
||||
|
||||
for (auto & i : attrPaths) {
|
||||
Value & v(*findAlongAttrPath(state, i, autoArgs, vRoot).first);
|
||||
state.forceValue(v, v.determinePos(noPos));
|
||||
state.forceValue(v, noPos);
|
||||
|
||||
NixStringContext context;
|
||||
if (evalOnly) {
|
||||
|
||||
@@ -112,7 +112,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
||||
|
||||
/* Evaluate it. */
|
||||
debug("evaluating user environment builder");
|
||||
state.forceValue(topLevel, topLevel.determinePos(noPos));
|
||||
state.forceValue(topLevel, noPos);
|
||||
NixStringContext context;
|
||||
Attr & aDrvPath(*topLevel.attrs->find(state.ctx.s.drvPath));
|
||||
auto topLevelDrv = state.coerceToStorePath(aDrvPath.pos, *aDrvPath.value, context, "");
|
||||
|
||||
+4
-4
@@ -869,7 +869,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||
Value v;
|
||||
e->eval(state, *env, v);
|
||||
(void) e.release(); // NOLINT(bugprone-unused-return-value): leak because of thunk references
|
||||
state.forceValue(v, v.determinePos(noPos));
|
||||
state.forceValue(v, noPos);
|
||||
printValue(std::cout, v, 1);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
@@ -1056,7 +1056,7 @@ Value * NixRepl::replInitInfo()
|
||||
|
||||
void NixRepl::addAttrsToScope(Value & attrs)
|
||||
{
|
||||
state.forceAttrs(attrs, attrs.determinePos(noPos), "while evaluating an attribute set to be merged in the global scope");
|
||||
state.forceAttrs(attrs, noPos, "while evaluating an attribute set to be merged in the global scope");
|
||||
if (displ + attrs.attrs->size() >= envSize)
|
||||
throw Error("environment full; cannot add more variables");
|
||||
|
||||
@@ -1115,7 +1115,7 @@ void NixRepl::evalString(std::string s, Value & v)
|
||||
{
|
||||
Expr & e = parseString(s);
|
||||
e.eval(state, *env, v);
|
||||
state.forceValue(v, v.determinePos(noPos));
|
||||
state.forceValue(v, noPos);
|
||||
}
|
||||
|
||||
Value * NixRepl::evalFile(SourcePath & path)
|
||||
@@ -1123,7 +1123,7 @@ Value * NixRepl::evalFile(SourcePath & path)
|
||||
auto & expr = evaluator.parseExprFromFile(evaluator.paths.checkSourcePath(path), staticEnv);
|
||||
Value * result(evaluator.mem.allocValue());
|
||||
expr.eval(state, *env, *result);
|
||||
state.forceValue(*result, result->determinePos(noPos));
|
||||
state.forceValue(*result, noPos);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1136,7 +1136,7 @@ void ExprSet::eval(EvalState & state, Env & env, Value & v)
|
||||
Hence we need __overrides.) */
|
||||
if (hasOverrides) {
|
||||
Value * vOverrides = (*v.attrs)[overrides->second.displ].value;
|
||||
state.forceAttrs(*vOverrides, vOverrides->determinePos(noPos), "while evaluating the `__overrides` attribute");
|
||||
state.forceAttrs(*vOverrides, noPos, "while evaluating the `__overrides` attribute");
|
||||
Bindings * newBnds = state.ctx.mem.allocBindings(v.attrs->capacity() + vOverrides->attrs->size());
|
||||
for (auto & i : *v.attrs)
|
||||
newBnds->push_back(i);
|
||||
@@ -2137,7 +2137,7 @@ void EvalState::forceValueDeep(Value & v)
|
||||
recurse = [&](Value & v) {
|
||||
if (!seen.insert(&v).second) return;
|
||||
|
||||
forceValue(v, v.determinePos(noPos));
|
||||
forceValue(v, noPos);
|
||||
|
||||
if (v.type() == nAttrs) {
|
||||
for (auto & i : *v.attrs)
|
||||
|
||||
@@ -286,7 +286,7 @@ StringSet DrvInfo::queryMetaNames(EvalState & state)
|
||||
|
||||
bool DrvInfo::checkMeta(EvalState & state, Value & v)
|
||||
{
|
||||
state.forceValue(v, v.determinePos(noPos));
|
||||
state.forceValue(v, noPos);
|
||||
if (v.type() == nList) {
|
||||
for (auto elem : v.listItems())
|
||||
if (!checkMeta(state, *elem)) return false;
|
||||
@@ -375,7 +375,7 @@ static bool getDerivation(EvalState & state, Value & v,
|
||||
bool ignoreAssertionFailures)
|
||||
{
|
||||
try {
|
||||
state.forceValue(v, v.determinePos(noPos));
|
||||
state.forceValue(v, noPos);
|
||||
if (!state.isDerivation(v)) return true;
|
||||
|
||||
DrvInfo drv(attrPath, v.attrs);
|
||||
|
||||
@@ -626,14 +626,14 @@ static RegisterPrimOp primop_addErrorContext(PrimOp {
|
||||
|
||||
static void prim_ceil(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
||||
{
|
||||
auto value = state.forceFloat(*args[0], args[0]->determinePos(pos),
|
||||
auto value = state.forceFloat(*args[0], pos,
|
||||
"while evaluating the first argument passed to builtins.ceil");
|
||||
v.mkInt(ceil(value));
|
||||
}
|
||||
|
||||
static void prim_floor(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
||||
{
|
||||
auto value = state.forceFloat(*args[0], args[0]->determinePos(pos), "while evaluating the first argument passed to builtins.floor");
|
||||
auto value = state.forceFloat(*args[0], pos, "while evaluating the first argument passed to builtins.floor");
|
||||
v.mkInt(floor(value));
|
||||
}
|
||||
|
||||
@@ -2346,7 +2346,7 @@ static void prim_concatMap(EvalState & state, const PosIdx pos, Value * * args,
|
||||
for (unsigned int n = 0; n < nrLists; ++n) {
|
||||
Value * vElem = args[1]->listElems()[n];
|
||||
state.callFunction(*args[0], *vElem, lists[n], pos);
|
||||
state.forceList(lists[n], lists[n].determinePos(args[0]->determinePos(pos)), "while evaluating the return value of the function passed to builtins.concatMap");
|
||||
state.forceList(lists[n], pos, "while evaluating the return value of the function passed to builtins.concatMap");
|
||||
len += lists[n].listSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ private:
|
||||
|
||||
if (options.force) {
|
||||
// The item is going to be forced during printing anyway, but we need its type now.
|
||||
state.forceValue(*item, item->determinePos(noPos));
|
||||
state.forceValue(*item, noPos);
|
||||
}
|
||||
|
||||
// Pretty-print single-item attrsets only if they contain nested
|
||||
@@ -339,7 +339,7 @@ private:
|
||||
|
||||
if (options.force) {
|
||||
// The item is going to be forced during printing anyway, but we need its type now.
|
||||
state.forceValue(*item, item->determinePos(noPos));
|
||||
state.forceValue(*item, noPos);
|
||||
}
|
||||
|
||||
// Pretty-print single-item lists only if they contain nested
|
||||
@@ -479,7 +479,7 @@ private:
|
||||
|
||||
try {
|
||||
if (options.force) {
|
||||
state.forceValue(v, v.determinePos(noPos));
|
||||
state.forceValue(v, noPos);
|
||||
}
|
||||
|
||||
switch (v.type()) {
|
||||
|
||||
Reference in New Issue
Block a user