23class ExprLocalFunctionNode;
122 using VarDictType = std::map<std::string, std::unique_ptr<ExprLocalVar>>;
162 void add(
const std::string &name, std::unique_ptr<ExprLocalVar> var);
171 std::vector<std::pair<std::string, ExprLocalVarPhi *>> &
merge(
size_t index)
209 newEnv->resetAndSetParent(parent);
211 return all.back().get();
216 std::vector<std::unique_ptr<ExprVarEnv>>
all;
242 double *
fp {
nullptr};
243 const char **
str {
nullptr};
Node that contains local function.
ExprLocalVar join (merge) references. Remembers which variables are possible assigners to this.
ExprLocalVarPhi(const ExprType &condLife, ExprLocalVar *thenVar, ExprLocalVar *elseVar)
void setPhi(ExprLocalVar *phi) override
sets the representative phi node (like a brute force set unioning operation) phi is the set represent...
ExprLocalVar reference, all local variables in seexpr are subclasses of this or this itself.
virtual LLVM_VALUE codegen(LLVM_BUILDER, const std::string &, LLVM_VALUE) LLVM_BASE
LLVM value that has been allocated.
ExprLocalVar(ExprLocalVar &&)=default
ExprLocalVar(const ExprType &type)
virtual void setType(const ExprType &type)
setter for variable type
virtual void setPhi(ExprLocalVar *phi)
sets the representative phi node (like a brute force set unioning operation) phi is the set represent...
ExprLocalVar & operator=(ExprLocalVar &&)=default
ExprLocalVar(ExprLocalVar &)=default
const ExprLocalVar * getPhi() const
get the primary representative phi node (i.e. the global parent of a dependent phi node)
virtual LLVM_VALUE varPtr()
LLVM value that has been pre-done.
int buildInterpreter(Interpreter *interpreter) const
Allocates variable for interpreter.
virtual ~ExprLocalVar()=default
ExprLocalVar & operator=(const ExprLocalVar &)=default
ExprType type() const
returns type of the variable
static bool valuesCompatible(const ExprType &a, const ExprType &b)
Checks if value types are compatible.
Variable scope builder is used by the type checking and code gen to track visiblity of variables and ...
void setCurrent(ExprVarEnv *env)
Set a new current variable scope.
ExprVarEnvBuilder()
Creates an empty builder with one current scope entry.
ExprVarEnv * current()
Return the current variable scope.
ExprVarEnv * _currentEnv
The current symbol table (should be a pointer owned by all)
void reset()
Reset to factory state (one empty environment that is current)
ExprVarEnv * createDescendant(ExprVarEnv *parent)
Create a descendant scope from the provided parent, does not clobber current.
std::vector< std::unique_ptr< ExprVarEnv > > all
All owned symbol tables.
Variable scope for tracking variable lookup.
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)
std::map< std::string, ExprLocalFunctionNode * > FuncDictType
LLVM_VALUE codegenMerges(LLVM_BUILDER, int) LLVM_BASE
ExprLocalFunctionNode * findFunction(const std::string &name)
Find a function by name (recursive to parents)
ExprVarEnv(ExprVarEnv &&)=default
ExprVarEnv & operator=(ExprVarEnv &&)=default
ExprVarEnv()=default
Create a scope with no parent.
std::vector< std::pair< std::string, ExprLocalVarPhi * > > & merge(size_t index)
void addFunction(const std::string &name, ExprLocalFunctionNode *prototype)
Add a function.
std::vector< std::vector< std::pair< std::string, ExprLocalVarPhi * > > > _mergedVariables
Keep track of all merged variables in.
ExprVarEnv(ExprVarEnv &other)
void add(const std::string &name, std::unique_ptr< ExprLocalVar > var)
Add a variable refernece.
std::vector< std::unique_ptr< ExprLocalVar > > shadowedVariables
Variables that have been superceded (and thus are inaccessible)
ExprVarEnv * _parent
Parent variable environment has all variablesf rom previou scope (for lookup)
void resetAndSetParent(ExprVarEnv *parent)
Resets the scope (deletes all variables) and sets parent.
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.
std::map< std::string, std::unique_ptr< ExprLocalVar > > VarDictType
ExprVarEnv & operator=(const ExprVarEnv &other)
ExprEvalResult(int n, double *fp, const char **c)
ExprEvalResult(int n, double *fp)
ExprEvalResult(const char **c)