PUMA Library Reference Manual
|
#include <Puma/CObjectInfo.h>
Abstract base class of all semantic information classes.
Provides all semantic information about an entity (class, function, object, etc).
A semantic object is identified by its object ID. Semantic information objects for the same kind of entity have the same object ID (like object ID CObjectInfo::FUNCTION_INFO for all semantic objects of functions).
Example:
Semantic information objects are created by the semantic analysis component of Puma (see Puma::Semantic) during the parse process and are collected in the semantic information database (see Puma::CSemDatabase).
There are several relations between the semantic objects forming the semantic tree. There is one semantic tree for each translation unit.
The root of the semantic tree usually is the semantic object for the file scope (see Puma::CFileInfo). It contains all the other scopes of the analysed source file, such as namespaces and class definitions, function definitions, global variables, and so on. The semantic tree is destroyed by destroying the root object of the tree. This recursively destroys all sub-objects of the tree.
Public Types | |
enum | ObjectId { FILE_INFO , UNION_INFO , CLASS_INFO , BASECLASS_INFO , MEMBERALIAS_INFO , ENUM_INFO , TYPEDEF_INFO , FUNCTION_INFO , LABEL_INFO , ENUMERATOR_INFO , ATTRIBUTE_INFO , TEMPLATE_PARAM_INFO , TEMPLATE_INFO , CLASS_INSTANCE_INFO , UNION_INSTANCE_INFO , FCT_INSTANCE_INFO , ARGUMENT_INFO , LOCAL_INFO , NAMESPACE_INFO , USING_INFO } |
Semantic information object types. More... | |
Public Member Functions | |
~CObjectInfo () | |
Destructor. | |
bool | operator== (const CObjectInfo &) const |
Compare the addresses of this object and all objects linked to this object with the address of the given object. | |
bool | operator!= (const CObjectInfo &) const |
Compare the addresses of this object and all objects linked to this object with the address of the given object. | |
CObjectInfo * | ObjectInfo () const |
Get a pointer to CObjectInfo for any semantic object type. | |
CLabelInfo * | LabelInfo () const |
Return a pointer to CLabelInfo if the entity is a label. | |
CMemberAliasInfo * | MemberAliasInfo () const |
Return a pointer to CMemberAliasInfo if the entity is a member alias. | |
CBaseClassInfo * | BaseClassInfo () const |
Return a pointer to CBaseClassInfo if the entity is a base class specifier. | |
CUsingInfo * | UsingInfo () const |
Return a pointer to CUsingInfo if the entity is a using-directive. | |
CTypedefInfo * | TypedefInfo () const |
Return a pointer to CTypedefInfo if the entity is a typedef. | |
CArgumentInfo * | ArgumentInfo () const |
Return a pointer to CArgumentInfo if the entity is a function parameter. | |
CAttributeInfo * | AttributeInfo () const |
Return a pointer to CAttributeInfo if the entity is an object or enumeration constant. | |
CTemplateParamInfo * | TemplateParamInfo () const |
Return a pointer to CTemplateParemInfo if the entity is a template parameter. | |
CStructure * | Structure () const |
Return a pointer to CStructure if the entity is a namespace, class, function, or any other construct that can contain other entities. | |
CFileInfo * | FileInfo () const |
Return a pointer to CFileInfo if this is the file scope. | |
CRecord * | Record () const |
Return a pointer to CRecord if the entity is a class or union. | |
CLocalScope * | LocalScope () const |
Return a pointer to CLocalScope if the entity is a local scope (block scope). | |
CScopeInfo * | ScopeInfo () const |
Return a pointer to CScopeInfo if the entity defines a scope. | |
CClassInfo * | ClassInfo () const |
Return a pointer to CClassInfo if the entity is a class. | |
CUnionInfo * | UnionInfo () const |
Return a pointer to CUnionInfo if the entity is a union. | |
CEnumInfo * | EnumInfo () const |
Return a pointer to CEnumInfo if the entity is an enumeration. | |
CFunctionInfo * | FunctionInfo () const |
Return a pointer to CFunctionInfo if the entity is a function, method, or overloaded operator. | |
CNamespaceInfo * | NamespaceInfo () const |
Return a pointer to CNamespaceInfo if the entity is a namespace. | |
CEnumeratorInfo * | EnumeratorInfo () const |
Return a pointer to CEnumeratorInfo if the entity is an enumeration constant. | |
CTemplateInfo * | TemplateInfo () const |
Return a pointer to CTemplateInfo if the entity is a template. | |
CClassInstance * | ClassInstance () const |
Return a pointer to CClassInstance if the entity is an instance of a class template. | |
CFctInstance * | FctInstance () const |
Return a pointer to CFctInstance if the entity is an instance of a function template. | |
CUnionInstance * | UnionInstance () const |
Return a pointer to CUnionInstance if the entity is an instance of a union template. | |
CTemplateInfo * | Template () const |
Return a pointer to CTemplateInfo if the entity is a template. | |
CTemplateInstance * | TemplateInstance () const |
Return a pointer to CTemplateInstance if the entity is an instance of a class or function template. | |
CScopeInfo * | Scope () const |
Get the scope in which the entity was declared. | |
CStructure * | QualifiedScope () const |
Get the scope of qualified names. | |
CRecord * | ClassScope () const |
Get the class containing the class member described by this object. | |
CStructure * | AssignedScope () const |
Get the scope of a friend class or function. | |
ObjectId | Id () const |
Get the type of this semantic object. | |
const DString & | Name () const |
Get the name of entity described by this semantic object. | |
const char * | QualName (bool abs=false, bool tdef=false, bool unnamed=false) |
Get the qualified name of the entity described by this semantic object. | |
CObjectInfo * | DefObject () const |
Get the semantic information object for the definition of an entity. | |
CTypeInfo * | TypeInfo () const |
Get the data type of the entity. | |
CSourceInfo * | SourceInfo () const |
Get the source file information. | |
CSemDatabase * | ClassDB () const |
Get the semantic information database object containing this semantic object. | |
CSemDatabase * | SemDB () const |
Get the semantic information database object containing this semantic object. | |
CTree * | Tree () const |
Get the syntax tree node for the entity described by this semantic object. | |
CObjectInfo * | NextObject () const |
Get the next semantic object linked with this object. | |
CObjectInfo * | PrevObject () const |
Get the previous semantic object linked with this object. | |
CObjectInfo * | BaseObject () const |
Get the semantic object for the base class entity this entity is overloading. | |
CTree * | Init () const |
Get the initializer of the entity. | |
CProtection::Type | Protection () const |
Get the member protection of the entity, if it is a class member. | |
CLinkage::Type | Linkage () const |
Get the linkage of the entity. | |
CStorage::Type | Storage () const |
Get the storage class of the entity. | |
const CLanguage & | Language () const |
Get the entity encoding language. | |
CLanguage & | Language () |
Get the entity encoding language. | |
const CSpecifiers & | Specifiers () const |
Get the declaration specifiers. | |
bool | isType () const |
Check if the entity is a type. | |
bool | isObject () const |
Check if the entity is an object. | |
bool | isAnonymous () const |
Check if the entity is anonymous (has no explicit name). | |
bool | isTemplate () const |
Check if the entity is a class or function template, or a template template parameter. | |
bool | isTemplateInstance () const |
Check if the entity is a class or function template instance. | |
bool | isBuiltin () const |
Check if the entity describes a built-in type or function. | |
bool | isClassMember () const |
Check if the entity is a method or data member of a class. | |
bool | isVirtual () const |
Check if the entity is declared virtual. | |
bool | isStatic () const |
Check if the entity is declared static. | |
bool | isThreadLocal () const |
Check if the entity is declared __thread. | |
bool | isExtern () const |
Check if the entity is declared extern. | |
bool | isMutable () const |
Check if the entity is declared mutable. | |
bool | isRegister () const |
Check if the entity is declared register. | |
bool | isExplicit () const |
Check if the entity is declared explicit. | |
bool | isInline () const |
Check if the entity is declared inline. | |
bool | isAuto () const |
Check if the entity is declared auto. | |
bool | isRegistered (const CStructure *s) const |
Check if the given semantic object is registered as being connected to this semantic object in any way. | |
bool | isLocal () const |
Check if the entity is local. | |
void | Name (const char *s) |
Set the name of the entity. | |
void | Name (const DString &ds) |
Set the name of the entity. | |
void | TypeInfo (CTypeInfo *type) |
Set the type of the entity. | |
void | BaseObject (CObjectInfo *base) |
Set the base class object for the entity this entity overloads. | |
void | Protection (CProtection::Type p) |
Set the member access protection of the entity. | |
void | Linkage (CLinkage::Type l) |
Set the linkage of the entity. | |
void | Storage (CStorage::Type s) |
Set the storage class of the entity. | |
void | Specifiers (const CSpecifiers &) |
Set the declaration specifiers. | |
void | FileInfo (CFileInfo *finfo) |
Set the source file information for the entity. | |
void | Tree (CTree *tree) |
Set the syntax tree node of the entity. | |
void | ClassDB (CSemDatabase *db) |
Set the semantic information database object containing this semantic object. | |
void | SemDB (CSemDatabase *db) |
Set the semantic information database object containing this semantic object. | |
void | NextObject (CObjectInfo *obj) |
Set the link to next semantic object. | |
void | PrevObject (CObjectInfo *obj) |
Set the link to next semantic object. | |
void | Unlink () |
Unlink this semantic object. | |
void | Register (CStructure *s) |
Register the given semantic object as being connected to this semantic object in any way. | |
void | Unregister (CStructure *s) |
Unregister the given semantic object as being connected to this semantic object in any way. | |
void | isVirtual (bool v) |
Set whether the entity was declared virtual. | |
void | isStatic (bool v) |
Set whether the entity was declared static. | |
void | isThreadLocal (bool v) |
Set whether the entity was declared __thread. | |
void | isExtern (bool v) |
Set whether the entity was declared extern. | |
void | isMutable (bool v) |
Set whether the entity was declared mutable. | |
void | isRegister (bool v) |
Set whether the entity was declared register. | |
void | isExplicit (bool v) |
Set whether the entity was declared explicit. | |
void | isInline (bool v) |
Set whether the entity was declared inline. | |
void | isAuto (bool v) |
Set whether the entity was declared auto. | |
void | AssignedScope (CStructure *s) |
Set the assigned scope of the entity. | |
Protected Member Functions | |
CObjectInfo (ObjectId id) | |
Constructor. | |
Protected Attributes | |
CStructure * | _QualScope |
Qualified name scope. | |
CStructure * | _AssignedScope |
The scope of a friend class or function. | |
Array< CStructure * > | _Registered |
Set of semantic objects connected to this object in any way. | |
Semantic information object types.
Puma::CObjectInfo::~CObjectInfo | ( | ) |
Destructor.
|
inlineprotected |
Constructor.
id | The semantic object type. |
|
inline |
Return a pointer to CArgumentInfo if the entity is a function parameter.
The object type has to be one of:
|
inline |
Get the scope of a friend class or function.
This is not the scope in which the friend class or function was declared. A friend function of a class may be declared first inside the scope of a class definition. But the declared function does not belong to this scope. In fact it belongs to the nearest non-class scope (usually the file scope). This is the assigned scope.
|
inline |
Set the assigned scope of the entity.
This is the scope of a friend class or function. It is not the scope in which the friend class or function was declared. A friend function of a class may be declared first inside the scope of a class definition. But the declared function does not belong to this scope. In fact it belongs to the nearest non-class scope (usually the file scope). This is the assigned scope.
s | The assigned scope. |
|
inline |
Return a pointer to CAttributeInfo if the entity is an object or enumeration constant.
The object type has to be one of:
|
inline |
Return a pointer to CBaseClassInfo if the entity is a base class specifier.
The object type has to be one of:
|
inline |
Get the semantic object for the base class entity this entity is overloading.
|
inline |
Set the base class object for the entity this entity overloads.
base | The base object. |
|
inline |
Get the semantic information database object containing this semantic object.
|
inline |
Set the semantic information database object containing this semantic object.
db | The semantic database. |
|
inline |
Return a pointer to CClassInfo if the entity is a class.
The object type has to be one of:
|
inline |
Return a pointer to CClassInstance if the entity is an instance of a class template.
The object type has to be one of:
CRecord * Puma::CObjectInfo::ClassScope | ( | ) | const |
Get the class containing the class member described by this object.
The object type has to be one of:
CObjectInfo * Puma::CObjectInfo::DefObject | ( | ) | const |
Get the semantic information object for the definition of an entity.
Some entities, like functions and classes, can be declared several times before a definition of the entity appears. The semantic objects for the definition and declarations are linked. This method searches the linked semantic objects for the semantic object of the definition of the entity.
|
inline |
Return a pointer to CEnumeratorInfo if the entity is an enumeration constant.
The object type has to be one of:
|
inline |
Return a pointer to CEnumInfo if the entity is an enumeration.
The object type has to be one of:
|
inline |
Return a pointer to CFctInstance if the entity is an instance of a function template.
The object type has to be one of:
|
inline |
Return a pointer to CFileInfo if this is the file scope.
The object type has to be one of:
void Puma::CObjectInfo::FileInfo | ( | CFileInfo * | finfo | ) |
Set the source file information for the entity.
finfo | The file information. |
|
inline |
Return a pointer to CFunctionInfo if the entity is a function, method, or overloaded operator.
The object type has to be one of:
|
inline |
Get the type of this semantic object.
CTree * Puma::CObjectInfo::Init | ( | ) | const |
Get the initializer of the entity.
|
inline |
Check if the entity is anonymous (has no explicit name).
|
inline |
Check if the entity is declared auto.
|
inline |
Set whether the entity was declared auto.
v | True for yes, false for no. |
|
inline |
Check if the entity describes a built-in type or function.
In this case the entity has no syntax tree (Tree() returns NULL).
bool Puma::CObjectInfo::isClassMember | ( | ) | const |
Check if the entity is a method or data member of a class.
|
inline |
Check if the entity is declared explicit.
|
inline |
Set whether the entity was declared explicit.
v | True for yes, false for no. |
|
inline |
Check if the entity is declared extern.
|
inline |
Set whether the entity was declared extern.
v | True for yes, false for no. |
|
inline |
Check if the entity is declared inline.
|
inline |
Set whether the entity was declared inline.
v | True for yes, false for no. |
bool Puma::CObjectInfo::isLocal | ( | ) | const |
Check if the entity is local.
An entity is local if it was declared in a local scope.
|
inline |
Check if the entity is declared mutable.
|
inline |
Set whether the entity was declared mutable.
v | True for yes, false for no. |
bool Puma::CObjectInfo::isObject | ( | ) | const |
Check if the entity is an object.
|
inline |
Check if the entity is declared register.
|
inline |
Set whether the entity was declared register.
v | True for yes, false for no. |
bool Puma::CObjectInfo::isRegistered | ( | const CStructure * | s | ) | const |
Check if the given semantic object is registered as being connected to this semantic object in any way.
s | The semantic object. |
|
inline |
Check if the entity is declared static.
|
inline |
Set whether the entity was declared static.
v | True for yes, false for no. |
bool Puma::CObjectInfo::isTemplate | ( | ) | const |
Check if the entity is a class or function template, or a template template parameter.
bool Puma::CObjectInfo::isTemplateInstance | ( | ) | const |
Check if the entity is a class or function template instance.
|
inline |
Check if the entity is declared __thread.
|
inline |
Set whether the entity was declared __thread.
v | True for yes, false for no. |
bool Puma::CObjectInfo::isType | ( | ) | const |
Check if the entity is a type.
|
inline |
Check if the entity is declared virtual.
|
inline |
Set whether the entity was declared virtual.
v | True for yes, false for no. |
|
inline |
Return a pointer to CLabelInfo if the entity is a label.
The object type has to be one of:
|
inline |
Get the entity encoding language.
|
inline |
Get the entity encoding language.
|
inline |
Get the linkage of the entity.
|
inline |
Set the linkage of the entity.
l | The linkage. |
|
inline |
Return a pointer to CLocalScope if the entity is a local scope (block scope).
The object type has to be one of:
|
inline |
Return a pointer to CMemberAliasInfo if the entity is a member alias.
The object type has to be one of:
|
inline |
Get the name of entity described by this semantic object.
|
inline |
Set the name of the entity.
s | The name. |
void Puma::CObjectInfo::Name | ( | const DString & | ds | ) |
Set the name of the entity.
ds | The name. |
|
inline |
Return a pointer to CNamespaceInfo if the entity is a namespace.
The object type has to be one of:
|
inline |
Get the next semantic object linked with this object.
Usually the definition and the declarations of an entity are linked.
void Puma::CObjectInfo::NextObject | ( | CObjectInfo * | obj | ) |
Set the link to next semantic object.
Usually the semantic objects for the definition and declaration of an entity are linked.
obj | The next object in the chain. |
|
inline |
Get a pointer to CObjectInfo for any semantic object type.
|
inline |
Compare the addresses of this object and all objects linked to this object with the address of the given object.
bool Puma::CObjectInfo::operator== | ( | const CObjectInfo & | ) | const |
Compare the addresses of this object and all objects linked to this object with the address of the given object.
|
inline |
Get the previous semantic object linked with this object.
Usually the definition and the declarations of an entity are linked.
void Puma::CObjectInfo::PrevObject | ( | CObjectInfo * | obj | ) |
Set the link to next semantic object.
Usually the semantic objects for the definition and declaration of an entity are linked.
obj | The previous object in the chain. |
|
inline |
Get the member protection of the entity, if it is a class member.
|
inline |
Set the member access protection of the entity.
p | The protection. |
|
inline |
Get the scope of qualified names.
The scope of a class member for instance is the corresponding class. If a function is declared in a namespace, then the qualified scope is that namespace.
const char * Puma::CObjectInfo::QualName | ( | bool | abs = false, |
bool | tdef = false, | ||
bool | unnamed = false ) |
Get the qualified name of the entity described by this semantic object.
abs | Create root qualified name (like ::X::Y::Z). |
tdef | Insert the name of a typedef instead of the named type. |
unnamed | Don't ignore unnamed namespaces (like <unnamed>::foo). |
|
inline |
Return a pointer to CRecord if the entity is a class or union.
The object type has to be one of:
|
inline |
Register the given semantic object as being connected to this semantic object in any way.
s | The semantic object. |
CScopeInfo * Puma::CObjectInfo::Scope | ( | ) | const |
Get the scope in which the entity was declared.
|
inline |
Return a pointer to CScopeInfo if the entity defines a scope.
The object type has to be one of:
|
inline |
Get the semantic information database object containing this semantic object.
|
inline |
Set the semantic information database object containing this semantic object.
db | The semantic database. |
|
inline |
Get the source file information.
Contains the position and token of the entity in the source file.
|
inline |
Get the declaration specifiers.
|
inline |
Set the declaration specifiers.
|
inline |
Get the storage class of the entity.
|
inline |
Set the storage class of the entity.
s | The storage class. |
|
inline |
Return a pointer to CStructure if the entity is a namespace, class, function, or any other construct that can contain other entities.
The object type has to be one of:
CTemplateInfo * Puma::CObjectInfo::Template | ( | ) | const |
Return a pointer to CTemplateInfo if the entity is a template.
The object type has to be one of:
|
inline |
Return a pointer to CTemplateInfo if the entity is a template.
The object type has to be one of:
CTemplateInstance * Puma::CObjectInfo::TemplateInstance | ( | ) | const |
Return a pointer to CTemplateInstance if the entity is an instance of a class or function template.
The object type has to be one of:
|
inline |
Return a pointer to CTemplateParemInfo if the entity is a template parameter.
The object type has to be one of:
|
inline |
Get the syntax tree node for the entity described by this semantic object.
|
inline |
Set the syntax tree node of the entity.
tree | The syntax tree node. |
|
inline |
Return a pointer to CTypedefInfo if the entity is a typedef.
The object type has to be one of:
|
inline |
Get the data type of the entity.
void Puma::CObjectInfo::TypeInfo | ( | CTypeInfo * | type | ) |
Set the type of the entity.
type | The type information. |
|
inline |
Return a pointer to CUnionInfo if the entity is a union.
The object type has to be one of:
|
inline |
Return a pointer to CUnionInstance if the entity is an instance of a union template.
The object type has to be one of:
void Puma::CObjectInfo::Unlink | ( | ) |
Unlink this semantic object.
Usually the semantic objects for the definition and declaration of an entity are linked. This method removes this object from the chain.
void Puma::CObjectInfo::Unregister | ( | CStructure * | s | ) |
Unregister the given semantic object as being connected to this semantic object in any way.
s | The semantic object. |
|
inline |
Return a pointer to CUsingInfo if the entity is a using-directive.
The object type has to be one of:
|
protected |
The scope of a friend class or function.
This is not the scope in which the friend class or function was declared. A friend function of a class may be declared first inside the scope of a class definition. But the declared function does not belong to this scope. In fact it belongs to the nearest non-class scope (usually the file scope). This is the assigned scope.
|
protected |
Qualified name scope.
Set only for CAttributeInfo, CFunctionInfo, and CRecord.
|
protected |
Set of semantic objects connected to this object in any way.