* Implemented `rec { inherit ...; }'.
This commit is contained in:
		
							parent
							
								
									4c53ca2692
								
							
						
					
					
						commit
						13c2adc897
					
				
					 2 changed files with 17 additions and 0 deletions
				
			
		|  | @ -326,11 +326,16 @@ void EvalState::eval(Env & env, Expr e, Value & v) | |||
|     } | ||||
| 
 | ||||
|     else if (matchRec(e, rbnds, nrbnds)) { | ||||
|         /* Create a new environment that contains the attributes in
 | ||||
|            this `rec'. */ | ||||
|         Env & env2(allocEnv()); | ||||
|         env2.up = &env; | ||||
|          | ||||
|         v.type = tAttrs; | ||||
|         v.attrs = &env2.bindings; | ||||
| 
 | ||||
|         /* The recursive attributes are evaluated in the new
 | ||||
|            environment. */ | ||||
|         ATerm name, e2, pos; | ||||
|         for (ATermIterator i(rbnds); i; ++i) { | ||||
|             if (!matchBind(*i, name, e2, pos)) abort(); /* can't happen */ | ||||
|  | @ -338,6 +343,15 @@ void EvalState::eval(Env & env, Expr e, Value & v) | |||
|             nrValues++; | ||||
|             mkThunk(v2, env2, e2); | ||||
|         } | ||||
| 
 | ||||
|         /* The non-recursive attributes, on the other hand, are
 | ||||
|            evaluated in the original environment. */ | ||||
|         for (ATermIterator i(nrbnds); i; ++i) { | ||||
|             if (!matchBind(*i, name, e2, pos)) abort(); /* can't happen */ | ||||
|             Value & v2 = env2.bindings[name]; | ||||
|             nrValues++; | ||||
|             mkThunk(v2, env, e2); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     else if (matchSelect(e, e2, name)) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue