mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 20:16:03 +01:00
libexpr: Simplify Value::is* methods by introducing isa function template
This commit is contained in:
parent
1a033ee4ee
commit
810455f1b8
2 changed files with 30 additions and 19 deletions
|
|
@ -125,7 +125,7 @@ std::string showType(const Value & v)
|
|||
// Allow selecting a subset of enum values
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wswitch-enum"
|
||||
switch (v.internalType) {
|
||||
switch (v.getInternalType()) {
|
||||
case tString: return v.context() ? "a string with context" : "a string";
|
||||
case tPrimOp:
|
||||
return fmt("the built-in function '%s'", std::string(v.primOp()->name));
|
||||
|
|
@ -145,7 +145,7 @@ PosIdx Value::determinePos(const PosIdx pos) const
|
|||
// Allow selecting a subset of enum values
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wswitch-enum"
|
||||
switch (internalType) {
|
||||
switch (getInternalType()) {
|
||||
case tAttrs: return attrs()->pos;
|
||||
case tLambda: return lambda().fun->pos;
|
||||
case tApp: return app().left->determinePos(pos);
|
||||
|
|
@ -157,9 +157,8 @@ PosIdx Value::determinePos(const PosIdx pos) const
|
|||
bool Value::isTrivial() const
|
||||
{
|
||||
return
|
||||
internalType != tApp
|
||||
&& internalType != tPrimOpApp
|
||||
&& (internalType != tThunk
|
||||
!isa<tApp, tPrimOpApp>()
|
||||
&& (!isa<tThunk>()
|
||||
|| (dynamic_cast<ExprAttrs *>(thunk().expr)
|
||||
&& ((ExprAttrs *) thunk().expr)->dynamicAttrs.empty())
|
||||
|| dynamic_cast<ExprLambda *>(thunk().expr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue