- All Superinterfaces:
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.civl.abc.ast.type.IF.Type
Type.TypeKind -
Method Summary
Modifier and TypeMethodDescriptionbooleanWas this type generated from an identifier list (as opposed to a parameter type list)?intReturns the number of parameters.getParameterType(int index) Returns the type of the index-th parameter.The sequence of formal parameter declarations for this function type.The return type of this function.booleanA function that takes a variable number of arguments will have an ellipsis occur at the end of its argument list.booleanReturns true iff the parameter information for this function type is known.Methods inherited from interface dev.civl.abc.ast.type.IF.Type
compatibleWith, equivalentTo, getId, ignoreQualifiersAtomic, isScalar, isVariablyModified, kind, print
-
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
Returns the number of parameters.- Returns:
- the number of parameters
- Throws:
ASTException- if the parameter information is not known
-
getParameterType
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
-