{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module HiFileParser
( Interface(..)
, List(..)
, Dictionary(..)
, Module(..)
, Usage(..)
, Dependencies(..)
, getInterface
, fromFile
) where
import Control.Monad (replicateM, replicateM_, when)
import Data.Binary (Word64,Word32,Word8)
import qualified Data.Binary.Get as G (Get, Decoder (..), bytesRead,
getByteString, getInt64be,
getWord32be, getWord64be,
getWord8, lookAhead,
runGetIncremental, skip)
import Data.Bool (bool)
import Data.ByteString.Lazy.Internal (defaultChunkSize)
import Data.Char (chr)
import Data.Functor (void, ($>))
import Data.Maybe (catMaybes)
#if !MIN_VERSION_base(4,11,0)
import Data.Semigroup ((<>))
#endif
import qualified Data.Vector as V
import qualified Data.Text.Encoding as Text
import qualified Data.Text as Text
import GHC.IO.IOMode (IOMode (..))
import Numeric (showHex)
import RIO.ByteString as B (ByteString, hGetSome, null)
import RIO (Int64,Generic, NFData)
import System.IO (withBinaryFile)
import Data.Bits (FiniteBits(..),testBit,
unsafeShiftL,(.|.),clearBit,
complement)
import Control.Monad.State (StateT, evalStateT, get, gets,
lift, modify)
import qualified Debug.Trace
newtype IfaceGetState = IfaceGetState
{ IfaceGetState -> IsBoot
useLEB128 :: Bool
}
data IfaceVersion
= V7021
| V7041
| V7061
| V7081
| V8001
| V8021
| V8041
| V8061
| V8101
| V9001
| V9041
| V9045
| V9081
deriving (Int -> IfaceVersion -> ShowS
[IfaceVersion] -> ShowS
IfaceVersion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IfaceVersion] -> ShowS
$cshowList :: [IfaceVersion] -> ShowS
show :: IfaceVersion -> String
$cshow :: IfaceVersion -> String
showsPrec :: Int -> IfaceVersion -> ShowS
$cshowsPrec :: Int -> IfaceVersion -> ShowS
Show,IfaceVersion -> IfaceVersion -> IsBoot
forall a. (a -> a -> IsBoot) -> (a -> a -> IsBoot) -> Eq a
/= :: IfaceVersion -> IfaceVersion -> IsBoot
$c/= :: IfaceVersion -> IfaceVersion -> IsBoot
== :: IfaceVersion -> IfaceVersion -> IsBoot
$c== :: IfaceVersion -> IfaceVersion -> IsBoot
Eq,Eq IfaceVersion
IfaceVersion -> IfaceVersion -> IsBoot
IfaceVersion -> IfaceVersion -> Ordering
IfaceVersion -> IfaceVersion -> IfaceVersion
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> IsBoot)
-> (a -> a -> IsBoot)
-> (a -> a -> IsBoot)
-> (a -> a -> IsBoot)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: IfaceVersion -> IfaceVersion -> IfaceVersion
$cmin :: IfaceVersion -> IfaceVersion -> IfaceVersion
max :: IfaceVersion -> IfaceVersion -> IfaceVersion
$cmax :: IfaceVersion -> IfaceVersion -> IfaceVersion
>= :: IfaceVersion -> IfaceVersion -> IsBoot
$c>= :: IfaceVersion -> IfaceVersion -> IsBoot
> :: IfaceVersion -> IfaceVersion -> IsBoot
$c> :: IfaceVersion -> IfaceVersion -> IsBoot
<= :: IfaceVersion -> IfaceVersion -> IsBoot
$c<= :: IfaceVersion -> IfaceVersion -> IsBoot
< :: IfaceVersion -> IfaceVersion -> IsBoot
$c< :: IfaceVersion -> IfaceVersion -> IsBoot
compare :: IfaceVersion -> IfaceVersion -> Ordering
$ccompare :: IfaceVersion -> IfaceVersion -> Ordering
Ord,Int -> IfaceVersion
IfaceVersion -> Int
IfaceVersion -> [IfaceVersion]
IfaceVersion -> IfaceVersion
IfaceVersion -> IfaceVersion -> [IfaceVersion]
IfaceVersion -> IfaceVersion -> IfaceVersion -> [IfaceVersion]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: IfaceVersion -> IfaceVersion -> IfaceVersion -> [IfaceVersion]
$cenumFromThenTo :: IfaceVersion -> IfaceVersion -> IfaceVersion -> [IfaceVersion]
enumFromTo :: IfaceVersion -> IfaceVersion -> [IfaceVersion]
$cenumFromTo :: IfaceVersion -> IfaceVersion -> [IfaceVersion]
enumFromThen :: IfaceVersion -> IfaceVersion -> [IfaceVersion]
$cenumFromThen :: IfaceVersion -> IfaceVersion -> [IfaceVersion]
enumFrom :: IfaceVersion -> [IfaceVersion]
$cenumFrom :: IfaceVersion -> [IfaceVersion]
fromEnum :: IfaceVersion -> Int
$cfromEnum :: IfaceVersion -> Int
toEnum :: Int -> IfaceVersion
$ctoEnum :: Int -> IfaceVersion
pred :: IfaceVersion -> IfaceVersion
$cpred :: IfaceVersion -> IfaceVersion
succ :: IfaceVersion -> IfaceVersion
$csucc :: IfaceVersion -> IfaceVersion
Enum)
type Get a = StateT IfaceGetState G.Get a
enableDebug :: Bool
enableDebug :: IsBoot
enableDebug = IsBoot
False
traceGet :: String -> Get ()
traceGet :: String -> Get ()
traceGet String
s
| IsBoot
enableDebug = forall a. String -> a -> a
Debug.Trace.trace String
s (forall (m :: * -> *) a. Monad m => a -> m a
return ())
| IsBoot
otherwise = forall (m :: * -> *) a. Monad m => a -> m a
return ()
traceShow :: Show a => String -> Get a -> Get a
traceShow :: forall a. Show a => String -> Get a -> Get a
traceShow String
s Get a
g
| IsBoot -> IsBoot
not IsBoot
enableDebug = Get a
g
| IsBoot
otherwise = do
a
a <- Get a
g
String -> Get ()
traceGet (String
s forall a. [a] -> [a] -> [a]
++ String
" " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show a
a)
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
runGetIncremental :: Get a -> G.Decoder a
runGetIncremental :: forall a. Get a -> Decoder a
runGetIncremental Get a
g = forall a. Get a -> Decoder a
G.runGetIncremental (forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT Get a
g IfaceGetState
emptyState)
where
emptyState :: IfaceGetState
emptyState = IsBoot -> IfaceGetState
IfaceGetState IsBoot
False
getByteString :: Int -> Get ByteString
getByteString :: Int -> Get ModuleName
getByteString Int
i = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Int -> Get ModuleName
G.getByteString Int
i)
getWord8 :: Get Word8
getWord8 :: Get Word8
getWord8 = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Word8
G.getWord8
bytesRead :: Get Int64
bytesRead :: Get Int64
bytesRead = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Int64
G.bytesRead
skip :: Int -> Get ()
skip :: Int -> Get ()
skip = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Get ()
G.skip
uleb :: Get a -> Get a -> Get a
uleb :: forall a. Get a -> Get a -> Get a
uleb Get a
f Get a
g = do
IsBoot
c <- forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets IfaceGetState -> IsBoot
useLEB128
if IsBoot
c then Get a
f else Get a
g
getWord32be :: Get Word32
getWord32be :: Get Word32
getWord32be = forall a. Get a -> Get a -> Get a
uleb forall a. (Integral a, FiniteBits a) => Get a
getULEB128 (forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Word32
G.getWord32be)
getWord64be :: Get Word64
getWord64be :: Get Word64
getWord64be = forall a. Get a -> Get a -> Get a
uleb forall a. (Integral a, FiniteBits a) => Get a
getULEB128 (forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Word64
G.getWord64be)
getInt64be :: Get Int64
getInt64be :: Get Int64
getInt64be = forall a. Get a -> Get a -> Get a
uleb forall a. (Integral a, FiniteBits a) => Get a
getSLEB128 (forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Int64
G.getInt64be)
lookAhead :: Get b -> Get b
lookAhead :: forall b. Get b -> Get b
lookAhead Get b
g = do
IfaceGetState
s <- forall s (m :: * -> *). MonadState s m => m s
get
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Get a -> Get a
G.lookAhead (forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT Get b
g IfaceGetState
s)
getPtr :: Get Word32
getPtr :: Get Word32
getPtr = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift Get Word32
G.getWord32be
type IsBoot = Bool
type ModuleName = ByteString
newtype List a = List
{ forall a. List a -> [a]
unList :: [a]
} deriving newtype (Int -> List a -> ShowS
[List a] -> ShowS
List a -> String
forall a. Show a => Int -> List a -> ShowS
forall a. Show a => [List a] -> ShowS
forall a. Show a => List a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [List a] -> ShowS
$cshowList :: forall a. Show a => [List a] -> ShowS
show :: List a -> String
$cshow :: forall a. Show a => List a -> String
showsPrec :: Int -> List a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> List a -> ShowS
Show, List a -> ()
forall a. NFData a => List a -> ()
forall a. (a -> ()) -> NFData a
rnf :: List a -> ()
$crnf :: forall a. NFData a => List a -> ()
NFData)
newtype Dictionary = Dictionary
{ Dictionary -> Vector ModuleName
unDictionary :: V.Vector ByteString
} deriving newtype (Int -> Dictionary -> ShowS
[Dictionary] -> ShowS
Dictionary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Dictionary] -> ShowS
$cshowList :: [Dictionary] -> ShowS
show :: Dictionary -> String
$cshow :: Dictionary -> String
showsPrec :: Int -> Dictionary -> ShowS
$cshowsPrec :: Int -> Dictionary -> ShowS
Show, Dictionary -> ()
forall a. (a -> ()) -> NFData a
rnf :: Dictionary -> ()
$crnf :: Dictionary -> ()
NFData)
newtype Module = Module
{ Module -> ModuleName
unModule :: ModuleName
} deriving newtype (Int -> Module -> ShowS
[Module] -> ShowS
Module -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Module] -> ShowS
$cshowList :: [Module] -> ShowS
show :: Module -> String
$cshow :: Module -> String
showsPrec :: Int -> Module -> ShowS
$cshowsPrec :: Int -> Module -> ShowS
Show, Module -> ()
forall a. (a -> ()) -> NFData a
rnf :: Module -> ()
$crnf :: Module -> ()
NFData)
newtype Usage = Usage
{ Usage -> String
unUsage :: FilePath
} deriving newtype (Int -> Usage -> ShowS
[Usage] -> ShowS
Usage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Usage] -> ShowS
$cshowList :: [Usage] -> ShowS
show :: Usage -> String
$cshow :: Usage -> String
showsPrec :: Int -> Usage -> ShowS
$cshowsPrec :: Int -> Usage -> ShowS
Show, Usage -> ()
forall a. (a -> ()) -> NFData a
rnf :: Usage -> ()
$crnf :: Usage -> ()
NFData)
data Dependencies = Dependencies
{ Dependencies -> List (ModuleName, IsBoot)
dmods :: List (ModuleName, IsBoot)
, Dependencies -> List (ModuleName, IsBoot)
dpkgs :: List (ModuleName, Bool)
, Dependencies -> List Module
dorphs :: List Module
, Dependencies -> List Module
dfinsts :: List Module
, Dependencies -> List ModuleName
dplugins :: List ModuleName
} deriving (Int -> Dependencies -> ShowS
[Dependencies] -> ShowS
Dependencies -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Dependencies] -> ShowS
$cshowList :: [Dependencies] -> ShowS
show :: Dependencies -> String
$cshow :: Dependencies -> String
showsPrec :: Int -> Dependencies -> ShowS
$cshowsPrec :: Int -> Dependencies -> ShowS
Show, forall x. Rep Dependencies x -> Dependencies
forall x. Dependencies -> Rep Dependencies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Dependencies x -> Dependencies
$cfrom :: forall x. Dependencies -> Rep Dependencies x
Generic)
instance NFData Dependencies
data Interface = Interface
{ Interface -> Dependencies
deps :: Dependencies
, Interface -> List Usage
usage :: List Usage
} deriving (Int -> Interface -> ShowS
[Interface] -> ShowS
Interface -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Interface] -> ShowS
$cshowList :: [Interface] -> ShowS
show :: Interface -> String
$cshow :: Interface -> String
showsPrec :: Int -> Interface -> ShowS
$cshowsPrec :: Int -> Interface -> ShowS
Show, forall x. Rep Interface x -> Interface
forall x. Interface -> Rep Interface x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Interface x -> Interface
$cfrom :: forall x. Interface -> Rep Interface x
Generic)
instance NFData Interface
withBlockPrefix :: Get a -> Get a
withBlockPrefix :: forall b. Get b -> Get b
withBlockPrefix Get a
f = Get Word32
getPtr forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get a
f
getBool :: Get Bool
getBool :: Get IsBoot
getBool = forall a. Enum a => Int -> a
toEnum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word8
getWord8
getString :: Get String
getString :: Get String
getString = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Int -> Char
chr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Integral a, Num b) => a -> b
fromIntegral) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. List a -> [a]
unList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList Get Word32
getWord32be
getMaybe :: Get a -> Get (Maybe a)
getMaybe :: forall a. Get a -> Get (Maybe a)
getMaybe Get a
f = forall a. a -> a -> IsBoot -> a
bool (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing) (forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get a
f) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Get IsBoot
getBool
getList :: Get a -> Get (List a)
getList :: forall a. Get a -> Get (List a)
getList Get a
f = do
IsBoot
use_uleb <- forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets IfaceGetState -> IsBoot
useLEB128
if IsBoot
use_uleb
then do
Int64
l <- (forall a. (Integral a, FiniteBits a) => Get a
getSLEB128 :: Get Int64)
forall a. [a] -> List a
List forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
l) Get a
f
else do
Word8
i <- Get Word8
getWord8
Word32
l <-
if Word8
i forall a. Eq a => a -> a -> IsBoot
== Word8
0xff
then Get Word32
getWord32be
else forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
i :: Word32)
forall a. [a] -> List a
List forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
l) Get a
f
getTuple :: Get a -> Get b -> Get (a, b)
getTuple :: forall a b. Get a -> Get b -> Get (a, b)
getTuple Get a
f Get b
g = (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get a
f forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get b
g
getByteStringSized :: Get ByteString
getByteStringSized :: Get ModuleName
getByteStringSized = do
Int64
size <- Get Int64
getInt64be
Int -> Get ModuleName
getByteString (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
size)
getDictionary :: Int -> Get Dictionary
getDictionary :: Int -> Get Dictionary
getDictionary Int
ptr = do
Int64
offset <- Get Int64
bytesRead
Int -> Get ()
skip forall a b. (a -> b) -> a -> b
$ Int
ptr forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
offset
Int
size <- forall a b. (Integral a, Num b) => a -> b
fromIntegral forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Int64
getInt64be
String -> Get ()
traceGet (String
"Dictionary size: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Int
size)
Dictionary
dict <- Vector ModuleName -> Dictionary
Dictionary forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. Monad m => Int -> m a -> m (Vector a)
V.replicateM Int
size Get ModuleName
getByteStringSized
String -> Get ()
traceGet (String
"Dictionary: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Dictionary
dict)
forall (m :: * -> *) a. Monad m => a -> m a
return Dictionary
dict
getCachedBS :: Dictionary -> Get ByteString
getCachedBS :: Dictionary -> Get ModuleName
getCachedBS Dictionary
d = forall {a} {f :: * -> *}.
(Integral a, MonadFail f, Show a) =>
a -> f ModuleName
go forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a. Show a => String -> Get a -> Get a
traceShow String
"Dict index:" Get Word32
getWord32be
where
go :: a -> f ModuleName
go a
i =
case Dictionary -> Vector ModuleName
unDictionary Dictionary
d forall a. Vector a -> Int -> Maybe a
V.!? forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i of
Just ModuleName
bs -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ModuleName
bs
Maybe ModuleName
Nothing -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid dictionary index: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show a
i
getFP' :: Get String
getFP' :: Get String
getFP' = do
Word64
x <- Get Word64
getWord64be
Word64
y <- Get Word64
getWord64be
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. (Integral a, Show a) => a -> ShowS
showHex Word64
x (forall a. (Integral a, Show a) => a -> ShowS
showHex Word64
y String
""))
getFP :: Get ()
getFP :: Get ()
getFP = forall (f :: * -> *) a. Functor f => f a -> f ()
void Get String
getFP'
getInterface721 :: Dictionary -> Get Interface
getInterface721 :: Dictionary -> Get Interface
getInterface721 Dictionary
d = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
2 Get ()
getFP
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
Dependencies -> List Usage -> Interface
Interface forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Dependencies
getDependencies forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ModuleName -> Module
Module forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ModuleName
getCachedBS Dictionary
d)
getDependencies :: Get Dependencies
getDependencies =
forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$
List (ModuleName, IsBoot)
-> List (ModuleName, IsBoot)
-> List Module
-> List Module
-> List ModuleName
-> Dependencies
Dependencies forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. [a] -> List a
List [])
getUsage :: Get (List Usage)
getUsage = forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$ forall a. [a] -> List a
List forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Maybe a] -> [a]
catMaybes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. List a -> [a]
unList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get ()
getFP) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Word8
usageType
getInterface741 :: Dictionary -> Get Interface
getInterface741 :: Dictionary -> Get Interface
getInterface741 Dictionary
d = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
3 Get ()
getFP
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
Dependencies -> List Usage -> Interface
Interface forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Dependencies
getDependencies forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ModuleName -> Module
Module forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ModuleName
getCachedBS Dictionary
d)
getDependencies :: Get Dependencies
getDependencies =
forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$
List (ModuleName, IsBoot)
-> List (ModuleName, IsBoot)
-> List Module
-> List Module
-> List ModuleName
-> Dependencies
Dependencies forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. [a] -> List a
List [])
getUsage :: Get (List Usage)
getUsage = forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$ forall a. [a] -> List a
List forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Maybe a] -> [a]
catMaybes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. List a -> [a]
unList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get ()
getFP) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
2 -> forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get Word64
getWord64be forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get Word64
getWord64be
Word8
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Word8
usageType
getInterface761 :: Dictionary -> Get Interface
getInterface761 :: Dictionary -> Get Interface
getInterface761 Dictionary
d = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
3 Get ()
getFP
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
Dependencies -> List Usage -> Interface
Interface forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Dependencies
getDependencies forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ModuleName -> Module
Module forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ModuleName
getCachedBS Dictionary
d)
getDependencies :: Get Dependencies
getDependencies =
forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$
List (ModuleName, IsBoot)
-> List (ModuleName, IsBoot)
-> List Module
-> List Module
-> List ModuleName
-> Dependencies
Dependencies forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. [a] -> List a
List [])
getUsage :: Get (List Usage)
getUsage = forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$ forall a. [a] -> List a
List forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Maybe a] -> [a]
catMaybes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. List a -> [a]
unList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get ()
getFP) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
2 -> forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get Word64
getWord64be forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get Word64
getWord64be
Word8
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Word8
usageType
getInterface781 :: Dictionary -> Get Interface
getInterface781 :: Dictionary -> Get Interface
getInterface781 Dictionary
d = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
3 Get ()
getFP
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
Dependencies -> List Usage -> Interface
Interface forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Dependencies
getDependencies forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ModuleName -> Module
Module forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ModuleName
getCachedBS Dictionary
d)
getDependencies :: Get Dependencies
getDependencies =
forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$
List (ModuleName, IsBoot)
-> List (ModuleName, IsBoot)
-> List Module
-> List Module
-> List ModuleName
-> Dependencies
Dependencies forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. [a] -> List a
List [])
getUsage :: Get (List Usage)
getUsage = forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$ forall a. [a] -> List a
List forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Maybe a] -> [a]
catMaybes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. List a -> [a]
unList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get ()
getFP) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
2 -> forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get ()
getFP
Word8
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Word8
usageType
getInterface801 :: Dictionary -> Get Interface
getInterface801 :: Dictionary -> Get Interface
getInterface801 Dictionary
d = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word8
getWord8
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
3 Get ()
getFP
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
Dependencies -> List Usage -> Interface
Interface forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Dependencies
getDependencies forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ModuleName -> Module
Module forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ModuleName
getCachedBS Dictionary
d)
getDependencies :: Get Dependencies
getDependencies =
forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$
List (ModuleName, IsBoot)
-> List (ModuleName, IsBoot)
-> List Module
-> List Module
-> List ModuleName
-> Dependencies
Dependencies forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. [a] -> List a
List [])
getUsage :: Get (List Usage)
getUsage = forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$ forall a. [a] -> List a
List forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Maybe a] -> [a]
catMaybes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. List a -> [a]
unList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get ()
getFP) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
2 -> forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get ()
getFP
Word8
3 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Word8
usageType
getInterface821 :: Dictionary -> Get Interface
getInterface821 :: Dictionary -> Get Interface
getInterface821 Dictionary
d = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall a. Get a -> Get (Maybe a)
getMaybe StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word8
getWord8
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
3 Get ()
getFP
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
Dependencies -> List Usage -> Interface
Interface forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Dependencies
getDependencies forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = do
Word8
idType <- Get Word8
getWord8
case Word8
idType of
Word8
0 -> forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ Dictionary -> Get ModuleName
getCachedBS Dictionary
d
Word8
_ ->
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$
Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) StateT IfaceGetState Get Module
getModule)
ModuleName -> Module
Module forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ModuleName
getCachedBS Dictionary
d
getDependencies :: Get Dependencies
getDependencies =
forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$
List (ModuleName, IsBoot)
-> List (ModuleName, IsBoot)
-> List Module
-> List Module
-> List ModuleName
-> Dependencies
Dependencies forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. [a] -> List a
List [])
getUsage :: Get (List Usage)
getUsage = forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$ forall a. [a] -> List a
List forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Maybe a] -> [a]
catMaybes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. List a -> [a]
unList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get ()
getFP) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
2 -> forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get ()
getFP
Word8
3 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Word8
usageType
getInterface841 :: Dictionary -> Get Interface
getInterface841 :: Dictionary -> Get Interface
getInterface841 Dictionary
d = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall a. Get a -> Get (Maybe a)
getMaybe StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word8
getWord8
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
5 Get ()
getFP
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
Dependencies -> List Usage -> Interface
Interface forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Dependencies
getDependencies forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = do
Word8
idType <- Get Word8
getWord8
case Word8
idType of
Word8
0 -> forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ Dictionary -> Get ModuleName
getCachedBS Dictionary
d
Word8
_ ->
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$
Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) StateT IfaceGetState Get Module
getModule)
ModuleName -> Module
Module forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ModuleName
getCachedBS Dictionary
d
getDependencies :: Get Dependencies
getDependencies =
forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$
List (ModuleName, IsBoot)
-> List (ModuleName, IsBoot)
-> List Module
-> List Module
-> List ModuleName
-> Dependencies
Dependencies forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. [a] -> List a
List [])
getUsage :: Get (List Usage)
getUsage = forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$ forall a. [a] -> List a
List forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Maybe a] -> [a]
catMaybes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. List a -> [a]
unList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get ()
getFP) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
2 -> forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get ()
getFP
Word8
3 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Word8
usageType
getInterface861 :: Dictionary -> Get Interface
getInterface861 :: Dictionary -> Get Interface
getInterface861 Dictionary
d = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall a. Get a -> Get (Maybe a)
getMaybe StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word8
getWord8
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
6 Get ()
getFP
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
Dependencies -> List Usage -> Interface
Interface forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Dependencies
getDependencies forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get (List Usage)
getUsage
where
getModule :: StateT IfaceGetState Get Module
getModule = do
Word8
idType <- Get Word8
getWord8
case Word8
idType of
Word8
0 -> forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ Dictionary -> Get ModuleName
getCachedBS Dictionary
d
Word8
_ ->
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$
Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) StateT IfaceGetState Get Module
getModule)
ModuleName -> Module
Module forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Dictionary -> Get ModuleName
getCachedBS Dictionary
d
getDependencies :: Get Dependencies
getDependencies =
forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$
List (ModuleName, IsBoot)
-> List (ModuleName, IsBoot)
-> List Module
-> List Module
-> List ModuleName
-> Dependencies
Dependencies forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get IsBoot
getBool) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
forall a. Get a -> Get (List a)
getList (Dictionary -> Get ModuleName
getCachedBS Dictionary
d)
getUsage :: Get (List Usage)
getUsage = forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$ forall a. [a] -> List a
List forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Maybe a] -> [a]
catMaybes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. List a -> [a]
unList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- Get Word8
getWord8
case Word8
usageType of
Word8
0 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
1 ->
Dictionary -> Get ModuleName
getCachedBS Dictionary
d forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Dictionary -> Get ModuleName
getCachedBS Dictionary
d) Get ()
getFP) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Get IsBoot
getBool forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
2 -> forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Usage
Usage forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get String
getString forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Get ()
getFP
Word8
3 -> StateT IfaceGetState Get Module
getModule forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ()
getFP forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> forall a. Maybe a
Nothing
Word8
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Word8
usageType
getInterfaceRecent :: IfaceVersion -> Dictionary -> Get Interface
getInterfaceRecent :: IfaceVersion -> Dictionary -> Get Interface
getInterfaceRecent IfaceVersion
version Dictionary
d = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall a. Show a => String -> Get a -> Get a
traceShow String
"Module:" StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall a. Show a => String -> Get a -> Get a
traceShow String
"Sig:" forall a b. (a -> b) -> a -> b
$ forall a. Get a -> Get (Maybe a)
getMaybe StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word8
getWord8
Get ()
getFP
Get ()
getFP
Get ()
getFP
Get ()
getFP
Get ()
getFP
Get ()
getFP
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
Dependencies
ddeps <- forall a. Show a => String -> Get a -> Get a
traceShow String
"Dependencies:" Get Dependencies
getDependencies
List Usage
dusage <- forall a. Show a => String -> Get a -> Get a
traceShow String
"Usage:" Get (List Usage)
getUsage
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Dependencies -> List Usage -> Interface
Interface Dependencies
ddeps List Usage
dusage)
where
since :: IfaceVersion -> f () -> f ()
since IfaceVersion
v = forall (f :: * -> *). Applicative f => IsBoot -> f () -> f ()
when (IfaceVersion
version forall a. Ord a => a -> a -> IsBoot
>= IfaceVersion
v)
getFastString :: Get ModuleName
getFastString = Dictionary -> Get ModuleName
getCachedBS Dictionary
d
getModule :: StateT IfaceGetState Get Module
getModule = do
Word8
idType <- forall a. Show a => String -> Get a -> Get a
traceShow String
"Unit type:" Get Word8
getWord8
case Word8
idType of
Word8
0 -> forall (f :: * -> *) a. Functor f => f a -> f ()
void Get ModuleName
getFastString
Word8
1 ->
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$
Get ModuleName
getFastString forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple Get ModuleName
getFastString StateT IfaceGetState Get Module
getModule)
Word8
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid unit type: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Word8
idType
ModuleName -> Module
Module forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get ModuleName
getFastString
getDependencies :: Get Dependencies
getDependencies =
forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$ do
if IfaceVersion
version forall a. Ord a => a -> a -> IsBoot
>= IfaceVersion
V9041
then do
List (ModuleName, IsBoot)
direct_mods <- forall a. Show a => String -> Get a -> Get a
traceShow String
"direct_mods:" forall a b. (a -> b) -> a -> b
$ forall a. Get a -> Get (List a)
getList (Get ModuleName
getFastString forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a b. Get a -> Get b -> Get (a, b)
getTuple Get ModuleName
getFastString Get IsBoot
getBool)
List ModuleName
direct_pkgs <- forall a. Get a -> Get (List a)
getList Get ModuleName
getFastString
List ModuleName
plugin_pkgs <- forall a. Get a -> Get (List a)
getList Get ModuleName
getFastString
let all_pkgs :: [ModuleName]
all_pkgs = forall a. List a -> [a]
unList List ModuleName
plugin_pkgs forall a. [a] -> [a] -> [a]
++ forall a. List a -> [a]
unList List ModuleName
direct_pkgs
List ModuleName
trusted_pkgs <- forall a. Get a -> Get (List a)
getList Get ModuleName
getFastString
let trusted :: ModuleName -> IsBoot
trusted ModuleName
u = ModuleName
u forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> IsBoot
`elem` forall a. List a -> [a]
unList List ModuleName
trusted_pkgs
let all_pkgs_trust :: List (ModuleName, IsBoot)
all_pkgs_trust = forall a. [a] -> List a
List (forall a b. [a] -> [b] -> [(a, b)]
zip [ModuleName]
all_pkgs (forall a b. (a -> b) -> [a] -> [b]
map ModuleName -> IsBoot
trusted [ModuleName]
all_pkgs))
List Module
_sig_mods <- forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule
List (ModuleName, IsBoot)
_boot_mods <- forall a. Get a -> Get (List a)
getList (Get ModuleName
getFastString forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall a b. Get a -> Get b -> Get (a, b)
getTuple Get ModuleName
getFastString Get IsBoot
getBool)
List Module
dep_orphs <- forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule
List Module
dep_finsts <- forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule
let dep_plgins :: List a
dep_plgins = forall a. [a] -> List a
List []
forall (f :: * -> *) a. Applicative f => a -> f a
pure (List (ModuleName, IsBoot)
-> List (ModuleName, IsBoot)
-> List Module
-> List Module
-> List ModuleName
-> Dependencies
Dependencies List (ModuleName, IsBoot)
direct_mods List (ModuleName, IsBoot)
all_pkgs_trust List Module
dep_orphs List Module
dep_finsts forall {a}. List a
dep_plgins)
else do
List (ModuleName, IsBoot)
dep_mods <- forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple Get ModuleName
getFastString Get IsBoot
getBool)
List (ModuleName, IsBoot)
dep_pkgs <- forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple Get ModuleName
getFastString Get IsBoot
getBool)
List Module
dep_orphs <- forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule
List Module
dep_finsts <- forall a. Get a -> Get (List a)
getList StateT IfaceGetState Get Module
getModule
List ModuleName
dep_plgins <- forall a. Get a -> Get (List a)
getList Get ModuleName
getFastString
forall (f :: * -> *) a. Applicative f => a -> f a
pure (List (ModuleName, IsBoot)
-> List (ModuleName, IsBoot)
-> List Module
-> List Module
-> List ModuleName
-> Dependencies
Dependencies List (ModuleName, IsBoot)
dep_mods List (ModuleName, IsBoot)
dep_pkgs List Module
dep_orphs List Module
dep_finsts List ModuleName
dep_plgins)
getUsage :: Get (List Usage)
getUsage = forall b. Get b -> Get b
withBlockPrefix forall a b. (a -> b) -> a -> b
$ forall a. [a] -> List a
List forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Maybe a] -> [a]
catMaybes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. List a -> [a]
unList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get (List a)
getList Get (Maybe Usage)
go
where
go :: Get (Maybe Usage)
go :: Get (Maybe Usage)
go = do
Word8
usageType <- forall a. Show a => String -> Get a -> Get a
traceShow String
"Usage type:" Get Word8
getWord8
case Word8
usageType of
Word8
0 -> do
forall (f :: * -> *) a. Functor f => f a -> f ()
void (forall a. Show a => String -> Get a -> Get a
traceShow String
"Module:" StateT IfaceGetState Get Module
getModule)
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get ()
getFP
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing
Word8
1 -> do
forall (f :: * -> *) a. Functor f => f a -> f ()
void (forall a. Show a => String -> Get a -> Get a
traceShow String
"Home module:" Get ModuleName
getFastString)
forall {f :: * -> *}. Applicative f => IfaceVersion -> f () -> f ()
since IfaceVersion
V9045 forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Functor f => f a -> f ()
void Get ModuleName
getFastString
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get ()
getFP
forall (f :: * -> *) a. Functor f => f a -> f ()
void (forall a. Get a -> Get (Maybe a)
getMaybe Get ()
getFP)
forall (f :: * -> *) a. Functor f => f a -> f ()
void (forall a. Get a -> Get (List a)
getList (forall a b. Get a -> Get b -> Get (a, b)
getTuple (Get Word8
getWord8 forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Get ModuleName
getFastString) Get ()
getFP))
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get IsBoot
getBool
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing
Word8
2 -> do
String
file_path <- forall a. Show a => String -> Get a -> Get a
traceShow String
"File:" forall a b. (a -> b) -> a -> b
$ if IfaceVersion
version forall a. Ord a => a -> a -> IsBoot
>= IfaceVersion
V9081
then Text -> String
Text.unpack forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleName -> Text
Text.decodeUtf8 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get ModuleName
getFastString
else Get String
getString
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall a. Show a => String -> Get a -> Get a
traceShow String
"FP:" Get String
getFP'
forall {f :: * -> *}. Applicative f => IfaceVersion -> f () -> f ()
since IfaceVersion
V9041 forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall a. Show a => String -> Get a -> Get a
traceShow String
"File label:" (forall a. Get a -> Get (Maybe a)
getMaybe Get String
getString)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall a. a -> Maybe a
Just (String -> Usage
Usage String
file_path))
Word8
3 -> do
forall (f :: * -> *) a. Functor f => f a -> f ()
void StateT IfaceGetState Get Module
getModule
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get ()
getFP
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing
Word8
4 | IfaceVersion
version forall a. Ord a => a -> a -> IsBoot
>= IfaceVersion
V9041 -> do
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get ModuleName
getFastString
forall {f :: * -> *}. Applicative f => IfaceVersion -> f () -> f ()
since IfaceVersion
V9045 forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Functor f => f a -> f ()
void Get ModuleName
getFastString
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get ()
getFP
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing
Word8
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid usageType: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Word8
usageType
getInterface :: Get Interface
getInterface :: Get Interface
getInterface = do
let enableLEB128 :: Get ()
enableLEB128 = forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (\IfaceGetState
c -> IfaceGetState
c { useLEB128 :: IsBoot
useLEB128 = IsBoot
True})
Word32
magic <- forall b. Get b -> Get b
lookAhead Get Word32
getWord32be forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Word32
0x1face -> Get Word32
getWord32be
Word32
0x1face64 -> Get Word32
getWord32be
Word32
m -> do
forall b. Get b -> Get b
lookAhead (Get ()
enableLEB128 forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Get Word32
getWord32be) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Word32
0x1face -> Get ()
enableLEB128 forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Get Word32
getWord32be
Word32
0x1face64 -> Get ()
enableLEB128 forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Get Word32
getWord32be
Word32
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid magic: " forall a. Semigroup a => a -> a -> a
<> forall a. (Integral a, Show a) => a -> ShowS
showHex Word32
m String
""
String -> Get ()
traceGet (String
"Magic: " forall a. [a] -> [a] -> [a]
++ forall a. (Integral a, Show a) => a -> ShowS
showHex Word32
magic String
"")
case Word32
magic of
Word32
0x1face -> do
Word32
e <- forall b. Get b -> Get b
lookAhead Get Word32
getWord32be
if Word32
e forall a. Eq a => a -> a -> IsBoot
== Word32
0
then forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word32
getWord32be
else Get ()
enableLEB128
Word32
0x1face64 -> do
Word64
e <- forall b. Get b -> Get b
lookAhead Get Word64
getWord64be
if Word64
e forall a. Eq a => a -> a -> IsBoot
== Word64
0
then forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word64
getWord64be
else Get ()
enableLEB128
Word32
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
String
version <- Get String
getString
String -> Get ()
traceGet (String
"Version: " forall a. [a] -> [a] -> [a]
++ String
version)
let !ifaceVersion :: IfaceVersion
ifaceVersion
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"9081" = IfaceVersion
V9081
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"9045" = IfaceVersion
V9045
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"9041" = IfaceVersion
V9041
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"9001" = IfaceVersion
V9001
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"8101" = IfaceVersion
V8101
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"8061" = IfaceVersion
V8061
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"8041" = IfaceVersion
V8041
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"8021" = IfaceVersion
V8021
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"8001" = IfaceVersion
V8001
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"7081" = IfaceVersion
V7081
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"7061" = IfaceVersion
V7061
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"7041" = IfaceVersion
V7041
| String
version forall a. Ord a => a -> a -> IsBoot
>= String
"7021" = IfaceVersion
V7021
| IsBoot
otherwise = forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String
"Unsupported version: " forall a. Semigroup a => a -> a -> a
<> String
version
String
way <- Get String
getString
String -> Get ()
traceGet (String
"Ways: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show String
way)
forall (f :: * -> *). Applicative f => IsBoot -> f () -> f ()
when (IfaceVersion
ifaceVersion forall a. Ord a => a -> a -> IsBoot
>= IfaceVersion
V9041) forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Functor f => f a -> f ()
void Get ()
getFP
forall (f :: * -> *). Applicative f => IsBoot -> f () -> f ()
when (IfaceVersion
ifaceVersion forall a. Ord a => a -> a -> IsBoot
>= IfaceVersion
V9001) forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word32
getPtr
Word32
dictPtr <- Get Word32
getPtr
String -> Get ()
traceGet (String
"Dict ptr: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Word32
dictPtr)
Dictionary
dict <- forall b. Get b -> Get b
lookAhead forall a b. (a -> b) -> a -> b
$ Int -> Get Dictionary
getDictionary forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
dictPtr
forall (f :: * -> *) a. Functor f => f a -> f ()
void Get Word32
getPtr
case IfaceVersion
ifaceVersion of
IfaceVersion
V9081 -> IfaceVersion -> Dictionary -> Get Interface
getInterfaceRecent IfaceVersion
ifaceVersion Dictionary
dict
IfaceVersion
V9045 -> IfaceVersion -> Dictionary -> Get Interface
getInterfaceRecent IfaceVersion
ifaceVersion Dictionary
dict
IfaceVersion
V9041 -> IfaceVersion -> Dictionary -> Get Interface
getInterfaceRecent IfaceVersion
ifaceVersion Dictionary
dict
IfaceVersion
V9001 -> IfaceVersion -> Dictionary -> Get Interface
getInterfaceRecent IfaceVersion
ifaceVersion Dictionary
dict
IfaceVersion
V8101 -> IfaceVersion -> Dictionary -> Get Interface
getInterfaceRecent IfaceVersion
ifaceVersion Dictionary
dict
IfaceVersion
V8061 -> Dictionary -> Get Interface
getInterface861 Dictionary
dict
IfaceVersion
V8041 -> Dictionary -> Get Interface
getInterface841 Dictionary
dict
IfaceVersion
V8021 -> Dictionary -> Get Interface
getInterface821 Dictionary
dict
IfaceVersion
V8001 -> Dictionary -> Get Interface
getInterface801 Dictionary
dict
IfaceVersion
V7081 -> Dictionary -> Get Interface
getInterface781 Dictionary
dict
IfaceVersion
V7061 -> Dictionary -> Get Interface
getInterface761 Dictionary
dict
IfaceVersion
V7041 -> Dictionary -> Get Interface
getInterface741 Dictionary
dict
IfaceVersion
V7021 -> Dictionary -> Get Interface
getInterface721 Dictionary
dict
fromFile :: FilePath -> IO (Either String Interface)
fromFile :: String -> IO (Either String Interface)
fromFile String
fp = forall r. String -> IOMode -> (Handle -> IO r) -> IO r
withBinaryFile String
fp IOMode
ReadMode forall {f :: * -> *}.
MonadIO f =>
Handle -> f (Either String Interface)
go
where
go :: Handle -> f (Either String Interface)
go Handle
h =
let feed :: Decoder b -> f (Either String b)
feed (G.Done ModuleName
_ Int64
_ b
iface) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right b
iface
feed (G.Fail ModuleName
_ Int64
_ String
msg) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left String
msg
feed (G.Partial Maybe ModuleName -> Decoder b
k) = do
ModuleName
chunk <- forall (m :: * -> *). MonadIO m => Handle -> Int -> m ModuleName
hGetSome Handle
h Int
defaultChunkSize
Decoder b -> f (Either String b)
feed forall a b. (a -> b) -> a -> b
$ Maybe ModuleName -> Decoder b
k forall a b. (a -> b) -> a -> b
$ if ModuleName -> IsBoot
B.null ModuleName
chunk then forall a. Maybe a
Nothing else forall a. a -> Maybe a
Just ModuleName
chunk
in forall {f :: * -> *} {b}.
MonadIO f =>
Decoder b -> f (Either String b)
feed forall a b. (a -> b) -> a -> b
$ forall a. Get a -> Decoder a
runGetIncremental Get Interface
getInterface
getULEB128 :: forall a. (Integral a, FiniteBits a) => Get a
getULEB128 :: forall a. (Integral a, FiniteBits a) => Get a
getULEB128 =
Int -> a -> Get a
go Int
0 a
0
where
go :: Int -> a -> Get a
go :: Int -> a -> Get a
go Int
shift a
w = do
Word8
b <- Get Word8
getWord8
let !hasMore :: IsBoot
hasMore = forall a. Bits a => a -> Int -> IsBoot
testBit Word8
b Int
7
let !val :: a
val = a
w forall a. Bits a => a -> a -> a
.|. (forall a. Bits a => a -> Int -> a
clearBit (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
b) Int
7 forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
shift) :: a
if IsBoot
hasMore
then do
Int -> a -> Get a
go (Int
shiftforall a. Num a => a -> a -> a
+Int
7) a
val
else
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$! a
val
getSLEB128 :: forall a. (Integral a, FiniteBits a) => Get a
getSLEB128 :: forall a. (Integral a, FiniteBits a) => Get a
getSLEB128 = do
(a
val,Int
shift,IsBoot
signed) <- Int -> a -> Get (a, Int, IsBoot)
go Int
0 a
0
if IsBoot
signed IsBoot -> IsBoot -> IsBoot
&& (Int
shift forall a. Ord a => a -> a -> IsBoot
< forall b. FiniteBits b => b -> Int
finiteBitSize a
val )
then forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$! ((forall a. Bits a => a -> a
complement a
0 forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
shift) forall a. Bits a => a -> a -> a
.|. a
val)
else forall (m :: * -> *) a. Monad m => a -> m a
return a
val
where
go :: Int -> a -> Get (a,Int,Bool)
go :: Int -> a -> Get (a, Int, IsBoot)
go Int
shift a
val = do
Word8
byte <- Get Word8
getWord8
let !byteVal :: a
byteVal = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Bits a => a -> Int -> a
clearBit Word8
byte Int
7) :: a
let !val' :: a
val' = a
val forall a. Bits a => a -> a -> a
.|. (a
byteVal forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
shift)
let !more :: IsBoot
more = forall a. Bits a => a -> Int -> IsBoot
testBit Word8
byte Int
7
let !shift' :: Int
shift' = Int
shiftforall a. Num a => a -> a -> a
+Int
7
if IsBoot
more
then Int -> a -> Get (a, Int, IsBoot)
go Int
shift' a
val'
else do
let !signed :: IsBoot
signed = forall a. Bits a => a -> Int -> IsBoot
testBit Word8
byte Int
6
forall (m :: * -> *) a. Monad m => a -> m a
return (a
val',Int
shift',IsBoot
signed)