Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions hi-file-parser.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.37.0.
-- This file has been generated from package.yaml by hpack version 0.38.2.
--
-- see: https://github.com/sol/hpack

Expand Down Expand Up @@ -39,16 +39,18 @@ extra-source-files:
test-files/iface/x64/ghc9028/X.hi
test-files/iface/x64/ghc9044/Main.hi
test-files/iface/x64/ghc9044/X.hi
test-files/iface/x64/ghc9047/Main.hi
test-files/iface/x64/ghc9047/X.hi
test-files/iface/x64/ghc9066/Main.hi
test-files/iface/x64/ghc9066/X.hi
test-files/iface/x64/ghc9083/Main.hi
test-files/iface/x64/ghc9083/X.hi
test-files/iface/x64/ghc9101/Main.hi
test-files/iface/x64/ghc9101/X.hi
test-files/iface/x64/ghc9120/Main.hi
test-files/iface/x64/ghc9120/X.hi
test-files/iface/x64/ghc9048/Main.hi
test-files/iface/x64/ghc9048/X.hi
test-files/iface/x64/ghc9067/Main.hi
test-files/iface/x64/ghc9067/X.hi
test-files/iface/x64/ghc9084/Main.hi
test-files/iface/x64/ghc9084/X.hi
test-files/iface/x64/ghc9102/Main.hi
test-files/iface/x64/ghc9102/X.hi
test-files/iface/x64/ghc9122/Main.hi
test-files/iface/x64/ghc9122/X.hi
test-files/iface/x64/ghc9140/Main.hi
test-files/iface/x64/ghc9140/X.hi

source-repository head
type: git
Expand Down
22 changes: 12 additions & 10 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ extra-source-files:
- test-files/iface/x64/ghc9028/X.hi
- test-files/iface/x64/ghc9044/Main.hi
- test-files/iface/x64/ghc9044/X.hi
- test-files/iface/x64/ghc9047/Main.hi
- test-files/iface/x64/ghc9047/X.hi
- test-files/iface/x64/ghc9066/Main.hi
- test-files/iface/x64/ghc9066/X.hi
- test-files/iface/x64/ghc9083/Main.hi
- test-files/iface/x64/ghc9083/X.hi
- test-files/iface/x64/ghc9101/Main.hi
- test-files/iface/x64/ghc9101/X.hi
- test-files/iface/x64/ghc9120/Main.hi
- test-files/iface/x64/ghc9120/X.hi
- test-files/iface/x64/ghc9048/Main.hi
- test-files/iface/x64/ghc9048/X.hi
- test-files/iface/x64/ghc9067/Main.hi
- test-files/iface/x64/ghc9067/X.hi
- test-files/iface/x64/ghc9084/Main.hi
- test-files/iface/x64/ghc9084/X.hi
- test-files/iface/x64/ghc9102/Main.hi
- test-files/iface/x64/ghc9102/X.hi
- test-files/iface/x64/ghc9122/Main.hi
- test-files/iface/x64/ghc9122/X.hi
- test-files/iface/x64/ghc9140/Main.hi
- test-files/iface/x64/ghc9140/X.hi

# Metadata used when publishing your package
synopsis: Parser for GHC's hi files
Expand Down
32 changes: 16 additions & 16 deletions src/HiFileParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ module HiFileParser
) where

import Control.Monad ( replicateM, replicateM_, when )
import Control.Monad.State
( StateT, evalStateT, get, gets, lift, modify )
import Data.Binary ( Word32, Word64, Word8)
import qualified Data.Binary.Get as G
( Decoder (..), Get, bytesRead, getByteString, getInt64be
, getWord32be, getWord64be, getWord8, lookAhead
, runGetIncremental, skip
)
import Data.Bits
( FiniteBits (..), (.|.), clearBit, complement, testBit
, unsafeShiftL
)
import Data.Bool ( bool )
import Data.ByteString.Lazy.Internal ( defaultChunkSize )
import Data.Char ( chr )
Expand All @@ -37,21 +43,15 @@ 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 qualified Data.Text.Encoding as Text
import qualified Data.Vector as V
import qualified Debug.Trace
import GHC.IO.IOMode ( IOMode (..) )
import Numeric ( showHex )
import RIO.ByteString as B ( ByteString, hGetSome, null )
import RIO ( Generic, Int64, NFData )
import RIO.ByteString as B ( ByteString, hGetSome, null )
import System.IO ( withBinaryFile )
import Data.Bits
( FiniteBits (..), (.|.), clearBit, complement, testBit
, unsafeShiftL
)
import Control.Monad.State
( StateT, evalStateT, get, gets, lift, modify )
import qualified Debug.Trace

newtype IfaceGetState = IfaceGetState
{ useLEB128 :: Bool -- ^ Use LEB128 encoding for numbers
Expand All @@ -71,7 +71,7 @@ data IfaceVersion
| V9041
| V9045
| V9081
| V9120
| V9121
| V9140
deriving (Eq, Enum, Ord, Show)
-- careful, the Ord matters!
Expand Down Expand Up @@ -865,8 +865,8 @@ getInterface = do
traceGet ("Version: " ++ version)

let !ifaceVersion
| version >= "9140" = V9140
| version >= "9120" = V9120
| version >= "9140" = V9140 -- Support GHC 9.14.1-alpha1
| version >= "9121" = V9121
| version >= "9081" = V9081
| version >= "9045" = V9045
| version >= "9041" = V9041
Expand All @@ -893,7 +893,7 @@ getInterface = do
when (ifaceVersion >= V9001) skipPtr

-- dict_ptr
dictPtr <- if ifaceVersion >= V9120 -- 9.12 uses relative pointers
dictPtr <- if ifaceVersion >= V9121 -- 9.12 uses relative pointers
then getRelPtr
else getPtr
traceGet ("Dict ptr: " ++ show dictPtr)
Expand All @@ -905,11 +905,11 @@ getInterface = do
skipPtr

-- IfaceType table
when (ifaceVersion >= V9120) skipPtr
when (ifaceVersion >= V9121) skipPtr

case ifaceVersion of
V9140 -> getInterfaceRecent ifaceVersion dict
V9120 -> getInterfaceRecent ifaceVersion dict
V9121 -> getInterfaceRecent ifaceVersion dict
V9081 -> getInterfaceRecent ifaceVersion dict
V9045 -> getInterfaceRecent ifaceVersion dict
V9041 -> getInterfaceRecent ifaceVersion dict
Expand Down
Loading