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>
This commit is contained in:
		
							parent
							
								
									6cd6ce5608
								
							
						
					
					
						commit
						afc6c1bad6
					
				
					 7 changed files with 46 additions and 38 deletions
				
			
		|  | @ -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; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue