-- | Types representing JVM types, such as field types and class info types.
module H2JVM.Type (
    ClassInfoType (..),
    PrimitiveType (..),
    FieldType (..),
    fieldTypeToClassInfoType,
    classInfoTypeToFieldType,
)
where

import Data.Data

import H2JVM.Internal.Pretty (Pretty (pretty))
import H2JVM.Name (QualifiedClassName)

{- | JVM primitive types.
Corresponds to the @BaseType@ production in the JVM specification.
-}
data PrimitiveType
    = JByte
    | JChar
    | JDouble
    | JFloat
    | JInt
    | JLong
    | JShort
    | JBoolean
    deriving (PrimitiveType
PrimitiveType -> PrimitiveType -> Bounded PrimitiveType
forall a. a -> a -> Bounded a
$cminBound :: PrimitiveType
minBound :: PrimitiveType
$cmaxBound :: PrimitiveType
maxBound :: PrimitiveType
Bounded, Typeable PrimitiveType
Typeable PrimitiveType =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> PrimitiveType -> c PrimitiveType)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c PrimitiveType)
-> (PrimitiveType -> Constr)
-> (PrimitiveType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c PrimitiveType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c PrimitiveType))
-> ((forall b. Data b => b -> b) -> PrimitiveType -> PrimitiveType)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PrimitiveType -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PrimitiveType -> r)
-> (forall u. (forall d. Data d => d -> u) -> PrimitiveType -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> PrimitiveType -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PrimitiveType -> m PrimitiveType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PrimitiveType -> m PrimitiveType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PrimitiveType -> m PrimitiveType)
-> Data PrimitiveType
PrimitiveType -> Constr
PrimitiveType -> DataType
(forall b. Data b => b -> b) -> PrimitiveType -> PrimitiveType
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> PrimitiveType -> u
forall u. (forall d. Data d => d -> u) -> PrimitiveType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PrimitiveType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PrimitiveType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PrimitiveType -> m PrimitiveType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PrimitiveType -> m PrimitiveType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PrimitiveType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PrimitiveType -> c PrimitiveType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PrimitiveType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PrimitiveType)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PrimitiveType -> c PrimitiveType
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PrimitiveType -> c PrimitiveType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PrimitiveType
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PrimitiveType
$ctoConstr :: PrimitiveType -> Constr
toConstr :: PrimitiveType -> Constr
$cdataTypeOf :: PrimitiveType -> DataType
dataTypeOf :: PrimitiveType -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PrimitiveType)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PrimitiveType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PrimitiveType)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PrimitiveType)
$cgmapT :: (forall b. Data b => b -> b) -> PrimitiveType -> PrimitiveType
gmapT :: (forall b. Data b => b -> b) -> PrimitiveType -> PrimitiveType
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PrimitiveType -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PrimitiveType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PrimitiveType -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PrimitiveType -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> PrimitiveType -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> PrimitiveType -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PrimitiveType -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PrimitiveType -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PrimitiveType -> m PrimitiveType
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PrimitiveType -> m PrimitiveType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PrimitiveType -> m PrimitiveType
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PrimitiveType -> m PrimitiveType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PrimitiveType -> m PrimitiveType
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PrimitiveType -> m PrimitiveType
Data, Int -> PrimitiveType
PrimitiveType -> Int
PrimitiveType -> [PrimitiveType]
PrimitiveType -> PrimitiveType
PrimitiveType -> PrimitiveType -> [PrimitiveType]
PrimitiveType -> PrimitiveType -> PrimitiveType -> [PrimitiveType]
(PrimitiveType -> PrimitiveType)
-> (PrimitiveType -> PrimitiveType)
-> (Int -> PrimitiveType)
-> (PrimitiveType -> Int)
-> (PrimitiveType -> [PrimitiveType])
-> (PrimitiveType -> PrimitiveType -> [PrimitiveType])
-> (PrimitiveType -> PrimitiveType -> [PrimitiveType])
-> (PrimitiveType
    -> PrimitiveType -> PrimitiveType -> [PrimitiveType])
-> Enum PrimitiveType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: PrimitiveType -> PrimitiveType
succ :: PrimitiveType -> PrimitiveType
$cpred :: PrimitiveType -> PrimitiveType
pred :: PrimitiveType -> PrimitiveType
$ctoEnum :: Int -> PrimitiveType
toEnum :: Int -> PrimitiveType
$cfromEnum :: PrimitiveType -> Int
fromEnum :: PrimitiveType -> Int
$cenumFrom :: PrimitiveType -> [PrimitiveType]
enumFrom :: PrimitiveType -> [PrimitiveType]
$cenumFromThen :: PrimitiveType -> PrimitiveType -> [PrimitiveType]
enumFromThen :: PrimitiveType -> PrimitiveType -> [PrimitiveType]
$cenumFromTo :: PrimitiveType -> PrimitiveType -> [PrimitiveType]
enumFromTo :: PrimitiveType -> PrimitiveType -> [PrimitiveType]
$cenumFromThenTo :: PrimitiveType -> PrimitiveType -> PrimitiveType -> [PrimitiveType]
enumFromThenTo :: PrimitiveType -> PrimitiveType -> PrimitiveType -> [PrimitiveType]
Enum, PrimitiveType -> PrimitiveType -> Bool
(PrimitiveType -> PrimitiveType -> Bool)
-> (PrimitiveType -> PrimitiveType -> Bool) -> Eq PrimitiveType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PrimitiveType -> PrimitiveType -> Bool
== :: PrimitiveType -> PrimitiveType -> Bool
$c/= :: PrimitiveType -> PrimitiveType -> Bool
/= :: PrimitiveType -> PrimitiveType -> Bool
Eq, Eq PrimitiveType
Eq PrimitiveType =>
(PrimitiveType -> PrimitiveType -> Ordering)
-> (PrimitiveType -> PrimitiveType -> Bool)
-> (PrimitiveType -> PrimitiveType -> Bool)
-> (PrimitiveType -> PrimitiveType -> Bool)
-> (PrimitiveType -> PrimitiveType -> Bool)
-> (PrimitiveType -> PrimitiveType -> PrimitiveType)
-> (PrimitiveType -> PrimitiveType -> PrimitiveType)
-> Ord PrimitiveType
PrimitiveType -> PrimitiveType -> Bool
PrimitiveType -> PrimitiveType -> Ordering
PrimitiveType -> PrimitiveType -> PrimitiveType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PrimitiveType -> PrimitiveType -> Ordering
compare :: PrimitiveType -> PrimitiveType -> Ordering
$c< :: PrimitiveType -> PrimitiveType -> Bool
< :: PrimitiveType -> PrimitiveType -> Bool
$c<= :: PrimitiveType -> PrimitiveType -> Bool
<= :: PrimitiveType -> PrimitiveType -> Bool
$c> :: PrimitiveType -> PrimitiveType -> Bool
> :: PrimitiveType -> PrimitiveType -> Bool
$c>= :: PrimitiveType -> PrimitiveType -> Bool
>= :: PrimitiveType -> PrimitiveType -> Bool
$cmax :: PrimitiveType -> PrimitiveType -> PrimitiveType
max :: PrimitiveType -> PrimitiveType -> PrimitiveType
$cmin :: PrimitiveType -> PrimitiveType -> PrimitiveType
min :: PrimitiveType -> PrimitiveType -> PrimitiveType
Ord, Int -> PrimitiveType -> ShowS
[PrimitiveType] -> ShowS
PrimitiveType -> String
(Int -> PrimitiveType -> ShowS)
-> (PrimitiveType -> String)
-> ([PrimitiveType] -> ShowS)
-> Show PrimitiveType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PrimitiveType -> ShowS
showsPrec :: Int -> PrimitiveType -> ShowS
$cshow :: PrimitiveType -> String
show :: PrimitiveType -> String
$cshowList :: [PrimitiveType] -> ShowS
showList :: [PrimitiveType] -> ShowS
Show)

instance Pretty PrimitiveType where
    pretty :: forall ann. PrimitiveType -> Doc ann
pretty PrimitiveType
JByte = Doc ann
"byte"
    pretty PrimitiveType
JChar = Doc ann
"char"
    pretty PrimitiveType
JDouble = Doc ann
"double"
    pretty PrimitiveType
JFloat = Doc ann
"float"
    pretty PrimitiveType
