KSeExpr 6.0.0.0
|
Variable scope for tracking variable lookup. More...
#include <ExprEnv.h>
Public Member Functions | |
ExprVarEnv ()=default | |
Create a scope with no parent. | |
~ExprVarEnv ()=default | |
ExprVarEnv (ExprVarEnv &&)=default | |
ExprVarEnv & | operator= (ExprVarEnv &&)=default |
void | resetAndSetParent (ExprVarEnv *parent) |
Resets the scope (deletes all variables) and sets parent. | |
ExprLocalFunctionNode * | findFunction (const std::string &name) |
Find a function by name (recursive to parents) | |
ExprLocalVar * | find (const std::string &name) |
Find a variable name by name (recursive to parents) | |
ExprLocalVar const * | lookup (const std::string &name) const |
Find a const variable reference name by name (recursive to parents) | |
void | addFunction (const std::string &name, ExprLocalFunctionNode *prototype) |
Add a function. | |
void | add (const std::string &name, std::unique_ptr< ExprLocalVar > var) |
Add a variable refernece. | |
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. | |
LLVM_VALUE | codegenMerges (LLVM_BUILDER, int) LLVM_BASE |
std::vector< std::pair< std::string, ExprLocalVarPhi * > > & | merge (size_t index) |
Protected Member Functions | |
ExprVarEnv (ExprVarEnv &other) | |
ExprVarEnv & | operator= (const ExprVarEnv &other) |
Private Types | |
using | VarDictType = std::map< std::string, std::unique_ptr< ExprLocalVar > > |
using | FuncDictType = std::map< std::string, ExprLocalFunctionNode * > |
Private Attributes | |
VarDictType | _map |
FuncDictType | _functions |
std::vector< std::unique_ptr< ExprLocalVar > > | shadowedVariables |
Variables that have been superceded (and thus are inaccessible) | |
std::vector< std::vector< std::pair< std::string, ExprLocalVarPhi * > > > | _mergedVariables |
Keep track of all merged variables in. | |
ExprVarEnv * | _parent {nullptr} |
Parent variable environment has all variablesf rom previou scope (for lookup) | |
|
private |
|
private |
|
protected |
|
default |
Create a scope with no parent.
|
default |
|
default |
void KSeExpr::ExprVarEnv::add | ( | const std::string & | name, |
std::unique_ptr< ExprLocalVar > | var | ||
) |
Add a variable refernece.
Definition at line 63 of file ExprEnv.cpp.
References _map, and shadowedVariables.
Referenced by mergeBranches().
void KSeExpr::ExprVarEnv::addFunction | ( | const std::string & | name, |
ExprLocalFunctionNode * | prototype | ||
) |
Add a function.
Definition at line 49 of file ExprEnv.cpp.
References _functions, _parent, and addFunction().
Referenced by addFunction().
LLVM_VALUE KSeExpr::ExprVarEnv::codegenMerges | ( | LLVM_BUILDER | , |
int | |||
) |
ExprLocalVar * KSeExpr::ExprVarEnv::find | ( | const std::string & | name | ) |
ExprLocalFunctionNode * KSeExpr::ExprVarEnv::findFunction | ( | const std::string & | name | ) |
Find a function by name (recursive to parents)
Definition at line 28 of file ExprEnv.cpp.
References _functions, _parent, and findFunction().
Referenced by findFunction().
ExprLocalVar const * KSeExpr::ExprVarEnv::lookup | ( | const std::string & | name | ) | const |
|
inline |
Definition at line 171 of file ExprEnv.h.
References _mergedVariables.
Referenced by KSeExpr::ExprIfThenElseNode::buildInterpreter().
size_t KSeExpr::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 74 of file ExprEnv.cpp.
References _mergedVariables, and add().
|
protected |
|
default |
void KSeExpr::ExprVarEnv::resetAndSetParent | ( | ExprVarEnv * | parent | ) |
Resets the scope (deletes all variables) and sets parent.
Definition at line 12 of file ExprEnv.cpp.
References _parent.
|
private |
Definition at line 125 of file ExprEnv.h.
Referenced by addFunction(), and findFunction().
|
private |
|
private |
Keep track of all merged variables in.
Definition at line 132 of file ExprEnv.h.
Referenced by merge(), and mergeBranches().
|
private |
Parent variable environment has all variablesf rom previou scope (for lookup)
Definition at line 135 of file ExprEnv.h.
Referenced by addFunction(), find(), findFunction(), lookup(), and resetAndSetParent().
|
private |