Class Type

java.lang.Object
com.jogamp.gluegen.cgram.types.Type
All Implemented Interfaces:
ASTLocusTag.ASTLocusTagProvider, TypeComparator.SemanticEqualityOp
Direct Known Subclasses:
FunctionType, MemoryLayoutType, PointerType, PrimitiveType, VoidType

public abstract class Type extends Object implements TypeComparator.SemanticEqualityOp, ASTLocusTag.ASTLocusTagProvider
Models a C type. Primitive types include int, float, and double. All types have an associated name. Structs and unions are modeled as "compound" types -- composed of fields of primitive or other types.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final boolean
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Type(String name, SizeThunk size, int cvAttributes, ASTLocusTag astLocus)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Helper method for determining how many array dimentions this type represents (i.e., "char[][]" returns 2).
    Casts this to an ArrayType or returns null if not an ArrayType.
    Casts this to a BitType or returns null if not a BitType.
    Casts this to a CompoundType or returns null if not a CompoundType.
    Casts this to a DoubleType or returns null if not a DoubleType.
    Casts this to an EnumType or returns null if not an EnumType.
    Casts this to a FloatType or returns null if not a FloatType.
    Casts this to a FunctionType or returns null if not a FunctionType.
    Casts this to an IntType or returns null if not an IntType.
    Casts this to a PointerType or returns null if not a PointerType.
    Casts this to a VoidType or returns null if not a VoidType.
    protected final void
     
    Clones this instance using a new ASTLocusTag.
    final boolean
    Equality test for Types inclusive its given name.
    final boolean
    Semantic equality test for Types exclusive its given name.
    protected abstract boolean
     
    protected abstract boolean
     
    Returns this instance's ASTLocusTag, if available, otherwise returns null.
    Helper method to returns the bottom-most element type of this type.
    final String
    Returns the name of this type.
    getCName(boolean includeCVAttrs)
    Returns the name of this type, optionally including const/volatile attributes.
    final int
     
    final String
    Returns a string indicating the const/volatile attributes of this type.
    final String
     
    final String
    Returns the name of this type.
    getName(boolean includeCVAttrs)
    Returns the name of this type, optionally including const/volatile attributes.
    final SizeThunk
    SizeThunk which computes size of this type in bytes.
    final long
    Size of this type in bytes according to the given MachineDataInfo.
    Helper method to returns the target type of this type, in case another type is being referenced.
    final int
    Hashcode for Types.
    protected abstract int
     
    final int
    Semantic hashcode for Types exclusive its given name.
    protected abstract int
     
    boolean
     
    final boolean
    Indicates whether this is an ArrayType.
    final boolean
    Checks the base type of pointer-to-pointer, pointer, array or plain for const-ness.
    final boolean
    Indicates whether this is a BitType.
    final boolean
    Indicates whether this is a CompoundType.
    final boolean
    Indicates whether this type is const.
    final boolean
    Indicates whether this is a DoubleType.
    final boolean
    Indicates whether this is an EnumType.
    final boolean
    Indicates whether this is a FloatType.
    final boolean
    Indicates whether this is a FunctionType.
    boolean
    Convenience routine indicating whether this Type is a pointer to a function.
    final boolean
    Indicates whether this is an IntType.
    final boolean
    Indicates whether this is a PointerType.
    boolean
    Indicates whether this type is a primitive type.
    final boolean
    Indicates whether this type is a typedef type, i.e.
    final boolean
    Indicates whether this is a VoidType.
    final boolean
    Indicates whether this type is volatile.
    final Type
    newCVVariant(int cvAttributes)
    Return a variant of this type matching the given const/volatile attributes.
    int
    Helper method for determining how many pointer indirections this type represents (i.e., "void **" returns 2).
    boolean
    Set the typedef name of this type and renders this type a typedef, if given name has a length.
    Returns a string representation of this type.
    void
    visit(TypeVisitor visitor)
    Traverse this Type and all of its component types; for example, the return type and argument types of a FunctionType.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • relaxedEqSem

      public final boolean relaxedEqSem
  • Constructor Details

  • Method Details

    • clearCache

      protected final void clearCache()
    • newCVVariant

      public final Type newCVVariant(int cvAttributes)
      Return a variant of this type matching the given const/volatile attributes. May return this object if the attributes match.
    • clone

      public Type clone(ASTLocusTag newLoc)
      Clones this instance using a new ASTLocusTag.
    • getASTLocusTag

      public final ASTLocusTag getASTLocusTag()
      Description copied from interface: ASTLocusTag.ASTLocusTagProvider
      Returns this instance's ASTLocusTag, if available, otherwise returns null.
      Specified by:
      getASTLocusTag in interface ASTLocusTag.ASTLocusTagProvider
    • isAnon

      public boolean isAnon()
    • getCName

      public final String getCName()
      Returns the name of this type. The returned string is suitable for use as a type specifier for native C. Does not include any const/volatile attributes.
    • getCName

      public String getCName(boolean includeCVAttrs)
      Returns the name of this type, optionally including const/volatile attributes. The returned string is suitable for use as a type specifier for native C.
    • getName

      public final String getName()
      Returns the name of this type. The returned string is suitable for use as a type specifier for Java. Does not include any const/volatile attributes.
    • getName

      public String getName(boolean includeCVAttrs)
      Returns the name of this type, optionally including const/volatile attributes. The returned string is suitable for use as a type specifier for Java.
    • toString

      public String toString()
      Returns a string representation of this type. The returned string is suitable for use as a type specifier for native C. It does contain an expanded description of structs/unions, hence may not be suitable for type declarations.
      Overrides:
      toString in class Object
    • getDebugString

      public final String getDebugString()
    • setTypedefName

      public boolean setTypedefName(String name)
      Set the typedef name of this type and renders this type a typedef, if given name has a length.

      Method issues clearCache(), to force re-evaluation of hashes.

    • isTypedef

      public final boolean isTypedef()
      Indicates whether this type is a typedef type, i.e. declared via setTypedefName(String).
    • getSize

      public final SizeThunk getSize()
      SizeThunk which computes size of this type in bytes.
    • getSize

      public final long getSize(MachineDataInfo machDesc)
      Size of this type in bytes according to the given MachineDataInfo.
    • asBit

      public BitType asBit()
      Casts this to a BitType or returns null if not a BitType.
    • asInt

      public IntType asInt()
      Casts this to an IntType or returns null if not an IntType.
    • asEnum

      public EnumType asEnum()
      Casts this to an EnumType or returns null if not an EnumType.
    • asFloat

      public FloatType asFloat()
      Casts this to a FloatType or returns null if not a FloatType.
    • asDouble

      public DoubleType asDouble()
      Casts this to a DoubleType or returns null if not a DoubleType.
    • asPointer

      public PointerType asPointer()
      Casts this to a PointerType or returns null if not a PointerType.
    • asArray

      public ArrayType asArray()
      Casts this to an ArrayType or returns null if not an ArrayType.
    • asCompound

      public CompoundType asCompound()
      Casts this to a CompoundType or returns null if not a CompoundType.
    • asFunction

      public FunctionType asFunction()
      Casts this to a FunctionType or returns null if not a FunctionType.
    • asVoid

      public VoidType asVoid()
      Casts this to a VoidType or returns null if not a VoidType.
    • isBit

      public final boolean isBit()
      Indicates whether this is a BitType.
    • isInt

      public final boolean isInt()
      Indicates whether this is an IntType.
    • isEnum

      public final boolean isEnum()
      Indicates whether this is an EnumType.
    • isFloat

      public final boolean isFloat()
      Indicates whether this is a FloatType.
    • isDouble

      public final boolean isDouble()
      Indicates whether this is a DoubleType.
    • isPointer

      public final boolean isPointer()
      Indicates whether this is a PointerType.
    • isArray

      public final boolean isArray()
      Indicates whether this is an ArrayType.
    • isCompound

      public final boolean isCompound()
      Indicates whether this is a CompoundType.
    • isFunction

      public final boolean isFunction()
      Indicates whether this is a FunctionType.
    • isVoid

      public final boolean isVoid()
      Indicates whether this is a VoidType.
    • isVolatile

      public final boolean isVolatile()
      Indicates whether this type is volatile.
    • isConst

      public final boolean isConst()
      Indicates whether this type is const.
    • isPrimitive

      public boolean isPrimitive()
      Indicates whether this type is a primitive type.
    • isFunctionPointer

      public boolean isFunctionPointer()
      Convenience routine indicating whether this Type is a pointer to a function.
    • isBaseTypeConst

      public final boolean isBaseTypeConst()
      Checks the base type of pointer-to-pointer, pointer, array or plain for const-ness.

      Note: Intermediate 'const' qualifier are not considered, e.g. const pointer.

    • hashCode

      public final int hashCode()
      Hashcode for Types.
      Overrides:
      hashCode in class Object
    • hashCodeImpl

      protected abstract int hashCodeImpl()
    • equals

      public final boolean equals(Object arg)
      Equality test for Types inclusive its given name.
      Overrides:
      equals in class Object
    • equalsImpl

      protected abstract boolean equalsImpl(Type t)
    • hashCodeSemantics

      public final int hashCodeSemantics()
      Description copied from interface: TypeComparator.SemanticEqualityOp
      Semantic hashcode for Types exclusive its given name.
      Specified by:
      hashCodeSemantics in interface TypeComparator.SemanticEqualityOp
      See Also:
    • hashCodeSemanticsImpl

      protected abstract int hashCodeSemanticsImpl()
    • equalSemantics

      public final boolean equalSemantics(TypeComparator.SemanticEqualityOp arg)
      Description copied from interface: TypeComparator.SemanticEqualityOp
      Semantic equality test for Types exclusive its given name.
      Specified by:
      equalSemantics in interface TypeComparator.SemanticEqualityOp
      See Also:
    • equalSemanticsImpl

      protected abstract boolean equalSemanticsImpl(Type t)
    • visit

      public void visit(TypeVisitor visitor)
      Traverse this Type and all of its component types; for example, the return type and argument types of a FunctionType.
    • getCVAttributes

      public final int getCVAttributes()
    • getCVAttributesString

      public final String getCVAttributesString()
      Returns a string indicating the const/volatile attributes of this type.
    • pointerDepth

      public int pointerDepth()
      Helper method for determining how many pointer indirections this type represents (i.e., "void **" returns 2). Returns 0 if this type is not a pointer type.
    • arrayDimension

      public int arrayDimension()
      Helper method for determining how many array dimentions this type represents (i.e., "char[][]" returns 2). Returns 0 if this type is not an array type.
    • getBaseElementType

      public Type getBaseElementType()
      Helper method to returns the bottom-most element type of this type.

      If this is a multidimensional array or pointer method returns the bottom-most element type, otherwise this.

    • getTargetType

      public Type getTargetType()
      Helper method to returns the target type of this type, in case another type is being referenced.