22 map<string, string>::iterator i = bindings_.find(var);
23 if (i != bindings_.end())
26 return parent_->LookupVariable(var);
35 assert(LookupRuleCurrentScope(rule->
name()) == NULL);
36 rules_[rule->
name()] = rule;
40 map<string, const Rule*>::iterator i = rules_.find(rule_name);
41 if (i == rules_.end())
47 map<string, const Rule*>::iterator i = rules_.find(rule_name);
48 if (i != rules_.end())
51 return parent_->LookupRule(rule_name);
60 Bindings::const_iterator i = bindings_.find(key);
61 if (i == bindings_.end())
68 return var ==
"command" ||
71 var ==
"description" ||
77 var ==
"rspfile_content" ||
78 var ==
"msvc_deps_prefix";
88 map<string, string>::iterator i = bindings_.find(var);
89 if (i != bindings_.end())
96 return parent_->LookupVariable(var);
103 for (TokenList::const_iterator i = parsed_.begin(); i != parsed_.end(); ++i) {
104 if (i->second == RAW)
105 result.append(i->first);
114 if (!parsed_.empty() && parsed_.back().second == RAW) {
115 parsed_.back().first.append(text.
str_, text.
len_);
117 parsed_.push_back(make_pair(text.
AsString(), RAW));
121 parsed_.push_back(make_pair(text.
AsString(), SPECIAL));
126 for (TokenList::const_iterator i = parsed_.begin();
127 i != parsed_.end(); ++i) {
129 if (i->second == SPECIAL)
131 result.append(i->first);
139 for (TokenList::const_iterator i = parsed_.begin();
140 i != parsed_.end(); ++i) {
141 bool special = (i->second == SPECIAL);
144 result.append(i->first);
std::string Evaluate(Env *env) const
virtual std::string LookupVariable(const std::string &var)=0
std::string AsString() const
Convert the slice into a full-fledged std::string, copying the data into a new string.
const std::map< std::string, const Rule * > & GetRules() const
const Rule * LookupRuleCurrentScope(const std::string &rule_name)
const EvalString * GetBinding(const std::string &key) const
StringPiece represents a slice of a string whose memory is managed externally.
const std::string & name() const
static bool IsReservedBinding(const std::string &var)
void AddSpecial(StringPiece text)
void AddRule(const Rule *rule)
void AddBinding(const std::string &key, const EvalString &val)
An invokable build command and associated metadata (description, etc.).
std::string LookupWithFallback(const std::string &var, const EvalString *eval, Env *env)
This is tricky.
const Rule * LookupRule(const std::string &rule_name)
std::string Serialize() const
Construct a human-readable representation of the parsed state, for use in tests.
void AddText(StringPiece text)
void AddBinding(const std::string &key, const std::string &val)
std::string Unparse() const
virtual std::string LookupVariable(const std::string &var)
A tokenized string that contains variable references.
An interface for a scope for variable (e.g. "$foo") lookups.