libexpr: mkThunk_ -> evalLazily

thunk creation doesn't have to be called that. thunks are more of an
implementation detail, calling it evalLazily seems a lot more clear.

Change-Id: I64bdac422eadb629002195cd6b6a89dce1b4a60f
This commit is contained in:
eldritch horrors 2024-12-03 20:38:41 +01:00
parent 32f7a93f71
commit ea931d4d03
3 changed files with 10 additions and 4 deletions

View file

@ -177,7 +177,9 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
for (auto & i : autoArgs) { for (auto & i : autoArgs) {
auto v = state.mem.allocValue(); auto v = state.mem.allocValue();
if (i.second[0] == 'E') if (i.second[0] == 'E')
state.mkThunk_(*v, state.parseExprFromString(i.second.substr(1), CanonPath::fromCwd())); state.evalLazily(
state.parseExprFromString(i.second.substr(1), CanonPath::fromCwd()), *v
);
else else
v->mkString(((std::string_view) i.second).substr(1)); v->mkString(((std::string_view) i.second).substr(1));
res.insert(state.symbols.create(i.first), v); res.insert(state.symbols.create(i.first), v);

View file

@ -788,9 +788,9 @@ static inline void mkThunk(Value & v, Env & env, Expr & expr)
} }
void EvalState::mkThunk_(Value & v, Expr & expr) void EvalState::evalLazily(Expr & e, Value & v)
{ {
mkThunk(v, builtins.env, expr); mkThunk(v, builtins.env, e);
} }

View file

@ -539,6 +539,11 @@ public:
*/ */
void eval(Expr & e, Value & v); void eval(Expr & e, Value & v);
/**
* Creates a thunk that will evaluate the given expression when forced.
*/
void evalLazily(Expr & e, Value & v);
/** /**
* Evaluation the expression, then verify that it has the expected * Evaluation the expression, then verify that it has the expected
* type. * type.
@ -690,7 +695,6 @@ public:
return mem.buildBindings(symbols, capacity); return mem.buildBindings(symbols, capacity);
} }
void mkThunk_(Value & v, Expr & expr);
void mkPos(Value & v, PosIdx pos); void mkPos(Value & v, PosIdx pos);
/** /**