add a list of function arguments to symbol database Function class
This commit is contained in:
parent
c1c9b96bb6
commit
eda25f6502
|
@ -456,6 +456,20 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fill in function arguments
|
||||||
|
for (it = scopeList.begin(); it != scopeList.end(); ++it)
|
||||||
|
{
|
||||||
|
scope = *it;
|
||||||
|
|
||||||
|
std::list<Function>::iterator func;
|
||||||
|
|
||||||
|
for (func = scope->functionList.begin(); func != scope->functionList.end(); ++func)
|
||||||
|
{
|
||||||
|
// add arguments
|
||||||
|
func->addArguments(this, scope);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// determine if user defined type needs initialization
|
// determine if user defined type needs initialization
|
||||||
unsigned int unknowns = 0; // stop checking when there are no unknowns
|
unsigned int unknowns = 0; // stop checking when there are no unknowns
|
||||||
unsigned int retry = 0; // bail if we don't resolve all the variable types for some reason
|
unsigned int retry = 0; // bail if we don't resolve all the variable types for some reason
|
||||||
|
@ -1002,6 +1016,58 @@ unsigned int Function::initializedArgCount() const
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *scope)
|
||||||
|
{
|
||||||
|
// check for non-empty argument list "( ... )"
|
||||||
|
if (arg->link() != arg->next())
|
||||||
|
{
|
||||||
|
unsigned int count = 0;
|
||||||
|
const Token *startTok;
|
||||||
|
const Token *endTok;
|
||||||
|
const Token *nameTok;
|
||||||
|
bool isConstVar;
|
||||||
|
const Token *tok = arg->next();
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
startTok = tok;
|
||||||
|
endTok = NULL;
|
||||||
|
nameTok = NULL;
|
||||||
|
isConstVar = bool(tok->str() == "const");
|
||||||
|
|
||||||
|
while (tok->str() != "," && tok->str() != ")")
|
||||||
|
{
|
||||||
|
if (tok->varId() != 0)
|
||||||
|
{
|
||||||
|
nameTok = tok;
|
||||||
|
endTok = tok->previous();
|
||||||
|
}
|
||||||
|
tok = tok->next();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for argument with no name
|
||||||
|
if (!endTok)
|
||||||
|
endTok = tok->previous();
|
||||||
|
|
||||||
|
const Token *typeTok = startTok;
|
||||||
|
if (isConstVar)
|
||||||
|
typeTok = typeTok->next();
|
||||||
|
|
||||||
|
const Scope *argType = NULL;
|
||||||
|
if (!typeTok->isStandardType())
|
||||||
|
argType = symbolDatabase->findVariableType(scope, typeTok);
|
||||||
|
|
||||||
|
bool isClassVar = startTok == endTok && !startTok->isStandardType();
|
||||||
|
|
||||||
|
argumentList.push_back(Variable(nameTok, startTok, endTok, count++, Argument, false, false, isConstVar, isClassVar, argType, scope));
|
||||||
|
|
||||||
|
if (tok->str() == ")")
|
||||||
|
break;
|
||||||
|
|
||||||
|
tok = tok->next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
Scope::Scope(SymbolDatabase *check_, const Token *classDef_, Scope *nestedIn_) :
|
Scope::Scope(SymbolDatabase *check_, const Token *classDef_, Scope *nestedIn_) :
|
||||||
|
|
|
@ -317,6 +317,7 @@ public:
|
||||||
|
|
||||||
unsigned int argCount() const;
|
unsigned int argCount() const;
|
||||||
unsigned int initializedArgCount() const;
|
unsigned int initializedArgCount() const;
|
||||||
|
void addArguments(const SymbolDatabase *symbolDatabase, const Scope *scope);
|
||||||
|
|
||||||
const Token *tokenDef; // function name token in class definition
|
const Token *tokenDef; // function name token in class definition
|
||||||
const Token *argDef; // function argument start '(' in class definition
|
const Token *argDef; // function argument start '(' in class definition
|
||||||
|
@ -335,6 +336,7 @@ public:
|
||||||
bool isOperator; // is operator
|
bool isOperator; // is operator
|
||||||
bool retFuncPtr; // returns function pointer
|
bool retFuncPtr; // returns function pointer
|
||||||
Type type; // constructor, destructor, ...
|
Type type; // constructor, destructor, ...
|
||||||
|
std::list<Variable> argumentList; // argument list
|
||||||
};
|
};
|
||||||
|
|
||||||
class Scope
|
class Scope
|
||||||
|
|
Loading…
Reference in New Issue