chore(3p/nix/libexpr): Remove unused __overrides feature
This feature does not appear in nixpkgs, so I don't care about it. My only goal is evaluating nixpkgs.
This commit is contained in:
		
							parent
							
								
									6b447f4b25
								
							
						
					
					
						commit
						92792264f7
					
				
					 3 changed files with 11 additions and 57 deletions
				
			
		
							
								
								
									
										58
									
								
								third_party/nix/src/libexpr/eval.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										58
									
								
								third_party/nix/src/libexpr/eval.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -299,7 +299,6 @@ EvalState::EvalState(const Strings& _searchPath, const ref<Store>& store) | ||||||
|       sName(symbols.Create("name")), |       sName(symbols.Create("name")), | ||||||
|       sValue(symbols.Create("value")), |       sValue(symbols.Create("value")), | ||||||
|       sSystem(symbols.Create("system")), |       sSystem(symbols.Create("system")), | ||||||
|       sOverrides(symbols.Create("__overrides")), |  | ||||||
|       sOutputs(symbols.Create("outputs")), |       sOutputs(symbols.Create("outputs")), | ||||||
|       sOutputName(symbols.Create("outputName")), |       sOutputName(symbols.Create("outputName")), | ||||||
|       sIgnoreNulls(symbols.Create("__ignoreNulls")), |       sIgnoreNulls(symbols.Create("__ignoreNulls")), | ||||||
|  | @ -799,8 +798,8 @@ void ExprString::eval(EvalState& state, Env& env, Value& v) { v = this->v; } | ||||||
| 
 | 
 | ||||||
| void ExprPath::eval(EvalState& state, Env& env, Value& v) { v = this->v; } | void ExprPath::eval(EvalState& state, Env& env, Value& v) { v = this->v; } | ||||||
| 
 | 
 | ||||||
