module CAST (CHeader(..), CExtDecl(..), CFunDef(..), CStat(..), CBlockItem(..),
CDecl(..), CDeclSpec(..), CStorageSpec(..), CTypeSpec(..),
CTypeQual(..), CStructUnion(..), CStructTag(..), CEnum(..),
CDeclr(..), CInit(..), CInitList, CDesignator(..), CExpr(..),
CAssignOp(..), CBinaryOp(..), CUnaryOp(..), CConst (..))
where
import Position (Position, Pos(posOf), nopos)
import Idents (Ident)
import Attributes (Attrs)
import Binary (Binary(..), putByte, getByte)
data CHeader = CHeader [CExtDecl]
Attrs
instance Pos CHeader where
posOf (CHeader _ at) = posOf at
instance Eq CHeader where
(CHeader _ at1) == (CHeader _ at2) = at1 == at2
data CExtDecl = CDeclExt CDecl
| CFDefExt CFunDef
| CAsmExt Attrs
instance Pos CExtDecl where
posOf (CDeclExt decl) = posOf decl
posOf (CFDefExt fdef) = posOf fdef
posOf (CAsmExt at) = posOf at
instance Eq CExtDecl where
CDeclExt decl1 == CDeclExt decl2 = decl1 == decl2
CFDefExt fdef1 == CFDefExt fdef2 = fdef1 == fdef2
CAsmExt at1 == CAsmExt at2 = at1 == at2
data CFunDef = CFunDef [CDeclSpec]
CDeclr
[CDecl]
CStat
Attrs
instance Pos CFunDef where
posOf (CFunDef _ _ _ _ at) = posOf at
instance Eq CFunDef where
CFunDef _ _ _ _ at1 == CFunDef _ _ _ _ at2 = at1 == at2
data CStat = CLabel Ident
CStat
Attrs
| CCase CExpr
CStat
Attrs
| CCases CExpr
CExpr
CStat
Attrs
| CDefault CStat
Attrs
| CExpr (Maybe CExpr)
Attrs
| CCompound [CBlockItem]
Attrs
| CIf CExpr
CStat
(Maybe CStat)
Attrs
| CSwitch CExpr
CStat
Attrs
| CWhile CExpr
CStat
Bool
Attrs
| CFor (Either (Maybe CExpr)
CDecl)
(Maybe CExpr)
(Maybe CExpr)
CStat
Attrs
| CGoto Ident
Attrs
| CGotoPtr CExpr
Attrs
| CCont Attrs
| CBreak Attrs
| CReturn (Maybe CExpr)
Attrs
| CAsm Attrs
instance Pos CStat where
posOf (CLabel _ _ at) = posOf at
posOf (CCase _ _ at) = posOf at
posOf (CCases _ _ _ at) = posOf at
posOf (CDefault _ at) = posOf at
posOf (CExpr _ at) = posOf at
posOf (CCompound _ at) = posOf at
posOf (CIf _ _ _ at) = posOf at
posOf (CSwitch _ _ at) = posOf at
posOf (CWhile _ _ _ at) = posOf at
posOf (CFor _ _ _ _ at) = posOf at
posOf (CGoto _ at) = posOf at
posOf (CGotoPtr _ at) = posOf at
posOf (CCont at) = posOf at
posOf (CBreak at) = posOf at
posOf (CReturn _ at) = posOf at
posOf (CAsm at) = posOf at
instance Eq CStat where
(CLabel _ _ at1) == (CLabel _ _ at2) = at1 == at2
(CCase _ _ at1) == (CCase _ _ at2) = at1 == at2
(CCases _ _ _ at1) == (CCases _ _ _ at2) = at1 == at2
(CDefault _ at1) == (CDefault _ at2) = at1 == at2
(CExpr _ at1) == (CExpr _ at2) = at1 == at2
(CCompound _ at1) == (CCompound _ at2) = at1 == at2
(CIf _ _ _ at1) == (CIf _ _ _ at2) = at1 == at2
(CSwitch _ _ at1) == (CSwitch _ _ at2) = at1 == at2
(CWhile _ _ _ at1) == (CWhile _ _ _ at2) = at1 == at2
(CFor _ _ _ _ at1) == (CFor _ _ _ _ at2) = at1 == at2
(CGoto _ at1) == (CGoto _ at2) = at1 == at2
(CGotoPtr _ at1) == (CGotoPtr _ at2) = at1 == at2
(CCont at1) == (CCont at2) = at1 == at2
(CBreak at1) == (CBreak at2) = at1 == at2
(CReturn _ at1) == (CReturn _ at2) = at1 == at2
(CAsm at1) == (CAsm at2) = at1 == at2
data CBlockItem = CBlockStmt CStat
| CBlockDecl CDecl
| CNestedFunDef CFunDef
instance Pos CBlockItem where
posOf (CBlockStmt stmt) = posOf stmt
posOf (CBlockDecl decl) = posOf decl
posOf (CNestedFunDef fdef) = posOf fdef
instance Eq CBlockItem where
CBlockStmt stmt1 == CBlockStmt stmt2 = stmt1 == stmt2
CBlockDecl decl1 == CBlockDecl decl2 = decl1 == decl2
CNestedFunDef fdef1 == CNestedFunDef fdef2 = fdef1 == fdef2
data CDecl = CDecl [CDeclSpec]
[(Maybe CDeclr,
Maybe CInit,
Maybe CExpr)]
Attrs
instance Pos CDecl where
posOf (CDecl _ _ at) = posOf at
instance Eq CDecl where
(CDecl _ _ at1) == (CDecl _ _ at2) = at1 == at2
data CDeclSpec = CStorageSpec CStorageSpec
| CTypeSpec CTypeSpec
| CTypeQual CTypeQual
deriving (Eq)
instance Pos CDeclSpec where
posOf (CStorageSpec sspec) = posOf sspec
posOf (CTypeSpec tspec) = posOf tspec
posOf (CTypeQual tqual) = posOf tqual
data CStorageSpec = CAuto Attrs
| CRegister Attrs
| CStatic Attrs
| CExtern Attrs
| CTypedef Attrs
| CThread Attrs
instance Pos CStorageSpec where
posOf (CAuto at) = posOf at
posOf (CRegister at) = posOf at
posOf (CStatic at) = posOf at
posOf (CExtern at) = posOf at
posOf (CTypedef at) = posOf at
posOf (CThread at) = posOf at
instance Eq CStorageSpec where
(CAuto at1) == (CAuto at2) = at1 == at2
(CRegister at1) == (CRegister at2) = at1 == at2
(CStatic at1) == (CStatic at2) = at1 == at2
(CExtern at1) == (CExtern at2) = at1 == at2
(CTypedef at1) == (CTypedef at2) = at1 == at2
(CThread at1) == (CThread at2) = at1 == at2
data CTypeSpec = CVoidType Attrs
| CCharType Attrs
| CShortType Attrs
| CIntType Attrs
| CLongType Attrs
| CFloatType Attrs
| CFloat128Type Attrs
| CDoubleType Attrs
| CSignedType Attrs
| CUnsigType Attrs
| CBoolType Attrs
| CComplexType Attrs
| CSUType CStructUnion
Attrs
| CEnumType CEnum
Attrs
| CTypeDef Ident
Attrs
| CTypeOfExpr CExpr
Attrs
| CTypeOfType CDecl
Attrs
instance Pos CTypeSpec where
posOf (CVoidType at) = posOf at
posOf (CCharType at) = posOf at
posOf (CShortType at) = posOf at
posOf (CIntType at) = posOf at
posOf (CLongType at) = posOf at
posOf (CFloatType at) = posOf at
posOf (CFloat128Type at) = posOf at
posOf (CDoubleType at) = posOf at
posOf (CSignedType at) = posOf at
posOf (CUnsigType at) = posOf at
posOf (CBoolType at) = posOf at
posOf (CComplexType at) = posOf at
posOf (CSUType _ at) = posOf at
posOf (CEnumType _ at) = posOf at
posOf (CTypeDef _ at) = posOf at
posOf (CTypeOfExpr _ at) = posOf at
posOf (CTypeOfType _ at) = posOf at
instance Eq CTypeSpec where
(CVoidType at1) == (CVoidType at2) = at1 == at2
(CCharType at1) == (CCharType at2) = at1 == at2
(CShortType at1) == (CShortType at2) = at1 == at2
(CIntType at1) == (CIntType at2) = at1 == at2
(CLongType at1) == (CLongType at2) = at1 == at2
(CFloatType at1) == (CFloatType at2) = at1 == at2
(CFloat128Type at1) == (CFloat128Type at2) = at1 == at2
(CDoubleType at1) == (CDoubleType at2) = at1 == at2
(CSignedType at1) == (CSignedType at2) = at1 == at2
(CUnsigType at1) == (CUnsigType at2) = at1 == at2
(CBoolType at1) == (CBoolType at2) = at1 == at2
(CComplexType at1) == (CComplexType at2) = at1 == at2
(CSUType _ at1) == (CSUType _ at2) = at1 == at2
(CEnumType _ at1) == (CEnumType _ at2) = at1 == at2
(CTypeDef _ at1) == (CTypeDef _ at2) = at1 == at2
(CTypeOfExpr _ at1) == (CTypeOfExpr _ at2) = at1 == at2
(CTypeOfType _ at1) == (CTypeOfType _ at2) = at1 == at2
data CTypeQual = CConstQual Attrs
| CVolatQual Attrs
| CRestrQual Attrs
| CInlinQual Attrs
instance Pos CTypeQual where
posOf (CConstQual at) = posOf at
posOf (CVolatQual at) = posOf at
posOf (CRestrQual at) = posOf at
posOf (CInlinQual at) = posOf at
instance Eq CTypeQual where
(CConstQual at1) == (CConstQual at2) = at1 == at2
(CVolatQual at1) == (CVolatQual at2) = at1 == at2
(CRestrQual at1) == (CRestrQual at2) = at1 == at2
(CInlinQual at1) == (CInlinQual at2) = at1 == at2
data CStructUnion = CStruct CStructTag
(Maybe Ident)
[CDecl]
Attrs
instance Pos CStructUnion where
posOf (CStruct _ _ _ at) = posOf at
instance Eq CStructUnion where
(CStruct _ _ _ at1) == (CStruct _ _ _ at2) = at1 == at2
data CStructTag = CStructTag
| CUnionTag
deriving (Eq)
data CEnum = CEnum (Maybe Ident)
[(Ident,
Maybe CExpr)]
Attrs
instance Pos CEnum where
posOf (CEnum _ _ at) = posOf at
instance Eq CEnum where
(CEnum _ _ at1) == (CEnum _ _ at2) = at1 == at2
data CDeclr = CVarDeclr (Maybe Ident)
Attrs
| CPtrDeclr [CTypeQual]
CDeclr
Attrs
| CArrDeclr CDeclr
[CTypeQual]
(Maybe CExpr)
Attrs
| CFunDeclr CDeclr
[CDecl]
Bool
Attrs
instance Pos CDeclr where
posOf (CVarDeclr _ at) = posOf at
posOf (CPtrDeclr _ _ at) = posOf at
posOf (CArrDeclr _ _ _ at) = posOf at
posOf (CFunDeclr _ _ _ at) = posOf at
instance Eq CDeclr where
(CVarDeclr _ at1) == (CVarDeclr _ at2) = at1 == at2
(CPtrDeclr _ _ at1) == (CPtrDeclr _ _ at2) = at1 == at2
(CArrDeclr _ _ _ at1) == (CArrDeclr _ _ _ at2) = at1 == at2
(CFunDeclr _ _ _ at1) == (CFunDeclr _ _ _ at2) = at1 == at2
data CInit = CInitExpr CExpr
Attrs
| CInitList CInitList
Attrs
type CInitList = [([CDesignator], CInit)]
instance Pos CInit where
posOf (CInitExpr _ at) = posOf at
posOf (CInitList _ at) = posOf at
instance Eq CInit where
(CInitExpr _ at1) == (CInitExpr _ at2) = at1 == at2
(CInitList _ at1) == (CInitList _ at2) = at1 == at2
data CDesignator = CArrDesig CExpr
Attrs
| CMemberDesig Ident
Attrs
| CRangeDesig CExpr
CExpr
Attrs
instance Pos CDesignator where
posOf (CArrDesig _ at) = posOf at
posOf (CMemberDesig _ at) = posOf at
posOf (CRangeDesig _ _ at) = posOf at
instance Eq CDesignator where
(CArrDesig _ at1) == (CArrDesig _ at2) = at1 == at2
(CMemberDesig _ at1) == (CMemberDesig _ at2) = at1 == at2
(CRangeDesig _ _ at1) == (CRangeDesig _ _ at2) = at1 == at2
data CExpr = CComma [CExpr]
Attrs
| CAssign CAssignOp
CExpr
CExpr
Attrs
| CCond CExpr
(Maybe CExpr)
CExpr
Attrs
| CBinary CBinaryOp
CExpr
CExpr
Attrs
| CCast CDecl
CExpr
Attrs
| CUnary CUnaryOp
CExpr
Attrs
| CSizeofExpr CExpr
Attrs
| CSizeofType CDecl
Attrs
| CAlignofExpr CExpr
Attrs
| CAlignofType CDecl
Attrs
| CIndex CExpr
CExpr
Attrs
| CCall CExpr
[CExpr]
Attrs
| CMember CExpr
Ident
Bool
Attrs
| CVar Ident
Attrs
| CConst CConst
Attrs
| CCompoundLit CDecl
CInitList
Attrs
| CStatExpr CStat
Attrs
| CLabAddrExpr Ident
Attrs
| CBuiltinExpr Attrs
instance Pos CExpr where
posOf (CComma _ at) = posOf at
posOf (CAssign _ _ _ at) = posOf at
posOf (CCond _ _ _ at) = posOf at
posOf (CBinary _ _ _ at) = posOf at
posOf (CCast _ _ at) = posOf at
posOf (CUnary _ _ at) = posOf at
posOf (CSizeofExpr _ at) = posOf at
posOf (CSizeofType _ at) = posOf at
posOf (CAlignofExpr _ at) = posOf at
posOf (CAlignofType _ at) = posOf at
posOf (CIndex _ _ at) = posOf at
posOf (CCall _ _ at) = posOf at
posOf (CMember _ _ _ at) = posOf at
posOf (CVar _ at) = posOf at
posOf (CConst _ at) = posOf at
posOf (CCompoundLit _ _ at) = posOf at
posOf (CStatExpr _ at) = posOf at
posOf (CLabAddrExpr _ at) = posOf at
posOf (CBuiltinExpr at) = posOf at
instance Eq CExpr where
(CComma _ at1) == (CComma _ at2) = at1 == at2
(CAssign _ _ _ at1) == (CAssign _ _ _ at2) = at1 == at2
(CCond _ _ _ at1) == (CCond _ _ _ at2) = at1 == at2
(CBinary _ _ _ at1) == (CBinary _ _ _ at2) = at1 == at2
(CCast _ _ at1) == (CCast _ _ at2) = at1 == at2
(CUnary _ _ at1) == (CUnary _ _ at2) = at1 == at2
(CSizeofExpr _ at1) == (CSizeofExpr _ at2) = at1 == at2
(CSizeofType _ at1) == (CSizeofType _ at2) = at1 == at2
(CAlignofExpr _ at1) == (CAlignofExpr _ at2) = at1 == at2
(CAlignofType _ at1) == (CAlignofType _ at2) = at1 == at2
(CIndex _ _ at1) == (CIndex _ _ at2) = at1 == at2
(CCall _ _ at1) == (CCall _ _ at2) = at1 == at2
(CMember _ _ _ at1) == (CMember _ _ _ at2) = at1 == at2
(CVar _ at1) == (CVar _ at2) = at1 == at2
(CConst _ at1) == (CConst _ at2) = at1 == at2
(CCompoundLit _ _ at1) == (CCompoundLit _ _ at2) = at1 == at2
(CStatExpr _ at1) == (CStatExpr _ at2) = at1 == at2
(CLabAddrExpr _ at1) == (CLabAddrExpr _ at2) = at1 == at2
(CBuiltinExpr at1) == (CBuiltinExpr at2) = at1 == at2
data CAssignOp = CAssignOp
| CMulAssOp
| CDivAssOp
| CRmdAssOp
| CAddAssOp
| CSubAssOp
| CShlAssOp
| CShrAssOp
| CAndAssOp
| CXorAssOp
| COrAssOp
deriving (Eq)
data CBinaryOp = CMulOp
| CDivOp
| CRmdOp
| CAddOp
| CSubOp
| CShlOp
| CShrOp
| CLeOp
| CGrOp
| CLeqOp
| CGeqOp
| CEqOp
| CNeqOp
| CAndOp
| CXorOp
| COrOp
| CLndOp
| CLorOp
deriving (Eq)
data CUnaryOp = CPreIncOp
| CPreDecOp
| CPostIncOp
| CPostDecOp
| CAdrOp
| CIndOp
| CPlusOp
| CMinOp
| CCompOp
| CNegOp
deriving (Eq)
data CConst = CIntConst Integer
Attrs
| CCharConst Char
Attrs
| CFloatConst String
Attrs
| CStrConst String
Attrs
instance Pos CConst where
posOf (CIntConst _ at) = posOf at
posOf (CCharConst _ at) = posOf at
posOf (CFloatConst _ at) = posOf at
posOf (CStrConst _ at) = posOf at
instance Eq CConst where
(CIntConst _ at1) == (CIntConst _ at2) = at1 == at2
(CCharConst _ at1) == (CCharConst _ at2) = at1 == at2
(CFloatConst _ at1) == (CFloatConst _ at2) = at1 == at2
(CStrConst _ at1) == (CStrConst _ at2) = at1 == at2
instance Binary CDecl where
put_ bh (CDecl aa ab ac) = do
put_ bh aa
put_ bh ab
put_ bh ac
get bh = do
aa <- get bh
ab <- get bh
ac <- get bh
return (CDecl aa ab ac)
instance Binary CEnum where
put_ bh (CEnum aa ab ac) = do
put_ bh aa
put_ bh ab
put_ bh ac
get bh = do
aa <- get bh
ab <- get bh
ac <- get bh
return (CEnum aa ab ac)
instance Binary CStructUnion where
put_ bh (CStruct aa ab ac ad) = do
put_ bh aa
put_ bh ab
put_ bh ac
put_ bh ad
get bh = do
aa <- get bh
ab <- get bh
ac <- get bh
ad <- get bh
return (CStruct aa ab ac ad)
instance Binary CStructTag where
put_ bh CStructTag = do
putByte bh 0
put_ bh CUnionTag = do
putByte bh 1
get bh = do
h <- getByte bh
case h of
0 -> do
return CStructTag
1 -> do
return CUnionTag
instance Binary CExpr where
put_ bh (CComma aa ab) = do
putByte bh 0
put_ bh aa
put_ bh ab
put_ bh (CAssign ac ad ae af) = do
putByte bh 1
put_ bh ac
put_ bh ad
put_ bh ae
put_ bh af
put_ bh (CCond ag ah ai aj) = do
putByte bh 2
put_ bh ag
put_ bh ah
put_ bh ai
put_ bh aj
put_ bh (CBinary ak al am an) = do
putByte bh 3
put_ bh ak
put_ bh al
put_ bh am
put_ bh an
put_ bh (CCast ao ap aq) = do
putByte bh 4
put_ bh ao
put_ bh ap
put_ bh aq
put_ bh (CUnary ar as at) = do
putByte bh 5
put_ bh ar
put_ bh as
put_ bh at
put_ bh (CSizeofExpr au av) = do
putByte bh 6
put_ bh au
put_ bh av
put_ bh (CSizeofType aw ax) = do
putByte bh 7
put_ bh aw
put_ bh ax
put_ bh (CAlignofExpr ay az) = do
putByte bh 8
put_ bh ay
put_ bh az
put_ bh (CAlignofType aA aB) = do
putByte bh 9
put_ bh aA
put_ bh aB
put_ bh (CIndex aC aD aE) = do
putByte bh 10
put_ bh aC
put_ bh aD
put_ bh aE
put_ bh (CCall aF aG aH) = do
putByte bh 11
put_ bh aF
put_ bh aG
put_ bh aH
put_ bh (CMember aI aJ aK aL) = do
putByte bh 12
put_ bh aI
put_ bh aJ
put_ bh aK
put_ bh aL
put_ bh (CVar aM aN) = do
putByte bh 13
put_ bh aM
put_ bh aN
put_ bh (CConst aO aP) = do
putByte bh 14
put_ bh aO
put_ bh aP
get bh = do
h <- getByte bh
case h of
0 -> do
aa <- get bh
ab <- get bh
return (CComma aa ab)
1 -> do
ac <- get bh
ad <- get bh
ae <- get bh
af <- get bh
return (CAssign ac ad ae af)
2 -> do
ag <- get bh
ah <- get bh
ai <- get bh
aj <- get bh
return (CCond ag ah ai aj)
3 -> do
ak <- get bh
al <- get bh
am <- get bh
an <- get bh
return (CBinary ak al am an)
4 -> do
ao <- get bh
ap <- get bh
aq <- get bh
return (CCast ao ap aq)
5 -> do
ar <- get bh
as <- get bh
at <- get bh
return (CUnary ar as at)
6 -> do
au <- get bh
av <- get bh
return (CSizeofExpr au av)
7 -> do
aw <- get bh
ax <- get bh
return (CSizeofType aw ax)
8 -> do
ay <- get bh
az <- get bh
return (CAlignofExpr ay az)
9 -> do
aA <- get bh
aB <- get bh
return (CAlignofType aA aB)
10 -> do
aC <- get bh
aD <- get bh
aE <- get bh
return (CIndex aC aD aE)
11 -> do
aF <- get bh
aG <- get bh
aH <- get bh
return (CCall aF aG aH)
12 -> do
aI <- get bh
aJ <- get bh
aK <- get bh
aL <- get bh
return (CMember aI aJ aK aL)
13 -> do
aM <- get bh
aN <- get bh
return (CVar aM aN)
14 -> do
aO <- get bh
aP <- get bh
return (CConst aO aP)
instance Binary CInit where
put_ bh (CInitExpr aa ab) = do
putByte bh 0
put_ bh aa
put_ bh ab
put_ bh (CInitList ac ad) = do
putByte bh 1
put_ bh ac
put_ bh ad
get bh = do
h <- getByte bh
case h of
0 -> do
aa <- get bh
ab <- get bh
return (CInitExpr aa ab)
1 -> do
ac <- get bh
ad <- get bh
return (CInitList ac ad)
instance Binary CDesignator where
put_ bh (CArrDesig aa ab) = do
putByte bh 0
put_ bh aa
put_ bh ab
put_ bh (CMemberDesig ac ad) = do
putByte bh 1
put_ bh ac
put_ bh ad
put_ bh (CRangeDesig ae af ag) = do
putByte bh 2
put_ bh ae
put_ bh af
put_ bh ag
get bh = do
h <- getByte bh
case h of
0 -> do
aa <- get bh
ab <- get bh
return (CArrDesig aa ab)
1 -> do
ac <- get bh
ad <- get bh
return (CMemberDesig ac ad)
2 -> do
ae <- get bh
af <- get bh
ag <- get bh
return (CRangeDesig ae af ag)
instance Binary CDeclr where
put_ bh (CVarDeclr aa ab) = do
putByte bh 0
put_ bh aa
put_ bh ab
put_ bh (CPtrDeclr ac ad ae) = do
putByte bh 1
put_ bh ac
put_ bh ad
put_ bh ae
put_ bh (CArrDeclr af ag ah ai) = do
putByte bh 2
put_ bh af
put_ bh ag
put_ bh ah
put_ bh ai
put_ bh (CFunDeclr ai aj ak al) = do
putByte bh 3
put_ bh ai
put_ bh aj
put_ bh ak
put_ bh al
get bh = do
h <- getByte bh
case h of
0 -> do
aa <- get bh
ab <- get bh
return (CVarDeclr aa ab)
1 -> do
ac <- get bh
ad <- get bh
ae <- get bh
return (CPtrDeclr ac ad ae)
2 -> do
af <- get bh
ag <- get bh
ah <- get bh
ai <- get bh
return (CArrDeclr af ag ah ai)
3 -> do
ai <- get bh
aj <- get bh
ak <- get bh
al <- get bh
return (CFunDeclr ai aj ak al)
instance Binary CDeclSpec where
put_ bh (CStorageSpec aa) = do
putByte bh 0
put_ bh aa
put_ bh (CTypeSpec ab) = do
putByte bh 1
put_ bh ab
put_ bh (CTypeQual ac) = do
putByte bh 2
put_ bh ac
get bh = do
h <- getByte bh
case h of
0 -> do
aa <- get bh
return (CStorageSpec aa)
1 -> do
ab <- get bh
return (CTypeSpec ab)
2 -> do
ac <- get bh
return (CTypeQual ac)
instance Binary CTypeSpec where
put_ bh (CVoidType aa) = do
putByte bh 0
put_ bh aa
put_ bh (CCharType ab) = do
putByte bh 1
put_ bh ab
put_ bh (CShortType ac) = do
putByte bh 2
put_ bh ac
put_ bh (CIntType ad) = do
putByte bh 3
put_ bh ad
put_ bh (CLongType ae) = do
putByte bh 4
put_ bh ae
put_ bh (CFloatType af) = do
putByte bh 5
put_ bh af
put_ bh (CDoubleType ag) = do
putByte bh 6
put_ bh ag
put_ bh (CSignedType ah) = do
putByte bh 7
put_ bh ah
put_ bh (CUnsigType ai) = do
putByte bh 8
put_ bh ai
put_ bh (CSUType aj ak) = do
putByte bh 9
put_ bh aj
put_ bh ak
put_ bh (CEnumType al am) = do
putByte bh 10
put_ bh al
put_ bh am
put_ bh (CTypeDef an ao) = do
putByte bh 11
put_ bh an
put_ bh ao
put_ bh (CTypeOfExpr ap aq) = do
putByte bh 12
put_ bh ap
put_ bh aq
put_ bh (CTypeOfType ar as) = do
putByte bh 13
put_ bh ar
put_ bh as
put_ bh (CFloat128Type at) = do
putByte bh 14
put_ bh at
get bh = do
h <- getByte bh
case h of
0 -> do
aa <- get bh
return (CVoidType aa)
1 -> do
ab <- get bh
return (CCharType ab)
2 -> do
ac <- get bh
return (CShortType ac)
3 -> do
ad <- get bh
return (CIntType ad)
4 -> do
ae <- get bh
return (CLongType ae)
5 -> do
af <- get bh
return (CFloatType af)
6 -> do
ag <- get bh
return (CDoubleType ag)
7 -> do
ah <- get bh
return (CSignedType ah)
8 -> do
ai <- get bh
return (CUnsigType ai)
9 -> do
aj <- get bh
ak <- get bh
return (CSUType aj ak)
10 -> do
al <- get bh
am <- get bh
return (CEnumType al am)
11 -> do
an <- get bh
ao <- get bh
return (CTypeDef an ao)
12 -> do
ap <- get bh
aq <- get bh
return (CTypeOfExpr ap aq)
13 -> do
ar <- get bh
as <- get bh
return (CTypeOfType ar as)
14 -> do
at <- get bh
return (CFloat128Type at)
instance Binary CStorageSpec where
put_ bh (CAuto aa) = do
putByte bh 0
put_ bh aa
put_ bh (CRegister ab) = do
putByte bh 1
put_ bh ab
put_ bh (CStatic ac) = do
putByte bh 2
put_ bh ac
put_ bh (CExtern ad) = do
putByte bh 3
put_ bh ad
put_ bh (CTypedef ae) = do
putByte bh 4
put_ bh ae
get bh = do
h <- getByte bh
case h of
0 -> do
aa <- get bh
return (CAuto aa)
1 -> do
ab <- get bh
return (CRegister ab)
2 -> do
ac <- get bh
return (CStatic ac)
3 -> do
ad <- get bh
return (CExtern ad)
4 -> do
ae <- get bh
return (CTypedef ae)
instance Binary CTypeQual where
put_ bh (CConstQual aa) = do
putByte bh 0
put_ bh aa
put_ bh (CVolatQual ab) = do
putByte bh 1
put_ bh ab
put_ bh (CRestrQual ac) = do
putByte bh 2
put_ bh ac
put_ bh (CInlinQual ad) = do
putByte bh 3
put_ bh ad
get bh = do
h <- getByte bh
case h of
0 -> do
aa <- get bh
return (CConstQual aa)
1 -> do
ab <- get bh
return (CVolatQual ab)
2 -> do
ac <- get bh
return (CRestrQual ac)
3 -> do
ad <- get bh
return (CInlinQual ad)
instance Binary CConst where
put_ bh (CIntConst aa ab) = do
putByte bh 0
put_ bh aa
put_ bh ab
put_ bh (CCharConst ac ad) = do
putByte bh 1
put_ bh ac
put_ bh ad
put_ bh (CFloatConst ae af) = do
putByte bh 2
put_ bh ae
put_ bh af
put_ bh (CStrConst ag ah) = do
putByte bh 3
put_ bh ag
put_ bh ah
get bh = do
h <- getByte bh
case h of
0 -> do
aa <- get bh
ab <- get bh
return (CIntConst aa ab)
1 -> do
ac <- get bh
ad <- get bh
return (CCharConst ac ad)
2 -> do
ae <- get bh
af <- get bh
return (CFloatConst ae af)
3 -> do
ag <- get bh
ah <- get bh
return (CStrConst ag ah)
instance Binary CUnaryOp where
put_ bh CPreIncOp = putByte bh 0
put_ bh CPreDecOp = putByte bh 1
put_ bh CPostIncOp = putByte bh 2
put_ bh CPostDecOp = putByte bh 3
put_ bh CAdrOp = putByte bh 4
put_ bh CIndOp = putByte bh 5
put_ bh CPlusOp = putByte bh 6
put_ bh CMinOp = putByte bh 7
put_ bh CCompOp = putByte bh 8
put_ bh CNegOp = putByte bh 9
get bh = do
h <- getByte bh
case h of
0 -> return CPreIncOp
1 -> return CPreDecOp
2 -> return CPostIncOp
3 -> return CPostDecOp
4 -> return CAdrOp
5 -> return CIndOp
6 -> return CPlusOp
7 -> return CMinOp
8 -> return CCompOp
9 -> return CNegOp
instance Binary CBinaryOp where
put_ bh CMulOp = putByte bh 0
put_ bh CDivOp = putByte bh 1
put_ bh CRmdOp = putByte bh 2
put_ bh CAddOp = putByte bh 3
put_ bh CSubOp = putByte bh 4
put_ bh CShlOp = putByte bh 5
put_ bh CShrOp = putByte bh 6
put_ bh CLeOp = putByte bh 7
put_ bh CGrOp = putByte bh 8
put_ bh CLeqOp = putByte bh 9
put_ bh CGeqOp = putByte bh 10
put_ bh CEqOp = putByte bh 11
put_ bh CNeqOp = putByte bh 12
put_ bh CAndOp = putByte bh 13
put_ bh CXorOp = putByte bh 14
put_ bh COrOp = putByte bh 15
put_ bh CLndOp = putByte bh 16
put_ bh CLorOp = putByte bh 17
get bh = do
h <- getByte bh
case h of
0 -> return CMulOp
1 -> return CDivOp
2 -> return CRmdOp
3 -> return CAddOp
4 -> return CSubOp
5 -> return CShlOp
6 -> return CShrOp
7 -> return CLeOp
8 -> return CGrOp
9 -> return CLeqOp
10 -> return CGeqOp
11 -> return CEqOp
12 -> return CNeqOp
13 -> return CAndOp
14 -> return CXorOp
15 -> return COrOp
16 -> return CLndOp
17 -> return CLorOp
instance Binary CAssignOp where
put_ bh CAssignOp = putByte bh 0
put_ bh CMulAssOp = putByte bh 1
put_ bh CDivAssOp = putByte bh 2
put_ bh CRmdAssOp = putByte bh 3
put_ bh CAddAssOp = putByte bh 4
put_ bh CSubAssOp = putByte bh 5
put_ bh CShlAssOp = putByte bh 6
put_ bh CShrAssOp = putByte bh 7
put_ bh CAndAssOp = putByte bh 8
put_ bh CXorAssOp = putByte bh 9
put_ bh COrAssOp = putByte bh 10
get bh = do
h <- getByte bh
case h of
0 -> return CAssignOp
1 -> return CMulAssOp
2 -> return CDivAssOp
3 -> return CRmdAssOp
4 -> return CAddAssOp
5 -> return CSubAssOp
6 -> return CShlAssOp
7 -> return CShrAssOp
8 -> return CAndAssOp
9 -> return CXorAssOp
10 -> return COrAssOp