Class TypeState


  • public class TypeState
    extends Object
    A value's inferred type set paired with its nullability lattice element.
    • Field Detail

      • BOTTOM

        public static final TypeState BOTTOM
        Type state representing no information (bottom).
      • NULL

        public static final TypeState NULL
        Type state representing a definitely null value.
    • Constructor Detail

      • TypeState

        public TypeState​(TypeSet typeSet,
                         Nullability nullability)
        Creates a state from an explicit type set.
        Parameters:
        typeSet - the set of possible types
        nullability - the nullability lattice element
      • TypeState

        public TypeState​(IRType type,
                         Nullability nullability)
        Creates a single-type state.
        Parameters:
        type - the only possible type
        nullability - the nullability lattice element
      • TypeState

        public TypeState​(IRType type)
        Creates a single-type state with unknown nullability.
        Parameters:
        type - the only possible type
    • Method Detail

      • notNull

        public static TypeState notNull​(IRType type)
        Creates a type state for a definitely non-null value.
        Parameters:
        type - the only possible type
        Returns:
        the new state
      • nullable

        public static TypeState nullable​(IRType type)
        Creates a type state whose nullability is unknown.
        Parameters:
        type - the only possible type
        Returns:
        the new state
      • polymorphic

        public static TypeState polymorphic​(TypeSet types,
                                            Nullability nullability)
        Creates a type state from multiple possible types.
        Parameters:
        types - the set of possible types
        nullability - the nullability lattice element
        Returns:
        the new state
      • getTypeSet

        public TypeSet getTypeSet()
        Returns:
        the type set
      • getNullability

        public Nullability getNullability()
        Returns:
        the nullability
      • getSingleType

        public IRType getSingleType()
        Returns:
        the sole possible type, or null if the set is not a singleton
      • getAnyType

        public IRType getAnyType()
        Returns:
        an arbitrary representative type from the set
      • isDefinitelyNull

        public boolean isDefinitelyNull()
        Returns:
        true if the value is known to be null
      • isDefinitelyNotNull

        public boolean isDefinitelyNotNull()
        Returns:
        true if the value is known to be non-null
      • isBottom

        public boolean isBottom()
        Returns:
        true if no information has been established yet
      • isPrecise

        public boolean isPrecise()
        Returns:
        true if the set holds exactly one type and is complete (no subtypes)
      • join

        public TypeState join​(TypeState other)
        Joins two states at a control-flow merge point; bottom is absorbing.
        Parameters:
        other - the state arriving on the other edge
        Returns:
        the least upper bound of both states
      • narrow

        public TypeState narrow​(TypeState other)
        Narrows this state with additional information; bottom on either side yields bottom.
        Parameters:
        other - the refining state
        Returns:
        the greatest lower bound of both states
      • withNullability

        public TypeState withNullability​(Nullability newNullability)
        Copies this state with a different nullability.
        Parameters:
        newNullability - the replacement lattice element
        Returns:
        the new state
      • withType

        public TypeState withType​(IRType additionalType)
        Copies this state with one more possible type in the set.
        Parameters:
        additionalType - the type to add
        Returns:
        the new state
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object