| void ExprAttrs::eval(EvalState& state, Env& env, Value& v) { | void ExprAttrs::eval(EvalState& state, Env& env, Value& value) { | ||||||
|   state.mkAttrs(v, attrs.size() + dynamicAttrs.size()); |   state.mkAttrs(value, attrs.size() + dynamicAttrs.size()); | ||||||
|   Env* dynamicEnv = &env; |   Env* dynamicEnv = &env; | ||||||
| 
 | 
 | ||||||
|   if (recursive) { |   if (recursive) { | ||||||
|  | @ -810,61 +809,26 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) { | ||||||
|     env2.up = &env; |     env2.up = &env; | ||||||
|     dynamicEnv = &env2; |     dynamicEnv = &env2; | ||||||
| 
 | 
 | ||||||
|     // TODO(tazjin): contains?
 |  | ||||||
|     AttrDefs::iterator overrides = attrs.find(state.sOverrides); |  | ||||||
|     bool hasOverrides = overrides != attrs.end(); |  | ||||||
| 
 |  | ||||||
|     /* The recursive attributes are evaluated in the new
 |     /* The recursive attributes are evaluated in the new
 | ||||||
|        environment, while the inherited attributes are evaluated |        environment, while the inherited attributes are evaluated | ||||||
|        in the original environment. */ |        in the original environment. */ | ||||||
|     size_t displ = 0; |     size_t displ = 0; | ||||||
|     for (auto& i : attrs) { |     for (auto& attr : attrs) { | ||||||
|       Value* vAttr; |       Value* vAttr; | ||||||
|       if (hasOverrides && !i.second.inherited) { |       vAttr = attr.second.e->maybeThunk(state, | ||||||
|         vAttr = state.allocValue(); |                                           attr.second.inherited ? env : env2); | ||||||
|         mkThunk(*vAttr, env2, i.second.e); |  | ||||||
|       } else { |  | ||||||
|         vAttr = i.second.e->maybeThunk(state, i.second.inherited ? env : env2); |  | ||||||
|       } |  | ||||||
|       env2.values[displ++] = vAttr; |       env2.values[displ++] = vAttr; | ||||||
|       v.attrs->push_back(Attr(i.first, vAttr, &i.second.pos)); |       value.attrs->push_back(Attr(attr.first, vAttr, &attr.second.pos)); | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /* If the rec contains an attribute called `__overrides', then
 |  | ||||||
|        evaluate it, and add the attributes in that set to the rec. |  | ||||||
|        This allows overriding of recursive attributes, which is |  | ||||||
|        otherwise not possible.  (You can use the // operator to
 |  | ||||||
|        replace an attribute, but other attributes in the rec will |  | ||||||
|        still reference the original value, because that value has |  | ||||||
|        been substituted into the bodies of the other attributes. |  | ||||||
|        Hence we need __overrides.) */ |  | ||||||
|     if (hasOverrides) { |  | ||||||
|       Value* vOverrides = v.attrs->find(overrides->first)->second.value; |  | ||||||
|       state.forceAttrs(*vOverrides); |  | ||||||
|       Bindings* newBnds = Bindings::NewGC(); |  | ||||||
|       for (auto& i : *v.attrs) {  // TODO(tazjin): copy constructor?
 |  | ||||||
|         newBnds->push_back(i.second); |  | ||||||
|       } |  | ||||||
|       for (auto& i : *vOverrides->attrs) { |  | ||||||
|         auto j = attrs.find(i.second.name); |  | ||||||
|         if (j != attrs.end()) { |  | ||||||
|           newBnds->push_back(i.second); |  | ||||||
|           env2.values[j->second.displ] = i.second.value; |  | ||||||
|         } else { |  | ||||||
|           newBnds->push_back(i.second); |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|       v.attrs = newBnds; |  | ||||||
|     } |     } | ||||||
|   } else { |   } else { | ||||||
|     // TODO(tazjin): insert range
 |     // TODO(tazjin): insert range
 | ||||||
|     for (auto& i : attrs) { |     for (auto& i : attrs) { | ||||||
|       v.attrs->push_back( |       value.attrs->push_back( | ||||||
|           Attr(i.first, i.second.e->maybeThunk(state, env), &i.second.pos)); |           Attr(i.first, i.second.e->maybeThunk(state, env), &i.second.pos)); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /* Dynamic attrs apply *after* rec and __overrides. */ |   /* Dynamic attrs apply *after* rec. */ | ||||||
|   for (auto& i : dynamicAttrs) { |   for (auto& i : dynamicAttrs) { | ||||||
|     Value nameVal; |     Value nameVal; | ||||||
|     i.nameExpr->eval(state, *dynamicEnv, nameVal); |     i.nameExpr->eval(state, *dynamicEnv, nameVal); | ||||||
|  | @ -874,14 +838,14 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) { | ||||||
|     } |     } | ||||||
|     state.forceStringNoCtx(nameVal); |     state.forceStringNoCtx(nameVal); | ||||||
|     Symbol nameSym = state.symbols.Create(nameVal.string.s); |     Symbol nameSym = state.symbols.Create(nameVal.string.s); | ||||||
|     Bindings::iterator j = v.attrs->find(nameSym); |     Bindings::iterator j = value.attrs->find(nameSym); | ||||||
|     if (j != v.attrs->end()) { |     if (j != value.attrs->end()) { | ||||||
|       throwEvalError("dynamic attribute '%1%' at %2% already defined at %3%", |       throwEvalError("dynamic attribute '%1%' at %2% already defined at %3%", | ||||||
|                      nameSym, i.pos, *j->second.pos); |                      nameSym, i.pos, *j->second.pos); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     i.valueExpr->setName(nameSym); |     i.valueExpr->setName(nameSym); | ||||||
|     v.attrs->push_back( |     value.attrs->push_back( | ||||||
|         Attr(nameSym, i.valueExpr->maybeThunk(state, *dynamicEnv), &i.pos)); |         Attr(nameSym, i.valueExpr->maybeThunk(state, *dynamicEnv), &i.pos)); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1 +0,0 @@ | ||||||
| 2 |  | ||||||
|  | @ -1,9 +0,0 @@ | ||||||
| let |  | ||||||
| 
 |  | ||||||
|   overrides = { a = 2; }; |  | ||||||
| 
 |  | ||||||
| in (rec { |  | ||||||
|   __overrides = overrides; |  | ||||||
|   x = a; |  | ||||||
|   a = 1; |  | ||||||
| }).x |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue