summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/eval_env.h2
-rw-r--r--src/parsers.cc6
2 files changed, 4 insertions, 4 deletions
diff --git a/src/eval_env.h b/src/eval_env.h
index 2341bcb..6e0a0c0 100644
--- a/src/eval_env.h
+++ b/src/eval_env.h
@@ -32,10 +32,12 @@ struct Env {
/// as well as a pointer to a parent scope.
struct BindingEnv : public Env {
BindingEnv() : parent_(NULL) {}
+ explicit BindingEnv(Env* parent) : parent_(parent) {}
virtual ~BindingEnv() {}
virtual string LookupVariable(const string& var);
void AddBinding(const string& key, const string& val);
+private:
map<string, string> bindings_;
Env* parent_;
};
diff --git a/src/parsers.cc b/src/parsers.cc
index 095e93f..506b209 100644
--- a/src/parsers.cc
+++ b/src/parsers.cc
@@ -243,8 +243,7 @@ bool ManifestParser::ParseEdge(string* err) {
// But create and fill a nested env if there are variables in scope.
if (lexer_.PeekToken(Lexer::INDENT)) {
// XXX scoped_ptr to handle error case.
- env = new BindingEnv;
- env->parent_ = env_;
+ env = new BindingEnv(env_);
do {
string key;
EvalString val;
@@ -290,8 +289,7 @@ bool ManifestParser::ParseFileInclude(bool new_scope, string* err) {
ManifestParser subparser(state_, file_reader_);
if (new_scope) {
- subparser.env_ = new BindingEnv;
- subparser.env_->parent_ = env_;
+ subparser.env_ = new BindingEnv(env_);
} else {
subparser.env_ = env_;
}