Renamed _variableList to mVariableList
This commit is contained in:
parent
759097301b
commit
56126d6e2d
|
@ -901,8 +901,8 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
|
||||||
void SymbolDatabase::createSymbolDatabaseVariableSymbolTable()
|
void SymbolDatabase::createSymbolDatabaseVariableSymbolTable()
|
||||||
{
|
{
|
||||||
// create variable symbol table
|
// create variable symbol table
|
||||||
_variableList.resize(mTokenizer->varIdCount() + 1);
|
mVariableList.resize(mTokenizer->varIdCount() + 1);
|
||||||
std::fill_n(_variableList.begin(), _variableList.size(), (const Variable*)nullptr);
|
std::fill_n(mVariableList.begin(), mVariableList.size(), (const Variable*)nullptr);
|
||||||
|
|
||||||
// check all scopes for variables
|
// check all scopes for variables
|
||||||
for (std::list<Scope>::iterator it = scopeList.begin(); it != scopeList.end(); ++it) {
|
for (std::list<Scope>::iterator it = scopeList.begin(); it != scopeList.end(); ++it) {
|
||||||
|
@ -912,7 +912,7 @@ void SymbolDatabase::createSymbolDatabaseVariableSymbolTable()
|
||||||
for (std::list<Variable>::iterator var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
|
for (std::list<Variable>::iterator var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
|
||||||
const unsigned int varId = var->declarationId();
|
const unsigned int varId = var->declarationId();
|
||||||
if (varId)
|
if (varId)
|
||||||
_variableList[varId] = &(*var);
|
mVariableList[varId] = &(*var);
|
||||||
// fix up variables without type
|
// fix up variables without type
|
||||||
if (!var->type() && !var->typeStartToken()->isStandardType()) {
|
if (!var->type() && !var->typeStartToken()->isStandardType()) {
|
||||||
const Type *type = findType(var->typeStartToken(), scope);
|
const Type *type = findType(var->typeStartToken(), scope);
|
||||||
|
@ -928,7 +928,7 @@ void SymbolDatabase::createSymbolDatabaseVariableSymbolTable()
|
||||||
if (arg->nameToken() && arg->declarationId()) {
|
if (arg->nameToken() && arg->declarationId()) {
|
||||||
const unsigned int declarationId = arg->declarationId();
|
const unsigned int declarationId = arg->declarationId();
|
||||||
if (declarationId > 0U)
|
if (declarationId > 0U)
|
||||||
_variableList[declarationId] = &(*arg);
|
mVariableList[declarationId] = &(*arg);
|
||||||
// fix up parameters without type
|
// fix up parameters without type
|
||||||
if (!arg->type() && !arg->typeStartToken()->isStandardType()) {
|
if (!arg->type() && !arg->typeStartToken()->isStandardType()) {
|
||||||
const Type *type = findTypeInNested(arg->typeStartToken(), scope);
|
const Type *type = findTypeInNested(arg->typeStartToken(), scope);
|
||||||
|
@ -950,14 +950,14 @@ void SymbolDatabase::createSymbolDatabaseVariableSymbolTable()
|
||||||
(tok->next()->str() == "." ||
|
(tok->next()->str() == "." ||
|
||||||
(tok->next()->str() == "[" && tok->linkAt(1)->strAt(1) == "."))) {
|
(tok->next()->str() == "[" && tok->linkAt(1)->strAt(1) == "."))) {
|
||||||
const Token *tok1 = tok->next()->str() == "." ? tok->tokAt(2) : tok->linkAt(1)->tokAt(2);
|
const Token *tok1 = tok->next()->str() == "." ? tok->tokAt(2) : tok->linkAt(1)->tokAt(2);
|
||||||
if (tok1 && tok1->varId() && _variableList[tok1->varId()] == 0) {
|
if (tok1 && tok1->varId() && mVariableList[tok1->varId()] == 0) {
|
||||||
const Variable *var = _variableList[tok->varId()];
|
const Variable *var = mVariableList[tok->varId()];
|
||||||
if (var && var->typeScope()) {
|
if (var && var->typeScope()) {
|
||||||
// find the member variable of this variable
|
// find the member variable of this variable
|
||||||
const Variable *var1 = var->typeScope()->getVariable(tok1->str());
|
const Variable *var1 = var->typeScope()->getVariable(tok1->str());
|
||||||
if (var1) {
|
if (var1) {
|
||||||
// add this variable to the look up table
|
// add this variable to the look up table
|
||||||
_variableList[tok1->varId()] = var1;
|
mVariableList[tok1->varId()] = var1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1088,9 +1088,9 @@ void SymbolDatabase::fixVarId(VarIdMap & varIds, const Token * vartok, Token * m
|
||||||
MemberIdMap memberId;
|
MemberIdMap memberId;
|
||||||
if (membertok->varId() == 0) {
|
if (membertok->varId() == 0) {
|
||||||
memberId[membervar->nameToken()->varId()] = const_cast<Tokenizer *>(mTokenizer)->newVarId();
|
memberId[membervar->nameToken()->varId()] = const_cast<Tokenizer *>(mTokenizer)->newVarId();
|
||||||
_variableList.push_back(membervar);
|
mVariableList.push_back(membervar);
|
||||||
} else
|
} else
|
||||||
_variableList[membertok->varId()] = membervar;
|
mVariableList[membertok->varId()] = membervar;
|
||||||
varIds.insert(std::make_pair(vartok->varId(), memberId));
|
varIds.insert(std::make_pair(vartok->varId(), memberId));
|
||||||
varId = varIds.find(vartok->varId());
|
varId = varIds.find(vartok->varId());
|
||||||
}
|
}
|
||||||
|
@ -1098,10 +1098,10 @@ void SymbolDatabase::fixVarId(VarIdMap & varIds, const Token * vartok, Token * m
|
||||||
if (memberId == varId->second.end()) {
|
if (memberId == varId->second.end()) {
|
||||||
if (membertok->varId() == 0) {
|
if (membertok->varId() == 0) {
|
||||||
varId->second.insert(std::make_pair(membervar->nameToken()->varId(), const_cast<Tokenizer *>(mTokenizer)->newVarId()));
|
varId->second.insert(std::make_pair(membervar->nameToken()->varId(), const_cast<Tokenizer *>(mTokenizer)->newVarId()));
|
||||||
_variableList.push_back(membervar);
|
mVariableList.push_back(membervar);
|
||||||
memberId = varId->second.find(membervar->nameToken()->varId());
|
memberId = varId->second.find(membervar->nameToken()->varId());
|
||||||
} else
|
} else
|
||||||
_variableList[membertok->varId()] = membervar;
|
mVariableList[membertok->varId()] = membervar;
|
||||||
}
|
}
|
||||||
if (membertok->varId() == 0)
|
if (membertok->varId() == 0)
|
||||||
membertok->varId(memberId->second);
|
membertok->varId(memberId->second);
|
||||||
|
@ -1139,7 +1139,7 @@ void SymbolDatabase::createSymbolDatabaseSetVariablePointers()
|
||||||
const Variable *membervar = var->typeScope()->getVariable(membertok->str());
|
const Variable *membervar = var->typeScope()->getVariable(membertok->str());
|
||||||
if (membervar) {
|
if (membervar) {
|
||||||
membertok->variable(membervar);
|
membertok->variable(membervar);
|
||||||
if (membertok->varId() == 0 || _variableList[membertok->varId()] == nullptr)
|
if (membertok->varId() == 0 || mVariableList[membertok->varId()] == nullptr)
|
||||||
fixVarId(varIds, tok, const_cast<Token *>(membertok), membervar);
|
fixVarId(varIds, tok, const_cast<Token *>(membertok), membervar);
|
||||||
}
|
}
|
||||||
} else if (var && tok->valueType() && tok->valueType()->type == ValueType::CONTAINER) {
|
} else if (var && tok->valueType() && tok->valueType()->type == ValueType::CONTAINER) {
|
||||||
|
@ -1149,7 +1149,7 @@ void SymbolDatabase::createSymbolDatabaseSetVariablePointers()
|
||||||
const Variable *membervar = type->classScope->getVariable(membertok->str());
|
const Variable *membervar = type->classScope->getVariable(membertok->str());
|
||||||
if (membervar) {
|
if (membervar) {
|
||||||
membertok->variable(membervar);
|
membertok->variable(membervar);
|
||||||
if (membertok->varId() == 0 || _variableList[membertok->varId()] == nullptr)
|
if (membertok->varId() == 0 || mVariableList[membertok->varId()] == nullptr)
|
||||||
fixVarId(varIds, tok, const_cast<Token *>(membertok), membervar);
|
fixVarId(varIds, tok, const_cast<Token *>(membertok), membervar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1177,7 +1177,7 @@ void SymbolDatabase::createSymbolDatabaseSetVariablePointers()
|
||||||
membervar = type->classScope->getVariable(membertok->str());
|
membervar = type->classScope->getVariable(membertok->str());
|
||||||
if (membervar) {
|
if (membervar) {
|
||||||
membertok->variable(membervar);
|
membertok->variable(membervar);
|
||||||
if (membertok->varId() == 0 || _variableList[membertok->varId()] == nullptr) {
|
if (membertok->varId() == 0 || mVariableList[membertok->varId()] == nullptr) {
|
||||||
if (tok->function()->retDef)
|
if (tok->function()->retDef)
|
||||||
fixVarId(varIds, tok->function()->retDef, const_cast<Token *>(membertok), membervar);
|
fixVarId(varIds, tok->function()->retDef, const_cast<Token *>(membertok), membervar);
|
||||||
}
|
}
|
||||||
|
@ -1261,9 +1261,9 @@ void SymbolDatabase::createSymbolDatabaseUnknownArrayDimensions()
|
||||||
// set all unknown array dimensions
|
// set all unknown array dimensions
|
||||||
for (std::size_t i = 1; i <= mTokenizer->varIdCount(); i++) {
|
for (std::size_t i = 1; i <= mTokenizer->varIdCount(); i++) {
|
||||||
// check each array variable
|
// check each array variable
|
||||||
if (_variableList[i] && _variableList[i]->isArray()) {
|
if (mVariableList[i] && mVariableList[i]->isArray()) {
|
||||||
// check each array dimension
|
// check each array dimension
|
||||||
const std::vector<Dimension>& dimensions = _variableList[i]->dimensions();
|
const std::vector<Dimension>& dimensions = mVariableList[i]->dimensions();
|
||||||
for (std::size_t j = 0; j < dimensions.size(); j++) {
|
for (std::size_t j = 0; j < dimensions.size(); j++) {
|
||||||
Dimension &dimension = const_cast<Dimension &>(dimensions[j]);
|
Dimension &dimension = const_cast<Dimension &>(dimensions[j]);
|
||||||
if (dimension.num == 0) {
|
if (dimension.num == 0) {
|
||||||
|
@ -1576,7 +1576,7 @@ namespace {
|
||||||
|
|
||||||
void SymbolDatabase::validateVariables() const
|
void SymbolDatabase::validateVariables() const
|
||||||
{
|
{
|
||||||
for (std::vector<const Variable *>::const_iterator iter = _variableList.begin(); iter!=_variableList.end(); ++iter) {
|
for (std::vector<const Variable *>::const_iterator iter = mVariableList.begin(); iter!=mVariableList.end(); ++iter) {
|
||||||
const Variable * const var = *iter;
|
const Variable * const var = *iter;
|
||||||
if (var) {
|
if (var) {
|
||||||
if (!var->scope()) {
|
if (!var->scope()) {
|
||||||
|
@ -2905,11 +2905,11 @@ void SymbolDatabase::printOut(const char *title) const
|
||||||
std::cout << " )" << std::endl;
|
std::cout << " )" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t i = 1; i < _variableList.size(); i++) {
|
for (std::size_t i = 1; i < mVariableList.size(); i++) {
|
||||||
std::cout << "_variableList[" << i << "]: " << _variableList[i];
|
std::cout << "mVariableList[" << i << "]: " << mVariableList[i];
|
||||||
if (_variableList[i]) {
|
if (mVariableList[i]) {
|
||||||
std::cout << " " << _variableList[i]->name() << " "
|
std::cout << " " << mVariableList[i]->name() << " "
|
||||||
<< mTokenizer->list.fileLine(_variableList[i]->nameToken());
|
<< mTokenizer->list.fileLine(mVariableList[i]->nameToken());
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -2985,7 +2985,7 @@ void SymbolDatabase::printXml(std::ostream &out) const
|
||||||
out << " </scopes>" << std::endl;
|
out << " </scopes>" << std::endl;
|
||||||
|
|
||||||
// Variables..
|
// Variables..
|
||||||
for (const Variable *var : _variableList)
|
for (const Variable *var : mVariableList)
|
||||||
variables.insert(var);
|
variables.insert(var);
|
||||||
out << " <variables>" << std::endl;
|
out << " <variables>" << std::endl;
|
||||||
for (const Variable *var : variables) {
|
for (const Variable *var : variables) {
|
||||||
|
|
|
@ -1154,11 +1154,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
const Variable *getVariableFromVarId(std::size_t varId) const {
|
const Variable *getVariableFromVarId(std::size_t varId) const {
|
||||||
return _variableList.at(varId);
|
return mVariableList.at(varId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<const Variable *> & variableList() const {
|
const std::vector<const Variable *> & variableList() const {
|
||||||
return _variableList;
|
return mVariableList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1243,7 +1243,7 @@ private:
|
||||||
ErrorLogger *mErrorLogger;
|
ErrorLogger *mErrorLogger;
|
||||||
|
|
||||||
/** variable symbol table */
|
/** variable symbol table */
|
||||||
std::vector<const Variable *> _variableList;
|
std::vector<const Variable *> mVariableList;
|
||||||
|
|
||||||
/** list for missing types */
|
/** list for missing types */
|
||||||
std::list<Type> _blankTypes;
|
std::list<Type> _blankTypes;
|
||||||
|
|
Loading…
Reference in New Issue