- All Superinterfaces:
Entity
- All Known Subinterfaces:
EnumerationType,Enumerator,Function,Label,OrdinaryEntity,StructureOrUnionType,TaggedEntity,Typedef,Variable
- All Known Implementing Classes:
CommonEntity
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe different kinds of linkage an entity may have: external, internal, or none.Nested classes/interfaces inherited from interface dev.civl.abc.ast.entity.IF.Entity
Entity.EntityKind -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDeclaration(DeclarationNode declaration) Adds a declaration to this entity.getDeclaration(int index) Returns the index-th declaration of this entity.Returns an iterator over all the known declarations of this entity.Gets the definition, i.e., the defining declaration of this entity.Gets one of the declarations of this entity.Returns the kind of linkage this entity has.intReturns the number of declarations of this entity.getType()Other thanLabel, andPragmaHandler, every kind of Entity has a type, returned by this method.booleanisSystem()Is this a system-defined entity (as opposed to a user-defined one)? Examples include standard types, likesize_t.voidsetDefinition(DeclarationNode declaration) Sets the definition for this entity.voidsetIsSystem(boolean value) Declares that this entity is or is not a system-defined entity.voidsetLinkage(ProgramEntity.LinkageKind linkage) Sets the linkage of this entity.voidSets the type of this entity.Methods inherited from interface dev.civl.abc.ast.entity.IF.Entity
getEntityKind, getName
-
Method Details
-
getDeclarations
Iterable<DeclarationNode> getDeclarations()Returns an iterator over all the known declarations of this entity. An entity may be declared multiple times. This includes the definition. The declarations will be returned in program order.- Returns:
- iterator over declarations of this entity, in program order
-
getFirstDeclaration
DeclarationNode getFirstDeclaration()Gets one of the declarations of this entity.- Returns:
- a declaration of this entity or
nullif there aren't any
-
getNumDeclarations
int getNumDeclarations()Returns the number of declarations of this entity.- Returns:
- the number of declarations of this entity
-
getDeclaration
Returns the index-th declaration of this entity.- Parameters:
index- an integer in the range [0,n), where n is the number of declarations of this entity- Returns:
- the index-th declaration of this entity
-
addDeclaration
Adds a declaration to this entity.- Parameters:
declaration- a declaration of this entity
-
getDefinition
DeclarationNode getDefinition()Gets the definition, i.e., the defining declaration of this entity. Every entity has at most one definition. The definition is a declaration of a special kind. For example, for an object (variable), a definition is the declaration that allocates storage for that object. For a function, a definition is the declaration the contains the function body.
The definition is initially
null, but can be set using methodsetDefinition(DeclarationNode).- Returns:
- the definition of this entity or
null
-
setDefinition
Sets the definition for this entity. Every entity has at most one definition. The definition is a declaration of a special kind. For example, for an object (variable), a definition is the declaration that allocates storage for that object. For a function, a definition is the declaration the contains the function body.
The definition is initially
null, and can be set using this method. Note that this does not affect the list of declarations of this entity. It is the client's responsibility to add the definition to the list of declarations as well as to invoke this method, to ensure that the definition occurs in the list of declarations.- Parameters:
declaration- the declaration node for the definition
-
getLinkage
ProgramEntity.LinkageKind getLinkage()Returns the kind of linkage this entity has.- Returns:
- the kind of linkage this entity has
-
setLinkage
Sets the linkage of this entity. It is initiallyProgramEntity.LinkageKind.NONE.- Parameters:
linkage- the linkage kind of this entity
-
getType
Type getType()Other than
Label, andPragmaHandler, every kind of Entity has a type, returned by this method. For aLabelorPragmaHandler, this returnsnull.The type is initially
null. It can be set using methodsetType(Type).- Returns:
- the type of this entity or
null
-
setType
Sets the type of this entity.- Parameters:
type- the type of this entity
-
isSystem
boolean isSystem()Is this a system-defined entity (as opposed to a user-defined one)? Examples include standard types, likesize_t. The default is false; it can be changed using methodsetIsSystem(boolean). -
setIsSystem
void setIsSystem(boolean value) Declares that this entity is or is not a system-defined entity.- Parameters:
value- iftrue, declares this to be a system-defined entity; iffalse, declares this to be a user-defined entity. The default isfalse.
-