diff options
author | David Waern <davve@dtek.chalmers.se> | 2007-11-08 01:45:13 +0000 |
---|---|---|
committer | David Waern <davve@dtek.chalmers.se> | 2007-11-08 01:45:13 +0000 |
commit | 6b31cd2c50be41cb3b7e3f85f6b0485dcbcae9f3 (patch) | |
tree | ec095e5ee5af254d8fc9e13b9e1e37d025694ccc /src/Haddock/InterfaceFile.hs | |
parent | f2c7dd08b7c38462db80fc23cc7a8afa437e074e (diff) |
Synch loading of names from .haddock files with GHC's name cache
Diffstat (limited to 'src/Haddock/InterfaceFile.hs')
-rw-r--r-- | src/Haddock/InterfaceFile.hs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/Haddock/InterfaceFile.hs b/src/Haddock/InterfaceFile.hs index 93d6fe4c..92dc371b 100644 --- a/src/Haddock/InterfaceFile.hs +++ b/src/Haddock/InterfaceFile.hs @@ -115,9 +115,9 @@ writeInterfaceFile filename iface = do writeBinMem bh filename return () - -readInterfaceFile :: FilePath -> IO (Either String InterfaceFile) -readInterfaceFile filename = do + +readInterfaceFile :: Session -> FilePath -> IO (Either String InterfaceFile) +readInterfaceFile session filename = do bh <- readBinMem filename magic <- get bh @@ -140,17 +140,21 @@ readInterfaceFile filename = do -- initialise the user-data field of bh ud <- newReadState dict bh <- return (setUserData bh ud) - + + -- get the name cache from the ghc session + ncRef <- withSession session (return . hsc_NC) + nc <- readIORef ncRef + -- get the symbol table symtab_p <- get bh data_p <- tellBin bh seekBin bh symtab_p - -- (construct an empty name cache) - u <- mkSplitUniqSupply 'a' -- ?? - let nc = initNameCache u [] - (_, symtab) <- getSymbolTable bh nc + (nc', symtab) <- getSymbolTable bh nc seekBin bh data_p + -- write back the new name cache + writeIORef ncRef nc' + -- set the symbol table let ud = getUserData bh bh <- return $! setUserData bh ud{ud_symtab = symtab} |