JInt = Doc ann
"int"
    pretty PrimitiveType
JLong = Doc ann
"long"
    pretty PrimitiveType
JShort = Doc ann
"short"
    pretty PrimitiveType
JBoolean = Doc ann
"boolean"

{- | JVM field type, corresponding to the @FieldType@ production in the JVM specification.
Used in places such as method descriptors and field descriptors.
-}
data FieldType
    = PrimitiveFieldType PrimitiveType
    | ObjectFieldType QualifiedClassName
    | ArrayFieldType FieldType
    deriving (Typeable FieldType
Typeable FieldType =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> FieldType -> c FieldType)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c FieldType)
-> (FieldType -> Constr)
-> (FieldType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c FieldType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FieldType))
-> ((forall b. Data b => b -> b) -> FieldType -> FieldType)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> FieldType -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> FieldType -> r)
-> (forall u. (forall d. Data d => d -> u) -> FieldType -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> FieldType -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> FieldType -> m FieldType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FieldType -> m FieldType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FieldType -> m FieldType)
-> Data FieldType
FieldType -> Constr
FieldType -> DataType
(forall b. Data b => b -> b) -> FieldType -> FieldType
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> FieldType -> u
forall u. (forall d. Data d => d -> u) -> FieldType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FieldType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FieldType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FieldType -> m FieldType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FieldType -> m FieldType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FieldType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FieldType -> c FieldType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FieldType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FieldType)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FieldType -> c FieldType
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FieldType -> c FieldType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FieldType
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FieldType
$ctoConstr :: FieldType -> Constr
toConstr :: FieldType -> Constr
$cdataTypeOf :: FieldType -> DataType
dataTypeOf :: FieldType -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FieldType)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FieldType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FieldType)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FieldType)
$cgmapT :: (forall b. Data b => b -> b) -> FieldType -> FieldType
gmapT :: (forall b. Data b => b -> b) -> FieldType -> FieldType
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FieldType -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FieldType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FieldType -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FieldType -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> FieldType -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> FieldType -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FieldType -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FieldType -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FieldType -> m FieldType
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FieldType -> m FieldType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FieldType -> m FieldType
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FieldType -> m FieldType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FieldType -> m FieldType
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FieldType -> m FieldType
Data, FieldType -> FieldType -> Bool
(FieldType -> FieldType -> Bool)
-> (FieldType -> FieldType -> Bool) -> Eq FieldType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FieldType -> FieldType -> Bool
== :: FieldType -> FieldType -> Bool
$c/= :: FieldType -> FieldType -> Bool
/= :: FieldType -> FieldType -> Bool
Eq, Eq FieldType
Eq FieldType =>
(FieldType -> FieldType -> Ordering)
-> (FieldType -> FieldType -> Bool)
-> (FieldType -> FieldType -> Bool)
-> (FieldType -> FieldType -> Bool)
-> (FieldType -> FieldType -> Bool)
-> (FieldType -> FieldType -> FieldType)
-> (FieldType -> FieldType -> FieldType)
-> Ord FieldType
FieldType -> FieldType -> Bool
FieldType -> FieldType -> Ordering
FieldType -> FieldType -> FieldType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FieldType -> FieldType -> Ordering
compare :: FieldType -> FieldType -> Ordering
$c< :: FieldType -> FieldType -> Bool
< :: FieldType -> FieldType -> Bool
$c<= :: FieldType -> FieldType -> Bool
<= :: FieldType -> FieldType -> Bool
$c> :: FieldType -> FieldType -> Bool
> :: FieldType -> FieldType -> Bool
$c>= :: FieldType -> FieldType -> Bool
>= :: FieldType -> FieldType -> Bool
$cmax :: FieldType -> FieldType -> FieldType
max :: FieldType -> FieldType -> FieldType
$cmin :: FieldType -> FieldType -> FieldType
min :: FieldType -> FieldType -> FieldType
Ord, Int -> FieldType -> ShowS
[FieldType] -> ShowS
FieldType -> String
(Int -> FieldType -> ShowS)
-> (FieldType -> String)
-> ([FieldType] -> ShowS)
-> Show FieldType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FieldType -> ShowS
showsPrec :: Int -> FieldType -> ShowS
$cshow :: FieldType -> String
show :: FieldType -> String
$cshowList :: [FieldType] -> ShowS
showList :: [FieldType] -> ShowS
Show)

