mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
* Keep attribute sets in sorted order to speed up attribute lookups.
* Simplify the representation of attributes in the AST. * Change the behaviour of listToAttrs() in case of duplicate names.
This commit is contained in:
parent
2dc6d50941
commit
e0b7fb8f27
12 changed files with 186 additions and 148 deletions
|
@ -101,6 +101,7 @@ struct VarRef
|
|||
unsigned int level;
|
||||
unsigned int displ;
|
||||
|
||||
VarRef() { };
|
||||
VarRef(const Symbol & name) : name(name) { };
|
||||
void bind(const StaticEnv & env);
|
||||
};
|
||||
|
@ -131,13 +132,18 @@ struct ExprOpHasAttr : Expr
|
|||
struct ExprAttrs : Expr
|
||||
{
|
||||
bool recursive;
|
||||
typedef std::pair<Expr *, Pos> Attr;
|
||||
typedef std::pair<VarRef, Pos> Inherited;
|
||||
typedef std::map<Symbol, Attr> Attrs;
|
||||
Attrs attrs;
|
||||
list<Inherited> inherited;
|
||||
std::map<Symbol, Pos> attrNames; // used during parsing
|
||||
std::map<Symbol, unsigned int> displs;
|
||||
struct AttrDef {
|
||||
bool inherited;
|
||||
Expr * e; // if not inherited
|
||||
VarRef var; // if inherited
|
||||
Pos pos;
|
||||
unsigned int displ; // displacement
|
||||
AttrDef(Expr * e, const Pos & pos) : inherited(false), e(e), pos(pos) { };
|
||||
AttrDef(const Symbol & name, const Pos & pos) : inherited(true), var(name), pos(pos) { };
|
||||
AttrDef() { };
|
||||
};
|
||||
typedef std::map<Symbol, AttrDef> AttrDefs;
|
||||
AttrDefs attrs;
|
||||
ExprAttrs() : recursive(false) { };
|
||||
COMMON_METHODS
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue