From 6b31cd2c50be41cb3b7e3f85f6b0485dcbcae9f3 Mon Sep 17 00:00:00 2001 From: David Waern Date: Thu, 8 Nov 2007 01:45:13 +0000 Subject: Synch loading of names from .haddock files with GHC's name cache --- src/Haddock/InterfaceFile.hs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/Haddock') 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} -- cgit v1.2.3