module Language.C.Syntax.AST (
CTranslUnit, CExtDecl,
CTranslationUnit(..), CExternalDeclaration(..),
CFunDef, CDecl, CStructUnion, CEnum,
CFunctionDef(..), CDeclaration(..),
CStructTag(..), CStructureUnion(..), CEnumeration(..),
CDeclSpec, partitionDeclSpecs,
CStorageSpec, CTypeSpec, isSUEDef, CTypeQual, CAttr,
CDeclarationSpecifier(..), CStorageSpecifier(..), CTypeSpecifier(..),
CTypeQualifier(..), CAttribute(..),
CDeclr,CDerivedDeclr,CArrSize,
CDeclarator(..), CDerivedDeclarator(..), CArraySize(..),
CInit, CInitList, CDesignator,
CInitializer(..), CInitializerList, CPartDesignator(..),
CStat, CBlockItem, CAsmStmt, CAsmOperand,
CStatement(..), CCompoundBlockItem(..),
CAssemblyStatement(..), CAssemblyOperand(..),
CExpr, CExpression(..),
CAssignOp(..), CBinaryOp(..), CUnaryOp(..),
CBuiltin, CBuiltinThing(..),
CConst, CStrLit, cstringOfLit, liftStrLit,
CConstant(..), CStringLiteral(..),
Annotated(..)
) where
import Data.List
import Language.C.Syntax.Constants
import Language.C.Syntax.Ops
import Language.C.Data.Ident
import Language.C.Data.Node
import Language.C.Data.Position
import Data.Generics
type CTranslUnit = CTranslationUnit NodeInfo
data CTranslationUnit a
= CTranslUnit [CExternalDeclaration a] a
deriving (Show, Data, Typeable )
type CExtDecl = CExternalDeclaration NodeInfo
data CExternalDeclaration a
= CDeclExt (CDeclaration a)
| CFDefExt (CFunctionDef a)
| CAsmExt (CStringLiteral a) a
deriving (Show, Data,Typeable )
type CFunDef = CFunctionDef NodeInfo
data CFunctionDef a
= CFunDef
[CDeclarationSpecifier a]
(CDeclarator a)
[CDeclaration a]
(CStatement a)
a
deriving (Show, Data,Typeable )
type CDecl = CDeclaration NodeInfo
data CDeclaration a
= CDecl
[CDeclarationSpecifier a]
[(Maybe (CDeclarator a),
Maybe (CInitializer a),
Maybe (CExpression a))]
a
deriving (Show, Data,Typeable )
instance Functor CDeclaration where
fmap f (CDecl specs declarators annot) =
CDecl (map (fmap f) specs) (map fmap3m declarators) (f annot)
where fmap3m (a,b,c) = (fmap (fmap f) a, fmap (fmap f) b, fmap (fmap f) c)
type CDeclr = CDeclarator NodeInfo
data CDeclarator a
= CDeclr (Maybe Ident) [CDerivedDeclarator a] (Maybe (CStringLiteral a)) [CAttribute a] a
deriving (Show, Data,Typeable )
type CDerivedDeclr = CDerivedDeclarator NodeInfo
data CDerivedDeclarator a
= CPtrDeclr [CTypeQualifier a] a
| CArrDeclr [CTypeQualifier a] (CArraySize a) a
| CFunDeclr (Either [Ident] ([CDeclaration a],Bool)) [CAttribute a] a
deriving (Show, Data,Typeable )
instance Functor CDerivedDeclarator where
fmap _f (CPtrDeclr a1 a2) = CPtrDeclr (fmap (fmap _f) a1) (_f a2)
fmap _f (CArrDeclr a1 a2 a3)
= CArrDeclr (fmap (fmap _f) a1) (fmap _f a2) (_f a3)
fmap _f (CFunDeclr a1 a2 a3)
= CFunDeclr (fmap (fmapFirst (fmap (fmap _f))) a1) (fmap (fmap _f) a2)
(_f a3)
where fmapFirst f (a,b) = (f a, b)
type CArrSize = CArraySize NodeInfo
data CArraySize a
= CNoArrSize Bool
| CArrSize Bool (CExpression a)
deriving (Show, Data,Typeable )
type CStat = CStatement NodeInfo
data CStatement a
= CLabel Ident (CStatement a) [CAttribute a] a
| CCase (CExpression a) (CStatement a) a
| CCases (CExpression a) (CExpression a) (CStatement a) a
| CDefault (CStatement a) a
| CExpr (Maybe (CExpression a)) a
| CCompound [Ident] [CCompoundBlockItem a] a
| CIf (CExpression a) (CStatement a) (Maybe (CStatement a)) a
| CSwitch (CExpression a) (CStatement a) a
| CWhile (CExpression a) (CStatement a) Bool a
| CFor (Either (Maybe (CExpression a)) (CDeclaration a))
(Maybe (CExpression a))
(Maybe (CExpression a))
(CStatement a)
a
| CGoto Ident a
| CGotoPtr (CExpression a) a
| CCont a
| CBreak a
| CReturn (Maybe (CExpression a)) a
| CAsm (CAssemblyStatement a) a
deriving (Show, Data,Typeable )
instance Functor CStatement where
fmap _f (CLabel a1 a2 a3 a4)
= CLabel a1 (fmap _f a2) (fmap (fmap _f) a3) (_f a4)
fmap _f (CCase a1 a2 a3) = CCase (fmap _f a1) (fmap _f a2) (_f a3)
fmap _f (CCases a1 a2 a3 a4)
= CCases (fmap _f a1) (fmap _f a2) (fmap _f a3) (_f a4)
fmap _f (CDefault a1 a2) = CDefault (fmap _f a1) (_f a2)
fmap _f (CExpr a1 a2) = CExpr (fmap (fmap _f) a1) (_f a2)
fmap _f (CCompound a1 a2 a3)
= CCompound a1 (fmap (fmap _f) a2) (_f a3)
fmap _f (CIf a1 a2 a3 a4)
= CIf (fmap _f a1) (fmap _f a2) (fmap (fmap _f) a3) (_f a4)
fmap _f (CSwitch a1 a2 a3)
= CSwitch (fmap _f a1) (fmap _f a2) (_f a3)
fmap _f (CWhile a1 a2 a3 a4)
= CWhile (fmap _f a1) (fmap _f a2) a3 (_f a4)
fmap _f (CFor a1 a2 a3 a4 a5)
= CFor (mapEither (fmap (fmap _f)) (fmap _f) a1)
(fmap (fmap _f) a2) (fmap (fmap _f) a3) (fmap _f a4)
(_f a5)
where mapEither f1 f2 = either (Left . f1) (Right . f2)
fmap _f (CGoto a1 a2) = CGoto a1 (_f a2)
fmap _f (CGotoPtr a1 a2) = CGotoPtr (fmap _f a1) (_f a2)
fmap _f (CCont a1) = CCont (_f a1)
fmap _f (CBreak a1) = CBreak (_f a1)
fmap _f (CReturn a1 a2) = CReturn (fmap (fmap _f) a1) (_f a2)
fmap _f (CAsm a1 a2) = CAsm (fmap _f a1) (_f a2)
type CAsmStmt = CAssemblyStatement NodeInfo
data CAssemblyStatement a
= CAsmStmt
(Maybe (CTypeQualifier a))
(CStringLiteral a)
[CAssemblyOperand a]
[CAssemblyOperand a]
[CStringLiteral a]
a
deriving (Show, Data,Typeable )
type CAsmOperand = CAssemblyOperand NodeInfo
data CAssemblyOperand a
= CAsmOperand
(Maybe Ident)
(CStringLiteral a)
(CExpression a)
a
deriving (Show, Data,Typeable )
type CBlockItem = CCompoundBlockItem NodeInfo
data CCompoundBlockItem a
= CBlockStmt (CStatement a)
| CBlockDecl (CDeclaration a)
| CNestedFunDef (CFunctionDef a)
deriving (Show, Data,Typeable )
type CDeclSpec = CDeclarationSpecifier NodeInfo
data CDeclarationSpecifier a
= CStorageSpec (CStorageSpecifier a)
| CTypeSpec (CTypeSpecifier a)
| CTypeQual (CTypeQualifier a)
deriving (Show, Data,Typeable )
partitionDeclSpecs :: [CDeclarationSpecifier a]
-> ( [CStorageSpecifier a], [CAttribute a]
, [CTypeQualifier a], [CTypeSpecifier a], Bool)
partitionDeclSpecs = foldr deals ([],[],[],[],False) where
deals (CTypeQual (CInlineQual _)) (sts,ats,tqs,tss,_) = (sts,ats,tqs,tss,True)
deals (CStorageSpec sp) (sts,ats,tqs,tss,inline) = (sp:sts,ats,tqs,tss,inline)
deals (CTypeQual (CAttrQual attr)) (sts,ats,tqs,tss,inline) = (sts,attr:ats,tqs,tss,inline)
deals (CTypeQual tq) (sts,ats,tqs,tss,inline) = (sts,ats,tq:tqs,tss,inline)
deals (CTypeSpec ts) (sts,ats,tqs,tss,inline) = (sts,ats,tqs,ts:tss,inline)
type CStorageSpec = CStorageSpecifier NodeInfo
data CStorageSpecifier a
= CAuto a
| CRegister a
| CStatic a
| CExtern a
| CTypedef a
| CThread a
deriving (Show, Eq,Ord,Data,Typeable )
type CTypeSpec = CTypeSpecifier NodeInfo
data CTypeSpecifier a
= CVoidType a
| CCharType a
| CShortType a
| CIntType a
| CLongType a
| CFloatType a
| CDoubleType a
| CSignedType a
| CUnsigType a
| CBoolType a
| CComplexType a
| CSUType (CStructureUnion a) a
| CEnumType (CEnumeration a) a
| CTypeDef Ident a
| CTypeOfExpr (CExpression a) a
| CTypeOfType (CDeclaration a) a
deriving (Show, Data,Typeable )
isSUEDef :: CTypeSpecifier a -> Bool
isSUEDef (CSUType (CStruct _ _ (Just _) _ _) _) = True
isSUEDef (CEnumType (CEnum _ (Just _) _ _) _) = True
isSUEDef _ = False
type CTypeQual = CTypeQualifier NodeInfo
data CTypeQualifier a
= CConstQual a
| CVolatQual a
| CRestrQual a
| CInlineQual a
| CAttrQual (CAttribute a)
deriving (Show, Data,Typeable )
type CStructUnion = CStructureUnion NodeInfo
data CStructureUnion a
= CStruct
CStructTag
(Maybe Ident)
(Maybe [CDeclaration a])
[CAttribute a]
a
deriving (Show, Data,Typeable )
data CStructTag = CStructTag
| CUnionTag
deriving (Show, Eq,Data,Typeable)
type CEnum = CEnumeration NodeInfo
data CEnumeration a
= CEnum
(Maybe Ident)
(Maybe [(Ident,
Maybe (CExpression a))])
[CAttribute a]
a
deriving (Show, Data,Typeable )
type CInit = CInitializer NodeInfo
data CInitializer a
= CInitExpr (CExpression a) a
| CInitList (CInitializerList a) a
deriving (Show, Data,Typeable )
instance Functor CInitializer where
fmap _f (CInitExpr a1 a2) = CInitExpr (fmap _f a1) (_f a2)
fmap _f (CInitList a1 a2) = CInitList (fmapInitList _f a1) (_f a2)
fmapInitList :: (a->b) -> (CInitializerList a) -> (CInitializerList b)
fmapInitList _f = map (\(desigs, initializer) -> (fmap (fmap _f) desigs, fmap _f initializer))
type CInitList = CInitializerList NodeInfo
type CInitializerList a = [([CPartDesignator a], CInitializer a)]
type CDesignator = CPartDesignator NodeInfo
data CPartDesignator a
= CArrDesig (CExpression a) a
| CMemberDesig Ident a
| CRangeDesig (CExpression a) (CExpression a) a
deriving (Show, Data,Typeable )
type CAttr = CAttribute NodeInfo
data CAttribute a = CAttr Ident [CExpression a] a
deriving (Show, Data,Typeable )
type CExpr = CExpression NodeInfo
data CExpression a
= CComma [CExpression a]
a
| CAssign CAssignOp
(CExpression a)
(CExpression a)
a
| CCond (CExpression a)
(Maybe (CExpression a))
(CExpression a)
a
| CBinary CBinaryOp
(CExpression a)
(CExpression a)
a
| CCast (CDeclaration a)
(CExpression a)
a
| CUnary CUnaryOp
(CExpression a)
a
| CSizeofExpr (CExpression a)
a
| CSizeofType (CDeclaration a)
a
| CAlignofExpr (CExpression a)
a
| CAlignofType (CDeclaration a)
a
| CComplexReal (CExpression a)
a
| CComplexImag (CExpression a)
a
| CIndex (CExpression a)
(CExpression a)
a
| CCall (CExpression a)
[CExpression a]
a
| CMember (CExpression a)
Ident
Bool
a
| CVar Ident
a
| CConst (CConstant a)
| CCompoundLit (CDeclaration a)
(CInitializerList a)
a
| CStatExpr (CStatement a) a
| CLabAddrExpr Ident a
| CBuiltinExpr (CBuiltinThing a)
deriving (Data,Typeable,Show )
instance Functor CExpression where
fmap _f (CComma a1 a2) = CComma (fmap (fmap _f) a1) (_f a2)
fmap _f (CAssign a1 a2 a3 a4)
= CAssign a1 (fmap _f a2) (fmap _f a3) (_f a4)
fmap _f (CCond a1 a2 a3 a4)
= CCond (fmap _f a1) (fmap (fmap _f) a2) (fmap _f a3) (_f a4)
fmap _f (CBinary a1 a2 a3 a4)
= CBinary a1 (fmap _f a2) (fmap _f a3) (_f a4)
fmap _f (CCast a1 a2 a3) = CCast (fmap _f a1) (fmap _f a2) (_f a3)
fmap _f (CUnary a1 a2 a3) = CUnary a1 (fmap _f a2) (_f a3)
fmap _f (CSizeofExpr a1 a2) = CSizeofExpr (fmap _f a1) (_f a2)
fmap _f (CSizeofType a1 a2) = CSizeofType (fmap _f a1) (_f a2)
fmap _f (CAlignofExpr a1 a2) = CAlignofExpr (fmap _f a1) (_f a2)
fmap _f (CAlignofType a1 a2) = CAlignofType (fmap _f a1) (_f a2)
fmap _f (CComplexReal a1 a2) = CComplexReal (fmap _f a1) (_f a2)
fmap _f (CComplexImag a1 a2) = CComplexImag (fmap _f a1) (_f a2)
fmap _f (CIndex a1 a2 a3)
= CIndex (fmap _f a1) (fmap _f a2) (_f a3)
fmap _f (CCall a1 a2 a3)
= CCall (fmap _f a1) (fmap (fmap _f) a2) (_f a3)
fmap _f (CMember a1 a2 a3 a4) = CMember (fmap _f a1) a2 a3 (_f a4)
fmap _f (CVar a1 a2) = CVar a1 (_f a2)
fmap _f (CConst a1) = CConst (fmap _f a1)
fmap _f (CCompoundLit a1 a2 a3)
= CCompoundLit (fmap _f a1) (fmapInitList _f a2) (_f a3)
fmap _f (CStatExpr a1 a2) = CStatExpr (fmap _f a1) (_f a2)
fmap _f (CLabAddrExpr a1 a2) = CLabAddrExpr a1 (_f a2)
fmap _f (CBuiltinExpr a1) = CBuiltinExpr (fmap _f a1)
type CBuiltin = CBuiltinThing NodeInfo
data CBuiltinThing a
= CBuiltinVaArg (CExpression a) (CDeclaration a) a
| CBuiltinOffsetOf (CDeclaration a) [CPartDesignator a] a
| CBuiltinTypesCompatible (CDeclaration a) (CDeclaration a) a
deriving (Show, Data,Typeable )
type CConst = CConstant NodeInfo
data CConstant a
= CIntConst CInteger a
| CCharConst CChar a
| CFloatConst CFloat a
| CStrConst CString a
deriving (Show, Data,Typeable )
type CStrLit = CStringLiteral NodeInfo
data CStringLiteral a = CStrLit CString a
deriving (Show, Data,Typeable )
cstringOfLit :: CStringLiteral a -> CString
cstringOfLit (CStrLit cstr _) = cstr
liftStrLit :: CStringLiteral a -> CConstant a
liftStrLit (CStrLit str at) = CStrConst str at
class (Functor ast) => Annotated ast where
annotation :: ast a -> a
amap :: (a->a) -> ast a -> ast a
instance (CNode t1) => CNode (CTranslationUnit t1) where
nodeInfo (CTranslUnit _ n) = nodeInfo n
instance (CNode t1) => Pos (CTranslationUnit t1) where
posOf x = posOf (nodeInfo x)
instance Functor CTranslationUnit where
fmap _f (CTranslUnit a1 a2)
= CTranslUnit (fmap (fmap _f) a1) (_f a2)
instance Annotated CTranslationUnit where
annotation (CTranslUnit _ n) = n
amap f (CTranslUnit a_1 a_2) = CTranslUnit a_1 (f a_2)
instance (CNode t1) => CNode (CExternalDeclaration t1) where
nodeInfo (CDeclExt d) = nodeInfo d
nodeInfo (CFDefExt d) = nodeInfo d
nodeInfo (CAsmExt _ n) = nodeInfo n
instance (CNode t1) => Pos (CExternalDeclaration t1) where
posOf x = posOf (nodeInfo x)
instance Functor CExternalDeclaration where
fmap _f (CDeclExt a1) = CDeclExt (fmap _f a1)
fmap _f (CFDefExt a1) = CFDefExt (fmap _f a1)
fmap _f (CAsmExt a1 a2) = CAsmExt (fmap _f a1) (_f a2)
instance Annotated CExternalDeclaration where
annotation (CDeclExt n) = annotation n
annotation (CFDefExt n) = annotation n
annotation (CAsmExt _ n) = n
amap f (CDeclExt n) = CDeclExt (amap f n)
amap f (CFDefExt n) = CFDefExt (amap f n)
amap f (CAsmExt a_1 a_2) = CAsmExt a_1 (f a_2)
instance (CNode t1) => CNode (CFunctionDef t1) where
nodeInfo (CFunDef _ _ _ _ n) = nodeInfo n
instance (CNode t1) => Pos (CFunctionDef t1) where
posOf x = posOf (nodeInfo x)
instance Functor CFunctionDef where
fmap _f (CFunDef a1 a2 a3 a4 a5)
= CFunDef (fmap (fmap _f) a1) (fmap _f a2) (fmap (fmap _f) a3)
(fmap _f a4)
(_f a5)
instance Annotated CFunctionDef where
annotation (CFunDef _ _ _ _ n) = n
amap f (CFunDef a_1 a_2 a_3 a_4 a_5)
= CFunDef a_1 a_2 a_3 a_4 (f a_5)
instance (CNode t1) => CNode (CDeclaration t1) where
nodeInfo (CDecl _ _ n) = nodeInfo n
instance (CNode t1) => Pos (CDeclaration t1) where
posOf x = posOf (nodeInfo x)
instance Annotated CDeclaration where
annotation (CDecl _ _ n) = n
amap f (CDecl a_1 a_2 a_3) = CDecl a_1 a_2 (f a_3)
instance (CNode t1) => CNode (CDeclarator t1) where
nodeInfo (CDeclr _ _ _ _ n) = nodeInfo n
instance (CNode t1) => Pos (CDeclarator t1) where
posOf x = posOf (nodeInfo x)
instance Functor CDeclarator where
fmap _f (CDeclr a1 a2 a3 a4 a5)
= CDeclr a1 (fmap (fmap _f) a2) (fmap (fmap _f) a3)
(fmap (fmap _f) a4)
(_f a5)
instance Annotated CDeclarator where
annotation (CDeclr _ _ _ _ n) = n
amap f (CDeclr a_1 a_2 a_3 a_4 a_5)
= CDeclr a_1 a_2 a_3 a_4 (f a_5)
instance (CNode t1) => CNode (CDerivedDeclarator t1) where
nodeInfo (CPtrDeclr _ n) = nodeInfo n
nodeInfo (CArrDeclr _ _ n) = nodeInfo n
nodeInfo (CFunDeclr _ _ n) = nodeInfo n
instance (CNode t1) => Pos (CDerivedDeclarator t1) where
posOf x = posOf (nodeInfo x)
instance Annotated CDerivedDeclarator where
annotation (CPtrDeclr _ n) = n
annotation (CArrDeclr _ _ n) = n
annotation (CFunDeclr _ _ n) = n
amap f (CPtrDeclr a_1 a_2) = CPtrDeclr a_1 (f a_2)
amap f (CArrDeclr a_1 a_2 a_3) = CArrDeclr a_1 a_2 (f a_3)
amap f (CFunDeclr a_1 a_2 a_3) = CFunDeclr a_1 a_2 (f a_3)
instance Functor CArraySize where
fmap _ (CNoArrSize a1) = CNoArrSize a1
fmap _f (CArrSize a1 a2) = CArrSize a1 (fmap _f a2)
instance (CNode t1) => CNode (CStatement t1) where
nodeInfo (CLabel _ _ _ n) = nodeInfo n
nodeInfo (CCase _ _ n) = nodeInfo n
nodeInfo (CCases _ _ _ n) = nodeInfo n
nodeInfo (CDefault _ n) = nodeInfo n
nodeInfo (CExpr _ n) = nodeInfo n
nodeInfo (CCompound _ _ n) = nodeInfo n
nodeInfo (CIf _ _ _ n) = nodeInfo n
nodeInfo (CSwitch _ _ n) = nodeInfo n
nodeInfo (CWhile _ _ _ n) = nodeInfo n
nodeInfo (CFor _ _ _ _ n) = nodeInfo n
nodeInfo (CGoto _ n) = nodeInfo n
nodeInfo (CGotoPtr _ n) = nodeInfo n
nodeInfo (CCont d) = nodeInfo d
nodeInfo (CBreak d) = nodeInfo d
nodeInfo (CReturn _ n) = nodeInfo n
nodeInfo (CAsm _ n) = nodeInfo n
instance (CNode t1) => Pos (CStatement t1) where
posOf x = posOf (nodeInfo x)
instance Annotated CStatement where
annotation (CLabel _ _ _ n) = n
annotation (CCase _ _ n) = n
annotation (CCases _ _ _ n) = n
annotation (CDefault _ n) = n
annotation (CExpr _ n) = n
annotation (CCompound _ _ n) = n
annotation (CIf _ _ _ n) = n
annotation (CSwitch _ _ n) = n
annotation (CWhile _ _ _ n) = n
annotation (CFor _ _ _ _ n) = n
annotation (CGoto _ n) = n
annotation (CGotoPtr _ n) = n
annotation (CCont n) = n
annotation (CBreak n) = n
annotation (CReturn _ n) = n
annotation (CAsm _ n) = n
amap f (CLabel a_1 a_2 a_3 a_4) = CLabel a_1 a_2 a_3 (f a_4)
amap f (CCase a_1 a_2 a_3) = CCase a_1 a_2 (f a_3)
amap f (CCases a_1 a_2 a_3 a_4) = CCases a_1 a_2 a_3 (f a_4)
amap f (CDefault a_1 a_2) = CDefault a_1 (f a_2)
amap f (CExpr a_1 a_2) = CExpr a_1 (f a_2)
amap f (CCompound a_1 a_2 a_3) = CCompound a_1 a_2 (f a_3)
amap f (CIf a_1 a_2 a_3 a_4) = CIf a_1 a_2 a_3 (f a_4)
amap f (CSwitch a_1 a_2 a_3) = CSwitch a_1 a_2 (f a_3)
amap f (CWhile a_1 a_2 a_3 a_4) = CWhile a_1 a_2 a_3 (f a_4)
amap f (CFor a_1 a_2 a_3 a_4 a_5) = CFor a_1 a_2 a_3 a_4 (f a_5)
amap f (CGoto a_1 a_2) = CGoto a_1 (f a_2)
amap f (CGotoPtr a_1 a_2) = CGotoPtr a_1 (f a_2)
amap f (CCont a_1) = CCont (f a_1)
amap f (CBreak a_1) = CBreak (f a_1)
amap f (CReturn a_1 a_2) = CReturn a_1 (f a_2)
amap f (CAsm a_1 a_2) = CAsm a_1 (f a_2)
instance (CNode t1) => CNode (CAssemblyStatement t1) where
nodeInfo (CAsmStmt _ _ _ _ _ n) = nodeInfo n
instance (CNode t1) => Pos (CAssemblyStatement t1) where
posOf x = posOf (nodeInfo x)
instance Functor CAssemblyStatement where
fmap _f (CAsmStmt a1 a2 a3 a4 a5 a6)
= CAsmStmt (fmap (fmap _f) a1) (fmap _f a2) (fmap (fmap _f) a3)
(fmap (fmap _f) a4)
(fmap (fmap _f) a5)
(_f a6)
instance Annotated CAssemblyStatement where
annotation (CAsmStmt _ _ _ _ _ n) = n
amap f (CAsmStmt a_1 a_2 a_3 a_4 a_5 a_6)
= CAsmStmt a_1 a_2 a_3 a_4 a_5 (f a_6)
instance (CNode t1) => CNode (CAssemblyOperand t1) where
nodeInfo (CAsmOperand _ _ _ n) = nodeInfo n
instance (CNode t1) => Pos (CAssemblyOperand t1) where
posOf x = posOf (nodeInfo x)
instance Functor CAssemblyOperand where
fmap _f (CAsmOperand a1 a2 a3 a4)
= CAsmOperand a1 (fmap _f a2) (fmap _f a3) (_f a4)
instance Annotated CAssemblyOperand where
annotation (CAsmOperand _ _ _ n) = n
amap f (CAsmOperand a_1 a_2 a_3 a_4)
= CAsmOperand a_1 a_2 a_3 (f a_4)
instance (CNode t1) => CNode (CCompoundBlockItem t1) where
nodeInfo (CBlockStmt d) = nodeInfo d
nodeInfo (CBlockDecl d) = nodeInfo d
nodeInfo (CNestedFunDef d) = nodeInfo d
instance (CNode t1) => Pos (CCompoundBlockItem t1) where
posOf x = posOf (nodeInfo x)
instance Functor CCompoundBlockItem where
fmap _f (CBlockStmt a1) = CBlockStmt (fmap _f a1)
fmap _f (CBlockDecl a1) = CBlockDecl (fmap _f a1)
fmap _f (CNestedFunDef a1) = CNestedFunDef (fmap _f a1)
instance Annotated CCompoundBlockItem where
annotation (CBlockStmt n) = annotation n
annotation (CBlockDecl n) = annotation n
annotation (CNestedFunDef n) = annotation n
amap f (CBlockStmt n) = CBlockStmt (amap f n)
amap f (CBlockDecl n) = CBlockDecl (amap f n)
amap f (CNestedFunDef n) = CNestedFunDef (amap f n)
instance (CNode t1) => CNode (CDeclarationSpecifier t1) where
nodeInfo (CStorageSpec d) = nodeInfo d
nodeInfo (CTypeSpec d) = nodeInfo d
nodeInfo (CTypeQual d) = nodeInfo d
instance (CNode t1) => Pos (CDeclarationSpecifier t1) where
posOf x = posOf (nodeInfo x)
instance Functor CDeclarationSpecifier where
fmap _f (CStorageSpec a1) = CStorageSpec (fmap _f a1)
fmap _f (CTypeSpec a1) = CTypeSpec (fmap _f a1)
fmap _f (CTypeQual a1) = CTypeQual (fmap _f a1)
instance Annotated CDeclarationSpecifier where
annotation (CStorageSpec n) = annotation n
annotation (CTypeSpec n) = annotation n
annotation (CTypeQual n) = annotation n
amap f (CStorageSpec n) = CStorageSpec (amap f n)
amap f (CTypeSpec n) = CTypeSpec (amap f n)
amap f (CTypeQual n) = CTypeQual (amap f n)
instance (CNode t1) => CNode (CStorageSpecifier t1) where
nodeInfo (CAuto d) = nodeInfo d
nodeInfo (CRegister d) = nodeInfo d
nodeInfo (CStatic d) = nodeInfo d
nodeInfo (CExtern d) = nodeInfo d
nodeInfo (CTypedef d) = nodeInfo d
nodeInfo (CThread d) = nodeInfo d
instance (CNode t1) => Pos (CStorageSpecifier t1) where
posOf x = posOf (nodeInfo x)
instance Functor CStorageSpecifier where
fmap _f (CAuto a1) = CAuto (_f a1)
fmap _f (CRegister a1) = CRegister (_f a1)
fmap _f (CStatic a1) = CStatic (_f a1)
fmap _f (CExtern a1) = CExtern (_f a1)
fmap _f (CTypedef a1) = CTypedef (_f a1)
fmap _f (CThread a1) = CThread (_f a1)
instance Annotated CStorageSpecifier where
annotation (CAuto n) = n
annotation (CRegister n) = n
annotation (CStatic n) = n
annotation (CExtern n) = n
annotation (CTypedef n) = n
annotation (CThread n) = n
amap f (CAuto a_1) = CAuto (f a_1)
amap f (CRegister a_1) = CRegister (f a_1)
amap f (CStatic a_1) = CStatic (f a_1)
amap f (CExtern a_1) = CExtern (f a_1)
amap f (CTypedef a_1) = CTypedef (f a_1)
amap f (CThread a_1) = CThread (f a_1)
instance (CNode t1) => CNode (CTypeSpecifier t1) where
nodeInfo (CVoidType d) = nodeInfo d
nodeInfo (CCharType d) = nodeInfo d
nodeInfo (CShortType d) = nodeInfo d
nodeInfo (CIntType d) = nodeInfo d
nodeInfo (CLongType d) = nodeInfo d
nodeInfo (CFloatType d) = nodeInfo d
nodeInfo (CDoubleType d) = nodeInfo d
nodeInfo (CSignedType d) = nodeInfo d
nodeInfo (CUnsigType d) = nodeInfo d
nodeInfo (CBoolType d) = nodeInfo d
nodeInfo (CComplexType d) = nodeInfo d
nodeInfo (CSUType _ n) = nodeInfo n
nodeInfo (CEnumType _ n) = nodeInfo n
nodeInfo (CTypeDef _ n) = nodeInfo n
nodeInfo (CTypeOfExpr _ n) = nodeInfo n
nodeInfo (CTypeOfType _ n) = nodeInfo n
instance (CNode t1) => Pos (CTypeSpecifier t1) where
posOf x = posOf (nodeInfo x)
instance Functor CTypeSpecifier where
fmap _f (CVoidType a1) = CVoidType (_f a1)
fmap _f (CCharType a1) = CCharType (_f a1)
fmap _f (CShortType a1) = CShortType (_f a1)
fmap _f (CIntType a1) = CIntType (_f a1)
fmap _f (CLongType a1) = CLongType (_f a1)
fmap _f (CFloatType a1) = CFloatType (_f a1)
fmap _f (CDoubleType a1) = CDoubleType (_f a1)
fmap _f (CSignedType a1) = CSignedType (_f a1)
fmap _f (CUnsigType a1) = CUnsigType (_f a1)
fmap _f (CBoolType a1) = CBoolType (_f a1)
fmap _f (CComplexType a1) = CComplexType (_f a1)
fmap _f (CSUType a1 a2) = CSUType (fmap _f a1) (_f a2)
fmap _f (CEnumType a1 a2) = CEnumType (fmap _f a1) (_f a2)
fmap _f (CTypeDef a1 a2) = CTypeDef a1 (_f a2)
fmap _f (CTypeOfExpr a1 a2) = CTypeOfExpr (fmap _f a1) (_f a2)
fmap _f (CTypeOfType a1 a2) = CTypeOfType (fmap _f a1) (_f a2)
instance Annotated CTypeSpecifier where
annotation (CVoidType n) = n
annotation (CCharType n) = n
annotation (CShortType n) = n
annotation (CIntType n) = n
annotation (CLongType n) = n
annotation (CFloatType n) = n
annotation (CDoubleType n) = n
annotation (CSignedType n) = n
annotation (CUnsigType n) = n
annotation (CBoolType n) = n
annotation (CComplexType n) = n
annotation (CSUType _ n) = n
annotation (CEnumType _ n) = n
annotation (CTypeDef _ n) = n
annotation (CTypeOfExpr _ n) = n
annotation (CTypeOfType _ n) = n
amap f (CVoidType a_1) = CVoidType (f a_1)
amap f (CCharType a_1) = CCharType (f a_1)
amap f (CShortType a_1) = CShortType (f a_1)
amap f (CIntType a_1) = CIntType (f a_1)
amap f (CLongType a_1) = CLongType (f a_1)
amap f (CFloatType a_1) = CFloatType (f a_1)
amap f (CDoubleType a_1) = CDoubleType (f a_1)
amap f (CSignedType a_1) = CSignedType (f a_1)
amap f (CUnsigType a_1) = CUnsigType (f a_1)
amap f (CBoolType a_1) = CBoolType (f a_1)
amap f (CComplexType a_1) = CComplexType (f a_1)
amap f (CSUType a_1 a_2) = CSUType a_1 (f a_2)
amap f (CEnumType a_1 a_2) = CEnumType a_1 (f a_2)
amap f (CTypeDef a_1 a_2) = CTypeDef a_1 (f a_2)
amap f (CTypeOfExpr a_1 a_2) = CTypeOfExpr a_1 (f a_2)
amap f (CTypeOfType a_1 a_2) = CTypeOfType a_1 (f a_2)
instance (CNode t1) => CNode (CTypeQualifier t1) where
nodeInfo (CConstQual d) = nodeInfo d
nodeInfo (CVolatQual d) = nodeInfo d
nodeInfo (CRestrQual d) = nodeInfo d
nodeInfo (CInlineQual d) = nodeInfo d
nodeInfo (CAttrQual d) = nodeInfo d
instance (CNode t1) => Pos (CTypeQualifier t1) where
posOf x = posOf (nodeInfo x)
instance Functor CTypeQualifier where
fmap _f (CConstQual a1) = CConstQual (_f a1)
fmap _f (CVolatQual a1) = CVolatQual (_f a1)
fmap _f (CRestrQual a1) = CRestrQual (_f a1)
fmap _f (CInlineQual a1) = CInlineQual (_f a1)
fmap _f (CAttrQual a1) = CAttrQual (fmap _f a1)
instance Annotated CTypeQualifier where
annotation (CConstQual n) = n
annotation (CVolatQual n) = n
annotation (CRestrQual n) = n
annotation (CInlineQual n) = n
annotation (CAttrQual n) = annotation n
amap f (CConstQual a_1) = CConstQual (f a_1)
amap f (CVolatQual a_1) = CVolatQual (f a_1)
amap f (CRestrQual a_1) = CRestrQual (f a_1)
amap f (CInlineQual a_1) = CInlineQual (f a_1)
amap f (CAttrQual n) = CAttrQual (amap f n)
instance (CNode t1) => CNode (CStructureUnion t1) where
nodeInfo (CStruct _ _ _ _ n) = nodeInfo n
instance (CNode t1) => Pos (CStructureUnion t1) where
posOf x = posOf (nodeInfo x)
instance Functor CStructureUnion where
fmap _f (CStruct a1 a2 a3 a4 a5)
= CStruct a1 a2 (fmap (fmap (fmap _f)) a3) (fmap (fmap _f) a4)
(_f a5)
instance Annotated CStructureUnion where
annotation (CStruct _ _ _ _ n) = n
amap f (CStruct a_1 a_2 a_3 a_4 a_5)
= CStruct a_1 a_2 a_3 a_4 (f a_5)
instance (CNode t1) => CNode (CEnumeration t1) where
nodeInfo (CEnum _ _ _ n) = nodeInfo n
instance (CNode t1) => Pos (CEnumeration t1) where
posOf x = posOf (nodeInfo x)
instance Functor CEnumeration where
fmap _f (CEnum a1 a2 a3 a4)
= CEnum a1 (fmap (fmap (fmap (fmap (fmap _f)))) a2)
(fmap (fmap _f) a3)
(_f a4)
instance Annotated CEnumeration where
annotation (CEnum _ _ _ n) = n
amap f (CEnum a_1 a_2 a_3 a_4) = CEnum a_1 a_2 a_3 (f a_4)
instance (CNode t1) => CNode (CInitializer t1) where
nodeInfo (CInitExpr _ n) = nodeInfo n
nodeInfo (CInitList _ n) = nodeInfo n
instance (CNode t1) => Pos (CInitializer t1) where
posOf x = posOf (nodeInfo x)
instance Annotated CInitializer where
annotation (CInitExpr _ n) = n
annotation (CInitList _ n) = n
amap f (CInitExpr a_1 a_2) = CInitExpr a_1 (f a_2)
amap f (CInitList a_1 a_2) = CInitList a_1 (f a_2)
instance (CNode t1) => CNode (CPartDesignator t1) where
nodeInfo (CArrDesig _ n) = nodeInfo n
nodeInfo (CMemberDesig _ n) = nodeInfo n
nodeInfo (CRangeDesig _ _ n) = nodeInfo n
instance (CNode t1) => Pos (CPartDesignator t1) where
posOf x = posOf (nodeInfo x)
instance Functor CPartDesignator where
fmap _f (CArrDesig a1 a2) = CArrDesig (fmap _f a1) (_f a2)
fmap _f (CMemberDesig a1 a2) = CMemberDesig a1 (_f a2)
fmap _f (CRangeDesig a1 a2 a3)
= CRangeDesig (fmap _f a1) (fmap _f a2) (_f a3)
instance Annotated CPartDesignator where
annotation (CArrDesig _ n) = n
annotation (CMemberDesig _ n) = n
annotation (CRangeDesig _ _ n) = n
amap f (CArrDesig a_1 a_2) = CArrDesig a_1 (f a_2)
amap f (CMemberDesig a_1 a_2) = CMemberDesig a_1 (f a_2)
amap f (CRangeDesig a_1 a_2 a_3) = CRangeDesig a_1 a_2 (f a_3)
instance (CNode t1) => CNode (CAttribute t1) where
nodeInfo (CAttr _ _ n) = nodeInfo n
instance (CNode t1) => Pos (CAttribute t1) where
posOf x = posOf (nodeInfo x)
instance Functor CAttribute where
fmap _f (CAttr a1 a2 a3) = CAttr a1 (fmap (fmap _f) a2) (_f a3)
instance Annotated CAttribute where
annotation (CAttr _ _ n) = n
amap f (CAttr a_1 a_2 a_3) = CAttr a_1 a_2 (f a_3)
instance (CNode t1) => CNode (CExpression t1) where
nodeInfo (CComma _ n) = nodeInfo n
nodeInfo (CAssign _ _ _ n) = nodeInfo n
nodeInfo (CCond _ _ _ n) = nodeInfo n
nodeInfo (CBinary _ _ _ n) = nodeInfo n
nodeInfo (CCast _ _ n) = nodeInfo n
nodeInfo (CUnary _ _ n) = nodeInfo n
nodeInfo (CSizeofExpr _ n) = nodeInfo n
nodeInfo (CSizeofType _ n) = nodeInfo n
nodeInfo (CAlignofExpr _ n) = nodeInfo n
nodeInfo (CAlignofType _ n) = nodeInfo n
nodeInfo (CComplexReal _ n) = nodeInfo n
nodeInfo (CComplexImag _ n) = nodeInfo n
nodeInfo (CIndex _ _ n) = nodeInfo n
nodeInfo (CCall _ _ n) = nodeInfo n
nodeInfo (CMember _ _ _ n) = nodeInfo n
nodeInfo (CVar _ n) = nodeInfo n
nodeInfo (CConst d) = nodeInfo d
nodeInfo (CCompoundLit _ _ n) = nodeInfo n
nodeInfo (CStatExpr _ n) = nodeInfo n
nodeInfo (CLabAddrExpr _ n) = nodeInfo n
nodeInfo (CBuiltinExpr d) = nodeInfo d
instance (CNode t1) => Pos (CExpression t1) where
posOf x = posOf (nodeInfo x)
instance Annotated CExpression where
annotation (CComma _ n) = n
annotation (CAssign _ _ _ n) = n
annotation (CCond _ _ _ n) = n
annotation (CBinary _ _ _ n) = n
annotation (CCast _ _ n) = n
annotation (CUnary _ _ n) = n
annotation (CSizeofExpr _ n) = n
annotation (CSizeofType _ n) = n
annotation (CAlignofExpr _ n) = n
annotation (CAlignofType _ n) = n
annotation (CComplexReal _ n) = n
annotation (CComplexImag _ n) = n
annotation (CIndex _ _ n) = n
annotation (CCall _ _ n) = n
annotation (CMember _ _ _ n) = n
annotation (CVar _ n) = n
annotation (CConst n) = annotation n
annotation (CCompoundLit _ _ n) = n
annotation (CStatExpr _ n) = n
annotation (CLabAddrExpr _ n) = n
annotation (CBuiltinExpr n) = annotation n
amap f (CComma a_1 a_2) = CComma a_1 (f a_2)
amap f (CAssign a_1 a_2 a_3 a_4) = CAssign a_1 a_2 a_3 (f a_4)
amap f (CCond a_1 a_2 a_3 a_4) = CCond a_1 a_2 a_3 (f a_4)
amap f (CBinary a_1 a_2 a_3 a_4) = CBinary a_1 a_2 a_3 (f a_4)
amap f (CCast a_1 a_2 a_3) = CCast a_1 a_2 (f a_3)
amap f (CUnary a_1 a_2 a_3) = CUnary a_1 a_2 (f a_3)
amap f (CSizeofExpr a_1 a_2) = CSizeofExpr a_1 (f a_2)
amap f (CSizeofType a_1 a_2) = CSizeofType a_1 (f a_2)
amap f (CAlignofExpr a_1 a_2) = CAlignofExpr a_1 (f a_2)
amap f (CAlignofType a_1 a_2) = CAlignofType a_1 (f a_2)
amap f (CComplexReal a_1 a_2) = CComplexReal a_1 (f a_2)
amap f (CComplexImag a_1 a_2) = CComplexImag a_1 (f a_2)
amap f (CIndex a_1 a_2 a_3) = CIndex a_1 a_2 (f a_3)
amap f (CCall a_1 a_2 a_3) = CCall a_1 a_2 (f a_3)
amap f (CMember a_1 a_2 a_3 a_4) = CMember a_1 a_2 a_3 (f a_4)
amap f (CVar a_1 a_2) = CVar a_1 (f a_2)
amap f (CConst n) = CConst (amap f n)
amap f (CCompoundLit a_1 a_2 a_3) = CCompoundLit a_1 a_2 (f a_3)
amap f (CStatExpr a_1 a_2) = CStatExpr a_1 (f a_2)
amap f (CLabAddrExpr a_1 a_2) = CLabAddrExpr a_1 (f a_2)
amap f (CBuiltinExpr n) = CBuiltinExpr (amap f n)
instance (CNode t1) => CNode (CBuiltinThing t1) where
nodeInfo (CBuiltinVaArg _ _ n) = nodeInfo n
nodeInfo (CBuiltinOffsetOf _ _ n) = nodeInfo n
nodeInfo (CBuiltinTypesCompatible _ _ n) = nodeInfo n
instance (CNode t1) => Pos (CBuiltinThing t1) where
posOf x = posOf (nodeInfo x)
instance Functor CBuiltinThing where
fmap _f (CBuiltinVaArg a1 a2 a3)
= CBuiltinVaArg (fmap _f a1) (fmap _f a2) (_f a3)
fmap _f (CBuiltinOffsetOf a1 a2 a3)
= CBuiltinOffsetOf (fmap _f a1) (fmap (fmap _f) a2) (_f a3)
fmap _f (CBuiltinTypesCompatible a1 a2 a3)
= CBuiltinTypesCompatible (fmap _f a1) (fmap _f a2) (_f a3)
instance Annotated CBuiltinThing where
annotation (CBuiltinVaArg _ _ n) = n
annotation (CBuiltinOffsetOf _ _ n) = n
annotation (CBuiltinTypesCompatible _ _ n) = n
amap f (CBuiltinVaArg a_1 a_2 a_3) = CBuiltinVaArg a_1 a_2 (f a_3)
amap f (CBuiltinOffsetOf a_1 a_2 a_3)
= CBuiltinOffsetOf a_1 a_2 (f a_3)
amap f (CBuiltinTypesCompatible a_1 a_2 a_3)
= CBuiltinTypesCompatible a_1 a_2 (f a_3)
instance (CNode t1) => CNode (CConstant t1) where
nodeInfo (CIntConst _ n) = nodeInfo n
nodeInfo (CCharConst _ n) = nodeInfo n
nodeInfo (CFloatConst _ n) = nodeInfo n
nodeInfo (CStrConst _ n) = nodeInfo n
instance (CNode t1) => Pos (CConstant t1) where
posOf x = posOf (nodeInfo x)
instance Functor CConstant where
fmap _f (CIntConst a1 a2) = CIntConst a1 (_f a2)
fmap _f (CCharConst a1 a2) = CCharConst a1 (_f a2)
fmap _f (CFloatConst a1 a2) = CFloatConst a1 (_f a2)
fmap _f (CStrConst a1 a2) = CStrConst a1 (_f a2)
instance Annotated CConstant where
annotation (CIntConst _ n) = n
annotation (CCharConst _ n) = n
annotation (CFloatConst _ n) = n
annotation (CStrConst _ n) = n
amap f (CIntConst a_1 a_2) = CIntConst a_1 (f a_2)
amap f (CCharConst a_1 a_2) = CCharConst a_1 (f a_2)
amap f (CFloatConst a_1 a_2) = CFloatConst a_1 (f a_2)
amap f (CStrConst a_1 a_2) = CStrConst a_1 (f a_2)
instance (CNode t1) => CNode (CStringLiteral t1) where
nodeInfo (CStrLit _ n) = nodeInfo n
instance (CNode t1) => Pos (CStringLiteral t1) where
posOf x = posOf (nodeInfo x)
instance Functor CStringLiteral where
fmap _f (CStrLit a1 a2) = CStrLit a1 (_f a2)
instance Annotated CStringLiteral where
annotation (CStrLit _ n) = n
amap f (CStrLit a_1 a_2) = CStrLit a_1 (f a_2)