- All Superinterfaces:
ArithmeticType,Entity,IntegerType,ObjectType,ProgramEntity,TaggedEntity,Type,UnqualifiedObjectType
An enumeration type. An enumeration type consists of a key, a tag, and a
sequence of enumerators. The key is used to determine when two enumeration
types are equal. Each enumerator consists of an identifier and an optional
constant expression.
-
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.LinkageKindNested classes/interfaces inherited from interface dev.civl.abc.ast.type.IF.Type
Type.TypeKind -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Makes this type incomplete, i.e., sets the enumerators tonull.voidcomplete(Iterable<Enumerator> enumerators) Completes this enumeration type by specifying the contents of the type, i.e., the list or enumerator constants.getEnumerator(int index) Returns the index-th enumerator defined in the type.Returns the sequence of enumerators for this enumerated type.getKey()Returns the key associated to this instance.intReturns the number of enumerators specified in this enumeration type.getTag()Returns the tag of this enumeration type.getType()Other thanLabel, andPragmaHandler, every kind of Entity has a type, returned by this method.Methods inherited from interface dev.civl.abc.ast.type.IF.ArithmeticType
inComplexDomain, inRealDomain, isEnumeration, isFloating, isIntegerMethods inherited from interface dev.civl.abc.ast.entity.IF.Entity
getEntityKind, getNameMethods inherited from interface dev.civl.abc.ast.type.IF.ObjectType
hasKnownConstantSize, isComplete, isConstantQualifiedMethods inherited from interface dev.civl.abc.ast.entity.IF.ProgramEntity
addDeclaration, getDeclaration, getDeclarations, getDefinition, getFirstDeclaration, getLinkage, getNumDeclarations, isSystem, setDefinition, setIsSystem, setLinkage, setTypeMethods inherited from interface dev.civl.abc.ast.entity.IF.TaggedEntity
isCompleteMethods inherited from interface dev.civl.abc.ast.type.IF.Type
compatibleWith, equivalentTo, getId, ignoreQualifiersAtomic, isScalar, isVariablyModified, kind, print
-
Method Details
-
getKey
Object getKey()Returns the key associated to this instance. The key is used in the determination of equality of two instances of EnumerationType.- Returns:
- the key
-
getTag
String getTag()Returns the tag of this enumeration type. This is the string used in the declaration of the type, i.e., in "enum foo {...}", "foo" is the tag.- Returns:
- the tag of this enumeration type
-
getNumEnumerators
int getNumEnumerators()Returns the number of enumerators specified in this enumeration type.- Returns:
- the number of enumerators in the type
- Throws:
RuntimeException- if the type is not complete, i.e., the enumerators have not yet been specified
-
getEnumerator
Returns the index-th enumerator defined in the type.- Parameters:
index- an integer between 0 and the number of enumerators minus 1, inclusive- Returns:
- the index-th enumerator
- Throws:
RuntimeException- if the type is not complete
-
getEnumerators
Iterable<Enumerator> getEnumerators()Returns the sequence of enumerators for this enumerated type. Each enumerator consists of a name and optional constant expression. If the optional constant expression is absent, it will be null. This will returnnullif the type is incomplete, i.e., the enumerators have not yet been specified- Returns:
- the sequence node for the enumerators of this type, or
null
-
complete
Completes this enumeration type by specifying the contents of the type, i.e., the list or enumerator constants.- Parameters:
enumerators- an ordered list of enumerators which comprise the type- Throws:
RuntimeException- if the type is already complete
-
clear
void clear()Makes this type incomplete, i.e., sets the enumerators tonull. -
getType
EnumerationType 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
-