diff options
Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r-- | src/libexpr/nixexpr.hh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index fe75592f0..246221c0f 100644 --- a/src/libexpr/nixexpr.hh +++ b/src/libexpr/nixexpr.hh @@ -172,6 +172,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; |