diff options
author | Shea Levy <shea@shealevy.com> | 2013-07-15 17:10:18 -0400 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-08-26 11:31:56 +0200 |
commit | afc6c1bad63e27d68adf49e673f8aafd36495a8a (patch) | |
tree | 9cfe21245d123b5d7e525aa2722b1e155d29e736 /src/libexpr/nixexpr.hh | |
parent | 6cd6ce56083d0077485896a761520812d039bf10 (diff) |
Simplify inherited attribute handling
This reduces the difference between inherited and non-inherited
attribute handling to the choice of which env to use (in recs and lets)
by setting the AttrDef::e to a new ExprVar in the parser rather than
carrying a separate AttrDef::v VarRef member.
As an added bonus, this allows inherited attributes that inherit from a
with to delay forcing evaluation of the with's attributes.
Signed-off-by: Shea Levy <shea@shealevy.com>
Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r-- | src/libexpr/nixexpr.hh | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index f6dcb3935..69372a77b 100644 --- a/src/libexpr/nixexpr.hh +++ b/src/libexpr/nixexpr.hh @@ -159,12 +159,10 @@ struct ExprAttrs : Expr bool recursive; struct AttrDef { bool inherited; - Expr * e; // if not inherited - VarRef var; // if inherited + Expr * e; 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(Expr * e, const Pos & pos, bool inherited=false) : inherited(inherited), e(e), pos(pos) { }; AttrDef() { }; }; typedef std::map<Symbol, AttrDef> AttrDefs; |