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)
 
void AddRule (const Rule *rule)
 
 BindingEnv ()
 
 BindingEnv (BindingEnv *parent)
 
const map< string, const Rule * > & GetRules () const
 
const RuleLookupRule (const string &rule_name)
 
const RuleLookupRuleCurrentScope (const string &rule_name)
 
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_
 
BindingEnvparent_
 
map< string, const Rule * > rules_
 

Detailed Description

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

Definition at line 77 of file eval_env.h.

Constructor & Destructor Documentation

◆ BindingEnv() [1/2]

BindingEnv::BindingEnv ( )
inline

Definition at line 78 of file eval_env.h.

◆ BindingEnv() [2/2]

BindingEnv::BindingEnv ( BindingEnv parent)
inlineexplicit

Definition at line 79 of file eval_env.h.

◆ ~BindingEnv()

virtual BindingEnv::~BindingEnv ( )
inlinevirtual

Definition at line 81 of file eval_env.h.

Member Function Documentation

◆ AddBinding()

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

Definition at line 28 of file eval_env.cc.

References bindings_.

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

◆ AddRule()

void BindingEnv::AddRule ( const Rule rule)

Definition at line 32 of file eval_env.cc.

References LookupRuleCurrentScope(), Rule::name(), and rules_.

Referenced by ManifestParser::ParseRule(), and State::State().

◆ GetRules()

const map< string, const Rule * > & BindingEnv::GetRules ( ) const

Definition at line 78 of file eval_env.cc.

References rules_.

◆ LookupRule()

const Rule * BindingEnv::LookupRule ( const string &  rule_name)

◆ LookupRuleCurrentScope()

const Rule * BindingEnv::LookupRuleCurrentScope ( const string &  rule_name)

Definition at line 37 of file eval_env.cc.

References rules_.

Referenced by AddRule(), and ManifestParser::ParseRule().

◆ LookupVariable()

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

Implements Env.

Definition at line 19 of file eval_env.cc.

References bindings_, LookupVariable(), and parent_.

Referenced by LookupVariable(), and LookupWithFallback().

◆ LookupWithFallback()

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 82 of file eval_env.cc.

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

Referenced by EdgeEnv::LookupVariable().

Member Data Documentation

◆ bindings_

map<string, string> BindingEnv::bindings_
private

Definition at line 100 of file eval_env.h.

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

◆ parent_

BindingEnv* BindingEnv::parent_
private

Definition at line 102 of file eval_env.h.

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

◆ rules_

map<string, const Rule*> BindingEnv::rules_
private

Definition at line 101 of file eval_env.h.

Referenced by AddRule(), GetRules(), LookupRule(), and LookupRuleCurrentScope().


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