forked from lix-project/lix
Merge VarRef into ExprVar
This commit is contained in:
parent
176c666f36
commit
221a2daf34
|
@ -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) ;
|
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 * 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.
|
/* The value might not be initialised in the environment yet.
|
||||||
In that case, ignore it. */
|
In that case, ignore it. */
|
||||||
if (v) { nrAvoided++; return v; }
|
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)
|
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);
|
state.forceValue(*v2);
|
||||||
v = *v2;
|
v = *v2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ public:
|
||||||
|
|
||||||
private:
|
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 ExprVar;
|
||||||
friend class ExprAttrs;
|
friend class ExprAttrs;
|
||||||
|
|
|
@ -38,7 +38,7 @@ void ExprPath::show(std::ostream & str)
|
||||||
|
|
||||||
void ExprVar::show(std::ostream & str)
|
void ExprVar::show(std::ostream & str)
|
||||||
{
|
{
|
||||||
str << info.name;
|
str << name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExprSelect::show(std::ostream & str)
|
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,
|
/* Check whether the variable appears in the environment. If so,
|
||||||
set its level and displacement. */
|
set its level and displacement. */
|
||||||
|
@ -204,11 +204,6 @@ void VarRef::bind(const StaticEnv & env)
|
||||||
this->level = withLevel;
|
this->level = withLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExprVar::bindVars(const StaticEnv & env)
|
|
||||||
{
|
|
||||||
info.bind(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExprSelect::bindVars(const StaticEnv & env)
|
void ExprSelect::bindVars(const StaticEnv & env)
|
||||||
{
|
{
|
||||||
e->bindVars(env);
|
e->bindVars(env);
|
||||||
|
|
|
@ -107,7 +107,7 @@ struct ExprPath : Expr
|
||||||
Value * maybeThunk(EvalState & state, Env & env);
|
Value * maybeThunk(EvalState & state, Env & env);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VarRef
|
struct ExprVar : Expr
|
||||||
{
|
{
|
||||||
Symbol name;
|
Symbol name;
|
||||||
|
|
||||||
|
@ -124,15 +124,7 @@ struct VarRef
|
||||||
unsigned int level;
|
unsigned int level;
|
||||||
unsigned int displ;
|
unsigned int displ;
|
||||||
|
|
||||||
VarRef() { };
|
ExprVar(const Symbol & name) : name(name) { };
|
||||||
VarRef(const Symbol & name) : name(name) { };
|
|
||||||
void bind(const StaticEnv & env);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExprVar : Expr
|
|
||||||
{
|
|
||||||
VarRef info;
|
|
||||||
ExprVar(const Symbol & name) : info(name) { };
|
|
||||||
COMMON_METHODS
|
COMMON_METHODS
|
||||||
Value * maybeThunk(EvalState & state, Env & env);
|
Value * maybeThunk(EvalState & state, Env & env);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue