Language.C.Analysis.TypeUtils

language-c-0.5.0: Analysis and generation of C code

Safe Haskell | None
Language | Haskell98

Language.C.Analysis.TypeUtils

Contents

- Constructors
- Classifiers
- Other utilities
- Orphan instances

Synopsis

- integral :: IntType -> Type
- floating :: FloatType -> Type
- simplePtr :: Type -> Type
- size_tType :: Type
- ptrDiffType :: Type
- boolType :: Type
- voidType :: Type
- voidPtr :: Type
- constVoidPtr :: Type
- charPtr :: Type
- constCharPtr :: Type
- stringType :: Type
- valistType :: Type
- isIntegralType :: Type -> Bool
- isFloatingType :: Type -> Bool
- isPointerType :: Type -> Bool
- isScalarType :: Type -> Bool
- isFunctionType :: Type -> Bool
- typeQuals :: Type -> TypeQuals
- typeQualsUpd :: (TypeQuals -> TypeQuals) -> Type -> Type
- typeAttrs :: Type -> Attributes
- typeAttrsUpd :: (Attributes -> Attributes) -> Type -> Type
- baseType :: Type -> Type
- derefTypeDef :: Type -> Type
- deepDerefTypeDef :: Type -> Type
- canonicalType :: Type -> Type
- getIntType :: Flags CIntFlag -> IntType
- getFloatType :: String -> FloatType

# Constructors

integral :: IntType -> Type #

Constructor for a simple integral type.

floating :: FloatType -> Type #

Constructor for a simple floating-point type.

simplePtr :: Type -> Type #

A simple pointer with no qualifiers

size_tType :: Type #

The type returned by sizeof (size_t). For now, this is just `int`.

ptrDiffType :: Type #

The type of pointer differences (ptrdiff_t). For now, this is just `int`.

boolType :: Type #

The type of comparisons/guards. This is always just `int`.

voidType :: Type #

Simple `void` type.

voidPtr :: Type #

An unqualified `void` pointer.

constVoidPtr :: Type #

A `const`-qualified `void` pointer.

charPtr :: Type #

An unqualified `char` pointer.

constCharPtr :: Type #

A `const`-qualified `char` pointer.

stringType :: Type #

The type of a constant string.

valistType :: Type #

The builtin type of variable-length argument lists.

# Classifiers

isIntegralType :: Type -> Bool #

Check whether a type is an integral type. This includes `enum` types. This function does not attempt to resolve `typedef` types.

isFloatingType :: Type -> Bool #

Check whether a type is a floating-point numeric type. This function does not attempt to resolve `typedef` types.

isPointerType :: Type -> Bool #

Check whether a type is an pointer type. This includes array types. This function does not attempt to resolve `typedef` types.

isScalarType :: Type -> Bool #

Check whether a type is a scalar type. Scalar types include arithmetic types and pointer types.

isFunctionType :: Type -> Bool #

return `True` if the given type is a function type

Result is undefined in the presence of undefined typeDefs

typeQuals :: Type -> TypeQuals #

Return the qualifiers of a type.

typeQualsUpd :: (TypeQuals -> TypeQuals) -> Type -> Type #

typeAttrs :: Type -> Attributes #

Return the attributes of a type.

typeAttrsUpd :: (Attributes -> Attributes) -> Type -> Type #

baseType :: Type -> Type #

Return the base type of a pointer or array type. It is an error to call this function with a type that is not in one of those two categories.

derefTypeDef :: Type -> Type #

resolve typedefs, if possible

deepDerefTypeDef :: Type -> Type #

Attempt to remove all references to `typedef` types from a given type. Note that this does not dereference the types of structure or union fields, so there are still cases where further dereferencing is needed.

canonicalType :: Type -> Type #

# Other utilities

getIntType :: Flags CIntFlag -> IntType #

getFloatType :: String -> FloatType #

# Orphan instances

Eq TypeQuals # |
Methods (==) :: TypeQuals -> TypeQuals -> Bool # (/=) :: TypeQuals -> TypeQuals -> Bool #
Ord TypeQuals # |
Methods compare :: TypeQuals -> TypeQuals -> Ordering # (<) :: TypeQuals -> TypeQuals -> Bool # (<=) :: TypeQuals -> TypeQuals -> Bool # (>) :: TypeQuals -> TypeQuals -> Bool # (>=) :: TypeQuals -> TypeQuals -> Bool # max :: TypeQuals -> TypeQuals -> TypeQuals # min :: TypeQuals -> TypeQuals -> TypeQuals #