mirror of
https://github.com/NixOS/nix.git
synced 2025-11-24 11:19:35 +01:00
libexpr: make ExprCall::args an std::optional
This commit is contained in:
parent
43fc6c314d
commit
484f40fc64
4 changed files with 10 additions and 7 deletions
|
|
@ -1751,9 +1751,9 @@ void ExprCall::eval(EvalState & state, Env & env, Value & v)
|
|||
// 4: about 60
|
||||
// 5: under 10
|
||||
// This excluded attrset lambdas (`{...}:`). Contributions of mixed lambdas appears insignificant at ~150 total.
|
||||
SmallValueVector<4> vArgs(args.size());
|
||||
for (size_t i = 0; i < args.size(); ++i)
|
||||
vArgs[i] = args[i]->maybeThunk(state, env);
|
||||
SmallValueVector<4> vArgs(args->size());
|
||||
for (size_t i = 0; i < args->size(); ++i)
|
||||
vArgs[i] = (*args)[i]->maybeThunk(state, env);
|
||||
|
||||
state.callFunction(vFun, vArgs, v, pos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -592,7 +592,10 @@ public:
|
|||
struct ExprCall : Expr
|
||||
{
|
||||
Expr * fun;
|
||||
std::pmr::vector<Expr *> args;
|
||||
/**
|
||||
* args will never be null. See comment on ExprAttrs::AttrDefs below.
|
||||
*/
|
||||
std::optional<std::pmr::vector<Expr *>> args;
|
||||
PosIdx pos;
|
||||
std::optional<PosIdx> cursedOrEndPos; // used during parsing to warn about https://github.com/NixOS/nix/issues/11118
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ void ExprCall::show(const SymbolTable & symbols, std::ostream & str) const
|
|||
{
|
||||
str << '(';
|
||||
fun->show(symbols, str);
|
||||
for (auto e : args) {
|
||||
for (auto e : *args) {
|
||||
str << ' ';
|
||||
e->show(symbols, str);
|
||||
}
|
||||
|
|
@ -490,7 +490,7 @@ void ExprCall::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> &
|
|||
es.exprEnvs.insert(std::make_pair(this, env));
|
||||
|
||||
fun->bindVars(es, env);
|
||||
for (auto e : args)
|
||||
for (auto e : *args)
|
||||
e->bindVars(es, env);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ static void setDocPosition(const LexerState & lexerState, ExprLambda * lambda, P
|
|||
|
||||
static Expr * makeCall(Exprs & exprs, PosIdx pos, Expr * fn, Expr * arg) {
|
||||
if (auto e2 = dynamic_cast<ExprCall *>(fn)) {
|
||||
e2->args.push_back(arg);
|
||||
e2->args->push_back(arg);
|
||||
return fn;
|
||||
}
|
||||
return exprs.add<ExprCall>(pos, fn, {arg});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue