symbol database: add a link from a Function to its Function Scope namd make function parameters belong to Function Scope

This commit is contained in:
Robert Reif 2011-03-24 22:08:18 -04:00
parent 74105f5d83
commit d643918761
2 changed files with 7 additions and 3 deletions

View File

@ -287,6 +287,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
{ {
scope->functionOf = functionOf; scope->functionOf = functionOf;
scope->function = &functionOf->functionList.back(); scope->function = &functionOf->functionList.back();
scope->function->functionScope = scope;
} }
tok = tok2; tok = tok2;
@ -980,7 +981,8 @@ void SymbolDatabase::addFunction(Scope **scope, const Token **tok, const Token *
if (*scope) if (*scope)
{ {
(*scope)->functionOf = scope1; (*scope)->functionOf = scope1;
(*scope)->function = &scope1->functionList.back(); (*scope)->function = &*func;
(*scope)->function->functionScope = *scope;
added = true; added = true;
} }
@ -1253,7 +1255,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
bool isClassVar = startTok == endTok && !startTok->isStandardType(); bool isClassVar = startTok == endTok && !startTok->isStandardType();
argumentList.push_back(Variable(nameTok, startTok, endTok, count++, Argument, false, false, isConstVar, isClassVar, argType, scope, isArrayVar)); argumentList.push_back(Variable(nameTok, startTok, endTok, count++, Argument, false, false, isConstVar, isClassVar, argType, functionScope, isArrayVar));
if (tok->str() == ")") if (tok->str() == ")")
break; break;

View File

@ -332,7 +332,8 @@ public:
isExplicit(false), isExplicit(false),
isOperator(false), isOperator(false),
retFuncPtr(false), retFuncPtr(false),
type(eFunction) type(eFunction),
functionScope(NULL)
{ {
} }
@ -357,6 +358,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, ...
Scope *functionScope; // scope of function body
std::list<Variable> argumentList; // argument list std::list<Variable> argumentList; // argument list
}; };