117
174
CLanguage _Language;
120
CStructure *_QualScope; // != 0 only in CAttributeInfo, CFunctionInfo, and CRecord
121
CStructure *_AssignedScope; // -real- scope of friend classes
177
/** Qualified name scope. Set only for CAttributeInfo,
178
* CFunctionInfo, and CRecord. */
179
CStructure *_QualScope;
180
/** The scope of a friend class or function. This is not
181
* the scope in which the friend class or function
182
* was declared. A friend function of a class may be declared
183
* first inside the scope of a class definition. But the
184
* declared function does not belong to this scope. In fact
185
* it belongs to the nearest non-class scope (usually the
186
* file scope). This is the assigned scope. */
187
CStructure *_AssignedScope;
188
/** Set of semantic objects connected to this object in
122
190
Array<CStructure*> _Registered;
127
// compares the addresses of this and all linked objects
128
// to determine whether two objects denote the same entity
196
/** Compare the addresses of this object and all objects
197
* linked to this object with the address of the given
199
* \return True if the addresses are the same and thus
200
* the given object describes the same entity. */
129
201
bool operator ==(const CObjectInfo &) const;
202
/** Compare the addresses of this object and all objects
203
* linked to this object with the address of the given
205
* \return True if the addresses are different and thus
206
* the given object does not describe the same entity. */
130
207
bool operator !=(const CObjectInfo &) const;
132
// ask the object info type
209
/** Get a pointer to CObjectInfo for any semantic object type. */
133
210
CObjectInfo *ObjectInfo () const;
211
/** Return a pointer to CLabelInfo if the entity is a label.
212
* The object type has to be one of:
213
* \li CObjectInfo::LABEL_INFO
215
* \return The valid pointer or NULL. */
134
216
CLabelInfo *LabelInfo () const;
217
/** Return a pointer to CMemberAliasInfo if the entity is a member alias.
218
* The object type has to be one of:
219
* \li CObjectInfo::MEMBERALIAS_INFO
221
* \return The valid pointer or NULL. */
135
222
CMemberAliasInfo *MemberAliasInfo () const;
223
/** Return a pointer to CBaseClassInfo if the entity is a base class specifier.
224
* The object type has to be one of:
225
* \li CObjectInfo::BASECLASS_INFO
227
* \return The valid pointer or NULL. */
136
228
CBaseClassInfo *BaseClassInfo () const;
229
/** Return a pointer to CUsingInfo if the entity is a using-directive.
230
* The object type has to be one of:
231
* \li CObjectInfo::USING_INFO
233
* \return The valid pointer or NULL. */
137
234
CUsingInfo *UsingInfo () const;
235
/** Return a pointer to CTypedefInfo if the entity is a typedef.
236
* The object type has to be one of:
237
* \li CObjectInfo::TYPEDEF_INFO
239
* \return The valid pointer or NULL. */
138
240
CTypedefInfo *TypedefInfo () const;
241
/** Return a pointer to CArgumentInfo if the entity is a function parameter.
242
* The object type has to be one of:
243
* \li CObjectInfo::ARGUMENT_INFO
245
* \return The valid pointer or NULL. */
139
246
CArgumentInfo *ArgumentInfo () const;
247
/** Return a pointer to CAttributeInfo if the entity is an object or
248
* enumeration constant.
249
* The object type has to be one of:
250
* \li CObjectInfo::ATTRIBUTE_INFO
251
* \li CObjectInfo::ENUMERATOR_INFO
253
* \return The valid pointer or NULL. */
140
254
CAttributeInfo *AttributeInfo () const;
255
/** Return a pointer to CTemplateParemInfo if the entity is a template parameter.
256
* The object type has to be one of:
257
* \li CObjectInfo::TEMPLATE_PARAM_INFO
259
* \return The valid pointer or NULL. */
141
260
CTemplateParamInfo *TemplateParamInfo () const;
261
/** Return a pointer to CStructure if the entity is a namespace, class,
262
* function, or any other construct that can contain other entities.
263
* The object type has to be one of:
264
* \li CObjectInfo::NAMESPACE_INFO
265
* \li CObjectInfo::FILE_INFO
266
* \li CObjectInfo::CLASS_INFO
267
* \li CObjectInfo::CLASS_INSTANCE_INFO
268
* \li CObjectInfo::UNION_INFO
269
* \li CObjectInfo::UNION_INSTANCE_INFO
270
* \li CObjectInfo::FUNCTION_INFO,
271
* \li CObjectInfo::FCT_INSTANCE_INFO
272
* \li CObjectInfo::TEMPLATE_INFO
273
* \li CObjectInfo::LOCAL_INFO
275
* \return The valid pointer or NULL. */
142
276
CStructure *Structure () const;
277
/** Return a pointer to CFileInfo if this is the file scope.
278
* The object type has to be one of:
279
* \li CObjectInfo::FILE_INFO
281
* \return The valid pointer or NULL. */
143
282
CFileInfo *FileInfo () const;
283
/** Return a pointer to CRecord if the entity is a class or union.
284
* The object type has to be one of:
285
* \li CObjectInfo::CLASS_INFO
286
* \li CObjectInfo::CLASS_INSTANCE_INFO
287
* \li CObjectInfo::UNION_INFO
288
* \li CObjectInfo::UNION_INSTANCE_INFO
290
* \return The valid pointer or NULL. */
144
291
CRecord *Record () const;
292
/** Return a pointer to CLocalScope if the entity is a local scope
294
* The object type has to be one of:
295
* \li CObjectInfo::LOCAL_INFO
297
* \return The valid pointer or NULL. */
145
298
CLocalScope *LocalScope () const;
299
/** Return a pointer to CScopeInfo if the entity defines a scope.
300
* The object type has to be one of:
301
* \li CObjectInfo::NAMESPACE_INFO
302
* \li CObjectInfo::FILE_INFO
303
* \li CObjectInfo::CLASS_INFO
304
* \li CObjectInfo::CLASS_INSTANCE_INFO
305
* \li CObjectInfo::UNION_INFO
306
* \li CObjectInfo::UNION_INSTANCE_INFO
307
* \li CObjectInfo::FUNCTION_INFO
308
* \li CObjectInfo::FCT_INSTANCE_INFO
309
* \li CObjectInfo::TEMPLATE_INFO
310
* \li CObjectInfo::LOCAL_INFO
312
* \return The valid pointer or NULL. */
146
313
CScopeInfo *ScopeInfo () const;
314
/** Return a pointer to CClassInfo if the entity is a class.
315
* The object type has to be one of:
316
* \li CObjectInfo::CLASS_INFO
317
* \li CObjectInfo::CLASS_INSTANCE_INFO
319
* \return The valid pointer or NULL. */
147
320
CClassInfo *ClassInfo () const;
321
/** Return a pointer to CUnionInfo if the entity is a union.
322
* The object type has to be one of:
323
* \li CObjectInfo::UNION_INFO
324
* \li CObjectInfo::UNION_INSTANCE_INFO
326
* \return The valid pointer or NULL. */
148
327
CUnionInfo *UnionInfo () const;
328
/** Return a pointer to CEnumInfo if the entity is an enumeration.
329
* The object type has to be one of:
330
* \li CObjectInfo::ENUM_INFO
332
* \return The valid pointer or NULL. */
149
333
CEnumInfo *EnumInfo () const;
334
/** Return a pointer to CFunctionInfo if the entity is a function,
335
* method, or overloaded operator.
336
* The object type has to be one of:
337
* \li CObjectInfo::FUNCTION_INFO
338
* \li CObjectInfo::FCT_INSTANCE_INFO
340
* \return The valid pointer or NULL. */
150
341
CFunctionInfo *FunctionInfo () const;
342
/** Return a pointer to CNamespaceInfo if the entity is a namespace.
343
* The object type has to be one of:
344
* \li CObjectInfo::NAMESPACE_INFO
345
* \li CObjectInfo::FILE_INFO
347
* \return The valid pointer or NULL. */
151
348
CNamespaceInfo *NamespaceInfo () const;
349
/** Return a pointer to CEnumeratorInfo if the entity is an
350
* enumeration constant.
351
* The object type has to be one of:
352
* \li CObjectInfo::ENUMERATOR_INFO
354
* \return The valid pointer or NULL. */
152
355
CEnumeratorInfo *EnumeratorInfo () const;
356
/** Return a pointer to CTemplateInfo if the entity is a template.
357
* The object type has to be one of:
358
* \li CObjectInfo::TEMPLATE_INFO
360
* \return The valid pointer or NULL. */
153
361
CTemplateInfo *TemplateInfo () const;
362
/** Return a pointer to CClassInstance if the entity is an instance
363
* of a class template.
364
* The object type has to be one of:
365
* \li CObjectInfo::CLASS_INSTANCE_INFO
367
* \return The valid pointer or NULL. */
154
368
CClassInstance *ClassInstance () const;
369
/** Return a pointer to CFctInstance if the entity is an instance
370
* of a function template.
371
* The object type has to be one of:
372
* \li CObjectInfo::FCT_INSTANCE_INFO
374
* \return The valid pointer or NULL. */
155
375
CFctInstance *FctInstance () const;
376
/** Return a pointer to CUnionInstance if the entity is an instance
377
* of a union template.
378
* The object type has to be one of:
379
* \li CObjectInfo::UNION_INSTANCE_INFO
381
* \return The valid pointer or NULL. */
156
382
CUnionInstance *UnionInstance () const;
384
/** Return a pointer to CTemplateInfo if the entity is a template.
385
* The object type has to be one of:
386
* \li CObjectInfo::CLASS_INFO
387
* \li CObjectInfo::UNION_INFO
388
* \li CObjectInfo::FUNCTION_INFO
389
* \li CObjectInfo::TEMPLATE_PARAM_INFO
391
* \return The valid pointer or NULL. */
392
CTemplateInfo *Template () const;
393
/** Return a pointer to CTemplateInstance if the entity is an
394
* instance of a class or function template.
395
* The object type has to be one of:
396
* \li CObjectInfo::CLASS_INSTANCE_INFO
397
* \li CObjectInfo::UNION_INSTANCE_INFO
398
* \li CObjectInfo::FCT_INSTANCE_INFO
400
* \return The valid pointer or NULL. */
157
401
CTemplateInstance *TemplateInstance () const;
403
/** Get the scope in which the entity was declared. */
404
CScopeInfo *Scope () const;
405
/** Get the scope of qualified names. The scope of a class member
406
* for instance is the corresponding class. If a function is declared
407
* in a namespace, then the qualified scope is that namespace. */
408
CStructure *QualifiedScope () const;
409
/** Get the class containing the class member described by this object.
410
* The object type has to be one of:
411
* \li CObjectInfo::FUNCTION_INFO
412
* \li CObjectInfo::FCT_INSTANCE_INFO
413
* \li CObjectInfo::ATTRIBUTE_INFO
414
* \li CObjectInfo::ENUMERATOR_INFO
416
* \return The class or union, or NULL if not a member of a class or union. */
158
417
CRecord *ClassScope () const;
418
/** Get the scope of a friend class or function. This is not
419
* the scope in which the friend class or function
420
* was declared. A friend function of a class may be declared
421
* first inside the scope of a class definition. But the
422
* declared function does not belong to this scope. In fact
423
* it belongs to the nearest non-class scope (usually the
424
* file scope). This is the assigned scope.
425
* \return The assigned scope or NULL. */
426
CStructure *AssignedScope () const;
428
/** Get the type of this semantic object. */
161
429
ObjectId Id () const;
430
/** Get the name of entity described by this semantic object. */
162
431
const DString& Name () const;
163
const char *QualName (bool abs = false, // created on demand
165
CObjectInfo *DefObject () const; // info of the definition
432
/** Get the qualified name of the entity described by this semantic object.
433
* \param abs Create root qualified name (like ::X::Y::Z).
434
* \param tdef Insert the name of a typedef instead of the named type. */
435
const char *QualName (bool abs = false, bool tdef = false);
436
/** Get the semantic information object for the definition of an entity.
437
* Some entities, like functions and classes, can be declared several
438
* times before a definition of the entity appears. The semantic objects
439
* for the definition and declarations are linked. This method searches
440
* the linked semantic objects for the semantic object of the definition
442
* \return The semantic object for the definition or this object if
443
* no definition found. */
444
CObjectInfo *DefObject () const;
445
/** Get the data type of the entity. */
166
446
CTypeInfo *TypeInfo () const;
167
CScopeInfo *Scope () const; // enclosing scope
168
CStructure *QualifiedScope () const; // scope of qualified names
169
CSourceInfo *SourceInfo () const; // location in source file
170
CClassDatabase *ClassDB () const;
447
/** Get the source file information. Contains the position and token
448
* of the entity in the source file. */
449
CSourceInfo *SourceInfo () const;
450
/** Get the semantic information database object containing this
452
* \deprecated Use CObjectInfo::SemDB() instead. */
453
CSemDatabase *ClassDB () const;
454
/** Get the semantic information database object containing this
455
* semantic object. */
456
CSemDatabase *SemDB () const;
457
/** Get the syntax tree node for the entity described by this
458
* semantic object. */
171
459
CTree *Tree () const;
172
CObjectInfo *NextObject () const; // next linked object
173
CObjectInfo *PrevObject () const; // previous linked object
174
bool isAnonymous () const; // has only a private name?
460
/** Get the next semantic object linked with this object. Usually
461
* the definition and the declarations of an entity are linked. */
462
CObjectInfo *NextObject () const;
463
/** Get the previous semantic object linked with this object. Usually
464
* the definition and the declarations of an entity are linked. */
465
CObjectInfo *PrevObject () const;
466
/** Get the semantic object for the base class entity this entity
468
* \note Not yet implemented!
469
* \return Always returns NULL. */
470
CObjectInfo *BaseObject () const;
471
/** Get the initializer of the entity.
472
* \return The initializer expression or NULL if no initializer. */
473
CT_ExprList *Init () const;
474
/** Get the member protection of the entity, if it is a class member. */
475
CProtection::Type Protection () const;
476
/** Get the linkage of the entity. */
477
CLinkage::Type Linkage () const;
478
/** Get the storage class of the entity. */
479
CStorage::Type Storage () const;
480
/** Get the entity encoding language. */
481
const CLanguage &Language () const;
482
/** Get the entity encoding language. */
483
CLanguage &Language ();
485
/** Check if the entity is anonymous (has no explicit name). */
486
bool isAnonymous () const;
487
/** Check if the entity is a class or function template, or a
488
* template template parameter. */
175
489
bool isTemplate () const;
490
/** Check if the entity is a class or function template instance. */
176
491
bool isTemplateInstance () const;
177
bool isBuiltin () const; // has no tree?
178
bool isClassMember () const; // is method or data member?
179
CTemplateInfo *Template () const; // template info of template
180
CObjectInfo *BaseObject () const; // base class object; not yet set
181
CT_ExprList *Init () const; // get initializer (if any)
182
CProtection::Type Protection () const; // member access level
183
CLinkage::Type Linkage () const; // object linkage
184
CStorage::Type Storage () const; // storage duration
185
const CLanguage &Language () const; // entity encoding language
186
CLanguage &Language (); // entity encoding language
187
bool isVirtual () const; // defined virtual?
188
bool isStatic () const; // defined static?
189
bool isExtern () const; // defined extern?
190
bool isMutable () const; // defined mutable?
191
bool isRegister () const; // defined register?
192
bool isExplicit () const; // defined explicit?
193
bool isInline () const; // defined inline?
194
bool isAuto () const; // defined auto?
195
CStructure *AssignedScope () const;
196
bool isRegistered (const CStructure*) const;
492
/** Check if the entity describes a built-in type or function.
493
* In this case the entity has no syntax tree (Tree() returns NULL). */
494
bool isBuiltin () const;
495
/** Check if the entity is a method or data member of a class. */
496
bool isClassMember () const;
497
/** Check if the entity is declared \e virtual. */
498
bool isVirtual () const;
499
/** Check if the entity is declared \e static. */
500
bool isStatic () const;
501
/** Check if the entity is declared \e extern. */
502
bool isExtern () const;
503
/** Check if the entity is declared \e mutable. */
504
bool isMutable () const;
505
/** Check if the entity is declared \e register. */
506
bool isRegister () const;
507
/** Check if the entity is declared \e explicit. */
508
bool isExplicit () const;
509
/** Check if the entity is declared \e inline. */
510
bool isInline () const;
511
/** Check if the entity is declared \e auto. */
512
bool isAuto () const;
513
/** Check if the given semantic object is registered as
514
* being connected to this semantic object in any way.
515
* \param s The semantic object. */
516
bool isRegistered (const CStructure* s) const;
518
/** Set the name of the entity.
519
* \param s The name. */
199
520
void Name (const char* s) { Name(DString(s==0?"":s)); }
200
void Name (const DString&);
201
void TypeInfo (CTypeInfo *);
202
void BaseObject (CObjectInfo *);
203
void Protection (CProtection::Type);
204
void Linkage (CLinkage::Type);
205
void Storage (CStorage::Type);
206
void FileInfo (CFileInfo *);
208
void ClassDB (CClassDatabase *);
521
/** Set the name of the entity.
522
* \param ds The name. */
523
void Name (const DString& ds);
524
/** Set the type of the entity.
525
* \param type The type information. */
526
void TypeInfo (CTypeInfo *type);
527
/** Set the base class object for the entity this entity overloads.
528
* \param base The base object. */
529
void BaseObject (CObjectInfo *base);
530
/** Set the member access protection of the entity.
531
* \param p The protection. */
532
void Protection (CProtection::Type p);
533
/** Set the linkage of the entity.
534
* \param l The linkage. */
535
void Linkage (CLinkage::Type l);
536
/** Set the storage class of the entity.
537
* \param s The storage class. */
538
void Storage (CStorage::Type s);
539
/** Set the source file information for the entity.
540
* \param finfo The file information. */
541
void FileInfo (CFileInfo *finfo);
542
/** Set the syntax tree node of the entity.
543
* \param tree The syntax tree node. */
544
void Tree (CTree *tree);
545
/** Set the semantic information database object containing
546
* this semantic object.
547
* \deprecated Use CObjectInfo::SemDB(CSemDatabase*) instead.
548
* \param db The semantic database. */
549
void ClassDB (CSemDatabase *db);
550
/** Set the semantic information database object containing
551
* this semantic object.
552
* \param db The semantic database. */
553
void SemDB (CSemDatabase *db);
554
/** Set that only the members of this semantic object are destroyed
555
* in the destructor. Otherwise it is also tried to remove all
556
* references to this object in other semantic objects. */
209
557
void DeleteMembersOnly ();
210
void NextObject (CObjectInfo *);
211
void PrevObject (CObjectInfo *);
558
/** Set the link to next semantic object. Usually the semantic objects
559
* for the definition and declaration of an entity are linked.
560
* \param obj The next object in the chain. */
561
void NextObject (CObjectInfo *obj);
562
/** Set the link to next semantic object. Usually the semantic objects
563
* for the definition and declaration of an entity are linked.
564
* \param obj The previous object in the chain. */
565
void PrevObject (CObjectInfo *obj);
566
/** Unlink this semantic object. Usually the semantic objects
567
* for the definition and declaration of an entity are linked.
568
* This method removes this object from the chain. */
213
void Register (CStructure *);
214
void Unregister (CStructure *);
215
void isVirtual (bool);
216
void isStatic (bool);
217
void isExtern (bool);
218
void isMutable (bool);
219
void isRegister (bool);
220
void isExplicit (bool);
221
void isInline (bool);
223
void AssignedScope (CStructure *);
570
/** Register the given semantic object as being connected to
571
* this semantic object in any way.
572
* \param s The semantic object. */
573
void Register (CStructure *s);
574
/** Unregister the given semantic object as being connected to
575
* this semantic object in any way.
576
* \param s The semantic object. */
577
void Unregister (CStructure *s);
578
/** Set whether the entity was declared \e virtual.
579
* \param v True for yes, false for no. */
580
void isVirtual (bool v);
581
/** Set whether the entity was declared \e static.
582
* \param v True for yes, false for no. */
583
void isStatic (bool v);
584
/** Set whether the entity was declared \e extern.
585
* \param v True for yes, false for no. */
586
void isExtern (bool v);
587
/** Set whether the entity was declared \e mutable.
588
* \param v True for yes, false for no. */
589
void isMutable (bool v);
590
/** Set whether the entity was declared \e register.
591
* \param v True for yes, false for no. */
592
void isRegister (bool v);
593
/** Set whether the entity was declared \e explicit.
594
* \param v True for yes, false for no. */
595
void isExplicit (bool v);
596
/** Set whether the entity was declared \e inline.
597
* \param v True for yes, false for no. */
598
void isInline (bool v);
599
/** Set whether the entity was declared \e auto.
600
* \param v True for yes, false for no. */
601
void isAuto (bool v);
602
/** Set the assigned scope of the entity. This is the scope of
603
* a friend class or function. It is not the scope in which the
604
* friend class or function was declared. A friend function of
605
* a class may be declared first inside the scope of a class
606
* definition. But the declared function does not belong to
607
* this scope. In fact it belongs to the nearest non-class scope
608
* (usually the file scope). This is the assigned scope.
609
* \param s The assigned scope. */
610
void AssignedScope (CStructure *s);
226
CObjectInfo (ObjectId);
614
* \param id The semantic object type. */
615
CObjectInfo (ObjectId id);
617
/** Clean up the semantic object. This is usually done before
618
* the semantic object is destroyed. */