+-- | This module converts the C form of the LLVM IR into a fully
+-- referential Haskell version of the IR.  The translation is slightly
+-- lossy around integral types in some cases, as Haskell Ints do not
+-- have the same range as C ints.  In the vast majority of cases this
+-- should not really be an issue, but it is possible to lose
+-- information.  If it is an issue it can be changed.
 {-# LANGUAGE ForeignFunctionInterface, DeriveDataTypeable, RankNTypes #-}
 module Data.LLVM.Private.Parser.Unmarshal ( parseLLVMBitcodeFile ) where
 


-- | Parse the named file into an FFI-friendly representation of an
-- LLVM module.
{#fun marshalLLVM { `String' } -> `ModulePtr' id #}

-- | Free all of the resources allocated by 'marshalLLVM'
{#fun disposeCModule { id `ModulePtr' } -> `()' #}

                           , visitedTypes :: Set IntPtr
                           , localId :: Int
                           , constantTranslationDepth :: Int
                           , stringCache :: Map ByteString ByteString
                           }
emptyState :: IORef Int -> IORef Int -> KnotState
emptyState r1 r2 =
  KnotState { valueMap = M.empty
            , typeMap = M.empty
            , idSrc = r1
            , typeIdSrc = r2
            , result = Nothing
            , visitedTypes = S.empty
            , localId = 0
            , constantTranslationDepth = 0
            , stringCache = M.empty
            }

nextId :: KnotMonad Int
nextId = do
