Ninja
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:

Public Member Functions

void AddBinding (const std::string &key, const std::string &val)
 
void AddRule (std::unique_ptr< const Rule > rule)
 
 BindingEnv ()
 
 BindingEnv (BindingEnv *parent)
 
const std::map< std::string, std::unique_ptr< const Rule > > & GetRules () const
 
const RuleLookupRule (const std::string &rule_name)
 
const RuleLookupRuleCurrentScope (const std::string &rule_name)
 
virtual std::string LookupVariable (const std::string &var)
 
std::string LookupWithFallback (const std::string &var, const EvalString *eval, Env *env)
 This is tricky.
 
virtual ~BindingEnv ()
 

Private Attributes

std::map< std::string, std::string > bindings_
 
BindingEnvparent_
 
std::map< std::string, std::unique_ptr< 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 93 of file eval_env.h.

Constructor & Destructor Documentation

◆ BindingEnv() [1/2]

BindingEnv::BindingEnv ( )
inline

Definition at line 94 of file eval_env.h.

References parent_.

Referenced by BindingEnv().

◆ BindingEnv() [2/2]

BindingEnv::BindingEnv ( BindingEnv * parent)
inlineexplicit

Definition at line 95 of file eval_env.h.

References BindingEnv(), and parent_.

◆ ~BindingEnv()

virtual BindingEnv::~BindingEnv ( )
inlinevirtual

Definition at line 97 of file eval_env.h.

Member Function Documentation

◆ AddBinding()

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

Definition at line 30 of file eval_env.cc.

References bindings_.

Referenced by ManifestParser::ParseEdge(), and DyndepLoader::UpdateEdge().

◆ AddRule()

void BindingEnv::AddRule ( std::unique_ptr< const Rule > rule)

Definition at line 34 of file eval_env.cc.

References LookupRuleCurrentScope(), and rules_.

◆ GetRules()

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

Definition at line 91 of file eval_env.cc.

References rules_.

◆ LookupRule()

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

Definition at line 46 of file eval_env.cc.

References parent_, and rules_.

◆ LookupRuleCurrentScope()

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

Definition at line 39 of file eval_env.cc.

References rules_.

Referenced by AddRule().

◆ LookupVariable()

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

Implements Env.

Definition at line 21 of file eval_env.cc.

References bindings_, and parent_.

◆ LookupWithFallback()

string BindingEnv::LookupWithFallback ( const std::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 95 of file eval_env.cc.

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

Member Data Documentation

◆ bindings_

std::map<std::string, std::string> BindingEnv::bindings_
private

Definition at line 116 of file eval_env.h.

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

◆ parent_

BindingEnv* BindingEnv::parent_
private

Definition at line 118 of file eval_env.h.

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

◆ rules_

std::map<std::string, std::unique_ptr<const Rule> > BindingEnv::rules_
private

Definition at line 117 of file eval_env.h.

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


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