Use Prototype instead of Function.

This commit is contained in:
Roberto Raggi
2010-08-05 17:06:16 +02:00
committed by Oswald Buddenhagen
parent 9aa991d636
commit 4ff3ee2ff0
11 changed files with 20 additions and 28 deletions

View File

@@ -280,7 +280,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
} }
} }
} else if (scope->isFunctionScope()) { } else if (scope->isPrototypeScope()) {
Function *fun = scope->owner()->asFunction(); Function *fun = scope->owner()->asFunction();
bindings()->lookupInScope(name, fun->members(), &candidates, /*templateId = */ 0, /*binding=*/ 0); bindings()->lookupInScope(name, fun->members(), &candidates, /*templateId = */ 0, /*binding=*/ 0);

View File

@@ -316,7 +316,7 @@ void ResolveExpression::thisObject()
{ {
Scope *scope = _scope; Scope *scope = _scope;
for (; scope; scope = scope->enclosingScope()) { for (; scope; scope = scope->enclosingScope()) {
if (scope->isFunctionScope()) { if (scope->isPrototypeScope()) {
Function *fun = scope->owner()->asFunction(); Function *fun = scope->owner()->asFunction();
if (Scope *cscope = scope->enclosingClassScope()) { if (Scope *cscope = scope->enclosingClassScope()) {
Class *klass = cscope->owner()->asClass(); Class *klass = cscope->owner()->asClass();

View File

@@ -1078,10 +1078,10 @@ void CPPEditor::switchDeclarationDefinition()
Symbol *lastVisibleSymbol = thisDocument->lastVisibleSymbolAt(line, column); Symbol *lastVisibleSymbol = thisDocument->lastVisibleSymbolAt(line, column);
Scope *functionScope = 0; Scope *functionScope = 0;
if (scope->isFunctionScope()) if (scope->isPrototypeScope())
functionScope = scope; functionScope = scope;
else else
functionScope = scope->enclosingFunctionScope(); functionScope = scope->enclosingPrototypeScope();
if (! functionScope && lastVisibleSymbol) { if (! functionScope && lastVisibleSymbol) {
if (Function *def = lastVisibleSymbol->asFunction()) if (Function *def = lastVisibleSymbol->asFunction())

View File

@@ -130,7 +130,7 @@ protected:
Scope *scope = _doc->scopeAt(line, column); Scope *scope = _doc->scopeAt(line, column);
while (scope) { while (scope) {
if (scope->isFunctionScope()) { if (scope->isPrototypeScope()) {
Function *fun = scope->owner()->asFunction(); Function *fun = scope->owner()->asFunction();
if (findMember(fun->members(), ast, line, column)) if (findMember(fun->members(), ast, line, column))
return false; return false;
@@ -176,7 +176,7 @@ protected:
Scope *scope = _doc->scopeAt(line, column); Scope *scope = _doc->scopeAt(line, column);
while (scope) { while (scope) {
if (scope->isFunctionScope()) { if (scope->isPrototypeScope()) {
Function *fun = scope->owner()->asFunction(); Function *fun = scope->owner()->asFunction();
if (findMember(fun->members(), ast, line, column)) if (findMember(fun->members(), ast, line, column))
return false; return false;

View File

@@ -68,7 +68,7 @@ QString AbstractEditorSupport::functionAt(const CppModelManagerInterface *modelM
return QString(); return QString();
if (const CPlusPlus::Symbol *symbol = document->lastVisibleSymbolAt(line, column)) if (const CPlusPlus::Symbol *symbol = document->lastVisibleSymbolAt(line, column))
if (const CPlusPlus::Scope *scope = symbol->scope()) if (const CPlusPlus::Scope *scope = symbol->scope())
if (const CPlusPlus::Scope *functionScope = scope->enclosingFunctionScope()) if (const CPlusPlus::Scope *functionScope = scope->enclosingPrototypeScope())
if (const CPlusPlus::Symbol *function = functionScope->owner()) { if (const CPlusPlus::Symbol *function = functionScope->owner()) {
const CPlusPlus::Overview o; const CPlusPlus::Overview o;
QString rc = o.prettyName(function->name()); QString rc = o.prettyName(function->name());

View File

@@ -1068,7 +1068,7 @@ void CppCodeCompletion::globalCompletion(Scope *currentScope)
} }
} }
} }
} else if (scope->isFunctionScope() || scope->isClassScope() || scope->isNamespaceScope()) { } else if (scope->isPrototypeScope() || scope->isClassScope() || scope->isNamespaceScope()) {
currentBinding = context.lookupType(scope->owner()); currentBinding = context.lookupType(scope->owner());
break; break;
} }
@@ -1079,7 +1079,7 @@ void CppCodeCompletion::globalCompletion(Scope *currentScope)
for (unsigned i = 0; i < scope->symbolCount(); ++i) { for (unsigned i = 0; i < scope->symbolCount(); ++i) {
addCompletionItem(scope->symbolAt(i)); addCompletionItem(scope->symbolAt(i));
} }
} else if (scope->isFunctionScope()) { } else if (scope->isPrototypeScope()) {
Function *fun = scope->owner()->asFunction(); Function *fun = scope->owner()->asFunction();
for (unsigned i = 0; i < fun->argumentCount(); ++i) { for (unsigned i = 0; i < fun->argumentCount(); ++i) {
addCompletionItem(fun->argumentAt(i)); addCompletionItem(fun->argumentAt(i));

View File

@@ -120,7 +120,7 @@ QDebug operator<<(QDebug d, const Scope &scope)
str << " enum"; str << " enum";
if (scope.isBlockScope()) if (scope.isBlockScope())
str << " block"; str << " block";
if (scope.isFunctionScope()) if (scope.isPrototypeScope())
str << " function"; str << " function";
if (scope.isPrototypeScope()) if (scope.isPrototypeScope())
str << " prototype"; str << " prototype";
@@ -374,7 +374,7 @@ int getUninitializedVariablesI(const CPlusPlus::Snapshot &snapshot,
if (CPlusPlus::Block *block = function->memberAt(0)->asBlock()) if (CPlusPlus::Block *block = function->memberAt(0)->asBlock())
innerMostScope = block->members(); innerMostScope = block->members();
} else { } else {
if (const CPlusPlus::Scope *functionScope = symbolAtLine->enclosingFunctionScope()) { if (const CPlusPlus::Scope *functionScope = symbolAtLine->enclosingPrototypeScope()) {
function = functionScope->owner()->asFunction(); function = functionScope->owner()->asFunction();
innerMostScope = symbolAtLine->isBlock() ? innerMostScope = symbolAtLine->isBlock() ?
symbolAtLine->asBlock()->members() : symbolAtLine->asBlock()->members() :

View File

@@ -118,7 +118,7 @@ Scope *Scope::enclosingEnumScope() const
return scope; return scope;
} }
Scope *Scope::enclosingFunctionScope() const Scope *Scope::enclosingPrototypeScope() const
{ {
Scope *scope = enclosingScope(); Scope *scope = enclosingScope();
for (; scope; scope = scope->enclosingScope()) { for (; scope; scope = scope->enclosingScope()) {
@@ -166,11 +166,6 @@ bool Scope::isBlockScope() const
return false; return false;
} }
bool Scope::isPrototypeScope() const
{
return isFunctionScope();
}
bool Scope::isObjCClassScope() const bool Scope::isObjCClassScope() const
{ {
if (_owner) if (_owner)
@@ -185,7 +180,7 @@ bool Scope::isObjCProtocolScope() const
return false; return false;
} }
bool Scope::isFunctionScope() const bool Scope::isPrototypeScope() const
{ {
if (_owner) if (_owner)
return _owner->isFunction(); return _owner->isFunction();

View File

@@ -87,8 +87,8 @@ public:
/// Returns the enclosing enum scope. /// Returns the enclosing enum scope.
Scope *enclosingEnumScope() const; Scope *enclosingEnumScope() const;
/// Rerturns the enclosing function scope. /// Rerturns the enclosing prototype scope.
Scope *enclosingFunctionScope() const; Scope *enclosingPrototypeScope() const;
/// Rerturns the enclosing Block scope. /// Rerturns the enclosing Block scope.
Scope *enclosingBlockScope() const; Scope *enclosingBlockScope() const;
@@ -105,9 +105,6 @@ public:
/// Returns true if this scope's owner is a Block Symbol. /// Returns true if this scope's owner is a Block Symbol.
bool isBlockScope() const; bool isBlockScope() const;
/// Returns true if this scope's owner is a Function Symbol.
bool isFunctionScope() const;
/// Returns true if this scope's owner is a Prototype Symbol. /// Returns true if this scope's owner is a Prototype Symbol.
bool isPrototypeScope() const; bool isPrototypeScope() const;

View File

@@ -283,15 +283,15 @@ Scope *Symbol::enclosingEnumScope() const
return _scope->enclosingEnumScope(); return _scope->enclosingEnumScope();
} }
Scope *Symbol::enclosingFunctionScope() const Scope *Symbol::enclosingPrototypeScope() const
{ {
if (! _scope) if (! _scope)
return 0; return 0;
else if (_scope->isFunctionScope()) else if (_scope->isPrototypeScope())
return _scope; return _scope;
return _scope->enclosingFunctionScope(); return _scope->enclosingPrototypeScope();
} }
Scope *Symbol::enclosingBlockScope() const Scope *Symbol::enclosingBlockScope() const

View File

@@ -295,8 +295,8 @@ public:
/// Returns the enclosing enum scope. /// Returns the enclosing enum scope.
Scope *enclosingEnumScope() const; Scope *enclosingEnumScope() const;
/// Returns the enclosing function scope. /// Returns the enclosing prototype scope.
Scope *enclosingFunctionScope() const; Scope *enclosingPrototypeScope() const;
/// Returns the enclosing Block scope. /// Returns the enclosing Block scope.
Scope *enclosingBlockScope() const; Scope *enclosingBlockScope() const;