instance Pretty FieldType where
    pretty :: forall ann. FieldType -> Doc ann
pretty (PrimitiveFieldType PrimitiveType
p) = PrimitiveType -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. PrimitiveType -> Doc ann
pretty PrimitiveType
p
    pretty (ObjectFieldType QualifiedClassName
c) = QualifiedClassName -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. QualifiedClassName -> Doc ann
pretty QualifiedClassName
c
    pretty (ArrayFieldType FieldType
f) = FieldType -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. FieldType -> Doc ann
pretty FieldType
f Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
"[]"

-- | Convert a 'FieldType' to a 'ClassInfoType'
fieldTypeToClassInfoType :: FieldType -> ClassInfoType
fieldTypeToClassInfoType :: FieldType -> ClassInfoType
fieldTypeToClassInfoType (PrimitiveFieldType PrimitiveType
p) = PrimitiveType -> ClassInfoType
PrimitiveClassInfoType PrimitiveType
p
fieldTypeToClassInfoType (ObjectFieldType QualifiedClassName
c) = QualifiedClassName -> ClassInfoType
ClassInfoType QualifiedClassName
c
fieldTypeToClassInfoType (ArrayFieldType FieldType
f) = ClassInfoType -> ClassInfoType
ArrayClassInfoType (FieldType -> ClassInfoType
fieldTypeToClassInfoType FieldType
f)

