Allow users of the GHC library to specify which packages have already been loaded.
authorLemmih <lemmih@gmail.com>
Mon, 27 Mar 2006 03:09:50 +0000 (03:09 +0000)
committerLemmih <lemmih@gmail.com>
Mon, 27 Mar 2006 03:09:50 +0000 (03:09 +0000)
This is pretty important when using the linker/bytecode-compiler from binaries
other than GHCi.

ghc/compiler/ghci/Linker.lhs

index 15786f4..44efac8 100644 (file)
@@ -16,7 +16,8 @@ necessary.
 {-# OPTIONS -optc-DNON_POSIX_SOURCE -#include "Linker.h" #-}
 
 module Linker ( HValue, showLinkerState,
-               linkExpr, unload, extendLinkEnv, 
+               linkExpr, unload, extendLinkEnv,
+                extendLoadedPkgs,
                linkPackages,
        ) where
 
@@ -47,7 +48,7 @@ import ErrUtils         ( debugTraceMsg )
 -- Standard libraries
 import Control.Monad   ( when, filterM, foldM )
 
-import Data.IORef      ( IORef, readIORef, writeIORef )
+import Data.IORef      ( IORef, readIORef, writeIORef, modifyIORef )
 import Data.List       ( partition, nub )
 
 import System.IO       ( putStr, putStrLn, hPutStrLn, stderr, fixIO )
@@ -124,6 +125,10 @@ emptyPLS dflags = PersistentLinkerState {
 \end{code}
 
 \begin{code}
+extendLoadedPkgs :: [PackageId] -> IO ()
+extendLoadedPkgs pkgs
+    = modifyIORef v_PersistentLinkerState (\s -> s{pkgs_loaded = pkgs ++ pkgs_loaded s})
+
 extendLinkEnv :: [(Name,HValue)] -> IO ()
 -- Automatically discards shadowed bindings
 extendLinkEnv new_bindings