libexpr: Migrate EvalState::mkPos to return a Value

Part of #1136 and progress towards #744

Change-Id: I31d0169077954ea82c9c7d341afdccd76a6a6964
This commit is contained in:
skye
2026-03-17 15:48:12 -04:00
parent 810a3bad11
commit 179164cffc
4 changed files with 6 additions and 8 deletions
+1 -3
View File
@@ -527,9 +527,7 @@ Value ExprConcatStrings::eval(EvalState & state, Env & env)
Value ExprPos::eval(EvalState & state, Env & env)
{
Value v;
state.mkPos(v, pos);
return v;
return state.mkPos(pos);
}
Value ExprBlackHole::eval(EvalState & state, Env & env)
+3 -3
View File
@@ -851,7 +851,7 @@ Value Evaluator::evalLazily(Expr & e)
return {NewValueAs::thunk, mem, builtins.env, e};
}
void EvalState::mkPos(Value & v, PosIdx p)
Value EvalState::mkPos(PosIdx p)
{
auto origin = ctx.positions.originOf(p);
if (auto path = std::get_if<CheckedSourcePath>(&origin)) {
@@ -860,9 +860,9 @@ void EvalState::mkPos(Value & v, PosIdx p)
auto [line, col] = makePositionThunks(*this, p);
attrs.insert(ctx.symbols.sym_line, line);
attrs.insert(ctx.symbols.sym_column, col);
v = {NewValueAs::attrs, attrs};
return {NewValueAs::attrs, attrs};
} else
v = Value::VNULL;
return Value::VNULL;
}
Value EvalPaths::mkStorePathString(const StorePath & p)
+1 -1
View File
@@ -800,7 +800,7 @@ public:
*/
Value autoCallFunction(Bindings & args, Value & fun, PosIdx pos);
void mkPos(Value & v, PosIdx pos);
Value mkPos(PosIdx pos);
/**
* Create a string representing a `SingleDerivedPath::Built`.
+1 -1
View File
@@ -1906,7 +1906,7 @@ static void prim_unsafeGetAttrPos(EvalState & state, Value * * args, Value & v)
if (!i) {
v = Value::VNULL;
} else {
state.mkPos(v, i->pos);
v = state.mkPos(i->pos);
}
}