|
KSeExpr 4.0.4.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 |
References ExprVarEnv().
Referenced by ExprVarEnv(), ExprVarEnv(), mergeBranches(), operator=(), operator=(), and resetAndSetParent().
|
default |
Create a scope with no parent.
|
default |
|
default |
References ExprVarEnv().
| 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(), and KSeExpr::ExprAssignNode::prep().
| void KSeExpr::ExprVarEnv::addFunction | ( | const std::string & | name, |
| ExprLocalFunctionNode * | prototype ) |
| LLVM_VALUE KSeExpr::ExprVarEnv::codegenMerges | ( | LLVM_BUILDER | , |
| int | ) |
References LLVM_BASE.
| ExprLocalVar * KSeExpr::ExprVarEnv::find | ( | const std::string & | name | ) |
Find a variable name by name (recursive to parents)
Definition at line 17 of file ExprEnv.cpp.
Referenced by mergeBranches(), and KSeExpr::ExprVarNode::prep().
| 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, and _parent.
Referenced by KSeExpr::ExprFuncNode::prep().
| ExprLocalVar const * KSeExpr::ExprVarEnv::lookup | ( | const std::string & | name | ) | const |
Find a const variable reference name by name (recursive to parents)
Definition at line 39 of file ExprEnv.cpp.
|
inline |
Definition at line 171 of file ExprEnv.h.
References _mergedVariables.
| 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 _map, _mergedVariables, add(), ExprVarEnv(), and find().
Referenced by KSeExpr::ExprIfThenElseNode::prep().
|
protected |
References ExprVarEnv().
|
default |
References ExprVarEnv().
| 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, and ExprVarEnv().
Referenced by KSeExpr::ExprLocalFunctionNode::prep().
|
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 |