{- | JVM class info type. Corresponds roughly to §4.2.1 of the JVM specification.
Used in places such as the constant pool and exception tables.
Isomorphic to 'FieldType', however converted to different low level representations (see 'H2JVM.Internal.Convert.Type.classInfoTypeDescriptor').
-}
data ClassInfoType
    = ClassInfoType QualifiedClassName
    | PrimitiveClassInfoType PrimitiveType
    | ArrayClassInfoType ClassInfoType
    deriving (Typeable ClassInfoType
Typeable ClassInfoType =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> ClassInfoType -> c ClassInfoType)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ClassInfoType)
-> (ClassInfoType -> Constr)
-> (ClassInfoType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ClassInfoType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ClassInfoType))
-> ((forall b. Data b => b -> b) -> ClassInfoType -> ClassInfoType)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ClassInfoType -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ClassInfoType -> r)
-> (forall u. (forall d. Data d => d -> u) -> ClassInfoType -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ClassInfoType -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ClassInfoType -> m ClassInfoType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ClassInfoType -> m ClassInfoType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ClassInfoType -> m ClassInfoType)
-> Data ClassInfoType
ClassInfoType -> Constr
ClassInfoType -> DataType
(forall b. Data b => b -> b) -> ClassInfoType -> ClassInfoType
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ClassInfoType -> u
forall u. (forall d. Data d => d -> u) -> ClassInfoType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ClassInfoType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ClassInfoType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ClassInfoType -> m ClassInfoType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ClassInfoType -> m ClassInfoType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ClassInfoType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ClassInfoType -> c ClassInfoType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ClassInfoType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ClassInfoType)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ClassInfoType -> c ClassInfoType
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ClassInfoType -> c ClassInfoType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ClassInfoType
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ClassInfoType
$ctoConstr :: ClassInfoType -> Constr
toConstr :: ClassInfoType -> Constr
$cdataTypeOf :: ClassInfoType -> DataType
dataTypeOf :: ClassInfoType -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ClassInfoType)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ClassInfoType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ClassInfoType)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ClassInfoType)
$cgmapT :: (forall b. Data b => b -> b) -> ClassInfoType -> ClassInfoType
gmapT :: (forall b. Data b => b -> b) -> ClassInfoType -> ClassInfoType
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ClassInfoType -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ClassInfoType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ClassInfoType -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ClassInfoType -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ClassInfoType -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ClassInfoType -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ClassInfoType -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ClassInfoType -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ClassInfoType -> m ClassInfoType
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ClassInfoType -> m ClassInfoType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ClassInfoType -> m ClassInfoType
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ClassInfoType -> m ClassInfoType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ClassInfoType -> m ClassInfoType
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ClassInfoType -> m ClassInfoType
Data, ClassInfoType -> ClassInfoType -> Bool
(ClassInfoType -> ClassInfoType -> Bool)
-> (ClassInfoType -> ClassInfoType -> Bool) -> Eq ClassInfoType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClassInfoType -> ClassInfoType -> Bool
== :: ClassInfoType -> ClassInfoType -> Bool
$c/= :: ClassInfoType -> ClassInfoType -> Bool
/= :: ClassInfoType -> ClassInfoType -> Bool
Eq, Eq ClassInfoType
Eq ClassInfoType =>
(ClassInfoType -> ClassInfoType -> Ordering)
-> (ClassInfoType -> ClassInfoType -> Bool)
-> (ClassInfoType -> ClassInfoType -> Bool)
-> (ClassInfoType -> ClassInfoType -> Bool)
-> (ClassInfoType -> ClassInfoType -> Bool)
-> (ClassInfoType -> ClassInfoType -> ClassInfoType)
-> (ClassInfoType -> ClassInfoType -> ClassInfoType)
-> Ord ClassInfoType
ClassInfoType -> ClassInfoType -> Bool
ClassInfoType -> ClassInfoType -> Ordering
ClassInfoType -> ClassInfoType -> ClassInfoType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ClassInfoType -> ClassInfoType -> Ordering
compare :: ClassInfoType -> ClassInfoType -> Ordering
$c< :: ClassInfoType -> ClassInfoType -> Bool
< :: ClassInfoType -> ClassInfoType -> Bool
$c<= :: ClassInfoType -> ClassInfoType -> Bool
<= :: ClassInfoType -> ClassInfoType -> Bool
$c> :: ClassInfoType -> ClassInfoType -> Bool
> :: ClassInfoType -> ClassInfoType -> Bool
$c>= :: ClassInfoType -> ClassInfoType -> Bool
>= :: ClassInfoType -> ClassInfoType -> Bool
$cmax :: ClassInfoType -> ClassInfoType -> ClassInfoType
max :: ClassInfoType -> ClassInfoType -> ClassInfoType
$cmin :: ClassInfoType -> ClassInfoType -> ClassInfoType
min :: ClassInfoType -> ClassInfoType -> ClassInfoType
Ord, Int -> ClassInfoType -> ShowS
[ClassInfoType] -> ShowS
ClassInfoType -> String
(Int -> ClassInfoType -> ShowS)
-> (ClassInfoType -> String)
-> ([ClassInfoType] -> ShowS)
-> Show ClassInfoType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClassInfoType -> ShowS
showsPrec :: Int -> ClassInfoType -> ShowS
$cshow :: ClassInfoType -> String
show :: ClassInfoType -> String
$cshowList :: [ClassInfoType] -> ShowS
showList :: [ClassInfoType] -> ShowS
Show)

-- | Convert a 'ClassInfoType' to a 'FieldType'.
classInfoTypeToFieldType :: ClassInfoType -> FieldType
classInfoTypeToFieldType :: ClassInfoType -> FieldType
classInfoTypeToFieldType (ClassInfoType QualifiedClassName
c) = QualifiedClassName -> FieldType
ObjectFieldType QualifiedClassName
c
classInfoTypeToFieldType (PrimitiveClassInfoType PrimitiveType
p) = PrimitiveType -> FieldType
PrimitiveFieldType PrimitiveType
p
classInfoTypeToFieldType (ArrayClassInfoType ClassInfoType
c) = FieldType -> FieldType
ArrayFieldType (ClassInfoType -> FieldType
classInfoTypeToFieldType ClassInfoType
c)

instance Pretty ClassInfoType where
    pretty :: forall ann. ClassInfoType -> Doc ann
pretty (ClassInfoType QualifiedClassName
c) = QualifiedClassName -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. QualifiedClassName -> Doc ann
pretty QualifiedClassName
c
    pretty (PrimitiveClassInfoType PrimitiveType
p) = PrimitiveType -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. PrimitiveType -> Doc ann
pretty PrimitiveType
p
    pretty (ArrayClassInfoType ClassInfoType
c) = ClassInfoType -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. ClassInfoType -> Doc ann
pretty ClassInfoType
c Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
"[]"