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...
ExprLocalFunctionNode * | findFunction (const std::string &name)
| Find a function by name (recursive to parents) More...
ExprLocalVar * | find (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)
ExprVarEnv & | operator= (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 94 of file ExprEnv.h.

## Member Typedef Documentation

## ◆ FuncDictType

typedef std::map<std::string, ExprLocalFunctionNode*> SeExpr2::ExprVarEnv::FuncDictType
| private

Definition at line 98 of file ExprEnv.h.

## ◆ VarDictType

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

Definition at line 96 of file ExprEnv.h.

## Constructor & Destructor Documentation

## ◆ ExprVarEnv() [1/2]

SeExpr2::ExprVarEnv::ExprVarEnv | ( | ExprVarEnv & | other | ) |
| protected

## ◆ ExprVarEnv() [2/2]

SeExpr2::ExprVarEnv::ExprVarEnv | ( |  | ) |
| inline

Create a scope with no parent.

Definition at line 118 of file ExprEnv.h.

## ◆ ~ExprVarEnv()

SeExpr2::ExprVarEnv::~ExprVarEnv | ( |  | ) |

Definition at line 25 of file ExprEnv.cpp.

References resetAndSetParent().

## Member Function Documentation

## ◆ add()

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

Add a variable refernece.

Definition at line 71 of file ExprEnv.cpp.

References _map, and shadowedVariables.

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

## ◆ addFunction()

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

Add a function.

Definition at line 58 of file ExprEnv.cpp.

References _functions, _parent, and addFunction().

Referenced by addFunction().

## ◆ codegenMerges()

LLVM_VALUE SeExpr2::ExprVarEnv::codegenMerges | ( | LLVM_BUILDER | builder,
|  | int | mergeIndex
| ) |  |

## ◆ find()

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

Find a variable name by name (recursive to parents)

Definition at line 29 of file ExprEnv.cpp.

References _map, _parent, and find().

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

## ◆ findFunction()

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

Find a function by name (recursive to parents)

Definition at line 39 of file ExprEnv.cpp.

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

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

## ◆ lookup()

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

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

Definition at line 49 of file ExprEnv.cpp.

References _map, _parent, and lookup().

Referenced by lookup().

## ◆ merge()

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

Definition at line 142 of file ExprEnv.h.

References _mergedVariables, and index().

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

## ◆ mergeBranches()

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 81 of file ExprEnv.cpp.

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

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

## ◆ operator=()

ExprVarEnv& SeExpr2::ExprVarEnv::operator= | ( | ExprVarEnv & | other | ) |
| protected

## ◆ resetAndSetParent()

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

## ◆ _functions

FuncDictType SeExpr2::ExprVarEnv::_functions
| private

Definition at line 99 of file ExprEnv.h.

Referenced by addFunction(), and findFunction().

## ◆ _map

VarDictType SeExpr2::ExprVarEnv::_map
| private

Definition at line 97 of file ExprEnv.h.

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

## ◆ _mergedVariables

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

Keep track of all merged variables in.

Definition at line 106 of file ExprEnv.h.

Referenced by merge(), and mergeBranches().

## ◆ _parent

ExprVarEnv* SeExpr2::ExprVarEnv::_parent
| private

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

Definition at line 109 of file ExprEnv.h.

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

## ◆ shadowedVariables

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

Variables that have been superceded (and thus are inaccessible)

Definition at line 103 of file ExprEnv.h.

Referenced by add().

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

- /build/seexpr/src/SeExpr/src/SeExpr2/ExprEnv.h
- /build/seexpr/src/SeExpr/src/SeExpr2/ExprEnv.cpp