{-# LANGUAGE DuplicateRecordFields, DisambiguateRecordFields, MultiParamTypeClasses, NamedFieldPuns, OverloadedStrings, PatternSynonyms, QuasiQuotes, RecordWildCards, ScopedTypeVariables, TemplateHaskell #-} {-# OPTIONS_GHC -fno-warn-orphans #-} 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 qualified LLVM.AST.Constant as A (Constant(Int, integerBits, integerValue)) import LLVM.Internal.FFI.LLVMCTypes (mdSubclassIdP) 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) ] 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) ] 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) ] 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) ] genCodingInstance [t|A.Virtuality|] ''FFI.DwVirtuality [ (FFI.DwVirtuality_none, A.NoVirtuality) , (FFI.DwVirtuality_virtual, A.Virtual) , (FFI.DwVirtuality_pure_virtual, A.PureVirtual) ] genCodingInstance [t|A.DIMacroInfo|] ''FFI.Macinfo [ (FFI.DW_Macinfo_Define, A.Define), (FFI.DW_Macinfo_Undef, A.Undef) ] genCodingInstance [t|A.ImportedEntityTag|] ''FFI.DwTag [ (FFI.DwTag_imported_module, A.ImportedModule) , (FFI.DwTag_imported_declaration, A.ImportedDeclaration) ] instance EncodeM EncodeAST ShortByteString (Ptr FFI.MDString) where encodeM :: HasCallStack => ShortByteString -> EncodeAST (Ptr MDString) encodeM ShortByteString s = do (CString, CUInt) s' <- ShortByteString -> EncodeAST (CString, CUInt) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString s Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => [DIFlag] -> m DIFlags encodeM [DIFlag] fs = DIFlags -> m DIFlags forall a. a -> m a forall (f :: * -> *) a. Applicative f => a -> f a pure (Word32 -> DIFlags FFI.DIFlags ((Word32 -> Word32 -> Word32) -> Word32 -> [Word32] -> Word32 forall b a. (b -> a -> b) -> b -> [a] -> b forall (t :: * -> *) b a. Foldable t => (b -> a -> b) -> b -> t a -> b foldl' Word32 -> Word32 -> Word32 forall a. Bits a => a -> a -> a (.|.) Word32 0 ((DIFlag -> Word32) -> [DIFlag] -> [Word32] forall a b. (a -> b) -> [a] -> [b] map DIFlag -> Word32 forall {a}. (Num a, Bits a) => DIFlag -> a encodeFlag [DIFlag] fs))) where encodeFlag :: DIFlag -> a encodeFlag DIFlag f = case DIFlag f of A.Accessibility DIAccessibility A.Private -> a 1 A.Accessibility DIAccessibility A.Protected -> a 2 A.Accessibility DIAccessibility A.Public -> a 3 DIFlag A.FwdDecl -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 2 DIFlag A.AppleBlock -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 3 DIFlag A.ReservedBit4 -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 4 DIFlag A.VirtualFlag -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 5 DIFlag A.Artificial -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 6 DIFlag A.Explicit -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 7 DIFlag A.Prototyped -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 8 DIFlag A.ObjcClassComplete -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 9 DIFlag A.ObjectPointer -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 10 DIFlag A.Vector -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 11 DIFlag A.StaticMember -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 12 DIFlag A.LValueReference -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 13 DIFlag A.RValueReference -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 14 A.InheritanceFlag DIInheritance A.SingleInheritance -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 16 A.InheritanceFlag DIInheritance A.MultipleInheritance -> a 2 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 16 A.InheritanceFlag DIInheritance A.VirtualInheritance -> a 3 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 16 DIFlag A.IntroducedVirtual -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 18 DIFlag A.BitField -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 19 DIFlag A.NoReturn -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 20 DIFlag A.TypePassByValue -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 22 DIFlag A.TypePassByReference -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 23 DIFlag A.EnumClass -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 24 DIFlag A.Thunk -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 25 DIFlag A.NonTrivial -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 26 DIFlag A.BigEndian -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 27 DIFlag A.LittleEndian -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 28 DIFlag A.AllCallsDescribed -> a 1 a -> Int -> a forall a. Bits a => a -> Int -> a `shiftL` Int 29 instance Applicative m => DecodeM m [A.DIFlag] FFI.DIFlags where decodeM :: HasCallStack => DIFlags -> m [DIFlag] decodeM (FFI.DIFlags Word32 f) = [DIFlag] -> m [DIFlag] forall a. a -> m a 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 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 /= Word32 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 Word32 f'') = [DIFlag] -> Identity DIFlags forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DIFlag f'] accessibility :: [DIFlag] accessibility | Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f Int 0 Bool -> Bool -> Bool && Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f Int 1 = [DIAccessibility -> DIFlag A.Accessibility DIAccessibility A.Public] | Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f Int 0 = [DIAccessibility -> DIFlag A.Accessibility DIAccessibility A.Private] | Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f Int 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 Int 16 Bool -> Bool -> Bool && Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f Int 17 = [DIInheritance -> DIFlag A.InheritanceFlag DIInheritance A.VirtualInheritance] | Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f Int 16 = [DIInheritance -> DIFlag A.InheritanceFlag DIInheritance A.SingleInheritance] | Word32 -> Int -> Bool forall a. Bits a => a -> Int -> Bool testBit Word32 f Int 17 = [DIInheritance -> DIFlag A.InheritanceFlag DIInheritance A.MultipleInheritance] | Bool otherwise = [] flags :: [DIFlag] flags = [ DIFlag A.FwdDecl , DIFlag A.AppleBlock , 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.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 :: HasCallStack => Ptr Value -> DecodeAST Operand decodeM Ptr Value v = do Ptr Constant c <- IO (Ptr Constant) -> DecodeAST (Ptr Constant) forall a. IO a -> DecodeAST a 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 a. a -> DecodeAST a 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, HasCallStack) => c -> d h decodeM Ptr Constant c else do Ptr MetadataAsVal m <- IO (Ptr MetadataAsVal) -> DecodeAST (Ptr MetadataAsVal) forall a. IO a -> DecodeAST a 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, HasCallStack) => 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a b. DecodeAST (a -> b) -> DecodeAST a -> DecodeAST b 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 :: HasCallStack => Ptr Metadata -> DecodeAST Metadata decodeM Ptr Metadata md = do Ptr MDString s <- IO (Ptr MDString) -> DecodeAST (Ptr MDString) forall a. IO a -> DecodeAST a 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, HasCallStack) => c -> d h decodeM Ptr MDString s else do Ptr MDNode n <- IO (Ptr MDNode) -> DecodeAST (Ptr MDNode) forall a. IO a -> DecodeAST a 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, HasCallStack) => c -> d h decodeM Ptr MDNode n else do Ptr MDValue v <- IO (Ptr MDValue) -> DecodeAST (Ptr MDValue) forall a. IO a -> DecodeAST a 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, HasCallStack) => c -> d h decodeM Ptr MDValue v else do DecodeException -> DecodeAST Metadata forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException String "Metadata was not one of [MDString, MDValue, MDNode]") instance DecodeM DecodeAST (Either String A.DINode) (Ptr FFI.DINode) where decodeM :: HasCallStack => Ptr DINode -> DecodeAST (Either String DINode) decodeM Ptr DINode diN = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall a. IO a -> DecodeAST a 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 MDSubclassID [mdSubclassIdP|DIEnumerator|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIEnumerator forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIEnumerator) MDSubclassID [mdSubclassIdP|DIImportedEntity|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIImportedEntity forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIImportedEntity) MDSubclassID [mdSubclassIdP|DIObjCProperty|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIObjCProperty forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIObjCProperty) MDSubclassID [mdSubclassIdP|DISubrange|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DISubrange forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DISubrange) MDSubclassID [mdSubclassIdP|DIBasicType|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) MDSubclassID [mdSubclassIdP|DICompositeType|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) MDSubclassID [mdSubclassIdP|DIDerivedType|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) MDSubclassID [mdSubclassIdP|DISubroutineType|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) MDSubclassID [mdSubclassIdP|DILexicalBlock|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) MDSubclassID [mdSubclassIdP|DILexicalBlockFile|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) MDSubclassID [mdSubclassIdP|DIFile|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) MDSubclassID [mdSubclassIdP|DINamespace|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) MDSubclassID [mdSubclassIdP|DISubprogram|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) MDSubclassID [mdSubclassIdP|DICompileUnit|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) MDSubclassID [mdSubclassIdP|DIModule|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIScope forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIScope) MDSubclassID [mdSubclassIdP|DIGlobalVariable|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIVariable forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIVariable) MDSubclassID [mdSubclassIdP|DILocalVariable|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DIVariable forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DIVariable) MDSubclassID [mdSubclassIdP|DITemplateTypeParameter|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DITemplateParameter forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DITemplateParameter) MDSubclassID [mdSubclassIdP|DITemplateValueParameter|] -> (DINode -> Either String DINode) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM DINode -> Either String DINode forall a b. b -> Either a b Right (DecodeAST DINode -> DecodeAST (Either String DINode)) -> DecodeAST DINode -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr DINode -> Ptr DITemplateParameter forall a b. Ptr a -> Ptr b castPtr Ptr DINode diN :: Ptr FFI.DITemplateParameter) MDSubclassID [mdSubclassIdP|MDString|] -> (String -> Either String DINode) -> DecodeAST String -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM String -> Either String DINode forall a b. a -> Either a b Left (DecodeAST String -> DecodeAST (Either String DINode)) -> DecodeAST String -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ String -> DecodeAST String forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (String "Lifting to Haskell not implemented for toplevel DINode kind: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId String -> String -> String forall a. Semigroup a => a -> a -> a <> String " (MDString)") MDSubclassID [mdSubclassIdP|ConstantAsMetadata|] -> (String -> Either String DINode) -> DecodeAST String -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM String -> Either String DINode forall a b. a -> Either a b Left (DecodeAST String -> DecodeAST (Either String DINode)) -> DecodeAST String -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ String -> DecodeAST String forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (String "Lifting to Haskell not implemented for toplevel DINode kind: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId String -> String -> String forall a. Semigroup a => a -> a -> a <> String " (ConstantAsMetadata)") MDSubclassID [mdSubclassIdP|LocalAsMetadata|] -> (String -> Either String DINode) -> DecodeAST String -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM String -> Either String DINode forall a b. a -> Either a b Left (DecodeAST String -> DecodeAST (Either String DINode)) -> DecodeAST String -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ String -> DecodeAST String forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (String "Lifting to Haskell not implemented for toplevel DINode kind: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId String -> String -> String forall a. Semigroup a => a -> a -> a <> String " (LocalAsMetadata)") MDSubclassID [mdSubclassIdP|DistinctMDOperandPlaceholder|] -> (String -> Either String DINode) -> DecodeAST String -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM String -> Either String DINode forall a b. a -> Either a b Left (DecodeAST String -> DecodeAST (Either String DINode)) -> DecodeAST String -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ String -> DecodeAST String forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (String "Lifting to Haskell not implemented for toplevel DINode kind: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId String -> String -> String forall a. Semigroup a => a -> a -> a <> String " (DistinctMDOperandPlaceholder)") MDSubclassID [mdSubclassIdP|MDTuple|] -> (String -> Either String DINode) -> DecodeAST String -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM String -> Either String DINode forall a b. a -> Either a b Left (DecodeAST String -> DecodeAST (Either String DINode)) -> DecodeAST String -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ String -> DecodeAST String forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (String "Lifting to Haskell not implemented for toplevel DINode kind: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId String -> String -> String forall a. Semigroup a => a -> a -> a <> String " (MDTuple)") MDSubclassID [mdSubclassIdP|DILocation|] -> (String -> Either String DINode) -> DecodeAST String -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM String -> Either String DINode forall a b. a -> Either a b Left (DecodeAST String -> DecodeAST (Either String DINode)) -> DecodeAST String -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ String -> DecodeAST String forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (String "Lifting to Haskell not implemented for toplevel DINode kind: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId String -> String -> String forall a. Semigroup a => a -> a -> a <> String " (DILocation)") MDSubclassID [mdSubclassIdP|DIExpression|] -> (String -> Either String DINode) -> DecodeAST String -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM String -> Either String DINode forall a b. a -> Either a b Left (DecodeAST String -> DecodeAST (Either String DINode)) -> DecodeAST String -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ String -> DecodeAST String forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (String "Lifting to Haskell not implemented for toplevel DINode kind: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId String -> String -> String forall a. Semigroup a => a -> a -> a <> String " (DIExpression)") MDSubclassID [mdSubclassIdP|DIGlobalVariableExpression|] -> (String -> Either String DINode) -> DecodeAST String -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM String -> Either String DINode forall a b. a -> Either a b Left (DecodeAST String -> DecodeAST (Either String DINode)) -> DecodeAST String -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ String -> DecodeAST String forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (String "Lifting to Haskell not implemented for toplevel DINode kind: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId String -> String -> String forall a. Semigroup a => a -> a -> a <> String " (DIGlobalVariableExpression)") MDSubclassID [mdSubclassIdP|GenericDINode|] -> (String -> Either String DINode) -> DecodeAST String -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM String -> Either String DINode forall a b. a -> Either a b Left (DecodeAST String -> DecodeAST (Either String DINode)) -> DecodeAST String -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ String -> DecodeAST String forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (String "Lifting to Haskell not implemented for toplevel DINode kind: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId String -> String -> String forall a. Semigroup a => a -> a -> a <> String " (GenericDINode)") MDSubclassID [mdSubclassIdP|DIMacro|] -> (String -> Either String DINode) -> DecodeAST String -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM String -> Either String DINode forall a b. a -> Either a b Left (DecodeAST String -> DecodeAST (Either String DINode)) -> DecodeAST String -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ String -> DecodeAST String forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (String "Lifting to Haskell not implemented for toplevel DINode kind: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId String -> String -> String forall a. Semigroup a => a -> a -> a <> String " (DIMacro)") MDSubclassID [mdSubclassIdP|DIMacroFile|] -> (String -> Either String DINode) -> DecodeAST String -> DecodeAST (Either String DINode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM String -> Either String DINode forall a b. a -> Either a b Left (DecodeAST String -> DecodeAST (Either String DINode)) -> DecodeAST String -> DecodeAST (Either String DINode) forall a b. (a -> b) -> a -> b $ String -> DecodeAST String forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (String "Lifting to Haskell not implemented for toplevel DINode kind: " String -> String -> String forall a. Semigroup a => a -> a -> a <> MDSubclassID -> String forall a. Show a => a -> String show MDSubclassID sId String -> String -> String forall a. Semigroup a => a -> a -> a <> String " (DIMacroFile)") MDSubclassID _ -> DecodeException -> DecodeAST (Either String DINode) forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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.DICount (Ptr FFI.Metadata) where encodeM :: HasCallStack => DICount -> EncodeAST (Ptr Metadata) encodeM DICount count = do case DICount count of A.DICountConstant Int64 i -> do let constant :: Metadata constant = Operand -> Metadata A.MDValue (Constant -> Operand A.ConstantOperand (A.Int { integerBits :: Word32 A.integerBits = Word32 64, integerValue :: Integer A.integerValue = Int64 -> Integer forall a. Integral a => a -> Integer toInteger Int64 i })) Metadata -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Metadata constant A.DICountVariable MDRef DIVariable v -> do Metadata -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM (MDRef MDNode -> Metadata A.MDNode (MDRef MDNode -> Metadata) -> MDRef MDNode -> Metadata forall a b. (a -> b) -> a -> b $ DINode -> MDNode A.DINode (DINode -> MDNode) -> (DIVariable -> DINode) -> DIVariable -> MDNode forall b c a. (b -> c) -> (a -> b) -> a -> c . DIVariable -> DINode A.DIVariable (DIVariable -> MDNode) -> MDRef DIVariable -> MDRef MDNode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> MDRef DIVariable v) instance EncodeM EncodeAST A.DIBound (Ptr FFI.Metadata) where encodeM :: HasCallStack => DIBound -> EncodeAST (Ptr Metadata) encodeM DIBound bound = do case DIBound bound of A.DIBoundConstant Int64 i -> do let constant :: Metadata constant = Operand -> Metadata A.MDValue (Constant -> Operand A.ConstantOperand (A.Int { integerBits :: Word32 A.integerBits = Word32 64, integerValue :: Integer A.integerValue = Int64 -> Integer forall a. Integral a => a -> Integer toInteger Int64 i })) Metadata -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Metadata constant A.DIBoundVariable MDRef DIVariable v -> do Metadata -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM (MDRef MDNode -> Metadata A.MDNode (DINode -> MDNode A.DINode (DINode -> MDNode) -> (DIVariable -> DINode) -> DIVariable -> MDNode forall b c a. (b -> c) -> (a -> b) -> a -> c . DIVariable -> DINode A.DIVariable (DIVariable -> MDNode) -> MDRef DIVariable -> MDRef MDNode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> MDRef DIVariable v)) A.DIBoundExpression MDRef DIExpression e -> do Metadata -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM (MDRef MDNode -> Metadata A.MDNode (DIExpression -> MDNode A.DIExpression (DIExpression -> MDNode) -> MDRef DIExpression -> MDRef MDNode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> MDRef DIExpression e)) instance DecodeM DecodeAST A.DICount (Ptr FFI.Metadata) where decodeM :: HasCallStack => Ptr Metadata -> DecodeAST DICount decodeM Ptr Metadata m = do Ptr MDValue c <- IO (Ptr MDValue) -> DecodeAST (Ptr MDValue) forall a. IO a -> DecodeAST a 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 m if Ptr MDValue c Ptr MDValue -> Ptr MDValue -> Bool forall a. Eq a => a -> a -> Bool /= Ptr MDValue forall a. Ptr a nullPtr then do (A.ConstantOperand A.Int { integerValue :: Constant -> Integer A.integerValue = Integer i }) <- Ptr MDValue -> DecodeAST Operand forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => c -> d h decodeM Ptr MDValue c DICount -> DecodeAST DICount forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (Int64 -> DICount A.DICountConstant (Integer -> Int64 forall a. Num a => Integer -> a fromInteger Integer i)) else do MDRef DIVariable v <- Ptr DIVariable -> DecodeAST (MDRef DIVariable) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Metadata -> IO (Ptr DIVariable) FFI.isADIVariable Ptr Metadata m) DICount -> DecodeAST DICount forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (MDRef DIVariable -> DICount A.DICountVariable MDRef DIVariable v) instance DecodeM DecodeAST A.DIBound (Ptr FFI.Metadata) where decodeM :: HasCallStack => Ptr Metadata -> DecodeAST DIBound decodeM Ptr Metadata m = do Ptr MDValue c <- IO (Ptr MDValue) -> DecodeAST (Ptr MDValue) forall a. IO a -> DecodeAST a 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 m if Ptr MDValue c Ptr MDValue -> Ptr MDValue -> Bool forall a. Eq a => a -> a -> Bool /= Ptr MDValue forall a. Ptr a nullPtr then do (A.ConstantOperand A.Int { integerValue :: Constant -> Integer A.integerValue = Integer i }) <- Ptr MDValue -> DecodeAST Operand forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => c -> d h decodeM Ptr MDValue c DIBound -> DecodeAST DIBound forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (Int64 -> DIBound A.DIBoundConstant (Integer -> Int64 forall a. Num a => Integer -> a fromInteger Integer i)) else do Ptr DIVariable v <- IO (Ptr DIVariable) -> DecodeAST (Ptr DIVariable) forall a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Metadata -> IO (Ptr DIVariable) FFI.isADIVariable Ptr Metadata m) if Ptr DIVariable v Ptr DIVariable -> Ptr DIVariable -> Bool forall a. Eq a => a -> a -> Bool /= Ptr DIVariable forall a. Ptr a nullPtr then do MDRef DIVariable v' <- Ptr DIVariable -> DecodeAST (MDRef DIVariable) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 =<< Ptr DIVariable -> DecodeAST (Ptr DIVariable) forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure Ptr DIVariable v DIBound -> DecodeAST DIBound forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (MDRef DIVariable -> DIBound A.DIBoundVariable MDRef DIVariable v') else do MDRef DIExpression e <- Ptr DIExpression -> DecodeAST (MDRef DIExpression) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Metadata -> IO (Ptr DIExpression) FFI.isADIExpression Ptr Metadata m) DIBound -> DecodeAST DIBound forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (MDRef DIExpression -> DIBound A.DIBoundExpression MDRef DIExpression e) instance EncodeM EncodeAST A.DISubrange (Ptr FFI.DISubrange) where encodeM :: HasCallStack => DISubrange -> EncodeAST (Ptr DISubrange) encodeM (A.Subrange {Maybe DIBound DICount count :: DICount lowerBound :: Maybe DIBound upperBound :: Maybe DIBound stride :: Maybe DIBound $sel:count:Subrange :: DISubrange -> DICount $sel:lowerBound:Subrange :: DISubrange -> Maybe DIBound $sel:upperBound:Subrange :: DISubrange -> Maybe DIBound $sel:stride:Subrange :: DISubrange -> Maybe DIBound ..}) = do Context Ptr Context c <- (EncodeState -> Context) -> EncodeAST Context forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets EncodeState -> Context encodeStateContext Ptr Metadata count' <- DICount -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DICount count Ptr Metadata lowerBound' <- Maybe DIBound -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe DIBound lowerBound Ptr Metadata upperBound' <- Maybe DIBound -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe DIBound upperBound Ptr Metadata stride' <- Maybe DIBound -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe DIBound stride IO (Ptr DISubrange) -> EncodeAST (Ptr DISubrange) forall a. IO a -> EncodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr Metadata -> Ptr Metadata -> Ptr Metadata -> Ptr Metadata -> IO (Ptr DISubrange) FFI.getDISubrangeVariableFields Ptr Context c Ptr Metadata count' Ptr Metadata lowerBound' Ptr Metadata upperBound' Ptr Metadata stride') instance DecodeM DecodeAST A.DISubrange (Ptr FFI.DISubrange) where decodeM :: HasCallStack => Ptr DISubrange -> DecodeAST DISubrange decodeM Ptr DISubrange r = do DICount count <- Ptr Metadata -> DecodeAST DICount forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => c -> d h decodeM (Ptr Metadata -> DecodeAST DICount) -> DecodeAST (Ptr Metadata) -> DecodeAST DICount forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr Metadata) -> DecodeAST (Ptr Metadata) forall a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubrange -> IO (Ptr Metadata) FFI.getDISubrangeCount Ptr DISubrange r) Maybe DIBound lowerBound <- Ptr Metadata -> DecodeAST (Maybe DIBound) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => c -> d h decodeM (Ptr Metadata -> DecodeAST (Maybe DIBound)) -> DecodeAST (Ptr Metadata) -> DecodeAST (Maybe DIBound) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr Metadata) -> DecodeAST (Ptr Metadata) forall a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubrange -> IO (Ptr Metadata) FFI.getDISubrangeLowerBound Ptr DISubrange r) Maybe DIBound upperBound <- Ptr Metadata -> DecodeAST (Maybe DIBound) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => c -> d h decodeM (Ptr Metadata -> DecodeAST (Maybe DIBound)) -> DecodeAST (Ptr Metadata) -> DecodeAST (Maybe DIBound) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr Metadata) -> DecodeAST (Ptr Metadata) forall a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubrange -> IO (Ptr Metadata) FFI.getDISubrangeUpperBound Ptr DISubrange r) Maybe DIBound stride <- Ptr Metadata -> DecodeAST (Maybe DIBound) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => c -> d h decodeM (Ptr Metadata -> DecodeAST (Maybe DIBound)) -> DecodeAST (Ptr Metadata) -> DecodeAST (Maybe DIBound) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr Metadata) -> DecodeAST (Ptr Metadata) forall a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubrange -> IO (Ptr Metadata) FFI.getDISubrangeStride Ptr DISubrange r) DISubrange -> DecodeAST DISubrange forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (DICount -> Maybe DIBound -> Maybe DIBound -> Maybe DIBound -> DISubrange A.Subrange DICount count Maybe DIBound lowerBound Maybe DIBound upperBound Maybe DIBound stride) instance EncodeM EncodeAST A.DIEnumerator (Ptr FFI.DIEnumerator) where encodeM :: HasCallStack => DIEnumerator -> EncodeAST (Ptr DIEnumerator) encodeM (A.Enumerator {Bool Int64 ShortByteString value :: Int64 isUnsigned :: Bool name :: ShortByteString $sel:value:Enumerator :: DIEnumerator -> Int64 $sel:isUnsigned:Enumerator :: DIEnumerator -> Bool $sel:name:Enumerator :: DIEnumerator -> ShortByteString ..}) = do Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name LLVMBool isUnsigned <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Bool isUnsigned Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DIEnumerator -> DecodeAST DIEnumerator decodeM Ptr DIEnumerator e = do Int64 value <- IO Int64 -> DecodeAST Int64 forall a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIEnumerator -> IO (Ptr MDString) FFI.getDIEnumeratorName Ptr DIEnumerator e) DIEnumerator -> DecodeAST DIEnumerator forall a. a -> DecodeAST a 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 :: HasCallStack => DINode -> EncodeAST (Ptr DINode) encodeM (A.DISubrange DISubrange r) = do Ptr DISubrange ptr <- DISubrange -> EncodeAST (Ptr DISubrange) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DISubrange r Ptr DINode -> EncodeAST (Ptr DINode) forall a. a -> EncodeAST a 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 DIEnumerator e) = do Ptr DIEnumerator ptr <- DIEnumerator -> EncodeAST (Ptr DIEnumerator) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DIEnumerator e Ptr DINode -> EncodeAST (Ptr DINode) forall a. a -> EncodeAST a 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 DIScope s) = do Ptr DIScope ptr <- DIScope -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DIScope s Ptr DINode -> EncodeAST (Ptr DINode) forall a. a -> EncodeAST a 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 DIVariable v) = do Ptr DIVariable ptr <- DIVariable -> EncodeAST (Ptr DIVariable) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DIVariable v Ptr DINode -> EncodeAST (Ptr DINode) forall a. a -> EncodeAST a 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 DITemplateParameter p) = do Ptr DITemplateParameter ptr <- DITemplateParameter -> EncodeAST (Ptr DITemplateParameter) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DITemplateParameter p Ptr DINode -> EncodeAST (Ptr DINode) forall a. a -> EncodeAST a 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 DIImportedEntity e) = do Ptr DIImportedEntity ptr <- DIImportedEntity -> EncodeAST (Ptr DIImportedEntity) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DIImportedEntity e Ptr DINode -> EncodeAST (Ptr DINode) forall a. a -> EncodeAST a 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 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, HasCallStack) => h -> e c encodeM DIObjCProperty o :: EncodeAST (Ptr FFI.DIObjCProperty)) instance DecodeM DecodeAST A.DIScope (Ptr FFI.DIScope) where decodeM :: HasCallStack => Ptr DIScope -> DecodeAST DIScope decodeM Ptr DIScope p = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall a. IO a -> DecodeAST a 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 MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIScope -> Ptr DINamespace forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DINamespace) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIScope -> Ptr DIFile forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIFile) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIScope -> Ptr DILocalScope forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DILocalScope) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIScope -> Ptr DILocalScope forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DILocalScope) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIScope -> Ptr DILocalScope forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DILocalScope) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIScope -> Ptr DIType forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIType) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIScope -> Ptr DIType forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIType) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIScope -> Ptr DIType forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIType) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIScope -> Ptr DIType forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIType) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIScope -> Ptr DICompileUnit forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DICompileUnit) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIScope -> Ptr DIModule forall a b. Ptr a -> Ptr b castPtr Ptr DIScope p :: Ptr FFI.DIModule) MDSubclassID _ -> DecodeException -> DecodeAST DIScope forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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 :: HasCallStack => Ptr DINamespace -> DecodeAST DINamespace decodeM Ptr DINamespace p = do Maybe (MDRef DIScope) scope <- Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope)) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. a -> DecodeAST a 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 :: HasCallStack => DINamespace -> EncodeAST (Ptr DINamespace) encodeM A.Namespace {Bool Maybe (MDRef DIScope) ShortByteString name :: ShortByteString scope :: Maybe (MDRef DIScope) exportSymbols :: Bool $sel:name:Namespace :: DINamespace -> ShortByteString $sel:scope:Namespace :: DINamespace -> Maybe (MDRef DIScope) $sel:exportSymbols:Namespace :: DINamespace -> Bool ..} = do Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIScope) scope LLVMBool exportSyms <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Bool exportSymbols Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DIModule -> DecodeAST DIModule decodeM Ptr DIModule p = do Maybe (MDRef DIScope) scope <- Ptr DIScope -> DecodeAST (Maybe (MDRef DIScope)) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIModule -> IO (Ptr MDString) FFI.getDIModuleIncludePath Ptr DIModule m) ShortByteString apiNotesFile <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIModule -> IO (Ptr MDString) FFI.getDIModuleAPINotesFile Ptr DIModule m) Word32 lineNo <- IO Word32 -> DecodeAST Word32 forall a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIModule -> IO Word32 FFI.getDIModuleLineNo Ptr DIModule m) DIModule -> DecodeAST DIModule forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure 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:apiNotesFile:Module :: ShortByteString A.apiNotesFile = ShortByteString apiNotesFile , $sel:lineNo:Module :: Word32 A.lineNo = Word32 lineNo } instance EncodeM EncodeAST A.DIModule (Ptr FFI.DIModule) where encodeM :: HasCallStack => DIModule -> EncodeAST (Ptr DIModule) encodeM A.Module {Maybe (MDRef DIScope) Word32 ShortByteString $sel:scope:Module :: DIModule -> Maybe (MDRef DIScope) $sel:name:Module :: DIModule -> ShortByteString $sel:configurationMacros:Module :: DIModule -> ShortByteString $sel:includePath:Module :: DIModule -> ShortByteString $sel:apiNotesFile:Module :: DIModule -> ShortByteString $sel:lineNo:Module :: DIModule -> Word32 scope :: Maybe (MDRef DIScope) name :: ShortByteString configurationMacros :: ShortByteString includePath :: ShortByteString apiNotesFile :: ShortByteString lineNo :: Word32 ..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr MDString configurationMacros <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString configurationMacros Ptr MDString includePath <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString includePath Ptr MDString apiNotesFile <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString apiNotesFile Context 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 a. IO a -> EncodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr DIScope -> Ptr MDString -> Ptr MDString -> Ptr MDString -> Ptr MDString -> Word32 -> IO (Ptr DIModule) FFI.getDIModule Ptr Context c Ptr DIScope scope Ptr MDString name Ptr MDString configurationMacros Ptr MDString includePath Ptr MDString apiNotesFile Word32 lineNo) instance DecodeM DecodeAST A.DICompileUnit (Ptr FFI.DICompileUnit) where decodeM :: HasCallStack => Ptr DICompileUnit -> DecodeAST DICompileUnit decodeM Ptr DICompileUnit p = do Word32 language <- CUInt -> DecodeAST Word32 forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 MetadataNodeID i) = MDRef (Either DIType DISubprogram) -> DecodeAST (MDRef (Either DIType DISubprogram)) forall a. a -> DecodeAST a 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 DIType ty)) = MDRef (Either DIType DISubprogram) -> DecodeAST (MDRef (Either DIType DISubprogram)) forall a. a -> DecodeAST a 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 DISubprogram p))) = MDRef (Either DIType DISubprogram) -> DecodeAST (MDRef (Either DIType DISubprogram)) forall a. a -> DecodeAST a 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 DIScope e) = DecodeException -> DecodeAST (MDRef (Either DIType DISubprogram)) forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> [a] -> f [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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO DebugNameTableKind FFI.getDICompileUnitNameTableKind Ptr DICompileUnit p) Bool rangesBaseAddress <- LLVMBool -> DecodeAST Bool forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompileUnit -> IO LLVMBool FFI.getDICompileUnitRangesBaseAddress Ptr DICompileUnit p) DICompileUnit -> DecodeAST DICompileUnit forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure 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:rangesBaseAddress:CompileUnit :: Bool A.rangesBaseAddress = Bool rangesBaseAddress } instance EncodeM EncodeAST A.DICompileUnit (Ptr FFI.DICompileUnit) where encodeM :: HasCallStack => DICompileUnit -> EncodeAST (Ptr DICompileUnit) encodeM (A.CompileUnit {Bool [MDRef (Either DIType DISubprogram)] [MDRef DICompositeType] [MDRef DIImportedEntity] [MDRef DIMacroNode] [MDRef DIGlobalVariableExpression] Word32 Word64 ShortByteString DebugNameTableKind DebugEmissionKind MDRef DIFile $sel:language:CompileUnit :: DICompileUnit -> Word32 $sel:file:CompileUnit :: DICompileUnit -> MDRef DIFile $sel:producer:CompileUnit :: DICompileUnit -> ShortByteString $sel:optimized:CompileUnit :: DICompileUnit -> Bool $sel:flags:CompileUnit :: DICompileUnit -> ShortByteString $sel:runtimeVersion:CompileUnit :: DICompileUnit -> Word32 $sel:splitDebugFileName:CompileUnit :: DICompileUnit -> ShortByteString $sel:emissionKind:CompileUnit :: DICompileUnit -> DebugEmissionKind $sel:enums:CompileUnit :: DICompileUnit -> [MDRef DICompositeType] $sel:retainedTypes:CompileUnit :: DICompileUnit -> [MDRef (Either DIType DISubprogram)] $sel:globals:CompileUnit :: DICompileUnit -> [MDRef DIGlobalVariableExpression] $sel:imports:CompileUnit :: DICompileUnit -> [MDRef DIImportedEntity] $sel:macros:CompileUnit :: DICompileUnit -> [MDRef DIMacroNode] $sel:dWOId:CompileUnit :: DICompileUnit -> Word64 $sel:splitDebugInlining:CompileUnit :: DICompileUnit -> Bool $sel:debugInfoForProfiling:CompileUnit :: DICompileUnit -> Bool $sel:nameTableKind:CompileUnit :: DICompileUnit -> DebugNameTableKind $sel:rangesBaseAddress:CompileUnit :: DICompileUnit -> Bool language :: Word32 file :: MDRef DIFile producer :: ShortByteString optimized :: Bool flags :: ShortByteString runtimeVersion :: Word32 splitDebugFileName :: ShortByteString emissionKind :: DebugEmissionKind enums :: [MDRef DICompositeType] retainedTypes :: [MDRef (Either DIType DISubprogram)] globals :: [MDRef DIGlobalVariableExpression] imports :: [MDRef DIImportedEntity] macros :: [MDRef DIMacroNode] dWOId :: Word64 splitDebugInlining :: Bool debugInfoForProfiling :: Bool nameTableKind :: DebugNameTableKind rangesBaseAddress :: Bool ..}) = do CUInt language <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Word32 language Ptr DIFile file <- MDRef DIFile -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM MDRef DIFile file Ptr MDString producer <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString producer LLVMBool optimized <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Bool optimized Ptr MDString flags <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString flags CUInt runtimeVersion <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Word32 runtimeVersion Ptr MDString debugFileName <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString splitDebugFileName DebugEmissionKind emissionKind <- DebugEmissionKind -> EncodeAST DebugEmissionKind forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DebugEmissionKind emissionKind TupleArray DICompositeType enums <- [MDRef DICompositeType] -> EncodeAST (TupleArray DICompositeType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [MDRef DICompositeType] enums TupleArray DIScope retainedTypes <- [MDRef DIScope] -> EncodeAST (TupleArray DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => 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 a b. (a -> b) -> MDRef a -> MDRef b 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, HasCallStack) => h -> e c encodeM [MDRef DIGlobalVariableExpression] globals TupleArray DIImportedEntity imports <- [MDRef DIImportedEntity] -> EncodeAST (TupleArray DIImportedEntity) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [MDRef DIImportedEntity] imports TupleArray DIMacroNode macros <- [MDRef DIMacroNode] -> EncodeAST (TupleArray DIMacroNode) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [MDRef DIMacroNode] macros Word64 dwoid <- Word64 -> EncodeAST Word64 forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Word64 dWOId LLVMBool splitDebugInlining <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Bool splitDebugInlining LLVMBool debugInfoForProfiling <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Bool debugInfoForProfiling DebugNameTableKind nameTableKind <- DebugNameTableKind -> EncodeAST DebugNameTableKind forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DebugNameTableKind nameTableKind LLVMBool rangesBaseAddress <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Bool rangesBaseAddress Context 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 a. IO a -> EncodeAST a 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 rangesBaseAddress instance EncodeM EncodeAST A.DIScope (Ptr FFI.DIScope) where encodeM :: HasCallStack => DIScope -> EncodeAST (Ptr DIScope) encodeM (A.DIFile 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, HasCallStack) => h -> e c encodeM DIFile f :: EncodeAST (Ptr FFI.DIFile)) encodeM (A.DICompileUnit 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, HasCallStack) => h -> e c encodeM DICompileUnit cu :: EncodeAST (Ptr FFI.DICompileUnit)) encodeM (A.DIType 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, HasCallStack) => h -> e c encodeM DIType t :: EncodeAST (Ptr FFI.DIType)) encodeM (A.DILocalScope 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, HasCallStack) => h -> e c encodeM DILocalScope t :: EncodeAST (Ptr FFI.DILocalScope)) encodeM (A.DINamespace 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, HasCallStack) => h -> e c encodeM DINamespace ns :: EncodeAST (Ptr FFI.DINamespace)) encodeM (A.DIModule 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, HasCallStack) => h -> e c encodeM DIModule m :: EncodeAST (Ptr FFI.DIModule)) instance DecodeM DecodeAST A.DIFile (Ptr FFI.DIFile) where decodeM :: HasCallStack => Ptr DIFile -> DecodeAST DIFile decodeM Ptr DIFile diF = do ShortByteString fname <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 Maybe ShortByteString Nothing -> DIFile -> DecodeAST DIFile forall a. a -> DecodeAST a 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 ShortByteString checksum -> do ChecksumKind csk <- ChecksumKind -> DecodeAST ChecksumKind forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIFile -> IO ChecksumKind FFI.getFileChecksumKind Ptr DIFile diF) DIFile -> DecodeAST DIFile forall a. a -> DecodeAST a 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 :: HasCallStack => DIFile -> EncodeAST (Ptr DIFile) encodeM (A.File {Maybe ChecksumInfo ShortByteString filename :: ShortByteString directory :: ShortByteString checksum :: Maybe ChecksumInfo $sel:filename:File :: DIFile -> ShortByteString $sel:directory:File :: DIFile -> ShortByteString $sel:checksum:File :: DIFile -> Maybe ChecksumInfo ..}) = do Ptr MDString filename <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString filename Ptr MDString directory <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString directory Context 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 Maybe ChecksumInfo Nothing -> IO (Ptr DIFile) -> EncodeAST (Ptr DIFile) forall a. IO a -> EncodeAST a 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 CUInt 0) Ptr MDString forall a. Ptr a nullPtr) Just (A.ChecksumInfo {ShortByteString ChecksumKind checksumKind :: ChecksumKind checksumValue :: ShortByteString $sel:checksumKind:ChecksumInfo :: ChecksumInfo -> ChecksumKind $sel:checksumValue:ChecksumInfo :: ChecksumInfo -> ShortByteString ..}) -> do Ptr MDString checksumValue <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString checksumValue ChecksumKind checksumKind <- ChecksumKind -> EncodeAST ChecksumKind forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ChecksumKind checksumKind IO (Ptr DIFile) -> EncodeAST (Ptr DIFile) forall a. IO a -> EncodeAST a 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 :: HasCallStack => Maybe Encoding -> EncodeAST Encoding encodeM Maybe Encoding Nothing = Encoding -> EncodeAST Encoding forall a. a -> EncodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (CUInt -> Encoding FFI.Encoding CUInt 0) encodeM (Just Encoding e) = Encoding -> EncodeAST Encoding forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Encoding e instance DecodeM DecodeAST (Maybe A.Encoding) FFI.Encoding where decodeM :: HasCallStack => Encoding -> DecodeAST (Maybe Encoding) decodeM (FFI.Encoding CUInt 0) = Maybe Encoding -> DecodeAST (Maybe Encoding) forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure Maybe Encoding forall a. Maybe a Nothing decodeM 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, HasCallStack) => c -> d h decodeM Encoding e instance EncodeM EncodeAST A.DIType (Ptr FFI.DIType) where encodeM :: HasCallStack => DIType -> EncodeAST (Ptr DIType) encodeM (A.DIBasicType 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, HasCallStack) => h -> e c encodeM DIBasicType t :: EncodeAST (Ptr FFI.DIBasicType)) encodeM (A.DIDerivedType 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, HasCallStack) => h -> e c encodeM DIDerivedType t :: EncodeAST (Ptr FFI.DIDerivedType)) encodeM (A.DISubroutineType 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, HasCallStack) => h -> e c encodeM DISubroutineType t :: EncodeAST (Ptr FFI.DISubroutineType)) encodeM (A.DICompositeType 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, HasCallStack) => h -> e c encodeM DICompositeType t :: EncodeAST (Ptr FFI.DICompositeType)) instance DecodeM DecodeAST A.DICompositeType (Ptr FFI.DICompositeType) where decodeM :: HasCallStack => Ptr DICompositeType -> DecodeAST DICompositeType decodeM Ptr DICompositeType diTy = do DwTag tag <- IO DwTag -> DecodeAST DwTag forall a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompositeType -> IO (Ptr MDString) FFI.getIdentifier Ptr DICompositeType diTy) case DwTag tag of DwTag FFI.DwTag_array_type -> do [DISubrange] subscripts <- TupleArray DISubrange -> DecodeAST [DISubrange] forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. a -> DecodeAST a 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) DwTag FFI.DwTag_enumeration_type -> do [DIEnumerator] values <- TupleArray DIEnumerator -> DecodeAST [DIEnumerator] forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. a -> DecodeAST a 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) DwTag FFI.DwTag_structure_type -> do [MDRef DIScope] elements <- TupleArray DIScope -> DecodeAST [MDRef DIScope] forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> [a] -> f [b] traverse MDRef DIScope -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) fromCompElement [MDRef DIScope] elements DICompositeType -> DecodeAST DICompositeType forall a. a -> DecodeAST a 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) DwTag FFI.DwTag_class_type -> do [MDRef DIScope] elements <- TupleArray DIScope -> DecodeAST [MDRef DIScope] forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> [a] -> f [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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DICompositeType -> IO (TupleArray DITemplateParameter) FFI.getTemplateParams Ptr DICompositeType diTy) DICompositeType -> DecodeAST DICompositeType forall a. a -> DecodeAST a 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) DwTag FFI.DwTag_union_type -> do [MDRef DIScope] elements <- TupleArray DIScope -> DecodeAST [MDRef DIScope] forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> [a] -> f [b] traverse MDRef DIScope -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) fromCompElement [MDRef DIScope] elements DICompositeType -> DecodeAST DICompositeType forall a. a -> DecodeAST a 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) DwTag _ -> DecodeException -> DecodeAST DICompositeType forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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 MetadataNodeID r) = MDRef (Either DIDerivedType DISubprogram) -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) forall a. a -> DecodeAST a 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 DIDerivedType ty))) = MDRef (Either DIDerivedType DISubprogram) -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) forall a. a -> DecodeAST a 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 DISubprogram p))) = MDRef (Either DIDerivedType DISubprogram) -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) forall a. a -> DecodeAST a 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 DIScope e) = DecodeException -> DecodeAST (MDRef (Either DIDerivedType DISubprogram)) forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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 a b. (a -> b) -> MDRef a -> MDRef b 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 :: HasCallStack => DICompositeType -> EncodeAST (Ptr DICompositeType) encodeM A.DIArrayType {[DISubrange] [DIFlag] Maybe (MDRef DIType) Word32 Word64 subscripts :: [DISubrange] elementTy :: Maybe (MDRef DIType) sizeInBits :: Word64 alignInBits :: Word32 flags :: [DIFlag] $sel:subscripts:DIArrayType :: DICompositeType -> [DISubrange] $sel:elementTy:DIArrayType :: DICompositeType -> Maybe (MDRef DIType) $sel:sizeInBits:DIArrayType :: DICompositeType -> Word64 $sel:alignInBits:DIArrayType :: DICompositeType -> Word32 $sel:flags:DIArrayType :: DICompositeType -> [DIFlag] ..} = do TupleArray DISubrange subscripts <- [DISubrange] -> EncodeAST (TupleArray DISubrange) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DISubrange] subscripts Ptr DIType elementTy <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIType) elementTy DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DIFlag] flags Context 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 a. IO a -> EncodeAST a 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 {[DIEnumerator] Maybe (MDRef DIType) Maybe (MDRef DIFile) Maybe (MDRef DIScope) Word32 Word64 ShortByteString $sel:sizeInBits:DIArrayType :: DICompositeType -> Word64 $sel:alignInBits:DIArrayType :: DICompositeType -> Word32 scope :: Maybe (MDRef DIScope) name :: ShortByteString file :: Maybe (MDRef DIFile) line :: Word32 values :: [DIEnumerator] baseType :: Maybe (MDRef DIType) identifier :: ShortByteString sizeInBits :: Word64 alignInBits :: Word32 $sel:scope:DIArrayType :: DICompositeType -> Maybe (MDRef DIScope) $sel:name:DIArrayType :: DICompositeType -> ShortByteString $sel:file:DIArrayType :: DICompositeType -> Maybe (MDRef DIFile) $sel:line:DIArrayType :: DICompositeType -> Word32 $sel:identifier:DIArrayType :: DICompositeType -> ShortByteString $sel:values:DIArrayType :: DICompositeType -> [DIEnumerator] $sel:baseType:DIArrayType :: DICompositeType -> Maybe (MDRef DIType) ..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIFile) file TupleArray DIEnumerator elements <- [DIEnumerator] -> EncodeAST (TupleArray DIEnumerator) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DIEnumerator] values Ptr DIType underlyingType <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIType) baseType Ptr MDString identifier <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString identifier Context 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 a. IO a -> EncodeAST a 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 {[DIFlag] [MDRef (Either DIDerivedType DISubprogram)] Maybe (MDRef DIType) Maybe (MDRef DIFile) Maybe (MDRef DIScope) Word16 Word32 Word64 ShortByteString $sel:sizeInBits:DIArrayType :: DICompositeType -> Word64 $sel:alignInBits:DIArrayType :: DICompositeType -> Word32 $sel:flags:DIArrayType :: DICompositeType -> [DIFlag] $sel:scope:DIArrayType :: DICompositeType -> Maybe (MDRef DIScope) $sel:name:DIArrayType :: DICompositeType -> ShortByteString $sel:file:DIArrayType :: DICompositeType -> Maybe (MDRef DIFile) $sel:line:DIArrayType :: DICompositeType -> Word32 $sel:identifier:DIArrayType :: DICompositeType -> ShortByteString scope :: Maybe (MDRef DIScope) name :: ShortByteString file :: Maybe (MDRef DIFile) line :: Word32 flags :: [DIFlag] derivedFrom :: Maybe (MDRef DIType) elements :: [MDRef (Either DIDerivedType DISubprogram)] runtimeLang :: Word16 vtableHolder :: Maybe (MDRef DIType) identifier :: ShortByteString sizeInBits :: Word64 alignInBits :: Word32 $sel:derivedFrom:DIArrayType :: DICompositeType -> Maybe (MDRef DIType) $sel:elements:DIArrayType :: DICompositeType -> [MDRef (Either DIDerivedType DISubprogram)] $sel:vtableHolder:DIArrayType :: DICompositeType -> Maybe (MDRef DIType) $sel:runtimeLang:DIArrayType :: DICompositeType -> Word16 ..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIFile) file DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DIFlag] flags Ptr DIType derivedFrom <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIType) derivedFrom TupleArray DIScope elements <- [MDRef DIScope] -> EncodeAST (TupleArray DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => 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, HasCallStack) => h -> e c encodeM Maybe (MDRef DIType) vtableHolder Ptr MDString identifier <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString identifier Context 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 a. IO a -> EncodeAST a 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 {[DIFlag] [MDRef (Either DIDerivedType DISubprogram)] Maybe (MDRef DIFile) Maybe (MDRef DIScope) Word16 Word32 Word64 ShortByteString $sel:sizeInBits:DIArrayType :: DICompositeType -> Word64 $sel:alignInBits:DIArrayType :: DICompositeType -> Word32 $sel:flags:DIArrayType :: DICompositeType -> [DIFlag] $sel:scope:DIArrayType :: DICompositeType -> Maybe (MDRef DIScope) $sel:name:DIArrayType :: DICompositeType -> ShortByteString $sel:file:DIArrayType :: DICompositeType -> Maybe (MDRef DIFile) $sel:line:DIArrayType :: DICompositeType -> Word32 $sel:identifier:DIArrayType :: DICompositeType -> ShortByteString $sel:elements:DIArrayType :: DICompositeType -> [MDRef (Either DIDerivedType DISubprogram)] $sel:runtimeLang:DIArrayType :: DICompositeType -> Word16 scope :: Maybe (MDRef DIScope) name :: ShortByteString file :: Maybe (MDRef DIFile) line :: Word32 flags :: [DIFlag] elements :: [MDRef (Either DIDerivedType DISubprogram)] runtimeLang :: Word16 identifier :: ShortByteString sizeInBits :: Word64 alignInBits :: Word32 ..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIFile) file DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DIFlag] flags TupleArray DIScope elements <- [MDRef DIScope] -> EncodeAST (TupleArray DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => 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, HasCallStack) => h -> e c encodeM ShortByteString identifier Context 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 a. IO a -> EncodeAST a 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 {[DITemplateParameter] [DIFlag] [MDRef (Either DIDerivedType DISubprogram)] Maybe (MDRef DIType) Maybe (MDRef DIFile) Maybe (MDRef DIScope) Word32 Word64 ShortByteString $sel:sizeInBits:DIArrayType :: DICompositeType -> Word64 $sel:alignInBits:DIArrayType :: DICompositeType -> Word32 $sel:flags:DIArrayType :: DICompositeType -> [DIFlag] $sel:scope:DIArrayType :: DICompositeType -> Maybe (MDRef DIScope) $sel:name:DIArrayType :: DICompositeType -> ShortByteString $sel:file:DIArrayType :: DICompositeType -> Maybe (MDRef DIFile) $sel:line:DIArrayType :: DICompositeType -> Word32 $sel:identifier:DIArrayType :: DICompositeType -> ShortByteString $sel:derivedFrom:DIArrayType :: DICompositeType -> Maybe (MDRef DIType) $sel:elements:DIArrayType :: DICompositeType -> [MDRef (Either DIDerivedType DISubprogram)] $sel:vtableHolder:DIArrayType :: DICompositeType -> Maybe (MDRef DIType) scope :: Maybe (MDRef DIScope) name :: ShortByteString file :: Maybe (MDRef DIFile) line :: Word32 flags :: [DIFlag] derivedFrom :: Maybe (MDRef DIType) elements :: [MDRef (Either DIDerivedType DISubprogram)] vtableHolder :: Maybe (MDRef DIType) templateParams :: [DITemplateParameter] identifier :: ShortByteString sizeInBits :: Word64 alignInBits :: Word32 $sel:templateParams:DIArrayType :: DICompositeType -> [DITemplateParameter] ..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIFile) file DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DIFlag] flags Ptr DIType derivedFrom <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIType) derivedFrom TupleArray DIScope elements <- [MDRef DIScope] -> EncodeAST (TupleArray DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => 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, HasCallStack) => h -> e c encodeM Maybe (MDRef DIType) vtableHolder TupleArray DITemplateParameter params <- [DITemplateParameter] -> EncodeAST (TupleArray DITemplateParameter) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DITemplateParameter] templateParams Ptr MDString identifier <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString identifier Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DIType -> DecodeAST DIType decodeM Ptr DIType diTy = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall a. IO a -> DecodeAST a 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 MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIType -> Ptr DIBasicType forall a b. Ptr a -> Ptr b castPtr Ptr DIType diTy :: Ptr FFI.DIBasicType) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIType -> Ptr DICompositeType forall a b. Ptr a -> Ptr b castPtr Ptr DIType diTy :: Ptr FFI.DICompositeType) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIType -> Ptr DIDerivedType forall a b. Ptr a -> Ptr b castPtr Ptr DIType diTy :: Ptr FFI.DIDerivedType) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIType -> Ptr DISubroutineType forall a b. Ptr a -> Ptr b castPtr Ptr DIType diTy :: Ptr FFI.DISubroutineType) MDSubclassID _ -> DecodeException -> DecodeAST DIType forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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 :: HasCallStack => Ptr DIBasicType -> DecodeAST DIBasicType decodeM Ptr DIBasicType diTy = do BasicTypeTag tag <- DwTag -> DecodeAST BasicTypeTag forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. a -> DecodeAST a 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 :: HasCallStack => DIBasicType -> EncodeAST (Ptr DIBasicType) encodeM A.BasicType {[DIFlag] Maybe Encoding Word32 Word64 ShortByteString BasicTypeTag name :: ShortByteString sizeInBits :: Word64 alignInBits :: Word32 encoding :: Maybe Encoding tag :: BasicTypeTag flags :: [DIFlag] $sel:name:BasicType :: DIBasicType -> ShortByteString $sel:sizeInBits:BasicType :: DIBasicType -> Word64 $sel:alignInBits:BasicType :: DIBasicType -> Word32 $sel:encoding:BasicType :: DIBasicType -> Maybe Encoding $sel:tag:BasicType :: DIBasicType -> BasicTypeTag $sel:flags:BasicType :: DIBasicType -> [DIFlag] ..} = do DwTag tag <- BasicTypeTag -> EncodeAST DwTag forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM BasicTypeTag tag Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Encoding encoding <- Maybe Encoding -> EncodeAST Encoding forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe Encoding encoding DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DIFlag] flags Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => DISubroutineType -> EncodeAST (Ptr DISubroutineType) encodeM A.SubroutineType {[Maybe (MDRef DIType)] [DIFlag] Word8 flags :: [DIFlag] cc :: Word8 typeArray :: [Maybe (MDRef DIType)] $sel:flags:SubroutineType :: DISubroutineType -> [DIFlag] $sel:cc:SubroutineType :: DISubroutineType -> Word8 $sel:typeArray:SubroutineType :: DISubroutineType -> [Maybe (MDRef DIType)] ..} = do DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DIFlag] flags TupleArray DIType types <- [Maybe (MDRef DIType)] -> EncodeAST (TupleArray DIType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [Maybe (MDRef DIType)] typeArray Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DISubroutineType -> DecodeAST DISubroutineType decodeM Ptr DISubroutineType p = do [DIFlag] flags <- DIFlags -> DecodeAST [DIFlag] forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubroutineType -> IO (TupleArray DIType) FFI.getSubroutineTypeArray Ptr DISubroutineType p) DISubroutineType -> DecodeAST DISubroutineType forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure 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 :: HasCallStack => DIDerivedType -> EncodeAST (Ptr DIDerivedType) encodeM A.DerivedType {[DIFlag] Maybe Word32 Maybe (MDRef DIType) Maybe (MDRef DIFile) Maybe (MDRef DIScope) Word32 Word64 ShortByteString DerivedTypeTag tag :: DerivedTypeTag name :: ShortByteString file :: Maybe (MDRef DIFile) line :: Word32 scope :: Maybe (MDRef DIScope) baseType :: Maybe (MDRef DIType) sizeInBits :: Word64 alignInBits :: Word32 offsetInBits :: Word64 addressSpace :: Maybe Word32 flags :: [DIFlag] $sel:tag:DerivedType :: DIDerivedType -> DerivedTypeTag $sel:name:DerivedType :: DIDerivedType -> ShortByteString $sel:file:DerivedType :: DIDerivedType -> Maybe (MDRef DIFile) $sel:line:DerivedType :: DIDerivedType -> Word32 $sel:scope:DerivedType :: DIDerivedType -> Maybe (MDRef DIScope) $sel:baseType:DerivedType :: DIDerivedType -> Maybe (MDRef DIType) $sel:sizeInBits:DerivedType :: DIDerivedType -> Word64 $sel:alignInBits:DerivedType :: DIDerivedType -> Word32 $sel:offsetInBits:DerivedType :: DIDerivedType -> Word64 $sel:addressSpace:DerivedType :: DIDerivedType -> Maybe Word32 $sel:flags:DerivedType :: DIDerivedType -> [DIFlag] ..} = do DwTag tag <- DerivedTypeTag -> EncodeAST DwTag forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DerivedTypeTag tag Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIFile) file CUInt line <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Word32 line Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => 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, HasCallStack) => h -> e c encodeM Maybe (MDRef DIType) baseType (Word32 addrSpace, LLVMBool addrSpacePresent) <- Maybe Word32 -> EncodeAST (Word32, LLVMBool) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe Word32 addressSpace DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DIFlag] flags Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DIDerivedType -> DecodeAST DIDerivedType decodeM 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure 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 } instance EncodeM EncodeAST A.DIVariable (Ptr FFI.DIVariable) where encodeM :: HasCallStack => DIVariable -> EncodeAST (Ptr DIVariable) encodeM (A.DIGlobalVariable DIGlobalVariable v) = do Ptr DIGlobalVariable ptr <- DIGlobalVariable -> EncodeAST (Ptr DIGlobalVariable) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DIGlobalVariable v Ptr DIVariable -> EncodeAST (Ptr DIVariable) forall a. a -> EncodeAST a 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 DILocalVariable v) = do Ptr DILocalVariable ptr <- DILocalVariable -> EncodeAST (Ptr DILocalVariable) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DILocalVariable v Ptr DIVariable -> EncodeAST (Ptr DIVariable) forall a. a -> EncodeAST a 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 :: HasCallStack => Ptr DIVariable -> DecodeAST DIVariable decodeM Ptr DIVariable p = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall a. IO a -> DecodeAST a 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 MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIVariable -> Ptr DIGlobalVariable forall a b. Ptr a -> Ptr b castPtr Ptr DIVariable p :: Ptr FFI.DIGlobalVariable) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DIVariable -> Ptr DILocalVariable forall a b. Ptr a -> Ptr b castPtr Ptr DIVariable p :: Ptr FFI.DILocalVariable) MDSubclassID _ -> DecodeException -> DecodeAST DIVariable forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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 :: HasCallStack => Ptr DIGlobalVariable -> DecodeAST DIGlobalVariable decodeM Ptr DIGlobalVariable p = do ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIGlobalVariable -> IO (Ptr DIDerivedType) FFI.getDIGlobalVariableStaticDataMemberDeclaration Ptr DIGlobalVariable p) DIGlobalVariable -> DecodeAST DIGlobalVariable forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure 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 :: HasCallStack => DIGlobalVariable -> EncodeAST (Ptr DIGlobalVariable) encodeM A.GlobalVariable {Bool [MDRef DITemplateParameter] Maybe (MDRef DIDerivedType) Maybe (MDRef DIType) Maybe (MDRef DIFile) Maybe (MDRef DIScope) Word32 ShortByteString $sel:name:GlobalVariable :: DIGlobalVariable -> ShortByteString $sel:scope:GlobalVariable :: DIGlobalVariable -> Maybe (MDRef DIScope) $sel:file:GlobalVariable :: DIGlobalVariable -> Maybe (MDRef DIFile) $sel:line:GlobalVariable :: DIGlobalVariable -> Word32 $sel:type':GlobalVariable :: DIGlobalVariable -> Maybe (MDRef DIType) $sel:linkageName:GlobalVariable :: DIGlobalVariable -> ShortByteString $sel:local:GlobalVariable :: DIGlobalVariable -> Bool $sel:definition:GlobalVariable :: DIGlobalVariable -> Bool $sel:staticDataMemberDeclaration:GlobalVariable :: DIGlobalVariable -> Maybe (MDRef DIDerivedType) $sel:templateParams:GlobalVariable :: DIGlobalVariable -> [MDRef DITemplateParameter] $sel:alignInBits:GlobalVariable :: DIGlobalVariable -> Word32 name :: ShortByteString scope :: Maybe (MDRef DIScope) file :: Maybe (MDRef DIFile) line :: Word32 type' :: Maybe (MDRef DIType) linkageName :: ShortByteString local :: Bool definition :: Bool staticDataMemberDeclaration :: Maybe (MDRef DIDerivedType) templateParams :: [MDRef DITemplateParameter] alignInBits :: Word32 ..} = do Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => 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, HasCallStack) => h -> e c encodeM Maybe (MDRef DIFile) file CUInt line <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Word32 line Ptr DIType type' <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIType) type' Ptr MDString linkageName <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString linkageName LLVMBool local <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Bool local LLVMBool definition <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Bool definition Ptr DIDerivedType dataMemberDeclaration <- Maybe (MDRef DIDerivedType) -> EncodeAST (Ptr DIDerivedType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIDerivedType) staticDataMemberDeclaration TupleArray DITemplateParameter templateParams <- [MDRef DITemplateParameter] -> EncodeAST (TupleArray DITemplateParameter) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [MDRef DITemplateParameter] templateParams Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DILocalVariable -> DecodeAST DILocalVariable decodeM Ptr DILocalVariable p = do ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILocalVariable -> IO DIFlags FFI.getDILocalVariableFlags Ptr DILocalVariable p) DILocalVariable -> DecodeAST DILocalVariable forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure 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 :: HasCallStack => DILocalVariable -> EncodeAST (Ptr DILocalVariable) encodeM A.LocalVariable {[DIFlag] Maybe (MDRef DIType) Maybe (MDRef DIFile) Word16 Word32 ShortByteString MDRef DIScope $sel:file:LocalVariable :: DILocalVariable -> Maybe (MDRef DIFile) $sel:scope:LocalVariable :: DILocalVariable -> MDRef DIScope $sel:name:LocalVariable :: DILocalVariable -> ShortByteString $sel:line:LocalVariable :: DILocalVariable -> Word32 $sel:arg:LocalVariable :: DILocalVariable -> Word16 $sel:flags:LocalVariable :: DILocalVariable -> [DIFlag] $sel:type':LocalVariable :: DILocalVariable -> Maybe (MDRef DIType) $sel:alignInBits:LocalVariable :: DILocalVariable -> Word32 name :: ShortByteString scope :: MDRef DIScope file :: Maybe (MDRef DIFile) line :: Word32 type' :: Maybe (MDRef DIType) flags :: [DIFlag] arg :: Word16 alignInBits :: Word32 ..} = do CString name <- ShortByteString -> EncodeAST CString forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr DIScope scope <- MDRef DIScope -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM MDRef DIScope scope Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => 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, HasCallStack) => h -> e c encodeM Maybe (MDRef DIType) type' DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DIFlag] flags Context 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 a. IO a -> EncodeAST a 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) getDITemplateParameterName :: A.DITemplateParameter -> ShortByteString getDITemplateParameterName :: DITemplateParameter -> ShortByteString getDITemplateParameterName A.DITemplateTypeParameter {Maybe (MDRef DIType) ShortByteString name :: ShortByteString type' :: Maybe (MDRef DIType) $sel:name:DITemplateTypeParameter :: DITemplateParameter -> ShortByteString $sel:type':DITemplateTypeParameter :: DITemplateParameter -> Maybe (MDRef DIType) ..} = ShortByteString name getDITemplateParameterName A.DITemplateValueParameter{Maybe (MDRef DIType) Maybe Metadata ShortByteString TemplateValueParameterTag $sel:name:DITemplateTypeParameter :: DITemplateParameter -> ShortByteString $sel:type':DITemplateTypeParameter :: DITemplateParameter -> Maybe (MDRef DIType) name :: ShortByteString type' :: Maybe (MDRef DIType) value :: Maybe Metadata tag :: TemplateValueParameterTag $sel:value:DITemplateTypeParameter :: DITemplateParameter -> Maybe Metadata $sel:tag:DITemplateTypeParameter :: DITemplateParameter -> TemplateValueParameterTag ..} = ShortByteString name getDITemplateParameterType :: A.DITemplateParameter -> Maybe (A.MDRef A.DIType) getDITemplateParameterType :: DITemplateParameter -> Maybe (MDRef DIType) getDITemplateParameterType A.DITemplateTypeParameter {Maybe (MDRef DIType) ShortByteString $sel:name:DITemplateTypeParameter :: DITemplateParameter -> ShortByteString $sel:type':DITemplateTypeParameter :: DITemplateParameter -> Maybe (MDRef DIType) name :: ShortByteString type' :: Maybe (MDRef DIType) ..} = Maybe (MDRef DIType) type' getDITemplateParameterType A.DITemplateValueParameter{Maybe (MDRef DIType) Maybe Metadata ShortByteString TemplateValueParameterTag $sel:name:DITemplateTypeParameter :: DITemplateParameter -> ShortByteString $sel:type':DITemplateTypeParameter :: DITemplateParameter -> Maybe (MDRef DIType) $sel:value:DITemplateTypeParameter :: DITemplateParameter -> Maybe Metadata $sel:tag:DITemplateTypeParameter :: DITemplateParameter -> TemplateValueParameterTag name :: ShortByteString type' :: Maybe (MDRef DIType) value :: Maybe Metadata tag :: TemplateValueParameterTag ..} = Maybe (MDRef DIType) type' instance EncodeM EncodeAST A.DITemplateParameter (Ptr FFI.DITemplateParameter) where encodeM :: HasCallStack => DITemplateParameter -> EncodeAST (Ptr DITemplateParameter) encodeM DITemplateParameter p = do Ptr MDString name' <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM (DITemplateParameter -> ShortByteString getDITemplateParameterName DITemplateParameter p) :: EncodeAST (Ptr FFI.MDString) Ptr DIType ty <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM (DITemplateParameter -> Maybe (MDRef DIType) getDITemplateParameterType DITemplateParameter p) Context 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 a. IO a -> EncodeAST a 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 {Maybe (MDRef DIType) Maybe Metadata ShortByteString TemplateValueParameterTag $sel:name:DITemplateTypeParameter :: DITemplateParameter -> ShortByteString $sel:type':DITemplateTypeParameter :: DITemplateParameter -> Maybe (MDRef DIType) $sel:value:DITemplateTypeParameter :: DITemplateParameter -> Maybe Metadata $sel:tag:DITemplateTypeParameter :: DITemplateParameter -> TemplateValueParameterTag name :: ShortByteString type' :: Maybe (MDRef DIType) value :: Maybe Metadata tag :: TemplateValueParameterTag ..} -> do DwTag tag <- TemplateValueParameterTag -> EncodeAST DwTag forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM TemplateValueParameterTag tag Ptr Metadata value <- Maybe Metadata -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => 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 a. IO a -> EncodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr Context -> Ptr MDString -> Ptr DIType -> DwTag -> Bool -> Ptr Metadata -> IO (Ptr DITemplateValueParameter) FFI.getDITemplateValueParameter Ptr Context c Ptr MDString name' Ptr DIType ty DwTag tag Bool True Ptr Metadata value) instance DecodeM DecodeAST A.DITemplateParameter (Ptr FFI.DITemplateParameter) where decodeM :: HasCallStack => Ptr DITemplateParameter -> DecodeAST DITemplateParameter decodeM Ptr DITemplateParameter p = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DITemplateParameter -> IO (Ptr DIType) FFI.getDITemplateParameterType Ptr DITemplateParameter p) case MDSubclassID sId of MDSubclassID [mdSubclassIdP|DITemplateTypeParameter|] -> DITemplateParameter -> DecodeAST DITemplateParameter forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (ShortByteString -> Maybe (MDRef DIType) -> DITemplateParameter A.DITemplateTypeParameter ShortByteString name Maybe (MDRef DIType) ty) MDSubclassID [mdSubclassIdP|DITemplateValueParameter|] -> do Maybe Metadata value <- Ptr Metadata -> DecodeAST (Maybe Metadata) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. a -> DecodeAST a 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) MDSubclassID _ -> DecodeException -> DecodeAST DITemplateParameter forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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)) instance DecodeM DecodeAST A.DISubprogram (Ptr FFI.DISubprogram) where decodeM :: HasCallStack => Ptr DISubprogram -> DecodeAST DISubprogram decodeM 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DISubprogram -> IO (Ptr DISubprogram) FFI.getDISubprogramDeclaration Ptr DISubprogram p) DISubprogram -> DecodeAST DISubprogram forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure 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 :: HasCallStack => DISubprogram -> EncodeAST (Ptr DISubprogram) encodeM A.Subprogram {Bool Int32 [DIFlag] [MDRef DILocalVariable] [MDRef DITemplateParameter] [MDRef DIType] Maybe (MDRef DISubroutineType) Maybe (MDRef DIType) Maybe (MDRef DISubprogram) Maybe (MDRef DIFile) Maybe (MDRef DICompileUnit) Maybe (MDRef DIScope) Word32 ShortByteString Virtuality $sel:name:Subprogram :: DISubprogram -> ShortByteString $sel:linkageName:Subprogram :: DISubprogram -> ShortByteString $sel:scope:Subprogram :: DISubprogram -> Maybe (MDRef DIScope) $sel:file:Subprogram :: DISubprogram -> Maybe (MDRef DIFile) $sel:line:Subprogram :: DISubprogram -> Word32 $sel:type':Subprogram :: DISubprogram -> Maybe (MDRef DISubroutineType) $sel:definition:Subprogram :: DISubprogram -> Bool $sel:scopeLine:Subprogram :: DISubprogram -> Word32 $sel:containingType:Subprogram :: DISubprogram -> Maybe (MDRef DIType) $sel:virtuality:Subprogram :: DISubprogram -> Virtuality $sel:virtualityIndex:Subprogram :: DISubprogram -> Word32 $sel:flags:Subprogram :: DISubprogram -> [DIFlag] $sel:optimized:Subprogram :: DISubprogram -> Bool $sel:unit:Subprogram :: DISubprogram -> Maybe (MDRef DICompileUnit) $sel:templateParams:Subprogram :: DISubprogram -> [MDRef DITemplateParameter] $sel:declaration:Subprogram :: DISubprogram -> Maybe (MDRef DISubprogram) $sel:retainedNodes:Subprogram :: DISubprogram -> [MDRef DILocalVariable] $sel:thrownTypes:Subprogram :: DISubprogram -> [MDRef DIType] $sel:localToUnit:Subprogram :: DISubprogram -> Bool $sel:thisAdjustment:Subprogram :: DISubprogram -> Int32 scope :: Maybe (MDRef DIScope) name :: ShortByteString linkageName :: ShortByteString file :: Maybe (MDRef DIFile) line :: Word32 type' :: Maybe (MDRef DISubroutineType) localToUnit :: Bool definition :: Bool scopeLine :: Word32 containingType :: Maybe (MDRef DIType) virtuality :: Virtuality virtualityIndex :: Word32 thisAdjustment :: Int32 flags :: [DIFlag] optimized :: Bool unit :: Maybe (MDRef DICompileUnit) templateParams :: [MDRef DITemplateParameter] declaration :: Maybe (MDRef DISubprogram) retainedNodes :: [MDRef DILocalVariable] thrownTypes :: [MDRef DIType] ..} = do Ptr DIScope scope <- Maybe (MDRef DIScope) -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIScope) scope Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr MDString linkageName <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString linkageName Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIFile) file CUInt line <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Word32 line Ptr DISubroutineType type' <- Maybe (MDRef DISubroutineType) -> EncodeAST (Ptr DISubroutineType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DISubroutineType) type' LLVMBool localToUnit <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Bool localToUnit LLVMBool definition <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Bool definition CUInt scopeLine <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Word32 scopeLine Ptr DIType containingType <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIType) containingType DwVirtuality virtuality <- Virtuality -> EncodeAST DwVirtuality forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Virtuality virtuality CUInt virtualityIndex <- Word32 -> EncodeAST CUInt forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Word32 virtualityIndex DIFlags flags <- [DIFlag] -> EncodeAST DIFlags forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [DIFlag] flags LLVMBool optimized <- Bool -> EncodeAST LLVMBool forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Bool optimized Ptr DICompileUnit unit <- Maybe (MDRef DICompileUnit) -> EncodeAST (Ptr DICompileUnit) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DICompileUnit) unit TupleArray DITemplateParameter templateParams <- [MDRef DITemplateParameter] -> EncodeAST (TupleArray DITemplateParameter) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [MDRef DITemplateParameter] templateParams Ptr DISubprogram declaration <- Maybe (MDRef DISubprogram) -> EncodeAST (Ptr DISubprogram) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DISubprogram) declaration TupleArray DILocalVariable retainedNodes <- [MDRef DILocalVariable] -> EncodeAST (TupleArray DILocalVariable) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [MDRef DILocalVariable] retainedNodes TupleArray DIType thrownTypes <- [MDRef DIType] -> EncodeAST (TupleArray DIType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [MDRef DIType] thrownTypes Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DILocalScope -> DecodeAST DILocalScope decodeM Ptr DILocalScope ls = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall a. IO a -> DecodeAST a 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 MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DILocalScope -> Ptr DISubprogram forall a b. Ptr a -> Ptr b castPtr Ptr DILocalScope ls :: Ptr FFI.DISubprogram) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DILocalScope -> Ptr DILexicalBlockBase forall a b. Ptr a -> Ptr b castPtr Ptr DILocalScope ls :: Ptr FFI.DILexicalBlockBase) MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr DILocalScope -> Ptr DILexicalBlockBase forall a b. Ptr a -> Ptr b castPtr Ptr DILocalScope ls :: Ptr FFI.DILexicalBlockBase) MDSubclassID _ -> DecodeException -> DecodeAST DILocalScope forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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 :: HasCallStack => DILocalScope -> EncodeAST (Ptr DILocalScope) encodeM (A.DISubprogram DISubprogram sp) = do Ptr DISubprogram ptr <- DISubprogram -> EncodeAST (Ptr DISubprogram) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DISubprogram sp Ptr DILocalScope -> EncodeAST (Ptr DILocalScope) forall a. a -> EncodeAST a 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 DILexicalBlockBase b) = do Ptr DILexicalBlockBase ptr <- DILexicalBlockBase -> EncodeAST (Ptr DILexicalBlockBase) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DILexicalBlockBase b Ptr DILocalScope -> EncodeAST (Ptr DILocalScope) forall a. a -> EncodeAST a 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 :: HasCallStack => Ptr DILexicalBlockBase -> DecodeAST DILexicalBlockBase decodeM Ptr DILexicalBlockBase p = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall a. IO a -> DecodeAST a 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 MDSubclassID [mdSubclassIdP|DILexicalBlock|] -> do MDRef DILocalScope scope <- Ptr DILocalScope -> DecodeAST (MDRef DILocalScope) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILexicalBlockBase -> IO Word16 FFI.getLexicalBlockColumn Ptr DILexicalBlockBase p) DILexicalBlockBase -> DecodeAST DILexicalBlockBase forall a. a -> DecodeAST a 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) MDSubclassID [mdSubclassIdP|DILexicalBlockFile|] -> do MDRef DILocalScope scope <- Ptr DILocalScope -> DecodeAST (MDRef DILocalScope) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILexicalBlockBase -> IO Word32 FFI.getLexicalBlockFileDiscriminator Ptr DILexicalBlockBase p) DILexicalBlockBase -> DecodeAST DILexicalBlockBase forall a. a -> DecodeAST a 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) MDSubclassID _ -> DecodeException -> DecodeAST DILexicalBlockBase forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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 :: HasCallStack => DILexicalBlockBase -> EncodeAST (Ptr DILexicalBlockBase) encodeM A.DILexicalBlock {Maybe (MDRef DIFile) Word16 Word32 MDRef DILocalScope scope :: MDRef DILocalScope file :: Maybe (MDRef DIFile) line :: Word32 column :: Word16 $sel:scope:DILexicalBlock :: DILexicalBlockBase -> MDRef DILocalScope $sel:file:DILexicalBlock :: DILexicalBlockBase -> Maybe (MDRef DIFile) $sel:line:DILexicalBlock :: DILexicalBlockBase -> Word32 $sel:column:DILexicalBlock :: DILexicalBlockBase -> Word16 ..} = do Ptr DILocalScope scope <- MDRef DILocalScope -> EncodeAST (Ptr DILocalScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM MDRef DILocalScope scope Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIFile) file Context 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 a. IO a -> EncodeAST a 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 {Maybe (MDRef DIFile) Word32 MDRef DILocalScope $sel:scope:DILexicalBlock :: DILexicalBlockBase -> MDRef DILocalScope $sel:file:DILexicalBlock :: DILexicalBlockBase -> Maybe (MDRef DIFile) scope :: MDRef DILocalScope file :: Maybe (MDRef DIFile) discriminator :: Word32 $sel:discriminator:DILexicalBlock :: DILexicalBlockBase -> Word32 ..} = do Ptr DILocalScope scope <- MDRef DILocalScope -> EncodeAST (Ptr DILocalScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM MDRef DILocalScope scope Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIFile) file Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr Value -> DecodeAST CallableOperand decodeM Ptr Value v = do Ptr InlineAsm ia <- IO (Ptr InlineAsm) -> DecodeAST (Ptr InlineAsm) forall a. IO a -> DecodeAST a 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, HasCallStack) => 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, HasCallStack) => c -> d h decodeM Ptr Value v instance EncodeM EncodeAST A.Operand (Ptr FFI.Value) where encodeM :: HasCallStack => Operand -> EncodeAST (Ptr Value) encodeM (A.ConstantOperand Constant c) = do Ptr Constant c' <- (Constant -> EncodeAST (Ptr Constant) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM :: A.Constant -> EncodeAST (Ptr FFI.Constant)) Constant c let v :: Ptr Value v = (Ptr Constant -> Ptr Value forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast :: Ptr FFI.Constant -> Ptr FFI.Value) Ptr Constant c' Ptr Value -> EncodeAST (Ptr Value) forall a. a -> EncodeAST a forall (m :: * -> *) a. Monad m => a -> m a return Ptr Value v encodeM (A.LocalReference Type t 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, HasCallStack) => h -> e c encodeM Name n Ptr Type t <- Type -> EncodeAST (Ptr Type) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Type t Ptr Value v <- IO (Ptr Value) -> EncodeAST (Ptr Value) forall a. IO a -> EncodeAST a 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 a. a -> EncodeAST a 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 $ \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 a. a -> EncodeAST a forall (m :: * -> *) a. Monad m => a -> m a return LocalValue lv Ptr Value -> EncodeAST (Ptr Value) forall a. a -> EncodeAST a 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 Ptr Value v -> Ptr Value v; ForwardValue Ptr Value v -> Ptr Value v encodeM (A.MetadataOperand Metadata md) = do Ptr Metadata md' <- Metadata -> EncodeAST (Ptr Metadata) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Metadata md Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Metadata -> EncodeAST (Ptr Metadata) encodeM (A.MDString ShortByteString s) = do Context 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, HasCallStack) => 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 a. IO a -> EncodeAST a 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 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, HasCallStack) => h -> e c encodeM MDRef MDNode mdn encodeM (A.MDValue Operand v) = do Ptr Value v <- Operand -> EncodeAST (Ptr Value) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Operand v Ptr MDValue mdVal <- IO (Ptr MDValue) -> EncodeAST (Ptr MDValue) forall a. IO a -> EncodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Ptr MDValue) -> EncodeAST (Ptr MDValue)) -> IO (Ptr MDValue) -> EncodeAST (Ptr MDValue) forall a b. (a -> b) -> a -> b $ Ptr Value -> IO (Ptr MDValue) FFI.mdValue Ptr Value v Ptr Metadata -> EncodeAST (Ptr Metadata) forall a. a -> EncodeAST a forall (m :: * -> *) a. Monad m => a -> m a return (Ptr Metadata -> EncodeAST (Ptr Metadata)) -> Ptr Metadata -> EncodeAST (Ptr Metadata) forall a b. (a -> b) -> a -> b $ Ptr MDValue -> Ptr Metadata forall a b. DescendentOf a b => Ptr b -> Ptr a FFI.upCast Ptr MDValue mdVal instance EncodeM EncodeAST A.CallableOperand (Ptr FFI.Value) where encodeM :: HasCallStack => CallableOperand -> EncodeAST (Ptr Value) encodeM (Right Operand o) = Operand -> EncodeAST (Ptr Value) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Operand o encodeM (Left 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, HasCallStack) => h -> e c encodeM InlineAssembly i instance EncodeM EncodeAST A.MDNode (Ptr FFI.MDNode) where encodeM :: HasCallStack => MDNode -> EncodeAST (Ptr MDNode) encodeM (A.MDTuple [Maybe Metadata] ops) = EncodeAST (Ptr MDNode) -> EncodeAST (Ptr MDNode) forall a. EncodeAST a -> EncodeAST a 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 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, HasCallStack) => 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 a. IO a -> EncodeAST a 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 DINode n) = do Ptr DINode ptr <- DINode -> EncodeAST (Ptr DINode) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DINode n Ptr MDNode -> EncodeAST (Ptr MDNode) forall a. a -> EncodeAST a 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 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, HasCallStack) => h -> e c encodeM DILocation l :: EncodeAST (Ptr FFI.DILocation)) encodeM (A.DIExpression 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, HasCallStack) => h -> e c encodeM DIExpression e :: EncodeAST (Ptr FFI.DIExpression)) encodeM (A.DIGlobalVariableExpression 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, HasCallStack) => h -> e c encodeM DIGlobalVariableExpression e :: EncodeAST (Ptr FFI.DIGlobalVariableExpression)) encodeM (A.DIMacroNode 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, HasCallStack) => h -> e c encodeM DIMacroNode n :: EncodeAST (Ptr FFI.DIMacroNode)) instance EncodeM EncodeAST A.DILocation (Ptr FFI.DILocation) where encodeM :: HasCallStack => DILocation -> EncodeAST (Ptr DILocation) encodeM A.Location {Word16 Word32 MDRef DILocalScope line :: Word32 column :: Word16 scope :: MDRef DILocalScope $sel:line:Location :: DILocation -> Word32 $sel:column:Location :: DILocation -> Word16 $sel:scope:Location :: DILocation -> MDRef DILocalScope ..} = do Context 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, HasCallStack) => h -> e c encodeM MDRef DILocalScope scope IO (Ptr DILocation) -> EncodeAST (Ptr DILocation) forall a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DILocation -> DecodeAST DILocation decodeM Ptr DILocation p = do Word32 line <- IO Word32 -> DecodeAST Word32 forall a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DILocation -> IO (Ptr DILocalScope) FFI.getDILocationScope Ptr DILocation p) DILocation -> DecodeAST DILocation forall a. a -> DecodeAST a 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 :: HasCallStack => [a] -> m (TupleArray a') encodeM [] = TupleArray a' -> m (TupleArray a') forall a. a -> m 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 [a] els = do (CUInt numEls, Ptr (Ptr a') elsPtr) <- [a] -> m (CUInt, Ptr (Ptr a')) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [a] els Context 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 a. IO a -> m a 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 :: HasCallStack => TupleArray a' -> m [a] decodeM (FFI.TupleArray 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 a. a -> m a forall (f :: * -> *) a. Applicative f => a -> f a pure [] | Bool otherwise = do (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 Ptr MDNode md 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 DWOp op = case DWOp op of DWOp A.DW_OP_And -> [Word64 FFI.DwOp_and] DWOp A.DW_OP_Bregx -> [Word64 FFI.DwOp_bregx] A.DW_OP_ConstU Word64 arg -> [Word64 FFI.DwOp_constu, Word64 arg] DWOp A.DW_OP_Deref -> [Word64 FFI.DwOp_deref] DWOp A.DW_OP_Div -> [Word64 FFI.DwOp_div] DWOp A.DW_OP_Dup -> [Word64 FFI.DwOp_dup] A.DwOpFragment (A.DW_OP_LLVM_Fragment Word64 offset Word64 size) -> [Word64 FFI.DwOp_LLVM_fragment, Word64 offset, Word64 size] DWOp A.DW_OP_Lit0 -> [Word64 FFI.DwOp_lit0] DWOp A.DW_OP_Minus -> [Word64 FFI.DwOp_minus] DWOp A.DW_OP_Mod -> [Word64 FFI.DwOp_mod] DWOp A.DW_OP_Mul -> [Word64 FFI.DwOp_mul] DWOp A.DW_OP_Not -> [Word64 FFI.DwOp_not] DWOp A.DW_OP_Or -> [Word64 FFI.DwOp_or] DWOp A.DW_OP_Plus -> [Word64 FFI.DwOp_plus] A.DW_OP_PlusUConst Word64 arg -> [Word64 FFI.DwOp_plus_uconst, Word64 arg] DWOp A.DW_OP_PushObjectAddress -> [Word64 FFI.DwOp_push_object_address] DWOp A.DW_OP_Shl -> [Word64 FFI.DwOp_shl] DWOp A.DW_OP_Shra -> [Word64 FFI.DwOp_shra] DWOp A.DW_OP_Shr -> [Word64 FFI.DwOp_shr] DWOp A.DW_OP_StackValue -> [Word64 FFI.DwOp_stack_value] DWOp A.DW_OP_Swap -> [Word64 FFI.DwOp_swap] DWOp A.DW_OP_XDeref -> [Word64 FFI.DwOp_xderef] DWOp A.DW_OP_Xor -> [Word64 FFI.DwOp_xor] instance DecodeM DecodeAST [Maybe A.Metadata] (Ptr FFI.MDNode) where decodeM :: HasCallStack => Ptr MDNode -> DecodeAST [Maybe Metadata] decodeM 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 :: HasCallStack => Ptr MDValue -> DecodeAST Operand decodeM = Ptr Value -> DecodeAST Operand forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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 :: HasCallStack => Ptr MetadataAsVal -> DecodeAST Metadata decodeM = Ptr Metadata -> DecodeAST Metadata forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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 decodeMDNode :: Ptr FFI.MDNode -> DecodeAST (Either String A.MDNode) decodeMDNode :: Ptr MDNode -> DecodeAST (Either String MDNode) decodeMDNode Ptr MDNode p = DecodeAST (Either String MDNode) -> DecodeAST (Either String MDNode) forall a. DecodeAST a -> DecodeAST a forall (m :: * -> *) a. ScopeAnyCont m => m a -> m a scopeAnyCont (DecodeAST (Either String MDNode) -> DecodeAST (Either String MDNode)) -> DecodeAST (Either String MDNode) -> DecodeAST (Either String MDNode) forall a b. (a -> b) -> a -> b $ do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall a. IO a -> DecodeAST a 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 MDSubclassID [mdSubclassIdP|MDTuple|] -> (MDNode -> Either String MDNode) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM MDNode -> Either String MDNode forall a b. b -> Either a b Right (DecodeAST MDNode -> DecodeAST (Either String MDNode)) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall a b. (a -> b) -> a -> b $ [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, HasCallStack) => c -> d h decodeM Ptr MDNode p MDSubclassID [mdSubclassIdP|DIExpression|] -> (MDNode -> Either String MDNode) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM MDNode -> Either String MDNode forall a b. b -> Either a b Right (DecodeAST MDNode -> DecodeAST (Either String MDNode)) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr MDNode -> Ptr DIExpression forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DIExpression) MDSubclassID [mdSubclassIdP|DIGlobalVariableExpression|] -> (MDNode -> Either String MDNode) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM MDNode -> Either String MDNode forall a b. b -> Either a b Right (DecodeAST MDNode -> DecodeAST (Either String MDNode)) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr MDNode -> Ptr DIGlobalVariableExpression forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DIGlobalVariableExpression) MDSubclassID [mdSubclassIdP|DILocation|] -> (MDNode -> Either String MDNode) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM MDNode -> Either String MDNode forall a b. b -> Either a b Right (DecodeAST MDNode -> DecodeAST (Either String MDNode)) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr MDNode -> Ptr DILocation forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DILocation) MDSubclassID [mdSubclassIdP|DIMacro|] -> (MDNode -> Either String MDNode) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM MDNode -> Either String MDNode forall a b. b -> Either a b Right (DecodeAST MDNode -> DecodeAST (Either String MDNode)) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr MDNode -> Ptr DIMacroNode forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DIMacroNode) MDSubclassID [mdSubclassIdP|DIMacroFile|] -> (MDNode -> Either String MDNode) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM MDNode -> Either String MDNode forall a b. b -> Either a b Right (DecodeAST MDNode -> DecodeAST (Either String MDNode)) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall a b. (a -> b) -> a -> b $ 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, HasCallStack) => c -> d h decodeM (Ptr MDNode -> Ptr DIMacroNode forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DIMacroNode) MDSubclassID _ -> do Either String DINode decoded <- Ptr DINode -> DecodeAST (Either String DINode) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => c -> d h decodeM (Ptr MDNode -> Ptr DINode forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DINode) case Either String DINode decoded of (Right DINode din) -> (MDNode -> Either String MDNode) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r liftM MDNode -> Either String MDNode forall a b. b -> Either a b Right (DecodeAST MDNode -> DecodeAST (Either String MDNode)) -> DecodeAST MDNode -> DecodeAST (Either String MDNode) forall a b. (a -> b) -> a -> b $ MDNode -> DecodeAST MDNode forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (MDNode -> DecodeAST MDNode) -> MDNode -> DecodeAST MDNode forall a b. (a -> b) -> a -> b $ DINode -> MDNode A.DINode DINode din (Left String err) -> Either String MDNode -> DecodeAST (Either String MDNode) forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (Either String MDNode -> DecodeAST (Either String MDNode)) -> Either String MDNode -> DecodeAST (Either String MDNode) forall a b. (a -> b) -> a -> b $ String -> Either String MDNode forall a b. a -> Either a b Left String err instance DecodeM DecodeAST A.DIMacroNode (Ptr FFI.DIMacroNode) where decodeM :: HasCallStack => Ptr DIMacroNode -> DecodeAST DIMacroNode decodeM Ptr DIMacroNode p = do MDSubclassID sId <- IO MDSubclassID -> DecodeAST MDSubclassID forall a. IO a -> DecodeAST a 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 MDSubclassID [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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIMacro -> IO (Ptr MDString) FFI.getDIMacroValue Ptr DIMacro p') DIMacroNode -> DecodeAST DIMacroNode forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (DIMacroInfo -> Word32 -> ShortByteString -> ShortByteString -> DIMacroNode A.DIMacro DIMacroInfo macInfo Word32 line ShortByteString name ShortByteString value) MDSubclassID [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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. a -> DecodeAST a 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) MDSubclassID _ -> DecodeException -> DecodeAST DIMacroNode forall e a. Exception e => e -> DecodeAST a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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 :: HasCallStack => DIMacroNode -> EncodeAST (Ptr DIMacroNode) encodeM A.DIMacro {Word32 ShortByteString DIMacroInfo info :: DIMacroInfo line :: Word32 name :: ShortByteString value :: ShortByteString $sel:info:DIMacro :: DIMacroNode -> DIMacroInfo $sel:line:DIMacro :: DIMacroNode -> Word32 $sel:name:DIMacro :: DIMacroNode -> ShortByteString $sel:value:DIMacro :: DIMacroNode -> ShortByteString ..} = do Macinfo macInfo <- DIMacroInfo -> EncodeAST Macinfo forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM DIMacroInfo info Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr MDString value <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString value Context 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 a. IO a -> EncodeAST a 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 {[MDRef DIMacroNode] Word32 MDRef DIFile $sel:line:DIMacro :: DIMacroNode -> Word32 line :: Word32 file :: MDRef DIFile elements :: [MDRef DIMacroNode] $sel:file:DIMacro :: DIMacroNode -> MDRef DIFile $sel:elements:DIMacro :: DIMacroNode -> [MDRef DIMacroNode] ..} = do Ptr DIFile file <- MDRef DIFile -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM MDRef DIFile file TupleArray DIMacroNode elements <- [MDRef DIMacroNode] -> EncodeAST (TupleArray DIMacroNode) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM [MDRef DIMacroNode] elements Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => DIExpression -> EncodeAST (Ptr DIExpression) encodeM A.Expression {[DWOp] operands :: [DWOp] $sel:operands:Expression :: DIExpression -> [DWOp] ..} = do (CUInt, Ptr Word64) ops <- [Word64] -> EncodeAST (CUInt, Ptr Word64) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => 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 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DIExpression -> DecodeAST DIExpression decodeM Ptr DIExpression diExpr = do CUInt numElems <- IO CUInt -> DecodeAST CUInt forall a. IO a -> DecodeAST a 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 CUInt i | CUInt i CUInt -> CUInt -> Bool forall a. Ord a => a -> a -> Bool >= CUInt numElems = [DWOp] -> IO [DWOp] forall a. a -> IO a 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 Word64 FFI.DwOp_LLVM_fragment -> do String -> CUInt -> CUInt -> IO () forall {f :: * -> *}. MonadThrow f => String -> CUInt -> CUInt -> f () expectElems String "LLVM_fragment" CUInt i CUInt 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 + CUInt 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 + CUInt 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 + CUInt 3) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 FFI.DwOp_constu -> do String -> CUInt -> CUInt -> IO () forall {f :: * -> *}. MonadThrow f => String -> CUInt -> CUInt -> f () expectElems String "constu" CUInt i CUInt 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 + CUInt 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 + CUInt 2) Word64 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 + CUInt 1) Word64 FFI.DwOp_plus_uconst -> do String -> CUInt -> CUInt -> IO () forall {f :: * -> *}. MonadThrow f => String -> CUInt -> CUInt -> f () expectElems String "uconst" CUInt i CUInt 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 + CUInt 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 + CUInt 2) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 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 + CUInt 1) Word64 FFI.DwOp_bregx -> (DWOp A.DW_OP_Bregx 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 + CUInt 1) Word64 FFI.DwOp_push_object_address -> (DWOp A.DW_OP_PushObjectAddress 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 + CUInt 1) Word64 _ -> DecodeException -> IO [DWOp] forall e a. Exception e => e -> IO a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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 String name CUInt i 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 e a. Exception e => e -> f a forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a throwM (String -> DecodeException DecodeException (String "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 <> String " 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 <> String " 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 - CUInt 1)))) IO DIExpression -> DecodeAST DIExpression forall a. IO a -> DecodeAST a 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 CUInt 0) instance EncodeM EncodeAST A.DIGlobalVariableExpression (Ptr FFI.DIGlobalVariableExpression) where encodeM :: HasCallStack => DIGlobalVariableExpression -> EncodeAST (Ptr DIGlobalVariableExpression) encodeM A.GlobalVariableExpression {MDRef DIGlobalVariable MDRef DIExpression var :: MDRef DIGlobalVariable expr :: MDRef DIExpression $sel:var:GlobalVariableExpression :: DIGlobalVariableExpression -> MDRef DIGlobalVariable $sel:expr:GlobalVariableExpression :: DIGlobalVariableExpression -> MDRef DIExpression ..} = do Ptr DIGlobalVariable var <- MDRef DIGlobalVariable -> EncodeAST (Ptr DIGlobalVariable) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM MDRef DIGlobalVariable var Ptr DIExpression expr <- MDRef DIExpression -> EncodeAST (Ptr DIExpression) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM MDRef DIExpression expr Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DIGlobalVariableExpression -> DecodeAST DIGlobalVariableExpression decodeM Ptr DIGlobalVariableExpression p = do MDRef DIGlobalVariable var <- Ptr DIGlobalVariable -> DecodeAST (MDRef DIGlobalVariable) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIGlobalVariableExpression -> IO (Ptr DIExpression) FFI.getDIGlobalVariableExpressionExpression Ptr DIGlobalVariableExpression p) DIGlobalVariableExpression -> DecodeAST DIGlobalVariableExpression forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (MDRef DIGlobalVariable -> MDRef DIExpression -> DIGlobalVariableExpression A.GlobalVariableExpression MDRef DIGlobalVariable var MDRef DIExpression expr) instance EncodeM EncodeAST A.DIImportedEntity (Ptr FFI.DIImportedEntity) where encodeM :: HasCallStack => DIImportedEntity -> EncodeAST (Ptr DIImportedEntity) encodeM A.ImportedEntity {Maybe (MDRef DIFile) Maybe (MDRef DINode) Word32 ShortByteString ImportedEntityTag MDRef DIScope tag :: ImportedEntityTag name :: ShortByteString scope :: MDRef DIScope entity :: Maybe (MDRef DINode) file :: Maybe (MDRef DIFile) line :: Word32 $sel:tag:ImportedEntity :: DIImportedEntity -> ImportedEntityTag $sel:name:ImportedEntity :: DIImportedEntity -> ShortByteString $sel:scope:ImportedEntity :: DIImportedEntity -> MDRef DIScope $sel:entity:ImportedEntity :: DIImportedEntity -> Maybe (MDRef DINode) $sel:file:ImportedEntity :: DIImportedEntity -> Maybe (MDRef DIFile) $sel:line:ImportedEntity :: DIImportedEntity -> Word32 ..} = do DwTag tag <- ImportedEntityTag -> EncodeAST DwTag forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ImportedEntityTag tag Ptr DIScope scope <- MDRef DIScope -> EncodeAST (Ptr DIScope) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM MDRef DIScope scope Ptr DINode entity <- Maybe (MDRef DINode) -> EncodeAST (Ptr DINode) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => 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, HasCallStack) => h -> e c encodeM Maybe (MDRef DIFile) file Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DIImportedEntity -> DecodeAST DIImportedEntity decodeM Ptr DIImportedEntity e = do ImportedEntityTag tag <- DwTag -> DecodeAST ImportedEntityTag forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIImportedEntity -> IO (Ptr DIScope) FFI.getDIImportedEntityScope Ptr DIImportedEntity e) Either String DINode entity :: Either String A.DINode <- Ptr DINode -> DecodeAST (Either String DINode) forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => c -> d h decodeM (Ptr DINode -> DecodeAST (Either String DINode)) -> DecodeAST (Ptr DINode) -> DecodeAST (Either String DINode) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< IO (Ptr DINode) -> DecodeAST (Ptr DINode) forall a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIImportedEntity -> IO Word32 FFI.getDIImportedEntityLine Ptr DIImportedEntity e) case Either String DINode entity of (Right DINode din) -> DIImportedEntity -> DecodeAST DIImportedEntity forall a. a -> DecodeAST a 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 (MDRef DINode -> Maybe (MDRef DINode) forall a. a -> Maybe a Just (MDRef DINode -> Maybe (MDRef DINode)) -> MDRef DINode -> Maybe (MDRef DINode) forall a b. (a -> b) -> a -> b $ DINode -> MDRef DINode forall a. a -> MDRef a A.MDInline DINode din) Maybe (MDRef DIFile) file Word32 line) (Left String _) -> DIImportedEntity -> DecodeAST DIImportedEntity forall a. a -> DecodeAST a 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) forall a. Maybe a Nothing Maybe (MDRef DIFile) file Word32 line) instance EncodeM EncodeAST A.DIObjCProperty (Ptr FFI.DIObjCProperty) where encodeM :: HasCallStack => DIObjCProperty -> EncodeAST (Ptr DIObjCProperty) encodeM A.ObjCProperty {Maybe (MDRef DIType) Maybe (MDRef DIFile) Word32 ShortByteString name :: ShortByteString file :: Maybe (MDRef DIFile) line :: Word32 getterName :: ShortByteString setterName :: ShortByteString attributes :: Word32 type' :: Maybe (MDRef DIType) $sel:name:ObjCProperty :: DIObjCProperty -> ShortByteString $sel:file:ObjCProperty :: DIObjCProperty -> Maybe (MDRef DIFile) $sel:line:ObjCProperty :: DIObjCProperty -> Word32 $sel:getterName:ObjCProperty :: DIObjCProperty -> ShortByteString $sel:setterName:ObjCProperty :: DIObjCProperty -> ShortByteString $sel:attributes:ObjCProperty :: DIObjCProperty -> Word32 $sel:type':ObjCProperty :: DIObjCProperty -> Maybe (MDRef DIType) ..} = do Ptr MDString name <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString name Ptr DIFile file <- Maybe (MDRef DIFile) -> EncodeAST (Ptr DIFile) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIFile) file Ptr MDString getterName <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString getterName Ptr MDString setterName <- ShortByteString -> EncodeAST (Ptr MDString) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM ShortByteString setterName Ptr DIType type' <- Maybe (MDRef DIType) -> EncodeAST (Ptr DIType) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => h -> e c encodeM Maybe (MDRef DIType) type' Context 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 a. IO a -> EncodeAST a 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 :: HasCallStack => Ptr DIObjCProperty -> DecodeAST DIObjCProperty decodeM Ptr DIObjCProperty p = do ShortByteString name <- Ptr MDString -> DecodeAST ShortByteString forall (d :: * -> *) h c. (DecodeM d h c, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a 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 a. IO a -> DecodeAST a 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, HasCallStack) => 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 a. IO a -> DecodeAST a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (Ptr DIObjCProperty -> IO (Ptr DIType) FFI.getDIObjCPropertyType Ptr DIObjCProperty p) DIObjCProperty -> DecodeAST DIObjCProperty forall a. a -> DecodeAST a 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 :: HasCallStack => Ptr MDNode -> DecodeAST (MDRef MDNode) decodeM Ptr MDNode p = DecodeAST (MDRef MDNode) -> DecodeAST (MDRef MDNode) forall a. DecodeAST a -> DecodeAST a 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 a. IO a -> DecodeAST a 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 MDSubclassID [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, HasCallStack) => c -> d h decodeM (Ptr MDNode -> Ptr DIExpression forall a b. Ptr a -> Ptr b castPtr Ptr MDNode p :: Ptr FFI.DIExpression) MDSubclassID _ -> 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 :: HasCallStack => Ptr b -> DecodeAST (MDRef a) decodeM Ptr b p = DecodeAST (MDRef a) -> DecodeAST (MDRef a) forall a. DecodeAST a -> DecodeAST 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 :: HasCallStack => MDRef a -> EncodeAST (Ptr b) encodeM (A.MDRef 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 a m) = a -> EncodeAST (Ptr b) forall (e :: * -> *) h c. (EncodeM e h c, HasCallStack) => 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 $ \DecodeAST [Definition] continue -> do Maybe (MetadataNodeID, Ptr MDNode) mdntd <- DecodeAST (Maybe (MetadataNodeID, Ptr MDNode)) takeMetadataNodeToDefine case Maybe (MetadataNodeID, Ptr MDNode) mdntd of Maybe (MetadataNodeID, Ptr MDNode) Nothing -> [Definition] -> DecodeAST [Definition] forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure [] Just (MetadataNodeID mid, Ptr MDNode p) -> do Either String MDNode decoded <- Ptr MDNode -> DecodeAST (Either String MDNode) decodeMDNode Ptr MDNode p case Either String MDNode decoded of (Right MDNode mdn) -> (:) (Definition -> [Definition] -> [Definition]) -> DecodeAST Definition -> DecodeAST ([Definition] -> [Definition]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (Definition -> DecodeAST Definition forall a. a -> DecodeAST a forall (f :: * -> *) a. Applicative f => a -> f a pure (Definition -> DecodeAST Definition) -> Definition -> DecodeAST Definition forall a b. (a -> b) -> a -> b $ MetadataNodeID -> MDNode -> Definition A.MetadataNodeDefinition MetadataNodeID mid MDNode mdn) DecodeAST ([Definition] -> [Definition]) -> DecodeAST [Definition] -> DecodeAST [Definition] forall a b. DecodeAST (a -> b) -> DecodeAST a -> DecodeAST b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> DecodeAST [Definition] continue (Left String _) -> DecodeAST [Definition] continue