SeExpr
Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
SeExpr2::ExprVarEnv Class Reference

Variable scope for tracking variable lookup. More...

#include <ExprEnv.h>

Public Member Functions

 ExprVarEnv ()
 Create a scope with no parent. More...
 
 ~ExprVarEnv ()
 
void resetAndSetParent (ExprVarEnv *parent)
 Resets the scope (deletes all variables) and sets parent. More...
 
ExprLocalFunctionNodefindFunction (const std::string &name)
 Find a function by name (recursive to parents) More...
 
ExprLocalVarfind (const std::string &name)
 Find a variable name by name (recursive to parents) More...
 
ExprLocalVar const * lookup (const std::string &name) const
 Find a const variable reference name by name (recursive to parents) More...
 
void addFunction (const std::string &name, ExprLocalFunctionNode *prototype)
 Add a function. More...
 
void add (const std::string &name, std::unique_ptr< ExprLocalVar > var)
 Add a variable refernece. More...
 
size_t mergeBranches (const ExprType &type, ExprVarEnv &env1, ExprVarEnv &env2)
 Add all variables into scope by name, but modify their lifetimes to the given type's lifetime. More...
 
LLVM_VALUE codegenMerges (LLVM_BUILDER builder, int mergeIndex) LLVM_BODY
 
std::vector< std::pair
< std::string, ExprLocalVarPhi * > > & 
merge (size_t index)
 

Protected Member Functions

 ExprVarEnv (ExprVarEnv &other)
 
ExprVarEnvoperator= (ExprVarEnv &other)
 

Private Types

typedef std::map< std::string,
std::unique_ptr< ExprLocalVar > > 
VarDictType
 
typedef std::map< std::string,
ExprLocalFunctionNode * > 
FuncDictType
 

Private Attributes

VarDictType _map
 
FuncDictType _functions
 
std::vector< std::unique_ptr
< ExprLocalVar > > 
shadowedVariables
 Variables that have been superceded (and thus are inaccessible) More...
 
std::vector< std::vector
< std::pair< std::string,
ExprLocalVarPhi * > > > 
_mergedVariables
 Keep track of all merged variables in. More...
 
ExprVarEnv_parent
 Parent variable environment has all variablesf rom previou scope (for lookup) More...
 

Detailed Description

Variable scope for tracking variable lookup.

Definition at line 97 of file ExprEnv.h.

Member Typedef Documentation

Definition at line 101 of file ExprEnv.h.

typedef std::map<std::string, std::unique_ptr<ExprLocalVar> > SeExpr2::ExprVarEnv::VarDictType
private

Definition at line 99 of file ExprEnv.h.

Constructor & Destructor Documentation

SeExpr2::ExprVarEnv::ExprVarEnv ( ExprVarEnv other)
protected
SeExpr2::ExprVarEnv::ExprVarEnv ( )
inline

Create a scope with no parent.

Definition at line 121 of file ExprEnv.h.

SeExpr2::ExprVarEnv::~ExprVarEnv ( )

Definition at line 25 of file ExprEnv.cpp.

References resetAndSetParent().

Member Function Documentation

void SeExpr2::ExprVarEnv::add ( const std::string &  name,
std::unique_ptr< ExprLocalVar var 
)

Add a variable refernece.

Definition at line 73 of file ExprEnv.cpp.

References _map, and shadowedVariables.

Referenced by mergeBranches(), SeExpr2::ExprPrototypeNode::prep(), and SeExpr2::ExprAssignNode::prep().

void SeExpr2::ExprVarEnv::addFunction ( const std::string &  name,
ExprLocalFunctionNode prototype 
)

Add a function.

Definition at line 60 of file ExprEnv.cpp.

References _functions, _parent, and addFunction().

Referenced by addFunction().

LLVM_VALUE SeExpr2::ExprVarEnv::codegenMerges ( LLVM_BUILDER  builder,
int  mergeIndex 
)
ExprLocalVar * SeExpr2::ExprVarEnv::find ( const std::string &  name)

Find a variable name by name (recursive to parents)

Definition at line 31 of file ExprEnv.cpp.

References _map, _parent, and find().

Referenced by find(), mergeBranches(), and SeExpr2::ExprVarNode::prep().

ExprLocalFunctionNode * SeExpr2::ExprVarEnv::findFunction ( const std::string &  name)

Find a function by name (recursive to parents)

Definition at line 41 of file ExprEnv.cpp.

References _functions, _parent, findFunction(), and if().

Referenced by findFunction(), and SeExpr2::ExprFuncNode::prep().

ExprLocalVar const * SeExpr2::ExprVarEnv::lookup ( const std::string &  name) const

Find a const variable reference name by name (recursive to parents)

Definition at line 51 of file ExprEnv.cpp.

References _map, _parent, and lookup().

Referenced by lookup().

std::vector<std::pair<std::string,ExprLocalVarPhi*> >& SeExpr2::ExprVarEnv::merge ( size_t  index)
inline

Definition at line 145 of file ExprEnv.h.

References _mergedVariables, and index().

Referenced by SeExpr2::ExprIfThenElseNode::buildInterpreter().

size_t SeExpr2::ExprVarEnv::mergeBranches ( const ExprType type,
ExprVarEnv env1,
ExprVarEnv env2 
)

Add all variables into scope by name, but modify their lifetimes to the given type's lifetime.

Checks if each branch shares the same items and the same types!

For each thing in env1 see if env2 has an entry

For each thing in env2 see if env1 has an entry

Definition at line 83 of file ExprEnv.cpp.

References _map, _mergedVariables, add(), find(), and it.

Referenced by SeExpr2::ExprIfThenElseNode::prep().

ExprVarEnv& SeExpr2::ExprVarEnv::operator= ( ExprVarEnv other)
protected
void SeExpr2::ExprVarEnv::resetAndSetParent ( ExprVarEnv parent)

Resets the scope (deletes all variables) and sets parent.

Definition at line 27 of file ExprEnv.cpp.

References _parent.

Referenced by SeExpr2::ExprLocalFunctionNode::prep(), and ~ExprVarEnv().

Member Data Documentation

FuncDictType SeExpr2::ExprVarEnv::_functions
private

Definition at line 102 of file ExprEnv.h.

Referenced by addFunction(), and findFunction().

VarDictType SeExpr2::ExprVarEnv::_map
private

Definition at line 100 of file ExprEnv.h.

Referenced by add(), find(), lookup(), and mergeBranches().

std::vector<std::vector<std::pair<std::string,ExprLocalVarPhi*> > > SeExpr2::ExprVarEnv::_mergedVariables
private

Keep track of all merged variables in.

Definition at line 109 of file ExprEnv.h.

Referenced by merge(), and mergeBranches().

ExprVarEnv* SeExpr2::ExprVarEnv::_parent
private

Parent variable environment has all variablesf rom previou scope (for lookup)

Definition at line 112 of file ExprEnv.h.

Referenced by addFunction(), find(), findFunction(), lookup(), and resetAndSetParent().

std::vector<std::unique_ptr<ExprLocalVar> > SeExpr2::ExprVarEnv::shadowedVariables
private

Variables that have been superceded (and thus are inaccessible)

Definition at line 106 of file ExprEnv.h.

Referenced by add().


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