summaryrefslogtreecommitdiffstats
path: root/src/eval_env.h
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-10-27 20:09:40 (GMT)
committerEvan Martin <martine@danga.com>2012-12-29 20:34:25 (GMT)
commit13dd08c1a03e5a8f4299816fbd3af1b6cb6d9642 (patch)
tree9564593d47936d2e47d88e344c2f6915ba8753a3 /src/eval_env.h
parent3249938cdf574058a066436aea06b0541ded6958 (diff)
downloadNinja-13dd08c1a03e5a8f4299816fbd3af1b6cb6d9642.zip
Ninja-13dd08c1a03e5a8f4299816fbd3af1b6cb6d9642.tar.gz
Ninja-13dd08c1a03e5a8f4299816fbd3af1b6cb6d9642.tar.bz2
rearrange handling of builtin bindings to make rules simpler
Now, a 'build' block can override any special binding like 'command' or 'description' if it needs to.
Diffstat (limited to 'src/eval_env.h')
-rw-r--r--src/eval_env.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/eval_env.h b/src/eval_env.h
index 6e0a0c0..f3c959a 100644
--- a/src/eval_env.h
+++ b/src/eval_env.h
@@ -22,6 +22,8 @@ using namespace std;
#include "string_piece.h"
+struct EvalString;
+
/// An interface for a scope for variable (e.g. "$foo") lookups.
struct Env {
virtual ~Env() {}
@@ -33,10 +35,20 @@ struct Env {
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);
+ /// This is tricky. Edges want lookup scope to go in this order:
+ /// 1) value set on edge itself (edge_->env_)
+ /// 2) value set on rule, with expansion in the edge's scope
+ /// 3) value set on enclosing scope of edge (edge_->env_->parent_)
+ /// This function takes as parameters the necessary info to do (2).
+ string LookupWithFallback(const string& var, const EvalString* eval,
+ Env* env);
+
private:
map<string, string> bindings_;
Env* parent_;