mirror of
https://github.com/NixOS/nix
synced 2025-06-25 14:51:16 +02:00
Make most calls to determinePos() lazy
This commit is contained in:
parent
4c755c3b3f
commit
bd383d1b6f
10 changed files with 46 additions and 24 deletions
|
@ -219,7 +219,7 @@ string showType(const Value & v)
|
|||
}
|
||||
}
|
||||
|
||||
Pos Value::determinePos(const Pos &pos) const
|
||||
Pos Value::determinePos(const Pos & pos) const
|
||||
{
|
||||
switch (internalType) {
|
||||
case tAttrs: return *attrs->pos;
|
||||
|
@ -754,6 +754,11 @@ LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s, const
|
|||
});
|
||||
}
|
||||
|
||||
LocalNoInlineNoReturn(void throwTypeError(const char * s, const Value & v))
|
||||
{
|
||||
throw TypeError(s, showType(v));
|
||||
}
|
||||
|
||||
LocalNoInlineNoReturn(void throwAssertionError(const Pos & pos, const char * s, const string & s1))
|
||||
{
|
||||
throw AssertionError({
|
||||
|
@ -1138,7 +1143,7 @@ void ExprAttrs::eval(EvalState & state, Env & env, Value & v)
|
|||
Hence we need __overrides.) */
|
||||
if (hasOverrides) {
|
||||
Value * vOverrides = (*v.attrs)[overrides->second.displ].value;
|
||||
state.forceAttrs(*vOverrides, vOverrides->determinePos(noPos));
|
||||
state.forceAttrs(*vOverrides, [&]() { return vOverrides->determinePos(noPos); });
|
||||
Bindings * newBnds = state.allocBindings(v.attrs->capacity() + vOverrides->attrs->size());
|
||||
for (auto & i : *v.attrs)
|
||||
newBnds->push_back(i);
|
||||
|
@ -1500,7 +1505,8 @@ void EvalState::incrFunctionCall(ExprLambda * fun)
|
|||
|
||||
void EvalState::autoCallFunction(Bindings & args, Value & fun, Value & res)
|
||||
{
|
||||
Pos pos = fun.determinePos(noPos);
|
||||
auto pos = fun.determinePos(noPos);
|
||||
|
||||
forceValue(fun, pos);
|
||||
|
||||
if (fun.type() == nAttrs) {
|
||||
|
@ -1797,7 +1803,7 @@ void EvalState::forceValueDeep(Value & v)
|
|||
recurse = [&](Value & v) {
|
||||
if (!seen.insert(&v).second) return;
|
||||
|
||||
forceValue(v, v.determinePos(noPos));
|
||||
forceValue(v, [&]() { return v.determinePos(noPos); });
|
||||
|
||||
if (v.type() == nAttrs) {
|
||||
for (auto & i : *v.attrs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue