Ninja
Public Member Functions | Private Attributes | List of all members
BindingEnv Struct Reference

An Env which contains a mapping of variables to values as well as a pointer to a parent scope. More...

#include <eval_env.h>

Inheritance diagram for BindingEnv:
Inheritance graph
[legend]

Public Member Functions

void AddBinding (const string &key, const string &val)
 
 BindingEnv ()
 
 BindingEnv (Env *parent)
 
virtual string LookupVariable (const string &var)
 
string LookupWithFallback (const string &var, const EvalString *eval, Env *env)
 This is tricky. More...
 
virtual ~BindingEnv ()
 

Private Attributes

map< string, string > bindings_
 
Envparent_
 

Detailed Description

An Env which contains a mapping of variables to values as well as a pointer to a parent scope.

Definition at line 35 of file eval_env.h.

Constructor & Destructor Documentation

BindingEnv::BindingEnv ( )
inline

Definition at line 36 of file eval_env.h.

BindingEnv::BindingEnv ( Env parent)
inlineexplicit

Definition at line 37 of file eval_env.h.

virtual BindingEnv::~BindingEnv ( )
inlinevirtual

Definition at line 39 of file eval_env.h.

Member Function Documentation

void BindingEnv::AddBinding ( const string &  key,
const string &  val 
)

Definition at line 26 of file eval_env.cc.

References bindings_.

Referenced by ManifestParser::Parse(), and ManifestParser::ParseEdge().

string BindingEnv::LookupVariable ( const string &  var)
virtual

Implements Env.

Definition at line 17 of file eval_env.cc.

References bindings_, Env::LookupVariable(), and parent_.

string BindingEnv::LookupWithFallback ( const string &  var,
const EvalString eval,
Env env 
)

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).

Definition at line 30 of file eval_env.cc.

References bindings_, EvalString::Evaluate(), Env::LookupVariable(), and parent_.

Referenced by EdgeEnv::LookupVariable().

Member Data Documentation

map<string, string> BindingEnv::bindings_
private

Definition at line 53 of file eval_env.h.

Referenced by AddBinding(), LookupVariable(), and LookupWithFallback().

Env* BindingEnv::parent_
private

Definition at line 54 of file eval_env.h.

Referenced by LookupVariable(), and LookupWithFallback().


The documentation for this struct was generated from the following files: