2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 12:01:29 +01:00
|
|
|
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
#include "Symbols.h"
|
|
|
|
#include "Names.h"
|
|
|
|
#include "TypeVisitor.h"
|
|
|
|
#include "SymbolVisitor.h"
|
2009-11-23 11:56:44 +01:00
|
|
|
#include "TypeMatcher.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "Scope.h"
|
|
|
|
|
2009-10-20 11:21:25 +02:00
|
|
|
using namespace CPlusPlus;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
UsingNamespaceDirective::UsingNamespaceDirective(TranslationUnit *translationUnit,
|
2009-12-01 12:46:15 +01:00
|
|
|
unsigned sourceLocation, const Name *name)
|
2008-12-02 12:01:29 +01:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
UsingNamespaceDirective::~UsingNamespaceDirective()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
FullySpecifiedType UsingNamespaceDirective::type() const
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
|
|
void UsingNamespaceDirective::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2010-05-05 10:18:11 +02:00
|
|
|
NamespaceAlias::NamespaceAlias(TranslationUnit *translationUnit,
|
|
|
|
unsigned sourceLocation, const Name *name)
|
|
|
|
: Symbol(translationUnit, sourceLocation, name), _namespaceName(0)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NamespaceAlias::~NamespaceAlias()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
const Name *NamespaceAlias::namespaceName() const
|
|
|
|
{ return _namespaceName; }
|
|
|
|
|
|
|
|
void NamespaceAlias::setNamespaceName(const Name *namespaceName)
|
|
|
|
{ _namespaceName = namespaceName; }
|
|
|
|
|
|
|
|
FullySpecifiedType NamespaceAlias::type() const
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
|
|
void NamespaceAlias::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
UsingDeclaration::UsingDeclaration(TranslationUnit *translationUnit,
|
2009-12-01 12:46:15 +01:00
|
|
|
unsigned sourceLocation, const Name *name)
|
2008-12-02 12:01:29 +01:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
UsingDeclaration::~UsingDeclaration()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
FullySpecifiedType UsingDeclaration::type() const
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
|
|
void UsingDeclaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
Declaration::Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
2010-08-11 12:47:28 +02:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
Declaration::~Declaration()
|
2010-08-11 12:47:28 +02:00
|
|
|
{ }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-11-17 14:37:45 +01:00
|
|
|
void Declaration::setType(const FullySpecifiedType &type)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ _type = type; }
|
|
|
|
|
|
|
|
FullySpecifiedType Declaration::type() const
|
|
|
|
{ return _type; }
|
|
|
|
|
|
|
|
void Declaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
Argument::Argument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
2008-12-02 12:01:29 +01:00
|
|
|
: Symbol(translationUnit, sourceLocation, name),
|
2009-12-08 11:34:22 +01:00
|
|
|
_initializer(0)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
Argument::~Argument()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
bool Argument::hasInitializer() const
|
2009-12-08 11:34:22 +01:00
|
|
|
{ return _initializer != 0; }
|
|
|
|
|
|
|
|
const StringLiteral *Argument::initializer() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{ return _initializer; }
|
|
|
|
|
2009-12-08 11:34:22 +01:00
|
|
|
void Argument::setInitializer(const StringLiteral *initializer)
|
|
|
|
{ _initializer = initializer; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-11-17 14:37:45 +01:00
|
|
|
void Argument::setType(const FullySpecifiedType &type)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ _type = type; }
|
|
|
|
|
|
|
|
FullySpecifiedType Argument::type() const
|
|
|
|
{ return _type; }
|
|
|
|
|
|
|
|
void Argument::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-12-08 11:58:27 +01:00
|
|
|
TypenameArgument::TypenameArgument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
TypenameArgument::~TypenameArgument()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void TypenameArgument::setType(const FullySpecifiedType &type)
|
|
|
|
{ _type = type; }
|
|
|
|
|
|
|
|
FullySpecifiedType TypenameArgument::type() const
|
|
|
|
{ return _type; }
|
|
|
|
|
|
|
|
void TypenameArgument::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
Function::Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
2010-08-11 12:26:02 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, name),
|
2010-08-05 17:02:25 +02:00
|
|
|
_flags(0)
|
|
|
|
{ }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
Function::~Function()
|
2010-08-11 12:47:28 +02:00
|
|
|
{ }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
bool Function::isNormal() const
|
2009-07-27 21:47:03 +02:00
|
|
|
{ return f._methodKey == NormalMethod; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
bool Function::isSignal() const
|
2009-07-27 21:47:03 +02:00
|
|
|
{ return f._methodKey == SignalMethod; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
bool Function::isSlot() const
|
2009-07-27 21:47:03 +02:00
|
|
|
{ return f._methodKey == SlotMethod; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-04-23 09:42:22 +02:00
|
|
|
bool Function::isInvokable() const
|
|
|
|
{ return f._methodKey == InvokableMethod; }
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
int Function::methodKey() const
|
2009-07-27 21:47:03 +02:00
|
|
|
{ return f._methodKey; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
void Function::setMethodKey(int key)
|
2009-07-27 21:47:03 +02:00
|
|
|
{ f._methodKey = key; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
bool Function::isEqualTo(const Type *other) const
|
|
|
|
{
|
2009-02-09 17:44:06 +01:00
|
|
|
const Function *o = other->asFunctionType();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (! o)
|
|
|
|
return false;
|
2009-05-19 12:15:30 +02:00
|
|
|
else if (isConst() != o->isConst())
|
|
|
|
return false;
|
|
|
|
else if (isVolatile() != o->isVolatile())
|
|
|
|
return false;
|
2010-01-19 15:26:08 +10:00
|
|
|
#ifdef ICHECK_BUILD
|
2010-02-03 13:21:08 +10:00
|
|
|
else if (isInvokable() != o->isInvokable())
|
|
|
|
return false;
|
|
|
|
else if (isSignal() != o->isSignal())
|
2010-01-19 15:26:08 +10:00
|
|
|
return false;
|
|
|
|
#endif
|
2009-05-19 12:15:30 +02:00
|
|
|
|
2010-08-26 12:23:09 +02:00
|
|
|
const Name *l = unqualifiedName();
|
|
|
|
const Name *r = o->unqualifiedName();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (l == r || (l && l->isEqualTo(r))) {
|
2010-08-05 17:02:25 +02:00
|
|
|
if (argumentCount() != o->argumentCount())
|
2008-12-02 12:01:29 +01:00
|
|
|
return false;
|
|
|
|
else if (! _returnType.isEqualTo(o->_returnType))
|
|
|
|
return false;
|
2010-08-05 17:02:25 +02:00
|
|
|
for (unsigned i = 0; i < argumentCount(); ++i) {
|
|
|
|
Symbol *l = argumentAt(i);
|
|
|
|
Symbol *r = o->argumentAt(i);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (! l->type().isEqualTo(r->type()))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-01-19 15:26:08 +10:00
|
|
|
#ifdef ICHECK_BUILD
|
|
|
|
bool Function::isEqualTo(const Function* fct, bool ignoreName/* = false*/) const
|
|
|
|
{
|
|
|
|
if(!ignoreName)
|
|
|
|
return isEqualTo((Type*)fct);
|
|
|
|
|
|
|
|
if (! fct)
|
|
|
|
return false;
|
|
|
|
else if (isConst() != fct->isConst())
|
|
|
|
return false;
|
|
|
|
else if (isVolatile() != fct->isVolatile())
|
|
|
|
return false;
|
|
|
|
else if (isInvokable() != fct->isInvokable())
|
|
|
|
return false;
|
2010-02-03 13:21:08 +10:00
|
|
|
else if (isSignal() != fct->isSignal())
|
|
|
|
return false;
|
2010-01-19 15:26:08 +10:00
|
|
|
|
|
|
|
if (_arguments->symbolCount() != fct->_arguments->symbolCount())
|
|
|
|
return false;
|
|
|
|
else if (! _returnType.isEqualTo(fct->_returnType))
|
|
|
|
return false;
|
|
|
|
for (unsigned i = 0; i < _arguments->symbolCount(); ++i) {
|
|
|
|
Symbol *l = _arguments->symbolAt(i);
|
|
|
|
Symbol *r = fct->_arguments->symbolAt(i);
|
|
|
|
if (! l->type().isEqualTo(r->type()))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Function::accept0(TypeVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-11-23 11:56:44 +01:00
|
|
|
bool Function::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
|
|
|
{
|
|
|
|
if (const Function *otherTy = otherType->asFunctionType())
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
FullySpecifiedType Function::type() const
|
2010-04-19 09:40:38 +02:00
|
|
|
{
|
|
|
|
FullySpecifiedType ty(const_cast<Function *>(this));
|
|
|
|
ty.setConst(isConst());
|
|
|
|
ty.setVolatile(isVolatile());
|
|
|
|
return ty;
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
FullySpecifiedType Function::returnType() const
|
|
|
|
{ return _returnType; }
|
|
|
|
|
2009-11-17 14:37:45 +01:00
|
|
|
void Function::setReturnType(const FullySpecifiedType &returnType)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ _returnType = returnType; }
|
|
|
|
|
2009-03-26 16:43:38 +01:00
|
|
|
bool Function::hasReturnType() const
|
|
|
|
{
|
|
|
|
const FullySpecifiedType ty = returnType();
|
|
|
|
return ty.isValid() || ty.isSigned() || ty.isUnsigned();
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
unsigned Function::argumentCount() const
|
|
|
|
{
|
2010-08-16 11:13:20 +02:00
|
|
|
const unsigned c = memberCount();
|
|
|
|
if (c > 0 && memberAt(c - 1)->isBlock())
|
|
|
|
return c - 1;
|
|
|
|
return c;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Symbol *Function::argumentAt(unsigned index) const
|
2010-08-05 17:02:25 +02:00
|
|
|
{ return memberAt(index); }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-03-26 16:43:38 +01:00
|
|
|
bool Function::hasArguments() const
|
|
|
|
{
|
|
|
|
return ! (argumentCount() == 0 ||
|
|
|
|
(argumentCount() == 1 && argumentAt(0)->type()->isVoidType()));
|
|
|
|
}
|
|
|
|
|
2010-08-03 17:34:51 +02:00
|
|
|
unsigned Function::minimumArgumentCount() const
|
|
|
|
{
|
|
|
|
unsigned index = 0;
|
|
|
|
|
2010-08-05 17:02:25 +02:00
|
|
|
for (; index < argumentCount(); ++index) {
|
|
|
|
if (Argument *arg = argumentAt(index)->asArgument()) {
|
2010-08-03 17:34:51 +02:00
|
|
|
if (arg->hasInitializer())
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2009-09-25 13:45:13 +02:00
|
|
|
bool Function::isVirtual() const
|
|
|
|
{ return f._isVirtual; }
|
|
|
|
|
|
|
|
void Function::setVirtual(bool isVirtual)
|
|
|
|
{ f._isVirtual = isVirtual; }
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
bool Function::isVariadic() const
|
2009-07-27 21:47:03 +02:00
|
|
|
{ return f._isVariadic; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
void Function::setVariadic(bool isVariadic)
|
2009-07-27 21:47:03 +02:00
|
|
|
{ f._isVariadic = isVariadic; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
bool Function::isConst() const
|
2009-07-27 21:47:03 +02:00
|
|
|
{ return f._isConst; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
void Function::setConst(bool isConst)
|
2009-07-27 21:47:03 +02:00
|
|
|
{ f._isConst = isConst; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
bool Function::isVolatile() const
|
2009-07-27 21:47:03 +02:00
|
|
|
{ return f._isVolatile; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
void Function::setVolatile(bool isVolatile)
|
2009-07-27 21:47:03 +02:00
|
|
|
{ f._isVolatile = isVolatile; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
bool Function::isPureVirtual() const
|
2009-07-27 21:47:03 +02:00
|
|
|
{ return f._isPureVirtual; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
void Function::setPureVirtual(bool isPureVirtual)
|
2009-07-27 21:47:03 +02:00
|
|
|
{ f._isPureVirtual = isPureVirtual; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-03-17 14:46:35 +01:00
|
|
|
bool Function::isAmbiguous() const
|
2009-07-27 21:47:03 +02:00
|
|
|
{ return f._isAmbiguous; }
|
2009-03-17 14:46:35 +01:00
|
|
|
|
|
|
|
void Function::setAmbiguous(bool isAmbiguous)
|
2009-07-27 21:47:03 +02:00
|
|
|
{ f._isAmbiguous = isAmbiguous; }
|
2009-03-17 14:46:35 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Function::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{
|
|
|
|
if (visitor->visit(this)) {
|
|
|
|
for (unsigned i = 0; i < memberCount(); ++i) {
|
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Block::Block(TranslationUnit *translationUnit, unsigned sourceLocation)
|
2010-08-11 12:26:02 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, /*name = */ 0)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
Block::~Block()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
FullySpecifiedType Block::type() const
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
|
|
void Block::visitSymbol0(SymbolVisitor *visitor)
|
2009-06-25 11:02:02 +02:00
|
|
|
{
|
|
|
|
if (visitor->visit(this)) {
|
|
|
|
for (unsigned i = 0; i < memberCount(); ++i) {
|
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
Enum::Enum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
2010-08-11 12:26:02 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, name)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
Enum::~Enum()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
FullySpecifiedType Enum::type() const
|
|
|
|
{ return FullySpecifiedType(const_cast<Enum *>(this)); }
|
|
|
|
|
|
|
|
bool Enum::isEqualTo(const Type *other) const
|
|
|
|
{
|
2009-02-09 17:44:06 +01:00
|
|
|
const Enum *o = other->asEnumType();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (! o)
|
|
|
|
return false;
|
2010-08-26 12:23:09 +02:00
|
|
|
const Name *l = unqualifiedName();
|
|
|
|
const Name *r = o->unqualifiedName();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (l == r)
|
|
|
|
return true;
|
|
|
|
else if (! l)
|
|
|
|
return false;
|
|
|
|
return l->isEqualTo(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Enum::accept0(TypeVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-11-23 11:56:44 +01:00
|
|
|
bool Enum::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
|
|
|
{
|
|
|
|
if (const Enum *otherTy = otherType->asEnumType())
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Enum::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{
|
|
|
|
if (visitor->visit(this)) {
|
|
|
|
for (unsigned i = 0; i < memberCount(); ++i) {
|
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-11 13:46:32 +02:00
|
|
|
Template::Template(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
|
|
|
: Scope(translationUnit, sourceLocation, name)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
Template::~Template()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
unsigned Template::templateParameterCount() const
|
|
|
|
{
|
|
|
|
if (declaration() != 0)
|
|
|
|
return memberCount() - 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Symbol *Template::templateParameterAt(unsigned index) const
|
|
|
|
{ return memberAt(index); }
|
|
|
|
|
|
|
|
Symbol *Template::declaration() const
|
|
|
|
{
|
|
|
|
if (isEmpty())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (Symbol *s = memberAt(memberCount() - 1)) {
|
|
|
|
if (s->isClass() || s->isForwardClassDeclaration() ||
|
|
|
|
s->isTemplate() || s->isFunction() || s->isDeclaration())
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
FullySpecifiedType Template::type() const
|
|
|
|
{ return FullySpecifiedType(const_cast<Template *>(this)); }
|
|
|
|
|
|
|
|
bool Template::isEqualTo(const Type *other) const
|
|
|
|
{ return other == this; }
|
|
|
|
|
|
|
|
void Template::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{
|
|
|
|
if (visitor->visit(this)) {
|
|
|
|
for (unsigned i = 0; i < memberCount(); ++i) {
|
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Template::accept0(TypeVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
|
|
bool Template::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
|
|
|
{
|
|
|
|
if (const Template *otherTy = otherType->asTemplateType())
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
Namespace::Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
2010-08-11 12:26:02 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, name)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
Namespace::~Namespace()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
bool Namespace::isEqualTo(const Type *other) const
|
|
|
|
{
|
2009-02-09 17:44:06 +01:00
|
|
|
const Namespace *o = other->asNamespaceType();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (! o)
|
|
|
|
return false;
|
2010-08-26 12:23:09 +02:00
|
|
|
const Name *l = unqualifiedName();
|
|
|
|
const Name *r = o->unqualifiedName();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (l == r || (l && l->isEqualTo(r)))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Namespace::accept0(TypeVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-11-23 11:56:44 +01:00
|
|
|
bool Namespace::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
|
|
|
{
|
|
|
|
if (const Namespace *otherTy = otherType->asNamespaceType())
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Namespace::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{
|
|
|
|
if (visitor->visit(this)) {
|
|
|
|
for (unsigned i = 0; i < memberCount(); ++i) {
|
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FullySpecifiedType Namespace::type() const
|
|
|
|
{ return FullySpecifiedType(const_cast<Namespace *>(this)); }
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
BaseClass::BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
2008-12-02 12:01:29 +01:00
|
|
|
: Symbol(translationUnit, sourceLocation, name),
|
|
|
|
_isVirtual(false)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
BaseClass::~BaseClass()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
FullySpecifiedType BaseClass::type() const
|
2010-01-06 11:23:41 +01:00
|
|
|
{ return _type; }
|
|
|
|
|
|
|
|
void BaseClass::setType(const FullySpecifiedType &type)
|
|
|
|
{ _type = type; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
bool BaseClass::isVirtual() const
|
|
|
|
{ return _isVirtual; }
|
|
|
|
|
|
|
|
void BaseClass::setVirtual(bool isVirtual)
|
|
|
|
{ _isVirtual = isVirtual; }
|
|
|
|
|
|
|
|
void BaseClass::visitSymbol0(SymbolVisitor *visitor)
|
2009-02-16 15:43:24 +01:00
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
|
|
ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit,
|
2009-12-01 12:46:15 +01:00
|
|
|
unsigned sourceLocation, const Name *name)
|
2010-08-11 12:47:28 +02:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
2009-02-16 15:43:24 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
ForwardClassDeclaration::~ForwardClassDeclaration()
|
2010-08-11 12:47:28 +02:00
|
|
|
{ }
|
2009-02-16 15:43:24 +01:00
|
|
|
|
|
|
|
FullySpecifiedType ForwardClassDeclaration::type() const
|
|
|
|
{ return FullySpecifiedType(const_cast<ForwardClassDeclaration *>(this)); }
|
|
|
|
|
|
|
|
bool ForwardClassDeclaration::isEqualTo(const Type *other) const
|
|
|
|
{
|
|
|
|
if (const ForwardClassDeclaration *otherClassFwdTy = other->asForwardClassDeclarationType()) {
|
|
|
|
if (name() == otherClassFwdTy->name())
|
|
|
|
return true;
|
|
|
|
else if (name() && otherClassFwdTy->name())
|
|
|
|
return name()->isEqualTo(otherClassFwdTy->name());
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForwardClassDeclaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
|
|
void ForwardClassDeclaration::accept0(TypeVisitor *visitor)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-11-23 11:56:44 +01:00
|
|
|
bool ForwardClassDeclaration::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
|
|
|
{
|
|
|
|
if (const ForwardClassDeclaration *otherTy = otherType->asForwardClassDeclarationType())
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
Class::Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
2010-08-11 12:26:02 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, name),
|
2010-08-11 12:47:28 +02:00
|
|
|
_key(ClassKey)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
Class::~Class()
|
2010-08-11 12:47:28 +02:00
|
|
|
{ }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
bool Class::isClass() const
|
|
|
|
{ return _key == ClassKey; }
|
|
|
|
|
|
|
|
bool Class::isStruct() const
|
|
|
|
{ return _key == StructKey; }
|
|
|
|
|
|
|
|
bool Class::isUnion() const
|
|
|
|
{ return _key == UnionKey; }
|
|
|
|
|
|
|
|
Class::Key Class::classKey() const
|
|
|
|
{ return _key; }
|
|
|
|
|
|
|
|
void Class::setClassKey(Key key)
|
|
|
|
{ _key = key; }
|
|
|
|
|
|
|
|
void Class::accept0(TypeVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-11-23 11:56:44 +01:00
|
|
|
bool Class::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
|
|
|
{
|
|
|
|
if (const Class *otherTy = otherType->asClassType())
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
unsigned Class::baseClassCount() const
|
2010-03-18 15:21:07 +01:00
|
|
|
{ return _baseClasses.size(); }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
BaseClass *Class::baseClassAt(unsigned index) const
|
|
|
|
{ return _baseClasses.at(index); }
|
|
|
|
|
|
|
|
void Class::addBaseClass(BaseClass *baseClass)
|
|
|
|
{ _baseClasses.push_back(baseClass); }
|
|
|
|
|
|
|
|
FullySpecifiedType Class::type() const
|
|
|
|
{ return FullySpecifiedType(const_cast<Class *>(this)); }
|
|
|
|
|
|
|
|
bool Class::isEqualTo(const Type *other) const
|
|
|
|
{
|
2009-02-09 17:44:06 +01:00
|
|
|
const Class *o = other->asClassType();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (! o)
|
|
|
|
return false;
|
2010-08-26 12:23:09 +02:00
|
|
|
const Name *l = unqualifiedName();
|
|
|
|
const Name *r = o->unqualifiedName();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (l == r || (l && l->isEqualTo(r)))
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Class::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{
|
|
|
|
if (visitor->visit(this)) {
|
|
|
|
for (unsigned i = 0; i < _baseClasses.size(); ++i) {
|
|
|
|
visitSymbol(_baseClasses.at(i), visitor);
|
|
|
|
}
|
|
|
|
for (unsigned i = 0; i < memberCount(); ++i) {
|
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
ObjCBaseClass::ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
2009-10-05 18:02:01 +02:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
ObjCBaseClass::~ObjCBaseClass()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
FullySpecifiedType ObjCBaseClass::type() const
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
|
|
void ObjCBaseClass::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
ObjCBaseProtocol::ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
2009-10-05 18:02:01 +02:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
ObjCBaseProtocol::~ObjCBaseProtocol()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
FullySpecifiedType ObjCBaseProtocol::type() const
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
|
|
void ObjCBaseProtocol::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
ObjCClass::ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name):
|
2010-08-11 12:26:02 +02:00
|
|
|
Scope(translationUnit, sourceLocation, name),
|
2009-10-21 17:03:18 +02:00
|
|
|
_isInterface(false),
|
2009-09-28 11:46:00 +02:00
|
|
|
_categoryName(0),
|
|
|
|
_baseClass(0)
|
2009-07-28 16:34:15 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjCClass::~ObjCClass()
|
|
|
|
{}
|
|
|
|
|
2010-03-30 15:35:42 +02:00
|
|
|
bool ObjCClass::isInterface() const
|
|
|
|
{ return _isInterface; }
|
|
|
|
|
|
|
|
void ObjCClass::setInterface(bool isInterface)
|
|
|
|
{ _isInterface = isInterface; }
|
|
|
|
|
|
|
|
bool ObjCClass::isCategory() const
|
|
|
|
{ return _categoryName != 0; }
|
|
|
|
|
|
|
|
const Name *ObjCClass::categoryName() const
|
|
|
|
{ return _categoryName; }
|
|
|
|
|
|
|
|
void ObjCClass::setCategoryName(const Name *categoryName)
|
|
|
|
{ _categoryName = categoryName; }
|
|
|
|
|
|
|
|
ObjCBaseClass *ObjCClass::baseClass() const
|
|
|
|
{ return _baseClass; }
|
|
|
|
|
|
|
|
void ObjCClass::setBaseClass(ObjCBaseClass *baseClass)
|
|
|
|
{ _baseClass = baseClass; }
|
|
|
|
|
|
|
|
unsigned ObjCClass::protocolCount() const
|
|
|
|
{ return _protocols.size(); }
|
|
|
|
|
|
|
|
ObjCBaseProtocol *ObjCClass::protocolAt(unsigned index) const
|
|
|
|
{ return _protocols.at(index); }
|
|
|
|
|
|
|
|
void ObjCClass::addProtocol(ObjCBaseProtocol *protocol)
|
|
|
|
{ _protocols.push_back(protocol); }
|
|
|
|
|
2009-07-28 16:34:15 +02:00
|
|
|
FullySpecifiedType ObjCClass::type() const
|
|
|
|
{ return FullySpecifiedType(const_cast<ObjCClass *>(this)); }
|
|
|
|
|
|
|
|
bool ObjCClass::isEqualTo(const Type *other) const
|
|
|
|
{
|
|
|
|
const ObjCClass *o = other->asObjCClassType();
|
|
|
|
if (!o)
|
|
|
|
return false;
|
|
|
|
|
2010-08-26 12:23:09 +02:00
|
|
|
const Name *l = unqualifiedName();
|
|
|
|
const Name *r = o->unqualifiedName();
|
2009-07-28 16:34:15 +02:00
|
|
|
if (l == r || (l && l->isEqualTo(r)))
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjCClass::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{
|
|
|
|
if (visitor->visit(this)) {
|
2009-09-28 11:46:00 +02:00
|
|
|
if (_baseClass)
|
|
|
|
visitSymbol(_baseClass, visitor);
|
|
|
|
|
2009-07-28 16:34:15 +02:00
|
|
|
for (unsigned i = 0; i < _protocols.size(); ++i)
|
|
|
|
visitSymbol(_protocols.at(i), visitor);
|
2009-09-28 11:46:00 +02:00
|
|
|
|
|
|
|
for (unsigned i = 0; i < memberCount(); ++i)
|
|
|
|
visitSymbol(memberAt(i), visitor);
|
2009-07-28 16:34:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjCClass::accept0(TypeVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-11-23 11:56:44 +01:00
|
|
|
bool ObjCClass::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
|
|
|
{
|
|
|
|
if (const ObjCClass *otherTy = otherType->asObjCClassType())
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
ObjCProtocol::ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name):
|
2010-08-11 12:26:02 +02:00
|
|
|
Scope(translationUnit, sourceLocation, name)
|
2009-07-28 16:34:15 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjCProtocol::~ObjCProtocol()
|
|
|
|
{}
|
|
|
|
|
2010-03-30 15:35:42 +02:00
|
|
|
unsigned ObjCProtocol::protocolCount() const
|
|
|
|
{ return _protocols.size(); }
|
|
|
|
|
|
|
|
ObjCBaseProtocol *ObjCProtocol::protocolAt(unsigned index) const
|
|
|
|
{ return _protocols.at(index); }
|
|
|
|
|
|
|
|
void ObjCProtocol::addProtocol(ObjCBaseProtocol *protocol)
|
|
|
|
{ _protocols.push_back(protocol); }
|
|
|
|
|
2009-07-28 16:34:15 +02:00
|
|
|
FullySpecifiedType ObjCProtocol::type() const
|
|
|
|
{ return FullySpecifiedType(const_cast<ObjCProtocol *>(this)); }
|
|
|
|
|
|
|
|
bool ObjCProtocol::isEqualTo(const Type *other) const
|
|
|
|
{
|
|
|
|
const ObjCProtocol *o = other->asObjCProtocolType();
|
|
|
|
if (!o)
|
|
|
|
return false;
|
|
|
|
|
2010-08-26 12:23:09 +02:00
|
|
|
const Name *l = unqualifiedName();
|
|
|
|
const Name *r = o->unqualifiedName();
|
2009-07-28 16:34:15 +02:00
|
|
|
if (l == r || (l && l->isEqualTo(r)))
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjCProtocol::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{
|
|
|
|
if (visitor->visit(this)) {
|
|
|
|
for (unsigned i = 0; i < _protocols.size(); ++i)
|
|
|
|
visitSymbol(_protocols.at(i), visitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjCProtocol::accept0(TypeVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-11-23 11:56:44 +01:00
|
|
|
bool ObjCProtocol::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
|
|
|
{
|
|
|
|
if (const ObjCProtocol *otherTy = otherType->asObjCProtocolType())
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation,
|
|
|
|
const Name *name):
|
2009-07-28 16:34:15 +02:00
|
|
|
Symbol(translationUnit, sourceLocation, name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjCForwardClassDeclaration::~ObjCForwardClassDeclaration()
|
|
|
|
{}
|
|
|
|
|
|
|
|
FullySpecifiedType ObjCForwardClassDeclaration::type() const
|
2009-08-05 17:14:08 +02:00
|
|
|
{ return FullySpecifiedType(); }
|
2009-07-28 16:34:15 +02:00
|
|
|
|
2009-09-28 11:46:00 +02:00
|
|
|
bool ObjCForwardClassDeclaration::isEqualTo(const Type *other) const
|
|
|
|
{
|
|
|
|
if (const ObjCForwardClassDeclaration *otherFwdClass = other->asObjCForwardClassDeclarationType()) {
|
|
|
|
if (name() == otherFwdClass->name())
|
|
|
|
return true;
|
|
|
|
else if (name() && otherFwdClass->name())
|
|
|
|
return name()->isEqualTo(otherFwdClass->name());
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-28 16:34:15 +02:00
|
|
|
void ObjCForwardClassDeclaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-09-28 11:46:00 +02:00
|
|
|
void ObjCForwardClassDeclaration::accept0(TypeVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-11-23 11:56:44 +01:00
|
|
|
bool ObjCForwardClassDeclaration::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
|
|
|
{
|
|
|
|
if (const ObjCForwardClassDeclaration *otherTy = otherType->asObjCForwardClassDeclarationType())
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation,
|
|
|
|
const Name *name):
|
2009-07-28 16:34:15 +02:00
|
|
|
Symbol(translationUnit, sourceLocation, name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjCForwardProtocolDeclaration::~ObjCForwardProtocolDeclaration()
|
|
|
|
{}
|
|
|
|
|
|
|
|
FullySpecifiedType ObjCForwardProtocolDeclaration::type() const
|
2009-08-05 17:14:08 +02:00
|
|
|
{ return FullySpecifiedType(); }
|
2009-07-28 16:34:15 +02:00
|
|
|
|
2009-09-28 11:46:00 +02:00
|
|
|
bool ObjCForwardProtocolDeclaration::isEqualTo(const Type *other) const
|
|
|
|
{
|
|
|
|
if (const ObjCForwardProtocolDeclaration *otherFwdProtocol = other->asObjCForwardProtocolDeclarationType()) {
|
|
|
|
if (name() == otherFwdProtocol->name())
|
|
|
|
return true;
|
|
|
|
else if (name() && otherFwdProtocol->name())
|
|
|
|
return name()->isEqualTo(otherFwdProtocol->name());
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-28 16:34:15 +02:00
|
|
|
void ObjCForwardProtocolDeclaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-09-28 11:46:00 +02:00
|
|
|
void ObjCForwardProtocolDeclaration::accept0(TypeVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-11-23 11:56:44 +01:00
|
|
|
bool ObjCForwardProtocolDeclaration::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
|
|
|
{
|
|
|
|
if (const ObjCForwardProtocolDeclaration *otherTy = otherType->asObjCForwardProtocolDeclarationType())
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-01 12:46:15 +01:00
|
|
|
ObjCMethod::ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
2010-08-11 12:26:02 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, name),
|
2009-08-05 18:30:18 +02:00
|
|
|
_flags(0)
|
2010-08-11 12:26:02 +02:00
|
|
|
{ }
|
2009-08-05 18:30:18 +02:00
|
|
|
|
|
|
|
ObjCMethod::~ObjCMethod()
|
2010-08-11 12:26:02 +02:00
|
|
|
{ }
|
2009-08-05 18:30:18 +02:00
|
|
|
|
|
|
|
bool ObjCMethod::isEqualTo(const Type *other) const
|
|
|
|
{
|
|
|
|
const ObjCMethod *o = other->asObjCMethodType();
|
|
|
|
if (! o)
|
|
|
|
return false;
|
|
|
|
|
2010-08-26 12:23:09 +02:00
|
|
|
const Name *l = unqualifiedName();
|
|
|
|
const Name *r = o->unqualifiedName();
|
2009-08-05 18:30:18 +02:00
|
|
|
if (l == r || (l && l->isEqualTo(r))) {
|
2010-08-11 12:26:02 +02:00
|
|
|
if (argumentCount() != o->argumentCount())
|
2009-08-05 18:30:18 +02:00
|
|
|
return false;
|
|
|
|
else if (! _returnType.isEqualTo(o->_returnType))
|
|
|
|
return false;
|
2010-08-11 12:26:02 +02:00
|
|
|
for (unsigned i = 0; i < argumentCount(); ++i) {
|
|
|
|
Symbol *l = argumentAt(i);
|
|
|
|
Symbol *r = o->argumentAt(i);
|
2009-08-05 18:30:18 +02:00
|
|
|
if (! l->type().isEqualTo(r->type()))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ObjCMethod::accept0(TypeVisitor *visitor)
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
2009-11-23 11:56:44 +01:00
|
|
|
bool ObjCMethod::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
|
|
|
{
|
|
|
|
if (const ObjCMethod *otherTy = otherType->asObjCMethodType())
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-05 18:30:18 +02:00
|
|
|
FullySpecifiedType ObjCMethod::type() const
|
|
|
|
{ return FullySpecifiedType(const_cast<ObjCMethod *>(this)); }
|
|
|
|
|
|
|
|
FullySpecifiedType ObjCMethod::returnType() const
|
|
|
|
{ return _returnType; }
|
|
|
|
|
2009-11-17 14:37:45 +01:00
|
|
|
void ObjCMethod::setReturnType(const FullySpecifiedType &returnType)
|
2009-08-05 18:30:18 +02:00
|
|
|
{ _returnType = returnType; }
|
|
|
|
|
|
|
|
bool ObjCMethod::hasReturnType() const
|
|
|
|
{
|
|
|
|
const FullySpecifiedType ty = returnType();
|
|
|
|
return ty.isValid() || ty.isSigned() || ty.isUnsigned();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned ObjCMethod::argumentCount() const
|
|
|
|
{
|
2010-08-16 11:31:53 +02:00
|
|
|
const unsigned c = memberCount();
|
|
|
|
if (c > 0 && memberAt(c - 1)->isBlock())
|
|
|
|
return c - 1;
|
|
|
|
return c;
|
2009-08-05 18:30:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Symbol *ObjCMethod::argumentAt(unsigned index) const
|
2010-08-11 12:26:02 +02:00
|
|
|
{
|
|
|
|
return memberAt(index);
|
|
|
|
}
|
2009-08-05 18:30:18 +02:00
|
|
|
|
|
|
|
bool ObjCMethod::hasArguments() const
|
|
|
|
{
|
|
|
|
return ! (argumentCount() == 0 ||
|
|
|
|
(argumentCount() == 1 && argumentAt(0)->type()->isVoidType()));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ObjCMethod::isVariadic() const
|
|
|
|
{ return f._isVariadic; }
|
|
|
|
|
|
|
|
void ObjCMethod::setVariadic(bool isVariadic)
|
|
|
|
{ f._isVariadic = isVariadic; }
|
|
|
|
|
|
|
|
void ObjCMethod::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{
|
|
|
|
if (visitor->visit(this)) {
|
|
|
|
for (unsigned i = 0; i < memberCount(); ++i) {
|
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-11 09:32:05 +01:00
|
|
|
ObjCPropertyDeclaration::ObjCPropertyDeclaration(TranslationUnit *translationUnit,
|
|
|
|
unsigned sourceLocation,
|
2009-12-01 12:46:15 +01:00
|
|
|
const Name *name):
|
2009-11-11 09:32:05 +01:00
|
|
|
Symbol(translationUnit, sourceLocation, name),
|
|
|
|
_propertyAttributes(None),
|
|
|
|
_getterName(0),
|
|
|
|
_setterName(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
ObjCPropertyDeclaration::~ObjCPropertyDeclaration()
|
|
|
|
{}
|
|
|
|
|
2010-03-30 15:35:42 +02:00
|
|
|
bool ObjCPropertyDeclaration::hasAttribute(int attribute) const
|
|
|
|
{ return _propertyAttributes & attribute; }
|
|
|
|
|
|
|
|
void ObjCPropertyDeclaration::setAttributes(int attributes)
|
|
|
|
{ _propertyAttributes = attributes; }
|
|
|
|
|
|
|
|
bool ObjCPropertyDeclaration::hasGetter() const
|
|
|
|
{ return hasAttribute(Getter); }
|
|
|
|
|
|
|
|
bool ObjCPropertyDeclaration::hasSetter() const
|
|
|
|
{ return hasAttribute(Setter); }
|
|
|
|
|
|
|
|
const Name *ObjCPropertyDeclaration::getterName() const
|
|
|
|
{ return _getterName; }
|
|
|
|
|
|
|
|
void ObjCPropertyDeclaration::setGetterName(const Name *getterName)
|
|
|
|
{ _getterName = getterName; }
|
|
|
|
|
|
|
|
const Name *ObjCPropertyDeclaration::setterName() const
|
|
|
|
{ return _setterName; }
|
|
|
|
|
|
|
|
void ObjCPropertyDeclaration::setSetterName(const Name *setterName)
|
|
|
|
{ _setterName = setterName; }
|
|
|
|
|
|
|
|
void ObjCPropertyDeclaration::setType(const FullySpecifiedType &type)
|
|
|
|
{ _type = type; }
|
|
|
|
|
2009-11-11 09:32:05 +01:00
|
|
|
FullySpecifiedType ObjCPropertyDeclaration::type() const
|
|
|
|
{ return _type; }
|
2009-10-20 11:21:25 +02:00
|
|
|
|
2009-11-11 09:32:05 +01:00
|
|
|
void ObjCPropertyDeclaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
{
|
|
|
|
if (visitor->visit(this)) {
|
|
|
|
}
|
|
|
|
}
|