Module dev.civl.abc

Interface FunctionType

All Superinterfaces:
Type

public interface FunctionType extends Type
According to C11, a function type is characterized by the return type and the number and types of the arguments. In reality, it is also necessary to know whether the type was generated from an identifier list or a parameter type list, as certain concepts (e.g., "compatibility") depend on this information. If fromIdentifierList is true and parametersKnown is false, this type came from a non-definition declaration of the form "f()", so no information about the arguments is known. If fromIdentifierList is false, then parametersKnown must be true, as this type came from a parameter-type list which must necessarily specify all of the parameter types. A declaration of the form "f(void)" yields a type with fromIdentifierList false, parametersKnown true, and parameterTypes of length 0. A declaration-definition of the form "f() {...}" yields a type with fromIdentifierList true, parametersKnown true, and parameterTypes of length 0. As stated above, a declaration of the form "f()" which is not part of a definition yields a type with fromIdentifierList true and parametersKnown false.
  • Method Details

    • getReturnType

      ObjectType getReturnType()
      The return type of this function. Non-null.
      Returns:
      the return type
    • fromIdentifierList

      boolean fromIdentifierList()
      Was this type generated from an identifier list (as opposed to a parameter type list)?
      Returns:
      true iff type was generated from an identifier list
    • parametersKnown

      boolean parametersKnown()
      Returns true iff the parameter information for this function type is known.
      Returns:
      true iff parameter information is known
    • getNumParameters

      int getNumParameters() throws ASTException
      Returns the number of parameters.
      Returns:
      the number of parameters
      Throws:
      ASTException - if the parameter information is not known
    • getParameterType

      ObjectType getParameterType(int index)
      Returns the type of the index-th parameter.
      Parameters:
      index - integer in range [0,n-1], where n is the number of parameters
      Returns:
      the index-th parameter type
      Throws:
      ASTException - if the parameter information is not known
    • getParameterTypes

      Iterable<ObjectType> getParameterTypes()
      The sequence of formal parameter declarations for this function type. An identifier list is represented by a sequence of declarations in which all components other than the identifiers are null.
      Returns:
      sequence of parameter declarations
      Throws:
      ASTException - if the parameter information is not known
    • hasVariableArgs

      boolean hasVariableArgs()
      A function that takes a variable number of arguments will have an ellipsis occur at the end of its argument list.
      Returns:
      true iff this function takes a variable number of arguments
      Throws:
      RuntimeException - if the parameter information is not known