summaryrefslogtreecommitdiffstats
path: root/src/eval_env.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval_env.h')
-rw-r--r--src/eval_env.h43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/eval_env.h b/src/eval_env.h
index 8fb9bf4..ca7daa4 100644
--- a/src/eval_env.h
+++ b/src/eval_env.h
@@ -18,7 +18,6 @@
#include <map>
#include <string>
#include <vector>
-using namespace std;
#include "string_piece.h"
@@ -27,7 +26,7 @@ struct Rule;
/// An interface for a scope for variable (e.g. "$foo") lookups.
struct Env {
virtual ~Env() {}
- virtual string LookupVariable(const string& var) = 0;
+ virtual std::string LookupVariable(const std::string& var) = 0;
};
/// A tokenized string that contains variable references.
@@ -35,10 +34,10 @@ struct Env {
struct EvalString {
/// @return The evaluated string with variable expanded using value found in
/// environment @a env.
- string Evaluate(Env* env) const;
+ std::string Evaluate(Env* env) const;
/// @return The string with variables not expanded.
- string Unparse() const;
+ std::string Unparse() const;
void Clear() { parsed_.clear(); }
bool empty() const { return parsed_.empty(); }
@@ -48,32 +47,32 @@ struct EvalString {
/// Construct a human-readable representation of the parsed state,
/// for use in tests.
- string Serialize() const;
+ std::string Serialize() const;
private:
enum TokenType { RAW, SPECIAL };
- typedef vector<pair<string, TokenType> > TokenList;
+ typedef std::vector<std::pair<std::string, TokenType> > TokenList;
TokenList parsed_;
};
/// An invokable build command and associated metadata (description, etc.).
struct Rule {
- explicit Rule(const string& name) : name_(name) {}
+ explicit Rule(const std::string& name) : name_(name) {}
- const string& name() const { return name_; }
+ const std::string& name() const { return name_; }
- void AddBinding(const string& key, const EvalString& val);
+ void AddBinding(const std::string& key, const EvalString& val);
- static bool IsReservedBinding(const string& var);
+ static bool IsReservedBinding(const std::string& var);
- const EvalString* GetBinding(const string& key) const;
+ const EvalString* GetBinding(const std::string& key) const;
private:
// Allow the parsers to reach into this object and fill out its fields.
friend struct ManifestParser;
- string name_;
- typedef map<string, EvalString> Bindings;
+ std::string name_;
+ typedef std::map<std::string, EvalString> Bindings;
Bindings bindings_;
};
@@ -84,26 +83,26 @@ struct BindingEnv : public Env {
explicit BindingEnv(BindingEnv* parent) : parent_(parent) {}
virtual ~BindingEnv() {}
- virtual string LookupVariable(const string& var);
+ virtual std::string LookupVariable(const std::string& var);
void AddRule(const Rule* rule);
- const Rule* LookupRule(const string& rule_name);
- const Rule* LookupRuleCurrentScope(const string& rule_name);
- const map<string, const Rule*>& GetRules() const;
+ const Rule* LookupRule(const std::string& rule_name);
+ const Rule* LookupRuleCurrentScope(const std::string& rule_name);
+ const std::map<std::string, const Rule*>& GetRules() const;
- void AddBinding(const string& key, const string& val);
+ void AddBinding(const std::string& key, const std::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);
+ std::string LookupWithFallback(const std::string& var, const EvalString* eval,
+ Env* env);
private:
- map<string, string> bindings_;
- map<string, const Rule*> rules_;
+ std::map<std::string, std::string> bindings_;
+ std::map<std::string, const Rule*> rules_;
BindingEnv* parent_;
};