about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-08T12·24+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-08T12·24+0200
commit221a2daf34234c426fec8058f24b1093b2a61ba8 (patch)
treed94ec6b74886dc0fe142a04be801f5c1777bcb02
parent176c666f36afee12f5cbd1f9615cf21d781fdbde (diff)
Merge VarRef into ExprVar
-rw-r--r--src/libexpr/eval.cc6
-rw-r--r--src/libexpr/eval.hh2
-rw-r--r--src/libexpr/nixexpr.cc9
-rw-r--r--src/libexpr/nixexpr.hh12
4 files changed, 8 insertions, 21 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index f128b6ad34a6..d7cab2bf7e99 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -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;
 }
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index b08bec8d9eb9..2f87b9c77610 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -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;
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index 2b33f73015f0..c847e3baf832 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -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);
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index 8733b9c7877c..7db0a15fa30f 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -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);
 };