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

preserve information about whether/how an attribute was inherited

This commit is contained in:
pennae 2024-01-27 16:33:34 +01:00
parent 73065a400d
commit c66ee57edc
5 changed files with 31 additions and 13 deletions

View file

@ -160,13 +160,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;