Tokenizer::setVarId: Refactoring, changed type name

This commit is contained in:
Daniel Marjamäki 2016-05-11 21:12:29 +02:00
parent b965cf5491
commit 99d0dbf39c
1 changed files with 8 additions and 8 deletions

View File

@ -39,11 +39,11 @@
namespace { namespace {
// local struct used in setVarId // local struct used in setVarId
// in order to store information about the scope // in order to store information about the scope
struct scopeStackEntryType { struct VarIdscopeInfo {
scopeStackEntryType() VarIdscopeInfo()
:isExecutable(false), startVarid(0) { :isExecutable(false), startVarid(0) {
} }
scopeStackEntryType(bool _isExecutable, unsigned int _startVarid) VarIdscopeInfo(bool _isExecutable, unsigned int _startVarid)
:isExecutable(_isExecutable), startVarid(_startVarid) { :isExecutable(_isExecutable), startVarid(_startVarid) {
} }
@ -2609,9 +2609,9 @@ void Tokenizer::setVarId()
std::map<unsigned int, std::map<std::string, unsigned int> > structMembers; std::map<unsigned int, std::map<std::string, unsigned int> > structMembers;
std::stack< std::map<std::string, unsigned int> > scopeInfo; std::stack< std::map<std::string, unsigned int> > scopeInfo;
std::stack<scopeStackEntryType> scopeStack; std::stack<VarIdscopeInfo> scopeStack;
scopeStack.push(scopeStackEntryType()); scopeStack.push(VarIdscopeInfo());
std::stack<const Token *> functionDeclEndStack; std::stack<const Token *> functionDeclEndStack;
bool initlist = false; bool initlist = false;
for (Token *tok = list.front(); tok; tok = tok->next()) { for (Token *tok = list.front(); tok; tok = tok->next()) {
@ -2625,7 +2625,7 @@ void Tokenizer::setVarId()
variableId.swap(scopeInfo.top()); variableId.swap(scopeInfo.top());
scopeInfo.pop(); scopeInfo.pop();
} else if (tok->str() == "{") } else if (tok->str() == "{")
scopeStack.push(scopeStackEntryType(true, _varId)); scopeStack.push(VarIdscopeInfo(true, _varId));
} else if (!initlist && tok->str()=="(") { } else if (!initlist && tok->str()=="(") {
const Token * newFunctionDeclEnd = nullptr; const Token * newFunctionDeclEnd = nullptr;
if (!scopeStack.top().isExecutable) if (!scopeStack.top().isExecutable)
@ -2658,7 +2658,7 @@ void Tokenizer::setVarId()
scopeInfo.push(variableId); scopeInfo.push(variableId);
} }
initlist = false; initlist = false;
scopeStack.push(scopeStackEntryType(isExecutable, _varId)); scopeStack.push(VarIdscopeInfo(isExecutable, _varId));
} else { /* if (tok->str() == "}") */ } else { /* if (tok->str() == "}") */
bool isNamespace = false; bool isNamespace = false;
for (const Token *tok1 = tok->link()->previous(); tok1 && tok1->isName(); tok1 = tok1->previous()) for (const Token *tok1 = tok->link()->previous(); tok1 && tok1->isName(); tok1 = tok1->previous())
@ -2680,7 +2680,7 @@ void Tokenizer::setVarId()
scopeStack.pop(); scopeStack.pop();
if (scopeStack.empty()) { // should be impossible if (scopeStack.empty()) { // should be impossible
scopeStack.push(scopeStackEntryType()); scopeStack.push(VarIdscopeInfo());
} }
} }
} }