aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/nixexpr.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-08 09:51:27 +0100
committereldritch horrors <pennae@lix.systems>2024-03-10 03:18:32 -0600
commit03f852b2c69233667de839a4777331114304c983 (patch)
tree1c4b3b1c695708b6d3ed8acaaa978d7f653b980b /src/libexpr/nixexpr.hh
parent3e43f4aeff2947aea98bb0d538fa686bd55a1385 (diff)
preserve information about whether/how an attribute was inherited
(cherry picked from commit c66ee57edc6cac3571bfbf77d0c0ea4d25b4e805) Change-Id: Ie8606a8b2f5946c87dd4d16b7b46203e199a4cc1
Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r--src/libexpr/nixexpr.hh17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index 6f34afaa7..fe75592f0 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -154,13 +154,24 @@ struct ExprAttrs : Expr
bool recursive;
PosIdx pos;
struct AttrDef {
- bool inherited;
+ enum class Kind {
+ /** `attr = expr;` */
+ Plain,
+ /** `inherit attr1 attrn;` */
+ Inherited,
+ /** `inherit (expr) attr1 attrn;` */
+ InheritedFrom,
+ };
+
+ Kind kind;
Expr * e;
PosIdx pos;
Displacement displ; // displacement
- AttrDef(Expr * e, const PosIdx & pos, bool inherited=false)
- : inherited(inherited), e(e), pos(pos) { };
+ AttrDef(Expr * e, const PosIdx & pos, Kind kind = Kind::Plain)
+ : kind(kind), e(e), pos(pos) { };
AttrDef() { };
+
+ bool inherited() const { return kind == Kind::Inherited; }
};
typedef std::map<Symbol, AttrDef> AttrDefs;
AttrDefs attrs;