{-# LANGUAGE DuplicateRecordFields, MultiParamTypeClasses, NamedFieldPuns, OverloadedStrings, PatternSynonyms, QuasiQuotes, RecordWildCards, ScopedTypeVariables, TemplateHaskell #-} module LLVM.Internal.Operand where import LLVM.Prelude import LLVM.Exception import Control.Monad.Catch import Control.Monad.State import Control.Monad.AnyCont import Data.Bits import Data.Functor.Identity import qualified Data.Map as Map import Data.Maybe (mapMaybe) import Foreign.Ptr import qualified LLVM.Internal.FFI.Constant as FFI import qualified LLVM.Internal.FFI.InlineAssembly as FFI import qualified LLVM.Internal.FFI.LLVMCTypes as FFI import qualified LLVM.Internal.FFI.Metadata as FFI import qualified LLVM.Internal.FFI.PtrHierarchy as FFI import qualified LLVM.Internal.FFI.Value as FFI import LLVM.Internal.Coding import LLVM.Internal.Constant () import LLVM.Internal.Context import LLVM.Internal.DecodeAST import LLVM.Internal.EncodeAST import LLVM.Internal.InlineAssembly () import LLVM.Internal.Metadata (getByteStringFromFFI) import qualified LLVM.AST as A hiding (GlobalVariable, Module, PointerType, type') import qualified LLVM.AST.Operand as A import LLVM.Internal.FFI.LLVMCTypes (mdSubclassIdP) instance EncodeM EncodeAST ShortByteString (Ptr FFI.MDString) where encodeM :: ShortByteString -> EncodeAST (Ptr MDString) encodeM s :: ShortByteString s = do (CString, CUInt) s' <- ShortByteString -> EncodeAST (CString, CUInt) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString s Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr MDString) -> EncodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> (CString, CUInt) -> IO (Ptr MDString) FFI.getMDString Ptr Context c (CString, CUInt) s') instance Applicative m => EncodeM m [A.DIFlag] FFI.DIFlags where encodeM :: [DIFlag] -> m DIFlags encodeM fs :: [DIFlag] fs = DIFlags -> m DIFlags forall (f :: * -> *) a. Applicative f => a -> f a pure (Word32 -> DIFlags FFI.DIFlags ((Word32 -> Word32 -> Word32) -> Word32 -> [Word32] -> Word32 forall (t :: * -> *) b a. Foldable t => (b -> a -> b) -> b -> t a -> b foldl' Word32 -> Word32 -> Word32 forall a. Bits a => a -> a -> a (.|.) 0 ((DIFlag -> Word32) -> [DIFlag] -> [Word32] forall a b. (a -> b) -> [a] -> [b] map DIFlag -> Word32 forall p. (Num p, Bits p) => DIFlag -> p encodeFlag [DIFlag] fs))) where encodeFlag :: DIFlag -> p encodeFlag f :: DIFlag f = case DIFlag f of A.Accessibility A.Private -> 1 A.Accessibility A.Protected -> 2 A.Accessibility A.Public -> 3 A.FwdDecl -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 2 A.AppleBlock -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 3 A.BlockByrefStruct -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 4 A.VirtualFlag -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 5 A.Artificial -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 6 A.Explicit -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 7 A.Prototyped -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 8 A.ObjcClassComplete -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 9 A.ObjectPointer -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 10 A.Vector -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 11 A.StaticMember -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 12 A.LValueReference -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 13 A.RValueReference -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 14 A.InheritanceFlag A.SingleInheritance -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 16 A.InheritanceFlag A.MultipleInheritance -> 2 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 16 A.InheritanceFlag A.VirtualInheritance -> 3 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 16 A.IntroducedVirtual -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 18 A.BitField -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 19 A.NoReturn -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 20 A.ArgumentNotModified -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 21 A.TypePassByValue -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 22 A.TypePassByReference -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 23 A.EnumClass -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 24 A.Thunk -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 25 A.NonTrivial -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 26 A.BigEndian -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 27 A.LittleEndian -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 28 A.AllCallsDescribed -> 1 p -> Int -> p forall a. Bits a => a -> Int -> a `shiftL` 29 instance Applicative m => DecodeM m [A.DIFlag] FFI.DIFlags where decodeM :: DIFlags -> m [DIFlag] decodeM (FFI.DIFlags f :: Word32 f) = [DIFlag] -> m [DIFlag] forall (f :: * -> *) a. Applicative f => a -> f a pure ([DIFlag] -> m [DIFlag]) -> [DIFlag] -> m [DIFlag] forall a b. (a -> b) -> a -> b $ [DIFlag] accessibility [DIFlag] -> [DIFlag] -> [DIFlag] forall a. [a] -> [a] -> [a] ++ [DIFlag] inheritance [DIFlag] -> [DIFlag] -> [DIFlag] forall a. [a] -> [a] -> [a] ++ (DIFlag -> Maybe DIFlag) -> [DIFlag] -> [DIFlag] forall a b. (a -> Maybe b) -> [a] -> [b] mapMaybe DIFlag -> Maybe DIFlag flagSet [DIFlag] flags where flagSet :: A.DIFlag -> Maybe A.DIFlag flagSet :: DIFlag -> Maybe DIFlag flagSet f' :: DIFlag f' | Word32 f'' Word32 -> Word32 -> Word32 forall a. Bits a => a -> a -> a .&. Word32 f Word32 -> Word32 -> Bool forall a. Eq a => a -> a -> Bool /= 0 = DIFlag -> Maybe DIFlag forall a. a -> Maybe a Just DIFlag f' | Bool otherwise = Maybe DIFlag forall a. Maybe a Nothing where Identity (FFI.DIFlags f'' :: Word32 f'') = [DIFlag] -> Identity DIFlags forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DIFlag f'] accessibility :: [DIFlag] accessibility | Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f 0 Bool -> Bool -> Bool && Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f 1 = [DIAccessibility -> DIFlag A.Accessibility DIAccessibility A.Public] | Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f 0 = [DIAccessibility -> DIFlag A.Accessibility DIAccessibility A.Private] | Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f 1 = [DIAccessibility -> DIFlag A.Accessibility DIAccessibility A.Protected] | Bool otherwise = [] inheritance :: [DIFlag] inheritance | Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f 16 Bool -> Bool -> Bool && Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f 17 = [DIInheritance -> DIFlag A.InheritanceFlag DIInheritance A.VirtualInheritance] | Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f 16 = [DIInheritance -> DIFlag A.InheritanceFlag DIInheritance A.SingleInheritance] | Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f 17 = [DIInheritance -> DIFlag A.InheritanceFlag DIInheritance A.MultipleInheritance] | Bool otherwise = [] flags :: [DIFlag] flags = [ DIFlag A.FwdDecl , DIFlag A.AppleBlock , DIFlag A.BlockByrefStruct , DIFlag A.VirtualFlag , DIFlag A.Artificial , DIFlag A.Explicit , DIFlag A.Prototyped , DIFlag A.ObjcClassComplete , DIFlag A.ObjectPointer , DIFlag A.Vector , DIFlag A.StaticMember , DIFlag A.LValueReference , DIFlag A.RValueReference , DIFlag A.IntroducedVirtual , DIFlag A.BitField , DIFlag A.NoReturn , DIFlag A.ArgumentNotModified , DIFlag A.TypePassByValue , DIFlag A.TypePassByReference , DIFlag A.EnumClass , DIFlag A.Thunk , DIFlag A.NonTrivial , DIFlag A.BigEndian , DIFlag A.LittleEndian , DIFlag A.AllCallsDescribed ] instance DecodeM DecodeAST A.Operand (Ptr FFI.Value) where decodeM :: Ptr Value -> DecodeAST Operand decodeM v :: Ptr Value v = do Ptr Constant c <- IO (Ptr Constant) -> DecodeAST (Ptr Constant) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr Constant) -> DecodeAST (Ptr Constant)) -> IO (Ptr Constant) -> DecodeAST (Ptr Constant) forall a b. (a -> b) -> a -> b $ Ptr Value -> IO (Ptr Constant) FFI.isAConstant Ptr Value v if Ptr Constant c Ptr Constant -> Ptr Constant -> Bool forall a. Eq a => a -> a -> Bool /= Ptr Constant forall a. Ptr a nullPtr then (Constant -> Operand) -> DecodeAST (Constant -> Operand) forall (m :: * -> *) a. Monad m => a -> m a return Constant -> Operand A.ConstantOperand DecodeAST (Constant -> Operand) -> DecodeAST Constant -> DecodeAST Operand forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b `ap` Ptr Constant -> DecodeAST Constant forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM Ptr Constant c else do Ptr MetadataAsVal m <- IO (Ptr MetadataAsVal) -> DecodeAST (Ptr MetadataAsVal) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr MetadataAsVal) -> DecodeAST (Ptr MetadataAsVal)) -> IO (Ptr MetadataAsVal) -> DecodeAST (Ptr MetadataAsVal) forall a b. (a -> b) -> a -> b $ Ptr Value -> IO (Ptr MetadataAsVal) FFI.isAMetadataOperand Ptr Value v if Ptr MetadataAsVal m Ptr MetadataAsVal -> Ptr MetadataAsVal -> Bool forall a. Eq a => a -> a -> Bool /= Ptr MetadataAsVal forall a. Ptr a nullPtr then Metadata -> Operand A.MetadataOperand (Metadata -> Operand) -> DecodeAST Metadata -> DecodeAST Operand forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr MetadataAsVal -> DecodeAST Metadata forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM Ptr MetadataAsVal m else Type -> Name -> Operand A.LocalReference (Type -> Name -> Operand) -> DecodeAST Type -> DecodeAST (Name -> Operand) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (Ptr Type -> DecodeAST Type forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr Type -> DecodeAST Type) -> DecodeAST (Ptr Type) -> DecodeAST Type forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr Type) -> DecodeAST (Ptr Type) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Value -> IO (Ptr Type) FFI.typeOf Ptr Value v)) DecodeAST (Name -> Operand) -> DecodeAST Name -> DecodeAST Operand forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Ptr Value -> DecodeAST Name forall v. DescendentOf Value v => Ptr v -> DecodeAST Name getLocalName Ptr Value v instance DecodeM DecodeAST A.Metadata (Ptr FFI.Metadata) where decodeM :: Ptr Metadata -> DecodeAST Metadata decodeM md :: Ptr Metadata md = do Ptr MDString s <- IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr MDString) -> DecodeAST (Ptr MDString)) -> IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall a b. (a -> b) -> a -> b $ Ptr Metadata -> IO (Ptr MDString) FFI.isAMDString Ptr Metadata md if Ptr MDString s Ptr MDString -> Ptr MDString -> Bool forall a. Eq a => a -> a -> Bool /= Ptr MDString forall a. Ptr a nullPtr then ShortByteString -> Metadata A.MDString (ShortByteString -> Metadata) -> DecodeAST ShortByteString -> DecodeAST Metadata forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM Ptr MDString s else do Ptr MDNode n <- IO (Ptr MDNode) -> DecodeAST (Ptr MDNode) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr MDNode) -> DecodeAST (Ptr MDNode)) -> IO (Ptr MDNode) -> DecodeAST (Ptr MDNode) forall a b. (a -> b) -> a -> b $ Ptr Metadata -> IO (Ptr MDNode) FFI.isAMDNode Ptr Metadata md if Ptr MDNode n Ptr MDNode -> Ptr MDNode -> Bool forall a. Eq a => a -> a -> Bool /= Ptr MDNode forall a. Ptr a nullPtr then MDRef MDNode -> Metadata A.MDNode (MDRef MDNode -> Metadata) -> DecodeAST (MDRef MDNode) -> DecodeAST Metadata forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr MDNode -> DecodeAST (MDRef MDNode) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM Ptr MDNode n else do Ptr MDValue v <- IO (Ptr MDValue) -> DecodeAST (Ptr MDValue) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr MDValue) -> DecodeAST (Ptr MDValue)) -> IO (Ptr MDValue) -> DecodeAST (Ptr MDValue) forall a b. (a -> b) -> a -> b $ Ptr Metadata -> IO (Ptr MDValue) FFI.isAMDValue Ptr Metadata md if Ptr MDValue v Ptr MDValue -> Ptr MDValue -> Bool forall a. Eq a => a -> a -> Bool /= Ptr MDValue forall a. Ptr a nullPtr then Operand -> Metadata A.MDValue (Operand -> Metadata) -> DecodeAST Operand -> DecodeAST Metadata forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr MDValue -> DecodeAST Operand forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM Ptr MDValue v else DecodeException -> DecodeAST Metadata forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException "Metadata was not one of [MDString, MDValue, MDNode]") instance DecodeM DecodeAST A.DINode (Ptr FFI.DINode) where decodeM :: Ptr DINode -> DecodeAST DINode decodeM diN :: Ptr DINode diN = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO MDSubclassID -> DecodeAST MDSubclassID) -> IO MDSubclassID -> DecodeAST MDSubclassID forall a b. (a -> b) -> a -> b $ Ptr MDNode -> IO MDSubclassID FFI.getMetadataClassId (Ptr DINode -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DINode diN) case MDSubclassID sId of [mdSubclassIdP|DIEnumerator|] -> DIEnumerator -> DINode A.DIEnumerator (DIEnumerator -> DINode) -> DecodeAST DIEnumerator -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIEnumerator -> DecodeAST DIEnumerator forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIEnumerator forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIEnumerator) [mdSubclassIdP|DIImportedEntity|] -> DIImportedEntity -> DINode A.DIImportedEntity (DIImportedEntity -> DINode) -> DecodeAST DIImportedEntity -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIImportedEntity -> DecodeAST DIImportedEntity forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIImportedEntity forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIImportedEntity) [mdSubclassIdP|DIObjCProperty|] -> DIObjCProperty -> DINode A.DIObjCProperty (DIObjCProperty -> DINode) -> DecodeAST DIObjCProperty -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIObjCProperty -> DecodeAST DIObjCProperty forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIObjCProperty forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIObjCProperty) [mdSubclassIdP|DISubrange|] -> DISubrange -> DINode A.DISubrange (DISubrange -> DINode) -> DecodeAST DISubrange -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DISubrange -> DecodeAST DISubrange forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DISubrange forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DISubrange) [mdSubclassIdP|DIBasicType|] -> DIScope -> DINode A.DIScope (DIScope -> DINode) -> DecodeAST DIScope -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIScope -> DecodeAST DIScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) [mdSubclassIdP|DICompositeType|] -> DIScope -> DINode A.DIScope (DIScope -> DINode) -> DecodeAST DIScope -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIScope -> DecodeAST DIScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) [mdSubclassIdP|DIDerivedType|] -> DIScope -> DINode A.DIScope (DIScope -> DINode) -> DecodeAST DIScope -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIScope -> DecodeAST DIScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) [mdSubclassIdP|DISubroutineType|] -> DIScope -> DINode A.DIScope (DIScope -> DINode) -> DecodeAST DIScope -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIScope -> DecodeAST DIScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) [mdSubclassIdP|DILexicalBlock|] -> DIScope -> DINode A.DIScope (DIScope -> DINode) -> DecodeAST DIScope -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIScope -> DecodeAST DIScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) [mdSubclassIdP|DILexicalBlockFile|] -> DIScope -> DINode A.DIScope (DIScope -> DINode) -> DecodeAST DIScope -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIScope -> DecodeAST DIScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) [mdSubclassIdP|DIFile|] -> DIScope -> DINode A.DIScope (DIScope -> DINode) -> DecodeAST DIScope -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIScope -> DecodeAST DIScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) [mdSubclassIdP|DINamespace|] -> DIScope -> DINode A.DIScope (DIScope -> DINode) -> DecodeAST DIScope -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIScope -> DecodeAST DIScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) [mdSubclassIdP|DISubprogram|] -> DIScope -> DINode A.DIScope (DIScope -> DINode) -> DecodeAST DIScope -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIScope -> DecodeAST DIScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) [mdSubclassIdP|DICompileUnit|] -> DIScope -> DINode A.DIScope (DIScope -> DINode) -> DecodeAST DIScope -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIScope -> DecodeAST DIScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) [mdSubclassIdP|DIModule|] -> DIScope -> DINode A.DIScope (DIScope -> DINode) -> DecodeAST DIScope -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIScope -> DecodeAST DIScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) [mdSubclassIdP|DIGlobalVariable|] -> DIVariable -> DINode A.DIVariable (DIVariable -> DINode) -> DecodeAST DIVariable -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIVariable -> DecodeAST DIVariable forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIVariable forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIVariable) [mdSubclassIdP|DILocalVariable|] -> DIVariable -> DINode A.DIVariable (DIVariable -> DINode) -> DecodeAST DIVariable -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIVariable -> DecodeAST DIVariable forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DIVariable forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIVariable) [mdSubclassIdP|DITemplateTypeParameter|] -> DITemplateParameter -> DINode A.DITemplateParameter (DITemplateParameter -> DINode) -> DecodeAST DITemplateParameter -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DITemplateParameter -> DecodeAST DITemplateParameter forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DITemplateParameter forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DITemplateParameter) [mdSubclassIdP|DITemplateValueParameter|] -> DITemplateParameter -> DINode A.DITemplateParameter (DITemplateParameter -> DINode) -> DecodeAST DITemplateParameter -> DecodeAST DINode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DITemplateParameter -> DecodeAST DITemplateParameter forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> Ptr DITemplateParameter forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DITemplateParameter) _ -> DecodeException -> DecodeAST DINode forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Unknown subclass id for DINode: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId)) instance EncodeM EncodeAST A.DISubrange (Ptr FFI.DISubrange) where encodeM :: DISubrange -> EncodeAST (Ptr DISubrange) encodeM (A.Subrange {..}) = do Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext case DICount count of A.DICountConstant i :: Int64 i -> IO (Ptr DISubrange) -> EncodeAST (Ptr DISubrange) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Int64 -> Int64 -> IO (Ptr DISubrange) FFI.getDISubrangeConstantCount Ptr Context c Int64 i Int64 lowerBound) A.DICountVariable v :: MDRef DIVariable v -> do Ptr DIVariable v' <- MDRef DIVariable -> EncodeAST (Ptr DIVariable) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM MDRef DIVariable v IO (Ptr DISubrange) -> EncodeAST (Ptr DISubrange) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIVariable -> Int64 -> IO (Ptr DISubrange) FFI.getDISubrangeVariableCount Ptr Context c Ptr DIVariable v' Int64 lowerBound) instance DecodeM DecodeAST A.DISubrange (Ptr FFI.DISubrange) where decodeM :: Ptr DISubrange -> DecodeAST DISubrange decodeM r :: Ptr DISubrange r = do Int64 lowerBound <- IO Int64 -> DecodeAST Int64 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubrange -> IO Int64 FFI.getDISubrangeLowerBound Ptr DISubrange r) Bool hasConstantCount <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubrange -> IO LLVMBool FFI.getDISubrangeHasConstantCount Ptr DISubrange r) if Bool hasConstantCount then do Int64 count <- IO Int64 -> DecodeAST Int64 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubrange -> IO Int64 FFI.getDISubrangeCountConstant Ptr DISubrange r) DISubrange -> DecodeAST DISubrange forall (f :: * -> *) a. Applicative f => a -> f a pure (DICount -> Int64 -> DISubrange A.Subrange (Int64 -> DICount A.DICountConstant Int64 count) Int64 lowerBound) else do MDRef DIVariable count <- Ptr DIVariable -> DecodeAST (MDRef DIVariable) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIVariable -> DecodeAST (MDRef DIVariable)) -> DecodeAST (Ptr DIVariable) -> DecodeAST (MDRef DIVariable) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIVariable) -> DecodeAST (Ptr DIVariable) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubrange -> IO (Ptr DIVariable) FFI.getDISubrangeCountVariable Ptr DISubrange r) DISubrange -> DecodeAST DISubrange forall (f :: * -> *) a. Applicative f => a -> f a pure (DICount -> Int64 -> DISubrange A.Subrange (MDRef DIVariable -> DICount A.DICountVariable MDRef DIVariable count) Int64 lowerBound) instance EncodeM EncodeAST A.DIEnumerator (Ptr FFI.DIEnumerator) where encodeM :: DIEnumerator -> EncodeAST (Ptr DIEnumerator) encodeM (A.Enumerator {..}) = do Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name LLVMBool isUnsigned <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Bool isUnsigned Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DIEnumerator) -> EncodeAST (Ptr DIEnumerator) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Int64 -> LLVMBool -> Ptr MDString -> IO (Ptr DIEnumerator) FFI.getDIEnumerator Ptr Context c Int64 value LLVMBool isUnsigned Ptr MDString name) instance DecodeM DecodeAST A.DIEnumerator (Ptr FFI.DIEnumerator) where decodeM :: Ptr DIEnumerator -> DecodeAST DIEnumerator decodeM e :: Ptr DIEnumerator e = do Int64 value <- IO Int64 -> DecodeAST Int64 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIEnumerator -> IO Int64 FFI.getDIEnumeratorValue Ptr DIEnumerator e) Bool isUnsigned <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIEnumerator -> IO LLVMBool FFI.getDIEnumeratorIsUnsigned Ptr DIEnumerator e) ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIEnumerator -> IO (Ptr MDString) FFI.getDIEnumeratorName Ptr DIEnumerator e) DIEnumerator -> DecodeAST DIEnumerator forall (f :: * -> *) a. Applicative f => a -> f a pure (Int64 -> Bool -> ShortByteString -> DIEnumerator A.Enumerator Int64 value Bool isUnsigned ShortByteString name) instance EncodeM EncodeAST A.DINode (Ptr FFI.DINode) where encodeM :: DINode -> EncodeAST (Ptr DINode) encodeM (A.DISubrange r :: DISubrange r) = do Ptr DISubrange ptr <- DISubrange -> EncodeAST (Ptr DISubrange) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DISubrange r Ptr DINode -> EncodeAST (Ptr DINode) forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr DISubrange -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DISubrange ptr :: Ptr FFI.DISubrange)) encodeM (A.DIEnumerator e :: DIEnumerator e) = do Ptr DIEnumerator ptr <- DIEnumerator -> EncodeAST (Ptr DIEnumerator) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIEnumerator e Ptr DINode -> EncodeAST (Ptr DINode) forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr DIEnumerator -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIEnumerator ptr :: Ptr FFI.DIEnumerator)) encodeM (A.DIScope s :: DIScope s) = do Ptr DIScope ptr <- DIScope -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIScope s Ptr DINode -> EncodeAST (Ptr DINode) forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr DIScope -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIScope ptr :: Ptr FFI.DIScope)) encodeM (A.DIVariable v :: DIVariable v) = do Ptr DIVariable ptr <- DIVariable -> EncodeAST (Ptr DIVariable) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIVariable v Ptr DINode -> EncodeAST (Ptr DINode) forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr DIVariable -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIVariable ptr :: Ptr FFI.DIVariable)) encodeM (A.DITemplateParameter p :: DITemplateParameter p) = do Ptr DITemplateParameter ptr <- DITemplateParameter -> EncodeAST (Ptr DITemplateParameter) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DITemplateParameter p Ptr DINode -> EncodeAST (Ptr DINode) forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr DITemplateParameter -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DITemplateParameter ptr :: Ptr FFI.DITemplateParameter)) encodeM (A.DIImportedEntity e :: DIImportedEntity e) = do Ptr DIImportedEntity ptr <- DIImportedEntity -> EncodeAST (Ptr DIImportedEntity) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIImportedEntity e Ptr DINode -> EncodeAST (Ptr DINode) forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr DIImportedEntity -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIImportedEntity ptr :: Ptr FFI.DIImportedEntity)) encodeM (A.DIObjCProperty o :: DIObjCProperty o) = Ptr DIObjCProperty -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIObjCProperty -> Ptr DINode) -> EncodeAST (Ptr DIObjCProperty) -> EncodeAST (Ptr DINode) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DIObjCProperty -> EncodeAST (Ptr DIObjCProperty) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIObjCProperty o :: EncodeAST (Ptr FFI.DIObjCProperty)) instance DecodeM DecodeAST A.DIScope (Ptr FFI.DIScope) where decodeM :: Ptr DIScope -> DecodeAST DIScope decodeM p :: Ptr DIScope p = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO MDSubclassID -> DecodeAST MDSubclassID) -> IO MDSubclassID -> DecodeAST MDSubclassID forall a b. (a -> b) -> a -> b $ Ptr MDNode -> IO MDSubclassID FFI.getMetadataClassId (Ptr DIScope -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIScope p) case MDSubclassID sId of [mdSubclassIdP|DINamespace|] -> DINamespace -> DIScope A.DINamespace (DINamespace -> DIScope) -> DecodeAST DINamespace -> DecodeAST DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DINamespace -> DecodeAST DINamespace forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> Ptr DINamespace forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DINamespace) [mdSubclassIdP|DIFile|] -> DIFile -> DIScope A.DIFile (DIFile -> DIScope) -> DecodeAST DIFile -> DecodeAST DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIFile -> DecodeAST DIFile forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> Ptr DIFile forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIFile) [mdSubclassIdP|DILexicalBlock|] -> DILocalScope -> DIScope A.DILocalScope (DILocalScope -> DIScope) -> DecodeAST DILocalScope -> DecodeAST DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DILocalScope -> DecodeAST DILocalScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> Ptr DILocalScope forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DILocalScope) [mdSubclassIdP|DILexicalBlockFile|] -> DILocalScope -> DIScope A.DILocalScope (DILocalScope -> DIScope) -> DecodeAST DILocalScope -> DecodeAST DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DILocalScope -> DecodeAST DILocalScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> Ptr DILocalScope forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DILocalScope) [mdSubclassIdP|DISubprogram|] -> DILocalScope -> DIScope A.DILocalScope (DILocalScope -> DIScope) -> DecodeAST DILocalScope -> DecodeAST DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DILocalScope -> DecodeAST DILocalScope forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> Ptr DILocalScope forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DILocalScope) [mdSubclassIdP|DIBasicType|] -> DIType -> DIScope A.DIType (DIType -> DIScope) -> DecodeAST DIType -> DecodeAST DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIType -> DecodeAST DIType forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> Ptr DIType forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIType) [mdSubclassIdP|DICompositeType|] -> DIType -> DIScope A.DIType (DIType -> DIScope) -> DecodeAST DIType -> DecodeAST DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIType -> DecodeAST DIType forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> Ptr DIType forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIType) [mdSubclassIdP|DIDerivedType|] -> DIType -> DIScope A.DIType (DIType -> DIScope) -> DecodeAST DIType -> DecodeAST DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIType -> DecodeAST DIType forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> Ptr DIType forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIType) [mdSubclassIdP|DISubroutineType|] -> DIType -> DIScope A.DIType (DIType -> DIScope) -> DecodeAST DIType -> DecodeAST DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIType -> DecodeAST DIType forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> Ptr DIType forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIType) [mdSubclassIdP|DICompileUnit|] -> DICompileUnit -> DIScope A.DICompileUnit (DICompileUnit -> DIScope) -> DecodeAST DICompileUnit -> DecodeAST DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DICompileUnit -> DecodeAST DICompileUnit forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> Ptr DICompileUnit forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DICompileUnit) [mdSubclassIdP|DIModule|] -> DIModule -> DIScope A.DIModule (DIModule -> DIScope) -> DecodeAST DIModule -> DecodeAST DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIModule -> DecodeAST DIModule forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> Ptr DIModule forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIModule) _ -> DecodeException -> DecodeAST DIScope forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Unknown subclass id for DIScope: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId)) instance DecodeM DecodeAST A.DINamespace (Ptr FFI.DINamespace) where decodeM :: Ptr DINamespace -> DecodeAST DINamespace decodeM p :: Ptr DINamespace p = do Maybe (MDRef DIScope) scope <- Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope))) -> DecodeAST (Ptr DIScope) -> DecodeAST (Maybe (MDRef DIScope)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIScope) -> DecodeAST (Ptr DIScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIScope -> IO (Ptr DIScope) FFI.getScopeScope (Ptr DINamespace -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DINamespace p)) ShortByteString name <- (Ptr DIScope -> Ptr CUInt -> IO CString) -> Ptr DIScope -> DecodeAST ShortByteString forall a. (Ptr a -> Ptr CUInt -> IO CString) -> Ptr a -> DecodeAST ShortByteString getByteStringFromFFI Ptr DIScope -> Ptr CUInt -> IO CString FFI.getScopeName (Ptr DINamespace -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DINamespace p) Bool exported <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DINamespace -> IO LLVMBool FFI.getNamespaceExportedSymbols (Ptr DINamespace -> Ptr DINamespace forall a b. Ptr a -> Ptr b castPtr Ptr DINamespace p)) DINamespace -> DecodeAST DINamespace forall (m :: * -> *) a. Monad m => a -> m a return (ShortByteString -> Maybe (MDRef DIScope) -> Bool -> DINamespace A.Namespace ShortByteString name Maybe (MDRef DIScope) scope Bool exported) instance EncodeM EncodeAST A.DINamespace (Ptr FFI.DINamespace) where encodeM :: DINamespace -> EncodeAST (Ptr DINamespace) encodeM A.Namespace {..} = do Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIScope) scope LLVMBool exportSyms <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Bool exportSymbols Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DINamespace) -> EncodeAST (Ptr DINamespace) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIScope -> Ptr MDString -> LLVMBool -> IO (Ptr DINamespace) FFI.getDINamespace Ptr Context c Ptr DIScope scope Ptr MDString name LLVMBool exportSyms) instance DecodeM DecodeAST A.DIModule (Ptr FFI.DIModule) where decodeM :: Ptr DIModule -> DecodeAST DIModule decodeM p :: Ptr DIModule p = do Maybe (MDRef DIScope) scope <- Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope))) -> DecodeAST (Ptr DIScope) -> DecodeAST (Maybe (MDRef DIScope)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIScope) -> DecodeAST (Ptr DIScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIScope -> IO (Ptr DIScope) FFI.getScopeScope (Ptr DIModule -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIModule p)) ShortByteString name <- (Ptr DIScope -> Ptr CUInt -> IO CString) -> Ptr DIScope -> DecodeAST ShortByteString forall a. (Ptr a -> Ptr CUInt -> IO CString) -> Ptr a -> DecodeAST ShortByteString getByteStringFromFFI Ptr DIScope -> Ptr CUInt -> IO CString FFI.getScopeName (Ptr DIModule -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIModule p) let m :: Ptr DIModule m = Ptr DIModule -> Ptr DIModule forall a b. Ptr a -> Ptr b castPtr Ptr DIModule p :: Ptr FFI.DIModule ShortByteString configurationMacros <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIModule -> IO (Ptr MDString) FFI.getDIModuleConfigurationMacros Ptr DIModule m) ShortByteString includePath <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIModule -> IO (Ptr MDString) FFI.getDIModuleIncludePath Ptr DIModule m) ShortByteString isysRoot <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIModule -> IO (Ptr MDString) FFI.getDIModuleISysRoot Ptr DIModule m) DIModule -> DecodeAST DIModule forall (f :: * -> *) a. Applicative f => a -> f a pure Module :: Maybe (MDRef DIScope) -> ShortByteString -> ShortByteString -> ShortByteString -> ShortByteString -> DIModule A.Module { $sel:scope:Module :: Maybe (MDRef DIScope) A.scope = Maybe (MDRef DIScope) scope , $sel:name:Module :: ShortByteString A.name = ShortByteString name , $sel:configurationMacros:Module :: ShortByteString A.configurationMacros = ShortByteString configurationMacros , $sel:includePath:Module :: ShortByteString A.includePath = ShortByteString includePath , $sel:isysRoot:Module :: ShortByteString A.isysRoot = ShortByteString isysRoot } instance EncodeM EncodeAST A.DIModule (Ptr FFI.DIModule) where encodeM :: DIModule -> EncodeAST (Ptr DIModule) encodeM A.Module {..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr MDString configurationMacros <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString configurationMacros Ptr MDString includePath <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString includePath Ptr MDString isysRoot <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString isysRoot Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DIModule) -> EncodeAST (Ptr DIModule) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIScope -> Ptr MDString -> Ptr MDString -> Ptr MDString -> Ptr MDString -> IO (Ptr DIModule) FFI.getDIModule Ptr Context c Ptr DIScope scope Ptr MDString name Ptr MDString configurationMacros Ptr MDString includePath Ptr MDString isysRoot) genCodingInstance [t|A.DebugEmissionKind|] ''FFI.DebugEmissionKind [ (FFI.NoDebug, A.NoDebug) , (FFI.FullDebug, A.FullDebug) , (FFI.LineTablesOnly, A.LineTablesOnly) ] genCodingInstance [t|A.DebugNameTableKind|] ''FFI.DebugNameTableKind [ (FFI.NameTableKindDefault, A.NameTableKindDefault) , (FFI.NameTableKindGNU, A.NameTableKindGNU) , (FFI.NameTableKindNone, A.NameTableKindNone) ] instance DecodeM DecodeAST A.DICompileUnit (Ptr FFI.DICompileUnit) where decodeM :: Ptr DICompileUnit -> DecodeAST DICompileUnit decodeM p :: Ptr DICompileUnit p = do Word32 language <- CUInt -> DecodeAST Word32 forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (CUInt -> DecodeAST Word32) -> DecodeAST CUInt -> DecodeAST Word32 forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO CUInt -> DecodeAST CUInt forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO CUInt FFI.getDICompileUnitLanguage Ptr DICompileUnit p) MDRef DIFile file <- Ptr DIFile -> DecodeAST (MDRef DIFile) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIFile -> DecodeAST (MDRef DIFile)) -> DecodeAST (Ptr DIFile) -> DecodeAST (MDRef DIFile) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIFile) -> DecodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIScope -> IO (Ptr DIFile) FFI.getScopeFile (Ptr DICompileUnit -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DICompileUnit p)) ShortByteString producer <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO (Ptr MDString) FFI.getDICompileUnitProducer Ptr DICompileUnit p) Bool optimized <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO LLVMBool FFI.getDICompileUnitOptimized Ptr DICompileUnit p) ShortByteString flags <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO (Ptr MDString) FFI.getDICompileUnitFlags Ptr DICompileUnit p) Word32 runtimeVersion <- CUInt -> DecodeAST Word32 forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (CUInt -> DecodeAST Word32) -> DecodeAST CUInt -> DecodeAST Word32 forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO CUInt -> DecodeAST CUInt forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO CUInt FFI.getDICompileUnitRuntimeVersion Ptr DICompileUnit p) ShortByteString splitDebugFilename <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO (Ptr MDString) FFI.getDICompileUnitSplitDebugFilename Ptr DICompileUnit p) DebugEmissionKind emissionKind <- DebugEmissionKind -> DecodeAST DebugEmissionKind forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DebugEmissionKind -> DecodeAST DebugEmissionKind) -> DecodeAST DebugEmissionKind -> DecodeAST DebugEmissionKind forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DebugEmissionKind -> DecodeAST DebugEmissionKind forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO DebugEmissionKind FFI.getDICompileUnitEmissionKind Ptr DICompileUnit p) Word64 dwoid <- Word64 -> DecodeAST Word64 forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Word64 -> DecodeAST Word64) -> DecodeAST Word64 -> DecodeAST Word64 forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO Word64 -> DecodeAST Word64 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO Word64 FFI.getDICompileUnitDWOId Ptr DICompileUnit p) Bool splitDebugInlining <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO LLVMBool FFI.getDICompileUnitSplitDebugInlining Ptr DICompileUnit p) Bool debugInfoForProfiling <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO LLVMBool FFI.getDICompileUnitDebugInfoForProfiling Ptr DICompileUnit p) [MDRef DICompositeType] enums <- TupleArray DICompositeType -> DecodeAST [MDRef DICompositeType] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (TupleArray DICompositeType -> DecodeAST [MDRef DICompositeType]) -> DecodeAST (TupleArray DICompositeType) -> DecodeAST [MDRef DICompositeType] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (TupleArray DICompositeType) -> DecodeAST (TupleArray DICompositeType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO (TupleArray DICompositeType) FFI.getDICompileUnitEnumTypes Ptr DICompileUnit p) [MDRef DIScope] retainedTypes' <- TupleArray DIScope -> DecodeAST [MDRef DIScope] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (TupleArray DIScope -> DecodeAST [MDRef DIScope]) -> DecodeAST (TupleArray DIScope) -> DecodeAST [MDRef DIScope] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (TupleArray DIScope) -> DecodeAST (TupleArray DIScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO (TupleArray DIScope) FFI.getDICompileUnitRetainedTypes Ptr DICompileUnit p) let toRetainedType :: A.MDRef A.DIScope -> DecodeAST (A.MDRef (Either A.DIType A.DISubprogram)) toRetainedType :: MDRef DIScope -> DecodeAST (MDRef (Either DIType DISubprogram)) toRetainedType (A.MDRef i :: MetadataNodeID i) = MDRef (Either DIType DISubprogram) -> DecodeAST (MDRef (Either DIType DISubprogram)) forall (f :: * -> *) a. Applicative f => a -> f a pure (MetadataNodeID -> MDRef (Either DIType DISubprogram) forall a. MetadataNodeID -> MDRef a A.MDRef MetadataNodeID i) toRetainedType (A.MDInline (A.DIType ty :: DIType ty)) = MDRef (Either DIType DISubprogram) -> DecodeAST (MDRef (Either DIType DISubprogram)) forall (f :: * -> *) a. Applicative f => a -> f a pure (Either DIType DISubprogram -> MDRef (Either DIType DISubprogram) forall a. a -> MDRef a A.MDInline (DIType -> Either DIType DISubprogram forall a b. a -> Either a b Left DIType ty)) toRetainedType (A.MDInline (A.DILocalScope (A.DISubprogram p :: DISubprogram p))) = MDRef (Either DIType DISubprogram) -> DecodeAST (MDRef (Either DIType DISubprogram)) forall (f :: * -> *) a. Applicative f => a -> f a pure (Either DIType DISubprogram -> MDRef (Either DIType DISubprogram) forall a. a -> MDRef a A.MDInline (DISubprogram -> Either DIType DISubprogram forall a b. b -> Either a b Right DISubprogram p)) toRetainedType (A.MDInline e :: DIScope e) = DecodeException -> DecodeAST (MDRef (Either DIType DISubprogram)) forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Retained type must be DISubprogram or DIType but got " String -> String -> String forall a. Semigroup a => a -> a -> a <> DIScope -> String forall a. Show a => a -> String show DIScope e)) [MDRef (Either DIType DISubprogram)] retainedTypes <- (MDRef DIScope -> DecodeAST (MDRef (Either DIType DISubprogram))) -> [MDRef DIScope] -> DecodeAST [MDRef (Either DIType DISubprogram)] forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse MDRef DIScope -> DecodeAST (MDRef (Either DIType DISubprogram)) toRetainedType [MDRef DIScope] retainedTypes' [MDRef DIGlobalVariableExpression] globals <- TupleArray DIGlobalVariableExpression -> DecodeAST [MDRef DIGlobalVariableExpression] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (TupleArray DIGlobalVariableExpression -> DecodeAST [MDRef DIGlobalVariableExpression]) -> DecodeAST (TupleArray DIGlobalVariableExpression) -> DecodeAST [MDRef DIGlobalVariableExpression] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (TupleArray DIGlobalVariableExpression) -> DecodeAST (TupleArray DIGlobalVariableExpression) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO (TupleArray DIGlobalVariableExpression) FFI.getDICompileUnitGlobalVariables Ptr DICompileUnit p) [MDRef DIImportedEntity] entities <- TupleArray DIImportedEntity -> DecodeAST [MDRef DIImportedEntity] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (TupleArray DIImportedEntity -> DecodeAST [MDRef DIImportedEntity]) -> DecodeAST (TupleArray DIImportedEntity) -> DecodeAST [MDRef DIImportedEntity] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (TupleArray DIImportedEntity) -> DecodeAST (TupleArray DIImportedEntity) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO (TupleArray DIImportedEntity) FFI.getDICompileUnitImportedEntities Ptr DICompileUnit p) [MDRef DIMacroNode] macros <- TupleArray DIMacroNode -> DecodeAST [MDRef DIMacroNode] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (TupleArray DIMacroNode -> DecodeAST [MDRef DIMacroNode]) -> DecodeAST (TupleArray DIMacroNode) -> DecodeAST [MDRef DIMacroNode] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (TupleArray DIMacroNode) -> DecodeAST (TupleArray DIMacroNode) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO (TupleArray DIMacroNode) FFI.getDICompileUnitMacros Ptr DICompileUnit p) DebugNameTableKind nameTableKind <- DebugNameTableKind -> DecodeAST DebugNameTableKind forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DebugNameTableKind -> DecodeAST DebugNameTableKind) -> DecodeAST DebugNameTableKind -> DecodeAST DebugNameTableKind forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DebugNameTableKind -> DecodeAST DebugNameTableKind forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO DebugNameTableKind FFI.getDICompileUnitNameTableKind Ptr DICompileUnit p) Bool debugBaseAddress <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO LLVMBool FFI.getDICompileUnitRangesBaseAddress Ptr DICompileUnit p) DICompileUnit -> DecodeAST DICompileUnit forall (f :: * -> *) a. Applicative f => a -> f a pure CompileUnit :: Word32 -> MDRef DIFile -> ShortByteString -> Bool -> ShortByteString -> Word32 -> ShortByteString -> DebugEmissionKind -> [MDRef DICompositeType] -> [MDRef (Either DIType DISubprogram)] -> [MDRef DIGlobalVariableExpression] -> [MDRef DIImportedEntity] -> [MDRef DIMacroNode] -> Word64 -> Bool -> Bool -> DebugNameTableKind -> Bool -> DICompileUnit A.CompileUnit { $sel:language:CompileUnit :: Word32 A.language = Word32 language , $sel:file:CompileUnit :: MDRef DIFile A.file = MDRef DIFile file , $sel:producer:CompileUnit :: ShortByteString A.producer = ShortByteString producer , $sel:optimized:CompileUnit :: Bool A.optimized = Bool optimized , $sel:flags:CompileUnit :: ShortByteString A.flags = ShortByteString flags , $sel:runtimeVersion:CompileUnit :: Word32 A.runtimeVersion = Word32 runtimeVersion , $sel:splitDebugFileName:CompileUnit :: ShortByteString A.splitDebugFileName = ShortByteString splitDebugFilename , $sel:emissionKind:CompileUnit :: DebugEmissionKind A.emissionKind = DebugEmissionKind emissionKind , $sel:enums:CompileUnit :: [MDRef DICompositeType] A.enums = [MDRef DICompositeType] enums , $sel:retainedTypes:CompileUnit :: [MDRef (Either DIType DISubprogram)] A.retainedTypes = [MDRef (Either DIType DISubprogram)] retainedTypes , $sel:globals:CompileUnit :: [MDRef DIGlobalVariableExpression] A.globals = [MDRef DIGlobalVariableExpression] globals , $sel:imports:CompileUnit :: [MDRef DIImportedEntity] A.imports = [MDRef DIImportedEntity] entities , $sel:macros:CompileUnit :: [MDRef DIMacroNode] A.macros = [MDRef DIMacroNode] macros , $sel:dWOId:CompileUnit :: Word64 A.dWOId = Word64 dwoid , $sel:splitDebugInlining:CompileUnit :: Bool A.splitDebugInlining = Bool splitDebugInlining , $sel:debugInfoForProfiling:CompileUnit :: Bool A.debugInfoForProfiling = Bool debugInfoForProfiling , $sel:nameTableKind:CompileUnit :: DebugNameTableKind A.nameTableKind = DebugNameTableKind nameTableKind , $sel:debugBaseAddress:CompileUnit :: Bool A.debugBaseAddress = Bool debugBaseAddress } instance EncodeM EncodeAST A.DICompileUnit (Ptr FFI.DICompileUnit) where encodeM :: DICompileUnit -> EncodeAST (Ptr DICompileUnit) encodeM (A.CompileUnit {..}) = do CUInt language <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Word32 language Ptr DIFile file <- MDRef DIFile -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM MDRef DIFile file Ptr MDString producer <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString producer LLVMBool optimized <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Bool optimized Ptr MDString flags <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString flags CUInt runtimeVersion <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Word32 runtimeVersion Ptr MDString debugFileName <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString splitDebugFileName DebugEmissionKind emissionKind <- DebugEmissionKind -> EncodeAST DebugEmissionKind forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DebugEmissionKind emissionKind TupleArray DICompositeType enums <- [MDRef DICompositeType] -> EncodeAST (TupleArray DICompositeType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [MDRef DICompositeType] enums TupleArray DIScope retainedTypes <- [MDRef DIScope] -> EncodeAST (TupleArray DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ((MDRef (Either DIType DISubprogram) -> MDRef DIScope) -> [MDRef (Either DIType DISubprogram)] -> [MDRef DIScope] forall a b. (a -> b) -> [a] -> [b] map ((Either DIType DISubprogram -> DIScope) -> MDRef (Either DIType DISubprogram) -> MDRef DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap ((DIType -> DIScope) -> (DISubprogram -> DIScope) -> Either DIType DISubprogram -> DIScope forall a c b. (a -> c) -> (b -> c) -> Either a b -> c either DIType -> DIScope A.DIType (DILocalScope -> DIScope A.DILocalScope (DILocalScope -> DIScope) -> (DISubprogram -> DILocalScope) -> DISubprogram -> DIScope forall b c a. (b -> c) -> (a -> b) -> a -> c . DISubprogram -> DILocalScope A.DISubprogram))) [MDRef (Either DIType DISubprogram)] retainedTypes) TupleArray DIGlobalVariableExpression globals <- [MDRef DIGlobalVariableExpression] -> EncodeAST (TupleArray DIGlobalVariableExpression) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [MDRef DIGlobalVariableExpression] globals TupleArray DIImportedEntity imports <- [MDRef DIImportedEntity] -> EncodeAST (TupleArray DIImportedEntity) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [MDRef DIImportedEntity] imports TupleArray DIMacroNode macros <- [MDRef DIMacroNode] -> EncodeAST (TupleArray DIMacroNode) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [MDRef DIMacroNode] macros Word64 dwoid <- Word64 -> EncodeAST Word64 forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Word64 dWOId LLVMBool splitDebugInlining <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Bool splitDebugInlining LLVMBool debugInfoForProfiling <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Bool debugInfoForProfiling DebugNameTableKind nameTableKind <- DebugNameTableKind -> EncodeAST DebugNameTableKind forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DebugNameTableKind nameTableKind LLVMBool debugBaseAddress <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Bool debugBaseAddress Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DICompileUnit) -> EncodeAST (Ptr DICompileUnit) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr DICompileUnit) -> EncodeAST (Ptr DICompileUnit)) -> IO (Ptr DICompileUnit) -> EncodeAST (Ptr DICompileUnit) forall a b. (a -> b) -> a -> b $ Ptr Context -> CUInt -> Ptr DIFile -> Ptr MDString -> LLVMBool -> Ptr MDString -> CUInt -> Ptr MDString -> DebugEmissionKind -> TupleArray DICompositeType -> TupleArray DIScope -> TupleArray DIGlobalVariableExpression -> TupleArray DIImportedEntity -> TupleArray DIMacroNode -> Word64 -> LLVMBool -> LLVMBool -> DebugNameTableKind -> LLVMBool -> IO (Ptr DICompileUnit) FFI.getDICompileUnit Ptr Context c CUInt language Ptr DIFile file Ptr MDString producer LLVMBool optimized Ptr MDString flags CUInt runtimeVersion Ptr MDString debugFileName DebugEmissionKind emissionKind TupleArray DICompositeType enums TupleArray DIScope retainedTypes TupleArray DIGlobalVariableExpression globals TupleArray DIImportedEntity imports TupleArray DIMacroNode macros Word64 dwoid LLVMBool splitDebugInlining LLVMBool debugInfoForProfiling DebugNameTableKind nameTableKind LLVMBool debugBaseAddress instance EncodeM EncodeAST A.DIScope (Ptr FFI.DIScope) where encodeM :: DIScope -> EncodeAST (Ptr DIScope) encodeM (A.DIFile f :: DIFile f) = Ptr DIFile -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIFile -> Ptr DIScope) -> EncodeAST (Ptr DIFile) -> EncodeAST (Ptr DIScope) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DIFile -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIFile f :: EncodeAST (Ptr FFI.DIFile)) encodeM (A.DICompileUnit cu :: DICompileUnit cu) = Ptr DICompileUnit -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DICompileUnit -> Ptr DIScope) -> EncodeAST (Ptr DICompileUnit) -> EncodeAST (Ptr DIScope) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DICompileUnit -> EncodeAST (Ptr DICompileUnit) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DICompileUnit cu :: EncodeAST (Ptr FFI.DICompileUnit)) encodeM (A.DIType t :: DIType t) = Ptr DIType -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIType -> Ptr DIScope) -> EncodeAST (Ptr DIType) -> EncodeAST (Ptr DIScope) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DIType -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIType t :: EncodeAST (Ptr FFI.DIType)) encodeM (A.DILocalScope t :: DILocalScope t) = Ptr DILocalScope -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DILocalScope -> Ptr DIScope) -> EncodeAST (Ptr DILocalScope) -> EncodeAST (Ptr DIScope) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DILocalScope -> EncodeAST (Ptr DILocalScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DILocalScope t :: EncodeAST (Ptr FFI.DILocalScope)) encodeM (A.DINamespace ns :: DINamespace ns) = Ptr DINamespace -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DINamespace -> Ptr DIScope) -> EncodeAST (Ptr DINamespace) -> EncodeAST (Ptr DIScope) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DINamespace -> EncodeAST (Ptr DINamespace) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DINamespace ns :: EncodeAST (Ptr FFI.DINamespace)) encodeM (A.DIModule m :: DIModule m) = Ptr DIModule -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIModule -> Ptr DIScope) -> EncodeAST (Ptr DIModule) -> EncodeAST (Ptr DIScope) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DIModule -> EncodeAST (Ptr DIModule) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIModule m :: EncodeAST (Ptr FFI.DIModule)) instance DecodeM DecodeAST A.DIFile (Ptr FFI.DIFile) where decodeM :: Ptr DIFile -> DecodeAST DIFile decodeM diF :: Ptr DIFile diF = do ShortByteString fname <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIFile -> IO (Ptr MDString) FFI.getFileFilename Ptr DIFile diF) ShortByteString dir <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIFile -> IO (Ptr MDString) FFI.getFileDirectory Ptr DIFile diF) Maybe ShortByteString mayChecksum <- Ptr MDString -> DecodeAST (Maybe ShortByteString) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST (Maybe ShortByteString)) -> DecodeAST (Ptr MDString) -> DecodeAST (Maybe ShortByteString) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIFile -> IO (Ptr MDString) FFI.getFileChecksumValue Ptr DIFile diF) case Maybe ShortByteString mayChecksum of Nothing -> DIFile -> DecodeAST DIFile forall (f :: * -> *) a. Applicative f => a -> f a pure (ShortByteString -> ShortByteString -> Maybe ChecksumInfo -> DIFile A.File ShortByteString fname ShortByteString dir Maybe ChecksumInfo forall a. Maybe a Nothing) Just checksum :: ShortByteString checksum -> do ChecksumKind csk <- ChecksumKind -> DecodeAST ChecksumKind forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (ChecksumKind -> DecodeAST ChecksumKind) -> DecodeAST ChecksumKind -> DecodeAST ChecksumKind forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO ChecksumKind -> DecodeAST ChecksumKind forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIFile -> IO ChecksumKind FFI.getFileChecksumKind Ptr DIFile diF) DIFile -> DecodeAST DIFile forall (f :: * -> *) a. Applicative f => a -> f a pure (ShortByteString -> ShortByteString -> Maybe ChecksumInfo -> DIFile A.File ShortByteString fname ShortByteString dir (ChecksumInfo -> Maybe ChecksumInfo forall a. a -> Maybe a Just (ChecksumKind -> ShortByteString -> ChecksumInfo A.ChecksumInfo ChecksumKind csk ShortByteString checksum))) instance EncodeM EncodeAST A.DIFile (Ptr FFI.DIFile) where encodeM :: DIFile -> EncodeAST (Ptr DIFile) encodeM (A.File {..}) = do Ptr MDString filename <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString filename Ptr MDString directory <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString directory Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext case Maybe ChecksumInfo checksum of Nothing -> IO (Ptr DIFile) -> EncodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr MDString -> Ptr MDString -> ChecksumKind -> Ptr MDString -> IO (Ptr DIFile) FFI.getDIFile Ptr Context c Ptr MDString filename Ptr MDString directory (CUInt -> ChecksumKind FFI.ChecksumKind 0) Ptr MDString forall a. Ptr a nullPtr) Just (A.ChecksumInfo {..}) -> do Ptr MDString checksumValue <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString checksumValue ChecksumKind checksumKind <- ChecksumKind -> EncodeAST ChecksumKind forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ChecksumKind checksumKind IO (Ptr DIFile) -> EncodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr MDString -> Ptr MDString -> ChecksumKind -> Ptr MDString -> IO (Ptr DIFile) FFI.getDIFile Ptr Context c Ptr MDString filename Ptr MDString directory ChecksumKind checksumKind Ptr MDString checksumValue) instance EncodeM EncodeAST (Maybe A.Encoding) FFI.Encoding where encodeM :: Maybe Encoding -> EncodeAST Encoding encodeM Nothing = Encoding -> EncodeAST Encoding forall (f :: * -> *) a. Applicative f => a -> f a pure (CUInt -> Encoding FFI.Encoding 0) encodeM (Just e :: Encoding e) = Encoding -> EncodeAST Encoding forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Encoding e instance DecodeM DecodeAST (Maybe A.Encoding) FFI.Encoding where decodeM :: Encoding -> DecodeAST (Maybe Encoding) decodeM (FFI.Encoding 0) = Maybe Encoding -> DecodeAST (Maybe Encoding) forall (f :: * -> *) a. Applicative f => a -> f a pure Maybe Encoding forall a. Maybe a Nothing decodeM e :: Encoding e = Encoding -> Maybe Encoding forall a. a -> Maybe a Just (Encoding -> Maybe Encoding) -> DecodeAST Encoding -> DecodeAST (Maybe Encoding) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Encoding -> DecodeAST Encoding forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM Encoding e genCodingInstance [t|A.Encoding|] ''FFI.Encoding [ (FFI.DwAtE_address, A.AddressEncoding) , (FFI.DwAtE_boolean, A.BooleanEncoding) , (FFI.DwAtE_float, A.FloatEncoding) , (FFI.DwAtE_signed, A.SignedEncoding) , (FFI.DwAtE_signed_char, A.SignedCharEncoding) , (FFI.DwAtE_unsigned, A.UnsignedEncoding) , (FFI.DwAtE_unsigned_char, A.UnsignedCharEncoding) , (FFI.DwAtE_UTF, A.UTFEncoding) ] genCodingInstance [t|A.ChecksumKind|] ''FFI.ChecksumKind [ (FFI.ChecksumKind 1, A.MD5) , (FFI.ChecksumKind 2, A.SHA1) ] genCodingInstance [t|A.BasicTypeTag|] ''FFI.DwTag [ (FFI.DwTag_base_type, A.BaseType) , (FFI.DwTag_unspecified_type, A.UnspecifiedType) ] instance EncodeM EncodeAST A.DIType (Ptr FFI.DIType) where encodeM :: DIType -> EncodeAST (Ptr DIType) encodeM (A.DIBasicType t :: DIBasicType t) = Ptr DIBasicType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIBasicType -> Ptr DIType) -> EncodeAST (Ptr DIBasicType) -> EncodeAST (Ptr DIType) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DIBasicType -> EncodeAST (Ptr DIBasicType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIBasicType t :: EncodeAST (Ptr FFI.DIBasicType)) encodeM (A.DIDerivedType t :: DIDerivedType t) = Ptr DIDerivedType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIDerivedType -> Ptr DIType) -> EncodeAST (Ptr DIDerivedType) -> EncodeAST (Ptr DIType) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DIDerivedType -> EncodeAST (Ptr DIDerivedType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIDerivedType t :: EncodeAST (Ptr FFI.DIDerivedType)) encodeM (A.DISubroutineType t :: DISubroutineType t) = Ptr DISubroutineType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DISubroutineType -> Ptr DIType) -> EncodeAST (Ptr DISubroutineType) -> EncodeAST (Ptr DIType) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DISubroutineType -> EncodeAST (Ptr DISubroutineType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DISubroutineType t :: EncodeAST (Ptr FFI.DISubroutineType)) encodeM (A.DICompositeType t :: DICompositeType t) = Ptr DICompositeType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DICompositeType -> Ptr DIType) -> EncodeAST (Ptr DICompositeType) -> EncodeAST (Ptr DIType) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DICompositeType -> EncodeAST (Ptr DICompositeType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DICompositeType t :: EncodeAST (Ptr FFI.DICompositeType)) instance DecodeM DecodeAST A.DICompositeType (Ptr FFI.DICompositeType) where decodeM :: Ptr DICompositeType -> DecodeAST DICompositeType decodeM diTy :: Ptr DICompositeType diTy = do DwTag tag <- IO DwTag -> DecodeAST DwTag forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DINode -> IO DwTag FFI.getTag (Ptr DICompositeType -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DICompositeType diTy)) Word64 size <- IO Word64 -> DecodeAST Word64 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO Word64 FFI.getTypeSizeInBits (Ptr DICompositeType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DICompositeType diTy)) Word32 align <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO Word32 FFI.getTypeAlignInBits (Ptr DICompositeType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DICompositeType diTy)) Ptr MDTuple elements <- IO (Ptr MDTuple) -> DecodeAST (Ptr MDTuple) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompositeType -> IO (Ptr MDTuple) FFI.getElements Ptr DICompositeType diTy) Maybe (MDRef DIScope) scope <- Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope))) -> DecodeAST (Ptr DIScope) -> DecodeAST (Maybe (MDRef DIScope)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIScope) -> DecodeAST (Ptr DIScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIScope -> IO (Ptr DIScope) FFI.getScopeScope (Ptr DICompositeType -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DICompositeType diTy)) ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO (Ptr MDString) FFI.getTypeName (Ptr DICompositeType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DICompositeType diTy)) Maybe (MDRef DIFile) file <- Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile))) -> DecodeAST (Ptr DIFile) -> DecodeAST (Maybe (MDRef DIFile)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIFile) -> DecodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIScope -> IO (Ptr DIFile) FFI.getScopeFile (Ptr DICompositeType -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DICompositeType diTy)) Word32 line <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO Word32 FFI.getTypeLine (Ptr DICompositeType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DICompositeType diTy)) [DIFlag] flags <- DIFlags -> DecodeAST [DIFlag] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DIFlags -> DecodeAST [DIFlag]) -> DecodeAST DIFlags -> DecodeAST [DIFlag] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DIFlags -> DecodeAST DIFlags forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO DIFlags FFI.getTypeFlags (Ptr DICompositeType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DICompositeType diTy)) Word16 runtimeLang <- IO Word16 -> DecodeAST Word16 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompositeType -> IO Word16 FFI.getRuntimeLang Ptr DICompositeType diTy) Maybe (MDRef DIType) vtableHolder <- Ptr DIType -> DecodeAST (Maybe (MDRef DIType)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> DecodeAST (Maybe (MDRef DIType))) -> DecodeAST (Ptr DIType) -> DecodeAST (Maybe (MDRef DIType)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIType) -> DecodeAST (Ptr DIType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompositeType -> IO (Ptr DIType) FFI.getVTableHolder Ptr DICompositeType diTy) Maybe (MDRef DIType) type' <- Ptr DIType -> DecodeAST (Maybe (MDRef DIType)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> DecodeAST (Maybe (MDRef DIType))) -> DecodeAST (Ptr DIType) -> DecodeAST (Maybe (MDRef DIType)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIType) -> DecodeAST (Ptr DIType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompositeType -> IO (Ptr DIType) FFI.getCompositeBaseType Ptr DICompositeType diTy) ShortByteString identifier <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompositeType -> IO (Ptr MDString) FFI.getIdentifier Ptr DICompositeType diTy) case DwTag tag of FFI.DwTag_array_type -> do [DISubrange] subscripts <- TupleArray DISubrange -> DecodeAST [DISubrange] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDTuple -> TupleArray DISubrange forall a. Ptr MDTuple -> TupleArray a FFI.TupleArray Ptr MDTuple elements :: FFI.TupleArray FFI.DISubrange) DICompositeType -> DecodeAST DICompositeType forall (f :: * -> *) a. Applicative f => a -> f a pure ([DISubrange] -> Maybe (MDRef DIType) -> Word64 -> Word32 -> [DIFlag] -> DICompositeType A.DIArrayType [DISubrange] subscripts Maybe (MDRef DIType) type' Word64 size Word32 align [DIFlag] flags) FFI.DwTag_enumeration_type -> do [DIEnumerator] values <- TupleArray DIEnumerator -> DecodeAST [DIEnumerator] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDTuple -> TupleArray DIEnumerator forall a. Ptr MDTuple -> TupleArray a FFI.TupleArray Ptr MDTuple elements :: FFI.TupleArray FFI.DIEnumerator) DICompositeType -> DecodeAST DICompositeType forall (f :: * -> *) a. Applicative f => a -> f a pure (Maybe (MDRef DIScope) -> ShortByteString -> Maybe (MDRef DIFile) -> Word32 -> [DIEnumerator] -> Maybe (MDRef DIType) -> ShortByteString -> Word64 -> Word32 -> DICompositeType A.DIEnumerationType Maybe (MDRef DIScope) scope ShortByteString name Maybe (MDRef DIFile) file Word32 line [DIEnumerator] values Maybe (MDRef DIType) type' ShortByteString identifier Word64 size Word32 align) FFI.DwTag_structure_type -> do [MDRef DIScope] elements <- TupleArray DIScope -> DecodeAST [MDRef DIScope] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDTuple -> TupleArray DIScope forall a. Ptr MDTuple -> TupleArray a FFI.TupleArray Ptr MDTuple elements :: FFI.TupleArray FFI.DIScope) [MDRef (Either DIDerivedType DISubprogram)] elements <- (MDRef DIScope -> DecodeAST (MDRef (Either DIDerivedType DISubprogram))) -> [MDRef DIScope] -> DecodeAST [MDRef (Either DIDerivedType DISubprogram)] forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse MDRef DIScope -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) fromCompElement [MDRef DIScope] elements DICompositeType -> DecodeAST DICompositeType forall (f :: * -> *) a. Applicative f => a -> f a pure (Maybe (MDRef DIScope) -> ShortByteString -> Maybe (MDRef DIFile) -> Word32 -> [DIFlag] -> Maybe (MDRef DIType) -> [MDRef (Either DIDerivedType DISubprogram)] -> Word16 -> Maybe (MDRef DIType) -> ShortByteString -> Word64 -> Word32 -> DICompositeType A.DIStructureType Maybe (MDRef DIScope) scope ShortByteString name Maybe (MDRef DIFile) file Word32 line [DIFlag] flags Maybe (MDRef DIType) type' [MDRef (Either DIDerivedType DISubprogram)] elements Word16 runtimeLang Maybe (MDRef DIType) vtableHolder ShortByteString identifier Word64 size Word32 align) FFI.DwTag_class_type -> do [MDRef DIScope] elements <- TupleArray DIScope -> DecodeAST [MDRef DIScope] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDTuple -> TupleArray DIScope forall a. Ptr MDTuple -> TupleArray a FFI.TupleArray Ptr MDTuple elements :: FFI.TupleArray FFI.DIScope) [MDRef (Either DIDerivedType DISubprogram)] elements <- (MDRef DIScope -> DecodeAST (MDRef (Either DIDerivedType DISubprogram))) -> [MDRef DIScope] -> DecodeAST [MDRef (Either DIDerivedType DISubprogram)] forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse MDRef DIScope -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) fromCompElement [MDRef DIScope] elements Maybe (MDRef DIType) vtableHolder <- Ptr DIType -> DecodeAST (Maybe (MDRef DIType)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> DecodeAST (Maybe (MDRef DIType))) -> DecodeAST (Ptr DIType) -> DecodeAST (Maybe (MDRef DIType)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIType) -> DecodeAST (Ptr DIType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompositeType -> IO (Ptr DIType) FFI.getVTableHolder Ptr DICompositeType diTy) [DITemplateParameter] params <- TupleArray DITemplateParameter -> DecodeAST [DITemplateParameter] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (TupleArray DITemplateParameter -> DecodeAST [DITemplateParameter]) -> DecodeAST (TupleArray DITemplateParameter) -> DecodeAST [DITemplateParameter] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (TupleArray DITemplateParameter) -> DecodeAST (TupleArray DITemplateParameter) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompositeType -> IO (TupleArray DITemplateParameter) FFI.getTemplateParams Ptr DICompositeType diTy) DICompositeType -> DecodeAST DICompositeType forall (f :: * -> *) a. Applicative f => a -> f a pure (Maybe (MDRef DIScope) -> ShortByteString -> Maybe (MDRef DIFile) -> Word32 -> [DIFlag] -> Maybe (MDRef DIType) -> [MDRef (Either DIDerivedType DISubprogram)] -> Maybe (MDRef DIType) -> [DITemplateParameter] -> ShortByteString -> Word64 -> Word32 -> DICompositeType A.DIClassType Maybe (MDRef DIScope) scope ShortByteString name Maybe (MDRef DIFile) file Word32 line [DIFlag] flags Maybe (MDRef DIType) type' [MDRef (Either DIDerivedType DISubprogram)] elements Maybe (MDRef DIType) vtableHolder [DITemplateParameter] params ShortByteString identifier Word64 size Word32 align) FFI.DwTag_union_type -> do [MDRef DIScope] elements <- TupleArray DIScope -> DecodeAST [MDRef DIScope] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDTuple -> TupleArray DIScope forall a. Ptr MDTuple -> TupleArray a FFI.TupleArray Ptr MDTuple elements :: FFI.TupleArray FFI.DIScope) [MDRef (Either DIDerivedType DISubprogram)] elements <- (MDRef DIScope -> DecodeAST (MDRef (Either DIDerivedType DISubprogram))) -> [MDRef DIScope] -> DecodeAST [MDRef (Either DIDerivedType DISubprogram)] forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse MDRef DIScope -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) fromCompElement [MDRef DIScope] elements DICompositeType -> DecodeAST DICompositeType forall (f :: * -> *) a. Applicative f => a -> f a pure (Maybe (MDRef DIScope) -> ShortByteString -> Maybe (MDRef DIFile) -> Word32 -> [DIFlag] -> [MDRef (Either DIDerivedType DISubprogram)] -> Word16 -> ShortByteString -> Word64 -> Word32 -> DICompositeType A.DIUnionType Maybe (MDRef DIScope) scope ShortByteString name Maybe (MDRef DIFile) file Word32 line [DIFlag] flags [MDRef (Either DIDerivedType DISubprogram)] elements Word16 runtimeLang ShortByteString identifier Word64 size Word32 align) _ -> DecodeException -> DecodeAST DICompositeType forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Unknown tag of DICompositeType: " String -> String -> String forall a. Semigroup a => a -> a -> a <> DwTag -> String forall a. Show a => a -> String show DwTag tag)) fromCompElement :: A.MDRef A.DIScope -> DecodeAST (A.MDRef (Either A.DIDerivedType A.DISubprogram)) fromCompElement :: MDRef DIScope -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) fromCompElement (A.MDRef r :: MetadataNodeID r) = MDRef (Either DIDerivedType DISubprogram) -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) forall (f :: * -> *) a. Applicative f => a -> f a pure (MetadataNodeID -> MDRef (Either DIDerivedType DISubprogram) forall a. MetadataNodeID -> MDRef a A.MDRef MetadataNodeID r) fromCompElement (A.MDInline (A.DIType (A.DIDerivedType ty :: DIDerivedType ty))) = MDRef (Either DIDerivedType DISubprogram) -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) forall (f :: * -> *) a. Applicative f => a -> f a pure (Either DIDerivedType DISubprogram -> MDRef (Either DIDerivedType DISubprogram) forall a. a -> MDRef a A.MDInline (DIDerivedType -> Either DIDerivedType DISubprogram forall a b. a -> Either a b Left DIDerivedType ty)) fromCompElement (A.MDInline (A.DILocalScope (A.DISubprogram p :: DISubprogram p))) = MDRef (Either DIDerivedType DISubprogram) -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) forall (f :: * -> *) a. Applicative f => a -> f a pure (Either DIDerivedType DISubprogram -> MDRef (Either DIDerivedType DISubprogram) forall a. a -> MDRef a A.MDInline (DISubprogram -> Either DIDerivedType DISubprogram forall a b. b -> Either a b Right DISubprogram p)) fromCompElement (A.MDInline e :: DIScope e) = DecodeException -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Elements of DIClassType, DIStructureType and DIUnionType must be DIDerivedType or DISubprogram but got " String -> String -> String forall a. Semigroup a => a -> a -> a <> DIScope -> String forall a. Show a => a -> String show DIScope e)) toCompElement :: A.MDRef (Either A.DIDerivedType A.DISubprogram) -> A.MDRef A.DIScope toCompElement :: MDRef (Either DIDerivedType DISubprogram) -> MDRef DIScope toCompElement = (Either DIDerivedType DISubprogram -> DIScope) -> MDRef (Either DIDerivedType DISubprogram) -> MDRef DIScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap ((DIDerivedType -> DIScope) -> (DISubprogram -> DIScope) -> Either DIDerivedType DISubprogram -> DIScope forall a c b. (a -> c) -> (b -> c) -> Either a b -> c either (DIType -> DIScope A.DIType (DIType -> DIScope) -> (DIDerivedType -> DIType) -> DIDerivedType -> DIScope forall b c a. (b -> c) -> (a -> b) -> a -> c . DIDerivedType -> DIType A.DIDerivedType) (DILocalScope -> DIScope A.DILocalScope (DILocalScope -> DIScope) -> (DISubprogram -> DILocalScope) -> DISubprogram -> DIScope forall b c a. (b -> c) -> (a -> b) -> a -> c . DISubprogram -> DILocalScope A.DISubprogram)) instance EncodeM EncodeAST A.DICompositeType (Ptr FFI.DICompositeType) where encodeM :: DICompositeType -> EncodeAST (Ptr DICompositeType) encodeM A.DIArrayType {..} = do TupleArray DISubrange subscripts <- [DISubrange] -> EncodeAST (TupleArray DISubrange) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DISubrange] subscripts Ptr DIType elementTy <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIType) elementTy DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DIFlag] flags Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DICompositeType) -> EncodeAST (Ptr DICompositeType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> TupleArray DISubrange -> Ptr DIType -> Word64 -> Word32 -> DIFlags -> IO (Ptr DICompositeType) FFI.getDIArrayType Ptr Context c TupleArray DISubrange subscripts Ptr DIType elementTy Word64 sizeInBits Word32 alignInBits DIFlags flags) encodeM A.DIEnumerationType {..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file TupleArray DIEnumerator elements <- [DIEnumerator] -> EncodeAST (TupleArray DIEnumerator) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DIEnumerator] values Ptr DIType underlyingType <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIType) baseType Ptr MDString identifier <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString identifier Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DICompositeType) -> EncodeAST (Ptr DICompositeType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIScope -> Ptr MDString -> Ptr DIFile -> Word32 -> Word64 -> Word32 -> TupleArray DIEnumerator -> Ptr DIType -> Ptr MDString -> IO (Ptr DICompositeType) FFI.getDIEnumerationType Ptr Context c Ptr DIScope scope Ptr MDString name Ptr DIFile file Word32 line Word64 sizeInBits Word32 alignInBits TupleArray DIEnumerator elements Ptr DIType underlyingType Ptr MDString identifier) encodeM A.DIStructureType {..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DIFlag] flags Ptr DIType derivedFrom <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIType) derivedFrom TupleArray DIScope elements <- [MDRef DIScope] -> EncodeAST (TupleArray DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ((MDRef (Either DIDerivedType DISubprogram) -> MDRef DIScope) -> [MDRef (Either DIDerivedType DISubprogram)] -> [MDRef DIScope] forall a b. (a -> b) -> [a] -> [b] map MDRef (Either DIDerivedType DISubprogram) -> MDRef DIScope toCompElement [MDRef (Either DIDerivedType DISubprogram)] elements) Ptr DIType vtableHolder <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIType) vtableHolder Ptr MDString identifier <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString identifier Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DICompositeType) -> EncodeAST (Ptr DICompositeType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIScope -> Ptr MDString -> Ptr DIFile -> Word32 -> Word64 -> Word32 -> DIFlags -> Ptr DIType -> TupleArray DIScope -> Word16 -> Ptr DIType -> Ptr MDString -> IO (Ptr DICompositeType) FFI.getDIStructType Ptr Context c Ptr DIScope scope Ptr MDString name Ptr DIFile file Word32 line Word64 sizeInBits Word32 alignInBits DIFlags flags Ptr DIType derivedFrom TupleArray DIScope elements Word16 runtimeLang Ptr DIType vtableHolder Ptr MDString identifier) encodeM A.DIUnionType {..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DIFlag] flags TupleArray DIScope elements <- [MDRef DIScope] -> EncodeAST (TupleArray DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ((MDRef (Either DIDerivedType DISubprogram) -> MDRef DIScope) -> [MDRef (Either DIDerivedType DISubprogram)] -> [MDRef DIScope] forall a b. (a -> b) -> [a] -> [b] map MDRef (Either DIDerivedType DISubprogram) -> MDRef DIScope toCompElement [MDRef (Either DIDerivedType DISubprogram)] elements) Ptr MDString identifier <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString identifier Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DICompositeType) -> EncodeAST (Ptr DICompositeType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIScope -> Ptr MDString -> Ptr DIFile -> Word32 -> Word64 -> Word32 -> DIFlags -> TupleArray DIScope -> Word16 -> Ptr MDString -> IO (Ptr DICompositeType) FFI.getDIUnionType Ptr Context c Ptr DIScope scope Ptr MDString name Ptr DIFile file Word32 line Word64 sizeInBits Word32 alignInBits DIFlags flags TupleArray DIScope elements Word16 runtimeLang Ptr MDString identifier) encodeM A.DIClassType {..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DIFlag] flags Ptr DIType derivedFrom <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIType) derivedFrom TupleArray DIScope elements <- [MDRef DIScope] -> EncodeAST (TupleArray DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ((MDRef (Either DIDerivedType DISubprogram) -> MDRef DIScope) -> [MDRef (Either DIDerivedType DISubprogram)] -> [MDRef DIScope] forall a b. (a -> b) -> [a] -> [b] map MDRef (Either DIDerivedType DISubprogram) -> MDRef DIScope toCompElement [MDRef (Either DIDerivedType DISubprogram)] elements) Ptr DIType vtableHolder <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIType) vtableHolder TupleArray DITemplateParameter params <- [DITemplateParameter] -> EncodeAST (TupleArray DITemplateParameter) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DITemplateParameter] templateParams Ptr MDString identifier <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString identifier Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DICompositeType) -> EncodeAST (Ptr DICompositeType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIScope -> Ptr MDString -> Ptr DIFile -> Word32 -> Word64 -> Word32 -> DIFlags -> Ptr DIType -> TupleArray DIScope -> Ptr DIType -> TupleArray DITemplateParameter -> Ptr MDString -> IO (Ptr DICompositeType) FFI.getDIClassType Ptr Context c Ptr DIScope scope Ptr MDString name Ptr DIFile file Word32 line Word64 sizeInBits Word32 alignInBits DIFlags flags Ptr DIType derivedFrom TupleArray DIScope elements Ptr DIType vtableHolder TupleArray DITemplateParameter params Ptr MDString identifier) instance DecodeM DecodeAST A.DIType (Ptr FFI.DIType) where decodeM :: Ptr DIType -> DecodeAST DIType decodeM diTy :: Ptr DIType diTy = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO MDSubclassID -> DecodeAST MDSubclassID) -> IO MDSubclassID -> DecodeAST MDSubclassID forall a b. (a -> b) -> a -> b $ Ptr MDNode -> IO MDSubclassID FFI.getMetadataClassId (Ptr DIType -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIType diTy) case MDSubclassID sId of [mdSubclassIdP|DIBasicType|] -> DIBasicType -> DIType A.DIBasicType (DIBasicType -> DIType) -> DecodeAST DIBasicType -> DecodeAST DIType forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIBasicType -> DecodeAST DIBasicType forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> Ptr DIBasicType forall a b. Ptr a -> Ptr b castPtr Ptr DIType diTy :: Ptr FFI.DIBasicType) [mdSubclassIdP|DICompositeType|] -> DICompositeType -> DIType A.DICompositeType (DICompositeType -> DIType) -> DecodeAST DICompositeType -> DecodeAST DIType forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DICompositeType -> DecodeAST DICompositeType forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> Ptr DICompositeType forall a b. Ptr a -> Ptr b castPtr Ptr DIType diTy :: Ptr FFI.DICompositeType) [mdSubclassIdP|DIDerivedType|] -> DIDerivedType -> DIType A.DIDerivedType (DIDerivedType -> DIType) -> DecodeAST DIDerivedType -> DecodeAST DIType forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIDerivedType -> DecodeAST DIDerivedType forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> Ptr DIDerivedType forall a b. Ptr a -> Ptr b castPtr Ptr DIType diTy :: Ptr FFI.DIDerivedType) [mdSubclassIdP|DISubroutineType|] -> DISubroutineType -> DIType A.DISubroutineType (DISubroutineType -> DIType) -> DecodeAST DISubroutineType -> DecodeAST DIType forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DISubroutineType -> DecodeAST DISubroutineType forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> Ptr DISubroutineType forall a b. Ptr a -> Ptr b castPtr Ptr DIType diTy :: Ptr FFI.DISubroutineType) _ -> DecodeException -> DecodeAST DIType forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Unknown subclass id for DIType: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId)) instance DecodeM DecodeAST A.DIBasicType (Ptr FFI.DIBasicType) where decodeM :: Ptr DIBasicType -> DecodeAST DIBasicType decodeM diTy :: Ptr DIBasicType diTy = do BasicTypeTag tag <- DwTag -> DecodeAST BasicTypeTag forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DwTag -> DecodeAST BasicTypeTag) -> DecodeAST DwTag -> DecodeAST BasicTypeTag forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DwTag -> DecodeAST DwTag forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DINode -> IO DwTag FFI.getTag (Ptr DIBasicType -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIBasicType diTy)) Word64 size <- IO Word64 -> DecodeAST Word64 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO Word64 FFI.getTypeSizeInBits (Ptr DIBasicType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIBasicType diTy)) Word32 align <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO Word32 FFI.getTypeAlignInBits (Ptr DIBasicType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIBasicType diTy)) ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO (Ptr MDString) FFI.getTypeName (Ptr DIBasicType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIBasicType diTy)) Maybe Encoding encoding <- Encoding -> DecodeAST (Maybe Encoding) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Encoding -> DecodeAST (Maybe Encoding)) -> DecodeAST Encoding -> DecodeAST (Maybe Encoding) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO Encoding -> DecodeAST Encoding forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIBasicType -> IO Encoding FFI.getBasicTypeEncoding Ptr DIBasicType diTy) [DIFlag] flags <- DIFlags -> DecodeAST [DIFlag] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DIFlags -> DecodeAST [DIFlag]) -> DecodeAST DIFlags -> DecodeAST [DIFlag] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DIFlags -> DecodeAST DIFlags forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO DIFlags FFI.getTypeFlags (Ptr DIBasicType -> Ptr DIType forall a b. Ptr a -> Ptr b castPtr Ptr DIBasicType diTy :: Ptr FFI.DIType)) DIBasicType -> DecodeAST DIBasicType forall (f :: * -> *) a. Applicative f => a -> f a pure (ShortByteString -> Word64 -> Word32 -> Maybe Encoding -> BasicTypeTag -> [DIFlag] -> DIBasicType A.BasicType ShortByteString name Word64 size Word32 align Maybe Encoding encoding BasicTypeTag tag [DIFlag] flags) instance EncodeM EncodeAST A.DIBasicType (Ptr FFI.DIBasicType) where encodeM :: DIBasicType -> EncodeAST (Ptr DIBasicType) encodeM A.BasicType {..} = do DwTag tag <- BasicTypeTag -> EncodeAST DwTag forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM BasicTypeTag tag Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Encoding encoding <- Maybe Encoding -> EncodeAST Encoding forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe Encoding encoding DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DIFlag] flags Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DIBasicType) -> EncodeAST (Ptr DIBasicType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> DwTag -> Ptr MDString -> Word64 -> Word32 -> Encoding -> DIFlags -> IO (Ptr DIBasicType) FFI.getDIBasicType Ptr Context c DwTag tag Ptr MDString name Word64 sizeInBits Word32 alignInBits Encoding encoding DIFlags flags) instance EncodeM EncodeAST A.DISubroutineType (Ptr FFI.DISubroutineType) where encodeM :: DISubroutineType -> EncodeAST (Ptr DISubroutineType) encodeM A.SubroutineType {..} = do DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DIFlag] flags TupleArray DIType types <- [Maybe (MDRef DIType)] -> EncodeAST (TupleArray DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [Maybe (MDRef DIType)] typeArray Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DISubroutineType) -> EncodeAST (Ptr DISubroutineType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> DIFlags -> Word8 -> TupleArray DIType -> IO (Ptr DISubroutineType) FFI.getDISubroutineType Ptr Context c DIFlags flags Word8 cc TupleArray DIType types) instance DecodeM DecodeAST A.DISubroutineType (Ptr FFI.DISubroutineType) where decodeM :: Ptr DISubroutineType -> DecodeAST DISubroutineType decodeM p :: Ptr DISubroutineType p = do [DIFlag] flags <- DIFlags -> DecodeAST [DIFlag] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DIFlags -> DecodeAST [DIFlag]) -> DecodeAST DIFlags -> DecodeAST [DIFlag] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DIFlags -> DecodeAST DIFlags forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO DIFlags FFI.getTypeFlags (Ptr DISubroutineType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DISubroutineType p)) Word8 cc <- IO Word8 -> DecodeAST Word8 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubroutineType -> IO Word8 FFI.getSubroutineCC Ptr DISubroutineType p) [Maybe (MDRef DIType)] arr <- TupleArray DIType -> DecodeAST [Maybe (MDRef DIType)] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (TupleArray DIType -> DecodeAST [Maybe (MDRef DIType)]) -> DecodeAST (TupleArray DIType) -> DecodeAST [Maybe (MDRef DIType)] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (TupleArray DIType) -> DecodeAST (TupleArray DIType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubroutineType -> IO (TupleArray DIType) FFI.getSubroutineTypeArray Ptr DISubroutineType p) DISubroutineType -> DecodeAST DISubroutineType forall (f :: * -> *) a. Applicative f => a -> f a pure SubroutineType :: [DIFlag] -> Word8 -> [Maybe (MDRef DIType)] -> DISubroutineType A.SubroutineType { $sel:flags:SubroutineType :: [DIFlag] A.flags = [DIFlag] flags , $sel:cc:SubroutineType :: Word8 A.cc = Word8 cc , $sel:typeArray:SubroutineType :: [Maybe (MDRef DIType)] A.typeArray = [Maybe (MDRef DIType)] arr } instance EncodeM EncodeAST A.DIDerivedType (Ptr FFI.DIDerivedType) where encodeM :: DIDerivedType -> EncodeAST (Ptr DIDerivedType) encodeM A.DerivedType {..} = do DwTag tag <- DerivedTypeTag -> EncodeAST DwTag forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DerivedTypeTag tag Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file CUInt line <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Word32 line Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr DIType type' <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIType) baseType (addrSpace :: Word32 addrSpace, addrSpacePresent :: LLVMBool addrSpacePresent) <- Maybe Word32 -> EncodeAST (Word32, LLVMBool) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe Word32 addressSpace DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DIFlag] flags Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext Ptr DIDerivedType -> Ptr DIDerivedType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIDerivedType -> Ptr DIDerivedType) -> EncodeAST (Ptr DIDerivedType) -> EncodeAST (Ptr DIDerivedType) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr DIDerivedType) -> EncodeAST (Ptr DIDerivedType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> DwTag -> Ptr MDString -> Ptr DIFile -> CUInt -> Ptr DIScope -> Ptr DIType -> Word64 -> Word32 -> Word64 -> Word32 -> LLVMBool -> DIFlags -> IO (Ptr DIDerivedType) FFI.getDIDerivedType Ptr Context c DwTag tag Ptr MDString name Ptr DIFile file CUInt line Ptr DIScope scope Ptr DIType type' Word64 sizeInBits Word32 alignInBits Word64 offsetInBits Word32 addrSpace LLVMBool addrSpacePresent DIFlags flags) instance DecodeM DecodeAST A.DIDerivedType (Ptr FFI.DIDerivedType) where decodeM :: Ptr DIDerivedType -> DecodeAST DIDerivedType decodeM diTy :: Ptr DIDerivedType diTy = do let diTy' :: Ptr DIType diTy' = Ptr DIDerivedType -> Ptr DIType forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIDerivedType diTy ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO (Ptr MDString) FFI.getTypeName Ptr DIType diTy') Maybe (MDRef DIFile) file <- Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile))) -> DecodeAST (Ptr DIFile) -> DecodeAST (Maybe (MDRef DIFile)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIFile) -> DecodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIScope -> IO (Ptr DIFile) FFI.getScopeFile (Ptr DIDerivedType -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIDerivedType diTy)) Maybe (MDRef DIScope) scope <- Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope))) -> DecodeAST (Ptr DIScope) -> DecodeAST (Maybe (MDRef DIScope)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIScope) -> DecodeAST (Ptr DIScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIScope -> IO (Ptr DIScope) FFI.getScopeScope (Ptr DIDerivedType -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIDerivedType diTy)) Maybe (MDRef DIType) ty <- Ptr DIType -> DecodeAST (Maybe (MDRef DIType)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> DecodeAST (Maybe (MDRef DIType))) -> DecodeAST (Ptr DIType) -> DecodeAST (Maybe (MDRef DIType)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIType) -> DecodeAST (Ptr DIType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO (Ptr DIType) FFI.getDerivedBaseType Ptr DIType diTy') Word32 line <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO Word32 FFI.getTypeLine Ptr DIType diTy') Word64 size <- IO Word64 -> DecodeAST Word64 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO Word64 FFI.getTypeSizeInBits Ptr DIType diTy') Word32 align <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO Word32 FFI.getTypeAlignInBits Ptr DIType diTy') Word64 offset <- IO Word64 -> DecodeAST Word64 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO Word64 FFI.getTypeOffsetInBits Ptr DIType diTy') DerivedTypeTag tag <- DwTag -> DecodeAST DerivedTypeTag forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DwTag -> DecodeAST DerivedTypeTag) -> DecodeAST DwTag -> DecodeAST DerivedTypeTag forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DwTag -> DecodeAST DwTag forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DINode -> IO DwTag FFI.getTag (Ptr DIDerivedType -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIDerivedType diTy)) [DIFlag] flags <- DIFlags -> DecodeAST [DIFlag] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DIFlags -> DecodeAST [DIFlag]) -> DecodeAST DIFlags -> DecodeAST [DIFlag] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DIFlags -> DecodeAST DIFlags forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIType -> IO DIFlags FFI.getTypeFlags Ptr DIType diTy') Maybe Word32 addressSpace <- (Ptr CUInt -> IO LLVMBool) -> DecodeAST (Maybe Word32) forall (m :: * -> *) b a. (DecodeM m b a, Storable a, MonadAnyCont IO m, MonadIO m) => (Ptr a -> IO LLVMBool) -> m (Maybe b) decodeOptional (Ptr DIType -> Ptr CUInt -> IO LLVMBool FFI.getDerivedAddressSpace Ptr DIType diTy') DIDerivedType -> DecodeAST DIDerivedType forall (f :: * -> *) a. Applicative f => a -> f a pure DerivedType :: DerivedTypeTag -> ShortByteString -> Maybe (MDRef DIFile) -> Word32 -> Maybe (MDRef DIScope) -> Maybe (MDRef DIType) -> Word64 -> Word32 -> Word64 -> Maybe Word32 -> [DIFlag] -> DIDerivedType A.DerivedType { $sel:tag:DerivedType :: DerivedTypeTag A.tag = DerivedTypeTag tag , $sel:name:DerivedType :: ShortByteString A.name = ShortByteString name , $sel:file:DerivedType :: Maybe (MDRef DIFile) A.file = Maybe (MDRef DIFile) file , $sel:line:DerivedType :: Word32 A.line = Word32 line , $sel:scope:DerivedType :: Maybe (MDRef DIScope) A.scope = Maybe (MDRef DIScope) scope , $sel:baseType:DerivedType :: Maybe (MDRef DIType) A.baseType = Maybe (MDRef DIType) ty , $sel:sizeInBits:DerivedType :: Word64 A.sizeInBits = Word64 size , $sel:alignInBits:DerivedType :: Word32 A.alignInBits = Word32 align , $sel:offsetInBits:DerivedType :: Word64 A.offsetInBits = Word64 offset , $sel:addressSpace:DerivedType :: Maybe Word32 A.addressSpace = Maybe Word32 addressSpace , $sel:flags:DerivedType :: [DIFlag] A.flags = [DIFlag] flags } genCodingInstance [t|A.DerivedTypeTag|] ''FFI.DwTag [ (FFI.DwTag_typedef, A.Typedef) , (FFI.DwTag_pointer_type, A.PointerType) , (FFI.DwTag_ptr_to_member_type, A.PtrToMemberType) , (FFI.DwTag_reference_type, A.ReferenceType) , (FFI.DwTag_rvalue_reference_type, A.RValueReferenceType) , (FFI.DwTag_const_type, A.ConstType) , (FFI.DwTag_volatile_type, A.VolatileType) , (FFI.DwTag_restrict_type, A.RestrictType) , (FFI.DwTag_atomic_type, A.AtomicType) , (FFI.DwTag_member, A.Member) , (FFI.DwTag_inheritance, A.Inheritance) , (FFI.DwTag_friend, A.Friend) ] instance EncodeM EncodeAST A.DIVariable (Ptr FFI.DIVariable) where encodeM :: DIVariable -> EncodeAST (Ptr DIVariable) encodeM (A.DIGlobalVariable v :: DIGlobalVariable v) = do Ptr DIGlobalVariable ptr <- DIGlobalVariable -> EncodeAST (Ptr DIGlobalVariable) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIGlobalVariable v Ptr DIVariable -> EncodeAST (Ptr DIVariable) forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr DIGlobalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIGlobalVariable ptr :: Ptr FFI.DIGlobalVariable)) encodeM (A.DILocalVariable v :: DILocalVariable v) = do Ptr DILocalVariable ptr <- DILocalVariable -> EncodeAST (Ptr DILocalVariable) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DILocalVariable v Ptr DIVariable -> EncodeAST (Ptr DIVariable) forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr DILocalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DILocalVariable ptr :: Ptr FFI.DILocalVariable)) instance DecodeM DecodeAST A.DIVariable (Ptr FFI.DIVariable) where decodeM :: Ptr DIVariable -> DecodeAST DIVariable decodeM p :: Ptr DIVariable p = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO MDSubclassID -> DecodeAST MDSubclassID) -> IO MDSubclassID -> DecodeAST MDSubclassID forall a b. (a -> b) -> a -> b $ Ptr MDNode -> IO MDSubclassID FFI.getMetadataClassId (Ptr DIVariable -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIVariable p) case MDSubclassID sId of [mdSubclassIdP|DIGlobalVariable|] -> DIGlobalVariable -> DIVariable A.DIGlobalVariable (DIGlobalVariable -> DIVariable) -> DecodeAST DIGlobalVariable -> DecodeAST DIVariable forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIGlobalVariable -> DecodeAST DIGlobalVariable forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIVariable -> Ptr DIGlobalVariable forall a b. Ptr a -> Ptr b castPtr Ptr DIVariable p :: Ptr FFI.DIGlobalVariable) [mdSubclassIdP|DILocalVariable|] -> DILocalVariable -> DIVariable A.DILocalVariable (DILocalVariable -> DIVariable) -> DecodeAST DILocalVariable -> DecodeAST DIVariable forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DILocalVariable -> DecodeAST DILocalVariable forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIVariable -> Ptr DILocalVariable forall a b. Ptr a -> Ptr b castPtr Ptr DIVariable p :: Ptr FFI.DILocalVariable) _ -> DecodeException -> DecodeAST DIVariable forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Unknown subclass id for DIVariable: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId)) instance DecodeM DecodeAST A.DIGlobalVariable (Ptr FFI.DIGlobalVariable) where decodeM :: Ptr DIGlobalVariable -> DecodeAST DIGlobalVariable decodeM p :: Ptr DIGlobalVariable p = do ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO (Ptr MDString) FFI.getDIVariableName (Ptr DIGlobalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIGlobalVariable p)) Maybe (MDRef DIScope) scope <- Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope))) -> DecodeAST (Ptr DIScope) -> DecodeAST (Maybe (MDRef DIScope)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIScope) -> DecodeAST (Ptr DIScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO (Ptr DIScope) FFI.getDIVariableScope (Ptr DIGlobalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIGlobalVariable p)) Maybe (MDRef DIFile) file <- Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile))) -> DecodeAST (Ptr DIFile) -> DecodeAST (Maybe (MDRef DIFile)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIFile) -> DecodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO (Ptr DIFile) FFI.getDIVariableFile (Ptr DIGlobalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIGlobalVariable p)) Word32 line <- CUInt -> DecodeAST Word32 forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (CUInt -> DecodeAST Word32) -> DecodeAST CUInt -> DecodeAST Word32 forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO CUInt -> DecodeAST CUInt forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO CUInt FFI.getDIVariableLine (Ptr DIGlobalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIGlobalVariable p)) Maybe (MDRef DIType) type' <- Ptr DIType -> DecodeAST (Maybe (MDRef DIType)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> DecodeAST (Maybe (MDRef DIType))) -> DecodeAST (Ptr DIType) -> DecodeAST (Maybe (MDRef DIType)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIType) -> DecodeAST (Ptr DIType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO (Ptr DIType) FFI.getDIVariableType (Ptr DIGlobalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIGlobalVariable p)) Word32 align <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO Word32 FFI.getDIVariableAlignInBits (Ptr DIGlobalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIGlobalVariable p)) ShortByteString linkageName <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIGlobalVariable -> IO (Ptr MDString) FFI.getDIGlobalVariableLinkageName Ptr DIGlobalVariable p) Bool local <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIGlobalVariable -> IO LLVMBool FFI.getDIGlobalVariableLocal Ptr DIGlobalVariable p) Bool definition <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIGlobalVariable -> IO LLVMBool FFI.getDIGlobalVariableDefinition Ptr DIGlobalVariable p) Maybe (MDRef DIDerivedType) decl <- Ptr DIDerivedType -> DecodeAST (Maybe (MDRef DIDerivedType)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIDerivedType -> DecodeAST (Maybe (MDRef DIDerivedType))) -> DecodeAST (Ptr DIDerivedType) -> DecodeAST (Maybe (MDRef DIDerivedType)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIDerivedType) -> DecodeAST (Ptr DIDerivedType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIGlobalVariable -> IO (Ptr DIDerivedType) FFI.getDIGlobalVariableStaticDataMemberDeclaration Ptr DIGlobalVariable p) DIGlobalVariable -> DecodeAST DIGlobalVariable forall (f :: * -> *) a. Applicative f => a -> f a pure GlobalVariable :: ShortByteString -> Maybe (MDRef DIScope) -> Maybe (MDRef DIFile) -> Word32 -> Maybe (MDRef DIType) -> ShortByteString -> Bool -> Bool -> Maybe (MDRef DIDerivedType) -> [MDRef DITemplateParameter] -> Word32 -> DIGlobalVariable A.GlobalVariable { $sel:name:GlobalVariable :: ShortByteString A.name = ShortByteString name , $sel:scope:GlobalVariable :: Maybe (MDRef DIScope) A.scope = Maybe (MDRef DIScope) scope , $sel:file:GlobalVariable :: Maybe (MDRef DIFile) A.file = Maybe (MDRef DIFile) file , $sel:line:GlobalVariable :: Word32 A.line = Word32 line , $sel:type':GlobalVariable :: Maybe (MDRef DIType) A.type' = Maybe (MDRef DIType) type' , $sel:linkageName:GlobalVariable :: ShortByteString A.linkageName = ShortByteString linkageName , $sel:local:GlobalVariable :: Bool A.local = Bool local , $sel:definition:GlobalVariable :: Bool A.definition = Bool definition , $sel:staticDataMemberDeclaration:GlobalVariable :: Maybe (MDRef DIDerivedType) A.staticDataMemberDeclaration = Maybe (MDRef DIDerivedType) decl , $sel:templateParams:GlobalVariable :: [MDRef DITemplateParameter] A.templateParams = [] , $sel:alignInBits:GlobalVariable :: Word32 A.alignInBits = Word32 align } instance EncodeM EncodeAST A.DIGlobalVariable (Ptr FFI.DIGlobalVariable) where encodeM :: DIGlobalVariable -> EncodeAST (Ptr DIGlobalVariable) encodeM A.GlobalVariable {..} = do Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file CUInt line <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Word32 line Ptr DIType type' <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIType) type' Ptr MDString linkageName <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString linkageName LLVMBool local <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Bool local LLVMBool definition <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Bool definition Ptr DIDerivedType dataMemberDeclaration <- Maybe (MDRef DIDerivedType) -> EncodeAST (Ptr DIDerivedType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIDerivedType) staticDataMemberDeclaration TupleArray DITemplateParameter templateParams <- [MDRef DITemplateParameter] -> EncodeAST (TupleArray DITemplateParameter) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [MDRef DITemplateParameter] templateParams Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DIGlobalVariable) -> EncodeAST (Ptr DIGlobalVariable) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIScope -> Ptr MDString -> Ptr MDString -> Ptr DIFile -> CUInt -> Ptr DIType -> LLVMBool -> LLVMBool -> Ptr DIDerivedType -> TupleArray DITemplateParameter -> Word32 -> IO (Ptr DIGlobalVariable) FFI.getDIGlobalVariable Ptr Context c Ptr DIScope scope Ptr MDString name Ptr MDString linkageName Ptr DIFile file CUInt line Ptr DIType type' LLVMBool local LLVMBool definition Ptr DIDerivedType dataMemberDeclaration TupleArray DITemplateParameter templateParams Word32 alignInBits) instance DecodeM DecodeAST A.DILocalVariable (Ptr FFI.DILocalVariable) where decodeM :: Ptr DILocalVariable -> DecodeAST DILocalVariable decodeM p :: Ptr DILocalVariable p = do ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO (Ptr MDString) FFI.getDIVariableName (Ptr DILocalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DILocalVariable p)) MDRef DIScope scope <- Ptr DIScope -> DecodeAST (MDRef DIScope) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> DecodeAST (MDRef DIScope)) -> DecodeAST (Ptr DIScope) -> DecodeAST (MDRef DIScope) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIScope) -> DecodeAST (Ptr DIScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO (Ptr DIScope) FFI.getDIVariableScope (Ptr DILocalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DILocalVariable p)) Maybe (MDRef DIFile) file <- Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile))) -> DecodeAST (Ptr DIFile) -> DecodeAST (Maybe (MDRef DIFile)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIFile) -> DecodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO (Ptr DIFile) FFI.getDIVariableFile (Ptr DILocalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DILocalVariable p)) Word32 line <- CUInt -> DecodeAST Word32 forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (CUInt -> DecodeAST Word32) -> DecodeAST CUInt -> DecodeAST Word32 forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO CUInt -> DecodeAST CUInt forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO CUInt FFI.getDIVariableLine (Ptr DILocalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DILocalVariable p)) Maybe (MDRef DIType) type' <- Ptr DIType -> DecodeAST (Maybe (MDRef DIType)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> DecodeAST (Maybe (MDRef DIType))) -> DecodeAST (Ptr DIType) -> DecodeAST (Maybe (MDRef DIType)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIType) -> DecodeAST (Ptr DIType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO (Ptr DIType) FFI.getDIVariableType (Ptr DILocalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DILocalVariable p)) Word32 align <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIVariable -> IO Word32 FFI.getDIVariableAlignInBits (Ptr DILocalVariable -> Ptr DIVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DILocalVariable p)) Word16 arg <- IO Word16 -> DecodeAST Word16 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILocalVariable -> IO Word16 FFI.getDILocalVariableArg Ptr DILocalVariable p) [DIFlag] flags <- DIFlags -> DecodeAST [DIFlag] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DIFlags -> DecodeAST [DIFlag]) -> DecodeAST DIFlags -> DecodeAST [DIFlag] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DIFlags -> DecodeAST DIFlags forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILocalVariable -> IO DIFlags FFI.getDILocalVariableFlags Ptr DILocalVariable p) DILocalVariable -> DecodeAST DILocalVariable forall (f :: * -> *) a. Applicative f => a -> f a pure LocalVariable :: ShortByteString -> MDRef DIScope -> Maybe (MDRef DIFile) -> Word32 -> Maybe (MDRef DIType) -> [DIFlag] -> Word16 -> Word32 -> DILocalVariable A.LocalVariable { $sel:file:LocalVariable :: Maybe (MDRef DIFile) A.file = Maybe (MDRef DIFile) file , $sel:scope:LocalVariable :: MDRef DIScope A.scope = MDRef DIScope scope , $sel:name:LocalVariable :: ShortByteString A.name = ShortByteString name , $sel:line:LocalVariable :: Word32 A.line = Word32 line , $sel:arg:LocalVariable :: Word16 A.arg = Word16 arg , $sel:flags:LocalVariable :: [DIFlag] A.flags = [DIFlag] flags , $sel:type':LocalVariable :: Maybe (MDRef DIType) A.type' = Maybe (MDRef DIType) type' , $sel:alignInBits:LocalVariable :: Word32 A.alignInBits = Word32 align } instance EncodeM EncodeAST A.DILocalVariable (Ptr FFI.DILocalVariable) where encodeM :: DILocalVariable -> EncodeAST (Ptr DILocalVariable) encodeM A.LocalVariable {..} = do CString name <- ShortByteString -> EncodeAST CString forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr DIScope scope <- MDRef DIScope -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM MDRef DIScope scope Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file Ptr DIType type' <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIType) type' DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DIFlag] flags Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext Ptr DILocalVariable -> Ptr DILocalVariable forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DILocalVariable -> Ptr DILocalVariable) -> EncodeAST (Ptr DILocalVariable) -> EncodeAST (Ptr DILocalVariable) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr DILocalVariable) -> EncodeAST (Ptr DILocalVariable) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIScope -> CString -> Ptr DIFile -> Word32 -> Ptr DIType -> Word16 -> DIFlags -> Word32 -> IO (Ptr DILocalVariable) FFI.getDILocalVariable Ptr Context c Ptr DIScope scope CString name Ptr DIFile file Word32 line Ptr DIType type' Word16 arg DIFlags flags Word32 alignInBits) genCodingInstance [t|A.TemplateValueParameterTag|] ''FFI.DwTag [ (FFI.DwTag_template_value_parameter, A.TemplateValueParameter) , (FFI.DwTag_GNU_template_template_param, A.GNUTemplateTemplateParam) , (FFI.DwTag_GNU_template_parameter_pack, A.GNUTemplateParameterPack) ] instance EncodeM EncodeAST A.DITemplateParameter (Ptr FFI.DITemplateParameter) where encodeM :: DITemplateParameter -> EncodeAST (Ptr DITemplateParameter) encodeM p :: DITemplateParameter p = do Ptr MDString name' <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM (DITemplateParameter -> ShortByteString A.name (DITemplateParameter p :: A.DITemplateParameter)) :: EncodeAST (Ptr FFI.MDString) Ptr DIType ty <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM (DITemplateParameter -> Maybe (MDRef DIType) A.type' (DITemplateParameter p :: A.DITemplateParameter)) Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext case DITemplateParameter p of A.DITemplateTypeParameter {} -> Ptr DITemplateTypeParameter -> Ptr DITemplateParameter forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DITemplateTypeParameter -> Ptr DITemplateParameter) -> EncodeAST (Ptr DITemplateTypeParameter) -> EncodeAST (Ptr DITemplateParameter) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr DITemplateTypeParameter) -> EncodeAST (Ptr DITemplateTypeParameter) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr MDString -> Ptr DIType -> IO (Ptr DITemplateTypeParameter) FFI.getDITemplateTypeParameter Ptr Context c Ptr MDString name' Ptr DIType ty) A.DITemplateValueParameter {..} -> do DwTag tag <- TemplateValueParameterTag -> EncodeAST DwTag forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM TemplateValueParameterTag tag Ptr Metadata value <- Maybe Metadata -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe Metadata value Ptr DITemplateValueParameter -> Ptr DITemplateParameter forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DITemplateValueParameter -> Ptr DITemplateParameter) -> EncodeAST (Ptr DITemplateValueParameter) -> EncodeAST (Ptr DITemplateParameter) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr DITemplateValueParameter) -> EncodeAST (Ptr DITemplateValueParameter) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr MDString -> Ptr DIType -> DwTag -> Ptr Metadata -> IO (Ptr DITemplateValueParameter) FFI.getDITemplateValueParameter Ptr Context c Ptr MDString name' Ptr DIType ty DwTag tag Ptr Metadata value) instance DecodeM DecodeAST A.DITemplateParameter (Ptr FFI.DITemplateParameter) where decodeM :: Ptr DITemplateParameter -> DecodeAST DITemplateParameter decodeM p :: Ptr DITemplateParameter p = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr MDNode -> IO MDSubclassID FFI.getMetadataClassId (Ptr DITemplateParameter -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DITemplateParameter p)) ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DITemplateParameter -> IO (Ptr MDString) FFI.getDITemplateParameterName Ptr DITemplateParameter p) Maybe (MDRef DIType) ty <- Ptr DIType -> DecodeAST (Maybe (MDRef DIType)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> DecodeAST (Maybe (MDRef DIType))) -> DecodeAST (Ptr DIType) -> DecodeAST (Maybe (MDRef DIType)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIType) -> DecodeAST (Ptr DIType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DITemplateParameter -> IO (Ptr DIType) FFI.getDITemplateParameterType Ptr DITemplateParameter p) case MDSubclassID sId of [mdSubclassIdP|DITemplateTypeParameter|] -> DITemplateParameter -> DecodeAST DITemplateParameter forall (f :: * -> *) a. Applicative f => a -> f a pure (ShortByteString -> Maybe (MDRef DIType) -> DITemplateParameter A.DITemplateTypeParameter ShortByteString name Maybe (MDRef DIType) ty) [mdSubclassIdP|DITemplateValueParameter|] -> do Maybe Metadata value <- Ptr Metadata -> DecodeAST (Maybe Metadata) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr Metadata -> DecodeAST (Maybe Metadata)) -> DecodeAST (Ptr Metadata) -> DecodeAST (Maybe Metadata) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr Metadata) -> DecodeAST (Ptr Metadata) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DITemplateValueParameter -> IO (Ptr Metadata) FFI.getDITemplateValueParameterValue (Ptr DITemplateParameter -> Ptr DITemplateValueParameter forall a b. Ptr a -> Ptr b castPtr Ptr DITemplateParameter p)) TemplateValueParameterTag tag <- DwTag -> DecodeAST TemplateValueParameterTag forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DwTag -> DecodeAST TemplateValueParameterTag) -> DecodeAST DwTag -> DecodeAST TemplateValueParameterTag forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DwTag -> DecodeAST DwTag forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DINode -> IO DwTag FFI.getTag (Ptr DITemplateParameter -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DITemplateParameter p)) DITemplateParameter -> DecodeAST DITemplateParameter forall (f :: * -> *) a. Applicative f => a -> f a pure (ShortByteString -> Maybe (MDRef DIType) -> Maybe Metadata -> TemplateValueParameterTag -> DITemplateParameter A.DITemplateValueParameter ShortByteString name Maybe (MDRef DIType) ty Maybe Metadata value TemplateValueParameterTag tag) _ -> DecodeException -> DecodeAST DITemplateParameter forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Unknown subclass id for DITemplateParameter: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId)) genCodingInstance [t|A.Virtuality|] ''FFI.DwVirtuality [ (FFI.DwVirtuality_none, A.NoVirtuality) , (FFI.DwVirtuality_virtual, A.Virtual) , (FFI.DwVirtuality_pure_virtual, A.PureVirtual) ] instance DecodeM DecodeAST A.DISubprogram (Ptr FFI.DISubprogram) where decodeM :: Ptr DISubprogram -> DecodeAST DISubprogram decodeM p :: Ptr DISubprogram p = do ShortByteString name <- (Ptr DIScope -> Ptr CUInt -> IO CString) -> Ptr DIScope -> DecodeAST ShortByteString forall a. (Ptr a -> Ptr CUInt -> IO CString) -> Ptr a -> DecodeAST ShortByteString getByteStringFromFFI Ptr DIScope -> Ptr CUInt -> IO CString FFI.getScopeName (Ptr DISubprogram -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DISubprogram p) ShortByteString linkageName <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO (Ptr MDString) FFI.getDISubprogramLinkageName Ptr DISubprogram p) Maybe (MDRef DIFile) file <- Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile))) -> DecodeAST (Ptr DIFile) -> DecodeAST (Maybe (MDRef DIFile)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIFile) -> DecodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIScope -> IO (Ptr DIFile) FFI.getScopeFile (Ptr DISubprogram -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DISubprogram p)) Maybe (MDRef DIScope) scope <- Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope))) -> DecodeAST (Ptr DIScope) -> DecodeAST (Maybe (MDRef DIScope)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIScope) -> DecodeAST (Ptr DIScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIScope -> IO (Ptr DIScope) FFI.getScopeScope (Ptr DISubprogram -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DISubprogram p)) Word32 line <- CUInt -> DecodeAST Word32 forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (CUInt -> DecodeAST Word32) -> DecodeAST CUInt -> DecodeAST Word32 forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO CUInt -> DecodeAST CUInt forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO CUInt FFI.getDISubprogramLine Ptr DISubprogram p) Virtuality virtuality <- DwVirtuality -> DecodeAST Virtuality forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DwVirtuality -> DecodeAST Virtuality) -> DecodeAST DwVirtuality -> DecodeAST Virtuality forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DwVirtuality -> DecodeAST DwVirtuality forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO DwVirtuality FFI.getDISubprogramVirtuality Ptr DISubprogram p) Word32 virtualIndex <- CUInt -> DecodeAST Word32 forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (CUInt -> DecodeAST Word32) -> DecodeAST CUInt -> DecodeAST Word32 forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO CUInt -> DecodeAST CUInt forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO CUInt FFI.getDISubprogramVirtualIndex Ptr DISubprogram p) Word32 scopeLine <- CUInt -> DecodeAST Word32 forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (CUInt -> DecodeAST Word32) -> DecodeAST CUInt -> DecodeAST Word32 forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO CUInt -> DecodeAST CUInt forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO CUInt FFI.getDISubprogramScopeLine Ptr DISubprogram p) Bool optimized <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO LLVMBool FFI.getDISubprogramIsOptimized Ptr DISubprogram p) Bool definition <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO LLVMBool FFI.getDISubprogramIsDefinition Ptr DISubprogram p) Bool localToUnit <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (LLVMBool -> DecodeAST Bool) -> DecodeAST LLVMBool -> DecodeAST Bool forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO LLVMBool -> DecodeAST LLVMBool forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO LLVMBool FFI.getDISubprogramLocalToUnit Ptr DISubprogram p) Int32 thisAdjustment <- IO Int32 -> DecodeAST Int32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO Int32 FFI.getDISubprogramThisAdjustment Ptr DISubprogram p) [DIFlag] flags <- DIFlags -> DecodeAST [DIFlag] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DIFlags -> DecodeAST [DIFlag]) -> DecodeAST DIFlags -> DecodeAST [DIFlag] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DIFlags -> DecodeAST DIFlags forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO DIFlags FFI.getDISubprogramFlags Ptr DISubprogram p) Maybe (MDRef DISubroutineType) type' <- Ptr DISubroutineType -> DecodeAST (Maybe (MDRef DISubroutineType)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DISubroutineType -> DecodeAST (Maybe (MDRef DISubroutineType))) -> DecodeAST (Ptr DISubroutineType) -> DecodeAST (Maybe (MDRef DISubroutineType)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DISubroutineType) -> DecodeAST (Ptr DISubroutineType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO (Ptr DISubroutineType) FFI.getDISubprogramType Ptr DISubprogram p) Maybe (MDRef DIType) containingType <- Ptr DIType -> DecodeAST (Maybe (MDRef DIType)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> DecodeAST (Maybe (MDRef DIType))) -> DecodeAST (Ptr DIType) -> DecodeAST (Maybe (MDRef DIType)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIType) -> DecodeAST (Ptr DIType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO (Ptr DIType) FFI.getDISubprogramContainingType Ptr DISubprogram p) Maybe (MDRef DICompileUnit) unit <- Ptr DICompileUnit -> DecodeAST (Maybe (MDRef DICompileUnit)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DICompileUnit -> DecodeAST (Maybe (MDRef DICompileUnit))) -> DecodeAST (Ptr DICompileUnit) -> DecodeAST (Maybe (MDRef DICompileUnit)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DICompileUnit) -> DecodeAST (Ptr DICompileUnit) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO (Ptr DICompileUnit) FFI.getDISubprogramUnit Ptr DISubprogram p) [MDRef DITemplateParameter] templateParams <- TupleArray DITemplateParameter -> DecodeAST [MDRef DITemplateParameter] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (TupleArray DITemplateParameter -> DecodeAST [MDRef DITemplateParameter]) -> DecodeAST (TupleArray DITemplateParameter) -> DecodeAST [MDRef DITemplateParameter] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (TupleArray DITemplateParameter) -> DecodeAST (TupleArray DITemplateParameter) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO (TupleArray DITemplateParameter) FFI.getDISubprogramTemplateParams Ptr DISubprogram p) [MDRef DILocalVariable] retainedNodes <- TupleArray DILocalVariable -> DecodeAST [MDRef DILocalVariable] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (TupleArray DILocalVariable -> DecodeAST [MDRef DILocalVariable]) -> DecodeAST (TupleArray DILocalVariable) -> DecodeAST [MDRef DILocalVariable] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (TupleArray DILocalVariable) -> DecodeAST (TupleArray DILocalVariable) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO (TupleArray DILocalVariable) FFI.getDISubprogramRetainedNodes Ptr DISubprogram p) [MDRef DIType] thrownTypes <- TupleArray DIType -> DecodeAST [MDRef DIType] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (TupleArray DIType -> DecodeAST [MDRef DIType]) -> DecodeAST (TupleArray DIType) -> DecodeAST [MDRef DIType] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (TupleArray DIType) -> DecodeAST (TupleArray DIType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO (TupleArray DIType) FFI.getDISubprogramThrownTypes Ptr DISubprogram p) Maybe (MDRef DISubprogram) decl <- Ptr DISubprogram -> DecodeAST (Maybe (MDRef DISubprogram)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DISubprogram -> DecodeAST (Maybe (MDRef DISubprogram))) -> DecodeAST (Ptr DISubprogram) -> DecodeAST (Maybe (MDRef DISubprogram)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DISubprogram) -> DecodeAST (Ptr DISubprogram) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO (Ptr DISubprogram) FFI.getDISubprogramDeclaration Ptr DISubprogram p) DISubprogram -> DecodeAST DISubprogram forall (f :: * -> *) a. Applicative f => a -> f a pure Subprogram :: Maybe (MDRef DIScope) -> ShortByteString -> ShortByteString -> Maybe (MDRef DIFile) -> Word32 -> Maybe (MDRef DISubroutineType) -> Bool -> Bool -> Word32 -> Maybe (MDRef DIType) -> Virtuality -> Word32 -> Int32 -> [DIFlag] -> Bool -> Maybe (MDRef DICompileUnit) -> [MDRef DITemplateParameter] -> Maybe (MDRef DISubprogram) -> [MDRef DILocalVariable] -> [MDRef DIType] -> DISubprogram A.Subprogram { $sel:name:Subprogram :: ShortByteString A.name = ShortByteString name , $sel:linkageName:Subprogram :: ShortByteString A.linkageName = ShortByteString linkageName , $sel:scope:Subprogram :: Maybe (MDRef DIScope) A.scope = Maybe (MDRef DIScope) scope , $sel:file:Subprogram :: Maybe (MDRef DIFile) A.file = Maybe (MDRef DIFile) file , $sel:line:Subprogram :: Word32 A.line = Word32 line , $sel:type':Subprogram :: Maybe (MDRef DISubroutineType) A.type' = Maybe (MDRef DISubroutineType) type' , $sel:definition:Subprogram :: Bool A.definition = Bool definition , $sel:scopeLine:Subprogram :: Word32 A.scopeLine = Word32 scopeLine , $sel:containingType:Subprogram :: Maybe (MDRef DIType) A.containingType = Maybe (MDRef DIType) containingType , $sel:virtuality:Subprogram :: Virtuality A.virtuality = Virtuality virtuality , $sel:virtualityIndex:Subprogram :: Word32 A.virtualityIndex = Word32 virtualIndex , $sel:flags:Subprogram :: [DIFlag] A.flags = [DIFlag] flags , $sel:optimized:Subprogram :: Bool A.optimized = Bool optimized , $sel:unit:Subprogram :: Maybe (MDRef DICompileUnit) A.unit = Maybe (MDRef DICompileUnit) unit , $sel:templateParams:Subprogram :: [MDRef DITemplateParameter] A.templateParams = [MDRef DITemplateParameter] templateParams , $sel:declaration:Subprogram :: Maybe (MDRef DISubprogram) A.declaration = Maybe (MDRef DISubprogram) decl , $sel:retainedNodes:Subprogram :: [MDRef DILocalVariable] A.retainedNodes = [MDRef DILocalVariable] retainedNodes , $sel:thrownTypes:Subprogram :: [MDRef DIType] A.thrownTypes = [MDRef DIType] thrownTypes , $sel:localToUnit:Subprogram :: Bool A.localToUnit = Bool localToUnit , $sel:thisAdjustment:Subprogram :: Int32 A.thisAdjustment = Int32 thisAdjustment } instance EncodeM EncodeAST A.DISubprogram (Ptr FFI.DISubprogram) where encodeM :: DISubprogram -> EncodeAST (Ptr DISubprogram) encodeM A.Subprogram {..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr MDString linkageName <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString linkageName Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file CUInt line <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Word32 line Ptr DISubroutineType type' <- Maybe (MDRef DISubroutineType) -> EncodeAST (Ptr DISubroutineType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DISubroutineType) type' LLVMBool localToUnit <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Bool localToUnit LLVMBool definition <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Bool definition CUInt scopeLine <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Word32 scopeLine Ptr DIType containingType <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIType) containingType DwVirtuality virtuality <- Virtuality -> EncodeAST DwVirtuality forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Virtuality virtuality CUInt virtualityIndex <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Word32 virtualityIndex DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [DIFlag] flags LLVMBool optimized <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Bool optimized Ptr DICompileUnit unit <- Maybe (MDRef DICompileUnit) -> EncodeAST (Ptr DICompileUnit) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DICompileUnit) unit TupleArray DITemplateParameter templateParams <- [MDRef DITemplateParameter] -> EncodeAST (TupleArray DITemplateParameter) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [MDRef DITemplateParameter] templateParams Ptr DISubprogram declaration <- Maybe (MDRef DISubprogram) -> EncodeAST (Ptr DISubprogram) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DISubprogram) declaration TupleArray DILocalVariable retainedNodes <- [MDRef DILocalVariable] -> EncodeAST (TupleArray DILocalVariable) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [MDRef DILocalVariable] retainedNodes TupleArray DIType thrownTypes <- [MDRef DIType] -> EncodeAST (TupleArray DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [MDRef DIType] thrownTypes Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext Ptr DISubprogram -> Ptr DISubprogram forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DISubprogram -> Ptr DISubprogram) -> EncodeAST (Ptr DISubprogram) -> EncodeAST (Ptr DISubprogram) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr DISubprogram) -> EncodeAST (Ptr DISubprogram) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIScope -> Ptr MDString -> Ptr MDString -> Ptr DIFile -> CUInt -> Ptr DISubroutineType -> LLVMBool -> LLVMBool -> CUInt -> Ptr DIType -> DwVirtuality -> CUInt -> Int32 -> DIFlags -> LLVMBool -> Ptr DICompileUnit -> TupleArray DITemplateParameter -> Ptr DISubprogram -> TupleArray DILocalVariable -> TupleArray DIType -> IO (Ptr DISubprogram) FFI.getDISubprogram Ptr Context c Ptr DIScope scope Ptr MDString name Ptr MDString linkageName Ptr DIFile file CUInt line Ptr DISubroutineType type' LLVMBool localToUnit LLVMBool definition CUInt scopeLine Ptr DIType containingType DwVirtuality virtuality CUInt virtualityIndex Int32 thisAdjustment DIFlags flags LLVMBool optimized Ptr DICompileUnit unit TupleArray DITemplateParameter templateParams Ptr DISubprogram declaration TupleArray DILocalVariable retainedNodes TupleArray DIType thrownTypes) instance DecodeM DecodeAST A.DILocalScope (Ptr FFI.DILocalScope) where decodeM :: Ptr DILocalScope -> DecodeAST DILocalScope decodeM ls :: Ptr DILocalScope ls = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO MDSubclassID -> DecodeAST MDSubclassID) -> IO MDSubclassID -> DecodeAST MDSubclassID forall a b. (a -> b) -> a -> b $ Ptr MDNode -> IO MDSubclassID FFI.getMetadataClassId (Ptr DILocalScope -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DILocalScope ls) case MDSubclassID sId of [mdSubclassIdP|DISubprogram|] -> DISubprogram -> DILocalScope A.DISubprogram (DISubprogram -> DILocalScope) -> DecodeAST DISubprogram -> DecodeAST DILocalScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DISubprogram -> DecodeAST DISubprogram forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DILocalScope -> Ptr DISubprogram forall a b. Ptr a -> Ptr b castPtr Ptr DILocalScope ls :: Ptr FFI.DISubprogram) [mdSubclassIdP|DILexicalBlock|] -> DILexicalBlockBase -> DILocalScope A.DILexicalBlockBase (DILexicalBlockBase -> DILocalScope) -> DecodeAST DILexicalBlockBase -> DecodeAST DILocalScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DILexicalBlockBase -> DecodeAST DILexicalBlockBase forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DILocalScope -> Ptr DILexicalBlockBase forall a b. Ptr a -> Ptr b castPtr Ptr DILocalScope ls :: Ptr FFI.DILexicalBlockBase) [mdSubclassIdP|DILexicalBlockFile|] -> DILexicalBlockBase -> DILocalScope A.DILexicalBlockBase (DILexicalBlockBase -> DILocalScope) -> DecodeAST DILexicalBlockBase -> DecodeAST DILocalScope forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DILexicalBlockBase -> DecodeAST DILexicalBlockBase forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DILocalScope -> Ptr DILexicalBlockBase forall a b. Ptr a -> Ptr b castPtr Ptr DILocalScope ls :: Ptr FFI.DILexicalBlockBase) _ -> DecodeException -> DecodeAST DILocalScope forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Unknown subclass id for DILocalScope: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId)) instance EncodeM EncodeAST A.DILocalScope (Ptr FFI.DILocalScope) where encodeM :: DILocalScope -> EncodeAST (Ptr DILocalScope) encodeM (A.DISubprogram sp :: DISubprogram sp) = do Ptr DISubprogram ptr <- DISubprogram -> EncodeAST (Ptr DISubprogram) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DISubprogram sp Ptr DILocalScope -> EncodeAST (Ptr DILocalScope) forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr DISubprogram -> Ptr DILocalScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DISubprogram ptr :: Ptr FFI.DISubprogram)) encodeM (A.DILexicalBlockBase b :: DILexicalBlockBase b) = do Ptr DILexicalBlockBase ptr <- DILexicalBlockBase -> EncodeAST (Ptr DILexicalBlockBase) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DILexicalBlockBase b Ptr DILocalScope -> EncodeAST (Ptr DILocalScope) forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr DILexicalBlockBase -> Ptr DILocalScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DILexicalBlockBase ptr :: Ptr FFI.DILexicalBlockBase)) instance DecodeM DecodeAST A.DILexicalBlockBase (Ptr FFI.DILexicalBlockBase) where decodeM :: Ptr DILexicalBlockBase -> DecodeAST DILexicalBlockBase decodeM p :: Ptr DILexicalBlockBase p = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr MDNode -> IO MDSubclassID FFI.getMetadataClassId (Ptr DILexicalBlockBase -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DILexicalBlockBase p)) case MDSubclassID sId of [mdSubclassIdP|DILexicalBlock|] -> do MDRef DILocalScope scope <- Ptr DILocalScope -> DecodeAST (MDRef DILocalScope) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DILocalScope -> DecodeAST (MDRef DILocalScope)) -> DecodeAST (Ptr DILocalScope) -> DecodeAST (MDRef DILocalScope) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DILocalScope) -> DecodeAST (Ptr DILocalScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILexicalBlockBase -> IO (Ptr DILocalScope) FFI.getLexicalBlockScope Ptr DILexicalBlockBase p) Maybe (MDRef DIFile) file <- Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile))) -> DecodeAST (Ptr DIFile) -> DecodeAST (Maybe (MDRef DIFile)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIFile) -> DecodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIScope -> IO (Ptr DIFile) FFI.getScopeFile (Ptr DILexicalBlockBase -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DILexicalBlockBase p)) Word32 line <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILexicalBlockBase -> IO Word32 FFI.getLexicalBlockLine Ptr DILexicalBlockBase p) Word16 col <- IO Word16 -> DecodeAST Word16 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILexicalBlockBase -> IO Word16 FFI.getLexicalBlockColumn Ptr DILexicalBlockBase p) DILexicalBlockBase -> DecodeAST DILexicalBlockBase forall (f :: * -> *) a. Applicative f => a -> f a pure (MDRef DILocalScope -> Maybe (MDRef DIFile) -> Word32 -> Word16 -> DILexicalBlockBase A.DILexicalBlock MDRef DILocalScope scope Maybe (MDRef DIFile) file Word32 line Word16 col) [mdSubclassIdP|DILexicalBlockFile|] -> do MDRef DILocalScope scope <- Ptr DILocalScope -> DecodeAST (MDRef DILocalScope) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DILocalScope -> DecodeAST (MDRef DILocalScope)) -> DecodeAST (Ptr DILocalScope) -> DecodeAST (MDRef DILocalScope) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DILocalScope) -> DecodeAST (Ptr DILocalScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILexicalBlockBase -> IO (Ptr DILocalScope) FFI.getLexicalBlockScope Ptr DILexicalBlockBase p) Maybe (MDRef DIFile) file <- Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile))) -> DecodeAST (Ptr DIFile) -> DecodeAST (Maybe (MDRef DIFile)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIFile) -> DecodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIScope -> IO (Ptr DIFile) FFI.getScopeFile (Ptr DILexicalBlockBase -> Ptr DIScope forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DILexicalBlockBase p)) Word32 disc <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILexicalBlockBase -> IO Word32 FFI.getLexicalBlockFileDiscriminator Ptr DILexicalBlockBase p) DILexicalBlockBase -> DecodeAST DILexicalBlockBase forall (f :: * -> *) a. Applicative f => a -> f a pure (MDRef DILocalScope -> Maybe (MDRef DIFile) -> Word32 -> DILexicalBlockBase A.DILexicalBlockFile MDRef DILocalScope scope Maybe (MDRef DIFile) file Word32 disc) _ -> DecodeException -> DecodeAST DILexicalBlockBase forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Unknown subclass id for DILexicalBlockBase: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId)) instance EncodeM EncodeAST A.DILexicalBlockBase (Ptr FFI.DILexicalBlockBase) where encodeM :: DILexicalBlockBase -> EncodeAST (Ptr DILexicalBlockBase) encodeM A.DILexicalBlock {..} = do Ptr DILocalScope scope <- MDRef DILocalScope -> EncodeAST (Ptr DILocalScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM MDRef DILocalScope scope Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext Ptr DILexicalBlock -> Ptr DILexicalBlockBase forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DILexicalBlock -> Ptr DILexicalBlockBase) -> EncodeAST (Ptr DILexicalBlock) -> EncodeAST (Ptr DILexicalBlockBase) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr DILexicalBlock) -> EncodeAST (Ptr DILexicalBlock) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DILocalScope -> Ptr DIFile -> Word32 -> Word16 -> IO (Ptr DILexicalBlock) FFI.getDILexicalBlock Ptr Context c Ptr DILocalScope scope Ptr DIFile file Word32 line Word16 column) encodeM A.DILexicalBlockFile {..} = do Ptr DILocalScope scope <- MDRef DILocalScope -> EncodeAST (Ptr DILocalScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM MDRef DILocalScope scope Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext Ptr DILexicalBlockFile -> Ptr DILexicalBlockBase forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DILexicalBlockFile -> Ptr DILexicalBlockBase) -> EncodeAST (Ptr DILexicalBlockFile) -> EncodeAST (Ptr DILexicalBlockBase) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr DILexicalBlockFile) -> EncodeAST (Ptr DILexicalBlockFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DILocalScope -> Ptr DIFile -> Word32 -> IO (Ptr DILexicalBlockFile) FFI.getDILexicalBlockFile Ptr Context c Ptr DILocalScope scope Ptr DIFile file Word32 discriminator) instance DecodeM DecodeAST A.CallableOperand (Ptr FFI.Value) where decodeM :: Ptr Value -> DecodeAST CallableOperand decodeM v :: Ptr Value v = do Ptr InlineAsm ia <- IO (Ptr InlineAsm) -> DecodeAST (Ptr InlineAsm) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr InlineAsm) -> DecodeAST (Ptr InlineAsm)) -> IO (Ptr InlineAsm) -> DecodeAST (Ptr InlineAsm) forall a b. (a -> b) -> a -> b $ Ptr Value -> IO (Ptr InlineAsm) FFI.isAInlineAsm Ptr Value v if Ptr InlineAsm ia Ptr InlineAsm -> Ptr InlineAsm -> Bool forall a. Eq a => a -> a -> Bool /= Ptr InlineAsm forall a. Ptr a nullPtr then InlineAssembly -> CallableOperand forall a b. a -> Either a b Left (InlineAssembly -> CallableOperand) -> DecodeAST InlineAssembly -> DecodeAST CallableOperand forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr InlineAsm -> DecodeAST InlineAssembly forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM Ptr InlineAsm ia else Operand -> CallableOperand forall a b. b -> Either a b Right (Operand -> CallableOperand) -> DecodeAST Operand -> DecodeAST CallableOperand forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr Value -> DecodeAST Operand forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM Ptr Value v instance EncodeM EncodeAST A.Operand (Ptr FFI.Value) where encodeM :: Operand -> EncodeAST (Ptr Value) encodeM (A.ConstantOperand c :: Constant c) = (Ptr Constant -> Ptr Value forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast :: Ptr FFI.Constant -> Ptr FFI.Value) (Ptr Constant -> Ptr Value) -> EncodeAST (Ptr Constant) -> EncodeAST (Ptr Value) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Constant -> EncodeAST (Ptr Constant) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Constant c encodeM (A.LocalReference t :: Type t n :: Name n) = do LocalValue lv <- (EncodeState -> Map Name LocalValue) -> Name -> EncodeAST LocalValue -> EncodeAST LocalValue forall n v. (Show n, Ord n) => (EncodeState -> Map n v) -> n -> EncodeAST v -> EncodeAST v refer EncodeState -> Map Name LocalValue encodeStateLocals Name n (EncodeAST LocalValue -> EncodeAST LocalValue) -> EncodeAST LocalValue -> EncodeAST LocalValue forall a b. (a -> b) -> a -> b $ do LocalValue lv <- do CString n <- Name -> EncodeAST CString forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Name n Ptr Type t <- Type -> EncodeAST (Ptr Type) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Type t Ptr Value v <- IO (Ptr Value) -> EncodeAST (Ptr Value) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr Value) -> EncodeAST (Ptr Value)) -> IO (Ptr Value) -> EncodeAST (Ptr Value) forall a b. (a -> b) -> a -> b $ Ptr Type -> CString -> IO (Ptr Value) FFI.createArgument Ptr Type t CString n LocalValue -> EncodeAST LocalValue forall (m :: * -> *) a. Monad m => a -> m a return (LocalValue -> EncodeAST LocalValue) -> LocalValue -> EncodeAST LocalValue forall a b. (a -> b) -> a -> b $ Ptr Value -> LocalValue ForwardValue Ptr Value v (EncodeState -> EncodeState) -> EncodeAST () forall s (m :: * -> *). MonadState s m => (s -> s) -> m () modify ((EncodeState -> EncodeState) -> EncodeAST ()) -> (EncodeState -> EncodeState) -> EncodeAST () forall a b. (a -> b) -> a -> b $ \s :: EncodeState s -> EncodeState s { encodeStateLocals :: Map Name LocalValue encodeStateLocals = Name -> LocalValue -> Map Name LocalValue -> Map Name LocalValue forall k a. Ord k => k -> a -> Map k a -> Map k a Map.insert Name n LocalValue lv (Map Name LocalValue -> Map Name LocalValue) -> Map Name LocalValue -> Map Name LocalValue forall a b. (a -> b) -> a -> b $ EncodeState -> Map Name LocalValue encodeStateLocals EncodeState s } LocalValue -> EncodeAST LocalValue forall (m :: * -> *) a. Monad m => a -> m a return LocalValue lv Ptr Value -> EncodeAST (Ptr Value) forall (m :: * -> *) a. Monad m => a -> m a return (Ptr Value -> EncodeAST (Ptr Value)) -> Ptr Value -> EncodeAST (Ptr Value) forall a b. (a -> b) -> a -> b $ case LocalValue lv of DefinedValue v :: Ptr Value v -> Ptr Value v; ForwardValue v :: Ptr Value v -> Ptr Value v encodeM (A.MetadataOperand md :: Metadata md) = do Ptr Metadata md' <- Metadata -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Metadata md Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr Value) -> EncodeAST (Ptr Value) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr Value) -> EncodeAST (Ptr Value)) -> IO (Ptr Value) -> EncodeAST (Ptr Value) forall a b. (a -> b) -> a -> b $ Ptr Value -> Ptr Value forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr Value -> Ptr Value) -> IO (Ptr Value) -> IO (Ptr Value) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr Context -> Ptr Metadata -> IO (Ptr Value) FFI.metadataOperand Ptr Context c Ptr Metadata md' instance EncodeM EncodeAST A.Metadata (Ptr FFI.Metadata) where encodeM :: Metadata -> EncodeAST (Ptr Metadata) encodeM (A.MDString s :: ShortByteString s) = do Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext (CString, CUInt) s <- ShortByteString -> EncodeAST (CString, CUInt) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString s Ptr MDString -> Ptr Metadata forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr MDString -> Ptr Metadata) -> EncodeAST (Ptr MDString) -> EncodeAST (Ptr Metadata) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr MDString) -> EncodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> (CString, CUInt) -> IO (Ptr MDString) FFI.getMDString Ptr Context c (CString, CUInt) s) encodeM (A.MDNode mdn :: MDRef MDNode mdn) = (Ptr MDNode -> Ptr Metadata forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast :: Ptr FFI.MDNode -> Ptr FFI.Metadata) (Ptr MDNode -> Ptr Metadata) -> EncodeAST (Ptr MDNode) -> EncodeAST (Ptr Metadata) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> MDRef MDNode -> EncodeAST (Ptr MDNode) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM MDRef MDNode mdn encodeM (A.MDValue v :: Operand v) = do Ptr Value v <- Operand -> EncodeAST (Ptr Value) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Operand v Ptr MDValue -> Ptr Metadata forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr MDValue -> Ptr Metadata) -> EncodeAST (Ptr MDValue) -> EncodeAST (Ptr Metadata) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr MDValue) -> EncodeAST (Ptr MDValue) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Value -> IO (Ptr MDValue) FFI.mdValue Ptr Value v) instance EncodeM EncodeAST A.CallableOperand (Ptr FFI.Value) where encodeM :: CallableOperand -> EncodeAST (Ptr Value) encodeM (Right o :: Operand o) = Operand -> EncodeAST (Ptr Value) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Operand o encodeM (Left i :: InlineAssembly i) = (Ptr InlineAsm -> Ptr Value forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast :: Ptr FFI.InlineAsm -> Ptr FFI.Value) (Ptr InlineAsm -> Ptr Value) -> EncodeAST (Ptr InlineAsm) -> EncodeAST (Ptr Value) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> InlineAssembly -> EncodeAST (Ptr InlineAsm) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM InlineAssembly i instance EncodeM EncodeAST A.MDNode (Ptr FFI.MDNode) where encodeM :: MDNode -> EncodeAST (Ptr MDNode) encodeM (A.MDTuple ops :: [Maybe Metadata] ops) = EncodeAST (Ptr MDNode) -> EncodeAST (Ptr MDNode) forall (m :: * -> *) a. ScopeAnyCont m => m a -> m a scopeAnyCont (EncodeAST (Ptr MDNode) -> EncodeAST (Ptr MDNode)) -> EncodeAST (Ptr MDNode) -> EncodeAST (Ptr MDNode) forall a b. (a -> b) -> a -> b $ do Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext (CUInt, Ptr (Ptr Metadata)) ops <- [Maybe Metadata] -> EncodeAST (CUInt, Ptr (Ptr Metadata)) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [Maybe Metadata] ops Ptr MDTuple -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr MDTuple -> Ptr MDNode) -> EncodeAST (Ptr MDTuple) -> EncodeAST (Ptr MDNode) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr MDTuple) -> EncodeAST (Ptr MDTuple) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> (CUInt, Ptr (Ptr Metadata)) -> IO (Ptr MDTuple) FFI.getMDTuple Ptr Context c (CUInt, Ptr (Ptr Metadata)) ops) encodeM (A.DINode n :: DINode n) = do Ptr DINode ptr <- DINode -> EncodeAST (Ptr DINode) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DINode n Ptr MDNode -> EncodeAST (Ptr MDNode) forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr DINode -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DINode ptr :: Ptr FFI.DINode)) encodeM (A.DILocation l :: DILocation l) = Ptr DILocation -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DILocation -> Ptr MDNode) -> EncodeAST (Ptr DILocation) -> EncodeAST (Ptr MDNode) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DILocation -> EncodeAST (Ptr DILocation) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DILocation l :: EncodeAST (Ptr FFI.DILocation)) encodeM (A.DIExpression e :: DIExpression e) = Ptr DIExpression -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIExpression -> Ptr MDNode) -> EncodeAST (Ptr DIExpression) -> EncodeAST (Ptr MDNode) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DIExpression -> EncodeAST (Ptr DIExpression) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIExpression e :: EncodeAST (Ptr FFI.DIExpression)) encodeM (A.DIGlobalVariableExpression e :: DIGlobalVariableExpression e) = Ptr DIGlobalVariableExpression -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIGlobalVariableExpression -> Ptr MDNode) -> EncodeAST (Ptr DIGlobalVariableExpression) -> EncodeAST (Ptr MDNode) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DIGlobalVariableExpression -> EncodeAST (Ptr DIGlobalVariableExpression) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIGlobalVariableExpression e :: EncodeAST (Ptr FFI.DIGlobalVariableExpression)) encodeM (A.DIMacroNode n :: DIMacroNode n) = Ptr DIMacroNode -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIMacroNode -> Ptr MDNode) -> EncodeAST (Ptr DIMacroNode) -> EncodeAST (Ptr MDNode) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (DIMacroNode -> EncodeAST (Ptr DIMacroNode) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIMacroNode n :: EncodeAST (Ptr FFI.DIMacroNode)) instance EncodeM EncodeAST A.DILocation (Ptr FFI.DILocation) where encodeM :: DILocation -> EncodeAST (Ptr DILocation) encodeM A.Location {..} = do Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext Ptr DILocalScope scopePtr <- MDRef DILocalScope -> EncodeAST (Ptr DILocalScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM MDRef DILocalScope scope IO (Ptr DILocation) -> EncodeAST (Ptr DILocation) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Word32 -> Word16 -> Ptr DILocalScope -> IO (Ptr DILocation) FFI.getDILocation Ptr Context c Word32 line Word16 column Ptr DILocalScope scopePtr) instance DecodeM DecodeAST A.DILocation (Ptr FFI.DILocation) where decodeM :: Ptr DILocation -> DecodeAST DILocation decodeM p :: Ptr DILocation p = do Word32 line <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILocation -> IO Word32 FFI.getDILocationLine Ptr DILocation p) Word16 col <- IO Word16 -> DecodeAST Word16 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILocation -> IO Word16 FFI.getDILocationColumn Ptr DILocation p) MDRef DILocalScope scope <- Ptr DILocalScope -> DecodeAST (MDRef DILocalScope) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DILocalScope -> DecodeAST (MDRef DILocalScope)) -> DecodeAST (Ptr DILocalScope) -> DecodeAST (MDRef DILocalScope) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DILocalScope) -> DecodeAST (Ptr DILocalScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILocation -> IO (Ptr DILocalScope) FFI.getDILocationScope Ptr DILocation p) DILocation -> DecodeAST DILocation forall (f :: * -> *) a. Applicative f => a -> f a pure (Word32 -> Word16 -> MDRef DILocalScope -> DILocation A.Location Word32 line Word16 col MDRef DILocalScope scope) instance (MonadIO m, MonadState EncodeState m, MonadAnyCont IO m, EncodeM m a (Ptr a'), FFI.DescendentOf FFI.Metadata a') => EncodeM m [a] (FFI.TupleArray a') where encodeM :: [a] -> m (TupleArray a') encodeM [] = TupleArray a' -> m (TupleArray a') forall (f :: * -> *) a. Applicative f => a -> f a pure (Ptr MDTuple -> TupleArray a' forall a. Ptr MDTuple -> TupleArray a FFI.TupleArray Ptr MDTuple forall a. Ptr a nullPtr) encodeM els :: [a] els = do (numEls :: CUInt numEls, elsPtr :: Ptr (Ptr a') elsPtr) <- [a] -> m (CUInt, Ptr (Ptr a')) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [a] els Context c :: Ptr Context c <- (EncodeState -> Context) -> m Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext Ptr MDTuple -> TupleArray a' forall a. Ptr MDTuple -> TupleArray a FFI.TupleArray (Ptr MDTuple -> TupleArray a') -> m (Ptr MDTuple) -> m (TupleArray a') forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr MDTuple) -> m (Ptr MDTuple) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> (CUInt, Ptr (Ptr Metadata)) -> IO (Ptr MDTuple) FFI.getMDTuple Ptr Context c (CUInt numEls, Ptr (Ptr a') -> Ptr (Ptr Metadata) forall a b. Ptr a -> Ptr b castPtr (Ptr (Ptr a') elsPtr :: Ptr (Ptr a')))) instance (MonadIO m, MonadAnyCont IO m, DecodeM m a (Ptr a')) => DecodeM m [a] (FFI.TupleArray a') where decodeM :: TupleArray a' -> m [a] decodeM (FFI.TupleArray p :: Ptr MDTuple p) | Ptr MDTuple p Ptr MDTuple -> Ptr MDTuple -> Bool forall a. Eq a => a -> a -> Bool == Ptr MDTuple forall a. Ptr a nullPtr = [a] -> m [a] forall (f :: * -> *) a. Applicative f => a -> f a pure [] | Bool otherwise = (Ptr MDNode -> IO CUInt) -> (Ptr MDNode -> CUInt -> IO (Ptr a')) -> Ptr MDNode -> m [a] forall (m :: * -> *) b' b a. (DecodeM m b' b, MonadIO m) => (a -> IO CUInt) -> (a -> CUInt -> IO b) -> a -> m [b'] decodeArray Ptr MDNode -> IO CUInt FFI.getMDNodeNumOperands Ptr MDNode -> CUInt -> IO (Ptr a') getOperand (Ptr MDTuple -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr MDTuple p) where getOperand :: Ptr MDNode -> CUInt -> IO (Ptr a') getOperand md :: Ptr MDNode md i :: CUInt i = (Ptr Metadata -> Ptr a' forall a b. Ptr a -> Ptr b castPtr (Ptr Metadata -> Ptr a') -> IO (Ptr Metadata) -> IO (Ptr a') forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr MDNode -> CUInt -> IO (Ptr Metadata) FFI.getMDNodeOperand Ptr MDNode md CUInt i) :: IO (Ptr a') encodeDWOp :: A.DWOp -> [Word64] encodeDWOp :: DWOp -> [Word64] encodeDWOp op :: DWOp op = case DWOp op of A.DwOpFragment (A.DW_OP_LLVM_Fragment offset :: Word64 offset size :: Word64 size) -> [Word64 FFI.DwOp_LLVM_fragment, Word64 offset, Word64 size] A.DW_OP_StackValue -> [Word64 FFI.DwOp_stack_value] A.DW_OP_Swap -> [Word64 FFI.DwOp_swap] A.DW_OP_ConstU arg :: Word64 arg -> [Word64 FFI.DwOp_constu, Word64 arg] A.DW_OP_Lit0 -> [Word64 FFI.DwOp_lit0] A.DW_OP_PlusUConst arg :: Word64 arg -> [Word64 FFI.DwOp_plus_uconst, Word64 arg] A.DW_OP_Plus -> [Word64 FFI.DwOp_plus] A.DW_OP_Minus -> [Word64 FFI.DwOp_minus] A.DW_OP_Mul -> [Word64 FFI.DwOp_mul] A.DW_OP_Div -> [Word64 FFI.DwOp_div] A.DW_OP_Mod -> [Word64 FFI.DwOp_mod] A.DW_OP_Not -> [Word64 FFI.DwOp_not] A.DW_OP_Or -> [Word64 FFI.DwOp_or] A.DW_OP_Xor -> [Word64 FFI.DwOp_xor] A.DW_OP_And -> [Word64 FFI.DwOp_and] A.DW_OP_Shr -> [Word64 FFI.DwOp_shr] A.DW_OP_Shra -> [Word64 FFI.DwOp_shra] A.DW_OP_Shl -> [Word64 FFI.DwOp_shl] A.DW_OP_Dup -> [Word64 FFI.DwOp_dup] A.DW_OP_Deref -> [Word64 FFI.DwOp_deref] A.DW_OP_XDeref -> [Word64 FFI.DwOp_xderef] instance DecodeM DecodeAST [Maybe A.Metadata] (Ptr FFI.MDNode) where decodeM :: Ptr MDNode -> DecodeAST [Maybe Metadata] decodeM p :: Ptr MDNode p = (Ptr MDNode -> IO CUInt) -> (Ptr MDNode -> CUInt -> IO (Ptr Metadata)) -> Ptr MDNode -> DecodeAST [Maybe Metadata] forall (m :: * -> *) b' b a. (DecodeM m b' b, MonadIO m) => (a -> IO CUInt) -> (a -> CUInt -> IO b) -> a -> m [b'] decodeArray Ptr MDNode -> IO CUInt FFI.getMDNodeNumOperands Ptr MDNode -> CUInt -> IO (Ptr Metadata) FFI.getMDNodeOperand Ptr MDNode p instance DecodeM DecodeAST A.Operand (Ptr FFI.MDValue) where decodeM :: Ptr MDValue -> DecodeAST Operand decodeM = Ptr Value -> DecodeAST Operand forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr Value -> DecodeAST Operand) -> (Ptr MDValue -> DecodeAST (Ptr Value)) -> Ptr MDValue -> DecodeAST Operand forall (m :: * -> *) b c a. Monad m => (b -> m c) -> (a -> m b) -> a -> m c <=< IO (Ptr Value) -> DecodeAST (Ptr Value) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr Value) -> DecodeAST (Ptr Value)) -> (Ptr MDValue -> IO (Ptr Value)) -> Ptr MDValue -> DecodeAST (Ptr Value) forall b c a. (b -> c) -> (a -> b) -> a -> c . Ptr MDValue -> IO (Ptr Value) FFI.getMDValue instance DecodeM DecodeAST A.Metadata (Ptr FFI.MetadataAsVal) where decodeM :: Ptr MetadataAsVal -> DecodeAST Metadata decodeM = Ptr Metadata -> DecodeAST Metadata forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr Metadata -> DecodeAST Metadata) -> (Ptr MetadataAsVal -> DecodeAST (Ptr Metadata)) -> Ptr MetadataAsVal -> DecodeAST Metadata forall (m :: * -> *) b c a. Monad m => (b -> m c) -> (a -> m b) -> a -> m c <=< IO (Ptr Metadata) -> DecodeAST (Ptr Metadata) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr Metadata) -> DecodeAST (Ptr Metadata)) -> (Ptr MetadataAsVal -> IO (Ptr Metadata)) -> Ptr MetadataAsVal -> DecodeAST (Ptr Metadata) forall b c a. (b -> c) -> (a -> b) -> a -> c . Ptr MetadataAsVal -> IO (Ptr Metadata) FFI.getMetadataOperand genCodingInstance [t|A.DIMacroInfo|] ''FFI.Macinfo [ (FFI.DW_Macinfo_Define, A.Define), (FFI.DW_Macinfo_Undef, A.Undef) ] decodeMDNode :: Ptr FFI.MDNode -> DecodeAST A.MDNode decodeMDNode :: Ptr MDNode -> DecodeAST MDNode decodeMDNode p :: Ptr MDNode p = DecodeAST MDNode -> DecodeAST MDNode forall (m :: * -> *) a. ScopeAnyCont m => m a -> m a scopeAnyCont (DecodeAST MDNode -> DecodeAST MDNode) -> DecodeAST MDNode -> DecodeAST MDNode forall a b. (a -> b) -> a -> b $ do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO MDSubclassID -> DecodeAST MDSubclassID) -> IO MDSubclassID -> DecodeAST MDSubclassID forall a b. (a -> b) -> a -> b $ Ptr MDNode -> IO MDSubclassID FFI.getMetadataClassId Ptr MDNode p case MDSubclassID sId of [mdSubclassIdP|MDTuple|] -> [Maybe Metadata] -> MDNode A.MDTuple ([Maybe Metadata] -> MDNode) -> DecodeAST [Maybe Metadata] -> DecodeAST MDNode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr MDNode -> DecodeAST [Maybe Metadata] forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM Ptr MDNode p [mdSubclassIdP|DIExpression|] -> DIExpression -> MDNode A.DIExpression (DIExpression -> MDNode) -> DecodeAST DIExpression -> DecodeAST MDNode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIExpression -> DecodeAST DIExpression forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDNode -> Ptr DIExpression forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DIExpression) [mdSubclassIdP|DIGlobalVariableExpression|] -> DIGlobalVariableExpression -> MDNode A.DIGlobalVariableExpression (DIGlobalVariableExpression -> MDNode) -> DecodeAST DIGlobalVariableExpression -> DecodeAST MDNode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIGlobalVariableExpression -> DecodeAST DIGlobalVariableExpression forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDNode -> Ptr DIGlobalVariableExpression forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DIGlobalVariableExpression) [mdSubclassIdP|DILocation|] -> DILocation -> MDNode A.DILocation (DILocation -> MDNode) -> DecodeAST DILocation -> DecodeAST MDNode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DILocation -> DecodeAST DILocation forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDNode -> Ptr DILocation forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DILocation) [mdSubclassIdP|DIMacro|] -> DIMacroNode -> MDNode A.DIMacroNode (DIMacroNode -> MDNode) -> DecodeAST DIMacroNode -> DecodeAST MDNode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIMacroNode -> DecodeAST DIMacroNode forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDNode -> Ptr DIMacroNode forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DIMacroNode) [mdSubclassIdP|DIMacroFile|] -> DIMacroNode -> MDNode A.DIMacroNode (DIMacroNode -> MDNode) -> DecodeAST DIMacroNode -> DecodeAST MDNode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIMacroNode -> DecodeAST DIMacroNode forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDNode -> Ptr DIMacroNode forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DIMacroNode) _ -> DINode -> MDNode A.DINode (DINode -> MDNode) -> DecodeAST DINode -> DecodeAST MDNode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DINode -> DecodeAST DINode forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDNode -> Ptr DINode forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DINode) instance DecodeM DecodeAST A.DIMacroNode (Ptr FFI.DIMacroNode) where decodeM :: Ptr DIMacroNode -> DecodeAST DIMacroNode decodeM p :: Ptr DIMacroNode p = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO MDSubclassID -> DecodeAST MDSubclassID) -> IO MDSubclassID -> DecodeAST MDSubclassID forall a b. (a -> b) -> a -> b $ Ptr MDNode -> IO MDSubclassID FFI.getMetadataClassId (Ptr DIMacroNode -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIMacroNode p) case MDSubclassID sId of [mdSubclassIdP|DIMacro|] -> do let p' :: Ptr DIMacro p' = Ptr DIMacroNode -> Ptr DIMacro forall a b. Ptr a -> Ptr b castPtr Ptr DIMacroNode p :: Ptr FFI.DIMacro DIMacroInfo macInfo <- Macinfo -> DecodeAST DIMacroInfo forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Macinfo -> DecodeAST DIMacroInfo) -> DecodeAST Macinfo -> DecodeAST DIMacroInfo forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO Macinfo -> DecodeAST Macinfo forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIMacro -> IO Macinfo FFI.getDIMacroMacinfo Ptr DIMacro p') Word32 line <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIMacro -> IO Word32 FFI.getDIMacroLine Ptr DIMacro p') ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIMacro -> IO (Ptr MDString) FFI.getDIMacroName Ptr DIMacro p') ShortByteString value <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIMacro -> IO (Ptr MDString) FFI.getDIMacroValue Ptr DIMacro p') DIMacroNode -> DecodeAST DIMacroNode forall (f :: * -> *) a. Applicative f => a -> f a pure (DIMacroInfo -> Word32 -> ShortByteString -> ShortByteString -> DIMacroNode A.DIMacro DIMacroInfo macInfo Word32 line ShortByteString name ShortByteString value) [mdSubclassIdP|DIMacroFile|] -> do let p' :: Ptr DIMacroFile p' = Ptr DIMacroNode -> Ptr DIMacroFile forall a b. Ptr a -> Ptr b castPtr Ptr DIMacroNode p :: Ptr FFI.DIMacroFile Word32 line <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIMacroFile -> IO Word32 FFI.getDIMacroFileLine Ptr DIMacroFile p') MDRef DIFile file <- Ptr DIFile -> DecodeAST (MDRef DIFile) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIFile -> DecodeAST (MDRef DIFile)) -> DecodeAST (Ptr DIFile) -> DecodeAST (MDRef DIFile) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIFile) -> DecodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIMacroFile -> IO (Ptr DIFile) FFI.getDIMacroFileFile Ptr DIMacroFile p') [MDRef DIMacroNode] elements <- (Ptr DIMacroFile -> IO CUInt) -> (Ptr DIMacroFile -> CUInt -> IO (Ptr DIMacroNode)) -> Ptr DIMacroFile -> DecodeAST [MDRef DIMacroNode] forall (m :: * -> *) b' b a. (DecodeM m b' b, MonadIO m) => (a -> IO CUInt) -> (a -> CUInt -> IO b) -> a -> m [b'] decodeArray Ptr DIMacroFile -> IO CUInt FFI.getDIMacroFileNumElements Ptr DIMacroFile -> CUInt -> IO (Ptr DIMacroNode) FFI.getDIMacroFileElement Ptr DIMacroFile p' DIMacroNode -> DecodeAST DIMacroNode forall (f :: * -> *) a. Applicative f => a -> f a pure (Word32 -> MDRef DIFile -> [MDRef DIMacroNode] -> DIMacroNode A.DIMacroFile Word32 line MDRef DIFile file [MDRef DIMacroNode] elements) _ -> DecodeException -> DecodeAST DIMacroNode forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Unknown subclass id for DIMacroNode: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId)) instance EncodeM EncodeAST A.DIMacroNode (Ptr FFI.DIMacroNode) where encodeM :: DIMacroNode -> EncodeAST (Ptr DIMacroNode) encodeM A.DIMacro {..} = do Macinfo macInfo <- DIMacroInfo -> EncodeAST Macinfo forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM DIMacroInfo info Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr MDString value <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString value Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext Ptr DIMacro -> Ptr DIMacroNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIMacro -> Ptr DIMacroNode) -> EncodeAST (Ptr DIMacro) -> EncodeAST (Ptr DIMacroNode) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr DIMacro) -> EncodeAST (Ptr DIMacro) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Macinfo -> Word32 -> Ptr MDString -> Ptr MDString -> IO (Ptr DIMacro) FFI.getDIMacro Ptr Context c Macinfo macInfo Word32 line Ptr MDString name Ptr MDString value) encodeM A.DIMacroFile {..} = do Ptr DIFile file <- MDRef DIFile -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM MDRef DIFile file TupleArray DIMacroNode elements <- [MDRef DIMacroNode] -> EncodeAST (TupleArray DIMacroNode) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM [MDRef DIMacroNode] elements Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext Ptr DIMacroFile -> Ptr DIMacroNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIMacroFile -> Ptr DIMacroNode) -> EncodeAST (Ptr DIMacroFile) -> EncodeAST (Ptr DIMacroNode) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr DIMacroFile) -> EncodeAST (Ptr DIMacroFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Word32 -> Ptr DIFile -> TupleArray DIMacroNode -> IO (Ptr DIMacroFile) FFI.getDIMacroFile Ptr Context c Word32 line Ptr DIFile file TupleArray DIMacroNode elements) instance EncodeM EncodeAST A.DIExpression (Ptr FFI.DIExpression) where encodeM :: DIExpression -> EncodeAST (Ptr DIExpression) encodeM A.Expression {..} = do (CUInt, Ptr Word64) ops <- [Word64] -> EncodeAST (CUInt, Ptr Word64) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ((DWOp -> [Word64]) -> [DWOp] -> [Word64] forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b] concatMap DWOp -> [Word64] encodeDWOp [DWOp] operands) Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext Ptr DIExpression -> Ptr DIExpression forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast (Ptr DIExpression -> Ptr DIExpression) -> EncodeAST (Ptr DIExpression) -> EncodeAST (Ptr DIExpression) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IO (Ptr DIExpression) -> EncodeAST (Ptr DIExpression) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> (CUInt, Ptr Word64) -> IO (Ptr DIExpression) FFI.getDIExpression Ptr Context c (CUInt, Ptr Word64) ops) instance DecodeM DecodeAST A.DIExpression (Ptr FFI.DIExpression) where decodeM :: Ptr DIExpression -> DecodeAST DIExpression decodeM diExpr :: Ptr DIExpression diExpr = do CUInt numElems <- IO CUInt -> DecodeAST CUInt forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIExpression -> IO CUInt FFI.getDIExpressionNumElements Ptr DIExpression diExpr) let go :: CUInt -> IO [DWOp] go i :: CUInt i | CUInt i CUInt -> CUInt -> Bool forall a. Ord a => a -> a -> Bool >= CUInt numElems = [DWOp] -> IO [DWOp] forall (f :: * -> *) a. Applicative f => a -> f a pure [] | Bool otherwise = do Word64 op <- Ptr DIExpression -> CUInt -> IO Word64 FFI.getDIExpressionElement Ptr DIExpression diExpr CUInt i case Word64 op of FFI.DwOp_LLVM_fragment -> do String -> CUInt -> CUInt -> IO () forall (f :: * -> *). MonadThrow f => String -> CUInt -> CUInt -> f () expectElems "LLVM_fragment" CUInt i 2 Word64 offset <- Ptr DIExpression -> CUInt -> IO Word64 FFI.getDIExpressionElement Ptr DIExpression diExpr (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) Word64 size <- Ptr DIExpression -> CUInt -> IO Word64 FFI.getDIExpressionElement Ptr DIExpression diExpr (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 2) (DWOpFragment -> DWOp A.DwOpFragment (Word64 -> Word64 -> DWOpFragment A.DW_OP_LLVM_Fragment Word64 offset Word64 size) DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 3) FFI.DwOp_stack_value -> (DWOp A.DW_OP_StackValue DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_swap -> (DWOp A.DW_OP_Swap DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_constu -> do String -> CUInt -> CUInt -> IO () forall (f :: * -> *). MonadThrow f => String -> CUInt -> CUInt -> f () expectElems "constu" CUInt i 1 Word64 arg <- Ptr DIExpression -> CUInt -> IO Word64 FFI.getDIExpressionElement Ptr DIExpression diExpr (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) (Word64 -> DWOp A.DW_OP_ConstU Word64 argDWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 2) FFI.DwOp_lit0 -> (DWOp A.DW_OP_Lit0 DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_plus_uconst -> do String -> CUInt -> CUInt -> IO () forall (f :: * -> *). MonadThrow f => String -> CUInt -> CUInt -> f () expectElems "uconst" CUInt i 1 Word64 arg <- Ptr DIExpression -> CUInt -> IO Word64 FFI.getDIExpressionElement Ptr DIExpression diExpr (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) (Word64 -> DWOp A.DW_OP_PlusUConst Word64 argDWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 2) FFI.DwOp_plus -> (DWOp A.DW_OP_Plus DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_minus -> (DWOp A.DW_OP_Minus DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_mul -> (DWOp A.DW_OP_Mul DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_div -> (DWOp A.DW_OP_Div DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_mod -> (DWOp A.DW_OP_Mod DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_not -> (DWOp A.DW_OP_Not DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_or -> (DWOp A.DW_OP_Or DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_xor -> (DWOp A.DW_OP_Xor DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_and -> (DWOp A.DW_OP_And DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_shr -> (DWOp A.DW_OP_Shr DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_shra -> (DWOp A.DW_OP_Shra DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_shl -> (DWOp A.DW_OP_Shl DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_dup -> (DWOp A.DW_OP_Dup DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_deref -> (DWOp A.DW_OP_Deref DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) FFI.DwOp_xderef -> (DWOp A.DW_OP_XDeref DWOp -> [DWOp] -> [DWOp] forall a. a -> [a] -> [a] :) ([DWOp] -> [DWOp]) -> IO [DWOp] -> IO [DWOp] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + 1) _ -> DecodeException -> IO [DWOp] forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Unknown DW_OP " String -> String -> String forall a. Semigroup a => a -> a -> a <> Word64 -> String forall a. Show a => a -> String show Word64 op)) expectElems :: String -> CUInt -> CUInt -> f () expectElems name :: String name i :: CUInt i n :: CUInt n = Bool -> f () -> f () forall (f :: * -> *). Applicative f => Bool -> f () -> f () when (CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a + CUInt n CUInt -> CUInt -> Bool forall a. Ord a => a -> a -> Bool >= CUInt numElems) (DecodeException -> f () forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException ("Expected " String -> String -> String forall a. Semigroup a => a -> a -> a <> CUInt -> String forall a. Show a => a -> String show CUInt n String -> String -> String forall a. Semigroup a => a -> a -> a <> " elements following DW_OP_" String -> String -> String forall a. Semigroup a => a -> a -> a <> String name String -> String -> String forall a. Semigroup a => a -> a -> a <> " but got " String -> String -> String forall a. Semigroup a => a -> a -> a <> CUInt -> String forall a. Show a => a -> String show (CUInt numElems CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a - CUInt i CUInt -> CUInt -> CUInt forall a. Num a => a -> a -> a - 1)))) IO DIExpression -> DecodeAST DIExpression forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO ([DWOp] -> DIExpression A.Expression ([DWOp] -> DIExpression) -> IO [DWOp] -> IO DIExpression forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> CUInt -> IO [DWOp] go 0) instance EncodeM EncodeAST A.DIGlobalVariableExpression (Ptr FFI.DIGlobalVariableExpression) where encodeM :: DIGlobalVariableExpression -> EncodeAST (Ptr DIGlobalVariableExpression) encodeM A.GlobalVariableExpression {..} = do Ptr DIGlobalVariable var <- MDRef DIGlobalVariable -> EncodeAST (Ptr DIGlobalVariable) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM MDRef DIGlobalVariable var Ptr DIExpression expr <- MDRef DIExpression -> EncodeAST (Ptr DIExpression) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM MDRef DIExpression expr Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DIGlobalVariableExpression) -> EncodeAST (Ptr DIGlobalVariableExpression) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIGlobalVariable -> Ptr DIExpression -> IO (Ptr DIGlobalVariableExpression) FFI.getDIGlobalVariableExpression Ptr Context c Ptr DIGlobalVariable var Ptr DIExpression expr) instance DecodeM DecodeAST A.DIGlobalVariableExpression (Ptr FFI.DIGlobalVariableExpression) where decodeM :: Ptr DIGlobalVariableExpression -> DecodeAST DIGlobalVariableExpression decodeM p :: Ptr DIGlobalVariableExpression p = do MDRef DIGlobalVariable var <- Ptr DIGlobalVariable -> DecodeAST (MDRef DIGlobalVariable) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIGlobalVariable -> DecodeAST (MDRef DIGlobalVariable)) -> DecodeAST (Ptr DIGlobalVariable) -> DecodeAST (MDRef DIGlobalVariable) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIGlobalVariable) -> DecodeAST (Ptr DIGlobalVariable) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIGlobalVariableExpression -> IO (Ptr DIGlobalVariable) FFI.getDIGlobalVariableExpressionVariable Ptr DIGlobalVariableExpression p) MDRef DIExpression expr <- Ptr DIExpression -> DecodeAST (MDRef DIExpression) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIExpression -> DecodeAST (MDRef DIExpression)) -> DecodeAST (Ptr DIExpression) -> DecodeAST (MDRef DIExpression) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIExpression) -> DecodeAST (Ptr DIExpression) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIGlobalVariableExpression -> IO (Ptr DIExpression) FFI.getDIGlobalVariableExpressionExpression Ptr DIGlobalVariableExpression p) DIGlobalVariableExpression -> DecodeAST DIGlobalVariableExpression forall (f :: * -> *) a. Applicative f => a -> f a pure (MDRef DIGlobalVariable -> MDRef DIExpression -> DIGlobalVariableExpression A.GlobalVariableExpression MDRef DIGlobalVariable var MDRef DIExpression expr) genCodingInstance [t|A.ImportedEntityTag|] ''FFI.DwTag [ (FFI.DwTag_imported_module, A.ImportedModule) , (FFI.DwTag_imported_declaration, A.ImportedDeclaration) ] instance EncodeM EncodeAST A.DIImportedEntity (Ptr FFI.DIImportedEntity) where encodeM :: DIImportedEntity -> EncodeAST (Ptr DIImportedEntity) encodeM A.ImportedEntity {..} = do DwTag tag <- ImportedEntityTag -> EncodeAST DwTag forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ImportedEntityTag tag Ptr DIScope scope <- MDRef DIScope -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM MDRef DIScope scope Ptr DINode entity <- Maybe (MDRef DINode) -> EncodeAST (Ptr DINode) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DINode) entity Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DIImportedEntity) -> EncodeAST (Ptr DIImportedEntity) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> DwTag -> Ptr DIScope -> Ptr DINode -> Ptr DIFile -> Word32 -> Ptr MDString -> IO (Ptr DIImportedEntity) FFI.getDIImportedEntity Ptr Context c DwTag tag Ptr DIScope scope Ptr DINode entity Ptr DIFile file Word32 line Ptr MDString name) instance DecodeM DecodeAST A.DIImportedEntity (Ptr FFI.DIImportedEntity) where decodeM :: Ptr DIImportedEntity -> DecodeAST DIImportedEntity decodeM e :: Ptr DIImportedEntity e = do ImportedEntityTag tag <- DwTag -> DecodeAST ImportedEntityTag forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (DwTag -> DecodeAST ImportedEntityTag) -> DecodeAST DwTag -> DecodeAST ImportedEntityTag forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO DwTag -> DecodeAST DwTag forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DINode -> IO DwTag FFI.getTag (Ptr DIImportedEntity -> Ptr DINode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr DIImportedEntity e)) MDRef DIScope scope <- Ptr DIScope -> DecodeAST (MDRef DIScope) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIScope -> DecodeAST (MDRef DIScope)) -> DecodeAST (Ptr DIScope) -> DecodeAST (MDRef DIScope) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIScope) -> DecodeAST (Ptr DIScope) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIImportedEntity -> IO (Ptr DIScope) FFI.getDIImportedEntityScope Ptr DIImportedEntity e) Maybe (MDRef DINode) entity <- Ptr DINode -> DecodeAST (Maybe (MDRef DINode)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DINode -> DecodeAST (Maybe (MDRef DINode))) -> DecodeAST (Ptr DINode) -> DecodeAST (Maybe (MDRef DINode)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DINode) -> DecodeAST (Ptr DINode) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIImportedEntity -> IO (Ptr DINode) FFI.getDIImportedEntityEntity Ptr DIImportedEntity e) Maybe (MDRef DIFile) file <- Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile))) -> DecodeAST (Ptr DIFile) -> DecodeAST (Maybe (MDRef DIFile)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIFile) -> DecodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIImportedEntity -> IO (Ptr DIFile) FFI.getDIImportedEntityFile Ptr DIImportedEntity e) ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIImportedEntity -> IO (Ptr MDString) FFI.getDIImportedEntityName Ptr DIImportedEntity e) Word32 line <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIImportedEntity -> IO Word32 FFI.getDIImportedEntityLine Ptr DIImportedEntity e) DIImportedEntity -> DecodeAST DIImportedEntity forall (f :: * -> *) a. Applicative f => a -> f a pure (ImportedEntityTag -> ShortByteString -> MDRef DIScope -> Maybe (MDRef DINode) -> Maybe (MDRef DIFile) -> Word32 -> DIImportedEntity A.ImportedEntity ImportedEntityTag tag ShortByteString name MDRef DIScope scope Maybe (MDRef DINode) entity Maybe (MDRef DIFile) file Word32 line) instance EncodeM EncodeAST A.DIObjCProperty (Ptr FFI.DIObjCProperty) where encodeM :: DIObjCProperty -> EncodeAST (Ptr DIObjCProperty) encodeM A.ObjCProperty {..} = do Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIFile) file Ptr MDString getterName <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString getterName Ptr MDString setterName <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM ShortByteString setterName Ptr DIType type' <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM Maybe (MDRef DIType) type' Context c :: Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext IO (Ptr DIObjCProperty) -> EncodeAST (Ptr DIObjCProperty) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr MDString -> Ptr DIFile -> Word32 -> Ptr MDString -> Ptr MDString -> Word32 -> Ptr DIType -> IO (Ptr DIObjCProperty) FFI.getDIObjCProperty Ptr Context c Ptr MDString name Ptr DIFile file Word32 line Ptr MDString getterName Ptr MDString setterName Word32 attributes Ptr DIType type') instance DecodeM DecodeAST A.DIObjCProperty (Ptr FFI.DIObjCProperty) where decodeM :: Ptr DIObjCProperty -> DecodeAST DIObjCProperty decodeM p :: Ptr DIObjCProperty p = do ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIObjCProperty -> IO (Ptr MDString) FFI.getDIObjCPropertyName Ptr DIObjCProperty p) Maybe (MDRef DIFile) file <- Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIFile -> DecodeAST (Maybe (MDRef DIFile))) -> DecodeAST (Ptr DIFile) -> DecodeAST (Maybe (MDRef DIFile)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIFile) -> DecodeAST (Ptr DIFile) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIObjCProperty -> IO (Ptr DIFile) FFI.getDIObjCPropertyFile Ptr DIObjCProperty p) Word32 line <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIObjCProperty -> IO Word32 FFI.getDIObjCPropertyLine Ptr DIObjCProperty p) ShortByteString getterName <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIObjCProperty -> IO (Ptr MDString) FFI.getDIObjCPropertyGetterName Ptr DIObjCProperty p) ShortByteString setterName <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDString -> DecodeAST ShortByteString) -> DecodeAST (Ptr MDString) -> DecodeAST ShortByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIObjCProperty -> IO (Ptr MDString) FFI.getDIObjCPropertySetterName Ptr DIObjCProperty p) Word32 attributes <- IO Word32 -> DecodeAST Word32 forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIObjCProperty -> IO Word32 FFI.getDIObjCPropertyAttributes Ptr DIObjCProperty p) Maybe (MDRef DIType) type' <- Ptr DIType -> DecodeAST (Maybe (MDRef DIType)) forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr DIType -> DecodeAST (Maybe (MDRef DIType))) -> DecodeAST (Ptr DIType) -> DecodeAST (Maybe (MDRef DIType)) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DIType) -> DecodeAST (Ptr DIType) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIObjCProperty -> IO (Ptr DIType) FFI.getDIObjCPropertyType Ptr DIObjCProperty p) DIObjCProperty -> DecodeAST DIObjCProperty forall (f :: * -> *) a. Applicative f => a -> f a pure (ShortByteString -> Maybe (MDRef DIFile) -> Word32 -> ShortByteString -> ShortByteString -> Word32 -> Maybe (MDRef DIType) -> DIObjCProperty A.ObjCProperty ShortByteString name Maybe (MDRef DIFile) file Word32 line ShortByteString getterName ShortByteString setterName Word32 attributes Maybe (MDRef DIType) type') instance {-# OVERLAPS #-} DecodeM DecodeAST (A.MDRef A.MDNode) (Ptr FFI.MDNode) where decodeM :: Ptr MDNode -> DecodeAST (MDRef MDNode) decodeM p :: Ptr MDNode p = DecodeAST (MDRef MDNode) -> DecodeAST (MDRef MDNode) forall (m :: * -> *) a. ScopeAnyCont m => m a -> m a scopeAnyCont (DecodeAST (MDRef MDNode) -> DecodeAST (MDRef MDNode)) -> DecodeAST (MDRef MDNode) -> DecodeAST (MDRef MDNode) forall a b. (a -> b) -> a -> b $ do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO MDSubclassID -> DecodeAST MDSubclassID) -> IO MDSubclassID -> DecodeAST MDSubclassID forall a b. (a -> b) -> a -> b $ Ptr MDNode -> IO MDSubclassID FFI.getMetadataClassId Ptr MDNode p case MDSubclassID sId of [mdSubclassIdP|DIExpression|] -> MDNode -> MDRef MDNode forall a. a -> MDRef a A.MDInline (MDNode -> MDRef MDNode) -> (DIExpression -> MDNode) -> DIExpression -> MDRef MDNode forall b c a. (b -> c) -> (a -> b) -> a -> c . DIExpression -> MDNode A.DIExpression (DIExpression -> MDRef MDNode) -> DecodeAST DIExpression -> DecodeAST (MDRef MDNode) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr DIExpression -> DecodeAST DIExpression forall (d :: * -> *) h c. DecodeM d h c => c -> d h decodeM (Ptr MDNode -> Ptr DIExpression forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DIExpression) _ -> MetadataNodeID -> MDRef MDNode forall a. MetadataNodeID -> MDRef a A.MDRef (MetadataNodeID -> MDRef MDNode) -> DecodeAST MetadataNodeID -> DecodeAST (MDRef MDNode) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr MDNode -> DecodeAST MetadataNodeID getMetadataNodeID Ptr MDNode p instance (DecodeM DecodeAST a (Ptr b), FFI.DescendentOf FFI.MDNode b) => DecodeM DecodeAST (A.MDRef a) (Ptr b) where decodeM :: Ptr b -> DecodeAST (MDRef a) decodeM p :: Ptr b p = DecodeAST (MDRef a) -> DecodeAST (MDRef a) forall (m :: * -> *) a. ScopeAnyCont m => m a -> m a scopeAnyCont (DecodeAST (MDRef a) -> DecodeAST (MDRef a)) -> DecodeAST (MDRef a) -> DecodeAST (MDRef a) forall a b. (a -> b) -> a -> b $ MetadataNodeID -> MDRef a forall a. MetadataNodeID -> MDRef a A.MDRef (MetadataNodeID -> MDRef a) -> DecodeAST MetadataNodeID -> DecodeAST (MDRef a) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr MDNode -> DecodeAST MetadataNodeID getMetadataNodeID (Ptr b -> Ptr MDNode forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr b p) instance (EncodeM EncodeAST a (Ptr b), FFI.DescendentOf FFI.MDNode b) => EncodeM EncodeAST (A.MDRef a) (Ptr b) where encodeM :: MDRef a -> EncodeAST (Ptr b) encodeM (A.MDRef id :: MetadataNodeID id) = Ptr MDNode -> Ptr b forall a b. Ptr a -> Ptr b castPtr (Ptr MDNode -> Ptr b) -> EncodeAST (Ptr MDNode) -> EncodeAST (Ptr b) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> MetadataNodeID -> EncodeAST (Ptr MDNode) referMDNode MetadataNodeID id encodeM (A.MDInline m :: a m) = a -> EncodeAST (Ptr b) forall (e :: * -> *) h c. EncodeM e h c => h -> e c encodeM a m getMetadataDefinitions :: DecodeAST [A.Definition] getMetadataDefinitions :: DecodeAST [Definition] getMetadataDefinitions = (DecodeAST [Definition] -> DecodeAST [Definition]) -> DecodeAST [Definition] forall a. (a -> a) -> a fix ((DecodeAST [Definition] -> DecodeAST [Definition]) -> DecodeAST [Definition]) -> (DecodeAST [Definition] -> DecodeAST [Definition]) -> DecodeAST [Definition] forall a b. (a -> b) -> a -> b $ \continue :: DecodeAST [Definition] continue -> do Maybe (MetadataNodeID, Ptr MDNode) mdntd <- DecodeAST (Maybe (MetadataNodeID, Ptr MDNode)) takeMetadataNodeToDefine case Maybe (MetadataNodeID, Ptr MDNode) mdntd of Nothing -> [Definition] -> DecodeAST [Definition] forall (f :: * -> *) a. Applicative f => a -> f a pure [] Just (mid :: MetadataNodeID mid, p :: Ptr MDNode p) -> (:) (Definition -> [Definition] -> [Definition]) -> DecodeAST Definition -> DecodeAST ([Definition] -> [Definition]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (MetadataNodeID -> MDNode -> Definition A.MetadataNodeDefinition MetadataNodeID mid (MDNode -> Definition) -> DecodeAST MDNode -> DecodeAST Definition forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Ptr MDNode -> DecodeAST MDNode decodeMDNode Ptr MDNode p) DecodeAST ([Definition] -> [Definition]) -> DecodeAST [Definition] -> DecodeAST [Definition] forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> DecodeAST [Definition] continue