From ea931d4d0325086df3979ca9dc851df8821cdd5e Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Tue, 3 Dec 2024 20:38:41 +0100 Subject: [PATCH] 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 --- lix/libcmd/common-eval-args.cc | 4 +++- lix/libexpr/eval.cc | 4 ++-- lix/libexpr/eval.hh | 6 +++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lix/libcmd/common-eval-args.cc b/lix/libcmd/common-eval-args.cc index 232f9a8e2..4cf6b43af 100644 --- a/lix/libcmd/common-eval-args.cc +++ b/lix/libcmd/common-eval-args.cc @@ -177,7 +177,9 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state) for (auto & i : autoArgs) { auto v = state.mem.allocValue(); 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 v->mkString(((std::string_view) i.second).substr(1)); res.insert(state.symbols.create(i.first), v); diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index 5f795fc30..c989dd0fb 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -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); } diff --git a/lix/libexpr/eval.hh b/lix/libexpr/eval.hh index a5e776fa3..d42e3ff87 100644 --- a/lix/libexpr/eval.hh +++ b/lix/libexpr/eval.hh @@ -539,6 +539,11 @@ public: */ 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 * type. @@ -690,7 +695,6 @@ public: return mem.buildBindings(symbols, capacity); } - void mkThunk_(Value & v, Expr & expr); void mkPos(Value & v, PosIdx pos); /**