Copyright | (c) roki 2019 |
---|---|
License | MIT |
Maintainer | falgon53@yahoo.co.jp |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
The types of C language
Synopsis
- data StructMember i = StructMember {}
- data TypeKind i
- data Incomplete i
- class TypeKindBase a where
- isCTArray :: a i -> Bool
- isArray :: a i -> Bool
- isCTStruct :: a i -> Bool
- isCTUndef :: a i -> Bool
- isCTIncomplete :: a i -> Bool
- makeCTArray :: [Natural] -> a i -> a i
- concatCTArray :: Ord i => a i -> a i -> Maybe (a i)
- toTypeKind :: a i -> TypeKind i
- mapTypeKind :: (TypeKind i -> TypeKind j) -> a i -> a j
- class IncompleteBase a where
- isIncompleteArray :: a i -> Bool
- isIncompleteStruct :: a i -> Bool
- fromIncompleteStruct :: a i -> Maybe Text
- fromIncompleteArray :: a i -> Maybe (TypeKind i)
- isValidIncomplete :: Ord i => a i -> Bool
- lookupMember :: Text -> TypeKind i -> Maybe (StructMember i)
- alignas :: (Bits a, Num a, Enum a) => a -> a -> a
- data Desg i
- = DesgIdx i
- | DesgMem (StructMember i)
- accessibleIndices :: Integral i => TypeKind i -> [[Desg i]]
TypeKind data type
data StructMember i Source #
The type and offset value of a data member.
StructMember |
|
Instances
The kinds of types in C language.
CTInt | The type |
CTChar | The type |
CTSigned (TypeKind i) | The type |
CTShort (TypeKind i) | The type |
CTLong (TypeKind i) | The type |
CTBool | The type |
CTVoid | The type |
CTPtr (TypeKind i) | The pointer type of |
CTArray Natural (TypeKind i) | The array type |
CTEnum (TypeKind i) (Map Text i) | The enum, has its underlying type and a map |
CTStruct (Map Text (StructMember i)) | The struct, has its members and their names. |
CTIncomplete (Incomplete i) | The incomplete type. |
CTUndef | Undefined type |
Instances
data Incomplete i Source #
The type representing an incomplete type
IncompleteArray (TypeKind i) | incomplete array, it has a base type. |
IncompleteStruct Text | incomplete struct, it has a tag name. |
Instances
Type classes that can be converted to TypeKind
class TypeKindBase a where Source #
Class to a type based on TypeKind
.
isCTArray :: a i -> Bool Source #
isArray :: a i -> Bool Source #
isArray
return True
when the given argument is CTArray
or IncompleteArray
Otherwise, returns False
isCTStruct :: a i -> Bool Source #
isCTStruct
returns True
when the given argument is CTStruct
.
Otherwise, returns False
isCTUndef :: a i -> Bool Source #
isCTIncomplete :: a i -> Bool Source #
isCTIncomplete
returns True
when the given argument is CTIncomplete
.
makeCTArray :: [Natural] -> a i -> a i Source #
makeCTArray
retunrs a multidimensional array based on the arguments (list of each dimension).
e.g.:
>>>
makeCTArray [1, 2] CTInt
int[1][2]>>>
makeCTArray [1, 2] (CTArray 2 CTInt)
int[2][1][2]
concatCTArray :: Ord i => a i -> a i -> Maybe (a i) Source #
Only if both arguments is CTArray
,
concatCTArray
returns a new multidimensional array by conbining the types of
multidimensional arrays as follows.
>>>
makeCTArray [1, 2] CTInt `concatCTArray` makeCTArray [3, 4] CTInt
Just int[1][2][3][4]>>>
CTInt `concatCTArray` CTArray 2 CTInt
Nothing
toTypeKind :: a i -> TypeKind i Source #
Convert to TypeKind
.
mapTypeKind :: (TypeKind i -> TypeKind j) -> a i -> a j Source #
Application to TypeKind
.
Instances
class IncompleteBase a where Source #
A class requesting a type that represents an incomplete type.
isIncompleteArray :: a i -> Bool Source #
When the given argument is incomplete array, isIncompleteArray
returns True
, otherwise False
.
isIncompleteStruct :: a i -> Bool Source #
When the given argument is incmoplete struct, isIncompleteStruct
returns True
, otherwise False
.
fromIncompleteStruct :: a i -> Maybe Text Source #
Extract the tag name from IncompleteStruct
. If not IncompleteStruct
, Nothing
is retunred.
fromIncompleteArray :: a i -> Maybe (TypeKind i) Source #
Extract the type of array from IncompleteArray
. If not IncompleteArray
, Nothing
is retunred.
isValidIncomplete :: Ord i => a i -> Bool Source #
Returns True if the incomplete type is temporarily valid at the time of declaration. Otherwise returns False
.
Instances
IncompleteBase TypeKind Source # | |
Defined in Htcc.CRules.Types.TypeKind | |
IncompleteBase Incomplete Source # | |
Defined in Htcc.CRules.Types.TypeKind isIncompleteArray :: Incomplete i -> Bool Source # isIncompleteStruct :: Incomplete i -> Bool Source # fromIncompleteStruct :: Incomplete i -> Maybe Text Source # fromIncompleteArray :: Incomplete i -> Maybe (TypeKind i) Source # isValidIncomplete :: Ord i => Incomplete i -> Bool Source # | |
IncompleteBase StorageClass Source # | |
Defined in Htcc.CRules.Types.StorageClass isIncompleteArray :: StorageClass i -> Bool Source # isIncompleteStruct :: StorageClass i -> Bool Source # fromIncompleteStruct :: StorageClass i -> Maybe Text Source # fromIncompleteArray :: StorageClass i -> Maybe (TypeKind i) Source # isValidIncomplete :: Ord i => StorageClass i -> Bool Source # | |
IncompleteBase ATKind Source # | |
Defined in Htcc.Parser.AST.Core |
Lookup functions
lookupMember :: Text -> TypeKind i -> Maybe (StructMember i) Source #
lookupMember
search the specified member by its name from CTStruct
.