32 VarDictType::iterator iter =
_map.find(name);
33 if (iter !=
_map.end())
34 return iter->second.get();
42 FuncDictType::iterator iter =
_functions.find(name);
52 VarDictType::const_iterator iter =
_map.find(name);
53 if (iter !=
_map.end())
54 return iter->second.get();
65 FuncDictType::iterator iter =
_functions.find(name);
67 iter->second = prototype;
69 _functions.insert(std::make_pair(name, prototype));
73 void ExprVarEnv::add(
const std::string& name, std::unique_ptr<ExprLocalVar> var) {
74 VarDictType::iterator iter =
_map.find(name);
75 if (iter !=
_map.end()){
78 iter->second=std::move(var);
80 _map.insert(std::make_pair(name, std::move(var)));
84 typedef std::map<std::pair<ExprLocalVar*, ExprLocalVar*>, std::string> MakeMap;
87 for (
auto& ienv: env1.
_map){
88 const std::string& name = ienv.first;
91 phisToMake[std::make_pair(var, env2Var)] = name;
95 for (
auto& ienv: env2.
_map){
96 const std::string& name = ienv.first;
99 phisToMake[std::make_pair(env1Var, var)] = name;
103 std::vector<std::pair<std::string,ExprLocalVarPhi*>> mergedVariablesInThisCall;
104 for (MakeMap::iterator
it = phisToMake.begin();
it != phisToMake.end(); ++
it) {
105 std::unique_ptr<ExprLocalVar> newVar(
new ExprLocalVarPhi(type,
it->first.first,
it->first.second));
106 mergedVariablesInThisCall.emplace_back(
it->second,static_cast<ExprLocalVarPhi*>(newVar.get()));
107 add(
it->second, std::move(newVar));
std::vector< std::vector< std::pair< std::string, ExprLocalVarPhi * > > > _mergedVariables
Keep track of all merged variables in.
Node that contains local function.
std::vector< std::unique_ptr< ExprLocalVar > > shadowedVariables
Variables that have been superceded (and thus are inaccessible)
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...
ExprLocalVar reference, all local variables in seexpr are subclasses of this or this itself...
Variable scope for tracking variable lookup.
ExprLocalVar * find(const std::string &name)
Find a variable name by name (recursive to parents)
ExprLocalFunctionNode * findFunction(const std::string &name)
Find a function by name (recursive to parents)
ExprLocalVar const * lookup(const std::string &name) const
Find a const variable reference name by name (recursive to parents)
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.
ExprLocalVar join (merge) references. Remembers which variables are possible assigners to this...
you may not use this file except in compliance with the License and the following modification to it
if((BISON_EXE STREQUAL"BISON_EXE-NOTFOUND") OR(FLEX_EXE STREQUAL"FLEX_EXE-NOTFOUND") OR(SED_EXE STREQUAL"SED_EXE-NOTFOUND")) else((BISON_EXE STREQUAL"BISON_EXE-NOTFOUND") OR(FLEX_EXE STREQUAL"FLEX_EXE-NOTFOUND") OR(SED_EXE STREQUAL"SED_EXE-NOTFOUND")) ADD_CUSTOM_COMMAND(SOURCE"ExprParserLex.l"COMMAND"flex"ARGS"-oExprParserLexIn.cpp""$
void addFunction(const std::string &name, ExprLocalFunctionNode *prototype)
Add a function.