Rename private member variables

This commit is contained in:
Daniel Marjamäki 2018-06-17 18:55:41 +02:00
parent e90c04cff9
commit 965fcf9303
1 changed files with 31 additions and 31 deletions

View File

@ -99,13 +99,13 @@ public:
public: public:
ScopeGuard(Variables & guarded, ScopeGuard(Variables & guarded,
bool insideLoop) bool insideLoop)
:_guarded(guarded), :mGuarded(guarded),
_insideLoop(insideLoop) { mInsideLoop(insideLoop) {
_guarded.enterScope(); mGuarded.enterScope();
} }
~ScopeGuard() { ~ScopeGuard() {
_guarded.leaveScope(_insideLoop); mGuarded.leaveScope(mInsideLoop);
} }
private: private:
@ -113,15 +113,15 @@ public:
ScopeGuard(); ScopeGuard();
ScopeGuard& operator=(const ScopeGuard &); ScopeGuard& operator=(const ScopeGuard &);
Variables & _guarded; Variables & mGuarded;
bool _insideLoop; bool mInsideLoop;
}; };
void clear() { void clear() {
_varUsage.clear(); mVarUsage.clear();
} }
const std::map<unsigned int, VariableUsage> &varUsage() const { const std::map<unsigned int, VariableUsage> &varUsage() const {
return _varUsage; return mVarUsage;
} }
void addVar(const Variable *var, VariableType type, bool write_); void addVar(const Variable *var, VariableType type, bool write_);
void allocateMemory(unsigned int varid, const Token* tok); void allocateMemory(unsigned int varid, const Token* tok);
@ -136,7 +136,7 @@ public:
VariableUsage *find(unsigned int varid); VariableUsage *find(unsigned int varid);
void alias(unsigned int varid1, unsigned int varid2, bool replace); void alias(unsigned int varid1, unsigned int varid2, bool replace);
void erase(unsigned int varid) { void erase(unsigned int varid) {
_varUsage.erase(varid); mVarUsage.erase(varid);
} }
void eraseAliases(unsigned int varid); void eraseAliases(unsigned int varid);
void eraseAll(unsigned int varid); void eraseAll(unsigned int varid);
@ -150,9 +150,9 @@ private:
void enterScope(); void enterScope();
void leaveScope(bool insideLoop); void leaveScope(bool insideLoop);
std::map<unsigned int, VariableUsage> _varUsage; std::map<unsigned int, VariableUsage> mVarUsage;
std::list<std::set<unsigned int> > _varAddedInScope; std::list<std::set<unsigned int> > mVarAddedInScope;
std::list<std::set<unsigned int> > _varReadInScope; std::list<std::set<unsigned int> > mVarReadInScope;
}; };
@ -173,7 +173,7 @@ void Variables::alias(unsigned int varid1, unsigned int varid2, bool replace)
// alias to self // alias to self
if (varid1 == varid2) { if (varid1 == varid2) {
var1->use(_varReadInScope); var1->use(mVarReadInScope);
return; return;
} }
@ -201,7 +201,7 @@ void Variables::alias(unsigned int varid1, unsigned int varid2, bool replace)
var1->_aliases.insert(varid2); var1->_aliases.insert(varid2);
if (var2->mType == Variables::pointer) { if (var2->mType == Variables::pointer) {
_varReadInScope.back().insert(varid2); mVarReadInScope.back().insert(varid2);
var2->_read = true; var2->_read = true;
} }
} }
@ -247,8 +247,8 @@ void Variables::addVar(const Variable *var,
bool write_) bool write_)
{ {
if (var->declarationId() > 0) { if (var->declarationId() > 0) {
_varAddedInScope.back().insert(var->declarationId()); mVarAddedInScope.back().insert(var->declarationId());
_varUsage.insert(std::make_pair(var->declarationId(), VariableUsage(var, type, false, write_, false))); mVarUsage.insert(std::make_pair(var->declarationId(), VariableUsage(var, type, false, write_, false)));
} }
} }
@ -267,7 +267,7 @@ void Variables::read(unsigned int varid, const Token* tok)
VariableUsage *usage = find(varid); VariableUsage *usage = find(varid);
if (usage) { if (usage) {
_varReadInScope.back().insert(varid); mVarReadInScope.back().insert(varid);
usage->_read = true; usage->_read = true;
if (tok) if (tok)
usage->_lastAccess = tok; usage->_lastAccess = tok;
@ -283,7 +283,7 @@ void Variables::readAliases(unsigned int varid, const Token* tok)
VariableUsage *aliased = find(*aliases); VariableUsage *aliased = find(*aliases);
if (aliased) { if (aliased) {
_varReadInScope.back().insert(*aliases); mVarReadInScope.back().insert(*aliases);
aliased->_read = true; aliased->_read = true;
aliased->_lastAccess = tok; aliased->_lastAccess = tok;
} }
@ -336,14 +336,14 @@ void Variables::use(unsigned int varid, const Token* tok)
VariableUsage *usage = find(varid); VariableUsage *usage = find(varid);
if (usage) { if (usage) {
usage->use(_varReadInScope); usage->use(mVarReadInScope);
usage->_lastAccess = tok; usage->_lastAccess = tok;
for (std::set<unsigned int>::const_iterator aliases = usage->_aliases.begin(); aliases != usage->_aliases.end(); ++aliases) { for (std::set<unsigned int>::const_iterator aliases = usage->_aliases.begin(); aliases != usage->_aliases.end(); ++aliases) {
VariableUsage *aliased = find(*aliases); VariableUsage *aliased = find(*aliases);
if (aliased) { if (aliased) {
aliased->use(_varReadInScope); aliased->use(mVarReadInScope);
aliased->_lastAccess = tok; aliased->_lastAccess = tok;
} }
} }
@ -374,8 +374,8 @@ void Variables::modified(unsigned int varid, const Token* tok)
Variables::VariableUsage *Variables::find(unsigned int varid) Variables::VariableUsage *Variables::find(unsigned int varid)
{ {
if (varid) { if (varid) {
std::map<unsigned int, VariableUsage>::iterator i = _varUsage.find(varid); std::map<unsigned int, VariableUsage>::iterator i = mVarUsage.find(varid);
if (i != _varUsage.end()) if (i != mVarUsage.end())
return &i->second; return &i->second;
} }
return nullptr; return nullptr;
@ -383,15 +383,15 @@ Variables::VariableUsage *Variables::find(unsigned int varid)
void Variables::enterScope() void Variables::enterScope()
{ {
_varAddedInScope.emplace_back(); mVarAddedInScope.emplace_back();
_varReadInScope.emplace_back(); mVarReadInScope.emplace_back();
} }
void Variables::leaveScope(bool insideLoop) void Variables::leaveScope(bool insideLoop)
{ {
if (insideLoop) { if (insideLoop) {
// read variables are read again in subsequent run through loop // read variables are read again in subsequent run through loop
std::set<unsigned int> const & currentVarReadInScope = _varReadInScope.back(); std::set<unsigned int> const & currentVarReadInScope = mVarReadInScope.back();
for (std::set<unsigned int>::const_iterator readIter = currentVarReadInScope.begin(); for (std::set<unsigned int>::const_iterator readIter = currentVarReadInScope.begin();
readIter != currentVarReadInScope.end(); readIter != currentVarReadInScope.end();
++readIter) { ++readIter) {
@ -399,13 +399,13 @@ void Variables::leaveScope(bool insideLoop)
} }
} }
std::list<std::set<unsigned int> >::reverse_iterator reverseReadIter = _varReadInScope.rbegin(); std::list<std::set<unsigned int> >::reverse_iterator reverseReadIter = mVarReadInScope.rbegin();
++reverseReadIter; ++reverseReadIter;
if (reverseReadIter != _varReadInScope.rend()) { if (reverseReadIter != mVarReadInScope.rend()) {
// Transfer read variables into previous scope // Transfer read variables into previous scope
std::set<unsigned int> const & currentVarAddedInScope = _varAddedInScope.back(); std::set<unsigned int> const & currentVarAddedInScope = mVarAddedInScope.back();
std::set<unsigned int> & currentVarReadInScope = _varReadInScope.back(); std::set<unsigned int> & currentVarReadInScope = mVarReadInScope.back();
for (std::set<unsigned int>::const_iterator addedIter = currentVarAddedInScope.begin(); for (std::set<unsigned int>::const_iterator addedIter = currentVarAddedInScope.begin();
addedIter != currentVarAddedInScope.end(); addedIter != currentVarAddedInScope.end();
++addedIter) { ++addedIter) {
@ -415,8 +415,8 @@ void Variables::leaveScope(bool insideLoop)
previousVarReadInScope.insert(currentVarReadInScope.begin(), previousVarReadInScope.insert(currentVarReadInScope.begin(),
currentVarReadInScope.end()); currentVarReadInScope.end());
} }
_varReadInScope.pop_back(); mVarReadInScope.pop_back();
_varAddedInScope.pop_back(); mVarAddedInScope.pop_back();
} }
static const Token* doAssignment(Variables &variables, const Token *tok, bool dereference, const Scope *scope) static const Token* doAssignment(Variables &variables, const Token *tok, bool dereference, const Scope *scope)