Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 1 | //===--- Decl.cpp - Declaration AST Node Implementation -------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Chris Lattner and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the Decl class and subclasses. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/AST/Decl.h" |
Steve Naroff | 3fafa10 | 2007-10-01 19:00:59 +0000 | [diff] [blame^] | 15 | #include "clang/AST/DeclObjC.h" |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 16 | #include "clang/Lex/IdentifierTable.h" |
| 17 | using namespace clang; |
| 18 | |
| 19 | // temporary statistics gathering |
| 20 | static unsigned nFuncs = 0; |
| 21 | static unsigned nBlockVars = 0; |
| 22 | static unsigned nFileVars = 0; |
| 23 | static unsigned nParmVars = 0; |
| 24 | static unsigned nSUC = 0; |
| 25 | static unsigned nEnumConst = 0; |
| 26 | static unsigned nEnumDecls = 0; |
| 27 | static unsigned nTypedef = 0; |
| 28 | static unsigned nFieldDecls = 0; |
Steve Naroff | 81f1bba | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 29 | static unsigned nInterfaceDecls = 0; |
Steve Naroff | 948fd37 | 2007-09-17 14:16:13 +0000 | [diff] [blame] | 30 | static unsigned nClassDecls = 0; |
| 31 | static unsigned nMethodDecls = 0; |
| 32 | static unsigned nProtocolDecls = 0; |
Fariborz Jahanian | c716c94 | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 33 | static unsigned nForwardProtocolDecls = 0; |
Fariborz Jahanian | f25220e | 2007-09-18 20:26:58 +0000 | [diff] [blame] | 34 | static unsigned nCategoryDecls = 0; |
Steve Naroff | 948fd37 | 2007-09-17 14:16:13 +0000 | [diff] [blame] | 35 | static unsigned nIvarDecls = 0; |
Fariborz Jahanian | c091b5d | 2007-09-25 18:38:09 +0000 | [diff] [blame] | 36 | static unsigned nObjcImplementationDecls = 0; |
Steve Naroff | 948fd37 | 2007-09-17 14:16:13 +0000 | [diff] [blame] | 37 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 38 | static bool StatSwitch = false; |
| 39 | |
Steve Naroff | 590aba8 | 2007-09-17 14:49:06 +0000 | [diff] [blame] | 40 | const char *Decl::getDeclKindName() const { |
Steve Naroff | f0c31dd | 2007-09-16 16:16:00 +0000 | [diff] [blame] | 41 | switch (DeclKind) { |
| 42 | default: assert(0 && "Unknown decl kind!"); |
| 43 | case Typedef: |
| 44 | return "Typedef"; |
| 45 | case Function: |
| 46 | return "Function"; |
| 47 | case BlockVariable: |
| 48 | return "BlockVariable"; |
| 49 | case FileVariable: |
| 50 | return "FileVariable"; |
| 51 | case ParmVariable: |
| 52 | return "ParmVariable"; |
| 53 | case EnumConstant: |
| 54 | return "EnumConstant"; |
| 55 | case ObjcInterface: |
| 56 | return "ObjcInterface"; |
| 57 | case ObjcClass: |
| 58 | return "ObjcClass"; |
| 59 | case ObjcMethod: |
| 60 | return "ObjcMethod"; |
Steve Naroff | f0c31dd | 2007-09-16 16:16:00 +0000 | [diff] [blame] | 61 | case ObjcProtocol: |
| 62 | return "ObjcProtocol"; |
Fariborz Jahanian | c716c94 | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 63 | case ObjcForwardProtocol: |
| 64 | return "ObjcForwardProtocol"; |
Steve Naroff | f0c31dd | 2007-09-16 16:16:00 +0000 | [diff] [blame] | 65 | case Struct: |
| 66 | return "Struct"; |
| 67 | case Union: |
| 68 | return "Union"; |
| 69 | case Class: |
| 70 | return "Class"; |
| 71 | case Enum: |
| 72 | return "Enum"; |
| 73 | } |
| 74 | } |
| 75 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 76 | bool Decl::CollectingStats(bool enable) { |
| 77 | if (enable) StatSwitch = true; |
| 78 | return StatSwitch; |
| 79 | } |
| 80 | |
| 81 | void Decl::PrintStats() { |
| 82 | fprintf(stderr, "*** Decl Stats:\n"); |
| 83 | fprintf(stderr, " %d decls total.\n", |
| 84 | int(nFuncs+nBlockVars+nFileVars+nParmVars+nFieldDecls+nSUC+ |
Steve Naroff | 948fd37 | 2007-09-17 14:16:13 +0000 | [diff] [blame] | 85 | nEnumDecls+nEnumConst+nTypedef+nInterfaceDecls+nClassDecls+ |
Fariborz Jahanian | f25220e | 2007-09-18 20:26:58 +0000 | [diff] [blame] | 86 | nMethodDecls+nProtocolDecls+nCategoryDecls+nIvarDecls)); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 87 | fprintf(stderr, " %d function decls, %d each (%d bytes)\n", |
| 88 | nFuncs, (int)sizeof(FunctionDecl), int(nFuncs*sizeof(FunctionDecl))); |
| 89 | fprintf(stderr, " %d block variable decls, %d each (%d bytes)\n", |
| 90 | nBlockVars, (int)sizeof(BlockVarDecl), |
| 91 | int(nBlockVars*sizeof(BlockVarDecl))); |
| 92 | fprintf(stderr, " %d file variable decls, %d each (%d bytes)\n", |
| 93 | nFileVars, (int)sizeof(FileVarDecl), |
| 94 | int(nFileVars*sizeof(FileVarDecl))); |
| 95 | fprintf(stderr, " %d parameter variable decls, %d each (%d bytes)\n", |
| 96 | nParmVars, (int)sizeof(ParmVarDecl), |
| 97 | int(nParmVars*sizeof(ParmVarDecl))); |
| 98 | fprintf(stderr, " %d field decls, %d each (%d bytes)\n", |
| 99 | nFieldDecls, (int)sizeof(FieldDecl), |
| 100 | int(nFieldDecls*sizeof(FieldDecl))); |
| 101 | fprintf(stderr, " %d struct/union/class decls, %d each (%d bytes)\n", |
| 102 | nSUC, (int)sizeof(RecordDecl), |
| 103 | int(nSUC*sizeof(RecordDecl))); |
| 104 | fprintf(stderr, " %d enum decls, %d each (%d bytes)\n", |
| 105 | nEnumDecls, (int)sizeof(EnumDecl), |
| 106 | int(nEnumDecls*sizeof(EnumDecl))); |
| 107 | fprintf(stderr, " %d enum constant decls, %d each (%d bytes)\n", |
| 108 | nEnumConst, (int)sizeof(EnumConstantDecl), |
| 109 | int(nEnumConst*sizeof(EnumConstantDecl))); |
| 110 | fprintf(stderr, " %d typedef decls, %d each (%d bytes)\n", |
| 111 | nTypedef, (int)sizeof(TypedefDecl),int(nTypedef*sizeof(TypedefDecl))); |
Steve Naroff | 948fd37 | 2007-09-17 14:16:13 +0000 | [diff] [blame] | 112 | // Objective-C decls... |
| 113 | fprintf(stderr, " %d interface decls, %d each (%d bytes)\n", |
| 114 | nInterfaceDecls, (int)sizeof(ObjcInterfaceDecl), |
| 115 | int(nInterfaceDecls*sizeof(ObjcInterfaceDecl))); |
| 116 | fprintf(stderr, " %d instance variable decls, %d each (%d bytes)\n", |
| 117 | nIvarDecls, (int)sizeof(ObjcIvarDecl), |
| 118 | int(nIvarDecls*sizeof(ObjcIvarDecl))); |
| 119 | fprintf(stderr, " %d class decls, %d each (%d bytes)\n", |
| 120 | nClassDecls, (int)sizeof(ObjcClassDecl), |
| 121 | int(nClassDecls*sizeof(ObjcClassDecl))); |
| 122 | fprintf(stderr, " %d method decls, %d each (%d bytes)\n", |
| 123 | nMethodDecls, (int)sizeof(ObjcMethodDecl), |
| 124 | int(nMethodDecls*sizeof(ObjcMethodDecl))); |
| 125 | fprintf(stderr, " %d protocol decls, %d each (%d bytes)\n", |
| 126 | nProtocolDecls, (int)sizeof(ObjcProtocolDecl), |
| 127 | int(nProtocolDecls*sizeof(ObjcProtocolDecl))); |
Fariborz Jahanian | c716c94 | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 128 | fprintf(stderr, " %d forward protocol decls, %d each (%d bytes)\n", |
| 129 | nForwardProtocolDecls, (int)sizeof(ObjcForwardProtocolDecl), |
| 130 | int(nForwardProtocolDecls*sizeof(ObjcForwardProtocolDecl))); |
Fariborz Jahanian | f25220e | 2007-09-18 20:26:58 +0000 | [diff] [blame] | 131 | fprintf(stderr, " %d category decls, %d each (%d bytes)\n", |
| 132 | nCategoryDecls, (int)sizeof(ObjcCategoryDecl), |
| 133 | int(nCategoryDecls*sizeof(ObjcCategoryDecl))); |
Steve Naroff | 948fd37 | 2007-09-17 14:16:13 +0000 | [diff] [blame] | 134 | |
Fariborz Jahanian | c091b5d | 2007-09-25 18:38:09 +0000 | [diff] [blame] | 135 | fprintf(stderr, " %d class implementation decls, %d each (%d bytes)\n", |
| 136 | nObjcImplementationDecls, (int)sizeof(ObjcImplementationDecl), |
| 137 | int(nObjcImplementationDecls*sizeof(ObjcImplementationDecl))); |
| 138 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 139 | fprintf(stderr, "Total bytes = %d\n", |
| 140 | int(nFuncs*sizeof(FunctionDecl)+nBlockVars*sizeof(BlockVarDecl)+ |
| 141 | nFileVars*sizeof(FileVarDecl)+nParmVars*sizeof(ParmVarDecl)+ |
| 142 | nFieldDecls*sizeof(FieldDecl)+nSUC*sizeof(RecordDecl)+ |
| 143 | nEnumDecls*sizeof(EnumDecl)+nEnumConst*sizeof(EnumConstantDecl)+ |
Steve Naroff | 948fd37 | 2007-09-17 14:16:13 +0000 | [diff] [blame] | 144 | nTypedef*sizeof(TypedefDecl)) /* FIXME: add Objc decls */); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | void Decl::addDeclKind(const Kind k) { |
| 148 | switch (k) { |
| 149 | case Typedef: |
| 150 | nTypedef++; |
| 151 | break; |
| 152 | case Function: |
| 153 | nFuncs++; |
| 154 | break; |
| 155 | case BlockVariable: |
| 156 | nBlockVars++; |
| 157 | break; |
| 158 | case FileVariable: |
| 159 | nFileVars++; |
| 160 | break; |
| 161 | case ParmVariable: |
| 162 | nParmVars++; |
| 163 | break; |
| 164 | case EnumConstant: |
| 165 | nEnumConst++; |
| 166 | break; |
| 167 | case Field: |
| 168 | nFieldDecls++; |
| 169 | break; |
| 170 | case Struct: |
| 171 | case Union: |
| 172 | case Class: |
| 173 | nSUC++; |
| 174 | break; |
| 175 | case Enum: |
| 176 | nEnumDecls++; |
| 177 | break; |
Steve Naroff | 81f1bba | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 178 | case ObjcInterface: |
| 179 | nInterfaceDecls++; |
| 180 | break; |
Chris Lattner | b15b438 | 2007-09-16 19:23:04 +0000 | [diff] [blame] | 181 | case ObjcClass: |
Steve Naroff | 948fd37 | 2007-09-17 14:16:13 +0000 | [diff] [blame] | 182 | nClassDecls++; |
| 183 | break; |
Chris Lattner | b15b438 | 2007-09-16 19:23:04 +0000 | [diff] [blame] | 184 | case ObjcMethod: |
Steve Naroff | 948fd37 | 2007-09-17 14:16:13 +0000 | [diff] [blame] | 185 | nMethodDecls++; |
| 186 | break; |
Chris Lattner | b15b438 | 2007-09-16 19:23:04 +0000 | [diff] [blame] | 187 | case ObjcProtocol: |
Steve Naroff | 948fd37 | 2007-09-17 14:16:13 +0000 | [diff] [blame] | 188 | nProtocolDecls++; |
| 189 | break; |
Fariborz Jahanian | c716c94 | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 190 | case ObjcForwardProtocol: |
| 191 | nForwardProtocolDecls++; |
| 192 | break; |
Fariborz Jahanian | f25220e | 2007-09-18 20:26:58 +0000 | [diff] [blame] | 193 | case ObjcCategory: |
| 194 | nCategoryDecls++; |
| 195 | break; |
Chris Lattner | b15b438 | 2007-09-16 19:23:04 +0000 | [diff] [blame] | 196 | case ObjcIvar: |
Steve Naroff | 948fd37 | 2007-09-17 14:16:13 +0000 | [diff] [blame] | 197 | nIvarDecls++; |
Chris Lattner | b15b438 | 2007-09-16 19:23:04 +0000 | [diff] [blame] | 198 | break; |
Fariborz Jahanian | c091b5d | 2007-09-25 18:38:09 +0000 | [diff] [blame] | 199 | case ObjcImplementation: |
| 200 | nObjcImplementationDecls++; |
| 201 | break; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 202 | } |
| 203 | } |
| 204 | |
| 205 | // Out-of-line virtual method providing a home for Decl. |
| 206 | Decl::~Decl() { |
| 207 | } |
| 208 | |
Steve Naroff | cb59747 | 2007-09-13 21:41:19 +0000 | [diff] [blame] | 209 | const char *FieldDecl::getName() const { |
| 210 | if (const IdentifierInfo *II = getIdentifier()) |
| 211 | return II->getName(); |
| 212 | return ""; |
| 213 | } |
| 214 | |
| 215 | const char *ScopedDecl::getName() const { |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 216 | if (const IdentifierInfo *II = getIdentifier()) |
| 217 | return II->getName(); |
| 218 | return ""; |
| 219 | } |
| 220 | |
| 221 | |
| 222 | FunctionDecl::~FunctionDecl() { |
| 223 | delete[] ParamInfo; |
| 224 | } |
| 225 | |
| 226 | unsigned FunctionDecl::getNumParams() const { |
| 227 | return cast<FunctionTypeProto>(getType().getTypePtr())->getNumArgs(); |
| 228 | } |
| 229 | |
| 230 | void FunctionDecl::setParams(ParmVarDecl **NewParamInfo, unsigned NumParams) { |
| 231 | assert(ParamInfo == 0 && "Already has param info!"); |
| 232 | assert(NumParams == getNumParams() && "Parameter count mismatch!"); |
| 233 | |
| 234 | // Zero params -> null pointer. |
| 235 | if (NumParams) { |
| 236 | ParamInfo = new ParmVarDecl*[NumParams]; |
| 237 | memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | |
| 242 | /// defineBody - When created, RecordDecl's correspond to a forward declared |
| 243 | /// record. This method is used to mark the decl as being defined, with the |
| 244 | /// specified contents. |
| 245 | void RecordDecl::defineBody(FieldDecl **members, unsigned numMembers) { |
| 246 | assert(!isDefinition() && "Cannot redefine record!"); |
| 247 | setDefinition(true); |
| 248 | NumMembers = numMembers; |
| 249 | if (numMembers) { |
| 250 | Members = new FieldDecl*[numMembers]; |
| 251 | memcpy(Members, members, numMembers*sizeof(Decl*)); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | FieldDecl* RecordDecl::getMember(IdentifierInfo *name) { |
| 256 | if (Members == 0 || NumMembers < 0) |
| 257 | return 0; |
| 258 | |
| 259 | // linear search. When C++ classes come along, will likely need to revisit. |
| 260 | for (int i = 0; i < NumMembers; ++i) { |
| 261 | if (Members[i]->getIdentifier() == name) |
| 262 | return Members[i]; |
| 263 | } |
| 264 | return 0; |
| 265 | } |
Fariborz Jahanian | 3dc7cbc | 2007-09-10 20:33:04 +0000 | [diff] [blame] | 266 | |
Fariborz Jahanian | 86f74a4 | 2007-09-12 18:23:47 +0000 | [diff] [blame] | 267 | void ObjcMethodDecl::setMethodParams(ParmVarDecl **NewParamInfo, |
Fariborz Jahanian | bec0d56 | 2007-10-01 16:53:59 +0000 | [diff] [blame] | 268 | unsigned NumParams) { |
Fariborz Jahanian | 86f74a4 | 2007-09-12 18:23:47 +0000 | [diff] [blame] | 269 | assert(ParamInfo == 0 && "Already has param info!"); |
| 270 | |
| 271 | // Zero params -> null pointer. |
| 272 | if (NumParams) { |
| 273 | ParamInfo = new ParmVarDecl*[NumParams]; |
| 274 | memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams); |
| 275 | NumMethodParams = NumParams; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | ObjcMethodDecl::~ObjcMethodDecl() { |
| 280 | delete[] ParamInfo; |
| 281 | } |
| 282 | |
Fariborz Jahanian | ebcc9b6 | 2007-09-14 21:08:27 +0000 | [diff] [blame] | 283 | /// ObjcAddInstanceVariablesToClass - Inserts instance variables |
| 284 | /// into ObjcInterfaceDecl's fields. |
| 285 | /// |
| 286 | void ObjcInterfaceDecl::ObjcAddInstanceVariablesToClass(ObjcIvarDecl **ivars, |
| 287 | unsigned numIvars) { |
| 288 | NumIvars = numIvars; |
| 289 | if (numIvars) { |
| 290 | Ivars = new ObjcIvarDecl*[numIvars]; |
| 291 | memcpy(Ivars, ivars, numIvars*sizeof(ObjcIvarDecl*)); |
| 292 | } |
| 293 | } |
| 294 | |
Fariborz Jahanian | d34caf9 | 2007-09-26 18:27:25 +0000 | [diff] [blame] | 295 | /// ObjcAddInstanceVariablesToClassImpl - Checks for correctness of Instance |
| 296 | /// Variables (Ivars) relative to what declared in @implementation;s class. |
| 297 | /// Ivars into ObjcImplementationDecl's fields. |
| 298 | /// |
| 299 | void ObjcImplementationDecl::ObjcAddInstanceVariablesToClassImpl( |
| 300 | ObjcIvarDecl **ivars, unsigned numIvars) { |
| 301 | NumIvars = numIvars; |
| 302 | if (numIvars) { |
| 303 | Ivars = new ObjcIvarDecl*[numIvars]; |
| 304 | memcpy(Ivars, ivars, numIvars*sizeof(ObjcIvarDecl*)); |
| 305 | } |
| 306 | } |
| 307 | |
Fariborz Jahanian | 3dc7cbc | 2007-09-10 20:33:04 +0000 | [diff] [blame] | 308 | /// addObjcMethods - Insert instance and methods declarations into |
| 309 | /// ObjcInterfaceDecl's InsMethods and ClsMethods fields. |
| 310 | /// |
| 311 | void ObjcInterfaceDecl::ObjcAddMethods(ObjcMethodDecl **insMethods, |
| 312 | unsigned numInsMembers, |
| 313 | ObjcMethodDecl **clsMethods, |
| 314 | unsigned numClsMembers) { |
| 315 | NumInsMethods = numInsMembers; |
| 316 | if (numInsMembers) { |
| 317 | InsMethods = new ObjcMethodDecl*[numInsMembers]; |
| 318 | memcpy(InsMethods, insMethods, numInsMembers*sizeof(ObjcMethodDecl*)); |
| 319 | } |
| 320 | NumClsMethods = numClsMembers; |
| 321 | if (numClsMembers) { |
| 322 | ClsMethods = new ObjcMethodDecl*[numClsMembers]; |
| 323 | memcpy(ClsMethods, clsMethods, numClsMembers*sizeof(ObjcMethodDecl*)); |
| 324 | } |
| 325 | } |
| 326 | |
Fariborz Jahanian | 63ca8ae | 2007-09-17 21:07:36 +0000 | [diff] [blame] | 327 | /// ObjcAddProtoMethods - Insert instance and methods declarations into |
| 328 | /// ObjcProtocolDecl's ProtoInsMethods and ProtoClsMethods fields. |
| 329 | /// |
| 330 | void ObjcProtocolDecl::ObjcAddProtoMethods(ObjcMethodDecl **insMethods, |
| 331 | unsigned numInsMembers, |
| 332 | ObjcMethodDecl **clsMethods, |
| 333 | unsigned numClsMembers) { |
| 334 | NumProtoInsMethods = numInsMembers; |
| 335 | if (numInsMembers) { |
Fariborz Jahanian | 4a2b0ac | 2007-09-17 22:36:42 +0000 | [diff] [blame] | 336 | ProtoInsMethods = new ObjcMethodDecl*[numInsMembers]; |
Fariborz Jahanian | 63ca8ae | 2007-09-17 21:07:36 +0000 | [diff] [blame] | 337 | memcpy(ProtoInsMethods, insMethods, numInsMembers*sizeof(ObjcMethodDecl*)); |
| 338 | } |
| 339 | NumProtoClsMethods = numClsMembers; |
| 340 | if (numClsMembers) { |
Fariborz Jahanian | 4a2b0ac | 2007-09-17 22:36:42 +0000 | [diff] [blame] | 341 | ProtoClsMethods = new ObjcMethodDecl*[numClsMembers]; |
Fariborz Jahanian | 63ca8ae | 2007-09-17 21:07:36 +0000 | [diff] [blame] | 342 | memcpy(ProtoClsMethods, clsMethods, numClsMembers*sizeof(ObjcMethodDecl*)); |
| 343 | } |
| 344 | } |
| 345 | |
Fariborz Jahanian | f25220e | 2007-09-18 20:26:58 +0000 | [diff] [blame] | 346 | /// ObjcAddCat - Insert instance and methods declarations into |
| 347 | /// ObjcProtocolDecl's CatInsMethods and CatClsMethods fields. |
| 348 | /// |
| 349 | void ObjcCategoryDecl::ObjcAddCatMethods(ObjcMethodDecl **insMethods, |
| 350 | unsigned numInsMembers, |
| 351 | ObjcMethodDecl **clsMethods, |
| 352 | unsigned numClsMembers) { |
| 353 | NumCatInsMethods = numInsMembers; |
| 354 | if (numInsMembers) { |
| 355 | CatInsMethods = new ObjcMethodDecl*[numInsMembers]; |
| 356 | memcpy(CatInsMethods, insMethods, numInsMembers*sizeof(ObjcMethodDecl*)); |
| 357 | } |
| 358 | NumCatClsMethods = numClsMembers; |
| 359 | if (numClsMembers) { |
| 360 | CatClsMethods = new ObjcMethodDecl*[numClsMembers]; |
| 361 | memcpy(CatClsMethods, clsMethods, numClsMembers*sizeof(ObjcMethodDecl*)); |
| 362 | } |
| 363 | } |
| 364 | |
Fariborz Jahanian | 1e4e82f | 2007-09-27 18:57:03 +0000 | [diff] [blame] | 365 | /// ObjcAddImplMethods - Insert instance and methods declarations into |
| 366 | /// ObjcImplementationDecl's InsMethods and ClsMethods fields. |
| 367 | /// |
| 368 | void ObjcImplementationDecl::ObjcAddImplMethods(ObjcMethodDecl **insMethods, |
| 369 | unsigned numInsMembers, |
| 370 | ObjcMethodDecl **clsMethods, |
| 371 | unsigned numClsMembers) { |
| 372 | NumInsMethods = numInsMembers; |
| 373 | if (numInsMembers) { |
| 374 | InsMethods = new ObjcMethodDecl*[numInsMembers]; |
| 375 | memcpy(InsMethods, insMethods, numInsMembers*sizeof(ObjcMethodDecl*)); |
| 376 | } |
| 377 | NumClsMethods = numClsMembers; |
| 378 | if (numClsMembers) { |
| 379 | ClsMethods = new ObjcMethodDecl*[numClsMembers]; |
| 380 | memcpy(ClsMethods, clsMethods, numClsMembers*sizeof(ObjcMethodDecl*)); |
| 381 | } |
| 382 | } |
| 383 | |
Fariborz Jahanian | 63ca8ae | 2007-09-17 21:07:36 +0000 | [diff] [blame] | 384 | |