summaryrefslogtreecommitdiffstats
path: root/src/eval_env.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-06-29 17:21:30 (GMT)
committerNico Weber <nicolasweber@gmx.de>2015-06-29 17:21:30 (GMT)
commit484c16336f19bd8970bb6e75322d61b92a229899 (patch)
tree2a8908981381da57e3f9ef3a01a8008b930f86f9 /src/eval_env.cc
parent3309498174411e02e7680ea8b470bb7d1d70bdb8 (diff)
parentd18eda4c3ed7d81c3f8d6d46972a0988f1ebb05e (diff)
downloadNinja-484c16336f19bd8970bb6e75322d61b92a229899.zip
Ninja-484c16336f19bd8970bb6e75322d61b92a229899.tar.gz
Ninja-484c16336f19bd8970bb6e75322d61b92a229899.tar.bz2
v1.6.0v1.6.0
Diffstat (limited to 'src/eval_env.cc')
-rw-r--r--src/eval_env.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/eval_env.cc b/src/eval_env.cc
index 834b7e1..e991d21 100644
--- a/src/eval_env.cc
+++ b/src/eval_env.cc
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#include <assert.h>
+
#include "eval_env.h"
string BindingEnv::LookupVariable(const string& var) {
@@ -27,6 +29,55 @@ void BindingEnv::AddBinding(const string& key, const string& val) {
bindings_[key] = val;
}
+void BindingEnv::AddRule(const Rule* rule) {
+ assert(LookupRuleCurrentScope(rule->name()) == NULL);
+ rules_[rule->name()] = rule;
+}
+
+const Rule* BindingEnv::LookupRuleCurrentScope(const string& rule_name) {
+ map<string, const Rule*>::iterator i = rules_.find(rule_name);
+ if (i == rules_.end())
+ return NULL;
+ return i->second;
+}
+
+const Rule* BindingEnv::LookupRule(const string& rule_name) {
+ map<string, const Rule*>::iterator i = rules_.find(rule_name);
+ if (i != rules_.end())
+ return i->second;
+ if (parent_)
+ return parent_->LookupRule(rule_name);
+ return NULL;
+}
+
+void Rule::AddBinding(const string& key, const EvalString& val) {
+ bindings_[key] = val;
+}
+
+const EvalString* Rule::GetBinding(const string& key) const {
+ map<string, EvalString>::const_iterator i = bindings_.find(key);
+ if (i == bindings_.end())
+ return NULL;
+ return &i->second;
+}
+
+// static
+bool Rule::IsReservedBinding(const string& var) {
+ return var == "command" ||
+ var == "depfile" ||
+ var == "description" ||
+ var == "deps" ||
+ var == "generator" ||
+ var == "pool" ||
+ var == "restat" ||
+ var == "rspfile" ||
+ var == "rspfile_content";
+}
+
+const map<string, const Rule*>& BindingEnv::GetRules() const {
+ return rules_;
+}
+
string BindingEnv::LookupWithFallback(const string& var,
const EvalString* eval,
Env* env) {