~ubuntu-branches/ubuntu/wily/aspectc++/wily

« back to all changes in this revision

Viewing changes to Puma/gen-release/step1/src/CFunctionInfo.cc

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-06-15 10:17:02 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090615101702-qsr30iptwbxylmo2
Tags: 1.0pre4~svn.20090615-1
* New upstream release.
* don't ignore errors in the postrm script
* avoid spurious creation of empty dir ./usr/sbin/
* improve short descriptions of libpuma-doc and libpuma-dev
* bump Standards-Version to 3.8.1
* bump debhelper compat level to level 7 (latest in stable)

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
  CObjectInfo *o = (CObjectInfo*)this;
172
172
  do {
173
173
    if (o->Tree () && o->Tree ()->NodeName () == CT_FctDef::NodeId ())
174
 
      if (! (o->TemplateInstance () && o->TemplateInstance ()->isPseudoInstance ()))
 
174
      if (! o->TemplateInstance () || o->TemplateInstance ()->canInstantiate ())
175
175
        return o->FunctionInfo ();
176
176
    o = o->NextObject ();
177
177
  } while (o != (CObjectInfo*)this);
210
210
  // first the names are compared
211
211
  if (Name () != fi->Name ())
212
212
    return false;
213
 
    
 
213
 
214
214
  // now the argument types are checked
215
215
  CTypeList *my_types    = TypeInfo ()->TypeFunction ()->ArgTypes ();
216
216
  CTypeList *other_types = fi->TypeInfo ()->TypeFunction ()->ArgTypes ();
228
228
  // the function has to be a non-static member function
229
229
  if (!isMethod () || isStaticMethod ())
230
230
    return false;
231
 
    
 
231
 
232
232
  CClassInfo *cls = TypeInfo ()->TypeFunction ()->Record ()->ClassInfo ();
233
233
  return cls->overridesVirtual (this);
234
234
}
235
235
 
 
236
/** Check if this is a default constructor. */
 
237
bool CFunctionInfo::isDefaultConstructor () const {
 
238
  // §12.1p5
 
239
  // A default constructor for a class X is a constructor of class X
 
240
  // that can be called without an argument.
 
241
  if (! isConstructor ())
 
242
    return false;
 
243
  // check the parameters
 
244
  for (unsigned i = 0; i < Arguments (); i++)
 
245
    if (! Argument (i)->hasDefaultArg ())
 
246
      return false;
 
247
  return true;
 
248
}
 
249
 
 
250
/** Check if this is a copy constructor. */
 
251
bool CFunctionInfo::isCopyConstructor () const {
 
252
  // §12.8p2
 
253
  // A non-template constructor for class X is a copy constructor if its
 
254
  // first parameter is of type X&, const X&, volatile X& or const volatile X&,
 
255
  // and either there are no other parameters or else all other parameters have
 
256
  // default arguments.
 
257
  if (! isConstructor () || isTemplate () || Arguments () == 0)
 
258
    return false;
 
259
 
 
260
  // get class
 
261
  CRecord* c = Record ();
 
262
  if (! c)
 
263
    return false;
 
264
 
 
265
  // check first parameter
 
266
  CTypeInfo* arg = Argument ((unsigned)0)->TypeInfo ();
 
267
  if (! arg->isAddress () ||
 
268
      ! arg->isClassOrUnion () ||
 
269
      *arg->VirtualType ()->TypeRecord () != *c->TypeInfo ())
 
270
    return false;
 
271
 
 
272
  // check the other parameters
 
273
  for (unsigned i = 1; i < Arguments (); i++)
 
274
    if (! Argument (i)->hasDefaultArg ())
 
275
      return false;
 
276
  return true;
 
277
}
 
278
 
 
279
/** Check if this is a copy assignment operator. */
 
280
bool CFunctionInfo::isCopyAssignOperator () const {
 
281
  // 12.8p9
 
282
  // A copy assignment operator X::operator= is a non-static non-template
 
283
  // member function of class X with exactly one parameter of type X, X&,
 
284
  // const X&, volatile X& or const volatile X&.
 
285
  if (! isOperator () || isStatic () || isTemplate () || Arguments () != 1)
 
286
    return false;
 
287
 
 
288
  // assignment operator
 
289
  if (Name ().c_str () && strcmp (Name ().c_str (), "operator =") != 0)
 
290
    return false;
 
291
 
 
292
  // get class
 
293
  CRecord* c = Record ();
 
294
  if (! c)
 
295
    return false;
 
296
 
 
297
  // check parameter
 
298
  CTypeInfo* arg = Argument ((unsigned)0)->TypeInfo ();
 
299
  if (! arg->isClassOrUnion ())
 
300
    return false;
 
301
  if (arg->isAddress () && *arg->VirtualType ()->TypeRecord () == *c->TypeInfo ())
 
302
    return true;
 
303
  if (arg->TypeRecord () && *arg->TypeRecord () == *c->TypeInfo ())
 
304
    return true;
 
305
  return false;
 
306
}
 
307
 
236
308
} // namespace Puma