- All Implemented Interfaces:
Entity,ProgramEntity
Entity. This class may be
extended by specific entities, or it may used as a field (as in the
Delegation Pattern) to help implement other entities that cannot extend this
class for some reason (for example, because they extend some other class.)-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.civl.abc.ast.entity.IF.Entity
Entity.EntityKindNested classes/interfaces inherited from interface dev.civl.abc.ast.entity.IF.ProgramEntity
ProgramEntity.LinkageKind -
Constructor Summary
ConstructorsConstructorDescriptionCommonEntity(Entity.EntityKind kind, String name, ProgramEntity.LinkageKind linkage) -
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.The kind of entity this is.Gets one of the declarations of this entity.Returns the kind of linkage this entity has.getName()Gets the name of this entity.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.toString()
-
Constructor Details
-
CommonEntity
-
-
Method Details
-
setIsSystem
public void setIsSystem(boolean value) Description copied from interface:ProgramEntityDeclares that this entity is or is not a system-defined entity.- Specified by:
setIsSystemin interfaceProgramEntity- Parameters:
value- iftrue, declares this to be a system-defined entity; iffalse, declares this to be a user-defined entity. The default isfalse.
-
isSystem
public boolean isSystem()Description copied from interface:ProgramEntityIs 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 methodProgramEntity.setIsSystem(boolean).- Specified by:
isSystemin interfaceProgramEntity
-
getEntityKind
Description copied from interface:EntityThe kind of entity this is.
If the kind is
Entity.EntityKind.VARIABLE, this entity may be safely cast toVariableIf the kind is
Entity.EntityKind.FUNCTION, this entity may be safely cast toFunction.If the kind is
Entity.EntityKind.TYPEDEF, this entity may be safely cast toTypedef.If the kind is
Entity.EntityKind.STRUCTURE_OR_UNION, this entity may be safely cast to.invalid reference
StructureOrUnionIf the kind is
Entity.EntityKind.ENUMERATION, this entity may be safely cast toEnumeration.If the kind is
Entity.EntityKind.ENUMERATOR, this entity may be safely cast toEnumerator. An enumerator is an element of an enumeration.If the kind is
Entity.EntityKind.FIELD, this entity may be safely cast toField. A "field" is a member of a structure or union.If the kind is
Entity.EntityKind.LABEL, this entity may be safely cast toLabel.If the kind is
Entity.EntityKind.PRAGMA_HANDLER, this entity may be safely cast toPragmaHandler.- Specified by:
getEntityKindin interfaceEntity- Returns:
- the entity kind
-
getDeclarations
Description copied from interface:ProgramEntityReturns 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.- Specified by:
getDeclarationsin interfaceProgramEntity- Returns:
- iterator over declarations of this entity, in program order
-
getFirstDeclaration
Description copied from interface:ProgramEntityGets one of the declarations of this entity.- Specified by:
getFirstDeclarationin interfaceProgramEntity- Returns:
- a declaration of this entity or
nullif there aren't any
-
getNumDeclarations
public int getNumDeclarations()Description copied from interface:ProgramEntityReturns the number of declarations of this entity.- Specified by:
getNumDeclarationsin interfaceProgramEntity- Returns:
- the number of declarations of this entity
-
getDeclaration
Description copied from interface:ProgramEntityReturns the index-th declaration of this entity.- Specified by:
getDeclarationin interfaceProgramEntity- 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
Description copied from interface:ProgramEntityAdds a declaration to this entity.- Specified by:
addDeclarationin interfaceProgramEntity- Parameters:
declaration- a declaration of this entity
-
getDefinition
Description copied from interface:ProgramEntityGets 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 methodProgramEntity.setDefinition(DeclarationNode).- Specified by:
getDefinitionin interfaceProgramEntity- Returns:
- the definition of this entity or
null
-
setDefinition
Description copied from interface:ProgramEntitySets 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.- Specified by:
setDefinitionin interfaceProgramEntity- Parameters:
declaration- the declaration node for the definition
-
getLinkage
Description copied from interface:ProgramEntityReturns the kind of linkage this entity has.- Specified by:
getLinkagein interfaceProgramEntity- Returns:
- the kind of linkage this entity has
-
setLinkage
Description copied from interface:ProgramEntitySets the linkage of this entity. It is initiallyProgramEntity.LinkageKind.NONE.- Specified by:
setLinkagein interfaceProgramEntity- Parameters:
linkage- the linkage kind of this entity
-
getName
Description copied from interface:EntityGets the name of this entity. This is the identifier used in the declaration of the entity. It can be null in certain situations (e.g., an unnamed field). -
getType
Description copied from interface:ProgramEntityOther 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 methodProgramEntity.setType(Type).- Specified by:
getTypein interfaceProgramEntity- Returns:
- the type of this entity or
null
-
setType
Description copied from interface:ProgramEntitySets the type of this entity.- Specified by:
setTypein interfaceProgramEntity- Parameters:
type- the type of this entity
-
toString
-