1 // Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com> 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 #pragma once 22 23 #include "CPlusPlusForwardDeclarations.h" 24 25 namespace CPlusPlus { 26 27 class CPLUSPLUS_EXPORT Type 28 { 29 public: 30 Type(); 31 virtual ~Type(); 32 33 bool isUndefinedType() const; 34 bool isVoidType() const; 35 bool isIntegerType() const; 36 bool isFloatType() const; 37 bool isPointerType() const; 38 bool isPointerToMemberType() const; 39 bool isReferenceType() const; 40 bool isArrayType() const; 41 bool isNamedType() const; 42 bool isFunctionType() const; 43 bool isNamespaceType() const; 44 bool isTemplateType() const; 45 bool isClassType() const; 46 bool isEnumType() const; 47 bool isForwardClassDeclarationType() const; 48 bool isObjCClassType() const; 49 bool isObjCProtocolType() const; 50 bool isObjCMethodType() const; 51 bool isObjCForwardClassDeclarationType() const; 52 bool isObjCForwardProtocolDeclarationType() const; 53 asUndefinedType()54 virtual const UndefinedType *asUndefinedType() const { return nullptr; } asVoidType()55 virtual const VoidType *asVoidType() const { return nullptr; } asIntegerType()56 virtual const IntegerType *asIntegerType() const { return nullptr; } asFloatType()57 virtual const FloatType *asFloatType() const { return nullptr; } asPointerType()58 virtual const PointerType *asPointerType() const { return nullptr; } asPointerToMemberType()59 virtual const PointerToMemberType *asPointerToMemberType() const { return nullptr; } asReferenceType()60 virtual const ReferenceType *asReferenceType() const { return nullptr; } asArrayType()61 virtual const ArrayType *asArrayType() const { return nullptr; } asNamedType()62 virtual const NamedType *asNamedType() const { return nullptr; } asFunctionType()63 virtual const Function *asFunctionType() const { return nullptr; } asNamespaceType()64 virtual const Namespace *asNamespaceType() const { return nullptr; } asTemplateType()65 virtual const Template *asTemplateType() const { return nullptr; } asClassType()66 virtual const Class *asClassType() const { return nullptr; } asEnumType()67 virtual const Enum *asEnumType() const { return nullptr; } asForwardClassDeclarationType()68 virtual const ForwardClassDeclaration *asForwardClassDeclarationType() const { return nullptr; } asObjCClassType()69 virtual const ObjCClass *asObjCClassType() const { return nullptr; } asObjCProtocolType()70 virtual const ObjCProtocol *asObjCProtocolType() const { return nullptr; } asObjCMethodType()71 virtual const ObjCMethod *asObjCMethodType() const { return nullptr; } asObjCForwardClassDeclarationType()72 virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() const { return nullptr; } asObjCForwardProtocolDeclarationType()73 virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() const { return nullptr; } 74 asUndefinedType()75 virtual UndefinedType *asUndefinedType() { return nullptr; } asVoidType()76 virtual VoidType *asVoidType() { return nullptr; } asIntegerType()77 virtual IntegerType *asIntegerType() { return nullptr; } asFloatType()78 virtual FloatType *asFloatType() { return nullptr; } asPointerType()79 virtual PointerType *asPointerType() { return nullptr; } asPointerToMemberType()80 virtual PointerToMemberType *asPointerToMemberType() { return nullptr; } asReferenceType()81 virtual ReferenceType *asReferenceType() { return nullptr; } asArrayType()82 virtual ArrayType *asArrayType() { return nullptr; } asNamedType()83 virtual NamedType *asNamedType() { return nullptr; } asFunctionType()84 virtual Function *asFunctionType() { return nullptr; } asNamespaceType()85 virtual Namespace *asNamespaceType() { return nullptr; } asTemplateType()86 virtual Template *asTemplateType() { return nullptr; } asClassType()87 virtual Class *asClassType() { return nullptr; } asEnumType()88 virtual Enum *asEnumType() { return nullptr; } asForwardClassDeclarationType()89 virtual ForwardClassDeclaration *asForwardClassDeclarationType() { return nullptr; } asObjCClassType()90 virtual ObjCClass *asObjCClassType() { return nullptr; } asObjCProtocolType()91 virtual ObjCProtocol *asObjCProtocolType() { return nullptr; } asObjCMethodType()92 virtual ObjCMethod *asObjCMethodType() { return nullptr; } asObjCForwardClassDeclarationType()93 virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() { return nullptr; } asObjCForwardProtocolDeclarationType()94 virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() { return nullptr; } 95 96 void accept(TypeVisitor *visitor); 97 static void accept(Type *type, TypeVisitor *visitor); 98 99 bool match(const Type *other, Matcher *matcher = nullptr) const; 100 101 protected: 102 virtual void accept0(TypeVisitor *visitor) = 0; 103 104 protected: // for Matcher 105 friend class Matcher; 106 virtual bool match0(const Type *otherType, Matcher *matcher) const = 0; 107 }; 108 109 } // namespace CPlusPlus 110