SeExpr
|
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... | |
|
private |
|
private |
|
protected |
|
inline |
SeExpr2::ExprVarEnv::~ExprVarEnv | ( | ) |
Definition at line 25 of file ExprEnv.cpp.
References resetAndSetParent().
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 |
|
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().
|
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().
|
private |
Definition at line 102 of file ExprEnv.h.
Referenced by addFunction(), and findFunction().
|
private |
|
private |
Keep track of all merged variables in.
Definition at line 109 of file ExprEnv.h.
Referenced by merge(), and mergeBranches().
|
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().
|
private |