mirror of
https://github.com/NixOS/nix
synced 2025-06-24 22:11:15 +02:00
libexpr: Add and use thunk
getter
This commit is contained in:
parent
6587e7bcff
commit
441fa86e82
3 changed files with 11 additions and 8 deletions
|
@ -160,10 +160,10 @@ bool Value::isTrivial() const
|
||||||
internalType != tApp
|
internalType != tApp
|
||||||
&& internalType != tPrimOpApp
|
&& internalType != tPrimOpApp
|
||||||
&& (internalType != tThunk
|
&& (internalType != tThunk
|
||||||
|| (dynamic_cast<ExprAttrs *>(payload.thunk.expr)
|
|| (dynamic_cast<ExprAttrs *>(thunk().expr)
|
||||||
&& ((ExprAttrs *) payload.thunk.expr)->dynamicAttrs.empty())
|
&& ((ExprAttrs *) thunk().expr)->dynamicAttrs.empty())
|
||||||
|| dynamic_cast<ExprLambda *>(payload.thunk.expr)
|
|| dynamic_cast<ExprLambda *>(thunk().expr)
|
||||||
|| dynamic_cast<ExprList *>(payload.thunk.expr));
|
|| dynamic_cast<ExprList *>(thunk().expr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2163,7 +2163,7 @@ void EvalState::forceValueDeep(Value & v)
|
||||||
try {
|
try {
|
||||||
// If the value is a thunk, we're evaling. Otherwise no trace necessary.
|
// If the value is a thunk, we're evaling. Otherwise no trace necessary.
|
||||||
auto dts = debugRepl && i.value->isThunk()
|
auto dts = debugRepl && i.value->isThunk()
|
||||||
? makeDebugTraceStacker(*this, *i.value->payload.thunk.expr, *i.value->payload.thunk.env, i.pos,
|
? makeDebugTraceStacker(*this, *i.value->thunk().expr, *i.value->thunk().env, i.pos,
|
||||||
"while evaluating the attribute '%1%'", symbols[i.name])
|
"while evaluating the attribute '%1%'", symbols[i.name])
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,9 @@ Env & EvalState::allocEnv(size_t size)
|
||||||
void EvalState::forceValue(Value & v, const PosIdx pos)
|
void EvalState::forceValue(Value & v, const PosIdx pos)
|
||||||
{
|
{
|
||||||
if (v.isThunk()) {
|
if (v.isThunk()) {
|
||||||
Env * env = v.payload.thunk.env;
|
Env * env = v.thunk().env;
|
||||||
assert(env || v.isBlackhole());
|
assert(env || v.isBlackhole());
|
||||||
Expr * expr = v.payload.thunk.expr;
|
Expr * expr = v.thunk().expr;
|
||||||
try {
|
try {
|
||||||
v.mkBlackhole();
|
v.mkBlackhole();
|
||||||
//checkInterrupt();
|
//checkInterrupt();
|
||||||
|
|
|
@ -485,6 +485,9 @@ public:
|
||||||
|
|
||||||
Lambda lambda() const
|
Lambda lambda() const
|
||||||
{ return payload.lambda; }
|
{ return payload.lambda; }
|
||||||
|
|
||||||
|
ClosureThunk thunk() const
|
||||||
|
{ return payload.thunk; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -492,7 +495,7 @@ extern ExprBlackHole eBlackHole;
|
||||||
|
|
||||||
bool Value::isBlackhole() const
|
bool Value::isBlackhole() const
|
||||||
{
|
{
|
||||||
return internalType == tThunk && payload.thunk.expr == (Expr*) &eBlackHole;
|
return internalType == tThunk && thunk().expr == (Expr*) &eBlackHole;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Value::mkBlackhole()
|
void Value::mkBlackhole()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue