1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

add ExprAttrs::AttrDef::chooseByKind

in place of inherited() — not quite useful yet since we don't
distinguish plain and inheritFrom attr kinds so far.
This commit is contained in:
pennae 2024-01-27 16:33:34 +01:00
parent c66ee57edc
commit 1f542adb3e
3 changed files with 46 additions and 18 deletions

View file

@ -178,6 +178,20 @@ struct ExprAttrs : Expr
AttrDef() { };
bool inherited() const { return kind == Kind::Inherited; }
template<typename T>
const T & chooseByKind(const T & plain, const T & inherited, const T & inheritedFrom) const
{
switch (kind) {
case Kind::Plain:
return plain;
case Kind::Inherited:
return inherited;
default:
case Kind::InheritedFrom:
return inheritedFrom;
}
}
};
typedef std::map<Symbol, AttrDef> AttrDefs;
AttrDefs attrs;