libexpr: Migrate EvalState::mkPos to return a Value
Part of #1136 and progress towards #744 Change-Id: I31d0169077954ea82c9c7d341afdccd76a6a6964
This commit is contained in:
@@ -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
@@ -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
@@ -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`.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user