DeclObjC.h revision b97de3eddf0a0f7ff97204e7def6b7e0aa8953f2
1980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===--- DeclObjC.h - Classes for representing declarations -----*- C++ -*-===//
2980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
3980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//                     The LLVM Compiler Infrastructure
4980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
5980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff// This file was developed by Steve Naroff and is distributed under
6980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff// the University of Illinois Open Source License. See LICENSE.TXT for details.
7980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
8980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===----------------------------------------------------------------------===//
9980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
10980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//  This file defines the DeclObjC interface and subclasses.
11980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//
12980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff//===----------------------------------------------------------------------===//
13980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
14980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#ifndef LLVM_CLANG_AST_DECLOBJC_H
15980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#define LLVM_CLANG_AST_DECLOBJC_H
16980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
17980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#include "clang/AST/Decl.h"
18980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
19980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffnamespace clang {
20980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Expr;
21980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass Stmt;
22980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass FunctionDecl;
23980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass AttributeList;
24980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass ObjcIvarDecl;
25980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass ObjcMethodDecl;
26980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass ObjcProtocolDecl;
27980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass ObjcCategoryDecl;
28980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
290c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// ObjcInterfaceDecl - Represents an ObjC class declaration. For example:
300c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
310c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   // MostPrimitive declares no super class (not particularly useful).
320c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @interface MostPrimitive
330c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     // no instance variables or methods.
340c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @end
350c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
360c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   // NSResponder inherits from NSObject and implements NSCoding (a protocol).
370c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @interface NSResponder : NSObject <NSCoding>
380c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   { // instance variables are represented by ObjcIvarDecl.
390c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id nextResponder; // nextResponder instance variable.
400c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   }
410c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   - (NSResponder *)nextResponder; // return a pointer to NSResponder.
420c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   - (void)mouseMoved:(NSEvent *)theEvent; // return void, takes a pointer
430c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @end                                    // to an NSEvent.
440c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
450c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   Unlike C/C++, forward class declarations are accomplished with @class.
460c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   Unlike C/C++, @class allows for a list of classes to be forward declared.
470c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes
480c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   typically inherit from NSObject (an exception is NSProxy).
490c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
50980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass ObjcInterfaceDecl : public TypeDecl {
51980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
52980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Class's super class.
53980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcInterfaceDecl *SuperClass;
54980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
55980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Protocols referenced in interface header declaration
567ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcProtocolDecl **ReferencedProtocols;  // Null if none
577ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumReferencedProtocols;  // -1 if none
58980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
59980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
60980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcIvarDecl **Ivars;   // Null if not defined.
61980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  int NumIvars;   // -1 if not defined.
62980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
63980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// instance methods
647ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **InstanceMethods;  // Null if not defined
657ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumInstanceMethods;  // -1 if not defined
66980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
67980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// class methods
687ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **ClassMethods;  // Null if not defined
697ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumClassMethods;  // -1 if not defined
70980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
71980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// List of categories defined for this class.
72980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcCategoryDecl *ListCategories;
73980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
74768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  bool ForwardDecl; // declared with @class.
75980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffpublic:
76980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcInterfaceDecl(SourceLocation L, unsigned numRefProtos,
77980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                    IdentifierInfo *Id, bool FD = false)
78768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff    : TypeDecl(ObjcInterface, L, Id, 0), SuperClass(0),
797ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      ReferencedProtocols(0), NumReferencedProtocols(-1), Ivars(0),
807ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      NumIvars(-1),
817ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      InstanceMethods(0), NumInstanceMethods(-1),
827ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      ClassMethods(0), NumClassMethods(-1),
83768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff      ListCategories(0), ForwardDecl(FD) {
84980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff        AllocIntfRefProtocols(numRefProtos);
85980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      }
86a5997c4f36e0f5aa44623a5b1e3b914760d1ec68Steve Naroff
87a5997c4f36e0f5aa44623a5b1e3b914760d1ec68Steve Naroff  // This is necessary when converting a forward declaration to a definition.
88980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void AllocIntfRefProtocols(unsigned numRefProtos) {
89980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    if (numRefProtos) {
907ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      ReferencedProtocols = new ObjcProtocolDecl*[numRefProtos];
917ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      memset(ReferencedProtocols, '\0',
92980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff             numRefProtos*sizeof(ObjcProtocolDecl*));
937ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      NumReferencedProtocols = numRefProtos;
94980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    }
95980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
96980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
977ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcProtocolDecl **getReferencedProtocols() const {
987ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian    return ReferencedProtocols;
997ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  }
1007ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumIntfRefProtocols() const { return NumReferencedProtocols; }
101980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
102980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcIvarDecl **getIntfDeclIvars() const { return Ivars; }
103980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  int getIntfDeclNumIvars() const { return NumIvars; }
104980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
1057ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl** getInstanceMethods() const { return InstanceMethods; }
1067ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumInstanceMethods() const { return NumInstanceMethods; }
107980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
1087ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl** getClassMethods() const { return ClassMethods; }
1097ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumClassMethods() const { return NumClassMethods; }
110980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
111980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void ObjcAddInstanceVariablesToClass(ObjcIvarDecl **ivars,
112980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff				       unsigned numIvars);
113980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
114980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void ObjcAddMethods(ObjcMethodDecl **insMethods, unsigned numInsMembers,
115980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                      ObjcMethodDecl **clsMethods, unsigned numClsMembers);
116980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
117768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  bool isForwardDecl() const { return ForwardDecl; }
118768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  void setForwardDecl(bool val) { ForwardDecl = val; }
119980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
120980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setIntfRefProtocols(int idx, ObjcProtocolDecl *OID) {
1217ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian    assert((idx < NumReferencedProtocols) && "index out of range");
1227ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian    ReferencedProtocols[idx] = OID;
123980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
124980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
125980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcInterfaceDecl *getSuperClass() const { return SuperClass; }
126980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setSuperClass(ObjcInterfaceDecl * superCls) { SuperClass = superCls; }
127980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
128980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcCategoryDecl* getListCategories() const { return ListCategories; }
129980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setListCategories(ObjcCategoryDecl *category) {
130980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff         ListCategories = category;
131980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
1326a8a9a41e9067b708498c02180159bafecfa044fSteve Naroff  ObjcMethodDecl *lookupInstanceMethod(Selector &Sel);
1336a8a9a41e9067b708498c02180159bafecfa044fSteve Naroff  ObjcMethodDecl *lookupClassMethod(Selector &Sel);
134980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
1354b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian  /// ImplicitInterfaceDecl - check that this is an implicitely declared
1364b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian  /// ObjcInterfaceDecl node. This is for legacy objective-c @implementation
1374b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian  /// declaration without an @interface declaration.
1384b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian  bool ImplicitInterfaceDecl() const { return getLocation().isInvalid(); }
1394b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian
140980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const Decl *D) {
141980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    return D->getKind() == ObjcInterface;
142980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
143980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const ObjcInterfaceDecl *D) { return true; }
144980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
145980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
1460c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// ObjcIvarDecl - Represents an ObjC instance variable. In general, ObjC
1470c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// instance variables are identical to C. The only exception is Objective-C
1480c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// supports C++ style access control. For example:
1490c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
1500c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @interface IvarExample : NSObject
1510c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   {
1520c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id defaultToPrivate; // same as C++.
1530c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @public:
1540c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBePublic; // same as C++.
1550c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @protected:
1560c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBeProtected; // same as C++.
1570c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   @package:
1580c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///     id canBePackage; // framework visibility (not available in C++).
1590c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///   }
1600c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
161980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass ObjcIvarDecl : public FieldDecl {
162980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffpublic:
163980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcIvarDecl(SourceLocation L, IdentifierInfo *Id, QualType T)
164980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    : FieldDecl(ObjcIvar, L, Id, T) {}
165980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
166980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  enum AccessControl {
167980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    None, Private, Protected, Public, Package
168980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  };
169980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setAccessControl(AccessControl ac) { DeclAccess = ac; }
170980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  AccessControl getAccessControl() const { return DeclAccess; }
171980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
172980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  // Implement isa/cast/dyncast/etc.
173980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const Decl *D) { return D->getKind() == ObjcIvar; }
174980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const ObjcIvarDecl *D) { return true; }
175980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffprivate:
176980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  AccessControl DeclAccess : 3;
177980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
178980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
1790c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// ObjcMethodDecl - Represents an instance or class method declaration.
1800c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// ObjC methods can be declared within 4 contexts: class interfaces,
1810c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// categories, protocols, and class implementations. While C++ member
1820c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// functions leverage C syntax, Objective-C method syntax is modeled after
1830c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Smalltalk (using colons to specify argument types/expressions).
1840c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Here are some brief examples:
1850c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
1860c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Setter/getter instance methods:
1870c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)setMenu:(NSMenu *)menu;
1880c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSMenu *)menu;
1890c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
1900c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Instance method that takes 2 NSView arguments:
1910c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView;
1920c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
1930c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Getter class method:
1940c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// + (NSMenu *)defaultMenu;
1950c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
1960c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// A selector represents a unique name for a method. The selector names for
1970c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu.
1980c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
199980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass ObjcMethodDecl : public Decl {
200980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffpublic:
201980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  enum ImplementationControl { None, Required, Optional };
202980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffprivate:
203980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Bitfields must be first fields in this class so they pack with those
204980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// declared in class Decl.
205980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// instance (true) or class (false) method.
206980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  bool IsInstance : 1;
207980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// @required/@optional
208980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ImplementationControl DeclImplementation : 2;
209980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
210980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  // A unigue name for this method.
211980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  Selector SelName;
212980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
213980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  // Type of this method.
214980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  QualType MethodDeclType;
215980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// ParamInfo - new[]'d array of pointers to VarDecls for the formal
216980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// parameters of this Method.  This is null if there are no formals.
217980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ParmVarDecl **ParamInfo;
218980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  int NumMethodParams;  // -1 if no parameters
219980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
220980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// List of attributes for this method declaration.
221980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  AttributeList *MethodAttrs;
222980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
223980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Loc - location of this declaration.
224980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  SourceLocation Loc;
225980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
226980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffpublic:
227980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcMethodDecl(SourceLocation L, Selector SelInfo, QualType T,
228980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                 ParmVarDecl **paramInfo = 0, int numParams=-1,
229980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                 AttributeList *M = 0, bool isInstance = true,
230980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                 ImplementationControl impControl = None,
231980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                 Decl *PrevDecl = 0)
232980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    : Decl(ObjcMethod),
233980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      IsInstance(isInstance), DeclImplementation(impControl),
234980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      SelName(SelInfo), MethodDeclType(T),
235980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      ParamInfo(paramInfo), NumMethodParams(numParams),
236980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      MethodAttrs(M), Loc(L) {}
237980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  virtual ~ObjcMethodDecl();
238980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  Selector getSelector() const { return SelName; }
239980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  QualType getMethodType() const { return MethodDeclType; }
240980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  unsigned getNumMethodParams() const { return NumMethodParams; }
241980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ParmVarDecl *getMethodParamDecl(unsigned i) {
242980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    assert(i < getNumMethodParams() && "Illegal param #");
243980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    return ParamInfo[i];
244980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
24585ff2646c1aeedd1105f867a5bba8a58febd1d2aFariborz Jahanian
24685ff2646c1aeedd1105f867a5bba8a58febd1d2aFariborz Jahanian  int getNumParams() const { return NumMethodParams; }
24785ff2646c1aeedd1105f867a5bba8a58febd1d2aFariborz Jahanian  ParmVarDecl *getParamDecl(int i) const {
24885ff2646c1aeedd1105f867a5bba8a58febd1d2aFariborz Jahanian    assert(i < getNumParams() && "Illegal param #");
24985ff2646c1aeedd1105f867a5bba8a58febd1d2aFariborz Jahanian    return ParamInfo[i];
25085ff2646c1aeedd1105f867a5bba8a58febd1d2aFariborz Jahanian  }
251980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setMethodParams(ParmVarDecl **NewParamInfo, unsigned NumParams);
252980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
253980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  AttributeList *getMethodAttrs() const {return MethodAttrs;}
254980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  SourceLocation getLocation() const { return Loc; }
255980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  bool isInstance() const { return IsInstance; }
256980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  // Related to protocols declared in  @protocol
257980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setDeclImplementation(ImplementationControl ic)
258980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff         { DeclImplementation = ic; }
259980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ImplementationControl  getImplementationControl() const
260980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                           { return DeclImplementation; }
261980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
262980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  // Implement isa/cast/dyncast/etc.
263980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const Decl *D) {
264980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    return D->getKind() == ObjcMethod;
265980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
266980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const ObjcMethodDecl *D) { return true; }
267980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
268980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
2690c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// ObjcProtocolDecl - Represents a protocol declaration. ObjC protocols
2700c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// declare a pure abstract type (i.e no instance variables are permitted).
2710c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Protocols orginally drew inspiration from C++ pure virtual functions (a C++
2720c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// feature with nice semantics and lousy syntax:-). Here is an example:
2730c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
2740c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @protocol NSDraggingInfo
2750c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSWindow *)draggingDestinationWindow;
2760c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (NSImage *)draggedImage;
2770c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
2780c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
2790c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface ImplementsNSDraggingInfo : NSObject <NSDraggingInfo>
2800c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
2810c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
2820c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Objc protocols inspired Java interfaces. Unlike Java, ObjC classes and
2830c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are in distinct namespaces. For example, Cocoa defines both
2840c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// an NSObject protocol and class (which isn't allowed in Java). As a result,
2850c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// protocols are referenced using angle brackets as follows:
2860c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
2870c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// id <NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo;
2880c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
289980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass ObjcProtocolDecl : public TypeDecl {
290980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// referenced protocols
291980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcProtocolDecl **ReferencedProtocols;  // Null if none
292980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  int NumReferencedProtocols;  // -1 if none
293980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
294980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// protocol instance methods
2957ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **InstanceMethods;  // Null if not defined
2967ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumInstanceMethods;  // -1 if not defined
297980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
298980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// protocol class methods
2997ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **ClassMethods;  // Null if not defined
3007ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumClassMethods;  // -1 if not defined
301980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
302980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  bool isForwardProtoDecl; // declared with @protocol.
303980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffpublic:
304980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcProtocolDecl(SourceLocation L, unsigned numRefProtos,
305980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                   IdentifierInfo *Id, bool FD = false)
306980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    : TypeDecl(ObjcProtocol, L, Id, 0),
307980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      ReferencedProtocols(0), NumReferencedProtocols(-1),
3087ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      InstanceMethods(0), NumInstanceMethods(-1),
3097ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      ClassMethods(0), NumClassMethods(-1),
310980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      isForwardProtoDecl(FD) {
311980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff        AllocReferencedProtocols(numRefProtos);
312980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      }
313980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void AllocReferencedProtocols(unsigned numRefProtos) {
314980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    if (numRefProtos) {
315980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      ReferencedProtocols = new ObjcProtocolDecl*[numRefProtos];
316980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      memset(ReferencedProtocols, '\0',
317980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff             numRefProtos*sizeof(ObjcProtocolDecl*));
318980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      NumReferencedProtocols = numRefProtos;
319980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    }
320980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
321980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void ObjcAddProtoMethods(ObjcMethodDecl **insMethods, unsigned numInsMembers,
322980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                           ObjcMethodDecl **clsMethods, unsigned numClsMembers);
323980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
324980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setReferencedProtocols(int idx, ObjcProtocolDecl *OID) {
325980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    assert((idx < NumReferencedProtocols) && "index out of range");
326980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    ReferencedProtocols[idx] = OID;
327980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
328980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
329980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcProtocolDecl** getReferencedProtocols() const {
330980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    return ReferencedProtocols;
331980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
332980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  int getNumReferencedProtocols() const { return NumReferencedProtocols; }
333980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
3347ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl** getInstanceMethods() const { return InstanceMethods; }
3357ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumInstanceMethods() const { return NumInstanceMethods; }
336980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
3377ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl** getClassMethods() const { return ClassMethods; }
3387ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumClassMethods() const { return NumClassMethods; }
339980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
340768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  bool isForwardDecl() const { return isForwardProtoDecl; }
341768f26ee5892cd63ff0335a15d71a2385ba7c5eaSteve Naroff  void setForwardDecl(bool val) { isForwardProtoDecl = val; }
342980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
343980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const Decl *D) {
344980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    return D->getKind() == ObjcProtocol;
345980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
346980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const ObjcProtocolDecl *D) { return true; }
347980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
348980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
34906ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// ObjcClassDecl - Specifies a list of forward class declarations. For example:
35006ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff///
35106ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// @class NSCursor, NSImage, NSPasteboard, NSWindow;
3520c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
35306ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroffclass ObjcClassDecl : public TypeDecl {
35406ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  ObjcInterfaceDecl **ForwardDecls;   // Null if not defined.
35506ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  int NumForwardDecls;               // -1 if not defined.
35606ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroffpublic:
35706ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  ObjcClassDecl(SourceLocation L, unsigned nElts)
35806ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff    : TypeDecl(ObjcClass, L, 0, 0) {
35906ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff    if (nElts) {
36006ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff      ForwardDecls = new ObjcInterfaceDecl*[nElts];
36106ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff      memset(ForwardDecls, '\0', nElts*sizeof(ObjcInterfaceDecl*));
36206ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff    }
36306ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff    NumForwardDecls = nElts;
36406ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  }
36506ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  void setInterfaceDecl(int idx, ObjcInterfaceDecl *OID) {
36606ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff    assert((idx < NumForwardDecls) && "index out of range");
36706ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff    ForwardDecls[idx] = OID;
36806ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  }
36906ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  static bool classof(const Decl *D) {
37006ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff    return D->getKind() == ObjcClass;
37106ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  }
37206ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  static bool classof(const ObjcClassDecl *D) { return true; }
37306ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff};
37406ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff
37506ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// ObjcForwardProtocolDecl - Specifies a list of forward protocol declarations.
37606ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff/// For example:
37706ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff///
3780c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @protocol NSTextInput, NSChangeSpelling, NSDraggingInfo;
3790c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
380980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass ObjcForwardProtocolDecl : public TypeDecl {
3819fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  ObjcProtocolDecl **ReferencedProtocols;
3829fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  unsigned NumReferencedProtocols;
38306ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroffpublic:
384b97de3eddf0a0f7ff97204e7def6b7e0aa8953f2Chris Lattner  ObjcForwardProtocolDecl(SourceLocation L,
385b97de3eddf0a0f7ff97204e7def6b7e0aa8953f2Chris Lattner                          ObjcProtocolDecl **Elts, unsigned nElts)
38606ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  : TypeDecl(ObjcForwardProtocol, L, 0, 0) {
387b97de3eddf0a0f7ff97204e7def6b7e0aa8953f2Chris Lattner    NumReferencedProtocols = nElts;
38806ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff    if (nElts) {
3897ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      ReferencedProtocols = new ObjcProtocolDecl*[nElts];
390b97de3eddf0a0f7ff97204e7def6b7e0aa8953f2Chris Lattner      memcpy(ReferencedProtocols, Elts, nElts*sizeof(ObjcProtocolDecl*));
3919fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner    } else {
3929fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner      ReferencedProtocols = 0;
393980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    }
39406ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  }
3959fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  void setForwardProtocolDecl(unsigned idx, ObjcProtocolDecl *OID) {
3969fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner    assert(idx < NumReferencedProtocols && "index out of range");
3977ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian    ReferencedProtocols[idx] = OID;
39806ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  }
3999fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner
4009fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  unsigned getNumForwardDecls() const { return NumReferencedProtocols; }
4019fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner
4029fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  ObjcProtocolDecl *getForwardProtocolDecl(unsigned idx) {
4039fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner    assert(idx < NumReferencedProtocols && "index out of range");
4049fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner    return ReferencedProtocols[idx];
4059fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  }
4069fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  const ObjcProtocolDecl *getForwardProtocolDecl(unsigned idx) const {
4079fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner    assert(idx < NumReferencedProtocols && "index out of range");
4089fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner    return ReferencedProtocols[idx];
4099fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner  }
4109fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattner
41106ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  static bool classof(const Decl *D) {
41206ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff    return D->getKind() == ObjcForwardProtocol;
41306ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  }
41406ae8d68ef258ccd40c9cd1ce762eaae6f3d4432Steve Naroff  static bool classof(const ObjcForwardProtocolDecl *D) { return true; }
415980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
416980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
4170c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// ObjcCategoryDecl - Represents a category declaration. A category allows
4180c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add methods to an existing class (without subclassing or modifying
4190c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// the original class interface or implementation:-). Categories don't allow
4200c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// you to add instance data. The following example adds "myMethod" to all
4210c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// NSView's within a process:
4220c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
4230c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @interface NSView (MyViewMethods)
4240c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - myMethod;
4250c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
4260c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
4270c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Cateogries also allow you to split the implementation of a class across
4280c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// several files (a feature more naturally supported in C++).
4290c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
4300c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Categories were originally inspired by dynamic languages such as Common
4310c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Lisp and Smalltalk. More traditional class-based languages (C++, Java)
4320c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// don't support this level of dynamism, which is both powerful and dangerous.
4330c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
43460199032e41216fa2fca635c7a942e5473cdf979Fariborz Jahanianclass ObjcCategoryDecl : public Decl {
435980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Interface belonging to this category
436980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcInterfaceDecl *ClassInterface;
437980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
438980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Category name
439980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  IdentifierInfo *ObjcCatName;
440980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
441980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// referenced protocols in this category
4427ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcProtocolDecl **ReferencedProtocols;  // Null if none
4437ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumReferencedProtocols;  // -1 if none
444980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
445980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// category instance methods
4467ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **InstanceMethods;  // Null if not defined
4477ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumInstanceMethods;  // -1 if not defined
448980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
449980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// category class methods
4507ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **ClassMethods;  // Null if not defined
4517ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumClassMethods;  // -1 if not defined
452980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
453980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Next category belonging to this class
454980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcCategoryDecl *NextClassCategory;
455ca3adf7e8cac8c9fbaf592b1e5c2be6f082de7baFariborz Jahanian
456ca3adf7e8cac8c9fbaf592b1e5c2be6f082de7baFariborz Jahanian  /// Location of cetagory declaration
457ca3adf7e8cac8c9fbaf592b1e5c2be6f082de7baFariborz Jahanian  SourceLocation CatLoc;
458980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
459980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffpublic:
46060199032e41216fa2fca635c7a942e5473cdf979Fariborz Jahanian  ObjcCategoryDecl(SourceLocation L, unsigned numRefProtocol)
46160199032e41216fa2fca635c7a942e5473cdf979Fariborz Jahanian    : Decl(ObjcCategory),
462980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      ClassInterface(0), ObjcCatName(0),
4637ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      ReferencedProtocols(0), NumReferencedProtocols(-1),
4647ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      InstanceMethods(0), NumInstanceMethods(-1),
4657ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      ClassMethods(0), NumClassMethods(-1),
466ca3adf7e8cac8c9fbaf592b1e5c2be6f082de7baFariborz Jahanian      NextClassCategory(0), CatLoc(L) {
467980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff        if (numRefProtocol) {
4687ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian          ReferencedProtocols = new ObjcProtocolDecl*[numRefProtocol];
4697ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian          memset(ReferencedProtocols, '\0',
470980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                 numRefProtocol*sizeof(ObjcProtocolDecl*));
4717ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian          NumReferencedProtocols = numRefProtocol;
472980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff        }
473980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      }
474980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
475980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcInterfaceDecl *getClassInterface() const { return ClassInterface; }
476980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setClassInterface(ObjcInterfaceDecl *IDecl) { ClassInterface = IDecl; }
477980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
478980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setCatReferencedProtocols(int idx, ObjcProtocolDecl *OID) {
4797ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian    assert((idx < NumReferencedProtocols) && "index out of range");
4807ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian    ReferencedProtocols[idx] = OID;
481980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
482980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
4837ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcProtocolDecl **getReferencedProtocols() const {
4847ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian    return ReferencedProtocols;
4858f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  }
4867ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumReferencedProtocols() const { return NumReferencedProtocols; }
4878f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
4887ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **getInstanceMethods() const { return InstanceMethods; }
4897ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumInstanceMethods() const { return NumInstanceMethods; }
4908f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
4917ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **getClassMethods() const { return ClassMethods; }
4927ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumClassMethods() const { return NumClassMethods; }
4938f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
494980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void ObjcAddCatMethods(ObjcMethodDecl **insMethods, unsigned numInsMembers,
495980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                         ObjcMethodDecl **clsMethods, unsigned numClsMembers);
496980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
497980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  IdentifierInfo *getCatName() const { return ObjcCatName; }
498980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void setCatName(IdentifierInfo *catName) { ObjcCatName = catName; }
499980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
500980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcCategoryDecl *getNextClassCategory() const { return NextClassCategory; }
501980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void insertNextClassCategory() {
502980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    NextClassCategory = ClassInterface->getListCategories();
503980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    ClassInterface->setListCategories(this);
504980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
505ca3adf7e8cac8c9fbaf592b1e5c2be6f082de7baFariborz Jahanian
50679139a121781854c3742273dd7b8289fa215341aFariborz Jahanian  SourceLocation getLocation() const { return CatLoc; }
507ca3adf7e8cac8c9fbaf592b1e5c2be6f082de7baFariborz Jahanian
508980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const Decl *D) {
509980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    return D->getKind() == ObjcCategory;
510980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
511980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const ObjcCategoryDecl *D) { return true; }
512980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
5130c6b6243d3efd958c17943130e2a773653511edcSteve Naroff
5148f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian/// ObjcCategoryImplDecl - An object of this class encapsulates a category
5158f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian/// @implementation declaration.
5168f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanianclass ObjcCategoryImplDecl : public Decl {
5178f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  /// Class interface for this category implementation
5188f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  ObjcInterfaceDecl *ClassInterface;
5198f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
5208f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  /// Category name
5218f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  IdentifierInfo *ObjcCatName;
5228f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
5238f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  /// category instance methods being implemented
5247ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **InstanceMethods; // Null if category is not implementing any
5257ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumInstanceMethods;           // -1 if category is not implementing any
5268f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
5278f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  /// category class methods being implemented
5287ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **ClassMethods; // Null if category is not implementing any
5297ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumClassMethods;  // -1 if category is not implementing any
5308f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
5314b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian  SourceLocation Loc;
5324b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian
5338f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  public:
5348f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian    ObjcCategoryImplDecl(SourceLocation L, IdentifierInfo *Id,
5358f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian                         ObjcInterfaceDecl *classInterface,
5368f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian                         IdentifierInfo *catName)
5378f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian    : Decl(ObjcCategoryImpl),
5388f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian    ClassInterface(classInterface),
5398f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian    ObjcCatName(catName),
5407ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian    InstanceMethods(0), NumInstanceMethods(-1),
5414b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian    ClassMethods(0), NumClassMethods(-1), Loc(L) {}
5428f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
5438f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian    ObjcInterfaceDecl *getClassInterface() const {
5448f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian      return ClassInterface;
5458f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian    }
5468f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
5478f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  IdentifierInfo *getObjcCatName() const { return ObjcCatName; }
5488f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
5497ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **getInstanceMethods() const { return InstanceMethods; }
5507ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumInstanceMethods() const { return NumInstanceMethods; }
5518f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
5527ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **getClassMethods() const { return ClassMethods; }
5537ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumClassMethods() const { return NumClassMethods; }
5548f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
5558f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  void ObjcAddCatImplMethods(
5568f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian        ObjcMethodDecl **insMethods, unsigned numInsMembers,
5578f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian        ObjcMethodDecl **clsMethods, unsigned numClsMembers);
5588f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
5594b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian  SourceLocation getLocation() const { return Loc; }
5604b6df3fa953267c5d755628c8afd818bb571e579Fariborz Jahanian
5618f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  static bool classof(const Decl *D) {
5628f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian    return D->getKind() == ObjcCategoryImpl;
5638f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  }
5648f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian  static bool classof(const ObjcCategoryImplDecl *D) { return true; }
5658f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian};
5668f3fde00ad4d4f943321e338b914ae4740711c84Fariborz Jahanian
5670c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// ObjcImplementationDecl - Represents a class definition - this is where
5680c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// method definitions are specified. For example:
5690c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
5700c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @implementation MyClass
5710c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// - (void)myMethod { /* do something */ }
5720c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// @end
5730c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
5740c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// Typically, instance variables are specified in the class interface,
5750c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// *not* in the implemenentation. Nevertheless (for legacy reasons), we
5760c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// allow instance variables to be specified in the implementation. When
5770c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// specified, they need to be *identical* to the interface. Now that we
5780c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// have support for non-fragile ivars in ObjC 2.0, we can consider removing
5790c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// the legacy semantics and allow developers to move private ivar declarations
5800c6b6243d3efd958c17943130e2a773653511edcSteve Naroff/// from the class interface to the class implementation (but I digress:-)
5810c6b6243d3efd958c17943130e2a773653511edcSteve Naroff///
582980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroffclass ObjcImplementationDecl : public TypeDecl {
583980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
584980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Implementation Class's super class.
585980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcInterfaceDecl *SuperClass;
586980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
587980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// Optional Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
588980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcIvarDecl **Ivars;   // Null if not specified
589980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  int NumIvars;   // -1 if not defined.
590980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
591980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// implemented instance methods
5927ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **InstanceMethods;  // Null if not defined
5937ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumInstanceMethods;  // -1 if not defined
594980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
595980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  /// implemented class methods
5967ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **ClassMethods;  // Null if not defined
5977ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int NumClassMethods;  // -1 if not defined
598980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
5999fa5e65d08aee1875c5f2a841c8b0b4069bd00e5Chris Lattnerpublic:
600980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  ObjcImplementationDecl(SourceLocation L, IdentifierInfo *Id,
601980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                         ObjcInterfaceDecl* superDecl)
602980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    : TypeDecl(ObjcImplementation, L, Id, 0),
603980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      SuperClass(superDecl),
604980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff      Ivars(0), NumIvars(-1),
6057ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      InstanceMethods(0), NumInstanceMethods(-1),
6067ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian      ClassMethods(0), NumClassMethods(-1) {}
607980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
608980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void ObjcAddInstanceVariablesToClassImpl(ObjcIvarDecl **ivars,
609980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                                           unsigned numIvars);
610980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
611980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  void ObjcAddImplMethods(ObjcMethodDecl **insMethods, unsigned numInsMembers,
612980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff                          ObjcMethodDecl **clsMethods, unsigned numClsMembers);
613980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
61493efc029bf485de724fd783ad14b58aaec9c919bFariborz Jahanian  ObjcInterfaceDecl *getSuperClass() const { return SuperClass; }
615980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
61693efc029bf485de724fd783ad14b58aaec9c919bFariborz Jahanian  void setSuperClass(ObjcInterfaceDecl * superCls)
617980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff         { SuperClass = superCls; }
618980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
6197ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **getInstanceMethods() const { return InstanceMethods; }
6207ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumInstanceMethods() const { return NumInstanceMethods; }
621980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
6227ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  ObjcMethodDecl **getClassMethods() const { return ClassMethods; }
6237ed9e0f97f4645edc5d4670385b985ea4c617ce7Fariborz Jahanian  int getNumClassMethods() const { return NumClassMethods; }
624980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
625980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const Decl *D) {
626980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff    return D->getKind() == ObjcImplementation;
627980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  }
628980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff  static bool classof(const ObjcImplementationDecl *D) { return true; }
629980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff};
630980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
631980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff
632980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff}  // end namespace clang
633980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff#endif
634