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:
parent
c66ee57edc
commit
1f542adb3e
3 changed files with 46 additions and 18 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue