~ubuntu-branches/ubuntu/jaunty/aspectc++/jaunty

« back to all changes in this revision

Viewing changes to Puma/src/infos/CObjectInfo.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-07-07 14:41:02 UTC
  • mfrom: (1.1.3 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080707144102-lzml7t07f3sl00r5
Tags: 1.0pre4~svn.20080711-1
* new upstream snapshot.
* include all upstream documentation. Clarifying emails regarding
  licensing has been included into debian/copyright.
* reformat description following recomendations of
  http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description
  (Closes: #480316)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#ifndef __CObjectInfo_h__
20
20
#define __CObjectInfo_h__
21
21
 
22
 
// base class of all semantic infos
23
 
// knows the type of the info, the name of the entity it
24
 
// represents, its qualified name (on demand), its type,
25
 
// its object linkage, its storage duration, its class
26
 
// member access level (protection), and the specifiers 
27
 
// that were used at the declaration of the entity,
28
 
// knows the source file location of the entity's declaration,
29
 
// the corresponding syntax tree node, the class database 
30
 
// it belongs to, and other semantic info objects that refer
31
 
// to the same entity
 
22
/** \file
 
23
 *  Basic semantic information class. */
32
24
 
33
25
#include "Puma/CSourceInfo.h"
34
26
#include "Puma/CProtection.h"
66
58
class CClassInstance;
67
59
class CUnionInstance;
68
60
class CFctInstance;
69
 
class CClassDatabase;
 
61
class CSemDatabase;
70
62
class CTree;
71
63
class CT_ExprList;
72
64
class CTemplateInstance;
73
65
 
 
66
 
 
67
/** \class CObjectInfo CObjectInfo.h Puma/CObjectInfo.h 
 
68
 *  Abstract base class of all semantic information classes.
 
69
 *  Provides all semantic information about an entity (class,
 
70
 *  function, object, etc). 
 
71
 *
 
72
 *  A semantic object is identified by its object ID. %Semantic
 
73
 *  information objects for the same kind of entity have the
 
74
 *  same object ID (like object ID CObjectInfo::FUNCTION_INFO
 
75
 *  for all semantic objects of functions). 
 
76
 * 
 
77
 *  Example:
 
78
 *
 
79
 *  \code 
 
80
 * // check if sem_obj is a semantic object for a function
 
81
 * if (sem_obj.Id() == Puma::CObjectInfo::FUNCTION_INFO) {
 
82
 *   ...
 
83
 * }
 
84
 * // same check
 
85
 * if (sem_obj.FunctionInfo()) {
 
86
 *   ...
 
87
 * }
 
88
 *  \endcode 
 
89
 *
 
90
 *  %Semantic information objects are created by the semantic
 
91
 *  analysis component of %Puma (see Puma::Semantic) during 
 
92
 *  the parse process and are collected in the semantic
 
93
 *  information database (see Puma::CSemDatabase). 
 
94
 *
 
95
 *  There are several relations between the semantic objects 
 
96
 *  forming the semantic tree. There is one semantic tree for 
 
97
 *  each translation unit. 
 
98
 *
 
99
 *  The root of the semantic tree usually is the semantic 
 
100
 *  object for the file scope (see Puma::CFileInfo). It contains 
 
101
 *  all the other scopes of the analysed source file, such 
 
102
 *  as namespaces and class definitions, function definitions, 
 
103
 *  global variables, and so on. The semantic tree is destroyed 
 
104
 *  by destroying the root object of the tree. This recursively 
 
105
 *  destroys all sub-objects of the tree. */
74
106
class CObjectInfo {
75
 
protected:
 
107
public:
 
108
  /** %Semantic information object types. */
76
109
  enum ObjectId {
 
110
    /** %Semantic information about the file scope. */
77
111
    FILE_INFO, 
 
112
    /** %Semantic information about a union. */
78
113
    UNION_INFO, 
 
114
    /** %Semantic information about a class. */
79
115
    CLASS_INFO,
 
116
    /** %Semantic information about a base class specifier. */
80
117
    BASECLASS_INFO,
 
118
    /** %Semantic information about class/namespace member alias. */
81
119
    MEMBERALIAS_INFO,
 
120
    /** %Semantic information about an enumeration. */
82
121
    ENUM_INFO, 
 
122
    /** %Semantic information about a typedef. */
83
123
    TYPEDEF_INFO, 
 
124
    /** %Semantic information about a function, method, or overloaded operator. */
84
125
    FUNCTION_INFO, 
 
126
    /** %Semantic information about a label. */
85
127
    LABEL_INFO,
 
128
    /** %Semantic information about an enumerator constant. */
86
129
    ENUMERATOR_INFO,
 
130
    /** %Semantic information about an object (variables etc). */
87
131
    ATTRIBUTE_INFO, 
 
132
    /** %Semantic information about a template parameter. */
88
133
    TEMPLATE_PARAM_INFO,
 
134
    /** %Semantic information about a class or function template. */
89
135
    TEMPLATE_INFO,
 
136
    /** %Semantic information about an instance of a class template. */
90
137
    CLASS_INSTANCE_INFO,
 
138
    /** %Semantic information about an instance of a union template. */
91
139
    UNION_INSTANCE_INFO,
 
140
    /** %Semantic information about an instance of a function template. */
92
141
    FCT_INSTANCE_INFO,
 
142
    /** %Semantic information about a function parameter. */
93
143
    ARGUMENT_INFO, 
 
144
    /** %Semantic information about a local scope (block scope). */
94
145
    LOCAL_INFO, 
 
146
    /** %Semantic information about a named or anonymous namespace. */
95
147
    NAMESPACE_INFO,
 
148
    /** %Semantic information about a using declaration. */
96
149
    USING_INFO
97
150
  };
98
151
 
 
152
protected:
 
153
  /** If true than only the members are destroyed in the destructor.
 
154
   *  Otherwise it is also tried to remove all references to this 
 
155
   *  object in other semantic objects. */
99
156
  bool               _DeleteMembersOnly;
100
157
  
101
158
private:
106
163
  CObjectInfo       *_BaseObject;       // corresponding object of base class
107
164
  CObjectInfo       *_Next;             // next linked object
108
165
  CObjectInfo       *_Prev;             // previous linked object
109
 
  CClassDatabase    *_ClassDB;
 
166
  CSemDatabase      *_SemDB;
110
167
  CTree             *_Tree;             // corresponding syntax tree
111
168
  ObjectId           _Id;               // object type
112
169
  CSpecifiers        _Specifiers;
117
174
  CLanguage          _Language;
118
175
 
119
176
protected:
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
 
189
   *  any way. */
122
190
  Array<CStructure*> _Registered;         
123
191
  
124
192
public: 
 
193
  /** Destructor. */
125
194
  ~CObjectInfo ();
126
195
  
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 
 
198
   *  object.
 
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 
 
204
   *  object.
 
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;
131
208
 
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
 
214
   * 
 
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
 
220
   *
 
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 
 
226
   *
 
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
 
232
   *
 
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
 
238
   *
 
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
 
244
   *
 
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
 
252
   *
 
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
 
258
   *
 
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
 
274
   *
 
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
 
280
   *
 
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
 
289
   *
 
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
 
293
   *  (block scope).
 
294
   *  The object type has to be one of:
 
295
   *  \li CObjectInfo::LOCAL_INFO
 
296
   *
 
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
 
311
   *
 
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
 
318
   *
 
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
 
325
   *
 
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
 
331
   *
 
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
 
339
   *
 
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
 
346
   *
 
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
 
353
   *
 
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
 
359
   *
 
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
 
366
   *
 
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
 
373
   *
 
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
 
380
   *
 
381
   *  \return The valid pointer or NULL. */
156
382
  CUnionInstance     *UnionInstance () const; 
 
383
 
 
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
 
390
   *
 
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
 
399
   *
 
400
   *  \return The valid pointer or NULL. */
157
401
  CTemplateInstance  *TemplateInstance () const;
 
402
  
 
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 
 
415
   *
 
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; 
159
427
 
160
 
  // Get ...
 
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
164
 
                                bool tdef = false);
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
 
441
   *  of the entity.
 
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
 
451
   *  semantic object. 
 
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
 
467
   *  is overloading. 
 
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 ();
 
484
 
 
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;
197
517
 
198
 
  // Set ...
 
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 *);
207
 
  void                Tree (CTree *);    
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. */
212
569
  void                Unlink (); 
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);
222
 
  void                isAuto (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);
224
611
 
225
612
protected:  
226
 
  CObjectInfo (ObjectId);
 
613
  /** Constructor.
 
614
   *  \param id The semantic object type. */
 
615
  CObjectInfo (ObjectId id);
227
616
 
 
617
  /** Clean up the semantic object. This is usually done before
 
618
   *  the semantic object is destroyed. */
228
619
  void CleanUp ();
229
620
};
230
621
 
236
627
  _BaseObject        ((CObjectInfo*)0),
237
628
  _Next              ((CObjectInfo*)this),
238
629
  _Prev              ((CObjectInfo*)this),
239
 
  _ClassDB           ((CClassDatabase*)0),
 
630
  _SemDB             ((CSemDatabase*)0),
240
631
  _Tree              ((CTree*)0),
241
632
  _Id                (id),
242
633
  _Protection        (CProtection::PROT_NONE), 
272
663
 { return _BaseObject; }
273
664
inline CTree *CObjectInfo::Tree () const 
274
665
 { return _Tree; }
275
 
inline CClassDatabase *CObjectInfo::ClassDB () const
276
 
 { return _ClassDB; }
 
666
inline CSemDatabase *CObjectInfo::ClassDB () const
 
667
 { return _SemDB; }
 
668
inline CSemDatabase *CObjectInfo::SemDB () const
 
669
 { return _SemDB; }
277
670
inline CT_ExprList *CObjectInfo::Init () const 
278
671
 { return (CT_ExprList*)0; }
279
672
 
287
680
 { _BaseObject = info; }
288
681
inline void CObjectInfo::Tree (CTree *t)    
289
682
 { _Tree = t; }
290
 
inline void CObjectInfo::ClassDB (CClassDatabase *db) 
291
 
 { _ClassDB = db; }
 
683
inline void CObjectInfo::ClassDB (CSemDatabase *db) 
 
684
 { _SemDB = db; }
 
685
inline void CObjectInfo::SemDB (CSemDatabase *db) 
 
686
 { _SemDB = db; }
292
687
inline void CObjectInfo::DeleteMembersOnly () 
293
688
 { _DeleteMembersOnly = true; }
294
689