Module dev.civl.abc

Interface EnumerationType

All Superinterfaces:
ArithmeticType, Entity, IntegerType, ObjectType, ProgramEntity, TaggedEntity, Type, UnqualifiedObjectType

public interface EnumerationType extends IntegerType, TaggedEntity
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.
  • 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

      Enumerator getEnumerator(int index)
      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 return null if 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

      void complete(Iterable<Enumerator> enumerators)
      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 to null.
    • getType

      EnumerationType getType()
      Description copied from interface: ProgramEntity

      Other than Label, and PragmaHandler, every kind of Entity has a type, returned by this method. For a Label or PragmaHandler, this returns null.

      The type is initially null. It can be set using method ProgramEntity.setType(Type).

      Specified by:
      getType in interface ProgramEntity
      Returns:
      the type of this entity or null