From afc6c1bad63e27d68adf49e673f8aafd36495a8a Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 15 Jul 2013 17:10:18 -0400 Subject: 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 --- src/libexpr/nixexpr.hh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/libexpr/nixexpr.hh') diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index f6dcb3935752..69372a77b64c 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 AttrDefs; -- cgit 1.4.1