tools/icheck/parser/src/shared/cplusplus/Symbols.h
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 // Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
       
    42 //
       
    43 // Permission is hereby granted, free of charge, to any person obtaining a copy
       
    44 // of this software and associated documentation files (the "Software"), to deal
       
    45 // in the Software without restriction, including without limitation the rights
       
    46 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       
    47 // copies of the Software, and to permit persons to whom the Software is
       
    48 // furnished to do so, subject to the following conditions:
       
    49 //
       
    50 // The above copyright notice and this permission notice shall be included in
       
    51 // all copies or substantial portions of the Software.
       
    52 //
       
    53 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
       
    54 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
       
    55 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
       
    56 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
       
    57 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
       
    58 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
       
    59 // THE SOFTWARE.
       
    60 
       
    61 #ifndef CPLUSPLUS_SYMBOLS_H
       
    62 #define CPLUSPLUS_SYMBOLS_H
       
    63 
       
    64 #include "CPlusPlusForwardDeclarations.h"
       
    65 #include "Symbol.h"
       
    66 #include "Type.h"
       
    67 #include "FullySpecifiedType.h"
       
    68 #include "Array.h"
       
    69 
       
    70 
       
    71 namespace CPlusPlus {
       
    72 
       
    73 class TemplateParameters
       
    74 {
       
    75 public:
       
    76     TemplateParameters(Scope *scope);
       
    77     TemplateParameters(TemplateParameters *previous, Scope *scope);
       
    78     ~TemplateParameters();
       
    79 
       
    80     TemplateParameters *previous() const;
       
    81     Scope *scope() const;
       
    82 
       
    83 private:
       
    84     TemplateParameters *_previous;
       
    85     Scope *_scope;
       
    86 };
       
    87 
       
    88 class CPLUSPLUS_EXPORT UsingNamespaceDirective: public Symbol
       
    89 {
       
    90 public:
       
    91     UsingNamespaceDirective(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
    92     virtual ~UsingNamespaceDirective();
       
    93 
       
    94     // Symbol's interface
       
    95     virtual FullySpecifiedType type() const;
       
    96 
       
    97     virtual const UsingNamespaceDirective *asUsingNamespaceDirective() const
       
    98     { return this; }
       
    99 
       
   100     virtual UsingNamespaceDirective *asUsingNamespaceDirective()
       
   101     { return this; }
       
   102 
       
   103 protected:
       
   104     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   105 };
       
   106 
       
   107 class CPLUSPLUS_EXPORT UsingDeclaration: public Symbol
       
   108 {
       
   109 public:
       
   110     UsingDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   111     virtual ~UsingDeclaration();
       
   112 
       
   113     // Symbol's interface
       
   114     virtual FullySpecifiedType type() const;
       
   115 
       
   116     virtual const UsingDeclaration *asUsingDeclaration() const
       
   117     { return this; }
       
   118 
       
   119     virtual UsingDeclaration *asUsingDeclaration()
       
   120     { return this; }
       
   121 
       
   122 protected:
       
   123     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   124 };
       
   125 
       
   126 class CPLUSPLUS_EXPORT Declaration: public Symbol
       
   127 {
       
   128 public:
       
   129     Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   130     virtual ~Declaration();
       
   131 
       
   132     TemplateParameters *templateParameters() const;
       
   133     void setTemplateParameters(TemplateParameters *templateParameters);
       
   134 
       
   135     void setType(const FullySpecifiedType &type);
       
   136 
       
   137     // Symbol's interface
       
   138     virtual FullySpecifiedType type() const;
       
   139 
       
   140     virtual const Declaration *asDeclaration() const
       
   141     { return this; }
       
   142 
       
   143     virtual Declaration *asDeclaration()
       
   144     { return this; }
       
   145 
       
   146 protected:
       
   147     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   148 
       
   149 private:
       
   150     FullySpecifiedType _type;
       
   151     TemplateParameters *_templateParameters;
       
   152 };
       
   153 
       
   154 class CPLUSPLUS_EXPORT Argument: public Symbol
       
   155 {
       
   156 public:
       
   157     Argument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   158     virtual ~Argument();
       
   159 
       
   160     void setType(const FullySpecifiedType &type);
       
   161 
       
   162     bool hasInitializer() const;
       
   163 
       
   164     const StringLiteral *initializer() const;
       
   165     void setInitializer(const StringLiteral *initializer);
       
   166 
       
   167     // Symbol's interface
       
   168     virtual FullySpecifiedType type() const;
       
   169 
       
   170     virtual const Argument *asArgument() const
       
   171     { return this; }
       
   172 
       
   173     virtual Argument *asArgument()
       
   174     { return this; }
       
   175 
       
   176 protected:
       
   177     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   178 
       
   179 private:
       
   180     FullySpecifiedType _type;
       
   181     const StringLiteral *_initializer;
       
   182 };
       
   183 
       
   184 class CPLUSPLUS_EXPORT TypenameArgument: public Symbol
       
   185 {
       
   186 public:
       
   187     TypenameArgument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   188     virtual ~TypenameArgument();
       
   189 
       
   190     void setType(const FullySpecifiedType &type);
       
   191 
       
   192     // Symbol's interface
       
   193     virtual FullySpecifiedType type() const;
       
   194 
       
   195     virtual const TypenameArgument *asTypenameArgument() const
       
   196     { return this; }
       
   197 
       
   198     virtual TypenameArgument *asTypenameArgument()
       
   199     { return this; }
       
   200 
       
   201 protected:
       
   202     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   203 
       
   204 private:
       
   205     FullySpecifiedType _type;
       
   206 };
       
   207 
       
   208 class CPLUSPLUS_EXPORT ScopedSymbol: public Symbol
       
   209 {
       
   210 public:
       
   211     ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   212     virtual ~ScopedSymbol();
       
   213 
       
   214     unsigned memberCount() const;
       
   215     Symbol *memberAt(unsigned index) const;
       
   216     Scope *members() const;
       
   217     void addMember(Symbol *member);
       
   218 
       
   219     virtual const ScopedSymbol *asScopedSymbol() const
       
   220     { return this; }
       
   221 
       
   222     virtual ScopedSymbol *asScopedSymbol()
       
   223     { return this; }
       
   224 
       
   225 private:
       
   226     Scope *_members;
       
   227 };
       
   228 
       
   229 class CPLUSPLUS_EXPORT Block: public ScopedSymbol
       
   230 {
       
   231 public:
       
   232     Block(TranslationUnit *translationUnit, unsigned sourceLocation);
       
   233     virtual ~Block();
       
   234 
       
   235     // Symbol's interface
       
   236     virtual FullySpecifiedType type() const;
       
   237 
       
   238     virtual const Block *asBlock() const
       
   239     { return this; }
       
   240 
       
   241     virtual Block *asBlock()
       
   242     { return this; }
       
   243 
       
   244 protected:
       
   245     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   246 };
       
   247 
       
   248 class CPLUSPLUS_EXPORT ForwardClassDeclaration: public Symbol, public Type
       
   249 {
       
   250 public:
       
   251     ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   252     virtual ~ForwardClassDeclaration();
       
   253 
       
   254     TemplateParameters *templateParameters() const;
       
   255     void setTemplateParameters(TemplateParameters *templateParameters);
       
   256 
       
   257     virtual FullySpecifiedType type() const;
       
   258 
       
   259     virtual bool isEqualTo(const Type *other) const;
       
   260 
       
   261     virtual const ForwardClassDeclaration *asForwardClassDeclaration() const
       
   262     { return this; }
       
   263 
       
   264     virtual ForwardClassDeclaration *asForwardClassDeclaration()
       
   265     { return this; }
       
   266 
       
   267     virtual const ForwardClassDeclaration *asForwardClassDeclarationType() const
       
   268     { return this; }
       
   269 
       
   270     virtual ForwardClassDeclaration *asForwardClassDeclarationType()
       
   271     { return this; }
       
   272 
       
   273 protected:
       
   274     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   275     virtual void accept0(TypeVisitor *visitor);
       
   276     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
       
   277 
       
   278 private:
       
   279     TemplateParameters *_templateParameters;
       
   280 };
       
   281 
       
   282 class CPLUSPLUS_EXPORT Enum: public ScopedSymbol, public Type
       
   283 {
       
   284 public:
       
   285     Enum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   286     virtual ~Enum();
       
   287 
       
   288     // Symbol's interface
       
   289     virtual FullySpecifiedType type() const;
       
   290 
       
   291     // Type's interface
       
   292     virtual bool isEqualTo(const Type *other) const;
       
   293 
       
   294     virtual const Enum *asEnum() const
       
   295     { return this; }
       
   296 
       
   297     virtual Enum *asEnum()
       
   298     { return this; }
       
   299 
       
   300     virtual const Enum *asEnumType() const
       
   301     { return this; }
       
   302 
       
   303     virtual Enum *asEnumType()
       
   304     { return this; }
       
   305 
       
   306 protected:
       
   307     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   308     virtual void accept0(TypeVisitor *visitor);
       
   309     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
       
   310 };
       
   311 
       
   312 class CPLUSPLUS_EXPORT Function: public ScopedSymbol, public Type
       
   313 {
       
   314 public:
       
   315     enum MethodKey {
       
   316         NormalMethod,
       
   317         SlotMethod,
       
   318         SignalMethod
       
   319     };
       
   320 
       
   321 public:
       
   322     Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   323     virtual ~Function();
       
   324 
       
   325     bool isNormal() const;
       
   326     bool isSignal() const;
       
   327     bool isSlot() const;
       
   328     int methodKey() const;
       
   329     void setMethodKey(int key);
       
   330 
       
   331     unsigned templateParameterCount() const; // ### remove me
       
   332     Symbol *templateParameterAt(unsigned index) const; // ### remove me
       
   333 
       
   334     TemplateParameters *templateParameters() const;
       
   335     void setTemplateParameters(TemplateParameters *templateParameters);
       
   336 
       
   337     FullySpecifiedType returnType() const;
       
   338     void setReturnType(const FullySpecifiedType &returnType);
       
   339 
       
   340     /** Convenience function that returns whether the function returns something (including void). */
       
   341     bool hasReturnType() const;
       
   342 
       
   343     unsigned argumentCount() const;
       
   344     Symbol *argumentAt(unsigned index) const;
       
   345     Scope *arguments() const;
       
   346 
       
   347     /** Convenience function that returns whether the function receives any arguments. */
       
   348     bool hasArguments() const;
       
   349 
       
   350     bool isVirtual() const;
       
   351     void setVirtual(bool isVirtual);
       
   352 
       
   353     bool isVariadic() const;
       
   354     void setVariadic(bool isVariadic);
       
   355 
       
   356     bool isConst() const;
       
   357     void setConst(bool isConst);
       
   358 
       
   359     bool isVolatile() const;
       
   360     void setVolatile(bool isVolatile);
       
   361 
       
   362     bool isPureVirtual() const;
       
   363     void setPureVirtual(bool isPureVirtual);
       
   364 
       
   365 #ifdef ICHECK_BUILD
       
   366 
       
   367     bool isInvokable() const;
       
   368     void setInvokable(bool isInvokable);
       
   369     bool isEqualTo(const Function* fct, bool ignoreName = false) const;
       
   370 
       
   371 #endif
       
   372 
       
   373     // Symbol's interface
       
   374     virtual FullySpecifiedType type() const;
       
   375 
       
   376     // Type's interface
       
   377     virtual bool isEqualTo(const Type *other) const;
       
   378 
       
   379     virtual const Function *asFunction() const
       
   380     { return this; }
       
   381 
       
   382     virtual Function *asFunction()
       
   383     { return this; }
       
   384 
       
   385     virtual const Function *asFunctionType() const
       
   386     { return this; }
       
   387 
       
   388     virtual Function *asFunctionType()
       
   389     { return this; }
       
   390 
       
   391     bool isAmbiguous() const; // internal
       
   392     void setAmbiguous(bool isAmbiguous); // internal
       
   393 
       
   394 protected:
       
   395     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   396     virtual void accept0(TypeVisitor *visitor);
       
   397     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
       
   398 
       
   399 private:
       
   400     TemplateParameters *_templateParameters;
       
   401     FullySpecifiedType _returnType;
       
   402     struct Flags {
       
   403         unsigned _isVirtual: 1;
       
   404         unsigned _isVariadic: 1;
       
   405         unsigned _isPureVirtual: 1;
       
   406         unsigned _isConst: 1;
       
   407         unsigned _isVolatile: 1;
       
   408         unsigned _isAmbiguous: 1;
       
   409         unsigned _methodKey: 3;
       
   410 #ifdef ICHECK_BUILD
       
   411         unsigned _isInvokable: 1;
       
   412 #endif
       
   413     };
       
   414     union {
       
   415         unsigned _flags;
       
   416         Flags f;
       
   417     };
       
   418     Scope *_arguments;
       
   419 };
       
   420 
       
   421 class CPLUSPLUS_EXPORT Namespace: public ScopedSymbol, public Type
       
   422 {
       
   423 public:
       
   424     Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   425     virtual ~Namespace();
       
   426 
       
   427     // Symbol's interface
       
   428     virtual FullySpecifiedType type() const;
       
   429 
       
   430     // Type's interface
       
   431     virtual bool isEqualTo(const Type *other) const;
       
   432 
       
   433     virtual const Namespace *asNamespace() const
       
   434     { return this; }
       
   435 
       
   436     virtual Namespace *asNamespace()
       
   437     { return this; }
       
   438 
       
   439     virtual const Namespace *asNamespaceType() const
       
   440     { return this; }
       
   441 
       
   442     virtual Namespace *asNamespaceType()
       
   443     { return this; }
       
   444 
       
   445 protected:
       
   446     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   447     virtual void accept0(TypeVisitor *visitor);
       
   448     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
       
   449 };
       
   450 
       
   451 class CPLUSPLUS_EXPORT BaseClass: public Symbol
       
   452 {
       
   453 public:
       
   454     BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   455     virtual ~BaseClass();
       
   456 
       
   457     bool isVirtual() const;
       
   458     void setVirtual(bool isVirtual);
       
   459 
       
   460     // Symbol's interface
       
   461     virtual FullySpecifiedType type() const;
       
   462     void setType(const FullySpecifiedType &type);
       
   463 
       
   464     virtual const BaseClass *asBaseClass() const
       
   465     { return this; }
       
   466 
       
   467     virtual BaseClass *asBaseClass()
       
   468     { return this; }
       
   469 
       
   470 protected:
       
   471     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   472 
       
   473 private:
       
   474     bool _isVirtual;
       
   475     FullySpecifiedType _type;
       
   476 };
       
   477 
       
   478 class CPLUSPLUS_EXPORT Class: public ScopedSymbol, public Type
       
   479 {
       
   480 public:
       
   481     Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   482     virtual ~Class();
       
   483 
       
   484     enum Key {
       
   485         ClassKey,
       
   486         StructKey,
       
   487         UnionKey
       
   488     };
       
   489 
       
   490     bool isClass() const;
       
   491     bool isStruct() const;
       
   492     bool isUnion() const;
       
   493     Key classKey() const;
       
   494     void setClassKey(Key key);
       
   495 
       
   496     unsigned templateParameterCount() const; // ### remove me
       
   497     Symbol *templateParameterAt(unsigned index) const; // ### remove me
       
   498 
       
   499     TemplateParameters *templateParameters() const;
       
   500     void setTemplateParameters(TemplateParameters *templateParameters);
       
   501 
       
   502     unsigned baseClassCount() const;
       
   503     BaseClass *baseClassAt(unsigned index) const;
       
   504     void addBaseClass(BaseClass *baseClass);
       
   505 
       
   506     // Symbol's interface
       
   507     virtual FullySpecifiedType type() const;
       
   508 
       
   509     // Type's interface
       
   510     virtual bool isEqualTo(const Type *other) const;
       
   511 
       
   512     virtual const Class *asClass() const
       
   513     { return this; }
       
   514 
       
   515     virtual Class *asClass()
       
   516     { return this; }
       
   517 
       
   518     virtual const Class *asClassType() const
       
   519     { return this; }
       
   520 
       
   521     virtual Class *asClassType()
       
   522     { return this; }
       
   523 
       
   524 protected:
       
   525     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   526     virtual void accept0(TypeVisitor *visitor);
       
   527     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
       
   528 
       
   529 private:
       
   530     Key _key;
       
   531     TemplateParameters *_templateParameters;
       
   532     Array<BaseClass *> _baseClasses;
       
   533 };
       
   534 
       
   535 class CPLUSPLUS_EXPORT ObjCBaseClass: public Symbol
       
   536 {
       
   537 public:
       
   538     ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   539     virtual ~ObjCBaseClass();
       
   540 
       
   541     // Symbol's interface
       
   542     virtual FullySpecifiedType type() const;
       
   543 
       
   544     virtual const ObjCBaseClass *asObjCBaseClass() const
       
   545     { return this; }
       
   546 
       
   547     virtual ObjCBaseClass *asObjCBaseClass()
       
   548     { return this; }
       
   549 
       
   550 protected:
       
   551     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   552 
       
   553 private:
       
   554 };
       
   555 
       
   556 class CPLUSPLUS_EXPORT ObjCBaseProtocol: public Symbol
       
   557 {
       
   558 public:
       
   559     ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   560     virtual ~ObjCBaseProtocol();
       
   561 
       
   562     // Symbol's interface
       
   563     virtual FullySpecifiedType type() const;
       
   564 
       
   565     virtual const ObjCBaseProtocol *asObjCBaseProtocol() const
       
   566     { return this; }
       
   567 
       
   568     virtual ObjCBaseProtocol *asObjCBaseProtocol()
       
   569     { return this; }
       
   570 
       
   571 protected:
       
   572     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   573 
       
   574 private:
       
   575 };
       
   576 
       
   577 class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration: public Symbol, public Type
       
   578 {
       
   579 public:
       
   580     ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   581     virtual ~ObjCForwardProtocolDeclaration();
       
   582 
       
   583     virtual FullySpecifiedType type() const;
       
   584 
       
   585     virtual bool isEqualTo(const Type *other) const;
       
   586 
       
   587     virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() const
       
   588     { return this; }
       
   589 
       
   590     virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration()
       
   591     { return this; }
       
   592 
       
   593     virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() const
       
   594     { return this; }
       
   595 
       
   596     virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType()
       
   597     { return this; }
       
   598 
       
   599 protected:
       
   600     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   601     virtual void accept0(TypeVisitor *visitor);
       
   602     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
       
   603 
       
   604 private:
       
   605 };
       
   606 
       
   607 class CPLUSPLUS_EXPORT ObjCProtocol: public ScopedSymbol, public Type
       
   608 {
       
   609 public:
       
   610     ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   611     virtual ~ObjCProtocol();
       
   612 
       
   613     unsigned protocolCount() const
       
   614     { return _protocols.count(); }
       
   615 
       
   616     ObjCBaseProtocol *protocolAt(unsigned index) const
       
   617     { return _protocols.at(index); }
       
   618 
       
   619     void addProtocol(ObjCBaseProtocol *protocol)
       
   620     { _protocols.push_back(protocol); }
       
   621 
       
   622     // Symbol's interface
       
   623     virtual FullySpecifiedType type() const;
       
   624 
       
   625     // Type's interface
       
   626     virtual bool isEqualTo(const Type *other) const;
       
   627 
       
   628     virtual const ObjCProtocol *asObjCProtocol() const
       
   629     { return this; }
       
   630 
       
   631     virtual ObjCProtocol *asObjCProtocol()
       
   632     { return this; }
       
   633 
       
   634     virtual const ObjCProtocol *asObjCProtocolType() const
       
   635     { return this; }
       
   636 
       
   637     virtual ObjCProtocol *asObjCProtocolType()
       
   638     { return this; }
       
   639 
       
   640 protected:
       
   641     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   642     virtual void accept0(TypeVisitor *visitor);
       
   643     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
       
   644 
       
   645 private:
       
   646     Array<ObjCBaseProtocol *> _protocols;
       
   647 };
       
   648 
       
   649 class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration: public Symbol, public Type
       
   650 {
       
   651 public:
       
   652     ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   653     virtual ~ObjCForwardClassDeclaration();
       
   654 
       
   655     virtual FullySpecifiedType type() const;
       
   656 
       
   657     virtual bool isEqualTo(const Type *other) const;
       
   658 
       
   659     virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() const
       
   660     { return this; }
       
   661 
       
   662     virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclaration()
       
   663     { return this; }
       
   664 
       
   665     virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() const
       
   666     { return this; }
       
   667 
       
   668     virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType()
       
   669     { return this; }
       
   670 
       
   671 protected:
       
   672     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   673     virtual void accept0(TypeVisitor *visitor);
       
   674     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
       
   675 
       
   676 private:
       
   677 };
       
   678 
       
   679 class CPLUSPLUS_EXPORT ObjCClass: public ScopedSymbol, public Type
       
   680 {
       
   681 public:
       
   682     ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   683     virtual ~ObjCClass();
       
   684 
       
   685     bool isInterface() const { return _isInterface; }
       
   686     void setInterface(bool isInterface) { _isInterface = isInterface; }
       
   687 
       
   688     bool isCategory() const { return _categoryName != 0; }
       
   689     const Name *categoryName() const { return _categoryName; }
       
   690     void setCategoryName(const Name *categoryName) { _categoryName = categoryName; }
       
   691 
       
   692     ObjCBaseClass *baseClass() const
       
   693     { return _baseClass; }
       
   694     void setBaseClass(ObjCBaseClass *baseClass)
       
   695     { _baseClass = baseClass; }
       
   696 
       
   697     unsigned protocolCount() const
       
   698     { return _protocols.count(); }
       
   699 
       
   700     ObjCBaseProtocol *protocolAt(unsigned index) const
       
   701     { return _protocols.at(index); }
       
   702 
       
   703     void addProtocol(ObjCBaseProtocol *protocol)
       
   704     { _protocols.push_back(protocol); }
       
   705 
       
   706     // Symbol's interface
       
   707     virtual FullySpecifiedType type() const;
       
   708 
       
   709     // Type's interface
       
   710     virtual bool isEqualTo(const Type *other) const;
       
   711 
       
   712     virtual const ObjCClass *asObjCClass() const
       
   713     { return this; }
       
   714 
       
   715     virtual ObjCClass *asObjCClass()
       
   716     { return this; }
       
   717 
       
   718     virtual const ObjCClass *asObjCClassType() const
       
   719     { return this; }
       
   720 
       
   721     virtual ObjCClass *asObjCClassType()
       
   722     { return this; }
       
   723 
       
   724 protected:
       
   725     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   726     virtual void accept0(TypeVisitor *visitor);
       
   727     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
       
   728 
       
   729 private:
       
   730     bool _isInterface;
       
   731     const Name *_categoryName;
       
   732     ObjCBaseClass * _baseClass;
       
   733     Array<ObjCBaseProtocol *> _protocols;
       
   734 };
       
   735 
       
   736 class CPLUSPLUS_EXPORT ObjCMethod: public ScopedSymbol, public Type
       
   737 {
       
   738 public:
       
   739     ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
       
   740     virtual ~ObjCMethod();
       
   741 
       
   742     FullySpecifiedType returnType() const;
       
   743     void setReturnType(const FullySpecifiedType &returnType);
       
   744 
       
   745     /** Convenience function that returns whether the function returns something (including void). */
       
   746     bool hasReturnType() const;
       
   747 
       
   748     unsigned argumentCount() const;
       
   749     Symbol *argumentAt(unsigned index) const;
       
   750     Scope *arguments() const;
       
   751 
       
   752     /** Convenience function that returns whether the function receives any arguments. */
       
   753     bool hasArguments() const;
       
   754 
       
   755     bool isVariadic() const;
       
   756     void setVariadic(bool isVariadic);
       
   757 
       
   758     // Symbol's interface
       
   759     virtual FullySpecifiedType type() const;
       
   760 
       
   761     // Type's interface
       
   762     virtual bool isEqualTo(const Type *other) const;
       
   763 
       
   764     virtual const ObjCMethod *asObjCMethod() const
       
   765     { return this; }
       
   766 
       
   767     virtual ObjCMethod *asObjCMethod()
       
   768     { return this; }
       
   769 
       
   770     virtual const ObjCMethod *asObjCMethodType() const
       
   771     { return this; }
       
   772 
       
   773     virtual ObjCMethod *asObjCMethodType()
       
   774     { return this; }
       
   775 
       
   776 protected:
       
   777     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   778     virtual void accept0(TypeVisitor *visitor);
       
   779     virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
       
   780 
       
   781 private:
       
   782     FullySpecifiedType _returnType;
       
   783     struct Flags {
       
   784         unsigned _isVariadic: 1;
       
   785     };
       
   786     union {
       
   787         unsigned _flags;
       
   788         Flags f;
       
   789     };
       
   790     Scope *_arguments;
       
   791 };
       
   792 
       
   793 class CPLUSPLUS_EXPORT ObjCPropertyDeclaration: public Symbol
       
   794 {
       
   795 public:
       
   796     enum PropertyAttributes {
       
   797         None = 0,
       
   798         Assign = 1 << 0,
       
   799         Retain = 1 << 1,
       
   800         Copy = 1 << 2,
       
   801         ReadOnly = 1 << 3,
       
   802         ReadWrite = 1 << 4,
       
   803         Getter = 1 << 5,
       
   804         Setter = 1 << 6,
       
   805         NonAtomic = 1 << 7,
       
   806 
       
   807         WritabilityMask = ReadOnly | ReadWrite,
       
   808         SetterSemanticsMask = Assign | Retain | Copy,
       
   809     };
       
   810 
       
   811 public:
       
   812     ObjCPropertyDeclaration(TranslationUnit *translationUnit,
       
   813                             unsigned sourceLocation,
       
   814                             const Name *name);
       
   815     virtual ~ObjCPropertyDeclaration();
       
   816 
       
   817     bool hasAttribute(int attribute) const
       
   818     { return _propertyAttributes & attribute; }
       
   819 
       
   820     void setAttributes(int attributes)
       
   821     { _propertyAttributes = attributes; }
       
   822 
       
   823     bool hasGetter() const
       
   824     { return hasAttribute(Getter); }
       
   825 
       
   826     bool hasSetter() const
       
   827     { return hasAttribute(Setter); }
       
   828 
       
   829     const Name *getterName() const
       
   830     { return _getterName; }
       
   831 
       
   832     void setGetterName(const Name *getterName)
       
   833     { _getterName = getterName; }
       
   834 
       
   835     const Name *setterName() const
       
   836     { return _setterName; }
       
   837 
       
   838     void setSetterName(const Name *setterName)
       
   839     { _setterName = setterName; }
       
   840 
       
   841     void setType(const FullySpecifiedType &type)
       
   842     { _type = type; }
       
   843 
       
   844     // Symbol's interface
       
   845     virtual FullySpecifiedType type() const;
       
   846 
       
   847     virtual const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const
       
   848     { return this; }
       
   849 
       
   850     virtual ObjCPropertyDeclaration *asObjCPropertyDeclaration()
       
   851     { return this; }
       
   852 
       
   853 protected:
       
   854     virtual void visitSymbol0(SymbolVisitor *visitor);
       
   855 
       
   856 private:
       
   857     FullySpecifiedType _type;
       
   858     int _propertyAttributes;
       
   859     const Name *_getterName;
       
   860     const Name *_setterName;
       
   861 };
       
   862 
       
   863 } // end of namespace CPlusPlus
       
   864 
       
   865 
       
   866 #endif // CPLUSPLUS_SYMBOLS_H