diff --git a/src/plugins/System/Plugins/Env.hs b/src/plugins/System/Plugins/Env.hs index 7d8362f..93dcb73 100644 --- a/src/plugins/System/Plugins/Env.hs +++ b/src/plugins/System/Plugins/Env.hs @@ -48,14 +48,14 @@ module System.Plugins.Env ( #include "../../../../config.h" -import System.Plugins.LoadTypes +import System.Plugins.LoadTypes (Module) import System.Plugins.PackageAPI {- everything -} #if CABAL == 1 || __GLASGOW_HASKELL__ >= 604 import System.Plugins.ParsePkgConfCabal( parsePkgConf ) #else import System.Plugins.ParsePkgConfLite ( parsePkgConf ) #endif -import System.Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix, dllSuf ) +import System.Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix ) import Data.IORef ( writeIORef, readIORef, newIORef, IORef() ) import Data.Maybe ( isJust, isNothing ) @@ -102,8 +102,8 @@ lookupFM = flip M.lookup -- safely ignore that request. We're in the IO monad anyway, so we can -- add some extra state of our own. -- --- The state is a FiniteMap String Bool (a hash of package/object names --- to whether they have been loaded or not). +-- The state is a FiniteMap String (Module,Int) (a hash of package/object names +-- to Modules and how many times they've been loaded). -- -- It also contains the package.conf information, so that if there is a -- package dependency we can find it correctly, even if it has a diff --git a/src/plugins/System/Plugins/Load.hs b/src/plugins/System/Plugins/Load.hs index 103b20a..0a2329d 100644 --- a/src/plugins/System/Plugins/Load.hs +++ b/src/plugins/System/Plugins/Load.hs @@ -289,7 +289,7 @@ dynload2 obj incpath pkgconfs sym = do ------------------------------------------------------------------------ -- --- | unload a module (not it's dependencies) +-- | unload a module (not its dependencies) -- we have the dependencies, so cascaded unloading is possible -- -- once you unload it, you can't 'load' it again, you have to 'reload' @@ -298,6 +298,11 @@ dynload2 obj incpath pkgconfs sym = do unload :: Module -> IO () unload m = rmModuleDeps m >> unloadObj m +------------------------------------------------------------------------ +-- +-- | unload a module and its dependencies +-- we have the dependencies, so cascaded unloading is possible +-- unloadAll :: Module -> IO () unloadAll m = do moduleDeps <- fmap (fromMaybe []) (getModuleDeps m) rmModuleDeps m