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

◆ BindingEnv() [2/2]

BindingEnv::BindingEnv ( BindingEnv parent)
inlineexplicit

Definition at line 95 of file eval_env.h.

◆ ~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 
)

◆ AddRule()

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

Definition at line 34 of file eval_env.cc.

Referenced by ManifestParser::ParseRule().

◆ GetRules()

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

Definition at line 91 of file eval_env.cc.

◆ LookupRule()

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

Definition at line 46 of file eval_env.cc.

Referenced by Cleaner::CleanRule(), Cleaner::CleanRules(), and ManifestParser::ParseEdge().

◆ LookupRuleCurrentScope()

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

Definition at line 39 of file eval_env.cc.

Referenced by ManifestParser::ParseRule().

◆ LookupVariable()

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

Implements Env.

Definition at line 21 of file eval_env.cc.

Referenced by Builder::Builder().

◆ 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 EvalString::Evaluate().

Member Data Documentation

◆ bindings_

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

Definition at line 116 of file eval_env.h.

◆ parent_

BindingEnv* BindingEnv::parent_
private

Definition at line 118 of file eval_env.h.

◆ rules_

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

Definition at line 117 of file eval_env.h.


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