Merge VarRef into ExprVar
This commit is contained in:
		
							parent
							
								
									176c666f36
								
							
						
					
					
						commit
						221a2daf34
					
				
					 4 changed files with 8 additions and 21 deletions
				
			
		|  | @ -310,7 +310,7 @@ void mkPath(Value & v, const char * s) | |||
| } | ||||
| 
 | ||||
| 
 | ||||
| inline Value * EvalState::lookupVar(Env * env, const VarRef & var, bool noEval) | ||||
| inline Value * EvalState::lookupVar(Env * env, const ExprVar & var, bool noEval) | ||||
| { | ||||
|     for (unsigned int l = var.level; l; --l, env = env->up) ; | ||||
| 
 | ||||
|  | @ -417,7 +417,7 @@ unsigned long nrAvoided = 0; | |||
| 
 | ||||
| Value * ExprVar::maybeThunk(EvalState & state, Env & env) | ||||
| { | ||||
|     Value * v = state.lookupVar(&env, info, true); | ||||
|     Value * v = state.lookupVar(&env, *this, true); | ||||
|     /* The value might not be initialised in the environment yet.
 | ||||
|        In that case, ignore it. */ | ||||
|     if (v) { nrAvoided++; return v; } | ||||
|  | @ -607,7 +607,7 @@ void ExprList::eval(EvalState & state, Env & env, Value & v) | |||
| 
 | ||||
| void ExprVar::eval(EvalState & state, Env & env, Value & v) | ||||
| { | ||||
|     Value * v2 = state.lookupVar(&env, info, false); | ||||
|     Value * v2 = state.lookupVar(&env, *this, false); | ||||
|     state.forceValue(*v2); | ||||
|     v = *v2; | ||||
| } | ||||
|  |  | |||
|  | @ -209,7 +209,7 @@ public: | |||
| 
 | ||||
| private: | ||||
| 
 | ||||
|     inline Value * lookupVar(Env * env, const VarRef & var, bool noEval); | ||||
|     inline Value * lookupVar(Env * env, const ExprVar & var, bool noEval); | ||||
| 
 | ||||
|     friend class ExprVar; | ||||
|     friend class ExprAttrs; | ||||
|  |  | |||
|  | @ -38,7 +38,7 @@ void ExprPath::show(std::ostream & str) | |||
| 
 | ||||
| void ExprVar::show(std::ostream & str) | ||||
| { | ||||
|     str << info.name; | ||||
|     str << name; | ||||
| } | ||||
| 
 | ||||
| void ExprSelect::show(std::ostream & str) | ||||
|  | @ -174,7 +174,7 @@ void ExprPath::bindVars(const StaticEnv & env) | |||
| { | ||||
| } | ||||
| 
 | ||||
| void VarRef::bind(const StaticEnv & env) | ||||
| void ExprVar::bindVars(const StaticEnv & env) | ||||
| { | ||||
|     /* Check whether the variable appears in the environment.  If so,
 | ||||
|        set its level and displacement. */ | ||||
|  | @ -204,11 +204,6 @@ void VarRef::bind(const StaticEnv & env) | |||
|     this->level = withLevel; | ||||
| } | ||||
| 
 | ||||
| void ExprVar::bindVars(const StaticEnv & env) | ||||
| { | ||||
|     info.bind(env); | ||||
| } | ||||
| 
 | ||||
| void ExprSelect::bindVars(const StaticEnv & env) | ||||
| { | ||||
|     e->bindVars(env); | ||||
|  |  | |||
|  | @ -107,7 +107,7 @@ struct ExprPath : Expr | |||
|     Value * maybeThunk(EvalState & state, Env & env); | ||||
| }; | ||||
| 
 | ||||
| struct VarRef | ||||
| struct ExprVar : Expr | ||||
| { | ||||
|     Symbol name; | ||||
| 
 | ||||
|  | @ -124,15 +124,7 @@ struct VarRef | |||
|     unsigned int level; | ||||
|     unsigned int displ; | ||||
| 
 | ||||
|     VarRef() { }; | ||||
|     VarRef(const Symbol & name) : name(name) { }; | ||||
|     void bind(const StaticEnv & env); | ||||
| }; | ||||
| 
 | ||||
| struct ExprVar : Expr | ||||
| { | ||||
|     VarRef info; | ||||
|     ExprVar(const Symbol & name) : info(name) { }; | ||||
|     ExprVar(const Symbol & name) : name(name) { }; | ||||
|     COMMON_METHODS | ||||
|     Value * maybeThunk(EvalState & state, Env & env); | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue