22 map<string, string>::iterator i =
bindings_.find(var);
26 return parent_->LookupVariable(var);
36 rules_[rule->name()] = std::move(rule);
40 auto i =
rules_.find(rule_name);
43 return i->second.get();
47 auto i =
rules_.find(rule_name);
49 return i->second.get();
51 return parent_->LookupRule(rule_name);
60 Bindings::const_iterator i =
bindings_.find(key);
67 auto rule = std::unique_ptr<Rule>(
new Rule(
"phony"));
78 return var ==
"command" ||
81 var ==
"description" ||
87 var ==
"rspfile_content" ||
88 var ==
"msvc_deps_prefix";
98 map<string, string>::iterator i =
bindings_.find(var);
106 return parent_->LookupVariable(var);
117 for (TokenList::const_iterator i =
parsed_.begin(); i !=
parsed_.end(); ++i) {
118 if (i->second ==
RAW)
119 result.append(i->first);
153 for (
const auto& pair :
parsed_) {
157 result.append(pair.first.begin(), pair.first.end());
169 for (TokenList::const_iterator i =
parsed_.begin();
171 bool special = (i->second ==
SPECIAL);
174 result.append(i->first.begin(), i->first.end());
std::string LookupWithFallback(const std::string &var, const EvalString *eval, Env *env)
This is tricky.
void AddBinding(const std::string &key, const std::string &val)
const Rule * LookupRule(const std::string &rule_name)
const std::map< std::string, std::unique_ptr< const Rule > > & GetRules() const
std::map< std::string, std::string > bindings_
std::map< std::string, std::unique_ptr< const Rule > > rules_
const Rule * LookupRuleCurrentScope(const std::string &rule_name)
virtual std::string LookupVariable(const std::string &var)
void AddRule(std::unique_ptr< const Rule > rule)
An interface for a scope for variable (e.g. "$foo") lookups.
virtual std::string LookupVariable(const std::string &var)=0
A tokenized string that contains variable references.
std::string Evaluate(Env *env) const
std::string Unparse() const
void AddSpecial(StringPiece text)
std::string single_token_
std::string Serialize() const
Construct a human-readable representation of the parsed state, for use in tests.
void AddText(StringPiece text)
An invocable build command and associated metadata (description, etc.).
const EvalString * GetBinding(const std::string &key) const
void AddBinding(const std::string &key, const EvalString &val)
static std::unique_ptr< Rule > Phony()
Rule(const std::string &name)
static bool IsReservedBinding(const std::string &var)
StringPiece represents a slice of a string whose memory is managed externally.
const_iterator end() const
std::string AsString() const
Convert the slice into a full-fledged std::string, copying the data into a new string.
const_iterator begin() const